1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/xpwidgets/nsPrintSettingsImpl.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,1192 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsPrintSettingsImpl.h" 1.10 +#include "nsReadableUtils.h" 1.11 +#include "nsIPrintSession.h" 1.12 + 1.13 +#define DEFAULT_MARGIN_WIDTH 0.5 1.14 + 1.15 +NS_IMPL_ISUPPORTS(nsPrintSettings, nsIPrintSettings) 1.16 + 1.17 +/** --------------------------------------------------- 1.18 + * See documentation in nsPrintSettingsImpl.h 1.19 + * @update 6/21/00 dwc 1.20 + */ 1.21 +nsPrintSettings::nsPrintSettings() : 1.22 + mPrintOptions(0L), 1.23 + mPrintRange(kRangeAllPages), 1.24 + mStartPageNum(1), 1.25 + mEndPageNum(1), 1.26 + mScaling(1.0), 1.27 + mPrintBGColors(false), 1.28 + mPrintBGImages(false), 1.29 + mPrintFrameTypeUsage(kUseInternalDefault), 1.30 + mPrintFrameType(kFramesAsIs), 1.31 + mHowToEnableFrameUI(kFrameEnableNone), 1.32 + mIsCancelled(false), 1.33 + mPrintSilent(false), 1.34 + mPrintPreview(false), 1.35 + mShrinkToFit(true), 1.36 + mShowPrintProgress(true), 1.37 + mPrintPageDelay(50), 1.38 + mPaperData(0), 1.39 + mPaperSizeType(kPaperSizeDefined), 1.40 + mPaperWidth(8.5), 1.41 + mPaperHeight(11.0), 1.42 + mPaperSizeUnit(kPaperSizeInches), 1.43 + mPrintReversed(false), 1.44 + mPrintInColor(true), 1.45 + mOrientation(kPortraitOrientation), 1.46 + mDownloadFonts(false), 1.47 + mNumCopies(1), 1.48 + mPrintToFile(false), 1.49 + mOutputFormat(kOutputFormatNative), 1.50 + mIsInitedFromPrinter(false), 1.51 + mIsInitedFromPrefs(false), 1.52 + mPersistMarginBoxSettings(true) 1.53 +{ 1.54 + 1.55 + /* member initializers and constructor code */ 1.56 + int32_t marginWidth = NS_INCHES_TO_INT_TWIPS(DEFAULT_MARGIN_WIDTH); 1.57 + mMargin.SizeTo(marginWidth, marginWidth, marginWidth, marginWidth); 1.58 + mEdge.SizeTo(0, 0, 0, 0); 1.59 + mUnwriteableMargin.SizeTo(0,0,0,0); 1.60 + 1.61 + mPrintOptions = kPrintOddPages | kPrintEvenPages; 1.62 + 1.63 + mHeaderStrs[0].AssignLiteral("&T"); 1.64 + mHeaderStrs[2].AssignLiteral("&U"); 1.65 + 1.66 + mFooterStrs[0].AssignLiteral("&PT"); // Use &P (Page Num Only) or &PT (Page Num of Page Total) 1.67 + mFooterStrs[2].AssignLiteral("&D"); 1.68 + 1.69 +} 1.70 + 1.71 +/** --------------------------------------------------- 1.72 + * See documentation in nsPrintSettingsImpl.h 1.73 + * @update 6/21/00 dwc 1.74 + */ 1.75 +nsPrintSettings::nsPrintSettings(const nsPrintSettings& aPS) 1.76 +{ 1.77 + *this = aPS; 1.78 +} 1.79 + 1.80 +/** --------------------------------------------------- 1.81 + * See documentation in nsPrintSettingsImpl.h 1.82 + * @update 6/21/00 dwc 1.83 + */ 1.84 +nsPrintSettings::~nsPrintSettings() 1.85 +{ 1.86 +} 1.87 + 1.88 +/* [noscript] attribute nsIPrintSession printSession; */ 1.89 +NS_IMETHODIMP nsPrintSettings::GetPrintSession(nsIPrintSession **aPrintSession) 1.90 +{ 1.91 + NS_ENSURE_ARG_POINTER(aPrintSession); 1.92 + *aPrintSession = nullptr; 1.93 + 1.94 + nsCOMPtr<nsIPrintSession> session = do_QueryReferent(mSession); 1.95 + if (!session) 1.96 + return NS_ERROR_NOT_INITIALIZED; 1.97 + *aPrintSession = session; 1.98 + NS_ADDREF(*aPrintSession); 1.99 + return NS_OK; 1.100 +} 1.101 +NS_IMETHODIMP nsPrintSettings::SetPrintSession(nsIPrintSession *aPrintSession) 1.102 +{ 1.103 + // Clearing it by passing nullptr is not allowed. That's why we 1.104 + // use a weak ref so that it doesn't have to be cleared. 1.105 + NS_ENSURE_ARG(aPrintSession); 1.106 + 1.107 + mSession = do_GetWeakReference(aPrintSession); 1.108 + if (!mSession) { 1.109 + // This may happen if the implementation of this object does 1.110 + // not support weak references - programmer error. 1.111 + NS_ERROR("Could not get a weak reference from aPrintSession"); 1.112 + return NS_ERROR_FAILURE; 1.113 + } 1.114 + return NS_OK; 1.115 +} 1.116 + 1.117 +/* attribute long startPageRange; */ 1.118 +NS_IMETHODIMP nsPrintSettings::GetStartPageRange(int32_t *aStartPageRange) 1.119 +{ 1.120 + //NS_ENSURE_ARG_POINTER(aStartPageRange); 1.121 + *aStartPageRange = mStartPageNum; 1.122 + return NS_OK; 1.123 +} 1.124 +NS_IMETHODIMP nsPrintSettings::SetStartPageRange(int32_t aStartPageRange) 1.125 +{ 1.126 + mStartPageNum = aStartPageRange; 1.127 + return NS_OK; 1.128 +} 1.129 + 1.130 +/* attribute long endPageRange; */ 1.131 +NS_IMETHODIMP nsPrintSettings::GetEndPageRange(int32_t *aEndPageRange) 1.132 +{ 1.133 + //NS_ENSURE_ARG_POINTER(aEndPageRange); 1.134 + *aEndPageRange = mEndPageNum; 1.135 + return NS_OK; 1.136 +} 1.137 +NS_IMETHODIMP nsPrintSettings::SetEndPageRange(int32_t aEndPageRange) 1.138 +{ 1.139 + mEndPageNum = aEndPageRange; 1.140 + return NS_OK; 1.141 +} 1.142 + 1.143 +/* attribute boolean printReversed; */ 1.144 +NS_IMETHODIMP nsPrintSettings::GetPrintReversed(bool *aPrintReversed) 1.145 +{ 1.146 + //NS_ENSURE_ARG_POINTER(aPrintReversed); 1.147 + *aPrintReversed = mPrintReversed; 1.148 + return NS_OK; 1.149 +} 1.150 +NS_IMETHODIMP nsPrintSettings::SetPrintReversed(bool aPrintReversed) 1.151 +{ 1.152 + mPrintReversed = aPrintReversed; 1.153 + return NS_OK; 1.154 +} 1.155 + 1.156 +/* attribute boolean printInColor; */ 1.157 +NS_IMETHODIMP nsPrintSettings::GetPrintInColor(bool *aPrintInColor) 1.158 +{ 1.159 + //NS_ENSURE_ARG_POINTER(aPrintInColor); 1.160 + *aPrintInColor = mPrintInColor; 1.161 + return NS_OK; 1.162 +} 1.163 +NS_IMETHODIMP nsPrintSettings::SetPrintInColor(bool aPrintInColor) 1.164 +{ 1.165 + mPrintInColor = aPrintInColor; 1.166 + return NS_OK; 1.167 +} 1.168 + 1.169 +/* attribute short orientation; */ 1.170 +NS_IMETHODIMP nsPrintSettings::GetOrientation(int32_t *aOrientation) 1.171 +{ 1.172 + NS_ENSURE_ARG_POINTER(aOrientation); 1.173 + *aOrientation = mOrientation; 1.174 + return NS_OK; 1.175 +} 1.176 +NS_IMETHODIMP nsPrintSettings::SetOrientation(int32_t aOrientation) 1.177 +{ 1.178 + mOrientation = aOrientation; 1.179 + return NS_OK; 1.180 +} 1.181 + 1.182 +/* attribute wstring colorspace; */ 1.183 +NS_IMETHODIMP nsPrintSettings::GetColorspace(char16_t * *aColorspace) 1.184 +{ 1.185 + NS_ENSURE_ARG_POINTER(aColorspace); 1.186 + if (!mColorspace.IsEmpty()) { 1.187 + *aColorspace = ToNewUnicode(mColorspace); 1.188 + } else { 1.189 + *aColorspace = nullptr; 1.190 + } 1.191 + return NS_OK; 1.192 +} 1.193 +NS_IMETHODIMP nsPrintSettings::SetColorspace(const char16_t * aColorspace) 1.194 +{ 1.195 + if (aColorspace) { 1.196 + mColorspace = aColorspace; 1.197 + } else { 1.198 + mColorspace.SetLength(0); 1.199 + } 1.200 + return NS_OK; 1.201 +} 1.202 + 1.203 +/* attribute wstring resolutionname; */ 1.204 +NS_IMETHODIMP nsPrintSettings::GetResolutionName(char16_t * *aResolutionName) 1.205 +{ 1.206 + NS_ENSURE_ARG_POINTER(aResolutionName); 1.207 + if (!mResolutionName.IsEmpty()) { 1.208 + *aResolutionName = ToNewUnicode(mResolutionName); 1.209 + } else { 1.210 + *aResolutionName = nullptr; 1.211 + } 1.212 + return NS_OK; 1.213 +} 1.214 +NS_IMETHODIMP nsPrintSettings::SetResolutionName(const char16_t * aResolutionName) 1.215 +{ 1.216 + if (aResolutionName) { 1.217 + mResolutionName = aResolutionName; 1.218 + } else { 1.219 + mResolutionName.SetLength(0); 1.220 + } 1.221 + return NS_OK; 1.222 +} 1.223 + 1.224 +/* attribute wstring resolution; */ 1.225 +NS_IMETHODIMP nsPrintSettings::GetResolution(int32_t *aResolution) 1.226 +{ 1.227 + NS_ENSURE_ARG_POINTER(aResolution); 1.228 + *aResolution = mResolution; 1.229 + return NS_OK; 1.230 +} 1.231 +NS_IMETHODIMP nsPrintSettings::SetResolution(const int32_t aResolution) 1.232 +{ 1.233 + mResolution = aResolution; 1.234 + return NS_OK; 1.235 +} 1.236 + 1.237 +/* attribute wstring duplex; */ 1.238 +NS_IMETHODIMP nsPrintSettings::GetDuplex(int32_t *aDuplex) 1.239 +{ 1.240 + NS_ENSURE_ARG_POINTER(aDuplex); 1.241 + *aDuplex = mDuplex; 1.242 + return NS_OK; 1.243 +} 1.244 +NS_IMETHODIMP nsPrintSettings::SetDuplex(const int32_t aDuplex) 1.245 +{ 1.246 + mDuplex = aDuplex; 1.247 + return NS_OK; 1.248 +} 1.249 + 1.250 +/* attribute boolean downloadFonts; */ 1.251 +NS_IMETHODIMP nsPrintSettings::GetDownloadFonts(bool *aDownloadFonts) 1.252 +{ 1.253 + //NS_ENSURE_ARG_POINTER(aDownloadFonts); 1.254 + *aDownloadFonts = mDownloadFonts; 1.255 + return NS_OK; 1.256 +} 1.257 +NS_IMETHODIMP nsPrintSettings::SetDownloadFonts(bool aDownloadFonts) 1.258 +{ 1.259 + mDownloadFonts = aDownloadFonts; 1.260 + return NS_OK; 1.261 +} 1.262 + 1.263 +/* attribute wstring printer; */ 1.264 +NS_IMETHODIMP nsPrintSettings::GetPrinterName(char16_t * *aPrinter) 1.265 +{ 1.266 + NS_ENSURE_ARG_POINTER(aPrinter); 1.267 + 1.268 + *aPrinter = ToNewUnicode(mPrinter); 1.269 + NS_ENSURE_TRUE(*aPrinter, NS_ERROR_OUT_OF_MEMORY); 1.270 + 1.271 + return NS_OK; 1.272 +} 1.273 + 1.274 +NS_IMETHODIMP nsPrintSettings::SetPrinterName(const char16_t * aPrinter) 1.275 +{ 1.276 + if (!aPrinter || !mPrinter.Equals(aPrinter)) { 1.277 + mIsInitedFromPrinter = false; 1.278 + mIsInitedFromPrefs = false; 1.279 + } 1.280 + 1.281 + mPrinter.Assign(aPrinter); 1.282 + return NS_OK; 1.283 +} 1.284 + 1.285 +/* attribute long numCopies; */ 1.286 +NS_IMETHODIMP nsPrintSettings::GetNumCopies(int32_t *aNumCopies) 1.287 +{ 1.288 + NS_ENSURE_ARG_POINTER(aNumCopies); 1.289 + *aNumCopies = mNumCopies; 1.290 + return NS_OK; 1.291 +} 1.292 +NS_IMETHODIMP nsPrintSettings::SetNumCopies(int32_t aNumCopies) 1.293 +{ 1.294 + mNumCopies = aNumCopies; 1.295 + return NS_OK; 1.296 +} 1.297 + 1.298 +/* attribute wstring printCommand; */ 1.299 +NS_IMETHODIMP nsPrintSettings::GetPrintCommand(char16_t * *aPrintCommand) 1.300 +{ 1.301 + //NS_ENSURE_ARG_POINTER(aPrintCommand); 1.302 + *aPrintCommand = ToNewUnicode(mPrintCommand); 1.303 + return NS_OK; 1.304 +} 1.305 +NS_IMETHODIMP nsPrintSettings::SetPrintCommand(const char16_t * aPrintCommand) 1.306 +{ 1.307 + if (aPrintCommand) { 1.308 + mPrintCommand = aPrintCommand; 1.309 + } else { 1.310 + mPrintCommand.SetLength(0); 1.311 + } 1.312 + return NS_OK; 1.313 +} 1.314 + 1.315 +/* attribute boolean printToFile; */ 1.316 +NS_IMETHODIMP nsPrintSettings::GetPrintToFile(bool *aPrintToFile) 1.317 +{ 1.318 + //NS_ENSURE_ARG_POINTER(aPrintToFile); 1.319 + *aPrintToFile = mPrintToFile; 1.320 + return NS_OK; 1.321 +} 1.322 +NS_IMETHODIMP nsPrintSettings::SetPrintToFile(bool aPrintToFile) 1.323 +{ 1.324 + mPrintToFile = aPrintToFile; 1.325 + return NS_OK; 1.326 +} 1.327 + 1.328 +/* attribute wstring toFileName; */ 1.329 +NS_IMETHODIMP nsPrintSettings::GetToFileName(char16_t * *aToFileName) 1.330 +{ 1.331 + //NS_ENSURE_ARG_POINTER(aToFileName); 1.332 + *aToFileName = ToNewUnicode(mToFileName); 1.333 + return NS_OK; 1.334 +} 1.335 +NS_IMETHODIMP nsPrintSettings::SetToFileName(const char16_t * aToFileName) 1.336 +{ 1.337 + if (aToFileName) { 1.338 + mToFileName = aToFileName; 1.339 + } else { 1.340 + mToFileName.SetLength(0); 1.341 + } 1.342 + return NS_OK; 1.343 +} 1.344 + 1.345 +/* attribute short outputFormat; */ 1.346 +NS_IMETHODIMP nsPrintSettings::GetOutputFormat(int16_t *aOutputFormat) 1.347 +{ 1.348 + NS_ENSURE_ARG_POINTER(aOutputFormat); 1.349 + *aOutputFormat = mOutputFormat; 1.350 + return NS_OK; 1.351 +} 1.352 +NS_IMETHODIMP nsPrintSettings::SetOutputFormat(int16_t aOutputFormat) 1.353 +{ 1.354 + mOutputFormat = aOutputFormat; 1.355 + return NS_OK; 1.356 +} 1.357 + 1.358 +/* attribute long printPageDelay; */ 1.359 +NS_IMETHODIMP nsPrintSettings::GetPrintPageDelay(int32_t *aPrintPageDelay) 1.360 +{ 1.361 + *aPrintPageDelay = mPrintPageDelay; 1.362 + return NS_OK; 1.363 +} 1.364 +NS_IMETHODIMP nsPrintSettings::SetPrintPageDelay(int32_t aPrintPageDelay) 1.365 +{ 1.366 + mPrintPageDelay = aPrintPageDelay; 1.367 + return NS_OK; 1.368 +} 1.369 + 1.370 +/* attribute boolean isInitializedFromPrinter; */ 1.371 +NS_IMETHODIMP nsPrintSettings::GetIsInitializedFromPrinter(bool *aIsInitializedFromPrinter) 1.372 +{ 1.373 + NS_ENSURE_ARG_POINTER(aIsInitializedFromPrinter); 1.374 + *aIsInitializedFromPrinter = (bool)mIsInitedFromPrinter; 1.375 + return NS_OK; 1.376 +} 1.377 +NS_IMETHODIMP nsPrintSettings::SetIsInitializedFromPrinter(bool aIsInitializedFromPrinter) 1.378 +{ 1.379 + mIsInitedFromPrinter = (bool)aIsInitializedFromPrinter; 1.380 + return NS_OK; 1.381 +} 1.382 + 1.383 +/* attribute boolean isInitializedFromPrefs; */ 1.384 +NS_IMETHODIMP nsPrintSettings::GetIsInitializedFromPrefs(bool *aInitializedFromPrefs) 1.385 +{ 1.386 + NS_ENSURE_ARG_POINTER(aInitializedFromPrefs); 1.387 + *aInitializedFromPrefs = (bool)mIsInitedFromPrefs; 1.388 + return NS_OK; 1.389 +} 1.390 +NS_IMETHODIMP nsPrintSettings::SetIsInitializedFromPrefs(bool aInitializedFromPrefs) 1.391 +{ 1.392 + mIsInitedFromPrefs = (bool)aInitializedFromPrefs; 1.393 + return NS_OK; 1.394 +} 1.395 + 1.396 +/* attribute boolean persistMarginBoxSettings; */ 1.397 +NS_IMETHODIMP nsPrintSettings::GetPersistMarginBoxSettings(bool *aPersistMarginBoxSettings) 1.398 +{ 1.399 + NS_ENSURE_ARG_POINTER(aPersistMarginBoxSettings); 1.400 + *aPersistMarginBoxSettings = mPersistMarginBoxSettings; 1.401 + return NS_OK; 1.402 +} 1.403 +NS_IMETHODIMP nsPrintSettings::SetPersistMarginBoxSettings(bool aPersistMarginBoxSettings) 1.404 +{ 1.405 + mPersistMarginBoxSettings = aPersistMarginBoxSettings; 1.406 + return NS_OK; 1.407 +} 1.408 + 1.409 +/* attribute double marginTop; */ 1.410 +NS_IMETHODIMP nsPrintSettings::GetMarginTop(double *aMarginTop) 1.411 +{ 1.412 + NS_ENSURE_ARG_POINTER(aMarginTop); 1.413 + *aMarginTop = NS_TWIPS_TO_INCHES(mMargin.top); 1.414 + return NS_OK; 1.415 +} 1.416 +NS_IMETHODIMP nsPrintSettings::SetMarginTop(double aMarginTop) 1.417 +{ 1.418 + mMargin.top = NS_INCHES_TO_INT_TWIPS(float(aMarginTop)); 1.419 + return NS_OK; 1.420 +} 1.421 + 1.422 +/* attribute double marginLeft; */ 1.423 +NS_IMETHODIMP nsPrintSettings::GetMarginLeft(double *aMarginLeft) 1.424 +{ 1.425 + NS_ENSURE_ARG_POINTER(aMarginLeft); 1.426 + *aMarginLeft = NS_TWIPS_TO_INCHES(mMargin.left); 1.427 + return NS_OK; 1.428 +} 1.429 +NS_IMETHODIMP nsPrintSettings::SetMarginLeft(double aMarginLeft) 1.430 +{ 1.431 + mMargin.left = NS_INCHES_TO_INT_TWIPS(float(aMarginLeft)); 1.432 + return NS_OK; 1.433 +} 1.434 + 1.435 +/* attribute double marginBottom; */ 1.436 +NS_IMETHODIMP nsPrintSettings::GetMarginBottom(double *aMarginBottom) 1.437 +{ 1.438 + NS_ENSURE_ARG_POINTER(aMarginBottom); 1.439 + *aMarginBottom = NS_TWIPS_TO_INCHES(mMargin.bottom); 1.440 + return NS_OK; 1.441 +} 1.442 +NS_IMETHODIMP nsPrintSettings::SetMarginBottom(double aMarginBottom) 1.443 +{ 1.444 + mMargin.bottom = NS_INCHES_TO_INT_TWIPS(float(aMarginBottom)); 1.445 + return NS_OK; 1.446 +} 1.447 + 1.448 +/* attribute double marginRight; */ 1.449 +NS_IMETHODIMP nsPrintSettings::GetMarginRight(double *aMarginRight) 1.450 +{ 1.451 + NS_ENSURE_ARG_POINTER(aMarginRight); 1.452 + *aMarginRight = NS_TWIPS_TO_INCHES(mMargin.right); 1.453 + return NS_OK; 1.454 +} 1.455 +NS_IMETHODIMP nsPrintSettings::SetMarginRight(double aMarginRight) 1.456 +{ 1.457 + mMargin.right = NS_INCHES_TO_INT_TWIPS(float(aMarginRight)); 1.458 + return NS_OK; 1.459 +} 1.460 + 1.461 +/* attribute double edgeTop; */ 1.462 +NS_IMETHODIMP nsPrintSettings::GetEdgeTop(double *aEdgeTop) 1.463 +{ 1.464 + NS_ENSURE_ARG_POINTER(aEdgeTop); 1.465 + *aEdgeTop = NS_TWIPS_TO_INCHES(mEdge.top); 1.466 + return NS_OK; 1.467 +} 1.468 +NS_IMETHODIMP nsPrintSettings::SetEdgeTop(double aEdgeTop) 1.469 +{ 1.470 + mEdge.top = NS_INCHES_TO_INT_TWIPS(float(aEdgeTop)); 1.471 + return NS_OK; 1.472 +} 1.473 + 1.474 +/* attribute double edgeLeft; */ 1.475 +NS_IMETHODIMP nsPrintSettings::GetEdgeLeft(double *aEdgeLeft) 1.476 +{ 1.477 + NS_ENSURE_ARG_POINTER(aEdgeLeft); 1.478 + *aEdgeLeft = NS_TWIPS_TO_INCHES(mEdge.left); 1.479 + return NS_OK; 1.480 +} 1.481 +NS_IMETHODIMP nsPrintSettings::SetEdgeLeft(double aEdgeLeft) 1.482 +{ 1.483 + mEdge.left = NS_INCHES_TO_INT_TWIPS(float(aEdgeLeft)); 1.484 + return NS_OK; 1.485 +} 1.486 + 1.487 +/* attribute double edgeBottom; */ 1.488 +NS_IMETHODIMP nsPrintSettings::GetEdgeBottom(double *aEdgeBottom) 1.489 +{ 1.490 + NS_ENSURE_ARG_POINTER(aEdgeBottom); 1.491 + *aEdgeBottom = NS_TWIPS_TO_INCHES(mEdge.bottom); 1.492 + return NS_OK; 1.493 +} 1.494 +NS_IMETHODIMP nsPrintSettings::SetEdgeBottom(double aEdgeBottom) 1.495 +{ 1.496 + mEdge.bottom = NS_INCHES_TO_INT_TWIPS(float(aEdgeBottom)); 1.497 + return NS_OK; 1.498 +} 1.499 + 1.500 +/* attribute double edgeRight; */ 1.501 +NS_IMETHODIMP nsPrintSettings::GetEdgeRight(double *aEdgeRight) 1.502 +{ 1.503 + NS_ENSURE_ARG_POINTER(aEdgeRight); 1.504 + *aEdgeRight = NS_TWIPS_TO_INCHES(mEdge.right); 1.505 + return NS_OK; 1.506 +} 1.507 +NS_IMETHODIMP nsPrintSettings::SetEdgeRight(double aEdgeRight) 1.508 +{ 1.509 + mEdge.right = NS_INCHES_TO_INT_TWIPS(float(aEdgeRight)); 1.510 + return NS_OK; 1.511 +} 1.512 + 1.513 +/* attribute double unwriteableMarginTop; */ 1.514 +NS_IMETHODIMP nsPrintSettings::GetUnwriteableMarginTop(double *aUnwriteableMarginTop) 1.515 +{ 1.516 + NS_ENSURE_ARG_POINTER(aUnwriteableMarginTop); 1.517 + *aUnwriteableMarginTop = NS_TWIPS_TO_INCHES(mUnwriteableMargin.top); 1.518 + return NS_OK; 1.519 +} 1.520 +NS_IMETHODIMP nsPrintSettings::SetUnwriteableMarginTop(double aUnwriteableMarginTop) 1.521 +{ 1.522 + if (aUnwriteableMarginTop >= 0.0) { 1.523 + mUnwriteableMargin.top = NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginTop); 1.524 + } 1.525 + return NS_OK; 1.526 +} 1.527 + 1.528 +/* attribute double unwriteableMarginLeft; */ 1.529 +NS_IMETHODIMP nsPrintSettings::GetUnwriteableMarginLeft(double *aUnwriteableMarginLeft) 1.530 +{ 1.531 + NS_ENSURE_ARG_POINTER(aUnwriteableMarginLeft); 1.532 + *aUnwriteableMarginLeft = NS_TWIPS_TO_INCHES(mUnwriteableMargin.left); 1.533 + return NS_OK; 1.534 +} 1.535 +NS_IMETHODIMP nsPrintSettings::SetUnwriteableMarginLeft(double aUnwriteableMarginLeft) 1.536 +{ 1.537 + if (aUnwriteableMarginLeft >= 0.0) { 1.538 + mUnwriteableMargin.left = NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginLeft); 1.539 + } 1.540 + return NS_OK; 1.541 +} 1.542 + 1.543 +/* attribute double unwriteableMarginBottom; */ 1.544 +NS_IMETHODIMP nsPrintSettings::GetUnwriteableMarginBottom(double *aUnwriteableMarginBottom) 1.545 +{ 1.546 + NS_ENSURE_ARG_POINTER(aUnwriteableMarginBottom); 1.547 + *aUnwriteableMarginBottom = NS_TWIPS_TO_INCHES(mUnwriteableMargin.bottom); 1.548 + return NS_OK; 1.549 +} 1.550 +NS_IMETHODIMP nsPrintSettings::SetUnwriteableMarginBottom(double aUnwriteableMarginBottom) 1.551 +{ 1.552 + if (aUnwriteableMarginBottom >= 0.0) { 1.553 + mUnwriteableMargin.bottom = NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginBottom); 1.554 + } 1.555 + return NS_OK; 1.556 +} 1.557 + 1.558 +/* attribute double unwriteableMarginRight; */ 1.559 +NS_IMETHODIMP nsPrintSettings::GetUnwriteableMarginRight(double *aUnwriteableMarginRight) 1.560 +{ 1.561 + NS_ENSURE_ARG_POINTER(aUnwriteableMarginRight); 1.562 + *aUnwriteableMarginRight = NS_TWIPS_TO_INCHES(mUnwriteableMargin.right); 1.563 + return NS_OK; 1.564 +} 1.565 +NS_IMETHODIMP nsPrintSettings::SetUnwriteableMarginRight(double aUnwriteableMarginRight) 1.566 +{ 1.567 + if (aUnwriteableMarginRight >= 0.0) { 1.568 + mUnwriteableMargin.right = NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginRight); 1.569 + } 1.570 + return NS_OK; 1.571 +} 1.572 + 1.573 +/* attribute double scaling; */ 1.574 +NS_IMETHODIMP nsPrintSettings::GetScaling(double *aScaling) 1.575 +{ 1.576 + NS_ENSURE_ARG_POINTER(aScaling); 1.577 + *aScaling = mScaling; 1.578 + return NS_OK; 1.579 +} 1.580 + 1.581 +NS_IMETHODIMP nsPrintSettings::SetScaling(double aScaling) 1.582 +{ 1.583 + mScaling = aScaling; 1.584 + return NS_OK; 1.585 +} 1.586 + 1.587 +/* attribute boolean printBGColors; */ 1.588 +NS_IMETHODIMP nsPrintSettings::GetPrintBGColors(bool *aPrintBGColors) 1.589 +{ 1.590 + NS_ENSURE_ARG_POINTER(aPrintBGColors); 1.591 + *aPrintBGColors = mPrintBGColors; 1.592 + return NS_OK; 1.593 +} 1.594 +NS_IMETHODIMP nsPrintSettings::SetPrintBGColors(bool aPrintBGColors) 1.595 +{ 1.596 + mPrintBGColors = aPrintBGColors; 1.597 + return NS_OK; 1.598 +} 1.599 + 1.600 +/* attribute boolean printBGImages; */ 1.601 +NS_IMETHODIMP nsPrintSettings::GetPrintBGImages(bool *aPrintBGImages) 1.602 +{ 1.603 + NS_ENSURE_ARG_POINTER(aPrintBGImages); 1.604 + *aPrintBGImages = mPrintBGImages; 1.605 + return NS_OK; 1.606 +} 1.607 +NS_IMETHODIMP nsPrintSettings::SetPrintBGImages(bool aPrintBGImages) 1.608 +{ 1.609 + mPrintBGImages = aPrintBGImages; 1.610 + return NS_OK; 1.611 +} 1.612 + 1.613 +/* attribute long printRange; */ 1.614 +NS_IMETHODIMP nsPrintSettings::GetPrintRange(int16_t *aPrintRange) 1.615 +{ 1.616 + NS_ENSURE_ARG_POINTER(aPrintRange); 1.617 + *aPrintRange = mPrintRange; 1.618 + return NS_OK; 1.619 +} 1.620 +NS_IMETHODIMP nsPrintSettings::SetPrintRange(int16_t aPrintRange) 1.621 +{ 1.622 + mPrintRange = aPrintRange; 1.623 + return NS_OK; 1.624 +} 1.625 + 1.626 +/* attribute wstring docTitle; */ 1.627 +NS_IMETHODIMP nsPrintSettings::GetTitle(char16_t * *aTitle) 1.628 +{ 1.629 + NS_ENSURE_ARG_POINTER(aTitle); 1.630 + if (!mTitle.IsEmpty()) { 1.631 + *aTitle = ToNewUnicode(mTitle); 1.632 + } else { 1.633 + *aTitle = nullptr; 1.634 + } 1.635 + return NS_OK; 1.636 +} 1.637 +NS_IMETHODIMP nsPrintSettings::SetTitle(const char16_t * aTitle) 1.638 +{ 1.639 + if (aTitle) { 1.640 + mTitle = aTitle; 1.641 + } else { 1.642 + mTitle.SetLength(0); 1.643 + } 1.644 + return NS_OK; 1.645 +} 1.646 + 1.647 +/* attribute wstring docURL; */ 1.648 +NS_IMETHODIMP nsPrintSettings::GetDocURL(char16_t * *aDocURL) 1.649 +{ 1.650 + NS_ENSURE_ARG_POINTER(aDocURL); 1.651 + if (!mURL.IsEmpty()) { 1.652 + *aDocURL = ToNewUnicode(mURL); 1.653 + } else { 1.654 + *aDocURL = nullptr; 1.655 + } 1.656 + return NS_OK; 1.657 +} 1.658 +NS_IMETHODIMP nsPrintSettings::SetDocURL(const char16_t * aDocURL) 1.659 +{ 1.660 + if (aDocURL) { 1.661 + mURL = aDocURL; 1.662 + } else { 1.663 + mURL.SetLength(0); 1.664 + } 1.665 + return NS_OK; 1.666 +} 1.667 + 1.668 +/** --------------------------------------------------- 1.669 + * See documentation in nsPrintSettingsImpl.h 1.670 + * @update 1/12/01 rods 1.671 + */ 1.672 +NS_IMETHODIMP 1.673 +nsPrintSettings::GetPrintOptions(int32_t aType, bool *aTurnOnOff) 1.674 +{ 1.675 + NS_ENSURE_ARG_POINTER(aTurnOnOff); 1.676 + *aTurnOnOff = mPrintOptions & aType ? true : false; 1.677 + return NS_OK; 1.678 +} 1.679 +/** --------------------------------------------------- 1.680 + * See documentation in nsPrintSettingsImpl.h 1.681 + * @update 1/12/01 rods 1.682 + */ 1.683 +NS_IMETHODIMP 1.684 +nsPrintSettings::SetPrintOptions(int32_t aType, bool aTurnOnOff) 1.685 +{ 1.686 + if (aTurnOnOff) { 1.687 + mPrintOptions |= aType; 1.688 + } else { 1.689 + mPrintOptions &= ~aType; 1.690 + } 1.691 + return NS_OK; 1.692 +} 1.693 + 1.694 +/** --------------------------------------------------- 1.695 + * See documentation in nsPrintSettingsImpl.h 1.696 + * @update 1/12/01 rods 1.697 + */ 1.698 +NS_IMETHODIMP 1.699 +nsPrintSettings::GetPrintOptionsBits(int32_t *aBits) 1.700 +{ 1.701 + NS_ENSURE_ARG_POINTER(aBits); 1.702 + *aBits = mPrintOptions; 1.703 + return NS_OK; 1.704 +} 1.705 + 1.706 +/* attribute wstring docTitle; */ 1.707 +nsresult 1.708 +nsPrintSettings::GetMarginStrs(char16_t * *aTitle, 1.709 + nsHeaderFooterEnum aType, 1.710 + int16_t aJust) 1.711 +{ 1.712 + NS_ENSURE_ARG_POINTER(aTitle); 1.713 + *aTitle = nullptr; 1.714 + if (aType == eHeader) { 1.715 + switch (aJust) { 1.716 + case kJustLeft: *aTitle = ToNewUnicode(mHeaderStrs[0]);break; 1.717 + case kJustCenter: *aTitle = ToNewUnicode(mHeaderStrs[1]);break; 1.718 + case kJustRight: *aTitle = ToNewUnicode(mHeaderStrs[2]);break; 1.719 + } //switch 1.720 + } else { 1.721 + switch (aJust) { 1.722 + case kJustLeft: *aTitle = ToNewUnicode(mFooterStrs[0]);break; 1.723 + case kJustCenter: *aTitle = ToNewUnicode(mFooterStrs[1]);break; 1.724 + case kJustRight: *aTitle = ToNewUnicode(mFooterStrs[2]);break; 1.725 + } //switch 1.726 + } 1.727 + return NS_OK; 1.728 +} 1.729 + 1.730 +nsresult 1.731 +nsPrintSettings::SetMarginStrs(const char16_t * aTitle, 1.732 + nsHeaderFooterEnum aType, 1.733 + int16_t aJust) 1.734 +{ 1.735 + NS_ENSURE_ARG_POINTER(aTitle); 1.736 + if (aType == eHeader) { 1.737 + switch (aJust) { 1.738 + case kJustLeft: mHeaderStrs[0] = aTitle;break; 1.739 + case kJustCenter: mHeaderStrs[1] = aTitle;break; 1.740 + case kJustRight: mHeaderStrs[2] = aTitle;break; 1.741 + } //switch 1.742 + } else { 1.743 + switch (aJust) { 1.744 + case kJustLeft: mFooterStrs[0] = aTitle;break; 1.745 + case kJustCenter: mFooterStrs[1] = aTitle;break; 1.746 + case kJustRight: mFooterStrs[2] = aTitle;break; 1.747 + } //switch 1.748 + } 1.749 + return NS_OK; 1.750 +} 1.751 + 1.752 +/* attribute wstring Header String Left */ 1.753 +NS_IMETHODIMP nsPrintSettings::GetHeaderStrLeft(char16_t * *aTitle) 1.754 +{ 1.755 + return GetMarginStrs(aTitle, eHeader, kJustLeft); 1.756 +} 1.757 +NS_IMETHODIMP nsPrintSettings::SetHeaderStrLeft(const char16_t * aTitle) 1.758 +{ 1.759 + return SetMarginStrs(aTitle, eHeader, kJustLeft); 1.760 +} 1.761 + 1.762 +/* attribute wstring Header String Center */ 1.763 +NS_IMETHODIMP nsPrintSettings::GetHeaderStrCenter(char16_t * *aTitle) 1.764 +{ 1.765 + return GetMarginStrs(aTitle, eHeader, kJustCenter); 1.766 +} 1.767 +NS_IMETHODIMP nsPrintSettings::SetHeaderStrCenter(const char16_t * aTitle) 1.768 +{ 1.769 + return SetMarginStrs(aTitle, eHeader, kJustCenter); 1.770 +} 1.771 + 1.772 +/* attribute wstring Header String Right */ 1.773 +NS_IMETHODIMP nsPrintSettings::GetHeaderStrRight(char16_t * *aTitle) 1.774 +{ 1.775 + return GetMarginStrs(aTitle, eHeader, kJustRight); 1.776 +} 1.777 +NS_IMETHODIMP nsPrintSettings::SetHeaderStrRight(const char16_t * aTitle) 1.778 +{ 1.779 + return SetMarginStrs(aTitle, eHeader, kJustRight); 1.780 +} 1.781 + 1.782 + 1.783 +/* attribute wstring Footer String Left */ 1.784 +NS_IMETHODIMP nsPrintSettings::GetFooterStrLeft(char16_t * *aTitle) 1.785 +{ 1.786 + return GetMarginStrs(aTitle, eFooter, kJustLeft); 1.787 +} 1.788 +NS_IMETHODIMP nsPrintSettings::SetFooterStrLeft(const char16_t * aTitle) 1.789 +{ 1.790 + return SetMarginStrs(aTitle, eFooter, kJustLeft); 1.791 +} 1.792 + 1.793 +/* attribute wstring Footer String Center */ 1.794 +NS_IMETHODIMP nsPrintSettings::GetFooterStrCenter(char16_t * *aTitle) 1.795 +{ 1.796 + return GetMarginStrs(aTitle, eFooter, kJustCenter); 1.797 +} 1.798 +NS_IMETHODIMP nsPrintSettings::SetFooterStrCenter(const char16_t * aTitle) 1.799 +{ 1.800 + return SetMarginStrs(aTitle, eFooter, kJustCenter); 1.801 +} 1.802 + 1.803 +/* attribute wstring Footer String Right */ 1.804 +NS_IMETHODIMP nsPrintSettings::GetFooterStrRight(char16_t * *aTitle) 1.805 +{ 1.806 + return GetMarginStrs(aTitle, eFooter, kJustRight); 1.807 +} 1.808 +NS_IMETHODIMP nsPrintSettings::SetFooterStrRight(const char16_t * aTitle) 1.809 +{ 1.810 + return SetMarginStrs(aTitle, eFooter, kJustRight); 1.811 +} 1.812 + 1.813 +/* attribute short printFrameTypeUsage; */ 1.814 +NS_IMETHODIMP nsPrintSettings::GetPrintFrameTypeUsage(int16_t *aPrintFrameTypeUsage) 1.815 +{ 1.816 + NS_ENSURE_ARG_POINTER(aPrintFrameTypeUsage); 1.817 + *aPrintFrameTypeUsage = mPrintFrameTypeUsage; 1.818 + return NS_OK; 1.819 +} 1.820 +NS_IMETHODIMP nsPrintSettings::SetPrintFrameTypeUsage(int16_t aPrintFrameTypeUsage) 1.821 +{ 1.822 + mPrintFrameTypeUsage = aPrintFrameTypeUsage; 1.823 + return NS_OK; 1.824 +} 1.825 + 1.826 +/* attribute long printFrameType; */ 1.827 +NS_IMETHODIMP nsPrintSettings::GetPrintFrameType(int16_t *aPrintFrameType) 1.828 +{ 1.829 + NS_ENSURE_ARG_POINTER(aPrintFrameType); 1.830 + *aPrintFrameType = (int32_t)mPrintFrameType; 1.831 + return NS_OK; 1.832 +} 1.833 +NS_IMETHODIMP nsPrintSettings::SetPrintFrameType(int16_t aPrintFrameType) 1.834 +{ 1.835 + mPrintFrameType = aPrintFrameType; 1.836 + return NS_OK; 1.837 +} 1.838 + 1.839 +/* attribute boolean printSilent; */ 1.840 +NS_IMETHODIMP nsPrintSettings::GetPrintSilent(bool *aPrintSilent) 1.841 +{ 1.842 + NS_ENSURE_ARG_POINTER(aPrintSilent); 1.843 + *aPrintSilent = mPrintSilent; 1.844 + return NS_OK; 1.845 +} 1.846 +NS_IMETHODIMP nsPrintSettings::SetPrintSilent(bool aPrintSilent) 1.847 +{ 1.848 + mPrintSilent = aPrintSilent; 1.849 + return NS_OK; 1.850 +} 1.851 + 1.852 +/* attribute boolean shrinkToFit; */ 1.853 +NS_IMETHODIMP nsPrintSettings::GetShrinkToFit(bool *aShrinkToFit) 1.854 +{ 1.855 + NS_ENSURE_ARG_POINTER(aShrinkToFit); 1.856 + *aShrinkToFit = mShrinkToFit; 1.857 + return NS_OK; 1.858 +} 1.859 +NS_IMETHODIMP nsPrintSettings::SetShrinkToFit(bool aShrinkToFit) 1.860 +{ 1.861 + mShrinkToFit = aShrinkToFit; 1.862 + return NS_OK; 1.863 +} 1.864 + 1.865 +/* attribute boolean showPrintProgress; */ 1.866 +NS_IMETHODIMP nsPrintSettings::GetShowPrintProgress(bool *aShowPrintProgress) 1.867 +{ 1.868 + NS_ENSURE_ARG_POINTER(aShowPrintProgress); 1.869 + *aShowPrintProgress = mShowPrintProgress; 1.870 + return NS_OK; 1.871 +} 1.872 +NS_IMETHODIMP nsPrintSettings::SetShowPrintProgress(bool aShowPrintProgress) 1.873 +{ 1.874 + mShowPrintProgress = aShowPrintProgress; 1.875 + return NS_OK; 1.876 +} 1.877 + 1.878 +/* attribute wstring paperName; */ 1.879 +NS_IMETHODIMP nsPrintSettings::GetPaperName(char16_t * *aPaperName) 1.880 +{ 1.881 + NS_ENSURE_ARG_POINTER(aPaperName); 1.882 + if (!mPaperName.IsEmpty()) { 1.883 + *aPaperName = ToNewUnicode(mPaperName); 1.884 + } else { 1.885 + *aPaperName = nullptr; 1.886 + } 1.887 + return NS_OK; 1.888 +} 1.889 +NS_IMETHODIMP nsPrintSettings::SetPaperName(const char16_t * aPaperName) 1.890 +{ 1.891 + if (aPaperName) { 1.892 + mPaperName = aPaperName; 1.893 + } else { 1.894 + mPaperName.SetLength(0); 1.895 + } 1.896 + return NS_OK; 1.897 +} 1.898 + 1.899 +/* attribute wstring plexName; */ 1.900 +NS_IMETHODIMP nsPrintSettings::GetPlexName(char16_t * *aPlexName) 1.901 +{ 1.902 + NS_ENSURE_ARG_POINTER(aPlexName); 1.903 + if (!mPlexName.IsEmpty()) { 1.904 + *aPlexName = ToNewUnicode(mPlexName); 1.905 + } else { 1.906 + *aPlexName = nullptr; 1.907 + } 1.908 + return NS_OK; 1.909 +} 1.910 +NS_IMETHODIMP nsPrintSettings::SetPlexName(const char16_t * aPlexName) 1.911 +{ 1.912 + if (aPlexName) { 1.913 + mPlexName = aPlexName; 1.914 + } else { 1.915 + mPlexName.SetLength(0); 1.916 + } 1.917 + return NS_OK; 1.918 +} 1.919 + 1.920 +/* attribute boolean howToEnableFrameUI; */ 1.921 +NS_IMETHODIMP nsPrintSettings::GetHowToEnableFrameUI(int16_t *aHowToEnableFrameUI) 1.922 +{ 1.923 + NS_ENSURE_ARG_POINTER(aHowToEnableFrameUI); 1.924 + *aHowToEnableFrameUI = mHowToEnableFrameUI; 1.925 + return NS_OK; 1.926 +} 1.927 +NS_IMETHODIMP nsPrintSettings::SetHowToEnableFrameUI(int16_t aHowToEnableFrameUI) 1.928 +{ 1.929 + mHowToEnableFrameUI = aHowToEnableFrameUI; 1.930 + return NS_OK; 1.931 +} 1.932 + 1.933 +/* attribute long isCancelled; */ 1.934 +NS_IMETHODIMP nsPrintSettings::GetIsCancelled(bool *aIsCancelled) 1.935 +{ 1.936 + NS_ENSURE_ARG_POINTER(aIsCancelled); 1.937 + *aIsCancelled = mIsCancelled; 1.938 + return NS_OK; 1.939 +} 1.940 +NS_IMETHODIMP nsPrintSettings::SetIsCancelled(bool aIsCancelled) 1.941 +{ 1.942 + mIsCancelled = aIsCancelled; 1.943 + return NS_OK; 1.944 +} 1.945 + 1.946 +/* attribute double paperWidth; */ 1.947 +NS_IMETHODIMP nsPrintSettings::GetPaperWidth(double *aPaperWidth) 1.948 +{ 1.949 + NS_ENSURE_ARG_POINTER(aPaperWidth); 1.950 + *aPaperWidth = mPaperWidth; 1.951 + return NS_OK; 1.952 +} 1.953 +NS_IMETHODIMP nsPrintSettings::SetPaperWidth(double aPaperWidth) 1.954 +{ 1.955 + mPaperWidth = aPaperWidth; 1.956 + return NS_OK; 1.957 +} 1.958 + 1.959 +/* attribute double paperHeight; */ 1.960 +NS_IMETHODIMP nsPrintSettings::GetPaperHeight(double *aPaperHeight) 1.961 +{ 1.962 + NS_ENSURE_ARG_POINTER(aPaperHeight); 1.963 + *aPaperHeight = mPaperHeight; 1.964 + return NS_OK; 1.965 +} 1.966 +NS_IMETHODIMP nsPrintSettings::SetPaperHeight(double aPaperHeight) 1.967 +{ 1.968 + mPaperHeight = aPaperHeight; 1.969 + return NS_OK; 1.970 +} 1.971 + 1.972 +/* attribute short PaperSizeUnit; */ 1.973 +NS_IMETHODIMP nsPrintSettings::GetPaperSizeUnit(int16_t *aPaperSizeUnit) 1.974 +{ 1.975 + NS_ENSURE_ARG_POINTER(aPaperSizeUnit); 1.976 + *aPaperSizeUnit = mPaperSizeUnit; 1.977 + return NS_OK; 1.978 +} 1.979 +NS_IMETHODIMP nsPrintSettings::SetPaperSizeUnit(int16_t aPaperSizeUnit) 1.980 +{ 1.981 + mPaperSizeUnit = aPaperSizeUnit; 1.982 + return NS_OK; 1.983 +} 1.984 + 1.985 +/* attribute short PaperSizeType; */ 1.986 +NS_IMETHODIMP nsPrintSettings::GetPaperSizeType(int16_t *aPaperSizeType) 1.987 +{ 1.988 + NS_ENSURE_ARG_POINTER(aPaperSizeType); 1.989 + *aPaperSizeType = mPaperSizeType; 1.990 + return NS_OK; 1.991 +} 1.992 +NS_IMETHODIMP nsPrintSettings::SetPaperSizeType(int16_t aPaperSizeType) 1.993 +{ 1.994 + mPaperSizeType = aPaperSizeType; 1.995 + return NS_OK; 1.996 +} 1.997 + 1.998 +/* attribute short PaperData; */ 1.999 +NS_IMETHODIMP nsPrintSettings::GetPaperData(int16_t *aPaperData) 1.1000 +{ 1.1001 + NS_ENSURE_ARG_POINTER(aPaperData); 1.1002 + *aPaperData = mPaperData; 1.1003 + return NS_OK; 1.1004 +} 1.1005 +NS_IMETHODIMP nsPrintSettings::SetPaperData(int16_t aPaperData) 1.1006 +{ 1.1007 + mPaperData = aPaperData; 1.1008 + return NS_OK; 1.1009 +} 1.1010 + 1.1011 +/** --------------------------------------------------- 1.1012 + * See documentation in nsPrintOptionsImpl.h 1.1013 + * @update 6/21/00 dwc 1.1014 + * @update 1/12/01 rods 1.1015 + */ 1.1016 +NS_IMETHODIMP 1.1017 +nsPrintSettings::SetMarginInTwips(nsIntMargin& aMargin) 1.1018 +{ 1.1019 + mMargin = aMargin; 1.1020 + return NS_OK; 1.1021 +} 1.1022 + 1.1023 +NS_IMETHODIMP 1.1024 +nsPrintSettings::SetEdgeInTwips(nsIntMargin& aEdge) 1.1025 +{ 1.1026 + mEdge = aEdge; 1.1027 + return NS_OK; 1.1028 +} 1.1029 + 1.1030 +// NOTE: Any subclass implementation of this function should make sure 1.1031 +// to check for negative margin values in aUnwriteableMargin (which 1.1032 +// would indicate that we should use the system default unwriteable margin.) 1.1033 +NS_IMETHODIMP 1.1034 +nsPrintSettings::SetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin) 1.1035 +{ 1.1036 + if (aUnwriteableMargin.top >= 0) { 1.1037 + mUnwriteableMargin.top = aUnwriteableMargin.top; 1.1038 + } 1.1039 + if (aUnwriteableMargin.left >= 0) { 1.1040 + mUnwriteableMargin.left = aUnwriteableMargin.left; 1.1041 + } 1.1042 + if (aUnwriteableMargin.bottom >= 0) { 1.1043 + mUnwriteableMargin.bottom = aUnwriteableMargin.bottom; 1.1044 + } 1.1045 + if (aUnwriteableMargin.right >= 0) { 1.1046 + mUnwriteableMargin.right = aUnwriteableMargin.right; 1.1047 + } 1.1048 + return NS_OK; 1.1049 +} 1.1050 + 1.1051 +/** --------------------------------------------------- 1.1052 + * See documentation in nsPrintOptionsImpl.h 1.1053 + * @update 6/21/00 dwc 1.1054 + */ 1.1055 +NS_IMETHODIMP 1.1056 +nsPrintSettings::GetMarginInTwips(nsIntMargin& aMargin) 1.1057 +{ 1.1058 + aMargin = mMargin; 1.1059 + return NS_OK; 1.1060 +} 1.1061 + 1.1062 +NS_IMETHODIMP 1.1063 +nsPrintSettings::GetEdgeInTwips(nsIntMargin& aEdge) 1.1064 +{ 1.1065 + aEdge = mEdge; 1.1066 + return NS_OK; 1.1067 +} 1.1068 + 1.1069 +NS_IMETHODIMP 1.1070 +nsPrintSettings::GetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin) 1.1071 +{ 1.1072 + aUnwriteableMargin = mUnwriteableMargin; 1.1073 + return NS_OK; 1.1074 +} 1.1075 + 1.1076 +/** --------------------------------------------------- 1.1077 + * Stub - platform-specific implementations can use this function. 1.1078 + */ 1.1079 +NS_IMETHODIMP 1.1080 +nsPrintSettings::SetupSilentPrinting() 1.1081 +{ 1.1082 + return NS_OK; 1.1083 +} 1.1084 + 1.1085 +/** --------------------------------------------------- 1.1086 + * See documentation in nsPrintOptionsImpl.h 1.1087 + */ 1.1088 +NS_IMETHODIMP 1.1089 +nsPrintSettings::GetEffectivePageSize(double *aWidth, double *aHeight) 1.1090 +{ 1.1091 + if (mPaperSizeUnit == kPaperSizeInches) { 1.1092 + *aWidth = NS_INCHES_TO_TWIPS(float(mPaperWidth)); 1.1093 + *aHeight = NS_INCHES_TO_TWIPS(float(mPaperHeight)); 1.1094 + } else { 1.1095 + *aWidth = NS_MILLIMETERS_TO_TWIPS(float(mPaperWidth)); 1.1096 + *aHeight = NS_MILLIMETERS_TO_TWIPS(float(mPaperHeight)); 1.1097 + } 1.1098 + if (kLandscapeOrientation == mOrientation) { 1.1099 + double temp = *aWidth; 1.1100 + *aWidth = *aHeight; 1.1101 + *aHeight = temp; 1.1102 + } 1.1103 + return NS_OK; 1.1104 +} 1.1105 + 1.1106 +NS_IMETHODIMP 1.1107 +nsPrintSettings::GetPageRanges(nsTArray<int32_t> &aPages) 1.1108 +{ 1.1109 + aPages.Clear(); 1.1110 + return NS_OK; 1.1111 +} 1.1112 + 1.1113 +nsresult 1.1114 +nsPrintSettings::_Clone(nsIPrintSettings **_retval) 1.1115 +{ 1.1116 + nsPrintSettings* printSettings = new nsPrintSettings(*this); 1.1117 + return printSettings->QueryInterface(NS_GET_IID(nsIPrintSettings), (void**)_retval); // ref counts 1.1118 +} 1.1119 + 1.1120 +/* nsIPrintSettings clone (); */ 1.1121 +NS_IMETHODIMP 1.1122 +nsPrintSettings::Clone(nsIPrintSettings **_retval) 1.1123 +{ 1.1124 + NS_ENSURE_ARG_POINTER(_retval); 1.1125 + return _Clone(_retval); 1.1126 +} 1.1127 + 1.1128 +/* void assign (in nsIPrintSettings aPS); */ 1.1129 +nsresult 1.1130 +nsPrintSettings::_Assign(nsIPrintSettings *aPS) 1.1131 +{ 1.1132 + nsPrintSettings *ps = static_cast<nsPrintSettings*>(aPS); 1.1133 + *this = *ps; 1.1134 + return NS_OK; 1.1135 +} 1.1136 + 1.1137 +/* void assign (in nsIPrintSettings aPS); */ 1.1138 +NS_IMETHODIMP 1.1139 +nsPrintSettings::Assign(nsIPrintSettings *aPS) 1.1140 +{ 1.1141 + NS_ENSURE_ARG(aPS); 1.1142 + return _Assign(aPS); 1.1143 +} 1.1144 + 1.1145 +//------------------------------------------- 1.1146 +nsPrintSettings& nsPrintSettings::operator=(const nsPrintSettings& rhs) 1.1147 +{ 1.1148 + if (this == &rhs) { 1.1149 + return *this; 1.1150 + } 1.1151 + 1.1152 + mStartPageNum = rhs.mStartPageNum; 1.1153 + mEndPageNum = rhs.mEndPageNum; 1.1154 + mMargin = rhs.mMargin; 1.1155 + mEdge = rhs.mEdge; 1.1156 + mUnwriteableMargin = rhs.mUnwriteableMargin; 1.1157 + mScaling = rhs.mScaling; 1.1158 + mPrintBGColors = rhs.mPrintBGColors; 1.1159 + mPrintBGImages = rhs.mPrintBGImages; 1.1160 + mPrintRange = rhs.mPrintRange; 1.1161 + mTitle = rhs.mTitle; 1.1162 + mURL = rhs.mURL; 1.1163 + mHowToEnableFrameUI = rhs.mHowToEnableFrameUI; 1.1164 + mIsCancelled = rhs.mIsCancelled; 1.1165 + mPrintFrameTypeUsage = rhs.mPrintFrameTypeUsage; 1.1166 + mPrintFrameType = rhs.mPrintFrameType; 1.1167 + mPrintSilent = rhs.mPrintSilent; 1.1168 + mShrinkToFit = rhs.mShrinkToFit; 1.1169 + mShowPrintProgress = rhs.mShowPrintProgress; 1.1170 + mPaperName = rhs.mPaperName; 1.1171 + mPlexName = rhs.mPlexName; 1.1172 + mPaperSizeType = rhs.mPaperSizeType; 1.1173 + mPaperData = rhs.mPaperData; 1.1174 + mPaperWidth = rhs.mPaperWidth; 1.1175 + mPaperHeight = rhs.mPaperHeight; 1.1176 + mPaperSizeUnit = rhs.mPaperSizeUnit; 1.1177 + mPrintReversed = rhs.mPrintReversed; 1.1178 + mPrintInColor = rhs.mPrintInColor; 1.1179 + mOrientation = rhs.mOrientation; 1.1180 + mPrintCommand = rhs.mPrintCommand; 1.1181 + mNumCopies = rhs.mNumCopies; 1.1182 + mPrinter = rhs.mPrinter; 1.1183 + mPrintToFile = rhs.mPrintToFile; 1.1184 + mToFileName = rhs.mToFileName; 1.1185 + mOutputFormat = rhs.mOutputFormat; 1.1186 + mPrintPageDelay = rhs.mPrintPageDelay; 1.1187 + 1.1188 + for (int32_t i=0;i<NUM_HEAD_FOOT;i++) { 1.1189 + mHeaderStrs[i] = rhs.mHeaderStrs[i]; 1.1190 + mFooterStrs[i] = rhs.mFooterStrs[i]; 1.1191 + } 1.1192 + 1.1193 + return *this; 1.1194 +} 1.1195 +