diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 9b5506770db..a2c385d79e7 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -123,15 +123,19 @@ // Print Options #include "nsIPrintSettings.h" +#include "nsIPrintSettingsService.h" #include "nsIPrintOptions.h" #include "nsGfxCIID.h" #include "nsIServiceManager.h" #include "nsHTMLAtoms.h" // XXX until atoms get factored into nsLayoutAtoms #include "nsISimpleEnumerator.h" #include "nsISupportsPrimitives.h" -static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); static NS_DEFINE_IID(kPrinterEnumeratorCID, NS_PRINTER_ENUMERATOR_CID); +// PrintOptions is now implemented by PrintSettingsService +const char* kPrintSettingsServiceCID = "@mozilla.org/gfx/printsettings-service;1"; +const char* kPrintOptionsCID = "@mozilla.org/gfx/printsettings-service;1"; + // Printing Events #include "nsIEventQueue.h" #include "nsIEventQueueService.h" @@ -6427,21 +6431,24 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings, // to if we have a PrintOptions first, because we can't do anything // below without it then inside we check to se if the printSettings // is null to know if we need to create on. + // if they don't pass in a PrintSettings, then get the Global PS mPrt->mPrintSettings = aPrintSettings; - mPrt->mPrintOptions = do_GetService(kPrintOptionsCID, &rv); - if (NS_SUCCEEDED(rv) && mPrt->mPrintOptions) { - // if they don't pass in a PrintSettings, then make one - if (mPrt->mPrintSettings == nsnull) { - mPrt->mPrintOptions->CreatePrintSettings(getter_AddRefs(mPrt->mPrintSettings)); - } - NS_ASSERTION(mPrt->mPrintSettings, "You can't PrintPreview without a PrintSettings!"); + if (!mPrt->mPrintSettings) { + GetGlobalPrintSettings(getter_AddRefs(mPrt->mPrintSettings)); + } + mPrt->mPrintOptions = do_GetService(kPrintOptionsCID, &rv); + if (NS_SUCCEEDED(rv) && mPrt->mPrintOptions && mPrt->mPrintSettings) { // Get the default printer name and set it into the PrintSettings - if (NS_FAILED(CheckForPrinters(mPrt->mPrintOptions, mPrt->mPrintSettings, NS_ERROR_GFX_PRINTER_PRINTPREVIEW, PR_FALSE))) { - delete mPrt; - mPrt = nsnull; - return NS_ERROR_FAILURE; - } + rv = CheckForPrinters(mPrt->mPrintOptions, mPrt->mPrintSettings, NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE, PR_TRUE); + } else { + NS_ASSERTION(mPrt->mPrintSettings, "You can't Print without a PrintSettings!"); + rv = NS_ERROR_FAILURE; + } + if (NS_FAILED(rv)) { + delete mPrt; + mPrt = nsnull; + return NS_ERROR_FAILURE; } // Let's print ... @@ -6541,7 +6548,7 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings, if (factory) { nsCOMPtr devspec; nsCOMPtr dx; - nsresult rv = factory->CreateDeviceContextSpec(mWindow, aPrintSettings, *getter_AddRefs(devspec), PR_TRUE); + nsresult rv = factory->CreateDeviceContextSpec(mWindow, mPrt->mPrintSettings, *getter_AddRefs(devspec), PR_TRUE); if (NS_SUCCEEDED(rv)) { rv = mDeviceContext->GetDeviceContextFor(devspec, *getter_AddRefs(ppDC)); if (NS_SUCCEEDED(rv)) { @@ -6818,23 +6825,24 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings, return NS_ERROR_OUT_OF_MEMORY; } - // if they don't pass in a PrintSettings, then make one - // it will have all the default values + // if they don't pass in a PrintSettings, then get the Global PS mPrt->mPrintSettings = aPrintSettings; - mPrt->mPrintOptions = do_GetService(kPrintOptionsCID, &rv); - if (NS_SUCCEEDED(rv) && mPrt->mPrintOptions) { - // if they don't pass in a PrintSettings, then make one - if (mPrt->mPrintSettings == nsnull) { - mPrt->mPrintOptions->CreatePrintSettings(getter_AddRefs(mPrt->mPrintSettings)); - } - NS_ASSERTION(mPrt->mPrintSettings, "You can't PrintPreview without a PrintSettings!"); + if (!mPrt->mPrintSettings) { + GetGlobalPrintSettings(getter_AddRefs(mPrt->mPrintSettings)); + } + mPrt->mPrintOptions = do_GetService(kPrintOptionsCID, &rv); + if (NS_SUCCEEDED(rv) && mPrt->mPrintOptions && mPrt->mPrintSettings) { // Get the default printer name and set it into the PrintSettings - if (NS_FAILED(CheckForPrinters(mPrt->mPrintOptions, mPrt->mPrintSettings, NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE, PR_TRUE))) { - delete mPrt; - mPrt = nsnull; - return NS_ERROR_FAILURE; - } + rv = CheckForPrinters(mPrt->mPrintOptions, mPrt->mPrintSettings, NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE, PR_TRUE); + } else { + NS_ASSERTION(mPrt->mPrintSettings, "You can't Print without a PrintSettings!"); + rv = NS_ERROR_FAILURE; + } + if (NS_FAILED(rv)) { + delete mPrt; + mPrt = nsnull; + return NS_ERROR_FAILURE; } mPrt->mPrintSettings->SetIsCancelled(PR_FALSE); mPrt->mPrintSettings->GetShrinkToFit(&mPrt->mShrinkToFit); @@ -6972,7 +6980,7 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings, // NS_ERROR_NOT_IMPLEMENTED indicates they want default behavior // Any other error code means we must bail out // - rv = printPromptService->ShowPrintDialog(domWin, this, aPrintSettings); + rv = printPromptService->ShowPrintDialog(domWin, this, mPrt->mPrintSettings); if (rv == NS_ERROR_NOT_IMPLEMENTED) { // This means the Dialog service was there, // but they choose not to implement this dialog and @@ -8221,57 +8229,6 @@ DocumentViewerImpl::EnumerateDocumentNames(PRUint32* aCount, } -/* readonly attribute nsIPrintSettings newPrintSettings; */ -NS_IMETHODIMP -DocumentViewerImpl::GetNewPrintSettings(nsIPrintSettings * *aNewPrintSettings) -{ - NS_ENSURE_ARG_POINTER(aNewPrintSettings); - - nsresult rv = NS_ERROR_FAILURE; - nsCOMPtr printService = do_GetService(kPrintOptionsCID, &rv); - if (NS_SUCCEEDED(rv)) { - rv = printService->CreatePrintSettings(aNewPrintSettings); - InitPrintSettingsFromPrinter(nsnull, *aNewPrintSettings); - } - return rv; -} - -/* readonly attribute wstring defaultPrinterName; */ -NS_IMETHODIMP -DocumentViewerImpl::GetDefaultPrinterName(PRUnichar * *aDefaultPrinterName) -{ - NS_ENSURE_ARG_POINTER(aDefaultPrinterName); - - nsresult rv; - nsCOMPtr prtEnum = do_GetService(kPrinterEnumeratorCID, &rv); - if (prtEnum) { - prtEnum->GetDefaultPrinterName(aDefaultPrinterName); - } - return rv; -} - -/* void initPrintSettingsFromPrinter (in wstring aPrinterName, in nsIPrintSettings aPrintSettings); */ -NS_IMETHODIMP -DocumentViewerImpl::InitPrintSettingsFromPrinter(const PRUnichar *aPrinterName, nsIPrintSettings *aPrintSettings) -{ - NS_ENSURE_ARG_POINTER(aPrintSettings); - - PRUnichar* printerName = nsnull; - if (!aPrinterName) { - GetDefaultPrinterName(&printerName); - if (!printerName || !*printerName) return NS_OK; - } - nsresult rv; - nsCOMPtr prtEnum = do_GetService(kPrinterEnumeratorCID, &rv); - if (prtEnum) { - prtEnum->InitPrintSettingsFromPrinter(aPrinterName?aPrinterName:printerName, aPrintSettings); - } - if (printerName) { - nsMemory::Free(printerName); - } - return NS_OK; -} - /* readonly attribute nsIPrintSettings globalPrintSettings; */ NS_IMETHODIMP DocumentViewerImpl::GetGlobalPrintSettings(nsIPrintSettings * *aGlobalPrintSettings) @@ -8279,9 +8236,10 @@ DocumentViewerImpl::GetGlobalPrintSettings(nsIPrintSettings * *aGlobalPrintSetti NS_ENSURE_ARG_POINTER(aGlobalPrintSettings); nsresult rv = NS_ERROR_FAILURE; - nsCOMPtr printService = do_GetService(kPrintOptionsCID, &rv); + //nsCOMPtr printSettingsService = do_GetService(kPrintOptionsCID, &rv); + nsCOMPtr printSettingsService = do_GetService(kPrintSettingsServiceCID, &rv); if (NS_SUCCEEDED(rv)) { - rv = printService->GetGlobalPrintSettings(aGlobalPrintSettings); + rv = printSettingsService->GetGlobalPrintSettings(aGlobalPrintSettings); } return rv; } @@ -8377,30 +8335,6 @@ DocumentViewerImpl::Cancel() return NS_ERROR_FAILURE; } -/* void initPrintSettingsFromPrefs (in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags); */ -NS_IMETHODIMP -DocumentViewerImpl::InitPrintSettingsFromPrefs(nsIPrintSettings *aPrintSettings, PRBool aUsePrinterNamePrefix, PRUint32 aFlags) -{ - nsresult rv; - nsCOMPtr printService = do_GetService(kPrintOptionsCID, &rv); - if (NS_SUCCEEDED(rv) && printService) { - return printService->InitPrintSettingsFromPrefs(aPrintSettings, aUsePrinterNamePrefix, aFlags); - } - return NS_OK; -} - -/* void savePrintSettingsToPrefs (in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags); */ -NS_IMETHODIMP -DocumentViewerImpl::SavePrintSettingsToPrefs(nsIPrintSettings *aPrintSettings, PRBool aUsePrinterNamePrefix, PRUint32 aFlags) -{ - nsresult rv; - nsCOMPtr printService = do_GetService(kPrintOptionsCID, &rv); - if (NS_SUCCEEDED(rv) && printService) { - return printService->SavePrintSettingsToPrefs(aPrintSettings, aUsePrinterNamePrefix, aFlags); - } - return NS_OK; -} - /** --------------------------------------------------- * Get the Focused Frame for a documentviewer * diff --git a/mozilla/embedding/browser/photon/src/EmbedPrivate.cpp b/mozilla/embedding/browser/photon/src/EmbedPrivate.cpp index 92acdde207f..128f05f24ae 100644 --- a/mozilla/embedding/browser/photon/src/EmbedPrivate.cpp +++ b/mozilla/embedding/browser/photon/src/EmbedPrivate.cpp @@ -66,7 +66,6 @@ // for profiles #include #include "nsIWebBrowserPrint.h" -#include "nsIPrintOptions.h" // all of our local includes #include "EmbedPrivate.h" @@ -81,7 +80,6 @@ #include "PtMozilla.h" static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID); -static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); static const char sWatcherContractID[] = "@mozilla.org/embedcomp/window-watcher;1"; diff --git a/mozilla/embedding/browser/photon/src/PtMozilla.cpp b/mozilla/embedding/browser/photon/src/PtMozilla.cpp index a168dcafe6f..b4840f2c60a 100644 --- a/mozilla/embedding/browser/photon/src/PtMozilla.cpp +++ b/mozilla/embedding/browser/photon/src/PtMozilla.cpp @@ -36,7 +36,6 @@ #include "nsIHistoryEntry.h" #include "nsIWebBrowserPrint.h" -#include "nsIPrintOptions.h" #include "nsIDOMEventReceiver.h" #include "nsIDOMEventListener.h" diff --git a/mozilla/embedding/browser/webBrowser/nsIWebBrowserPrint.idl b/mozilla/embedding/browser/webBrowser/nsIWebBrowserPrint.idl index 7a654b7238e..9ecafe2ad3b 100644 --- a/mozilla/embedding/browser/webBrowser/nsIWebBrowserPrint.idl +++ b/mozilla/embedding/browser/webBrowser/nsIWebBrowserPrint.idl @@ -44,21 +44,6 @@ interface nsIWebBrowserPrint : nsISupports const short PRINTPREVIEW_HOME = 3; const short PRINTPREVIEW_END = 4; - /** - * Returns a new, unique PrintSettings object each time. - * - * For example, if each browser was to have its own unique - * PrintSettings, then each browser window would call this to - * create its own unique PrintSettings object. - * - * If each browse window was to use the same PrintSettings object - * then it should use "globalPrintSettings" - * - * Initializes the newPrintSettings from the default printer - * - */ - readonly attribute nsIPrintSettings newPrintSettings; - /** * Returns a "global" PrintSettings object * Creates a new the first time, if one doesn't exist. @@ -88,62 +73,6 @@ interface nsIWebBrowserPrint : nsISupports */ readonly attribute boolean doingPrintPreview; - - /** - * The name of the default printer - */ - readonly attribute wstring defaultPrinterName; - - /** - * Initializes certain settings from the native printer into the PrintSettings - * if aPrinterName is null then it uses the default printer name if it can - * These settings include, but are not limited to: - * Page Orientation - * Page Size - * Number of Copies - */ - void initPrintSettingsFromPrinter(in wstring aPrinterName, in nsIPrintSettings aPrintSettings); - - /** - * Reads PrintSettings values from Prefs, - * the values to be read are indicated by the "flags" arg. - * - * First it reads in the "generic" set of PrintSetings not associated with any printer - * then it uses the PrinterName in the PrinterSettings to read any settings that were saved - * just for that printer. - * - * aPS - PrintSettings to have its settings read - * aUsePrinterNamePrefix - indicates whether to use the printer name as a prefix - * aFlags - indicates which prefs to read, see nsIPrintSettings.idl for the const values. - * - * Items not read: - * startPageRange, endPageRange, scaling, printRange, title - * docURL, howToEnableFrameUI, isCancelled, printFrameTypeUsage - * printFrameType, printSilent, shrinkToFit, numCopies - * - */ - void initPrintSettingsFromPrefs(in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags); - - /** - * Writes PrintSettings values to Prefs, - * the values to be written are indicated by the "flags" arg. - * - * If there is no PrinterName in the PrinterSettings - * the values are saved as the "generic" values not associated with any printer. - * If a PrinterName is there, then it saves the items qualified for that Printer - * - * aPS - PrintSettings to have its settings saved - * aUsePrinterNamePrefix - indicates whether to use the printer name as a prefix - * aFlags - indicates which prefs to save, see nsIPrintSettings.idl for the const values. - * - * Items not written: - * startPageRange, endPageRange, scaling, printRange, title - * docURL, howToEnableFrameUI, isCancelled, printFrameTypeUsage - * printFrameType, printSilent, shrinkToFit, numCopies - * - */ - void savePrintSettingsToPrefs(in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags); - /** * This returns whether the current document is a frameset document */ @@ -172,7 +101,8 @@ interface nsIWebBrowserPrint : nsISupports /** * Print the specified DOM window * - * aThePrintOptions - Printer Settings for the print job + * aThePrintOptions - Printer Settings for the print job, if aThePrintSettings is null + * then the global PS will be used. * nsIWebProgressListener - is updated during the print * @return void */ @@ -182,7 +112,8 @@ interface nsIWebBrowserPrint : nsISupports /** * Print Preview the specified DOM window * - * aThePrintOptions - Printer Settings for the print preview + * aThePrintOptions - Printer Settings for the print preview, if aThePrintSettings is null + * then the global PS will be used. * nsIWebProgressListener - is updated during the printpreview * @return void */ diff --git a/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp b/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp index 9dc135979c5..b9492dd5680 100644 --- a/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp +++ b/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp @@ -66,7 +66,6 @@ // PSM2 includes #include "nsISecureBrowserUI.h" -static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); static NS_DEFINE_CID(kWebShellCID, NS_WEB_SHELL_CID); static NS_DEFINE_CID(kChildCID, NS_CHILD_CID); static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); diff --git a/mozilla/embedding/components/printingui/src/mac/nsPrintingPromptService.cpp b/mozilla/embedding/components/printingui/src/mac/nsPrintingPromptService.cpp index f520531e8f0..d318953e617 100644 --- a/mozilla/embedding/components/printingui/src/mac/nsPrintingPromptService.cpp +++ b/mozilla/embedding/components/printingui/src/mac/nsPrintingPromptService.cpp @@ -170,7 +170,6 @@ Handle itemH; if (((TPPrDlg)aDialog)->fDone) { - //nsCOMPtr printOptionsService = do_GetService("@mozilla.org/gfx/printoptions;1"); // cleanup and set the print options to what we want if (gPrintSettings) { diff --git a/mozilla/embedding/components/printingui/src/os2/nsPrintingPromptService.cpp b/mozilla/embedding/components/printingui/src/os2/nsPrintingPromptService.cpp index f2077a414a7..8e4ad948957 100644 --- a/mozilla/embedding/components/printingui/src/os2/nsPrintingPromptService.cpp +++ b/mozilla/embedding/components/printingui/src/os2/nsPrintingPromptService.cpp @@ -55,7 +55,7 @@ #include "nsIPrintOptions.h" #include "nsIServiceManager.h" #include "nsGfxCIID.h" -static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); +const char* kPrintOptionsCID = "@mozilla.org/gfx/printsettings-service;1"; static const char *kPrintDialogURL = "chrome://global/content/printdialog.xul"; static const char *kPrintProgressDialogURL = "chrome://global/content/printProgress.xul"; diff --git a/mozilla/embedding/components/printingui/src/win/nsPrintDialogUtil.cpp b/mozilla/embedding/components/printingui/src/win/nsPrintDialogUtil.cpp index fa63e0da832..c4881fcd936 100644 --- a/mozilla/embedding/components/printingui/src/win/nsPrintDialogUtil.cpp +++ b/mozilla/embedding/components/printingui/src/win/nsPrintDialogUtil.cpp @@ -76,7 +76,6 @@ WIN_LIBS= \ #include "nsUnitConversion.h" #include "nsIPrintOptions.h" #include "nsGfxCIID.h" -static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); static NS_DEFINE_IID(kPrinterEnumeratorCID, NS_PRINTER_ENUMERATOR_CID); #include "nsRect.h" diff --git a/mozilla/embedding/qa/testembed/StdAfx.h b/mozilla/embedding/qa/testembed/StdAfx.h index c772306da7f..47e29d3b8bf 100644 --- a/mozilla/embedding/qa/testembed/StdAfx.h +++ b/mozilla/embedding/qa/testembed/StdAfx.h @@ -104,7 +104,6 @@ #include "nsIServiceManager.h" // Printer Includes -#include "nsIPrintOptions.h" #include "nsIWebBrowserPrint.h" // qa additions diff --git a/mozilla/embedding/tests/mfcembed/PrintSetupDialog.cpp b/mozilla/embedding/tests/mfcembed/PrintSetupDialog.cpp index 4deb399124c..aa606ab93be 100644 --- a/mozilla/embedding/tests/mfcembed/PrintSetupDialog.cpp +++ b/mozilla/embedding/tests/mfcembed/PrintSetupDialog.cpp @@ -4,6 +4,7 @@ #include "stdafx.h" #include "mfcembed.h" #include "PrintSetupDialog.h" +#include "nsIPrintSettings.h" #ifdef _DEBUG #define new DEBUG_NEW diff --git a/mozilla/embedding/tests/mfcembed/StdAfx.h b/mozilla/embedding/tests/mfcembed/StdAfx.h index 63631a15bbe..7cee6473128 100644 --- a/mozilla/embedding/tests/mfcembed/StdAfx.h +++ b/mozilla/embedding/tests/mfcembed/StdAfx.h @@ -127,7 +127,6 @@ #include "nsIWebBrowserFocus.h" // Printer Includes -#include "nsIPrintOptions.h" #include "nsIWebBrowserPrint.h" #include "nsIDOMWindow.h" diff --git a/mozilla/gfx/idl/MANIFEST_IDL b/mozilla/gfx/idl/MANIFEST_IDL index a1c020de461..8622de7f94c 100644 --- a/mozilla/gfx/idl/MANIFEST_IDL +++ b/mozilla/gfx/idl/MANIFEST_IDL @@ -9,3 +9,4 @@ nsIScreen.idl nsIScreenManager.idl nsIPrintOptions.idl nsIPrintSettings.idl +nsIPrintSettingsService.idl diff --git a/mozilla/gfx/idl/Makefile.in b/mozilla/gfx/idl/Makefile.in index 6036b401fa1..6f9833df9b1 100644 --- a/mozilla/gfx/idl/Makefile.in +++ b/mozilla/gfx/idl/Makefile.in @@ -38,6 +38,7 @@ XPIDLSRCS = \ nsIScreenManager.idl \ nsIPrintOptions.idl \ nsIPrintSettings.idl \ + nsIPrintSettingsService.idl \ $(NULL) ifneq (,$(filter mac cocoa,$(MOZ_GFX_TOOLKIT))) diff --git a/mozilla/gfx/idl/makefile.win b/mozilla/gfx/idl/makefile.win index 2986023e7fc..7c4b9624e38 100644 --- a/mozilla/gfx/idl/makefile.win +++ b/mozilla/gfx/idl/makefile.win @@ -33,6 +33,7 @@ XPIDLSRCS = \ .\nsIScreenManager.idl \ .\nsIPrintOptions.idl \ .\nsIPrintSettings.idl \ + .\nsIPrintSettingsService.idl \ .\nsIPrintSettingsWin.idl \ $(NULL) diff --git a/mozilla/gfx/idl/nsIPrintOptions.idl b/mozilla/gfx/idl/nsIPrintOptions.idl index 2568bdbf187..40a9b65ca1f 100644 --- a/mozilla/gfx/idl/nsIPrintOptions.idl +++ b/mozilla/gfx/idl/nsIPrintOptions.idl @@ -73,30 +73,6 @@ interface nsIPrintOptions : nsISupports */ nsIPrintSettings CreatePrintSettings(); - /** - * Creates a new PrintSettnigs Object if it doesn't exist - * otherwise it always hand back the same one. - * This is THE global PrintSettings - */ - readonly attribute nsIPrintSettings globalPrintSettings; - - /** - * Initialize the values in the PrintSettings from Prefs - * aPS - PrintSettings to have its settings read - * aUsePrinterNamePrefix - indicates whether to use the printer name as a prefix - */ - void initPrintSettingsFromPrefs(in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags); - - /** - * Save all the PrintSettings to Prefs. - * This is on a printer by printer basis - * Or saved generically if the printer name is null or empty - * - * aPS - PrintSettings to have its settings saved - * aUsePrinterNamePrefix - indicates whether to use the printer name as a prefix - */ - void savePrintSettingsToPrefs(in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags); - /** * available Printers */ diff --git a/mozilla/gfx/idl/nsIPrintSettingsService.idl b/mozilla/gfx/idl/nsIPrintSettingsService.idl new file mode 100644 index 00000000000..193fb99d7aa --- /dev/null +++ b/mozilla/gfx/idl/nsIPrintSettingsService.idl @@ -0,0 +1,136 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2001 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* Interface to the Service for gwetting the Global PrintSettings object + or a unique PrintSettings object +*/ + +#include "nsISupports.idl" + +interface nsIPrintSettings; + +[scriptable, uuid(841387C8-72E6-484b-9296-BF6EEA80D58A)] +interface nsIPrintSettingsService : nsISupports +{ + /** + * Returns a "global" PrintSettings object + * Creates a new the first time, if one doesn't exist. + * + * Then returns the same object each time after that. + * + * Initializes the globalPrintSettings from the default printer + */ + readonly attribute nsIPrintSettings globalPrintSettings; + + /** + * Returns a new, unique PrintSettings object each time. + * + * For example, if each browser was to have its own unique + * PrintSettings, then each browser window would call this to + * create its own unique PrintSettings object. + * + * If each browse window was to use the same PrintSettings object + * then it should use "globalPrintSettings" + * + * Initializes the newPrintSettings from the default printer + * + */ + readonly attribute nsIPrintSettings newPrintSettings; + + /** + * The name of the default printer + */ + readonly attribute wstring defaultPrinterName; + + /** + * Initializes certain settings from the native printer into the PrintSettings + * if aPrinterName is null then it uses the default printer name if it can + * These settings include, but are not limited to: + * Page Orientation + * Page Size + * Number of Copies + */ + void initPrintSettingsFromPrinter(in wstring aPrinterName, in nsIPrintSettings aPrintSettings); + + /** + * Reads PrintSettings values from Prefs, + * the values to be read are indicated by the "flags" arg. + * + * First it reads in the "generic" set of PrintSetings not associated with any printer + * then it uses the PrinterName in the PrinterSettings to read any settings that were saved + * just for that printer. + * + * aPS - PrintSettings to have its settings read + * aUsePrinterNamePrefix - indicates whether to use the printer name as a prefix + * aFlags - indicates which prefs to read, see nsIPrintSettings.idl for the const values. + * + * Items not read: + * startPageRange, endPageRange, scaling, printRange, title + * docURL, howToEnableFrameUI, isCancelled, printFrameTypeUsage + * printFrameType, printSilent, shrinkToFit, numCopies + * + */ + void initPrintSettingsFromPrefs(in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags); + + /** + * Writes PrintSettings values to Prefs, + * the values to be written are indicated by the "flags" arg. + * + * If there is no PrinterName in the PrinterSettings + * the values are saved as the "generic" values not associated with any printer. + * If a PrinterName is there, then it saves the items qualified for that Printer + * + * aPS - PrintSettings to have its settings saved + * aUsePrinterNamePrefix - indicates whether to use the printer name as a prefix + * aFlags - indicates which prefs to save, see nsIPrintSettings.idl for the const values. + * + * Items not written: + * startPageRange, endPageRange, scaling, printRange, title + * docURL, howToEnableFrameUI, isCancelled, printFrameTypeUsage + * printFrameType, printSilent, shrinkToFit, numCopies + * + */ + void savePrintSettingsToPrefs(in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags); + +}; + +%{C++ +// {841387C8-72E6-484b-9296-BF6EEA80D58A} +#define NS_PRINTSETTINGSSERVICE_IID \ + {0x841387c8, 0x72e6, 0x484b, { 0x92, 0x96, 0xbf, 0x6e, 0xea, 0x80, 0xd5, 0x8a}} +%} diff --git a/mozilla/gfx/macbuild/gfxIDL.xml b/mozilla/gfx/macbuild/gfxIDL.xml index b1c47bdad63..40f14675c47 100644 --- a/mozilla/gfx/macbuild/gfxIDL.xml +++ b/mozilla/gfx/macbuild/gfxIDL.xml @@ -762,6 +762,13 @@ Text + + Name + nsIPrintSettingsService.idl + MacOS + Text + + Name nsIFontList.idl @@ -822,6 +829,11 @@ nsIPrintOptions.idl MacOS + + Name + nsIPrintSettingsService.idl + MacOS + Name nsIFontList.idl @@ -1553,6 +1565,13 @@ Text + + Name + nsIPrintSettingsService.idl + MacOS + Text + + Name nsIFontList.idl @@ -1613,6 +1632,11 @@ nsIPrintOptions.idl MacOS + + Name + nsIPrintSettingsService.idl + MacOS + Name nsIFontList.idl @@ -1667,6 +1691,12 @@ nsIPrintOptions.idl MacOS + + headers + Name + nsIPrintSettingsService.idl + MacOS + headers Name diff --git a/mozilla/gfx/public/nsGfxCIID.h b/mozilla/gfx/public/nsGfxCIID.h index edf97e2fdc3..4048281d80f 100644 --- a/mozilla/gfx/public/nsGfxCIID.h +++ b/mozilla/gfx/public/nsGfxCIID.h @@ -95,9 +95,13 @@ { 0xc401eb80, 0xf9ea, 0x11d3, \ { 0xbb, 0x6f, 0xe7, 0x32, 0xb7, 0x3e, 0xbe, 0x7c } } -#define NS_PRINTOPTIONS_CID \ -{ 0x30a3b080, 0x4867, 0x11d4, \ -{ 0xa8, 0x56, 0x0, 0x10, 0x5a, 0x18, 0x34, 0x19 } } +#define NS_PRINTSETTINGSSERVICE_CID \ +{ 0x841387c8, 0x72e6, 0x484b, \ +{ 0x92, 0x96, 0xbf, 0x6e, 0xea, 0x80, 0xd5, 0x8a } } + +// NOTE: This now has the same CID as NS_PRINTSETTINGSSERVICE_CID +// will go away when Bug 144114 is fixed +#define NS_PRINTOPTIONS_CID NS_PRINTSETTINGSSERVICE_CID #define NS_PRINTER_ENUMERATOR_CID \ { 0xa6cf9129, 0x15b3, 0x11d2, \ diff --git a/mozilla/gfx/src/beos/nsGfxFactoryBeOS.cpp b/mozilla/gfx/src/beos/nsGfxFactoryBeOS.cpp index c1948bbd4f9..7ac658fcead 100644 --- a/mozilla/gfx/src/beos/nsGfxFactoryBeOS.cpp +++ b/mozilla/gfx/src/beos/nsGfxFactoryBeOS.cpp @@ -180,9 +180,9 @@ static const nsModuleComponentInfo components[] = // "@mozilla.org/gfx/printer_enumerator/beos;1", "@mozilla.org/gfx/printerenumerator;1", nsPrinterEnumeratorBeOSConstructor }, - { "BeOS Printer Options", - NS_PRINTOPTIONS_CID, - "@mozilla.org/gfx/printoptions;1", + { "BeOS PrintSettings Service", + NS_PRINTSETTINGSSERVICE_CID, + "@mozilla.org/gfx/printsettings-service;1", nsPrintOptionsBeOSConstructor } }; diff --git a/mozilla/gfx/src/gtk/nsGfxFactoryGTK.cpp b/mozilla/gfx/src/gtk/nsGfxFactoryGTK.cpp index 5b7f038f385..7950d38d51b 100644 --- a/mozilla/gfx/src/gtk/nsGfxFactoryGTK.cpp +++ b/mozilla/gfx/src/gtk/nsGfxFactoryGTK.cpp @@ -171,10 +171,10 @@ static const nsModuleComponentInfo components[] = // "@mozilla.org/gfx/device_context_spec_factory/gtk;1", "@mozilla.org/gfx/devicecontextspecfactory;1", nsDeviceContextSpecFactoryGTKConstructor }, - { "Print Options", - NS_PRINTOPTIONS_CID, - // "@mozilla.org/gfx/printoptions;1", - "@mozilla.org/gfx/printoptions;1", + { "PrintSettings Service", + NS_PRINTSETTINGSSERVICE_CID, + // "@mozilla.org/gfx/printsettings-service;1", + "@mozilla.org/gfx/printsettings-service;1", nsPrintOptionsGTKConstructor }, { "GTK Font Enumerator", NS_FONT_ENUMERATOR_CID, diff --git a/mozilla/gfx/src/mac/nsGfxFactoryMac.cpp b/mozilla/gfx/src/mac/nsGfxFactoryMac.cpp index 7013623f91a..f737e0c7834 100644 --- a/mozilla/gfx/src/mac/nsGfxFactoryMac.cpp +++ b/mozilla/gfx/src/mac/nsGfxFactoryMac.cpp @@ -149,14 +149,14 @@ static const nsModuleComponentInfo components[] = "@mozilla.org/gfx/devicecontextspecfactory;1", nsDeviceContextSpecFactoryMacConstructor }, #if TARGET_CARBON - { "nsPrintOptions", - NS_PRINTOPTIONS_CID, - "@mozilla.org/gfx/printoptions;1", + { "PrintSettings Service", + NS_PRINTSETTINGSSERVICE_CID, + "@mozilla.org/gfx/printsettings-service;1", nsPrintOptionsXConstructor }, #else - { "Print Options", - NS_PRINTOPTIONS_CID, - "@mozilla.org/gfx/printoptions;1", + { "PrintSettings Service", + NS_PRINTSETTINGSSERVICE_CID, + "@mozilla.org/gfx/printsettings-service;1", nsPrintOptionsMacConstructor }, #endif { "nsFontEnumerator", diff --git a/mozilla/gfx/src/nsPrintOptionsImpl.cpp b/mozilla/gfx/src/nsPrintOptionsImpl.cpp index 1f05522f677..8115c6eadbf 100644 --- a/mozilla/gfx/src/nsPrintOptionsImpl.cpp +++ b/mozilla/gfx/src/nsPrintOptionsImpl.cpp @@ -62,7 +62,7 @@ static NS_DEFINE_IID(kCPrinterEnumerator, NS_PRINTER_ENUMERATOR_CID); -NS_IMPL_ISUPPORTS1(nsPrintOptions, nsIPrintOptions) +NS_IMPL_ISUPPORTS2(nsPrintOptions, nsIPrintOptions, nsIPrintSettingsService) // Pref Constants const char kMarginTop[] = "print_margin_top"; @@ -332,57 +332,6 @@ const char* nsPrintOptions::GetPrefName(const char * aPrefName, } -/** --------------------------------------------------- - * Helper function - Returns either the name or sets the length to zero - */ -static void GetAdjustedPrinterName(nsIPrintSettings* aPS, PRBool aUsePNP, nsString& aPrinterName) -{ - aPrinterName.SetLength(0); - - // Get the Printer Name from the PtinerSettings - // to use as a prefix for Pref Names - PRUnichar* prtName = nsnull; - if (aUsePNP && NS_SUCCEEDED(aPS->GetPrinterName(&prtName))) { - if (prtName && !*prtName) { - nsMemory::Free(prtName); - prtName = nsnull; - } - } - - if (prtName) { - aPrinterName = prtName; - PRUnichar uc = '_'; - const char* replaceStr = " \n\r"; - for (PRInt32 i=0;i<(PRInt32)strlen(replaceStr);i++) { - PRUnichar uChar = replaceStr[i]; - aPrinterName.ReplaceChar(uChar, uc); - } - } -} - -/** --------------------------------------------------- - * See documentation in nsPrintOptionsImpl.h - * @update 1/12/01 rods - */ -NS_IMETHODIMP -nsPrintOptions::InitPrintSettingsFromPrefs(nsIPrintSettings* aPS, PRBool aUsePNP, PRUint32 aFlags) -{ - nsString prtName; - // read any non printer specific prefs - // with empty printer name - nsresult rv = ReadPrefs(aPS, prtName, aFlags); - NS_ENSURE_SUCCESS(rv, rv); - - // Get the Printer Name from the PtinerSettings - // to use as a prefix for Pref Names - GetAdjustedPrinterName(aPS, aUsePNP, prtName); - if (prtName.Length()) { - // Now read any printer specific prefs - return ReadPrefs(aPS, prtName, aFlags); - } - return NS_OK; -} - //---------------------------------------------------------------------- // Testing of read/write prefs // This define controls debug output @@ -627,24 +576,6 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUi return NS_ERROR_FAILURE; } -/* void SavePrintSettingsToPrefs (in nsIPrintSettings aPS); */ -/** --------------------------------------------------- - * This will asve into prefs most all the PrintSettings either generically (not specified printer) - * or to a specific printer. - */ -nsresult -nsPrintOptions::SavePrintSettingsToPrefs(nsIPrintSettings *aPS, PRBool aUsePrinterNamePrefix, PRUint32 aFlags) -{ - nsString prtName; - // Get the Printer Name from the PtinerSettings - // to use as a prefix for Pref Names - GetAdjustedPrinterName(aPS, aUsePrinterNamePrefix, prtName); - - // Now write any printer specific prefs - return WritePrefs(aPS, prtName, aFlags); -} - - /** --------------------------------------------------- * See documentation in nsPrintOptionsImpl.h * @update 1/12/01 rods @@ -924,6 +855,11 @@ NS_IMETHODIMP nsPrintOptions::CreatePrintSettings(nsIPrintSettings **_retval) return rv; } +//----------------------------------------------------- +//----------------------------------------------------- +//-- nsIPrintSettingsService +//----------------------------------------------------- +//----------------------------------------------------- /* readonly attribute nsIPrintSettings globalPrintSettings; */ NS_IMETHODIMP nsPrintOptions::GetGlobalPrintSettings(nsIPrintSettings * *aGlobalPrintSettings) { @@ -957,6 +893,121 @@ NS_IMETHODIMP nsPrintOptions::GetGlobalPrintSettings(nsIPrintSettings * *aGlobal return NS_OK; } +/* readonly attribute nsIPrintSettings newPrintSettings; */ +NS_IMETHODIMP +nsPrintOptions::GetNewPrintSettings(nsIPrintSettings * *aNewPrintSettings) +{ + NS_ENSURE_ARG_POINTER(aNewPrintSettings); + + nsresult rv = CreatePrintSettings(aNewPrintSettings); + NS_ENSURE_SUCCESS(rv, rv); + rv = InitPrintSettingsFromPrinter(nsnull, *aNewPrintSettings); + return rv; +} + +//----------------------------------------------------------------------- +NS_IMETHODIMP +nsPrintOptions::GetDefaultPrinterName(PRUnichar * *aDefaultPrinterName) +{ + NS_ENSURE_ARG_POINTER(aDefaultPrinterName); + + nsresult rv; + nsCOMPtr prtEnum = do_GetService(kPrinterEnumeratorCID, &rv); + if (prtEnum) { + rv = prtEnum->GetDefaultPrinterName(aDefaultPrinterName); + } + return rv; +} + +//----------------------------------------------------------------------- +NS_IMETHODIMP +nsPrintOptions::InitPrintSettingsFromPrinter(const PRUnichar *aPrinterName, nsIPrintSettings *aPrintSettings) +{ + NS_ENSURE_ARG_POINTER(aPrintSettings); + + PRUnichar* printerName = nsnull; + if (!aPrinterName) { + GetDefaultPrinterName(&printerName); + if (!printerName || !*printerName) return NS_OK; + } + nsresult rv; + nsCOMPtr prtEnum = do_GetService(kPrinterEnumeratorCID, &rv); + if (prtEnum) { + rv = prtEnum->InitPrintSettingsFromPrinter(aPrinterName?aPrinterName:printerName, aPrintSettings); + } + if (printerName) { + nsMemory::Free(printerName); + } + return rv; +} + +/** --------------------------------------------------- + * Helper function - Returns either the name or sets the length to zero + */ +static void GetAdjustedPrinterName(nsIPrintSettings* aPS, PRBool aUsePNP, nsString& aPrinterName) +{ + aPrinterName.SetLength(0); + + // Get the Printer Name from the PtinerSettings + // to use as a prefix for Pref Names + PRUnichar* prtName = nsnull; + if (aUsePNP && NS_SUCCEEDED(aPS->GetPrinterName(&prtName))) { + if (prtName && !*prtName) { + nsMemory::Free(prtName); + prtName = nsnull; + } + } + + if (prtName) { + aPrinterName = prtName; + PRUnichar uc = '_'; + const char* replaceStr = " \n\r"; + for (PRInt32 i=0;i<(PRInt32)strlen(replaceStr);i++) { + PRUnichar uChar = replaceStr[i]; + aPrinterName.ReplaceChar(uChar, uc); + } + } +} + +/** --------------------------------------------------- + * See documentation in nsPrintOptionsImpl.h + * @update 1/12/01 rods + */ +NS_IMETHODIMP +nsPrintOptions::InitPrintSettingsFromPrefs(nsIPrintSettings* aPS, PRBool aUsePNP, PRUint32 aFlags) +{ + nsString prtName; + // read any non printer specific prefs + // with empty printer name + nsresult rv = ReadPrefs(aPS, prtName, aFlags); + NS_ENSURE_SUCCESS(rv, rv); + + // Get the Printer Name from the PtinerSettings + // to use as a prefix for Pref Names + GetAdjustedPrinterName(aPS, aUsePNP, prtName); + if (prtName.Length()) { + // Now read any printer specific prefs + return ReadPrefs(aPS, prtName, aFlags); + } + return NS_OK; +} + +/** --------------------------------------------------- + * This will asve into prefs most all the PrintSettings either generically (not specified printer) + * or to a specific printer. + */ +nsresult +nsPrintOptions::SavePrintSettingsToPrefs(nsIPrintSettings *aPS, PRBool aUsePrinterNamePrefix, PRUint32 aFlags) +{ + nsString prtName; + // Get the Printer Name from the PtinerSettings + // to use as a prefix for Pref Names + GetAdjustedPrinterName(aPS, aUsePrinterNamePrefix, prtName); + + // Now write any printer specific prefs + return WritePrefs(aPS, prtName, aFlags); +} + //----------------------------------------------------- //-- Protected Methods @@ -1121,7 +1172,7 @@ public: }; Tester::Tester() { - static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); + const char* kPrintOptionsCID = "@mozilla.org/gfx/printsettings-service;1"; nsCOMPtr ps; nsresult rv; nsCOMPtr printService = do_GetService(kPrintOptionsCID, &rv); diff --git a/mozilla/gfx/src/nsPrintOptionsImpl.h b/mozilla/gfx/src/nsPrintOptionsImpl.h index 627ea1477bc..a257b24d6db 100644 --- a/mozilla/gfx/src/nsPrintOptionsImpl.h +++ b/mozilla/gfx/src/nsPrintOptionsImpl.h @@ -25,17 +25,19 @@ #define nsPrintOptionsImpl_h__ #include "nsIPrintOptions.h" +#include "nsIPrintSettingsService.h" class nsIPref; -class nsIPrintSettings; +//class nsIPrintSettings; //***************************************************************************** //*** nsPrintOptions //***************************************************************************** -class NS_GFX nsPrintOptions : public nsIPrintOptions +class NS_GFX nsPrintOptions : public nsIPrintOptions, public nsIPrintSettingsService { public: NS_DECL_ISUPPORTS NS_DECL_NSIPRINTOPTIONS + NS_DECL_NSIPRINTSETTINGSSERVICE nsPrintOptions(); virtual ~nsPrintOptions(); diff --git a/mozilla/gfx/src/os2/nsGfxFactoryOS2.cpp b/mozilla/gfx/src/os2/nsGfxFactoryOS2.cpp index 2adb7b43062..f3a8277b307 100644 --- a/mozilla/gfx/src/os2/nsGfxFactoryOS2.cpp +++ b/mozilla/gfx/src/os2/nsGfxFactoryOS2.cpp @@ -160,10 +160,10 @@ static const nsModuleComponentInfo components[] = // "@mozilla.org/gfx/device_context_spec_factory/gtk;1", "@mozilla.org/gfx/devicecontextspecfactory;1", nsDeviceContextSpecFactoryOS2Constructor }, - { "Print Options", - NS_PRINTOPTIONS_CID, - // "@mozilla.org/gfx/printoptions;1", - "@mozilla.org/gfx/printoptions;1", + { "PrintSettings Service", + NS_PRINTSETTINGSSERVICE_CID, + // "@mozilla.org/gfx/printsettings-service;1", + "@mozilla.org/gfx/printsettings-service;1", nsPrintOptionsOS2Constructor }, { "OS2 Font Enumerator", NS_FONT_ENUMERATOR_CID, diff --git a/mozilla/gfx/src/photon/nsDeviceContextSpecFactoryP.cpp b/mozilla/gfx/src/photon/nsDeviceContextSpecFactoryP.cpp index 8a1a1679c70..6eb6f4a6789 100644 --- a/mozilla/gfx/src/photon/nsDeviceContextSpecFactoryP.cpp +++ b/mozilla/gfx/src/photon/nsDeviceContextSpecFactoryP.cpp @@ -58,7 +58,6 @@ nsDeviceContextSpecFactoryPh :: ~nsDeviceContextSpecFactoryPh() static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID); static NS_DEFINE_IID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID); -static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); NS_IMPL_ISUPPORTS1(nsDeviceContextSpecFactoryPh, nsIDeviceContextSpecFactory) diff --git a/mozilla/gfx/src/photon/nsGfxFactoryPh.cpp b/mozilla/gfx/src/photon/nsGfxFactoryPh.cpp index 8dc563187ca..0bcfad5c262 100644 --- a/mozilla/gfx/src/photon/nsGfxFactoryPh.cpp +++ b/mozilla/gfx/src/photon/nsGfxFactoryPh.cpp @@ -159,10 +159,10 @@ static const nsModuleComponentInfo components[] = "@mozilla.org/gfx/devicecontextspecfactory;1", //"@mozilla.org/gfx/device_context_spec_factory/Ph;1", nsDeviceContextSpecFactoryPhConstructor }, - { "Print Options", - NS_PRINTOPTIONS_CID, - // "@mozilla.org/gfx/printoptions;1", - "@mozilla.org/gfx/printoptions;1", + { "PrintSettings Service", + NS_PRINTSETTINGSSERVICE_CID, + // "@mozilla.org/gfx/printsettings-service;1", + "@mozilla.org/gfx/printsettings-service;1", nsPrintOptionsPhConstructor }, { "Ph Font Enumerator", NS_FONT_ENUMERATOR_CID, diff --git a/mozilla/gfx/src/windows/nsDeviceContextSpecFactoryW.cpp b/mozilla/gfx/src/windows/nsDeviceContextSpecFactoryW.cpp index 437c7b4c973..14265c8c47c 100644 --- a/mozilla/gfx/src/windows/nsDeviceContextSpecFactoryW.cpp +++ b/mozilla/gfx/src/windows/nsDeviceContextSpecFactoryW.cpp @@ -51,7 +51,6 @@ nsDeviceContextSpecFactoryWin :: ~nsDeviceContextSpecFactoryWin() static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID); static NS_DEFINE_IID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID); -static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); NS_IMPL_ISUPPORTS1(nsDeviceContextSpecFactoryWin, nsIDeviceContextSpecFactory) diff --git a/mozilla/gfx/src/windows/nsDeviceContextSpecWin.cpp b/mozilla/gfx/src/windows/nsDeviceContextSpecWin.cpp index d487666aa8c..7d224241873 100644 --- a/mozilla/gfx/src/windows/nsDeviceContextSpecWin.cpp +++ b/mozilla/gfx/src/windows/nsDeviceContextSpecWin.cpp @@ -60,7 +60,6 @@ #include "nsIServiceManager.h" #include "nsReadableUtils.h" #include "nsGfxCIID.h" -static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); // File Picker #include "nsILocalFile.h" diff --git a/mozilla/gfx/src/windows/nsGfxFactoryWin.cpp b/mozilla/gfx/src/windows/nsGfxFactoryWin.cpp index f4cbd092f71..6e2d20f523f 100644 --- a/mozilla/gfx/src/windows/nsGfxFactoryWin.cpp +++ b/mozilla/gfx/src/windows/nsGfxFactoryWin.cpp @@ -196,8 +196,8 @@ static const nsModuleComponentInfo components[] = nsScriptableRegionConstructor }, { "nsPrintOptionsWin", - NS_PRINTOPTIONS_CID, - "@mozilla.org/gfx/printoptions;1", + NS_PRINTSETTINGSSERVICE_CID, + "@mozilla.org/gfx/printsettings-service;1", nsPrintOptionsWinConstructor }, { "nsFontEnumeratorWin", diff --git a/mozilla/gfx/src/xlib/nsGfxFactoryXlib.cpp b/mozilla/gfx/src/xlib/nsGfxFactoryXlib.cpp index 10964313660..46315a88617 100644 --- a/mozilla/gfx/src/xlib/nsGfxFactoryXlib.cpp +++ b/mozilla/gfx/src/xlib/nsGfxFactoryXlib.cpp @@ -159,10 +159,10 @@ static const nsModuleComponentInfo components[] = // "@mozilla.org/gfx/device_context_spec_factory/xlib;1", "@mozilla.org/gfx/devicecontextspecfactory;1", nsDeviceContextSpecFactoryXlibConstructor }, - { "Print Options", - NS_PRINTOPTIONS_CID, - // "@mozilla.org/gfx/printoptions;1", - "@mozilla.org/gfx/printoptions;1", + { "PrintSettings Service", + NS_PRINTSETTINGSSERVICE_CID, + // "@mozilla.org/gfx/printsettings-service;1", + "@mozilla.org/gfx/printsettings-service;1", nsPrintOptionsXlibConstructor }, { "Xlib Font Enumerator", NS_FONT_ENUMERATOR_CID, diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index 9b5506770db..a2c385d79e7 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -123,15 +123,19 @@ // Print Options #include "nsIPrintSettings.h" +#include "nsIPrintSettingsService.h" #include "nsIPrintOptions.h" #include "nsGfxCIID.h" #include "nsIServiceManager.h" #include "nsHTMLAtoms.h" // XXX until atoms get factored into nsLayoutAtoms #include "nsISimpleEnumerator.h" #include "nsISupportsPrimitives.h" -static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); static NS_DEFINE_IID(kPrinterEnumeratorCID, NS_PRINTER_ENUMERATOR_CID); +// PrintOptions is now implemented by PrintSettingsService +const char* kPrintSettingsServiceCID = "@mozilla.org/gfx/printsettings-service;1"; +const char* kPrintOptionsCID = "@mozilla.org/gfx/printsettings-service;1"; + // Printing Events #include "nsIEventQueue.h" #include "nsIEventQueueService.h" @@ -6427,21 +6431,24 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings, // to if we have a PrintOptions first, because we can't do anything // below without it then inside we check to se if the printSettings // is null to know if we need to create on. + // if they don't pass in a PrintSettings, then get the Global PS mPrt->mPrintSettings = aPrintSettings; - mPrt->mPrintOptions = do_GetService(kPrintOptionsCID, &rv); - if (NS_SUCCEEDED(rv) && mPrt->mPrintOptions) { - // if they don't pass in a PrintSettings, then make one - if (mPrt->mPrintSettings == nsnull) { - mPrt->mPrintOptions->CreatePrintSettings(getter_AddRefs(mPrt->mPrintSettings)); - } - NS_ASSERTION(mPrt->mPrintSettings, "You can't PrintPreview without a PrintSettings!"); + if (!mPrt->mPrintSettings) { + GetGlobalPrintSettings(getter_AddRefs(mPrt->mPrintSettings)); + } + mPrt->mPrintOptions = do_GetService(kPrintOptionsCID, &rv); + if (NS_SUCCEEDED(rv) && mPrt->mPrintOptions && mPrt->mPrintSettings) { // Get the default printer name and set it into the PrintSettings - if (NS_FAILED(CheckForPrinters(mPrt->mPrintOptions, mPrt->mPrintSettings, NS_ERROR_GFX_PRINTER_PRINTPREVIEW, PR_FALSE))) { - delete mPrt; - mPrt = nsnull; - return NS_ERROR_FAILURE; - } + rv = CheckForPrinters(mPrt->mPrintOptions, mPrt->mPrintSettings, NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE, PR_TRUE); + } else { + NS_ASSERTION(mPrt->mPrintSettings, "You can't Print without a PrintSettings!"); + rv = NS_ERROR_FAILURE; + } + if (NS_FAILED(rv)) { + delete mPrt; + mPrt = nsnull; + return NS_ERROR_FAILURE; } // Let's print ... @@ -6541,7 +6548,7 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings, if (factory) { nsCOMPtr devspec; nsCOMPtr dx; - nsresult rv = factory->CreateDeviceContextSpec(mWindow, aPrintSettings, *getter_AddRefs(devspec), PR_TRUE); + nsresult rv = factory->CreateDeviceContextSpec(mWindow, mPrt->mPrintSettings, *getter_AddRefs(devspec), PR_TRUE); if (NS_SUCCEEDED(rv)) { rv = mDeviceContext->GetDeviceContextFor(devspec, *getter_AddRefs(ppDC)); if (NS_SUCCEEDED(rv)) { @@ -6818,23 +6825,24 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings, return NS_ERROR_OUT_OF_MEMORY; } - // if they don't pass in a PrintSettings, then make one - // it will have all the default values + // if they don't pass in a PrintSettings, then get the Global PS mPrt->mPrintSettings = aPrintSettings; - mPrt->mPrintOptions = do_GetService(kPrintOptionsCID, &rv); - if (NS_SUCCEEDED(rv) && mPrt->mPrintOptions) { - // if they don't pass in a PrintSettings, then make one - if (mPrt->mPrintSettings == nsnull) { - mPrt->mPrintOptions->CreatePrintSettings(getter_AddRefs(mPrt->mPrintSettings)); - } - NS_ASSERTION(mPrt->mPrintSettings, "You can't PrintPreview without a PrintSettings!"); + if (!mPrt->mPrintSettings) { + GetGlobalPrintSettings(getter_AddRefs(mPrt->mPrintSettings)); + } + mPrt->mPrintOptions = do_GetService(kPrintOptionsCID, &rv); + if (NS_SUCCEEDED(rv) && mPrt->mPrintOptions && mPrt->mPrintSettings) { // Get the default printer name and set it into the PrintSettings - if (NS_FAILED(CheckForPrinters(mPrt->mPrintOptions, mPrt->mPrintSettings, NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE, PR_TRUE))) { - delete mPrt; - mPrt = nsnull; - return NS_ERROR_FAILURE; - } + rv = CheckForPrinters(mPrt->mPrintOptions, mPrt->mPrintSettings, NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE, PR_TRUE); + } else { + NS_ASSERTION(mPrt->mPrintSettings, "You can't Print without a PrintSettings!"); + rv = NS_ERROR_FAILURE; + } + if (NS_FAILED(rv)) { + delete mPrt; + mPrt = nsnull; + return NS_ERROR_FAILURE; } mPrt->mPrintSettings->SetIsCancelled(PR_FALSE); mPrt->mPrintSettings->GetShrinkToFit(&mPrt->mShrinkToFit); @@ -6972,7 +6980,7 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings, // NS_ERROR_NOT_IMPLEMENTED indicates they want default behavior // Any other error code means we must bail out // - rv = printPromptService->ShowPrintDialog(domWin, this, aPrintSettings); + rv = printPromptService->ShowPrintDialog(domWin, this, mPrt->mPrintSettings); if (rv == NS_ERROR_NOT_IMPLEMENTED) { // This means the Dialog service was there, // but they choose not to implement this dialog and @@ -8221,57 +8229,6 @@ DocumentViewerImpl::EnumerateDocumentNames(PRUint32* aCount, } -/* readonly attribute nsIPrintSettings newPrintSettings; */ -NS_IMETHODIMP -DocumentViewerImpl::GetNewPrintSettings(nsIPrintSettings * *aNewPrintSettings) -{ - NS_ENSURE_ARG_POINTER(aNewPrintSettings); - - nsresult rv = NS_ERROR_FAILURE; - nsCOMPtr printService = do_GetService(kPrintOptionsCID, &rv); - if (NS_SUCCEEDED(rv)) { - rv = printService->CreatePrintSettings(aNewPrintSettings); - InitPrintSettingsFromPrinter(nsnull, *aNewPrintSettings); - } - return rv; -} - -/* readonly attribute wstring defaultPrinterName; */ -NS_IMETHODIMP -DocumentViewerImpl::GetDefaultPrinterName(PRUnichar * *aDefaultPrinterName) -{ - NS_ENSURE_ARG_POINTER(aDefaultPrinterName); - - nsresult rv; - nsCOMPtr prtEnum = do_GetService(kPrinterEnumeratorCID, &rv); - if (prtEnum) { - prtEnum->GetDefaultPrinterName(aDefaultPrinterName); - } - return rv; -} - -/* void initPrintSettingsFromPrinter (in wstring aPrinterName, in nsIPrintSettings aPrintSettings); */ -NS_IMETHODIMP -DocumentViewerImpl::InitPrintSettingsFromPrinter(const PRUnichar *aPrinterName, nsIPrintSettings *aPrintSettings) -{ - NS_ENSURE_ARG_POINTER(aPrintSettings); - - PRUnichar* printerName = nsnull; - if (!aPrinterName) { - GetDefaultPrinterName(&printerName); - if (!printerName || !*printerName) return NS_OK; - } - nsresult rv; - nsCOMPtr prtEnum = do_GetService(kPrinterEnumeratorCID, &rv); - if (prtEnum) { - prtEnum->InitPrintSettingsFromPrinter(aPrinterName?aPrinterName:printerName, aPrintSettings); - } - if (printerName) { - nsMemory::Free(printerName); - } - return NS_OK; -} - /* readonly attribute nsIPrintSettings globalPrintSettings; */ NS_IMETHODIMP DocumentViewerImpl::GetGlobalPrintSettings(nsIPrintSettings * *aGlobalPrintSettings) @@ -8279,9 +8236,10 @@ DocumentViewerImpl::GetGlobalPrintSettings(nsIPrintSettings * *aGlobalPrintSetti NS_ENSURE_ARG_POINTER(aGlobalPrintSettings); nsresult rv = NS_ERROR_FAILURE; - nsCOMPtr printService = do_GetService(kPrintOptionsCID, &rv); + //nsCOMPtr printSettingsService = do_GetService(kPrintOptionsCID, &rv); + nsCOMPtr printSettingsService = do_GetService(kPrintSettingsServiceCID, &rv); if (NS_SUCCEEDED(rv)) { - rv = printService->GetGlobalPrintSettings(aGlobalPrintSettings); + rv = printSettingsService->GetGlobalPrintSettings(aGlobalPrintSettings); } return rv; } @@ -8377,30 +8335,6 @@ DocumentViewerImpl::Cancel() return NS_ERROR_FAILURE; } -/* void initPrintSettingsFromPrefs (in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags); */ -NS_IMETHODIMP -DocumentViewerImpl::InitPrintSettingsFromPrefs(nsIPrintSettings *aPrintSettings, PRBool aUsePrinterNamePrefix, PRUint32 aFlags) -{ - nsresult rv; - nsCOMPtr printService = do_GetService(kPrintOptionsCID, &rv); - if (NS_SUCCEEDED(rv) && printService) { - return printService->InitPrintSettingsFromPrefs(aPrintSettings, aUsePrinterNamePrefix, aFlags); - } - return NS_OK; -} - -/* void savePrintSettingsToPrefs (in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags); */ -NS_IMETHODIMP -DocumentViewerImpl::SavePrintSettingsToPrefs(nsIPrintSettings *aPrintSettings, PRBool aUsePrinterNamePrefix, PRUint32 aFlags) -{ - nsresult rv; - nsCOMPtr printService = do_GetService(kPrintOptionsCID, &rv); - if (NS_SUCCEEDED(rv) && printService) { - return printService->SavePrintSettingsToPrefs(aPrintSettings, aUsePrinterNamePrefix, aFlags); - } - return NS_OK; -} - /** --------------------------------------------------- * Get the Focused Frame for a documentviewer * diff --git a/mozilla/layout/generic/nsPageFrame.cpp b/mozilla/layout/generic/nsPageFrame.cpp index 3e29d1b6066..3974c6be3b8 100644 --- a/mozilla/layout/generic/nsPageFrame.cpp +++ b/mozilla/layout/generic/nsPageFrame.cpp @@ -76,7 +76,6 @@ #include "nsIPrintSettings.h" #include "nsGfxCIID.h" #include "nsIServiceManager.h" -static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); // Widget Creation #include "nsIWidget.h" diff --git a/mozilla/layout/generic/nsSimplePageSequence.cpp b/mozilla/layout/generic/nsSimplePageSequence.cpp index 4569dfc5529..2968cba4a8b 100644 --- a/mozilla/layout/generic/nsSimplePageSequence.cpp +++ b/mozilla/layout/generic/nsSimplePageSequence.cpp @@ -80,7 +80,8 @@ static NS_DEFINE_CID(kLocaleServiceCID, NS_LOCALESERVICE_CID); #include "nsIPrintOptions.h" #include "nsGfxCIID.h" #include "nsIServiceManager.h" -static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); +const char* kPrintOptionsCID = "@mozilla.org/gfx/printsettings-service;1"; + // static NS_DEFINE_CID(kRegionCID, NS_REGION_CID); diff --git a/mozilla/layout/html/base/src/nsPageFrame.cpp b/mozilla/layout/html/base/src/nsPageFrame.cpp index 3e29d1b6066..3974c6be3b8 100644 --- a/mozilla/layout/html/base/src/nsPageFrame.cpp +++ b/mozilla/layout/html/base/src/nsPageFrame.cpp @@ -76,7 +76,6 @@ #include "nsIPrintSettings.h" #include "nsGfxCIID.h" #include "nsIServiceManager.h" -static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); // Widget Creation #include "nsIWidget.h" diff --git a/mozilla/layout/html/base/src/nsSimplePageSequence.cpp b/mozilla/layout/html/base/src/nsSimplePageSequence.cpp index 4569dfc5529..2968cba4a8b 100644 --- a/mozilla/layout/html/base/src/nsSimplePageSequence.cpp +++ b/mozilla/layout/html/base/src/nsSimplePageSequence.cpp @@ -80,7 +80,8 @@ static NS_DEFINE_CID(kLocaleServiceCID, NS_LOCALESERVICE_CID); #include "nsIPrintOptions.h" #include "nsGfxCIID.h" #include "nsIServiceManager.h" -static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); +const char* kPrintOptionsCID = "@mozilla.org/gfx/printsettings-service;1"; + // static NS_DEFINE_CID(kRegionCID, NS_REGION_CID); diff --git a/mozilla/modules/plugin/base/src/nsPluginViewer.cpp b/mozilla/modules/plugin/base/src/nsPluginViewer.cpp index efd59f9d264..ba8a3b8d6cf 100644 --- a/mozilla/modules/plugin/base/src/nsPluginViewer.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginViewer.cpp @@ -843,30 +843,11 @@ PluginViewerImpl::Print(nsIPrintSettings* aPrintSettings, } -NS_IMETHODIMP -PluginViewerImpl::GetNewPrintSettings(nsIPrintSettings * *aNewPrintSettings) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* readonly attribute wstring defaultPrinterName; */ -NS_IMETHODIMP -PluginViewerImpl::GetDefaultPrinterName(PRUnichar * *aDefaultPrinterName) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void initPrintSettingsFromPrinter (in wstring aPrinterName, in nsIPrintSettings aPrintSettings); */ -NS_IMETHODIMP -PluginViewerImpl::InitPrintSettingsFromPrinter(const PRUnichar *aPrinterName, nsIPrintSettings *aPrintSettings) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} /* readonly attribute nsIPrintSettings globalPrintSettings; */ -NS_IMETHODIMP +NS_IMETHODIMP PluginViewerImpl::GetGlobalPrintSettings(nsIPrintSettings * *aGlobalPrintSettings) { - return NS_ERROR_NOT_IMPLEMENTED; + return NS_ERROR_NOT_IMPLEMENTED; } /* void printPreview (in nsIPrintSettings aThePrintSettings); */ @@ -912,20 +893,6 @@ PluginViewerImpl::Cancel() return NS_ERROR_NOT_IMPLEMENTED; } -/* void initPrintSettingsFromPrefs (in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags); */ -NS_IMETHODIMP -PluginViewerImpl::InitPrintSettingsFromPrefs(nsIPrintSettings *aPrintSettings, PRBool aUsePrinterNamePrefix, PRUint32 aFlags) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void savePrintSettingsToPrefs (in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags); */ -NS_IMETHODIMP -PluginViewerImpl::SavePrintSettingsToPrefs(nsIPrintSettings *aPrintSettings, PRBool aUsePrinterNamePrefix, PRUint32 aFlags) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - /* void enumerateDocumentNames (out PRUint32 aCount, [array, size_is (aCount), retval] out wstring aResult); */ NS_IMETHODIMP PluginViewerImpl::EnumerateDocumentNames(PRUint32 *aCount, PRUnichar ***aResult) diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp index 962847f6732..d3f59f6954f 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp @@ -2211,7 +2211,7 @@ void nsBrowserWindow::DoPrint(void) nsCOMPtr webBrowserPrint = do_QueryInterface(viewer); if (webBrowserPrint) { if (!mPrintSettings) { - webBrowserPrint->GetNewPrintSettings(getter_AddRefs(mPrintSettings)); + webBrowserPrint->GetGlobalPrintSettings(getter_AddRefs(mPrintSettings)); } webBrowserPrint->Print(mPrintSettings, (nsIWebProgressListener*)nsnull); } diff --git a/mozilla/xpfe/browser/resources/content/browser.js b/mozilla/xpfe/browser/resources/content/browser.js index 340fa24d718..70a81416193 100644 --- a/mozilla/xpfe/browser/resources/content/browser.js +++ b/mozilla/xpfe/browser/resources/content/browser.js @@ -198,7 +198,7 @@ function BrowserExitPrintPreview() mainWin.setAttribute("onclose", gOldCloseHandler); } -function GetPrintSettings(webBrowserPrint) +function GetPrintSettings() { var prevPS = gPrintSettings; @@ -211,13 +211,15 @@ function GetPrintSettings(webBrowserPrint) gSavePrintSettings = pref.getBoolPref("print.save_print_settings", false); } + var psService = Components.classes["@mozilla.org/gfx/printsettings-service;1"] + .getService(Components.interfaces.nsIPrintSettingsService); if (gPrintSettingsAreGlobal) { - gPrintSettings = webBrowserPrint.globalPrintSettings; + gPrintSettings = psService.globalPrintSettings; if (gSavePrintSettings) { - webBrowserPrint.initPrintSettingsFromPrefs(gPrintSettings, false, gPrintSettings.kInitSaveNativeData); + psService.initPrintSettingsFromPrefs(gPrintSettings, false, gPrintSettings.kInitSaveNativeData); } } else { - gPrintSettings = webBrowserPrint.newPrintSettings; + gPrintSettings = psService.newPrintSettings; } } } catch (e) { @@ -249,7 +251,7 @@ function BrowserPrintPreview() var webBrowserPrint = ifreq.getInterface( Components.interfaces.nsIWebBrowserPrint); if (webBrowserPrint) { - gPrintSettings = GetPrintSettings(webBrowserPrint); + gPrintSettings = GetPrintSettings(); webBrowserPrint.printPreview(gPrintSettings, null); } @@ -274,7 +276,7 @@ function BrowserPrintSetup() var ifreq = _content.QueryInterface(Components.interfaces.nsIInterfaceRequestor); var webBrowserPrint = ifreq.getInterface(Components.interfaces.nsIWebBrowserPrint); if (webBrowserPrint) { - gPrintSettings = GetPrintSettings(webBrowserPrint); + gPrintSettings = GetPrintSettings(); } didOK = goPageSetup(window, gPrintSettings); // from utilityOverlay.js @@ -282,7 +284,9 @@ function BrowserPrintSetup() if (webBrowserPrint) { if (gPrintSettingsAreGlobal && gSavePrintSettings) { - webBrowserPrint.savePrintSettingsToPrefs(gPrintSettings, false, gPrintSettings.kInitSaveNativeData); + var psService = Components.classes["@mozilla.org/gfx/printsettings-service;1"] + .getService(Components.interfaces.nsIPrintSettingsService); + psService.savePrintSettingsToPrefs(gPrintSettings, false, gPrintSettings.kInitSaveNativeData); } if (webBrowserPrint.doingPrintPreview) { webBrowserPrint.printPreview(gPrintSettings, null); @@ -301,7 +305,7 @@ function BrowserPrint() var ifreq = _content.QueryInterface(Components.interfaces.nsIInterfaceRequestor); var webBrowserPrint = ifreq.getInterface(Components.interfaces.nsIWebBrowserPrint); if (webBrowserPrint) { - gPrintSettings = GetPrintSettings(webBrowserPrint); + gPrintSettings = GetPrintSettings(); webBrowserPrint.print(gPrintSettings, null); } } catch (e) { diff --git a/mozilla/xpfe/global/resources/content/printdialog.js b/mozilla/xpfe/global/resources/content/printdialog.js index b7c6c4a6578..3c3104f7df1 100644 --- a/mozilla/xpfe/global/resources/content/printdialog.js +++ b/mozilla/xpfe/global/resources/content/printdialog.js @@ -26,6 +26,7 @@ var dialog; var printService = null; +var printOptions = null; var gOriginalNumCopies = 1; var paramBlock; @@ -176,7 +177,7 @@ listElement.prototype = //--------------------------------------------------- function getPrinters() { - var printerEnumerator = printService.availablePrinters(); + var printerEnumerator = printOptions.availablePrinters(); var selectElement = new listElement(dialog.printerList); selectElement.clearList(); @@ -198,7 +199,7 @@ function setPrinterDefaultsForSelectedPrinter() gPrintSettings.printerName = dialog.printerList.value; // First get any defaults from the printer - gWebBrowserPrint.initPrintSettingsFromPrinter(gPrintSettings.printerName, gPrintSettings); + printService.initPrintSettingsFromPrinter(gPrintSettings.printerName, gPrintSettings); var flags = gPrintSetInterface.kInitSavePaperSizeType | gPrintSetInterface.kInitSavePaperSizeUnit | gPrintSetInterface.kInitSavePaperWidth | gPrintSetInterface.kInitSavePaperHeight | @@ -206,7 +207,7 @@ function setPrinterDefaultsForSelectedPrinter() gPrintSetInterface.kInitSavePrintCommand; // now augment them with any values from last time - gWebBrowserPrint.initPrintSettingsFromPrefs(gPrintSettings, true, flags); + printService.initPrintSettingsFromPrefs(gPrintSettings, true, flags); } @@ -252,11 +253,12 @@ function loadDialog() var print_tofile = ""; try { - printService = Components.classes["@mozilla.org/gfx/printoptions;1"]; + printService = Components.classes["@mozilla.org/gfx/printsettings-service;1"]; if (printService) { printService = printService.getService(); if (printService) { - printService = printService.QueryInterface(Components.interfaces.nsIPrintOptions); + printService = printService.QueryInterface(Components.interfaces.nsIPrintSettingsService); + printOptions = printService.QueryInterface(Components.interfaces.nsIPrintOptions); } } } catch(e) {} @@ -435,12 +437,12 @@ function onAccept() saveToPrefs = prefs.getBoolPref("print.save_print_settings"); } - if (saveToPrefs && gWebBrowserPrint != null) { + if (saveToPrefs && printService != null) { var flags = gPrintSetInterface.kInitSavePaperSizeType | gPrintSetInterface.kInitSavePaperSizeUnit | gPrintSetInterface.kInitSavePaperWidth | gPrintSetInterface.kInitSavePaperHeight | gPrintSetInterface.kInitSavePaperName | gPrintSetInterface.kInitSavePrintCommand; - gWebBrowserPrint.savePrintSettingsToPrefs(gPrintSettings, true, flags); + printService.savePrintSettingsToPrefs(gPrintSettings, true, flags); } // set return value to "print"