зеркало из https://github.com/mozilla/gecko-dev.git
formatting cleanup for Cocoa printing impl. no bug. rs=roc
This commit is contained in:
Родитель
7fd20df4e3
Коммит
68d8f4586a
|
@ -41,27 +41,18 @@
|
|||
|
||||
#include "nsPrintOptionsImpl.h"
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//*** nsPrintOptions
|
||||
//*****************************************************************************
|
||||
|
||||
class nsPrintOptionsX : public nsPrintOptions
|
||||
{
|
||||
public:
|
||||
nsPrintOptionsX();
|
||||
virtual ~nsPrintOptionsX();
|
||||
|
||||
NS_IMETHOD ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings);
|
||||
|
||||
NS_IMETHOD GetNativeData(PRInt16 aDataType, void * *_retval);
|
||||
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);
|
||||
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_
|
||||
|
|
|
@ -56,28 +56,6 @@ nsPrintOptionsX::~nsPrintOptionsX()
|
|||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
(void)InitPrintSettingsFromPrefs(*_retval, PR_FALSE,
|
||||
nsIPrintSettings::kInitSaveAll);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintOptionsX::ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings)
|
||||
{
|
||||
|
@ -95,9 +73,6 @@ nsPrintOptionsX::GetNativeData(PRInt16 aDataType, void **_retval)
|
|||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
|
||||
|
||||
nsresult
|
||||
nsPrintOptionsX::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, PRUint32 aFlags)
|
||||
{
|
||||
|
@ -116,19 +91,39 @@ nsPrintOptionsX::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName,
|
|||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
rv = printSettings->Init();
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(*_retval);
|
||||
return rv;
|
||||
}
|
||||
|
||||
InitPrintSettingsFromPrefs(*_retval, PR_FALSE, nsIPrintSettings::kInitSaveAll);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
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<nsIPrintSettingsX> 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;
|
||||
}
|
||||
|
|
|
@ -42,9 +42,6 @@
|
|||
#include "nsPrintSession.h"
|
||||
#include "nsIPrintSessionX.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//*** nsPrintSessionX
|
||||
//*****************************************************************************
|
||||
|
||||
class nsPrintSessionX : public nsPrintSession,
|
||||
public nsIPrintSessionX
|
||||
|
@ -55,11 +52,11 @@ public:
|
|||
|
||||
nsPrintSessionX();
|
||||
virtual ~nsPrintSessionX();
|
||||
|
||||
|
||||
nsresult Init();
|
||||
|
||||
|
||||
protected:
|
||||
PMPrintSession mSession;
|
||||
PMPrintSession mSession;
|
||||
};
|
||||
|
||||
#endif // nsPrintSessionX_h_
|
||||
|
|
|
@ -39,20 +39,16 @@
|
|||
#include "nsPrintSessionX.h"
|
||||
#include "nsObjCExceptions.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//*** nsPrintSessionX
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsPrintSessionX,
|
||||
nsPrintSession,
|
||||
nsIPrintSessionX)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
nsPrintSessionX::nsPrintSessionX()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
nsPrintSessionX::~nsPrintSessionX()
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
@ -65,7 +61,7 @@ nsPrintSessionX::~nsPrintSessionX()
|
|||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
nsresult nsPrintSessionX::Init()
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
@ -73,26 +69,25 @@ 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;
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/* 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;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
/* -*- 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
|
||||
|
@ -42,9 +41,6 @@
|
|||
#include "nsPrintSettingsImpl.h"
|
||||
#include "nsIPrintSettingsX.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//*** nsPrintSettingsX
|
||||
//*****************************************************************************
|
||||
|
||||
class nsPrintSettingsX : public nsPrintSettings,
|
||||
public nsIPrintSettingsX
|
||||
|
@ -55,7 +51,7 @@ public:
|
|||
|
||||
nsPrintSettingsX();
|
||||
virtual ~nsPrintSettingsX();
|
||||
|
||||
|
||||
nsresult Init();
|
||||
|
||||
protected:
|
||||
|
@ -64,11 +60,9 @@ protected:
|
|||
|
||||
nsresult _Clone(nsIPrintSettings **_retval);
|
||||
nsresult _Assign(nsIPrintSettings *aPS);
|
||||
|
||||
/**
|
||||
* Re-initialize mUnwriteableMargin with values from mPageFormat.
|
||||
* Should be called whenever mPageFormat is initialized or overwritten.
|
||||
*/
|
||||
|
||||
// Re-initialize mUnwriteableMargin with values from mPageFormat.
|
||||
// Should be called whenever mPageFormat is initialized or overwritten.
|
||||
nsresult InitUnwriteableMargin();
|
||||
|
||||
// The out param has a ref count of 1 on return so caller needs to PMRelase() when done.
|
||||
|
|
|
@ -48,23 +48,20 @@
|
|||
#include "prmem.h"
|
||||
#include "prnetdb.h"
|
||||
|
||||
|
||||
// This struct should be represented identically on all architectures, and
|
||||
// there shouldn't be any padding before the data field.
|
||||
struct FrozenHandle {
|
||||
PRUint32 size;
|
||||
char data[0];
|
||||
char data[0];
|
||||
};
|
||||
|
||||
// Constants
|
||||
|
||||
#define PRINTING_PREF_BRANCH "print."
|
||||
#define MAC_OS_X_PAGE_SETUP_PREFNAME "macosx.pagesetup-2"
|
||||
|
||||
|
||||
|
||||
/** ------------------------------------------------------------
|
||||
* Utility class stack-based handle ownership
|
||||
*/
|
||||
|
||||
// Utility class stack-based handle ownership
|
||||
class StHandleOwner
|
||||
{
|
||||
public:
|
||||
|
@ -98,19 +95,15 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
|
||||
Handle mHandle;
|
||||
Handle mHandle;
|
||||
};
|
||||
|
||||
/** ------------------------------------------------------------
|
||||
* Utility class for saving, locking, and restoring handle state
|
||||
* Ok with null handle
|
||||
*/
|
||||
|
||||
// Utility class for saving, locking, and restoring handle state.
|
||||
// Ok with null handle.
|
||||
class StHandleLocker
|
||||
{
|
||||
public:
|
||||
|
||||
StHandleLocker(Handle theHandle)
|
||||
: mHandle(theHandle)
|
||||
{
|
||||
|
@ -135,26 +128,20 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
|
||||
Handle mHandle;
|
||||
SInt8 mOldHandleState;
|
||||
Handle mHandle;
|
||||
SInt8 mOldHandleState;
|
||||
};
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsPrintSettingsX,
|
||||
nsPrintSettings,
|
||||
nsIPrintSettingsX)
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsPrintSettingsX, nsPrintSettings, nsIPrintSettingsX)
|
||||
|
||||
/** ---------------------------------------------------
|
||||
*/
|
||||
nsPrintSettingsX::nsPrintSettingsX() :
|
||||
mPageFormat(kPMNoPageFormat),
|
||||
mPrintSettings(kPMNoPrintSettings)
|
||||
{
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
*/
|
||||
|
||||
nsPrintSettingsX::nsPrintSettingsX(const nsPrintSettingsX& src) :
|
||||
mPageFormat(kPMNoPageFormat),
|
||||
mPrintSettings(kPMNoPrintSettings)
|
||||
|
@ -162,8 +149,7 @@ nsPrintSettingsX::nsPrintSettingsX(const nsPrintSettingsX& src) :
|
|||
*this = src;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
*/
|
||||
|
||||
nsPrintSettingsX::~nsPrintSettingsX()
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
@ -180,8 +166,7 @@ nsPrintSettingsX::~nsPrintSettingsX()
|
|||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
*/
|
||||
|
||||
nsPrintSettingsX& nsPrintSettingsX::operator=(const nsPrintSettingsX& rhs)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
|
||||
|
@ -235,8 +220,7 @@ nsPrintSettingsX& nsPrintSettingsX::operator=(const nsPrintSettingsX& rhs)
|
|||
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(*this);
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
*/
|
||||
|
||||
nsresult nsPrintSettingsX::Init()
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
@ -264,14 +248,14 @@ nsresult nsPrintSettingsX::Init()
|
|||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
|
||||
// Should be called whenever mPageFormat changes.
|
||||
NS_IMETHODIMP nsPrintSettingsX::InitUnwriteableMargin()
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
if (mPageFormat == kPMNoPageFormat) {
|
||||
if (mPageFormat == kPMNoPageFormat)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PMPaper paper;
|
||||
PMPaperMargins paperMargin;
|
||||
|
@ -287,8 +271,7 @@ NS_IMETHODIMP nsPrintSettingsX::InitUnwriteableMargin()
|
|||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
*/
|
||||
|
||||
NS_IMETHODIMP nsPrintSettingsX::GetNativePrintSession(PMPrintSession *aNativePrintSession)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNativePrintSession);
|
||||
|
@ -305,8 +288,7 @@ NS_IMETHODIMP nsPrintSettingsX::GetNativePrintSession(PMPrintSession *aNativePri
|
|||
return printSessionX->GetNativeSession(aNativePrintSession);
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
*/
|
||||
|
||||
NS_IMETHODIMP nsPrintSettingsX::GetPMPageFormat(PMPageFormat *aPMPageFormat)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPMPageFormat);
|
||||
|
@ -319,8 +301,7 @@ NS_IMETHODIMP nsPrintSettingsX::GetPMPageFormat(PMPageFormat *aPMPageFormat)
|
|||
return (status == noErr) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
*/
|
||||
|
||||
NS_IMETHODIMP nsPrintSettingsX::SetPMPageFormat(PMPageFormat aPMPageFormat)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
@ -339,8 +320,7 @@ NS_IMETHODIMP nsPrintSettingsX::SetPMPageFormat(PMPageFormat aPMPageFormat)
|
|||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
*/
|
||||
|
||||
NS_IMETHODIMP nsPrintSettingsX::GetPMPrintSettings(PMPrintSettings *aPMPrintSettings)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPMPrintSettings);
|
||||
|
@ -352,8 +332,7 @@ NS_IMETHODIMP nsPrintSettingsX::GetPMPrintSettings(PMPrintSettings *aPMPrintSett
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
*/
|
||||
|
||||
NS_IMETHODIMP nsPrintSettingsX::SetPMPrintSettings(PMPrintSettings aPMPrintSettings)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
@ -371,8 +350,7 @@ NS_IMETHODIMP nsPrintSettingsX::SetPMPrintSettings(PMPrintSettings aPMPrintSetti
|
|||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
*/
|
||||
|
||||
NS_IMETHODIMP nsPrintSettingsX::ReadPageFormatFromPrefs()
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
@ -436,8 +414,7 @@ NS_IMETHODIMP nsPrintSettingsX::ReadPageFormatFromPrefs()
|
|||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
*/
|
||||
|
||||
NS_IMETHODIMP nsPrintSettingsX::WritePageFormatToPrefs()
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
@ -488,7 +465,7 @@ NS_IMETHODIMP nsPrintSettingsX::WritePageFormatToPrefs()
|
|||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
//-------------------------------------------
|
||||
|
||||
nsresult nsPrintSettingsX::_Clone(nsIPrintSettings **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
@ -503,7 +480,6 @@ nsresult nsPrintSettingsX::_Clone(nsIPrintSettings **_retval)
|
|||
}
|
||||
|
||||
|
||||
//-------------------------------------------
|
||||
NS_IMETHODIMP nsPrintSettingsX::_Assign(nsIPrintSettings *aPS)
|
||||
{
|
||||
nsPrintSettingsX *printSettingsX = static_cast<nsPrintSettingsX*>(aPS);
|
||||
|
@ -513,7 +489,7 @@ NS_IMETHODIMP nsPrintSettingsX::_Assign(nsIPrintSettings *aPS)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------
|
||||
|
||||
OSStatus nsPrintSettingsX::CreateDefaultPageFormat(PMPrintSession aSession, PMPageFormat& outFormat)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
|
||||
|
@ -534,8 +510,7 @@ OSStatus nsPrintSettingsX::CreateDefaultPageFormat(PMPrintSession aSession, PMPa
|
|||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(noErr);
|
||||
}
|
||||
|
||||
//-------------------------------------------
|
||||
|
||||
|
||||
OSStatus nsPrintSettingsX::CreateDefaultPrintSettings(PMPrintSession aSession, PMPrintSettings& outSettings)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче