~ubuntu-branches/ubuntu/intrepid/xulrunner-1.9/intrepid

« back to all changes in this revision

Viewing changes to mozilla/embedding/components/printingui/src/mac/nsPrintingPromptService.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack, Alexander Sack, Fabien Tassin
  • Date: 2008-02-13 11:47:21 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080213114721-7om0mgzngvuk9czv
Tags: 1.9~b3+nobinonly-0ubuntu1
* release FIREFOX_3_0b3_RELEASE

[ Alexander Sack ]
* submit patch that ships xpcshell to bugzilla
  - rename debian/patches/ship_xpcshell.patch =>
           debian/patches/bz410617_att295212_ship_xpcshell.patch
  - update debian/patches/series
* fix tooltip in epiphany: previously displayed out of screen bounds
  (LP: #37507)
  - add debian/patches/bz233371_att297343_fix_outofscreen_embed_tooltip.patch
  - update debian/patches/series
* use default upstream gcc tweaks for improved performance - especially of the
  javascript engine
  - update debian/rules
* update global extension/plugin patch to apply cleanly against latest code
  - update debian/patches/bzXXX_gre_extension_plugin_support.patch
* fix pyxpcom build failure introduced by recent commit
  - add debian/patches/bzXXX_fix_pyxpcom_build_failure.patch
  - update debian/patches/series
* add distro independent global install locations for extensions,
  /usr/lib/mozilla/extensions and /usr/share/mozilla/extensions
  - update debian/xulrunner-1.9.dirs
* support embedded tarball layout when either there is a *.tar.bz2 in orig tarball
  or if DEBIAN_MOZCLIENT_EMBEDDED is not unset (you will need this to produce embedded
  tarballs during |get-orig-source|
  - update debian/rules
* bump minimum libnss3-dev build requirements to >= 3.12.0~1.9b3
  - update debian/control
* bump minimum libnspr4-dev build requirements to >= 4.7.0~1.9b3
  - update debian/control

[ Fabien Tassin ]
* Drop patches applied upstream
  - drop debian/patches/bz410617_att295212_ship_xpcshell.patch
  - drop debian/patches/bz404634_att294921.patch
  - drop debian/patches/bz386610_python2.5_ftbfs_amd64.patch
  - drop debian/patches/bz373918_att295042.patch
  - drop debian/patches/bz408062_unstable_pc.patch
  - drop debian/patches/bz384304_fix_recursive_symlinks.patch
  - update debian/patches/series
* Refresh diverged patches:
  - update debian/patches/bzXXX_pc_honour_system_nspr_nss.patch
  - update debian/patches/rename_venkman_addon.patch
  - update debian/patches/bz344818_cairo_xrender.patch
* Install links for all .so libs in the -dev package
  - update debian/patches/dont_install_so_in_dev.patch
* Bump gtk requirement to 2.12 as per Mozilla bug 412432
  - update debian/control
* Add #DEBHELPER# token to postinst/prerm scripts
  - update debian/xulrunner-1.9.{postinst,prerm}
* Install previously missed libdbusservice.so
  - update debian/xulrunner-1.9.install
* Update venkman patch to also rename locales
  - update debian/patches/rename_venkman_addon.patch
* Bump requirement for system cairo to >= 1.5.8 as we now need
  the newly added cairo_path_extents()
  - update debian/rules
* Include mozilla-devscripts file using -include so ifneq could be omitted
  - update debian/rules
* Fix missing .so symlinks regression
  - update debian/patches/dont_install_so_in_dev.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
 
/* ***** BEGIN LICENSE BLOCK *****
3
 
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
 
 *
5
 
 * The contents of this file are subject to the Mozilla Public License Version
6
 
 * 1.1 (the "License"); you may not use this file except in compliance with
7
 
 * the License. You may obtain a copy of the License at
8
 
 * http://www.mozilla.org/MPL/
9
 
 *
10
 
 * Software distributed under the License is distributed on an "AS IS" basis,
11
 
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
 
 * for the specific language governing rights and limitations under the
13
 
 * License.
14
 
 *
15
 
 * The Original Code is mozilla.org code.
16
 
 *
17
 
 * The Initial Developer of the Original Code is
18
 
 * Netscape Communications Corporation.
19
 
 * Portions created by the Initial Developer are Copyright (C) 1998
20
 
 * the Initial Developer. All Rights Reserved.
21
 
 *
22
 
 * Contributor(s):
23
 
 *   Rod Spears <rods@netscape.com>
24
 
 *   Don Cone <dcone@netscape.com>
25
 
 *   Conrad Carlen <ccarlen@netscape.com>
26
 
 *
27
 
 * Alternatively, the contents of this file may be used under the terms of
28
 
 * either the GNU General Public License Version 2 or later (the "GPL"), or
29
 
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30
 
 * in which case the provisions of the GPL or the LGPL are applicable instead
31
 
 * of those above. If you wish to allow use of your version of this file only
32
 
 * under the terms of either the GPL or the LGPL, and not to allow others to
33
 
 * use your version of this file under the terms of the MPL, indicate your
34
 
 * decision by deleting the provisions above and replace them with the notice
35
 
 * and other provisions required by the GPL or the LGPL. If you do not delete
36
 
 * the provisions above, a recipient may use your version of this file under
37
 
 * the terms of any one of the MPL, the GPL or the LGPL.
38
 
 *
39
 
 * ***** END LICENSE BLOCK ***** */
40
 
 
41
 
#include "nsPrintingPromptService.h"
42
 
 
43
 
#include "nsCOMPtr.h"
44
 
 
45
 
#include "nsIPrintingPromptService.h"
46
 
#include "nsIFactory.h"
47
 
#include "nsIDOMWindow.h"
48
 
#include "nsReadableUtils.h"
49
 
#include "nsIEmbeddingSiteWindow.h"
50
 
#include "nsIServiceManager.h"
51
 
#include "nsIWebBrowserChrome.h"
52
 
#include "nsIWindowWatcher.h"
53
 
#include "nsIPrintSettingsMac.h"
54
 
#include "nsComponentResContext.h"
55
 
#include "nsWatchTask.h"
56
 
 
57
 
// Printing Progress Includes
58
 
#include "nsPrintProgress.h"
59
 
#include "nsPrintProgressParams.h"
60
 
#include "nsIWebProgressListener.h"
61
 
 
62
 
// OS Includes
63
 
#include <Printing.h>
64
 
#include <Dialogs.h>
65
 
#include <Appearance.h>
66
 
#include <Resources.h>
67
 
 
68
 
// Constants
69
 
static const char *kPrintProgressDialogURL = "chrome://global/content/printProgress.xul";
70
 
 
71
 
//-----------------------------------------------------------------------------
72
 
// Dialog Extension Code
73
 
//-----------------------------------------------------------------------------
74
 
 
75
 
// Types and Defines
76
 
 
77
 
// items to support the additional items for the dialog
78
 
#define DITL_ADDITIONS  128
79
 
 
80
 
enum {
81
 
  ePrintSelectionCheckboxID = 1,
82
 
  ePrintFrameAsIsCheckboxID,
83
 
  ePrintSelectedFrameCheckboxID,
84
 
  ePrintAllFramesCheckboxID,
85
 
  eDrawFrameID
86
 
};
87
 
 
88
 
typedef struct dialog_item_struct {
89
 
  Handle  handle;       // handle or procedure pointer for this item */
90
 
  Rect    bounds;         // display rectangle for this item */
91
 
  char    type;           // item type - 1 */
92
 
  char    data[1];        // length byte of data */
93
 
} DialogItem, *DialogItemPtr, **DialogItemHandle;
94
 
 
95
 
typedef struct append_item_list_struct {
96
 
  short max_index;      // number of items - 1 
97
 
  DialogItem  items[1]; // first item in the array
98
 
} ItemList, *ItemListPtr, **ItemListHandle;
99
 
 
100
 
// Static Variables - used by the dialog callbacks - no choice but globals
101
 
 
102
 
//static pascal TPPrDlg   MyJobDlgInit(THPrint);        // Our extention to PrJobInit
103
 
static TPPrDlg          gPrtJobDialog;                 // pointer to job dialog 
104
 
static long             prFirstItem;                  // our first item in the extended dialog
105
 
static PItemUPP         prPItemProc;                  // store the old item handler here
106
 
static PRBool           gPrintSelection;
107
 
static PItemUPP         gPrtJobDialogItemProc;
108
 
static UserItemUPP      gDrawListUPP = nsnull;
109
 
static nsIPrintSettings *gPrintSettings = nsnull;
110
 
 
111
 
// Routines
112
 
 
113
 
/** -------------------------------------------------------
114
 
 *  this is a drawing procedure for the user item.. this draws a box around the frameset radio buttons
115
 
 *  @update   dc 12/02/98
116
 
 */
117
 
static pascal void MyBBoxDraw(WindowPtr theWindow, short aItemNo)
118
 
{
119
 
  short   itemType;
120
 
  Rect    itemBox;
121
 
  Handle  itemH;
122
 
 
123
 
  ::GetDialogItem((DialogPtr)gPrtJobDialog, prFirstItem + eDrawFrameID-1, &itemType, &itemH, &itemBox);
124
 
  
125
 
  // use appearance if possible
126
 
  if ((long)DrawThemeSecondaryGroup != kUnresolvedCFragSymbolAddress)
127
 
    ::DrawThemeSecondaryGroup(&itemBox, kThemeStateActive);
128
 
  else
129
 
    ::FrameRect(&itemBox);
130
 
}
131
 
 
132
 
 
133
 
/** -------------------------------------------------------
134
 
 *  this is the dialog hook, takes care of setting the dialog items
135
 
 *  @update   dc 12/02/98
136
 
 */
137
 
static pascal void MyJobItems(DialogPtr aDialog, short aItemNo)
138
 
{
139
 
short   myItem, firstItem, i, itemType;
140
 
short   value;
141
 
Rect    itemBox;
142
 
Handle  itemH;
143
 
 
144
 
  firstItem = prFirstItem;
145
 
  
146
 
  myItem = aItemNo-firstItem+1;
147
 
  if (myItem>0) {
148
 
    switch (myItem) {
149
 
      case ePrintSelectionCheckboxID:
150
 
        ::GetDialogItem(aDialog, firstItem, &itemType, &itemH, &itemBox);
151
 
        gPrintSelection = !gPrintSelection;
152
 
        ::SetControlValue((ControlHandle)itemH, gPrintSelection);
153
 
        break;
154
 
 
155
 
      case ePrintFrameAsIsCheckboxID:
156
 
      case ePrintSelectedFrameCheckboxID:
157
 
      case ePrintAllFramesCheckboxID:
158
 
        for (i=ePrintFrameAsIsCheckboxID; i<=ePrintAllFramesCheckboxID; i++){
159
 
          ::GetDialogItem(aDialog, firstItem+i-1, &itemType, &itemH, &itemBox);
160
 
          ::SetControlValue((ControlHandle)itemH, i==myItem);
161
 
        }
162
 
        break;
163
 
        
164
 
      default:
165
 
        break;
166
 
    }
167
 
  } else {
168
 
    // chain to standard Item handler
169
 
    CallPItemProc(prPItemProc, aDialog, aItemNo);
170
 
    
171
 
    if (((TPPrDlg)aDialog)->fDone)
172
 
    {
173
 
      // cleanup and set the print options to what we want
174
 
      if (gPrintSettings)
175
 
      {
176
 
        // print selection
177
 
        ::GetDialogItem(aDialog, firstItem+ePrintSelectionCheckboxID-1, &itemType, &itemH, &itemBox);
178
 
        value = ::GetControlValue((ControlHandle)itemH);
179
 
        if (1==value){
180
 
          gPrintSettings->SetPrintRange(nsIPrintSettings::kRangeSelection);
181
 
        } else {
182
 
          gPrintSettings->SetPrintRange(nsIPrintSettings::kRangeAllPages);
183
 
        }
184
 
        
185
 
        // print frames as is
186
 
        ::GetDialogItem(aDialog, firstItem+ePrintFrameAsIsCheckboxID-1, &itemType, &itemH, &itemBox);
187
 
        value = ::GetControlValue((ControlHandle)itemH);
188
 
        if (1==value){
189
 
          gPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs);
190
 
        }
191
 
        
192
 
        // selected frame
193
 
        ::GetDialogItem(aDialog, firstItem+ePrintSelectedFrameCheckboxID-1, &itemType, &itemH, &itemBox);
194
 
        value = ::GetControlValue((ControlHandle)itemH);
195
 
        if (1==value){
196
 
          gPrintSettings->SetPrintFrameType(nsIPrintSettings::kSelectedFrame);
197
 
        }
198
 
        
199
 
        // print all frames
200
 
        ::GetDialogItem(aDialog, firstItem+ePrintAllFramesCheckboxID-1, &itemType, &itemH, &itemBox);
201
 
        value = ::GetControlValue((ControlHandle)itemH);
202
 
        if (1==value){
203
 
          gPrintSettings->SetPrintFrameType(nsIPrintSettings::kEachFrameSep);
204
 
        }        
205
 
      }
206
 
    }
207
 
  }
208
 
}
209
 
 
210
 
/** -------------------------------------------------------
211
 
 *  Append DITL items to the dialog
212
 
 *  @update   dc 05/04/2001
213
 
 */
214
 
static PRInt32  AppendToDialog(TPPrDlg  aDialog, PRInt32  aDITLID)
215
 
{
216
 
  short           firstItem;
217
 
  ItemListHandle  myAppendDITLH;
218
 
  ItemListHandle  dlg_Item_List;
219
 
 
220
 
  dlg_Item_List = (ItemListHandle)((DialogPeek)aDialog)->items;
221
 
  firstItem = (**dlg_Item_List).max_index+2;
222
 
 
223
 
  nsComponentResourceContext resContext;
224
 
  if (resContext.BecomeCurrent()) { // destructor restores
225
 
    myAppendDITLH = (ItemListHandle)::GetResource('DITL', aDITLID);
226
 
    NS_ASSERTION(myAppendDITLH, "Failed to get DITL items");
227
 
    if (myAppendDITLH) {
228
 
      ::AppendDITL((DialogPtr)aDialog, (Handle)myAppendDITLH, appendDITLBottom);
229
 
      ::ReleaseResource((Handle) myAppendDITLH);
230
 
    }
231
 
  }
232
 
 
233
 
  return firstItem;
234
 
}
235
 
 
236
 
 
237
 
/** -------------------------------------------------------
238
 
 *  Initialize the print dialogs additional items
239
 
 *  @update   dc 05/04/2001
240
 
 */
241
 
static pascal TPPrDlg MyJobDlgInit(THPrint aHPrint)
242
 
{
243
 
  PRInt32 i;
244
 
  short   itemType;
245
 
  Handle  itemH;
246
 
  Rect    itemBox;
247
 
  PRBool  isOn;
248
 
  PRInt16 howToEnableFrameUI = nsIPrintSettings::kFrameEnableNone;
249
 
 
250
 
  prFirstItem = AppendToDialog(gPrtJobDialog, DITL_ADDITIONS);
251
 
 
252
 
  if (gPrintSettings) {
253
 
    gPrintSettings->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn);
254
 
    gPrintSettings->GetHowToEnableFrameUI(&howToEnableFrameUI);
255
 
  }
256
 
 
257
 
  ::GetDialogItem((DialogPtr) gPrtJobDialog, prFirstItem+ePrintSelectionCheckboxID-1, &itemType, &itemH, &itemBox);
258
 
  if ( isOn ) {
259
 
    ::HiliteControl((ControlHandle)itemH, 0);
260
 
  } else {
261
 
    ::HiliteControl((ControlHandle)itemH, 255); 
262
 
  }
263
 
  
264
 
  gPrintSelection = PR_FALSE;
265
 
  ::SetControlValue((ControlHandle) itemH, gPrintSelection);
266
 
 
267
 
  if (howToEnableFrameUI == nsIPrintSettings::kFrameEnableAll) {
268
 
    for (i = ePrintFrameAsIsCheckboxID; i <= ePrintAllFramesCheckboxID; i++){
269
 
      ::GetDialogItem((DialogPtr) gPrtJobDialog, prFirstItem+i-1, &itemType, &itemH, &itemBox);
270
 
      ::SetControlValue((ControlHandle) itemH, (i==4));
271
 
      ::HiliteControl((ControlHandle)itemH, 0);
272
 
    }
273
 
  }
274
 
  else if (howToEnableFrameUI == nsIPrintSettings::kFrameEnableAsIsAndEach) {
275
 
    for (i = ePrintFrameAsIsCheckboxID; i <= ePrintAllFramesCheckboxID; i++){
276
 
      ::GetDialogItem((DialogPtr) gPrtJobDialog, prFirstItem+i-1, &itemType, &itemH, &itemBox);
277
 
      ::SetControlValue((ControlHandle) itemH, (i==4));
278
 
      if ( i == 3){
279
 
        ::HiliteControl((ControlHandle)itemH, 255);
280
 
      }
281
 
    }
282
 
  }
283
 
  else {
284
 
    for (i = ePrintFrameAsIsCheckboxID; i <= ePrintAllFramesCheckboxID; i++){
285
 
      ::GetDialogItem((DialogPtr) gPrtJobDialog, prFirstItem+i-1, &itemType, &itemH, &itemBox);
286
 
      ::SetControlValue((ControlHandle) itemH, FALSE);
287
 
      ::HiliteControl((ControlHandle)itemH, 255); 
288
 
    }
289
 
  }
290
 
  
291
 
  // attach our handler
292
 
  prPItemProc = gPrtJobDialog->pItemProc;
293
 
  gPrtJobDialog->pItemProc = gPrtJobDialogItemProc = NewPItemUPP(MyJobItems);
294
 
 
295
 
 
296
 
  // attach a draw routine
297
 
  gDrawListUPP = NewUserItemProc(MyBBoxDraw);
298
 
  ::GetDialogItem((DialogPtr)gPrtJobDialog, prFirstItem+eDrawFrameID-1, &itemType, &itemH, &itemBox);
299
 
  ::SetDialogItem((DialogPtr)gPrtJobDialog, prFirstItem+eDrawFrameID-1, itemType, (Handle)gDrawListUPP, &itemBox);
300
 
 
301
 
  return gPrtJobDialog;
302
 
}
303
 
 
304
 
 
305
 
//*****************************************************************************
306
 
// nsPrintingPromptService
307
 
//*****************************************************************************   
308
 
 
309
 
NS_IMPL_ISUPPORTS2(nsPrintingPromptService, nsIPrintingPromptService, nsIWebProgressListener)
310
 
 
311
 
nsPrintingPromptService::nsPrintingPromptService() :
312
 
    mWatcher(do_GetService(NS_WINDOWWATCHER_CONTRACTID))
313
 
{
314
 
}
315
 
 
316
 
nsPrintingPromptService::~nsPrintingPromptService()
317
 
{
318
 
}
319
 
 
320
 
nsresult nsPrintingPromptService::Init()
321
 
{
322
 
    return NS_OK;
323
 
}
324
 
 
325
 
//*****************************************************************************
326
 
// nsPrintingPromptService::nsIPrintingPromptService
327
 
//*****************************************************************************   
328
 
 
329
 
NS_IMETHODIMP 
330
 
nsPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrint *webBrowserPrint, nsIPrintSettings *printSettings)
331
 
{
332
 
  THPrint     printRecH = nsnull;    // local copy of nsIPrintSettingsMac's data
333
 
  GrafPtr     oldport;
334
 
  PDlgInitUPP theInitProcPtr;
335
 
 
336
 
        gPrintSettings = printSettings;
337
 
 
338
 
  ::GetPort(&oldport);
339
 
  
340
 
  nsresult rv;
341
 
  nsCOMPtr<nsIPrintSettingsMac> printSettingsMac(do_QueryInterface(printSettings));
342
 
  if (!printSettingsMac)
343
 
    return NS_ERROR_NO_INTERFACE;
344
 
 
345
 
  theInitProcPtr = NewPDlgInitProc(MyJobDlgInit);
346
 
  if (!theInitProcPtr)
347
 
    return NS_ERROR_FAILURE;
348
 
      
349
 
  // Get the print record from the settings
350
 
  rv = printSettingsMac->GetTHPrint(&printRecH);
351
 
  if (NS_FAILED(rv))
352
 
    return rv;
353
 
 
354
 
  // open the printing manager
355
 
  ::PrOpen();
356
 
  if (::PrError() != noErr) {
357
 
    ::DisposeHandle((Handle)printRecH);
358
 
    return NS_ERROR_FAILURE;
359
 
  }
360
 
  
361
 
  // make sure the print record is valid
362
 
  ::PrValidate(printRecH);
363
 
  if (::PrError() != noErr) {
364
 
    ::DisposeHandle((Handle)printRecH);
365
 
    ::PrClose();
366
 
    return NS_ERROR_FAILURE;
367
 
  }
368
 
  
369
 
  // get pointer to invisible job dialog box
370
 
  gPrtJobDialog = ::PrJobInit(printRecH);
371
 
  if (::PrError() != noErr) {
372
 
    ::DisposeHandle((Handle)printRecH);
373
 
    ::PrClose();
374
 
    return NS_ERROR_FAILURE;
375
 
  }
376
 
 
377
 
  // create a UUP  for the dialog init procedure
378
 
  theInitProcPtr = NewPDlgInitProc(MyJobDlgInit);
379
 
  if (!theInitProcPtr)
380
 
    return NS_ERROR_FAILURE;      
381
 
 
382
 
  nsWatchTask::GetTask().Suspend();
383
 
  ::InitCursor();
384
 
        
385
 
  // put up the print dialog
386
 
  if (::PrDlgMain(printRecH, theInitProcPtr))
387
 
  {
388
 
    // have the print record
389
 
    rv = NS_OK;
390
 
    printSettingsMac->SetTHPrint(printRecH);
391
 
  }
392
 
  else
393
 
  {
394
 
    // don't print
395
 
    ::SetPort(oldport); 
396
 
    rv = NS_ERROR_ABORT;
397
 
  }
398
 
  
399
 
  ::DisposeHandle((Handle)printRecH);
400
 
  
401
 
  // clean up our dialog routines
402
 
  DisposePItemUPP(gPrtJobDialogItemProc);
403
 
  gPrtJobDialogItemProc = nsnull;
404
 
  
405
 
  DisposePItemUPP(theInitProcPtr);
406
 
  DisposePItemUPP(gDrawListUPP);
407
 
  gDrawListUPP = nsnull;
408
 
      
409
 
  nsWatchTask::GetTask().Resume();
410
 
  return rv;
411
 
}
412
 
 
413
 
NS_IMETHODIMP 
414
 
nsPrintingPromptService::ShowProgress(nsIDOMWindow*            parent, 
415
 
                                      nsIWebBrowserPrint*      webBrowserPrint,    // ok to be null
416
 
                                      nsIPrintSettings*        printSettings,      // ok to be null
417
 
                                      nsIObserver*             openDialogObserver, // ok to be null
418
 
                                      PRBool                   isForPrinting,
419
 
                                      nsIWebProgressListener** webProgressListener,
420
 
                                      nsIPrintProgressParams** printProgressParams,
421
 
                                      PRBool*                  notifyOnOpen)
422
 
{
423
 
    NS_ENSURE_ARG(webProgressListener);
424
 
    NS_ENSURE_ARG(printProgressParams);
425
 
    NS_ENSURE_ARG(notifyOnOpen);
426
 
 
427
 
    *notifyOnOpen = PR_FALSE;
428
 
 
429
 
    nsPrintProgress* prtProgress = new nsPrintProgress();
430
 
    nsresult rv = prtProgress->QueryInterface(NS_GET_IID(nsIPrintProgress), (void**)getter_AddRefs(mPrintProgress));
431
 
    NS_ENSURE_SUCCESS(rv, rv);
432
 
 
433
 
    rv = prtProgress->QueryInterface(NS_GET_IID(nsIWebProgressListener), (void**)getter_AddRefs(mWebProgressListener));
434
 
    NS_ENSURE_SUCCESS(rv, rv);
435
 
 
436
 
    nsPrintProgressParams* prtProgressParams = new nsPrintProgressParams();
437
 
    rv = prtProgressParams->QueryInterface(NS_GET_IID(nsIPrintProgressParams), (void**)printProgressParams);
438
 
    NS_ENSURE_SUCCESS(rv, rv);
439
 
 
440
 
    if (printProgressParams) 
441
 
    {
442
 
        if (mWatcher) 
443
 
        {
444
 
            nsCOMPtr<nsIDOMWindow> active;
445
 
            mWatcher->GetActiveWindow(getter_AddRefs(active));
446
 
            nsCOMPtr<nsIDOMWindowInternal> parent(do_QueryInterface(active));
447
 
            mPrintProgress->OpenProgressDialog(parent, kPrintProgressDialogURL, *printProgressParams, openDialogObserver, notifyOnOpen);
448
 
        }
449
 
    }
450
 
 
451
 
    *webProgressListener = static_cast<nsIWebProgressListener*>(this);
452
 
    NS_ADDREF(*webProgressListener);
453
 
 
454
 
    return rv;
455
 
}
456
 
 
457
 
NS_IMETHODIMP 
458
 
nsPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent, nsIPrintSettings *printSettings, nsIObserver *aObs)
459
 
{
460
 
  nsCOMPtr<nsIPrintSettingsMac> printSettingsMac(do_QueryInterface(printSettings));
461
 
  if (!printSettingsMac)
462
 
    return NS_ERROR_NO_INTERFACE;
463
 
 
464
 
  // open the printing manager
465
 
  ::PrOpen();
466
 
  if(::PrError() != noErr)
467
 
    return NS_ERROR_FAILURE;
468
 
  
469
 
  THPrint printRecH;
470
 
  nsresult rv;
471
 
  
472
 
  rv = printSettingsMac->GetTHPrint(&printRecH);
473
 
  if (NS_FAILED(rv))
474
 
    return rv;
475
 
    
476
 
  ::PrValidate(printRecH);
477
 
  NS_ASSERTION(::PrError() == noErr, "PrValidate error");
478
 
 
479
 
  nsWatchTask::GetTask().Suspend();
480
 
  ::InitCursor();
481
 
  Boolean   dialogOK = ::PrStlDialog(printRecH);                // open up and process the style record
482
 
  nsWatchTask::GetTask().Resume();
483
 
  
484
 
  OSErr err = ::PrError();
485
 
  ::PrClose();
486
 
 
487
 
  if (dialogOK)
488
 
    rv = printSettingsMac->SetTHPrint(printRecH);
489
 
      
490
 
  if (err != noErr)
491
 
    return NS_ERROR_FAILURE;
492
 
  if (!dialogOK)
493
 
    return NS_ERROR_ABORT;
494
 
    
495
 
  return rv;
496
 
}
497
 
 
498
 
NS_IMETHODIMP 
499
 
nsPrintingPromptService::ShowPrinterProperties(nsIDOMWindow *parent, const PRUnichar *printerName, nsIPrintSettings *printSettings)
500
 
{
501
 
    return NS_ERROR_NOT_IMPLEMENTED;
502
 
}
503
 
 
504
 
//*****************************************************************************
505
 
// nsPrintingPromptService::nsIWebProgressListener
506
 
//*****************************************************************************   
507
 
 
508
 
NS_IMETHODIMP 
509
 
nsPrintingPromptService::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags, nsresult aStatus)
510
 
{
511
 
    if ((aStateFlags & STATE_STOP) && mWebProgressListener) 
512
 
    {
513
 
        mWebProgressListener->OnStateChange(aWebProgress, aRequest, aStateFlags, aStatus);
514
 
        if (mPrintProgress) 
515
 
        {
516
 
            mPrintProgress->CloseProgressDialog(PR_TRUE);
517
 
        }
518
 
        mPrintProgress       = nsnull;
519
 
        mWebProgressListener = nsnull;
520
 
    }
521
 
    return NS_OK;
522
 
}
523
 
 
524
 
/* void onProgressChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aCurSelfProgress, in long aMaxSelfProgress, in long aCurTotalProgress, in long aMaxTotalProgress); */
525
 
NS_IMETHODIMP 
526
 
nsPrintingPromptService::OnProgressChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress, PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress)
527
 
{
528
 
    if (mWebProgressListener) {
529
 
      return mWebProgressListener->OnProgressChange(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress);
530
 
    }
531
 
    return NS_OK;
532
 
}
533
 
 
534
 
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location); */
535
 
NS_IMETHODIMP 
536
 
nsPrintingPromptService::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location)
537
 
{
538
 
    if (mWebProgressListener) {
539
 
        return mWebProgressListener->OnLocationChange(aWebProgress, aRequest, location);
540
 
    }
541
 
    return NS_OK;
542
 
}
543
 
 
544
 
/* void onStatusChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsresult aStatus, in wstring aMessage); */
545
 
NS_IMETHODIMP 
546
 
nsPrintingPromptService::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsresult aStatus, const PRUnichar *aMessage)
547
 
{
548
 
    if (mWebProgressListener) {
549
 
        return mWebProgressListener->OnStatusChange(aWebProgress, aRequest, aStatus, aMessage);
550
 
    }
551
 
    return NS_OK;
552
 
}
553
 
 
554
 
/* void onSecurityChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long state); */
555
 
NS_IMETHODIMP 
556
 
nsPrintingPromptService::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 state)
557
 
{
558
 
    if (mWebProgressListener) {
559
 
        return mWebProgressListener->OnSecurityChange(aWebProgress, aRequest, state);
560
 
    }
561
 
    return NS_OK;
562
 
}