michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsPrintSettingsImpl.h" michael@0: #include "nsReadableUtils.h" michael@0: #include "nsIPrintSession.h" michael@0: michael@0: #define DEFAULT_MARGIN_WIDTH 0.5 michael@0: michael@0: NS_IMPL_ISUPPORTS(nsPrintSettings, nsIPrintSettings) michael@0: michael@0: /** --------------------------------------------------- michael@0: * See documentation in nsPrintSettingsImpl.h michael@0: * @update 6/21/00 dwc michael@0: */ michael@0: nsPrintSettings::nsPrintSettings() : michael@0: mPrintOptions(0L), michael@0: mPrintRange(kRangeAllPages), michael@0: mStartPageNum(1), michael@0: mEndPageNum(1), michael@0: mScaling(1.0), michael@0: mPrintBGColors(false), michael@0: mPrintBGImages(false), michael@0: mPrintFrameTypeUsage(kUseInternalDefault), michael@0: mPrintFrameType(kFramesAsIs), michael@0: mHowToEnableFrameUI(kFrameEnableNone), michael@0: mIsCancelled(false), michael@0: mPrintSilent(false), michael@0: mPrintPreview(false), michael@0: mShrinkToFit(true), michael@0: mShowPrintProgress(true), michael@0: mPrintPageDelay(50), michael@0: mPaperData(0), michael@0: mPaperSizeType(kPaperSizeDefined), michael@0: mPaperWidth(8.5), michael@0: mPaperHeight(11.0), michael@0: mPaperSizeUnit(kPaperSizeInches), michael@0: mPrintReversed(false), michael@0: mPrintInColor(true), michael@0: mOrientation(kPortraitOrientation), michael@0: mDownloadFonts(false), michael@0: mNumCopies(1), michael@0: mPrintToFile(false), michael@0: mOutputFormat(kOutputFormatNative), michael@0: mIsInitedFromPrinter(false), michael@0: mIsInitedFromPrefs(false), michael@0: mPersistMarginBoxSettings(true) michael@0: { michael@0: michael@0: /* member initializers and constructor code */ michael@0: int32_t marginWidth = NS_INCHES_TO_INT_TWIPS(DEFAULT_MARGIN_WIDTH); michael@0: mMargin.SizeTo(marginWidth, marginWidth, marginWidth, marginWidth); michael@0: mEdge.SizeTo(0, 0, 0, 0); michael@0: mUnwriteableMargin.SizeTo(0,0,0,0); michael@0: michael@0: mPrintOptions = kPrintOddPages | kPrintEvenPages; michael@0: michael@0: mHeaderStrs[0].AssignLiteral("&T"); michael@0: mHeaderStrs[2].AssignLiteral("&U"); michael@0: michael@0: mFooterStrs[0].AssignLiteral("&PT"); // Use &P (Page Num Only) or &PT (Page Num of Page Total) michael@0: mFooterStrs[2].AssignLiteral("&D"); michael@0: michael@0: } michael@0: michael@0: /** --------------------------------------------------- michael@0: * See documentation in nsPrintSettingsImpl.h michael@0: * @update 6/21/00 dwc michael@0: */ michael@0: nsPrintSettings::nsPrintSettings(const nsPrintSettings& aPS) michael@0: { michael@0: *this = aPS; michael@0: } michael@0: michael@0: /** --------------------------------------------------- michael@0: * See documentation in nsPrintSettingsImpl.h michael@0: * @update 6/21/00 dwc michael@0: */ michael@0: nsPrintSettings::~nsPrintSettings() michael@0: { michael@0: } michael@0: michael@0: /* [noscript] attribute nsIPrintSession printSession; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetPrintSession(nsIPrintSession **aPrintSession) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aPrintSession); michael@0: *aPrintSession = nullptr; michael@0: michael@0: nsCOMPtr session = do_QueryReferent(mSession); michael@0: if (!session) michael@0: return NS_ERROR_NOT_INITIALIZED; michael@0: *aPrintSession = session; michael@0: NS_ADDREF(*aPrintSession); michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetPrintSession(nsIPrintSession *aPrintSession) michael@0: { michael@0: // Clearing it by passing nullptr is not allowed. That's why we michael@0: // use a weak ref so that it doesn't have to be cleared. michael@0: NS_ENSURE_ARG(aPrintSession); michael@0: michael@0: mSession = do_GetWeakReference(aPrintSession); michael@0: if (!mSession) { michael@0: // This may happen if the implementation of this object does michael@0: // not support weak references - programmer error. michael@0: NS_ERROR("Could not get a weak reference from aPrintSession"); michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute long startPageRange; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetStartPageRange(int32_t *aStartPageRange) michael@0: { michael@0: //NS_ENSURE_ARG_POINTER(aStartPageRange); michael@0: *aStartPageRange = mStartPageNum; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetStartPageRange(int32_t aStartPageRange) michael@0: { michael@0: mStartPageNum = aStartPageRange; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute long endPageRange; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetEndPageRange(int32_t *aEndPageRange) michael@0: { michael@0: //NS_ENSURE_ARG_POINTER(aEndPageRange); michael@0: *aEndPageRange = mEndPageNum; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetEndPageRange(int32_t aEndPageRange) michael@0: { michael@0: mEndPageNum = aEndPageRange; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute boolean printReversed; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetPrintReversed(bool *aPrintReversed) michael@0: { michael@0: //NS_ENSURE_ARG_POINTER(aPrintReversed); michael@0: *aPrintReversed = mPrintReversed; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetPrintReversed(bool aPrintReversed) michael@0: { michael@0: mPrintReversed = aPrintReversed; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute boolean printInColor; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetPrintInColor(bool *aPrintInColor) michael@0: { michael@0: //NS_ENSURE_ARG_POINTER(aPrintInColor); michael@0: *aPrintInColor = mPrintInColor; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetPrintInColor(bool aPrintInColor) michael@0: { michael@0: mPrintInColor = aPrintInColor; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute short orientation; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetOrientation(int32_t *aOrientation) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aOrientation); michael@0: *aOrientation = mOrientation; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetOrientation(int32_t aOrientation) michael@0: { michael@0: mOrientation = aOrientation; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute wstring colorspace; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetColorspace(char16_t * *aColorspace) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aColorspace); michael@0: if (!mColorspace.IsEmpty()) { michael@0: *aColorspace = ToNewUnicode(mColorspace); michael@0: } else { michael@0: *aColorspace = nullptr; michael@0: } michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetColorspace(const char16_t * aColorspace) michael@0: { michael@0: if (aColorspace) { michael@0: mColorspace = aColorspace; michael@0: } else { michael@0: mColorspace.SetLength(0); michael@0: } michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute wstring resolutionname; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetResolutionName(char16_t * *aResolutionName) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aResolutionName); michael@0: if (!mResolutionName.IsEmpty()) { michael@0: *aResolutionName = ToNewUnicode(mResolutionName); michael@0: } else { michael@0: *aResolutionName = nullptr; michael@0: } michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetResolutionName(const char16_t * aResolutionName) michael@0: { michael@0: if (aResolutionName) { michael@0: mResolutionName = aResolutionName; michael@0: } else { michael@0: mResolutionName.SetLength(0); michael@0: } michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute wstring resolution; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetResolution(int32_t *aResolution) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aResolution); michael@0: *aResolution = mResolution; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetResolution(const int32_t aResolution) michael@0: { michael@0: mResolution = aResolution; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute wstring duplex; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetDuplex(int32_t *aDuplex) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aDuplex); michael@0: *aDuplex = mDuplex; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetDuplex(const int32_t aDuplex) michael@0: { michael@0: mDuplex = aDuplex; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute boolean downloadFonts; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetDownloadFonts(bool *aDownloadFonts) michael@0: { michael@0: //NS_ENSURE_ARG_POINTER(aDownloadFonts); michael@0: *aDownloadFonts = mDownloadFonts; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetDownloadFonts(bool aDownloadFonts) michael@0: { michael@0: mDownloadFonts = aDownloadFonts; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute wstring printer; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetPrinterName(char16_t * *aPrinter) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aPrinter); michael@0: michael@0: *aPrinter = ToNewUnicode(mPrinter); michael@0: NS_ENSURE_TRUE(*aPrinter, NS_ERROR_OUT_OF_MEMORY); michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP nsPrintSettings::SetPrinterName(const char16_t * aPrinter) michael@0: { michael@0: if (!aPrinter || !mPrinter.Equals(aPrinter)) { michael@0: mIsInitedFromPrinter = false; michael@0: mIsInitedFromPrefs = false; michael@0: } michael@0: michael@0: mPrinter.Assign(aPrinter); michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute long numCopies; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetNumCopies(int32_t *aNumCopies) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aNumCopies); michael@0: *aNumCopies = mNumCopies; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetNumCopies(int32_t aNumCopies) michael@0: { michael@0: mNumCopies = aNumCopies; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute wstring printCommand; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetPrintCommand(char16_t * *aPrintCommand) michael@0: { michael@0: //NS_ENSURE_ARG_POINTER(aPrintCommand); michael@0: *aPrintCommand = ToNewUnicode(mPrintCommand); michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetPrintCommand(const char16_t * aPrintCommand) michael@0: { michael@0: if (aPrintCommand) { michael@0: mPrintCommand = aPrintCommand; michael@0: } else { michael@0: mPrintCommand.SetLength(0); michael@0: } michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute boolean printToFile; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetPrintToFile(bool *aPrintToFile) michael@0: { michael@0: //NS_ENSURE_ARG_POINTER(aPrintToFile); michael@0: *aPrintToFile = mPrintToFile; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetPrintToFile(bool aPrintToFile) michael@0: { michael@0: mPrintToFile = aPrintToFile; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute wstring toFileName; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetToFileName(char16_t * *aToFileName) michael@0: { michael@0: //NS_ENSURE_ARG_POINTER(aToFileName); michael@0: *aToFileName = ToNewUnicode(mToFileName); michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetToFileName(const char16_t * aToFileName) michael@0: { michael@0: if (aToFileName) { michael@0: mToFileName = aToFileName; michael@0: } else { michael@0: mToFileName.SetLength(0); michael@0: } michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute short outputFormat; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetOutputFormat(int16_t *aOutputFormat) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aOutputFormat); michael@0: *aOutputFormat = mOutputFormat; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetOutputFormat(int16_t aOutputFormat) michael@0: { michael@0: mOutputFormat = aOutputFormat; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute long printPageDelay; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetPrintPageDelay(int32_t *aPrintPageDelay) michael@0: { michael@0: *aPrintPageDelay = mPrintPageDelay; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetPrintPageDelay(int32_t aPrintPageDelay) michael@0: { michael@0: mPrintPageDelay = aPrintPageDelay; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute boolean isInitializedFromPrinter; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetIsInitializedFromPrinter(bool *aIsInitializedFromPrinter) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aIsInitializedFromPrinter); michael@0: *aIsInitializedFromPrinter = (bool)mIsInitedFromPrinter; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetIsInitializedFromPrinter(bool aIsInitializedFromPrinter) michael@0: { michael@0: mIsInitedFromPrinter = (bool)aIsInitializedFromPrinter; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute boolean isInitializedFromPrefs; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetIsInitializedFromPrefs(bool *aInitializedFromPrefs) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aInitializedFromPrefs); michael@0: *aInitializedFromPrefs = (bool)mIsInitedFromPrefs; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetIsInitializedFromPrefs(bool aInitializedFromPrefs) michael@0: { michael@0: mIsInitedFromPrefs = (bool)aInitializedFromPrefs; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute boolean persistMarginBoxSettings; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetPersistMarginBoxSettings(bool *aPersistMarginBoxSettings) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aPersistMarginBoxSettings); michael@0: *aPersistMarginBoxSettings = mPersistMarginBoxSettings; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetPersistMarginBoxSettings(bool aPersistMarginBoxSettings) michael@0: { michael@0: mPersistMarginBoxSettings = aPersistMarginBoxSettings; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute double marginTop; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetMarginTop(double *aMarginTop) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aMarginTop); michael@0: *aMarginTop = NS_TWIPS_TO_INCHES(mMargin.top); michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetMarginTop(double aMarginTop) michael@0: { michael@0: mMargin.top = NS_INCHES_TO_INT_TWIPS(float(aMarginTop)); michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute double marginLeft; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetMarginLeft(double *aMarginLeft) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aMarginLeft); michael@0: *aMarginLeft = NS_TWIPS_TO_INCHES(mMargin.left); michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetMarginLeft(double aMarginLeft) michael@0: { michael@0: mMargin.left = NS_INCHES_TO_INT_TWIPS(float(aMarginLeft)); michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute double marginBottom; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetMarginBottom(double *aMarginBottom) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aMarginBottom); michael@0: *aMarginBottom = NS_TWIPS_TO_INCHES(mMargin.bottom); michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetMarginBottom(double aMarginBottom) michael@0: { michael@0: mMargin.bottom = NS_INCHES_TO_INT_TWIPS(float(aMarginBottom)); michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute double marginRight; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetMarginRight(double *aMarginRight) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aMarginRight); michael@0: *aMarginRight = NS_TWIPS_TO_INCHES(mMargin.right); michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetMarginRight(double aMarginRight) michael@0: { michael@0: mMargin.right = NS_INCHES_TO_INT_TWIPS(float(aMarginRight)); michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute double edgeTop; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetEdgeTop(double *aEdgeTop) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aEdgeTop); michael@0: *aEdgeTop = NS_TWIPS_TO_INCHES(mEdge.top); michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetEdgeTop(double aEdgeTop) michael@0: { michael@0: mEdge.top = NS_INCHES_TO_INT_TWIPS(float(aEdgeTop)); michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute double edgeLeft; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetEdgeLeft(double *aEdgeLeft) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aEdgeLeft); michael@0: *aEdgeLeft = NS_TWIPS_TO_INCHES(mEdge.left); michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetEdgeLeft(double aEdgeLeft) michael@0: { michael@0: mEdge.left = NS_INCHES_TO_INT_TWIPS(float(aEdgeLeft)); michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute double edgeBottom; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetEdgeBottom(double *aEdgeBottom) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aEdgeBottom); michael@0: *aEdgeBottom = NS_TWIPS_TO_INCHES(mEdge.bottom); michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetEdgeBottom(double aEdgeBottom) michael@0: { michael@0: mEdge.bottom = NS_INCHES_TO_INT_TWIPS(float(aEdgeBottom)); michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute double edgeRight; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetEdgeRight(double *aEdgeRight) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aEdgeRight); michael@0: *aEdgeRight = NS_TWIPS_TO_INCHES(mEdge.right); michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetEdgeRight(double aEdgeRight) michael@0: { michael@0: mEdge.right = NS_INCHES_TO_INT_TWIPS(float(aEdgeRight)); michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute double unwriteableMarginTop; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetUnwriteableMarginTop(double *aUnwriteableMarginTop) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aUnwriteableMarginTop); michael@0: *aUnwriteableMarginTop = NS_TWIPS_TO_INCHES(mUnwriteableMargin.top); michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetUnwriteableMarginTop(double aUnwriteableMarginTop) michael@0: { michael@0: if (aUnwriteableMarginTop >= 0.0) { michael@0: mUnwriteableMargin.top = NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginTop); michael@0: } michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute double unwriteableMarginLeft; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetUnwriteableMarginLeft(double *aUnwriteableMarginLeft) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aUnwriteableMarginLeft); michael@0: *aUnwriteableMarginLeft = NS_TWIPS_TO_INCHES(mUnwriteableMargin.left); michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetUnwriteableMarginLeft(double aUnwriteableMarginLeft) michael@0: { michael@0: if (aUnwriteableMarginLeft >= 0.0) { michael@0: mUnwriteableMargin.left = NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginLeft); michael@0: } michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute double unwriteableMarginBottom; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetUnwriteableMarginBottom(double *aUnwriteableMarginBottom) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aUnwriteableMarginBottom); michael@0: *aUnwriteableMarginBottom = NS_TWIPS_TO_INCHES(mUnwriteableMargin.bottom); michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetUnwriteableMarginBottom(double aUnwriteableMarginBottom) michael@0: { michael@0: if (aUnwriteableMarginBottom >= 0.0) { michael@0: mUnwriteableMargin.bottom = NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginBottom); michael@0: } michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute double unwriteableMarginRight; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetUnwriteableMarginRight(double *aUnwriteableMarginRight) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aUnwriteableMarginRight); michael@0: *aUnwriteableMarginRight = NS_TWIPS_TO_INCHES(mUnwriteableMargin.right); michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetUnwriteableMarginRight(double aUnwriteableMarginRight) michael@0: { michael@0: if (aUnwriteableMarginRight >= 0.0) { michael@0: mUnwriteableMargin.right = NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginRight); michael@0: } michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute double scaling; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetScaling(double *aScaling) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aScaling); michael@0: *aScaling = mScaling; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP nsPrintSettings::SetScaling(double aScaling) michael@0: { michael@0: mScaling = aScaling; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute boolean printBGColors; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetPrintBGColors(bool *aPrintBGColors) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aPrintBGColors); michael@0: *aPrintBGColors = mPrintBGColors; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetPrintBGColors(bool aPrintBGColors) michael@0: { michael@0: mPrintBGColors = aPrintBGColors; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute boolean printBGImages; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetPrintBGImages(bool *aPrintBGImages) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aPrintBGImages); michael@0: *aPrintBGImages = mPrintBGImages; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetPrintBGImages(bool aPrintBGImages) michael@0: { michael@0: mPrintBGImages = aPrintBGImages; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute long printRange; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetPrintRange(int16_t *aPrintRange) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aPrintRange); michael@0: *aPrintRange = mPrintRange; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetPrintRange(int16_t aPrintRange) michael@0: { michael@0: mPrintRange = aPrintRange; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute wstring docTitle; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetTitle(char16_t * *aTitle) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aTitle); michael@0: if (!mTitle.IsEmpty()) { michael@0: *aTitle = ToNewUnicode(mTitle); michael@0: } else { michael@0: *aTitle = nullptr; michael@0: } michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetTitle(const char16_t * aTitle) michael@0: { michael@0: if (aTitle) { michael@0: mTitle = aTitle; michael@0: } else { michael@0: mTitle.SetLength(0); michael@0: } michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute wstring docURL; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetDocURL(char16_t * *aDocURL) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aDocURL); michael@0: if (!mURL.IsEmpty()) { michael@0: *aDocURL = ToNewUnicode(mURL); michael@0: } else { michael@0: *aDocURL = nullptr; michael@0: } michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetDocURL(const char16_t * aDocURL) michael@0: { michael@0: if (aDocURL) { michael@0: mURL = aDocURL; michael@0: } else { michael@0: mURL.SetLength(0); michael@0: } michael@0: return NS_OK; michael@0: } michael@0: michael@0: /** --------------------------------------------------- michael@0: * See documentation in nsPrintSettingsImpl.h michael@0: * @update 1/12/01 rods michael@0: */ michael@0: NS_IMETHODIMP michael@0: nsPrintSettings::GetPrintOptions(int32_t aType, bool *aTurnOnOff) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aTurnOnOff); michael@0: *aTurnOnOff = mPrintOptions & aType ? true : false; michael@0: return NS_OK; michael@0: } michael@0: /** --------------------------------------------------- michael@0: * See documentation in nsPrintSettingsImpl.h michael@0: * @update 1/12/01 rods michael@0: */ michael@0: NS_IMETHODIMP michael@0: nsPrintSettings::SetPrintOptions(int32_t aType, bool aTurnOnOff) michael@0: { michael@0: if (aTurnOnOff) { michael@0: mPrintOptions |= aType; michael@0: } else { michael@0: mPrintOptions &= ~aType; michael@0: } michael@0: return NS_OK; michael@0: } michael@0: michael@0: /** --------------------------------------------------- michael@0: * See documentation in nsPrintSettingsImpl.h michael@0: * @update 1/12/01 rods michael@0: */ michael@0: NS_IMETHODIMP michael@0: nsPrintSettings::GetPrintOptionsBits(int32_t *aBits) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aBits); michael@0: *aBits = mPrintOptions; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute wstring docTitle; */ michael@0: nsresult michael@0: nsPrintSettings::GetMarginStrs(char16_t * *aTitle, michael@0: nsHeaderFooterEnum aType, michael@0: int16_t aJust) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aTitle); michael@0: *aTitle = nullptr; michael@0: if (aType == eHeader) { michael@0: switch (aJust) { michael@0: case kJustLeft: *aTitle = ToNewUnicode(mHeaderStrs[0]);break; michael@0: case kJustCenter: *aTitle = ToNewUnicode(mHeaderStrs[1]);break; michael@0: case kJustRight: *aTitle = ToNewUnicode(mHeaderStrs[2]);break; michael@0: } //switch michael@0: } else { michael@0: switch (aJust) { michael@0: case kJustLeft: *aTitle = ToNewUnicode(mFooterStrs[0]);break; michael@0: case kJustCenter: *aTitle = ToNewUnicode(mFooterStrs[1]);break; michael@0: case kJustRight: *aTitle = ToNewUnicode(mFooterStrs[2]);break; michael@0: } //switch michael@0: } michael@0: return NS_OK; michael@0: } michael@0: michael@0: nsresult michael@0: nsPrintSettings::SetMarginStrs(const char16_t * aTitle, michael@0: nsHeaderFooterEnum aType, michael@0: int16_t aJust) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aTitle); michael@0: if (aType == eHeader) { michael@0: switch (aJust) { michael@0: case kJustLeft: mHeaderStrs[0] = aTitle;break; michael@0: case kJustCenter: mHeaderStrs[1] = aTitle;break; michael@0: case kJustRight: mHeaderStrs[2] = aTitle;break; michael@0: } //switch michael@0: } else { michael@0: switch (aJust) { michael@0: case kJustLeft: mFooterStrs[0] = aTitle;break; michael@0: case kJustCenter: mFooterStrs[1] = aTitle;break; michael@0: case kJustRight: mFooterStrs[2] = aTitle;break; michael@0: } //switch michael@0: } michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute wstring Header String Left */ michael@0: NS_IMETHODIMP nsPrintSettings::GetHeaderStrLeft(char16_t * *aTitle) michael@0: { michael@0: return GetMarginStrs(aTitle, eHeader, kJustLeft); michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetHeaderStrLeft(const char16_t * aTitle) michael@0: { michael@0: return SetMarginStrs(aTitle, eHeader, kJustLeft); michael@0: } michael@0: michael@0: /* attribute wstring Header String Center */ michael@0: NS_IMETHODIMP nsPrintSettings::GetHeaderStrCenter(char16_t * *aTitle) michael@0: { michael@0: return GetMarginStrs(aTitle, eHeader, kJustCenter); michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetHeaderStrCenter(const char16_t * aTitle) michael@0: { michael@0: return SetMarginStrs(aTitle, eHeader, kJustCenter); michael@0: } michael@0: michael@0: /* attribute wstring Header String Right */ michael@0: NS_IMETHODIMP nsPrintSettings::GetHeaderStrRight(char16_t * *aTitle) michael@0: { michael@0: return GetMarginStrs(aTitle, eHeader, kJustRight); michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetHeaderStrRight(const char16_t * aTitle) michael@0: { michael@0: return SetMarginStrs(aTitle, eHeader, kJustRight); michael@0: } michael@0: michael@0: michael@0: /* attribute wstring Footer String Left */ michael@0: NS_IMETHODIMP nsPrintSettings::GetFooterStrLeft(char16_t * *aTitle) michael@0: { michael@0: return GetMarginStrs(aTitle, eFooter, kJustLeft); michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetFooterStrLeft(const char16_t * aTitle) michael@0: { michael@0: return SetMarginStrs(aTitle, eFooter, kJustLeft); michael@0: } michael@0: michael@0: /* attribute wstring Footer String Center */ michael@0: NS_IMETHODIMP nsPrintSettings::GetFooterStrCenter(char16_t * *aTitle) michael@0: { michael@0: return GetMarginStrs(aTitle, eFooter, kJustCenter); michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetFooterStrCenter(const char16_t * aTitle) michael@0: { michael@0: return SetMarginStrs(aTitle, eFooter, kJustCenter); michael@0: } michael@0: michael@0: /* attribute wstring Footer String Right */ michael@0: NS_IMETHODIMP nsPrintSettings::GetFooterStrRight(char16_t * *aTitle) michael@0: { michael@0: return GetMarginStrs(aTitle, eFooter, kJustRight); michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetFooterStrRight(const char16_t * aTitle) michael@0: { michael@0: return SetMarginStrs(aTitle, eFooter, kJustRight); michael@0: } michael@0: michael@0: /* attribute short printFrameTypeUsage; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetPrintFrameTypeUsage(int16_t *aPrintFrameTypeUsage) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aPrintFrameTypeUsage); michael@0: *aPrintFrameTypeUsage = mPrintFrameTypeUsage; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetPrintFrameTypeUsage(int16_t aPrintFrameTypeUsage) michael@0: { michael@0: mPrintFrameTypeUsage = aPrintFrameTypeUsage; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute long printFrameType; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetPrintFrameType(int16_t *aPrintFrameType) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aPrintFrameType); michael@0: *aPrintFrameType = (int32_t)mPrintFrameType; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetPrintFrameType(int16_t aPrintFrameType) michael@0: { michael@0: mPrintFrameType = aPrintFrameType; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute boolean printSilent; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetPrintSilent(bool *aPrintSilent) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aPrintSilent); michael@0: *aPrintSilent = mPrintSilent; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetPrintSilent(bool aPrintSilent) michael@0: { michael@0: mPrintSilent = aPrintSilent; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute boolean shrinkToFit; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetShrinkToFit(bool *aShrinkToFit) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aShrinkToFit); michael@0: *aShrinkToFit = mShrinkToFit; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetShrinkToFit(bool aShrinkToFit) michael@0: { michael@0: mShrinkToFit = aShrinkToFit; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute boolean showPrintProgress; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetShowPrintProgress(bool *aShowPrintProgress) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aShowPrintProgress); michael@0: *aShowPrintProgress = mShowPrintProgress; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetShowPrintProgress(bool aShowPrintProgress) michael@0: { michael@0: mShowPrintProgress = aShowPrintProgress; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute wstring paperName; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetPaperName(char16_t * *aPaperName) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aPaperName); michael@0: if (!mPaperName.IsEmpty()) { michael@0: *aPaperName = ToNewUnicode(mPaperName); michael@0: } else { michael@0: *aPaperName = nullptr; michael@0: } michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetPaperName(const char16_t * aPaperName) michael@0: { michael@0: if (aPaperName) { michael@0: mPaperName = aPaperName; michael@0: } else { michael@0: mPaperName.SetLength(0); michael@0: } michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute wstring plexName; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetPlexName(char16_t * *aPlexName) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aPlexName); michael@0: if (!mPlexName.IsEmpty()) { michael@0: *aPlexName = ToNewUnicode(mPlexName); michael@0: } else { michael@0: *aPlexName = nullptr; michael@0: } michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetPlexName(const char16_t * aPlexName) michael@0: { michael@0: if (aPlexName) { michael@0: mPlexName = aPlexName; michael@0: } else { michael@0: mPlexName.SetLength(0); michael@0: } michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute boolean howToEnableFrameUI; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetHowToEnableFrameUI(int16_t *aHowToEnableFrameUI) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aHowToEnableFrameUI); michael@0: *aHowToEnableFrameUI = mHowToEnableFrameUI; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetHowToEnableFrameUI(int16_t aHowToEnableFrameUI) michael@0: { michael@0: mHowToEnableFrameUI = aHowToEnableFrameUI; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute long isCancelled; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetIsCancelled(bool *aIsCancelled) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aIsCancelled); michael@0: *aIsCancelled = mIsCancelled; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetIsCancelled(bool aIsCancelled) michael@0: { michael@0: mIsCancelled = aIsCancelled; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute double paperWidth; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetPaperWidth(double *aPaperWidth) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aPaperWidth); michael@0: *aPaperWidth = mPaperWidth; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetPaperWidth(double aPaperWidth) michael@0: { michael@0: mPaperWidth = aPaperWidth; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute double paperHeight; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetPaperHeight(double *aPaperHeight) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aPaperHeight); michael@0: *aPaperHeight = mPaperHeight; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetPaperHeight(double aPaperHeight) michael@0: { michael@0: mPaperHeight = aPaperHeight; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute short PaperSizeUnit; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetPaperSizeUnit(int16_t *aPaperSizeUnit) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aPaperSizeUnit); michael@0: *aPaperSizeUnit = mPaperSizeUnit; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetPaperSizeUnit(int16_t aPaperSizeUnit) michael@0: { michael@0: mPaperSizeUnit = aPaperSizeUnit; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute short PaperSizeType; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetPaperSizeType(int16_t *aPaperSizeType) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aPaperSizeType); michael@0: *aPaperSizeType = mPaperSizeType; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetPaperSizeType(int16_t aPaperSizeType) michael@0: { michael@0: mPaperSizeType = aPaperSizeType; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* attribute short PaperData; */ michael@0: NS_IMETHODIMP nsPrintSettings::GetPaperData(int16_t *aPaperData) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aPaperData); michael@0: *aPaperData = mPaperData; michael@0: return NS_OK; michael@0: } michael@0: NS_IMETHODIMP nsPrintSettings::SetPaperData(int16_t aPaperData) michael@0: { michael@0: mPaperData = aPaperData; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /** --------------------------------------------------- michael@0: * See documentation in nsPrintOptionsImpl.h michael@0: * @update 6/21/00 dwc michael@0: * @update 1/12/01 rods michael@0: */ michael@0: NS_IMETHODIMP michael@0: nsPrintSettings::SetMarginInTwips(nsIntMargin& aMargin) michael@0: { michael@0: mMargin = aMargin; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsPrintSettings::SetEdgeInTwips(nsIntMargin& aEdge) michael@0: { michael@0: mEdge = aEdge; michael@0: return NS_OK; michael@0: } michael@0: michael@0: // NOTE: Any subclass implementation of this function should make sure michael@0: // to check for negative margin values in aUnwriteableMargin (which michael@0: // would indicate that we should use the system default unwriteable margin.) michael@0: NS_IMETHODIMP michael@0: nsPrintSettings::SetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin) michael@0: { michael@0: if (aUnwriteableMargin.top >= 0) { michael@0: mUnwriteableMargin.top = aUnwriteableMargin.top; michael@0: } michael@0: if (aUnwriteableMargin.left >= 0) { michael@0: mUnwriteableMargin.left = aUnwriteableMargin.left; michael@0: } michael@0: if (aUnwriteableMargin.bottom >= 0) { michael@0: mUnwriteableMargin.bottom = aUnwriteableMargin.bottom; michael@0: } michael@0: if (aUnwriteableMargin.right >= 0) { michael@0: mUnwriteableMargin.right = aUnwriteableMargin.right; michael@0: } michael@0: return NS_OK; michael@0: } michael@0: michael@0: /** --------------------------------------------------- michael@0: * See documentation in nsPrintOptionsImpl.h michael@0: * @update 6/21/00 dwc michael@0: */ michael@0: NS_IMETHODIMP michael@0: nsPrintSettings::GetMarginInTwips(nsIntMargin& aMargin) michael@0: { michael@0: aMargin = mMargin; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsPrintSettings::GetEdgeInTwips(nsIntMargin& aEdge) michael@0: { michael@0: aEdge = mEdge; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsPrintSettings::GetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin) michael@0: { michael@0: aUnwriteableMargin = mUnwriteableMargin; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /** --------------------------------------------------- michael@0: * Stub - platform-specific implementations can use this function. michael@0: */ michael@0: NS_IMETHODIMP michael@0: nsPrintSettings::SetupSilentPrinting() michael@0: { michael@0: return NS_OK; michael@0: } michael@0: michael@0: /** --------------------------------------------------- michael@0: * See documentation in nsPrintOptionsImpl.h michael@0: */ michael@0: NS_IMETHODIMP michael@0: nsPrintSettings::GetEffectivePageSize(double *aWidth, double *aHeight) michael@0: { michael@0: if (mPaperSizeUnit == kPaperSizeInches) { michael@0: *aWidth = NS_INCHES_TO_TWIPS(float(mPaperWidth)); michael@0: *aHeight = NS_INCHES_TO_TWIPS(float(mPaperHeight)); michael@0: } else { michael@0: *aWidth = NS_MILLIMETERS_TO_TWIPS(float(mPaperWidth)); michael@0: *aHeight = NS_MILLIMETERS_TO_TWIPS(float(mPaperHeight)); michael@0: } michael@0: if (kLandscapeOrientation == mOrientation) { michael@0: double temp = *aWidth; michael@0: *aWidth = *aHeight; michael@0: *aHeight = temp; michael@0: } michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsPrintSettings::GetPageRanges(nsTArray &aPages) michael@0: { michael@0: aPages.Clear(); michael@0: return NS_OK; michael@0: } michael@0: michael@0: nsresult michael@0: nsPrintSettings::_Clone(nsIPrintSettings **_retval) michael@0: { michael@0: nsPrintSettings* printSettings = new nsPrintSettings(*this); michael@0: return printSettings->QueryInterface(NS_GET_IID(nsIPrintSettings), (void**)_retval); // ref counts michael@0: } michael@0: michael@0: /* nsIPrintSettings clone (); */ michael@0: NS_IMETHODIMP michael@0: nsPrintSettings::Clone(nsIPrintSettings **_retval) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(_retval); michael@0: return _Clone(_retval); michael@0: } michael@0: michael@0: /* void assign (in nsIPrintSettings aPS); */ michael@0: nsresult michael@0: nsPrintSettings::_Assign(nsIPrintSettings *aPS) michael@0: { michael@0: nsPrintSettings *ps = static_cast(aPS); michael@0: *this = *ps; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* void assign (in nsIPrintSettings aPS); */ michael@0: NS_IMETHODIMP michael@0: nsPrintSettings::Assign(nsIPrintSettings *aPS) michael@0: { michael@0: NS_ENSURE_ARG(aPS); michael@0: return _Assign(aPS); michael@0: } michael@0: michael@0: //------------------------------------------- michael@0: nsPrintSettings& nsPrintSettings::operator=(const nsPrintSettings& rhs) michael@0: { michael@0: if (this == &rhs) { michael@0: return *this; michael@0: } michael@0: michael@0: mStartPageNum = rhs.mStartPageNum; michael@0: mEndPageNum = rhs.mEndPageNum; michael@0: mMargin = rhs.mMargin; michael@0: mEdge = rhs.mEdge; michael@0: mUnwriteableMargin = rhs.mUnwriteableMargin; michael@0: mScaling = rhs.mScaling; michael@0: mPrintBGColors = rhs.mPrintBGColors; michael@0: mPrintBGImages = rhs.mPrintBGImages; michael@0: mPrintRange = rhs.mPrintRange; michael@0: mTitle = rhs.mTitle; michael@0: mURL = rhs.mURL; michael@0: mHowToEnableFrameUI = rhs.mHowToEnableFrameUI; michael@0: mIsCancelled = rhs.mIsCancelled; michael@0: mPrintFrameTypeUsage = rhs.mPrintFrameTypeUsage; michael@0: mPrintFrameType = rhs.mPrintFrameType; michael@0: mPrintSilent = rhs.mPrintSilent; michael@0: mShrinkToFit = rhs.mShrinkToFit; michael@0: mShowPrintProgress = rhs.mShowPrintProgress; michael@0: mPaperName = rhs.mPaperName; michael@0: mPlexName = rhs.mPlexName; michael@0: mPaperSizeType = rhs.mPaperSizeType; michael@0: mPaperData = rhs.mPaperData; michael@0: mPaperWidth = rhs.mPaperWidth; michael@0: mPaperHeight = rhs.mPaperHeight; michael@0: mPaperSizeUnit = rhs.mPaperSizeUnit; michael@0: mPrintReversed = rhs.mPrintReversed; michael@0: mPrintInColor = rhs.mPrintInColor; michael@0: mOrientation = rhs.mOrientation; michael@0: mPrintCommand = rhs.mPrintCommand; michael@0: mNumCopies = rhs.mNumCopies; michael@0: mPrinter = rhs.mPrinter; michael@0: mPrintToFile = rhs.mPrintToFile; michael@0: mToFileName = rhs.mToFileName; michael@0: mOutputFormat = rhs.mOutputFormat; michael@0: mPrintPageDelay = rhs.mPrintPageDelay; michael@0: michael@0: for (int32_t i=0;i