diff --git a/gfx/public/Makefile.in b/gfx/public/Makefile.in index 98cfd011334b..f1580d46acf0 100644 --- a/gfx/public/Makefile.in +++ b/gfx/public/Makefile.in @@ -72,7 +72,6 @@ EXPORTS = \ ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) EXPORTS += \ - nsIPrintingContext.h \ nsRepeater.h \ $(NULL) endif diff --git a/gfx/public/nsIPrintingContext.h b/gfx/public/nsIPrintingContext.h deleted file mode 100644 index bb8764d460fb..000000000000 --- a/gfx/public/nsIPrintingContext.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla 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/MPL/ - * - * 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) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Patrick C. Beard - * - * Alternatively, the contents of this file may be used under the terms of - * either of 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 MPL, 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 MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsIPrintingContextMac_h___ -#define nsIPrintingContextMac_h___ - -#include "nsISupports.h" - -class nsIPrintSettings; - -// 3d5917da-1dd2-11b2-bc7b-aa83823362e0 -#define NS_IPRINTING_CONTEXT_IID \ -{ 0xD9853908, 0xA34D, 0x4D8B, \ -{ 0xB4, 0xD6, 0x5D, 0xC3, 0x6E, 0x21, 0x1B, 0xDD } } - -class nsIPrintingContext : public nsISupports { -public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPRINTING_CONTEXT_IID) - /** - * Initialize the printing context for use. - * @param aIsPrintPreview TRUE if doing print preview, FALSE if normal printing. - * @return error status - */ - NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview) = 0; - - /** - * This will tell if the printmanager is currently open - * @update dc 12/03/98 - * @param aIsOpen True or False depending if the printmanager is open - * @return error status - */ - NS_IMETHOD PrintManagerOpen(PRBool* aIsOpen) = 0; - - /** - * Closes the printmanager if it is open. - * @update dc 12/03/98 - * @return error status - */ - NS_IMETHOD ClosePrintManager() = 0; - - NS_IMETHOD BeginDocument(PRUnichar* aTitle, - PRUnichar* aPrintToFileName, - PRInt32 aStartPage, - PRInt32 aEndPage) = 0; - - NS_IMETHOD EndDocument() = 0; - - NS_IMETHOD BeginPage() = 0; - - NS_IMETHOD EndPage() = 0; - - NS_IMETHOD GetPrinterResolution(double* aResolution) = 0; - - NS_IMETHOD GetPageRect(double* aTop, double* aLeft, double* aBottom, double* aRight) = 0; -}; - -NS_DEFINE_STATIC_IID_ACCESSOR(nsIPrintingContext, NS_IPRINTING_CONTEXT_IID) - -#endif /* nsIPrintingContextMac_h___ */ diff --git a/gfx/src/mac/Makefile.in b/gfx/src/mac/Makefile.in index af05c8b28a82..f53178b9ad90 100644 --- a/gfx/src/mac/Makefile.in +++ b/gfx/src/mac/Makefile.in @@ -69,8 +69,6 @@ REQUIRES = xpcom \ CPPSRCS = \ nsATSUIUtils.cpp \ nsDeviceContextMac.cpp \ - nsDeviceContextSpecFactoryM.cpp \ - nsDeviceContextSpecX.cpp \ nsDrawingSurfaceMac.cpp \ nsFontMetricsMac.cpp \ nsGfxFactoryMac.cpp \ @@ -82,9 +80,6 @@ CPPSRCS = \ nsUnicodeFontMappingMac.cpp \ nsUnicodeMappingUtil.cpp \ nsUnicodeRenderingToolkit.cpp \ - nsPrintOptionsX.cpp \ - nsPrintSettingsX.cpp \ - nsPrintSessionX.cpp \ nsFontUtils.cpp \ $(NULL) diff --git a/gfx/src/mac/nsDeviceContextSpecFactoryM.cpp b/gfx/src/mac/nsDeviceContextSpecFactoryM.cpp deleted file mode 100644 index b916ca1bc942..000000000000 --- a/gfx/src/mac/nsDeviceContextSpecFactoryM.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla 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/MPL/ - * - * 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) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of 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 MPL, 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 MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsDeviceContextSpecFactoryM.h" -#include "nsIDeviceContextSpec.h" -#include "nsIPrintingContext.h" -#include "nsWidgetsCID.h" -#include "plstr.h" -#include "nsDeviceContextSpecX.h" - - -/** ------------------------------------------------------- - * Constructor - * @update dc 12/02/98 - */ -nsDeviceContextSpecFactoryMac :: nsDeviceContextSpecFactoryMac() -{ -} - -/** ------------------------------------------------------- - * Destructor - * @update dc 12/02/98 - */ -nsDeviceContextSpecFactoryMac :: ~nsDeviceContextSpecFactoryMac() -{ -} - -NS_IMPL_ISUPPORTS1(nsDeviceContextSpecFactoryMac, nsIDeviceContextSpecFactory) - -/** ------------------------------------------------------- - * Initialize the device context spec factory - * @update dc 12/02/98 - */ -NS_IMETHODIMP nsDeviceContextSpecFactoryMac :: Init(void) -{ - return NS_OK; -} - -/** ------------------------------------------------------- - * Get a device context specification - * @update dc 12/02/98 - */ -NS_IMETHODIMP nsDeviceContextSpecFactoryMac :: CreateDeviceContextSpec(nsIWidget *aWidget, - nsIPrintSettings* aPrintSettings, - nsIDeviceContextSpec *&aNewSpec, - PRBool aIsPrintPreview) -{ - - nsresult rv; - static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID); - nsCOMPtr devSpec = do_CreateInstance(kDeviceContextSpecCID,&rv); - if (NS_SUCCEEDED(rv)) { - nsCOMPtr printingContext = do_QueryInterface(devSpec,&rv); - if (NS_SUCCEEDED(rv)) { - rv = printingContext->Init(aPrintSettings,aIsPrintPreview); - if (NS_SUCCEEDED(rv)) { - aNewSpec = devSpec; - NS_ADDREF(aNewSpec); - } - } - } - return rv; -} diff --git a/gfx/src/mac/nsDeviceContextSpecFactoryM.h b/gfx/src/mac/nsDeviceContextSpecFactoryM.h deleted file mode 100644 index e45165400cf9..000000000000 --- a/gfx/src/mac/nsDeviceContextSpecFactoryM.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla 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/MPL/ - * - * 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) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of 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 MPL, 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 MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsDeviceContextSpecFactoryM_h___ -#define nsDeviceContextSpecFactoryM_h___ - -#include "nsIDeviceContextSpecFactory.h" -#include "nsIDeviceContextSpec.h" - -class nsDeviceContextSpecFactoryMac : public nsIDeviceContextSpecFactory -{ -public: - nsDeviceContextSpecFactoryMac(); - - NS_DECL_ISUPPORTS - - NS_IMETHOD Init(void); - NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget, - nsIPrintSettings* aPrintSettings, - nsIDeviceContextSpec *&aNewSpec, - PRBool aIsPrintPreview); - -protected: - ~nsDeviceContextSpecFactoryMac(); -}; - -#endif diff --git a/gfx/src/mac/nsDeviceContextSpecX.cpp b/gfx/src/mac/nsDeviceContextSpecX.cpp deleted file mode 100644 index 0636881259ce..000000000000 --- a/gfx/src/mac/nsDeviceContextSpecX.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla 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/MPL/ - * - * 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) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Patrick C. Beard - * Simon Fraser - * Conrad Carlen - * - * Alternatively, the contents of this file may be used under the terms of - * either of 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 MPL, 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 MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsDeviceContextSpecX.h" - -#include "prmem.h" -#include "plstr.h" -#include "nsCRT.h" - -#include "nsIServiceManager.h" -#include "nsIPrintOptions.h" -#include "nsIPrintSettingsX.h" - -/** ------------------------------------------------------- - * Construct the nsDeviceContextSpecX - * @update dc 12/02/98 - */ -nsDeviceContextSpecX::nsDeviceContextSpecX() -: mPrintSession(0) -, mPageFormat(kPMNoPageFormat) -, mPrintSettings(kPMNoPrintSettings) -, mSavedPort(0) -, mBeganPrinting(PR_FALSE) -{ -} - -/** ------------------------------------------------------- - * Destroy the nsDeviceContextSpecX - * @update dc 12/02/98 - */ -nsDeviceContextSpecX::~nsDeviceContextSpecX() -{ - ClosePrintManager(); -} - -NS_IMPL_ISUPPORTS2(nsDeviceContextSpecX, nsIDeviceContextSpec, nsIPrintingContext) - -/** ------------------------------------------------------- - * Initialize the nsDeviceContextSpecMac - * @update dc 12/02/98 - */ -NS_IMETHODIMP nsDeviceContextSpecX::Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview) -{ - nsresult rv; - - nsCOMPtr printSettingsX(do_QueryInterface(aPS)); - if (!printSettingsX) - return NS_ERROR_NO_INTERFACE; - - rv = printSettingsX->GetNativePrintSession(&mPrintSession); - if (NS_FAILED(rv)) - return rv; - rv = printSettingsX->GetPMPageFormat(&mPageFormat); - if (NS_FAILED(rv)) - return rv; - rv = printSettingsX->GetPMPrintSettings(&mPrintSettings); - if (NS_FAILED(rv)) - return rv; - - return NS_OK; -} - -NS_IMETHODIMP nsDeviceContextSpecX::PrintManagerOpen(PRBool* aIsOpen) -{ - *aIsOpen = mBeganPrinting; - return NS_OK; -} - -/** ------------------------------------------------------- - * Closes the printmanager if it is open. - * @update dc 12/03/98 - */ -NS_IMETHODIMP nsDeviceContextSpecX::ClosePrintManager() -{ - return NS_OK; -} - -NS_IMETHODIMP nsDeviceContextSpecX::BeginDocument(PRUnichar* aTitle, - PRUnichar* aPrintToFileName, - PRInt32 aStartPage, - PRInt32 aEndPage) -{ - if (aTitle) { - CFStringRef cfString = ::CFStringCreateWithCharacters(NULL, aTitle, nsCRT::strlen(aTitle)); - if (cfString) { - ::PMSetJobNameCFString(mPrintSettings, cfString); - ::CFRelease(cfString); - } - } - - OSStatus status; - status = ::PMSetFirstPage(mPrintSettings, aStartPage, false); - NS_ASSERTION(status == noErr, "PMSetFirstPage failed"); - status = ::PMSetLastPage(mPrintSettings, aEndPage, false); - NS_ASSERTION(status == noErr, "PMSetLastPage failed"); - - status = ::PMSessionBeginDocument(mPrintSession, mPrintSettings, mPageFormat); - if (status != noErr) return NS_ERROR_ABORT; - - return NS_OK; -} - -NS_IMETHODIMP nsDeviceContextSpecX::EndDocument() -{ - ::PMSessionEndDocument(mPrintSession); - return NS_OK; -} - -NS_IMETHODIMP nsDeviceContextSpecX::AbortDocument() -{ - return EndDocument(); -} - -NS_IMETHODIMP nsDeviceContextSpecX::BeginPage() -{ - OSStatus status = ::PMSessionBeginPage(mPrintSession, mPageFormat, NULL); - if (status != noErr) return NS_ERROR_ABORT; - - ::GetPort(&mSavedPort); - void *graphicsContext; - status = ::PMSessionGetGraphicsContext(mPrintSession, kPMGraphicsContextQuickdraw, &graphicsContext); - if (status != noErr) - return NS_ERROR_ABORT; - ::SetPort((CGrafPtr)graphicsContext); - return NS_OK; -} - -NS_IMETHODIMP nsDeviceContextSpecX::EndPage() -{ - OSStatus status = ::PMSessionEndPage(mPrintSession); - if (mSavedPort) - { - ::SetPort(mSavedPort); - mSavedPort = 0; - } - if (status != noErr) - return NS_ERROR_ABORT; - return NS_OK; -} - -NS_IMETHODIMP nsDeviceContextSpecX::GetPrinterResolution(double* aResolution) -{ - PMPrinter printer; - OSStatus status = ::PMSessionGetCurrentPrinter(mPrintSession, &printer); - if (status != noErr) - return NS_ERROR_FAILURE; - - PMResolution defaultResolution; - status = ::PMPrinterGetPrinterResolution(printer, kPMDefaultResolution, &defaultResolution); - if (status != noErr) - return NS_ERROR_FAILURE; - - *aResolution = defaultResolution.hRes; - return NS_OK; -} - -NS_IMETHODIMP nsDeviceContextSpecX::GetPageRect(double* aTop, double* aLeft, double* aBottom, double* aRight) -{ - PMRect pageRect; - ::PMGetAdjustedPageRect(mPageFormat, &pageRect); - *aTop = pageRect.top, *aLeft = pageRect.left; - *aBottom = pageRect.bottom, *aRight = pageRect.right; - return NS_OK; -} diff --git a/gfx/src/mac/nsDeviceContextSpecX.h b/gfx/src/mac/nsDeviceContextSpecX.h deleted file mode 100644 index 062cbfc589e7..000000000000 --- a/gfx/src/mac/nsDeviceContextSpecX.h +++ /dev/null @@ -1,114 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla 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/MPL/ - * - * 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) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Patrick C. Beard - * - * Alternatively, the contents of this file may be used under the terms of - * either of 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 MPL, 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 MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsDeviceContextSpecX_h___ -#define nsDeviceContextSpecX_h___ - -#include "nsIDeviceContextSpec.h" -#include "nsIPrintingContext.h" -#include "nsDeviceContextMac.h" - -#include - -class nsDeviceContextSpecX : public nsIDeviceContextSpec, public nsIPrintingContext -{ -public: - /** - * Construct a nsDeviceContextSpecMac, which is an object which contains and manages a mac printrecord - * @update dc 12/02/98 - */ - nsDeviceContextSpecX(); - - NS_DECL_ISUPPORTS - - /** - * Initialize the nsDeviceContextSpecMac for use. This will allocate a printrecord for use - * @update dc 12/02/98 - * @param aIsPrintPreview TRUE if doing print preview, FALSE if normal printing. - * @return error status - */ - NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview); - - /** - * This will tell if the printmanager is currently open - * @update dc 12/03/98 - * @param aIsOpen True or False depending if the printmanager is open - * @return error status - */ - NS_IMETHOD PrintManagerOpen(PRBool* aIsOpen); - - /** - * Closes the printmanager if it is open. - * @update dc 12/03/98 - * @return error status - */ - NS_IMETHOD ClosePrintManager(); - - NS_IMETHOD BeginDocument(PRUnichar* aTitle, - PRUnichar* aPrintToFileName, - PRInt32 aStartPage, - PRInt32 aEndPage); - - NS_IMETHOD EndDocument(); - - NS_IMETHOD AbortDocument(); - - NS_IMETHOD BeginPage(); - - NS_IMETHOD EndPage(); - - NS_IMETHOD GetPrinterResolution(double* aResolution); - - NS_IMETHOD GetPageRect(double* aTop, double* aLeft, double* aBottom, double* aRight); -protected: -/** - * Destuct a nsDeviceContextSpecMac, this will release the printrecord - * @update dc 12/02/98 - */ - virtual ~nsDeviceContextSpecX(); - -protected: - - PMPrintSession mPrintSession; // printing context. - PMPageFormat mPageFormat; // page format. - PMPrintSettings mPrintSettings; // print settings. - CGrafPtr mSavedPort; // saved graphics port. - PRBool mBeganPrinting; -}; - -#endif diff --git a/gfx/src/mac/nsPrintOptionsX.cpp b/gfx/src/mac/nsPrintOptionsX.cpp deleted file mode 100644 index daf55b59b57f..000000000000 --- a/gfx/src/mac/nsPrintOptionsX.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla 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/MPL/ - * - * 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) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Simon Fraser - * - * Alternatively, the contents of this file may be used under the terms of - * either of 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 MPL, 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 MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include - -#include "nsCOMPtr.h" -#include "nsIServiceManager.h" -#include "nsPrintOptionsX.h" -#include "nsPrintSettingsX.h" - -#include "nsGfxUtils.h" -#include "nsCRT.h" -#include "plbase64.h" -#include "prmem.h" - - -/** --------------------------------------------------- - */ -nsPrintOptionsX::nsPrintOptionsX() -{ -} - -/** --------------------------------------------------- - */ -nsPrintOptionsX::~nsPrintOptionsX() -{ -} - -/** --------------------------------------------------- - * See documentation in nsPrintOptionsImpl.h - */ -nsresult nsPrintOptionsX::_CreatePrintSettings(nsIPrintSettings **_retval) -{ - nsresult rv; - *_retval = nsnull; - - nsPrintSettingsX* printSettings = new nsPrintSettingsX; // does not initially ref count - NS_ENSURE_TRUE(printSettings, NS_ERROR_OUT_OF_MEMORY); - - NS_ADDREF(*_retval = printSettings); // ref count - - rv = printSettings->Init(); - if (NS_FAILED(rv)) { - NS_RELEASE(*_retval); - return rv; - } - - nsXPIDLString printerName; - rv = GetDefaultPrinterName(getter_Copies(printerName)); - NS_ENSURE_SUCCESS(rv, rv); - (*_retval)->SetPrinterName(printerName.get()); - - (void)InitPrintSettingsFromPrefs(*_retval, nsIPrintSettings::kInitSaveAll); - return rv; -} - -/** --------------------------------------------------- - */ -NS_IMETHODIMP -nsPrintOptionsX::ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* [noscript] voidPtr GetNativeData (in short aDataType); */ -NS_IMETHODIMP -nsPrintOptionsX::GetNativeData(PRInt16 aDataType, void * *_retval) -{ - NS_ENSURE_ARG_POINTER(_retval); - *_retval = nsnull; - - return NS_ERROR_NOT_IMPLEMENTED; -} - -#pragma mark - - -nsresult -nsPrintOptionsX::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, PRUint32 aFlags) -{ - nsresult rv; - - rv = nsPrintOptions::ReadPrefs(aPS, aPrinterName, aFlags); - NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::ReadPrefs() failed"); - - nsCOMPtr printSettingsX(do_QueryInterface(aPS)); - if (!printSettingsX) - return NS_ERROR_NO_INTERFACE; - rv = printSettingsX->ReadPageFormatFromPrefs(); - NS_ASSERTION(NS_SUCCEEDED(rv), "nsIPrintSettingsX::ReadPageFormatFromPrefs() failed"); - - return NS_OK; -} - -nsresult -nsPrintOptionsX::WritePrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, PRUint32 aFlags) -{ - nsresult rv; - - rv = nsPrintOptions::WritePrefs(aPS, aPrinterName, aFlags); - NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::WritePrefs() failed"); - - nsCOMPtr printSettingsX(do_QueryInterface(aPS)); - if (!printSettingsX) - return NS_ERROR_NO_INTERFACE; - rv = printSettingsX->WritePageFormatToPrefs(); - NS_ASSERTION(NS_SUCCEEDED(rv), "nsIPrintSettingsX::WritePageFormatToPrefs() failed"); - - return NS_OK; -} diff --git a/gfx/src/mac/nsPrintOptionsX.h b/gfx/src/mac/nsPrintOptionsX.h deleted file mode 100644 index ad26340914ae..000000000000 --- a/gfx/src/mac/nsPrintOptionsX.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla 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/MPL/ - * - * 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) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Simon Fraser - * - * Alternatively, the contents of this file may be used under the terms of - * either of 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 MPL, 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 MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsPrintOptionsX_h__ -#define nsPrintOptionsX_h__ - -#include "nsPrintOptionsImpl.h" - - -//***************************************************************************** -//*** nsPrintOptions -//***************************************************************************** - -class nsPrintOptionsX : public nsPrintOptions -{ -public: - nsPrintOptionsX(); - virtual ~nsPrintOptionsX(); - - NS_IMETHOD ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings); - - NS_IMETHOD GetNativeData(PRInt16 aDataType, void * *_retval); - -protected: - nsresult _CreatePrintSettings(nsIPrintSettings **_retval); - - nsresult ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, PRUint32 aFlags); - nsresult WritePrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, PRUint32 aFlags); -}; - - -#endif /* nsPrintOptionsX_h__ */ diff --git a/gfx/src/mac/nsPrintSessionX.cpp b/gfx/src/mac/nsPrintSessionX.cpp deleted file mode 100644 index f7995670ae25..000000000000 --- a/gfx/src/mac/nsPrintSessionX.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla 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/MPL/ - * - * 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) 2000 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Conrad Carlen - * - * Alternatively, the contents of this file may be used under the terms of - * either of 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 MPL, 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 MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsPrintSessionX.h" - -//***************************************************************************** -//*** nsPrintSessionX -//***************************************************************************** - -NS_IMPL_ISUPPORTS_INHERITED1(nsPrintSessionX, - nsPrintSession, - nsIPrintSessionX) - -//----------------------------------------------------------------------------- -nsPrintSessionX::nsPrintSessionX() -{ -} - -//----------------------------------------------------------------------------- -nsPrintSessionX::~nsPrintSessionX() -{ - if (mSession) { - ::PMRelease(mSession); - mSession = nsnull; - } -} - -//----------------------------------------------------------------------------- -nsresult nsPrintSessionX::Init() -{ - nsresult rv = nsPrintSession::Init(); - if (NS_FAILED(rv)) - return rv; - - OSStatus status = ::PMCreateSession(&mSession); - if (status != noErr) - return NS_ERROR_FAILURE; - - return NS_OK; -} - -//----------------------------------------------------------------------------- -/* readonly attribute nsPMPrintSession nativeSession; */ -NS_IMETHODIMP nsPrintSessionX::GetNativeSession(PMPrintSession *aNativeSession) -{ - NS_ENSURE_ARG_POINTER(aNativeSession); - *aNativeSession = nsnull; - - if (!mSession) - return NS_ERROR_NOT_INITIALIZED; - - *aNativeSession = mSession; - return NS_OK; -} diff --git a/gfx/src/mac/nsPrintSessionX.h b/gfx/src/mac/nsPrintSessionX.h deleted file mode 100644 index b373842a3ecc..000000000000 --- a/gfx/src/mac/nsPrintSessionX.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla 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/MPL/ - * - * 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) 2000 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Conrad Carlen - * - * Alternatively, the contents of this file may be used under the terms of - * either of 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 MPL, 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 MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsPrintSessionX_h__ -#define nsPrintSessionX_h__ - -#include "nsPrintSession.h" -#include "nsIPrintSessionX.h" - -//***************************************************************************** -//*** nsPrintSessionX -//***************************************************************************** - -class nsPrintSessionX : public nsPrintSession, - public nsIPrintSessionX -{ -public: - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIPRINTSESSIONX - - nsPrintSessionX(); - virtual ~nsPrintSessionX(); - - nsresult Init(); - -protected: - PMPrintSession mSession; -}; - -#endif // nsPrintSessionX_h__ diff --git a/gfx/src/mac/nsPrintSettingsX.cpp b/gfx/src/mac/nsPrintSettingsX.cpp deleted file mode 100644 index d1764d334df8..000000000000 --- a/gfx/src/mac/nsPrintSettingsX.cpp +++ /dev/null @@ -1,377 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla 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/MPL/ - * - * 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) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Conrad Carlen - * - * Alternatively, the contents of this file may be used under the terms of - * either of 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 MPL, 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 MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsPrintSettingsX.h" -#include "nsIPrintSessionX.h" - -#include "nsIPrefService.h" -#include "nsIPrefBranch.h" -#include "nsServiceManagerUtils.h" - -#include "plbase64.h" -#include "prmem.h" -#include "nsGfxUtils.h" - -// Constants -#define PRINTING_PREF_BRANCH "print." -#define MAC_OS_X_PAGE_SETUP_PREFNAME "macosx.pagesetup" - - -NS_IMPL_ISUPPORTS_INHERITED1(nsPrintSettingsX, - nsPrintSettings, - nsIPrintSettingsX) - -/** --------------------------------------------------- - */ -nsPrintSettingsX::nsPrintSettingsX() : - mPageFormat(kPMNoPageFormat), - mPrintSettings(kPMNoPrintSettings) -{ -} - -/** --------------------------------------------------- - */ -nsPrintSettingsX::nsPrintSettingsX(const nsPrintSettingsX& src) : - mPageFormat(kPMNoPageFormat), - mPrintSettings(kPMNoPrintSettings) -{ - *this = src; -} - -/** --------------------------------------------------- - */ -nsPrintSettingsX::~nsPrintSettingsX() -{ - if (mPageFormat != kPMNoPageFormat) { - ::PMRelease(mPageFormat); - mPageFormat = kPMNoPageFormat; - } - if (mPrintSettings != kPMNoPrintSettings) { - ::PMRelease(mPrintSettings); - mPrintSettings = kPMNoPrintSettings; - } -} - -/** --------------------------------------------------- - */ -nsPrintSettingsX& nsPrintSettingsX::operator=(const nsPrintSettingsX& rhs) -{ - if (this == &rhs) { - return *this; - } - - nsPrintSettings::operator=(rhs); - - OSStatus status; - - if (mPageFormat != kPMNoPageFormat) { - ::PMRelease(mPageFormat); - mPageFormat = kPMNoPageFormat; - } - if (rhs.mPageFormat != kPMNoPageFormat) { - PMPageFormat pageFormat; - status = ::PMCreatePageFormat(&pageFormat); - if (status == noErr) { - status = ::PMCopyPageFormat(rhs.mPageFormat, pageFormat); - if (status == noErr) - mPageFormat = pageFormat; - else - ::PMRelease(pageFormat); - } - } - - if (mPrintSettings != kPMNoPrintSettings) { - ::PMRelease(mPrintSettings); - mPrintSettings = kPMNoPrintSettings; - } - if (rhs.mPrintSettings != kPMNoPrintSettings) { - PMPrintSettings printSettings; - status = ::PMCreatePrintSettings(&printSettings); - if (status == noErr) { - status = ::PMCopyPrintSettings(rhs.mPrintSettings, printSettings); - if (status == noErr) - mPrintSettings = printSettings; - else - ::PMRelease(printSettings); - } - } - - return *this; -} - -/** --------------------------------------------------- - */ -nsresult nsPrintSettingsX::Init() -{ - OSStatus status; - - PMPrintSession printSession = NULL; - status = ::PMCreateSession(&printSession); - - if (status == noErr) { - // First, create a default page format - status = CreateDefaultPageFormat(printSession, mPageFormat); - - // Then, if no error, create the default print settings - if (status == noErr) { - status = CreateDefaultPrintSettings(printSession, mPrintSettings); - } - OSStatus tempStatus = ::PMRelease(printSession); - if (status == noErr) - status = tempStatus; - } - return (status == noErr) ? NS_OK : NS_ERROR_FAILURE; -} - -/** --------------------------------------------------- - */ -NS_IMETHODIMP nsPrintSettingsX::GetNativePrintSession(PMPrintSession *aNativePrintSession) -{ - NS_ENSURE_ARG_POINTER(aNativePrintSession); - *aNativePrintSession = nsnull; - - nsCOMPtr printSession; - GetPrintSession(getter_AddRefs(printSession)); - if (!printSession) - return NS_ERROR_FAILURE; - nsCOMPtr printSessionX(do_QueryInterface(printSession)); - if (!printSession) - return NS_ERROR_FAILURE; - - return printSessionX->GetNativeSession(aNativePrintSession); -} - -/** --------------------------------------------------- - */ -NS_IMETHODIMP nsPrintSettingsX::GetPMPageFormat(PMPageFormat *aPMPageFormat) -{ - NS_ENSURE_ARG_POINTER(aPMPageFormat); - *aPMPageFormat = kPMNoPageFormat; - NS_ENSURE_STATE(mPageFormat != kPMNoPageFormat); - - *aPMPageFormat = mPageFormat; - OSStatus status = noErr; - - return (status == noErr) ? NS_OK : NS_ERROR_FAILURE; -} - -/** --------------------------------------------------- - */ -NS_IMETHODIMP nsPrintSettingsX::SetPMPageFormat(PMPageFormat aPMPageFormat) -{ - NS_ENSURE_ARG(aPMPageFormat); - - OSStatus status = ::PMRetain(aPMPageFormat); - if (status == noErr) { - if (mPageFormat) - status = ::PMRelease(mPageFormat); - mPageFormat = aPMPageFormat; - } - return (status == noErr) ? NS_OK : NS_ERROR_FAILURE; -} - -/** --------------------------------------------------- - */ -NS_IMETHODIMP nsPrintSettingsX::GetPMPrintSettings(PMPrintSettings *aPMPrintSettings) -{ - NS_ENSURE_ARG_POINTER(aPMPrintSettings); - *aPMPrintSettings = kPMNoPrintSettings; - NS_ENSURE_STATE(mPrintSettings != kPMNoPrintSettings); - - *aPMPrintSettings = mPrintSettings; - OSStatus status = noErr; - - return (status == noErr) ? NS_OK : NS_ERROR_FAILURE; -} - -/** --------------------------------------------------- - */ -NS_IMETHODIMP nsPrintSettingsX::SetPMPrintSettings(PMPrintSettings aPMPrintSettings) -{ - NS_ENSURE_ARG(aPMPrintSettings); - - OSStatus status = ::PMRetain(aPMPrintSettings); - if (status == noErr) { - if (mPrintSettings) - status = ::PMRelease(mPrintSettings); - mPrintSettings = aPMPrintSettings; - } - return (status == noErr) ? NS_OK : NS_ERROR_FAILURE; -} - -/** --------------------------------------------------- - */ -NS_IMETHODIMP nsPrintSettingsX::ReadPageFormatFromPrefs() -{ - nsresult rv; - nsCOMPtr prefService(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); - if (NS_FAILED(rv)) - return rv; - nsCOMPtr prefBranch; - rv = prefService->GetBranch(PRINTING_PREF_BRANCH, getter_AddRefs(prefBranch)); - if (NS_FAILED(rv)) - return rv; - - nsXPIDLCString encodedData; - rv = prefBranch->GetCharPref(MAC_OS_X_PAGE_SETUP_PREFNAME, getter_Copies(encodedData)); - if (NS_FAILED(rv)) - return rv; - - // decode the base64 - PRInt32 encodedDataLen = strlen(encodedData.get()); - char* decodedData = ::PL_Base64Decode(encodedData.get(), encodedDataLen, nsnull); - if (!decodedData) - return NS_ERROR_FAILURE; - - Handle decodedDataHandle = nsnull; - OSErr err = ::PtrToHand(decodedData, &decodedDataHandle, (encodedDataLen * 3) / 4); - PR_Free(decodedData); - if (err != noErr) - return NS_ERROR_OUT_OF_MEMORY; - - StHandleOwner handleOwner(decodedDataHandle); - - OSStatus status; - PMPageFormat newPageFormat = kPMNoPageFormat; - - status = ::PMCreatePageFormat(&newPageFormat); - if (status == noErr) { - status = ::PMUnflattenPageFormat(decodedDataHandle, &newPageFormat); - if (status == noErr) { - if (mPageFormat) - status = ::PMRelease(mPageFormat); - mPageFormat = newPageFormat; // PMCreatePageFormat returned it with a refcnt of 1 - } - } - return (status == noErr) ? NS_OK : NS_ERROR_FAILURE; -} - -/** --------------------------------------------------- - */ -NS_IMETHODIMP nsPrintSettingsX::WritePageFormatToPrefs() -{ - if (mPageFormat == kPMNoPageFormat) - return NS_ERROR_NOT_INITIALIZED; - - nsresult rv; - nsCOMPtr prefService(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); - if (NS_FAILED(rv)) - return rv; - nsCOMPtr prefBranch; - rv = prefService->GetBranch(PRINTING_PREF_BRANCH, getter_AddRefs(prefBranch)); - if (NS_FAILED(rv)) - return rv; - - Handle pageFormatHandle = nsnull; - OSStatus err = ::PMFlattenPageFormat(mPageFormat, &pageFormatHandle); - if (err != noErr) - return NS_ERROR_FAILURE; - - StHandleOwner handleOwner(pageFormatHandle); - StHandleLocker handleLocker(pageFormatHandle); - - nsXPIDLCString encodedData; - encodedData.Adopt(::PL_Base64Encode(*pageFormatHandle, ::GetHandleSize(pageFormatHandle), nsnull)); - if (!encodedData.get()) - return NS_ERROR_OUT_OF_MEMORY; - - return prefBranch->SetCharPref(MAC_OS_X_PAGE_SETUP_PREFNAME, encodedData); -} - -//------------------------------------------- -nsresult nsPrintSettingsX::_Clone(nsIPrintSettings **_retval) -{ - NS_ENSURE_ARG_POINTER(_retval); - *_retval = nsnull; - - nsPrintSettingsX *newSettings = new nsPrintSettingsX(*this); - if (!newSettings) - return NS_ERROR_FAILURE; - *_retval = newSettings; - NS_ADDREF(*_retval); - return NS_OK; -} - - -//------------------------------------------- -NS_IMETHODIMP nsPrintSettingsX::_Assign(nsIPrintSettings *aPS) -{ - nsPrintSettingsX *printSettingsX = NS_STATIC_CAST(nsPrintSettingsX*, aPS); - if (!printSettingsX) - return NS_ERROR_UNEXPECTED; - *this = *printSettingsX; - return NS_OK; -} - -//------------------------------------------- -OSStatus nsPrintSettingsX::CreateDefaultPageFormat(PMPrintSession aSession, PMPageFormat& outFormat) -{ - OSStatus status; - PMPageFormat pageFormat; - - outFormat = kPMNoPageFormat; - status = ::PMCreatePageFormat(&pageFormat); - if (status == noErr && pageFormat != kPMNoPageFormat) { - status = ::PMSessionDefaultPageFormat(aSession, pageFormat); - if (status == noErr) { - outFormat = pageFormat; - return NS_OK; - } - } - return status; -} - -//------------------------------------------- - -OSStatus nsPrintSettingsX::CreateDefaultPrintSettings(PMPrintSession aSession, PMPrintSettings& outSettings) -{ - OSStatus status; - PMPrintSettings printSettings; - - outSettings = kPMNoPrintSettings; - status = ::PMCreatePrintSettings(&printSettings); - if (status == noErr && printSettings != kPMNoPrintSettings) { - status = ::PMSessionDefaultPrintSettings(aSession, printSettings); - if (status == noErr) { - outSettings = printSettings; - return noErr; - } - } - return status; -} - diff --git a/gfx/src/mac/nsPrintSettingsX.h b/gfx/src/mac/nsPrintSettingsX.h deleted file mode 100644 index be99702e2d17..000000000000 --- a/gfx/src/mac/nsPrintSettingsX.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla 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/MPL/ - * - * 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 the Mozilla browser. - * - * The Initial Developer of the Original Code is - * Netscape Communications, Inc. - * Portions created by the Initial Developer are Copyright (C) 1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of 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 MPL, 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 MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsPrintSettingsX_h__ -#define nsPrintSettingsX_h__ - -#include "nsPrintSettingsImpl.h" -#include "nsIPrintSettingsX.h" - -//***************************************************************************** -//*** nsPrintSettingsX -//***************************************************************************** - -class nsPrintSettingsX : public nsPrintSettings, - public nsIPrintSettingsX -{ -public: - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIPRINTSETTINGSX - - nsPrintSettingsX(); - virtual ~nsPrintSettingsX(); - - nsresult Init(); - -protected: - nsPrintSettingsX(const nsPrintSettingsX& src); - nsPrintSettingsX& operator=(const nsPrintSettingsX& rhs); - - nsresult _Clone(nsIPrintSettings **_retval); - nsresult _Assign(nsIPrintSettings *aPS); - - // The out param has a ref count of 1 on return so caller needs to PMRelase() when done. - OSStatus CreateDefaultPageFormat(PMPrintSession aSession, PMPageFormat& outFormat); - OSStatus CreateDefaultPrintSettings(PMPrintSession aSession, PMPrintSettings& outSettings); - - PMPageFormat mPageFormat; - PMPrintSettings mPrintSettings; -}; - -#endif /* nsPrintSettingsX_h__ */ diff --git a/widget/public/Makefile.in b/widget/public/Makefile.in index fdc6df223003..107dfe10c3b0 100644 --- a/widget/public/Makefile.in +++ b/widget/public/Makefile.in @@ -112,6 +112,8 @@ ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) XPIDLSRCS += nsIEventSink.idl \ nsIPrintSettingsX.idl \ nsIPrintSessionX.idl + +EXPORTS += nsIPrintingContext.h endif EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) diff --git a/widget/src/cocoa/Makefile.in b/widget/src/cocoa/Makefile.in index 9d8b1c9540d2..9bac4cf55b3b 100644 --- a/widget/src/cocoa/Makefile.in +++ b/widget/src/cocoa/Makefile.in @@ -97,6 +97,11 @@ MAC_LCPPSRCS = \ nsTSMStrategy.cpp \ nsScreenMac.cpp \ nsScreenManagerMac.cpp \ + nsDeviceContextSpecFactoryM.cpp \ + nsDeviceContextSpecX.cpp \ + nsPrintOptionsX.cpp \ + nsPrintSettingsX.cpp \ + nsPrintSessionX.cpp \ $(NULL) diff --git a/widget/src/mac/Makefile.in b/widget/src/mac/Makefile.in index 6002a79c1695..af4fd34e6b92 100644 --- a/widget/src/mac/Makefile.in +++ b/widget/src/mac/Makefile.in @@ -111,6 +111,11 @@ CPPSRCS = nsAppShell.cpp \ nsNativeScrollbar.cpp \ nsScreenMac.cpp \ nsScreenManagerMac.cpp \ + nsDeviceContextSpecFactoryM.cpp \ + nsDeviceContextSpecX.cpp \ + nsPrintOptionsX.cpp \ + nsPrintSettingsX.cpp \ + nsPrintSessionX.cpp \ $(GFX_LCPPSRCS) \ $(NULL) diff --git a/widget/src/mac/nsWidgetFactory.cpp b/widget/src/mac/nsWidgetFactory.cpp index 21d70d97837b..e06326eefbeb 100644 --- a/widget/src/mac/nsWidgetFactory.cpp +++ b/widget/src/mac/nsWidgetFactory.cpp @@ -66,6 +66,10 @@ #include "nsNativeThemeMac.h" #include "nsScreenManagerMac.h" +#include "nsPrintOptionsX.h" +#include "nsPrintSessionX.h" +#include "nsDeviceContextSpecFactoryM.h" + NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacWindow) NS_GENERIC_FACTORY_CONSTRUCTOR(ChildWindow) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker) @@ -86,6 +90,9 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeScrollbar) NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeThemeMac) NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerMac) +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsX, Init) +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSessionX, Init) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryMac) static const nsModuleComponentInfo gComponents[] = { @@ -172,7 +179,23 @@ static const nsModuleComponentInfo gComponents[] = { "nsScreenManager", NS_SCREENMANAGER_CID, "@mozilla.org/gfx/screenmanager;1", - nsScreenManagerMacConstructor } + nsScreenManagerMacConstructor }, + { "nsDeviceContextSpec", + NS_DEVICE_CONTEXT_SPEC_CID, + "@mozilla.org/gfx/devicecontextspec;1", + nsDeviceContextSpecXConstructor }, + { "nsDeviceContextSpecFactory", + NS_DEVICE_CONTEXT_SPEC_FACTORY_CID, + "@mozilla.org/gfx/devicecontextspecfactory;1", + nsDeviceContextSpecFactoryMacConstructor }, + { "PrintSettings Service", + NS_PRINTSETTINGSSERVICE_CID, + "@mozilla.org/gfx/printsettings-service;1", + nsPrintOptionsXConstructor }, + { "Print Session", + NS_PRINTSESSION_CID, + "@mozilla.org/gfx/printsession;1", + nsPrintSessionXConstructor }, }; NS_IMPL_NSGETMODULE(nsWidgetMacModule, gComponents)