widget/xpwidgets/nsPrintSettingsImpl.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "nsPrintSettingsImpl.h"
michael@0 7 #include "nsReadableUtils.h"
michael@0 8 #include "nsIPrintSession.h"
michael@0 9
michael@0 10 #define DEFAULT_MARGIN_WIDTH 0.5
michael@0 11
michael@0 12 NS_IMPL_ISUPPORTS(nsPrintSettings, nsIPrintSettings)
michael@0 13
michael@0 14 /** ---------------------------------------------------
michael@0 15 * See documentation in nsPrintSettingsImpl.h
michael@0 16 * @update 6/21/00 dwc
michael@0 17 */
michael@0 18 nsPrintSettings::nsPrintSettings() :
michael@0 19 mPrintOptions(0L),
michael@0 20 mPrintRange(kRangeAllPages),
michael@0 21 mStartPageNum(1),
michael@0 22 mEndPageNum(1),
michael@0 23 mScaling(1.0),
michael@0 24 mPrintBGColors(false),
michael@0 25 mPrintBGImages(false),
michael@0 26 mPrintFrameTypeUsage(kUseInternalDefault),
michael@0 27 mPrintFrameType(kFramesAsIs),
michael@0 28 mHowToEnableFrameUI(kFrameEnableNone),
michael@0 29 mIsCancelled(false),
michael@0 30 mPrintSilent(false),
michael@0 31 mPrintPreview(false),
michael@0 32 mShrinkToFit(true),
michael@0 33 mShowPrintProgress(true),
michael@0 34 mPrintPageDelay(50),
michael@0 35 mPaperData(0),
michael@0 36 mPaperSizeType(kPaperSizeDefined),
michael@0 37 mPaperWidth(8.5),
michael@0 38 mPaperHeight(11.0),
michael@0 39 mPaperSizeUnit(kPaperSizeInches),
michael@0 40 mPrintReversed(false),
michael@0 41 mPrintInColor(true),
michael@0 42 mOrientation(kPortraitOrientation),
michael@0 43 mDownloadFonts(false),
michael@0 44 mNumCopies(1),
michael@0 45 mPrintToFile(false),
michael@0 46 mOutputFormat(kOutputFormatNative),
michael@0 47 mIsInitedFromPrinter(false),
michael@0 48 mIsInitedFromPrefs(false),
michael@0 49 mPersistMarginBoxSettings(true)
michael@0 50 {
michael@0 51
michael@0 52 /* member initializers and constructor code */
michael@0 53 int32_t marginWidth = NS_INCHES_TO_INT_TWIPS(DEFAULT_MARGIN_WIDTH);
michael@0 54 mMargin.SizeTo(marginWidth, marginWidth, marginWidth, marginWidth);
michael@0 55 mEdge.SizeTo(0, 0, 0, 0);
michael@0 56 mUnwriteableMargin.SizeTo(0,0,0,0);
michael@0 57
michael@0 58 mPrintOptions = kPrintOddPages | kPrintEvenPages;
michael@0 59
michael@0 60 mHeaderStrs[0].AssignLiteral("&T");
michael@0 61 mHeaderStrs[2].AssignLiteral("&U");
michael@0 62
michael@0 63 mFooterStrs[0].AssignLiteral("&PT"); // Use &P (Page Num Only) or &PT (Page Num of Page Total)
michael@0 64 mFooterStrs[2].AssignLiteral("&D");
michael@0 65
michael@0 66 }
michael@0 67
michael@0 68 /** ---------------------------------------------------
michael@0 69 * See documentation in nsPrintSettingsImpl.h
michael@0 70 * @update 6/21/00 dwc
michael@0 71 */
michael@0 72 nsPrintSettings::nsPrintSettings(const nsPrintSettings& aPS)
michael@0 73 {
michael@0 74 *this = aPS;
michael@0 75 }
michael@0 76
michael@0 77 /** ---------------------------------------------------
michael@0 78 * See documentation in nsPrintSettingsImpl.h
michael@0 79 * @update 6/21/00 dwc
michael@0 80 */
michael@0 81 nsPrintSettings::~nsPrintSettings()
michael@0 82 {
michael@0 83 }
michael@0 84
michael@0 85 /* [noscript] attribute nsIPrintSession printSession; */
michael@0 86 NS_IMETHODIMP nsPrintSettings::GetPrintSession(nsIPrintSession **aPrintSession)
michael@0 87 {
michael@0 88 NS_ENSURE_ARG_POINTER(aPrintSession);
michael@0 89 *aPrintSession = nullptr;
michael@0 90
michael@0 91 nsCOMPtr<nsIPrintSession> session = do_QueryReferent(mSession);
michael@0 92 if (!session)
michael@0 93 return NS_ERROR_NOT_INITIALIZED;
michael@0 94 *aPrintSession = session;
michael@0 95 NS_ADDREF(*aPrintSession);
michael@0 96 return NS_OK;
michael@0 97 }
michael@0 98 NS_IMETHODIMP nsPrintSettings::SetPrintSession(nsIPrintSession *aPrintSession)
michael@0 99 {
michael@0 100 // Clearing it by passing nullptr is not allowed. That's why we
michael@0 101 // use a weak ref so that it doesn't have to be cleared.
michael@0 102 NS_ENSURE_ARG(aPrintSession);
michael@0 103
michael@0 104 mSession = do_GetWeakReference(aPrintSession);
michael@0 105 if (!mSession) {
michael@0 106 // This may happen if the implementation of this object does
michael@0 107 // not support weak references - programmer error.
michael@0 108 NS_ERROR("Could not get a weak reference from aPrintSession");
michael@0 109 return NS_ERROR_FAILURE;
michael@0 110 }
michael@0 111 return NS_OK;
michael@0 112 }
michael@0 113
michael@0 114 /* attribute long startPageRange; */
michael@0 115 NS_IMETHODIMP nsPrintSettings::GetStartPageRange(int32_t *aStartPageRange)
michael@0 116 {
michael@0 117 //NS_ENSURE_ARG_POINTER(aStartPageRange);
michael@0 118 *aStartPageRange = mStartPageNum;
michael@0 119 return NS_OK;
michael@0 120 }
michael@0 121 NS_IMETHODIMP nsPrintSettings::SetStartPageRange(int32_t aStartPageRange)
michael@0 122 {
michael@0 123 mStartPageNum = aStartPageRange;
michael@0 124 return NS_OK;
michael@0 125 }
michael@0 126
michael@0 127 /* attribute long endPageRange; */
michael@0 128 NS_IMETHODIMP nsPrintSettings::GetEndPageRange(int32_t *aEndPageRange)
michael@0 129 {
michael@0 130 //NS_ENSURE_ARG_POINTER(aEndPageRange);
michael@0 131 *aEndPageRange = mEndPageNum;
michael@0 132 return NS_OK;
michael@0 133 }
michael@0 134 NS_IMETHODIMP nsPrintSettings::SetEndPageRange(int32_t aEndPageRange)
michael@0 135 {
michael@0 136 mEndPageNum = aEndPageRange;
michael@0 137 return NS_OK;
michael@0 138 }
michael@0 139
michael@0 140 /* attribute boolean printReversed; */
michael@0 141 NS_IMETHODIMP nsPrintSettings::GetPrintReversed(bool *aPrintReversed)
michael@0 142 {
michael@0 143 //NS_ENSURE_ARG_POINTER(aPrintReversed);
michael@0 144 *aPrintReversed = mPrintReversed;
michael@0 145 return NS_OK;
michael@0 146 }
michael@0 147 NS_IMETHODIMP nsPrintSettings::SetPrintReversed(bool aPrintReversed)
michael@0 148 {
michael@0 149 mPrintReversed = aPrintReversed;
michael@0 150 return NS_OK;
michael@0 151 }
michael@0 152
michael@0 153 /* attribute boolean printInColor; */
michael@0 154 NS_IMETHODIMP nsPrintSettings::GetPrintInColor(bool *aPrintInColor)
michael@0 155 {
michael@0 156 //NS_ENSURE_ARG_POINTER(aPrintInColor);
michael@0 157 *aPrintInColor = mPrintInColor;
michael@0 158 return NS_OK;
michael@0 159 }
michael@0 160 NS_IMETHODIMP nsPrintSettings::SetPrintInColor(bool aPrintInColor)
michael@0 161 {
michael@0 162 mPrintInColor = aPrintInColor;
michael@0 163 return NS_OK;
michael@0 164 }
michael@0 165
michael@0 166 /* attribute short orientation; */
michael@0 167 NS_IMETHODIMP nsPrintSettings::GetOrientation(int32_t *aOrientation)
michael@0 168 {
michael@0 169 NS_ENSURE_ARG_POINTER(aOrientation);
michael@0 170 *aOrientation = mOrientation;
michael@0 171 return NS_OK;
michael@0 172 }
michael@0 173 NS_IMETHODIMP nsPrintSettings::SetOrientation(int32_t aOrientation)
michael@0 174 {
michael@0 175 mOrientation = aOrientation;
michael@0 176 return NS_OK;
michael@0 177 }
michael@0 178
michael@0 179 /* attribute wstring colorspace; */
michael@0 180 NS_IMETHODIMP nsPrintSettings::GetColorspace(char16_t * *aColorspace)
michael@0 181 {
michael@0 182 NS_ENSURE_ARG_POINTER(aColorspace);
michael@0 183 if (!mColorspace.IsEmpty()) {
michael@0 184 *aColorspace = ToNewUnicode(mColorspace);
michael@0 185 } else {
michael@0 186 *aColorspace = nullptr;
michael@0 187 }
michael@0 188 return NS_OK;
michael@0 189 }
michael@0 190 NS_IMETHODIMP nsPrintSettings::SetColorspace(const char16_t * aColorspace)
michael@0 191 {
michael@0 192 if (aColorspace) {
michael@0 193 mColorspace = aColorspace;
michael@0 194 } else {
michael@0 195 mColorspace.SetLength(0);
michael@0 196 }
michael@0 197 return NS_OK;
michael@0 198 }
michael@0 199
michael@0 200 /* attribute wstring resolutionname; */
michael@0 201 NS_IMETHODIMP nsPrintSettings::GetResolutionName(char16_t * *aResolutionName)
michael@0 202 {
michael@0 203 NS_ENSURE_ARG_POINTER(aResolutionName);
michael@0 204 if (!mResolutionName.IsEmpty()) {
michael@0 205 *aResolutionName = ToNewUnicode(mResolutionName);
michael@0 206 } else {
michael@0 207 *aResolutionName = nullptr;
michael@0 208 }
michael@0 209 return NS_OK;
michael@0 210 }
michael@0 211 NS_IMETHODIMP nsPrintSettings::SetResolutionName(const char16_t * aResolutionName)
michael@0 212 {
michael@0 213 if (aResolutionName) {
michael@0 214 mResolutionName = aResolutionName;
michael@0 215 } else {
michael@0 216 mResolutionName.SetLength(0);
michael@0 217 }
michael@0 218 return NS_OK;
michael@0 219 }
michael@0 220
michael@0 221 /* attribute wstring resolution; */
michael@0 222 NS_IMETHODIMP nsPrintSettings::GetResolution(int32_t *aResolution)
michael@0 223 {
michael@0 224 NS_ENSURE_ARG_POINTER(aResolution);
michael@0 225 *aResolution = mResolution;
michael@0 226 return NS_OK;
michael@0 227 }
michael@0 228 NS_IMETHODIMP nsPrintSettings::SetResolution(const int32_t aResolution)
michael@0 229 {
michael@0 230 mResolution = aResolution;
michael@0 231 return NS_OK;
michael@0 232 }
michael@0 233
michael@0 234 /* attribute wstring duplex; */
michael@0 235 NS_IMETHODIMP nsPrintSettings::GetDuplex(int32_t *aDuplex)
michael@0 236 {
michael@0 237 NS_ENSURE_ARG_POINTER(aDuplex);
michael@0 238 *aDuplex = mDuplex;
michael@0 239 return NS_OK;
michael@0 240 }
michael@0 241 NS_IMETHODIMP nsPrintSettings::SetDuplex(const int32_t aDuplex)
michael@0 242 {
michael@0 243 mDuplex = aDuplex;
michael@0 244 return NS_OK;
michael@0 245 }
michael@0 246
michael@0 247 /* attribute boolean downloadFonts; */
michael@0 248 NS_IMETHODIMP nsPrintSettings::GetDownloadFonts(bool *aDownloadFonts)
michael@0 249 {
michael@0 250 //NS_ENSURE_ARG_POINTER(aDownloadFonts);
michael@0 251 *aDownloadFonts = mDownloadFonts;
michael@0 252 return NS_OK;
michael@0 253 }
michael@0 254 NS_IMETHODIMP nsPrintSettings::SetDownloadFonts(bool aDownloadFonts)
michael@0 255 {
michael@0 256 mDownloadFonts = aDownloadFonts;
michael@0 257 return NS_OK;
michael@0 258 }
michael@0 259
michael@0 260 /* attribute wstring printer; */
michael@0 261 NS_IMETHODIMP nsPrintSettings::GetPrinterName(char16_t * *aPrinter)
michael@0 262 {
michael@0 263 NS_ENSURE_ARG_POINTER(aPrinter);
michael@0 264
michael@0 265 *aPrinter = ToNewUnicode(mPrinter);
michael@0 266 NS_ENSURE_TRUE(*aPrinter, NS_ERROR_OUT_OF_MEMORY);
michael@0 267
michael@0 268 return NS_OK;
michael@0 269 }
michael@0 270
michael@0 271 NS_IMETHODIMP nsPrintSettings::SetPrinterName(const char16_t * aPrinter)
michael@0 272 {
michael@0 273 if (!aPrinter || !mPrinter.Equals(aPrinter)) {
michael@0 274 mIsInitedFromPrinter = false;
michael@0 275 mIsInitedFromPrefs = false;
michael@0 276 }
michael@0 277
michael@0 278 mPrinter.Assign(aPrinter);
michael@0 279 return NS_OK;
michael@0 280 }
michael@0 281
michael@0 282 /* attribute long numCopies; */
michael@0 283 NS_IMETHODIMP nsPrintSettings::GetNumCopies(int32_t *aNumCopies)
michael@0 284 {
michael@0 285 NS_ENSURE_ARG_POINTER(aNumCopies);
michael@0 286 *aNumCopies = mNumCopies;
michael@0 287 return NS_OK;
michael@0 288 }
michael@0 289 NS_IMETHODIMP nsPrintSettings::SetNumCopies(int32_t aNumCopies)
michael@0 290 {
michael@0 291 mNumCopies = aNumCopies;
michael@0 292 return NS_OK;
michael@0 293 }
michael@0 294
michael@0 295 /* attribute wstring printCommand; */
michael@0 296 NS_IMETHODIMP nsPrintSettings::GetPrintCommand(char16_t * *aPrintCommand)
michael@0 297 {
michael@0 298 //NS_ENSURE_ARG_POINTER(aPrintCommand);
michael@0 299 *aPrintCommand = ToNewUnicode(mPrintCommand);
michael@0 300 return NS_OK;
michael@0 301 }
michael@0 302 NS_IMETHODIMP nsPrintSettings::SetPrintCommand(const char16_t * aPrintCommand)
michael@0 303 {
michael@0 304 if (aPrintCommand) {
michael@0 305 mPrintCommand = aPrintCommand;
michael@0 306 } else {
michael@0 307 mPrintCommand.SetLength(0);
michael@0 308 }
michael@0 309 return NS_OK;
michael@0 310 }
michael@0 311
michael@0 312 /* attribute boolean printToFile; */
michael@0 313 NS_IMETHODIMP nsPrintSettings::GetPrintToFile(bool *aPrintToFile)
michael@0 314 {
michael@0 315 //NS_ENSURE_ARG_POINTER(aPrintToFile);
michael@0 316 *aPrintToFile = mPrintToFile;
michael@0 317 return NS_OK;
michael@0 318 }
michael@0 319 NS_IMETHODIMP nsPrintSettings::SetPrintToFile(bool aPrintToFile)
michael@0 320 {
michael@0 321 mPrintToFile = aPrintToFile;
michael@0 322 return NS_OK;
michael@0 323 }
michael@0 324
michael@0 325 /* attribute wstring toFileName; */
michael@0 326 NS_IMETHODIMP nsPrintSettings::GetToFileName(char16_t * *aToFileName)
michael@0 327 {
michael@0 328 //NS_ENSURE_ARG_POINTER(aToFileName);
michael@0 329 *aToFileName = ToNewUnicode(mToFileName);
michael@0 330 return NS_OK;
michael@0 331 }
michael@0 332 NS_IMETHODIMP nsPrintSettings::SetToFileName(const char16_t * aToFileName)
michael@0 333 {
michael@0 334 if (aToFileName) {
michael@0 335 mToFileName = aToFileName;
michael@0 336 } else {
michael@0 337 mToFileName.SetLength(0);
michael@0 338 }
michael@0 339 return NS_OK;
michael@0 340 }
michael@0 341
michael@0 342 /* attribute short outputFormat; */
michael@0 343 NS_IMETHODIMP nsPrintSettings::GetOutputFormat(int16_t *aOutputFormat)
michael@0 344 {
michael@0 345 NS_ENSURE_ARG_POINTER(aOutputFormat);
michael@0 346 *aOutputFormat = mOutputFormat;
michael@0 347 return NS_OK;
michael@0 348 }
michael@0 349 NS_IMETHODIMP nsPrintSettings::SetOutputFormat(int16_t aOutputFormat)
michael@0 350 {
michael@0 351 mOutputFormat = aOutputFormat;
michael@0 352 return NS_OK;
michael@0 353 }
michael@0 354
michael@0 355 /* attribute long printPageDelay; */
michael@0 356 NS_IMETHODIMP nsPrintSettings::GetPrintPageDelay(int32_t *aPrintPageDelay)
michael@0 357 {
michael@0 358 *aPrintPageDelay = mPrintPageDelay;
michael@0 359 return NS_OK;
michael@0 360 }
michael@0 361 NS_IMETHODIMP nsPrintSettings::SetPrintPageDelay(int32_t aPrintPageDelay)
michael@0 362 {
michael@0 363 mPrintPageDelay = aPrintPageDelay;
michael@0 364 return NS_OK;
michael@0 365 }
michael@0 366
michael@0 367 /* attribute boolean isInitializedFromPrinter; */
michael@0 368 NS_IMETHODIMP nsPrintSettings::GetIsInitializedFromPrinter(bool *aIsInitializedFromPrinter)
michael@0 369 {
michael@0 370 NS_ENSURE_ARG_POINTER(aIsInitializedFromPrinter);
michael@0 371 *aIsInitializedFromPrinter = (bool)mIsInitedFromPrinter;
michael@0 372 return NS_OK;
michael@0 373 }
michael@0 374 NS_IMETHODIMP nsPrintSettings::SetIsInitializedFromPrinter(bool aIsInitializedFromPrinter)
michael@0 375 {
michael@0 376 mIsInitedFromPrinter = (bool)aIsInitializedFromPrinter;
michael@0 377 return NS_OK;
michael@0 378 }
michael@0 379
michael@0 380 /* attribute boolean isInitializedFromPrefs; */
michael@0 381 NS_IMETHODIMP nsPrintSettings::GetIsInitializedFromPrefs(bool *aInitializedFromPrefs)
michael@0 382 {
michael@0 383 NS_ENSURE_ARG_POINTER(aInitializedFromPrefs);
michael@0 384 *aInitializedFromPrefs = (bool)mIsInitedFromPrefs;
michael@0 385 return NS_OK;
michael@0 386 }
michael@0 387 NS_IMETHODIMP nsPrintSettings::SetIsInitializedFromPrefs(bool aInitializedFromPrefs)
michael@0 388 {
michael@0 389 mIsInitedFromPrefs = (bool)aInitializedFromPrefs;
michael@0 390 return NS_OK;
michael@0 391 }
michael@0 392
michael@0 393 /* attribute boolean persistMarginBoxSettings; */
michael@0 394 NS_IMETHODIMP nsPrintSettings::GetPersistMarginBoxSettings(bool *aPersistMarginBoxSettings)
michael@0 395 {
michael@0 396 NS_ENSURE_ARG_POINTER(aPersistMarginBoxSettings);
michael@0 397 *aPersistMarginBoxSettings = mPersistMarginBoxSettings;
michael@0 398 return NS_OK;
michael@0 399 }
michael@0 400 NS_IMETHODIMP nsPrintSettings::SetPersistMarginBoxSettings(bool aPersistMarginBoxSettings)
michael@0 401 {
michael@0 402 mPersistMarginBoxSettings = aPersistMarginBoxSettings;
michael@0 403 return NS_OK;
michael@0 404 }
michael@0 405
michael@0 406 /* attribute double marginTop; */
michael@0 407 NS_IMETHODIMP nsPrintSettings::GetMarginTop(double *aMarginTop)
michael@0 408 {
michael@0 409 NS_ENSURE_ARG_POINTER(aMarginTop);
michael@0 410 *aMarginTop = NS_TWIPS_TO_INCHES(mMargin.top);
michael@0 411 return NS_OK;
michael@0 412 }
michael@0 413 NS_IMETHODIMP nsPrintSettings::SetMarginTop(double aMarginTop)
michael@0 414 {
michael@0 415 mMargin.top = NS_INCHES_TO_INT_TWIPS(float(aMarginTop));
michael@0 416 return NS_OK;
michael@0 417 }
michael@0 418
michael@0 419 /* attribute double marginLeft; */
michael@0 420 NS_IMETHODIMP nsPrintSettings::GetMarginLeft(double *aMarginLeft)
michael@0 421 {
michael@0 422 NS_ENSURE_ARG_POINTER(aMarginLeft);
michael@0 423 *aMarginLeft = NS_TWIPS_TO_INCHES(mMargin.left);
michael@0 424 return NS_OK;
michael@0 425 }
michael@0 426 NS_IMETHODIMP nsPrintSettings::SetMarginLeft(double aMarginLeft)
michael@0 427 {
michael@0 428 mMargin.left = NS_INCHES_TO_INT_TWIPS(float(aMarginLeft));
michael@0 429 return NS_OK;
michael@0 430 }
michael@0 431
michael@0 432 /* attribute double marginBottom; */
michael@0 433 NS_IMETHODIMP nsPrintSettings::GetMarginBottom(double *aMarginBottom)
michael@0 434 {
michael@0 435 NS_ENSURE_ARG_POINTER(aMarginBottom);
michael@0 436 *aMarginBottom = NS_TWIPS_TO_INCHES(mMargin.bottom);
michael@0 437 return NS_OK;
michael@0 438 }
michael@0 439 NS_IMETHODIMP nsPrintSettings::SetMarginBottom(double aMarginBottom)
michael@0 440 {
michael@0 441 mMargin.bottom = NS_INCHES_TO_INT_TWIPS(float(aMarginBottom));
michael@0 442 return NS_OK;
michael@0 443 }
michael@0 444
michael@0 445 /* attribute double marginRight; */
michael@0 446 NS_IMETHODIMP nsPrintSettings::GetMarginRight(double *aMarginRight)
michael@0 447 {
michael@0 448 NS_ENSURE_ARG_POINTER(aMarginRight);
michael@0 449 *aMarginRight = NS_TWIPS_TO_INCHES(mMargin.right);
michael@0 450 return NS_OK;
michael@0 451 }
michael@0 452 NS_IMETHODIMP nsPrintSettings::SetMarginRight(double aMarginRight)
michael@0 453 {
michael@0 454 mMargin.right = NS_INCHES_TO_INT_TWIPS(float(aMarginRight));
michael@0 455 return NS_OK;
michael@0 456 }
michael@0 457
michael@0 458 /* attribute double edgeTop; */
michael@0 459 NS_IMETHODIMP nsPrintSettings::GetEdgeTop(double *aEdgeTop)
michael@0 460 {
michael@0 461 NS_ENSURE_ARG_POINTER(aEdgeTop);
michael@0 462 *aEdgeTop = NS_TWIPS_TO_INCHES(mEdge.top);
michael@0 463 return NS_OK;
michael@0 464 }
michael@0 465 NS_IMETHODIMP nsPrintSettings::SetEdgeTop(double aEdgeTop)
michael@0 466 {
michael@0 467 mEdge.top = NS_INCHES_TO_INT_TWIPS(float(aEdgeTop));
michael@0 468 return NS_OK;
michael@0 469 }
michael@0 470
michael@0 471 /* attribute double edgeLeft; */
michael@0 472 NS_IMETHODIMP nsPrintSettings::GetEdgeLeft(double *aEdgeLeft)
michael@0 473 {
michael@0 474 NS_ENSURE_ARG_POINTER(aEdgeLeft);
michael@0 475 *aEdgeLeft = NS_TWIPS_TO_INCHES(mEdge.left);
michael@0 476 return NS_OK;
michael@0 477 }
michael@0 478 NS_IMETHODIMP nsPrintSettings::SetEdgeLeft(double aEdgeLeft)
michael@0 479 {
michael@0 480 mEdge.left = NS_INCHES_TO_INT_TWIPS(float(aEdgeLeft));
michael@0 481 return NS_OK;
michael@0 482 }
michael@0 483
michael@0 484 /* attribute double edgeBottom; */
michael@0 485 NS_IMETHODIMP nsPrintSettings::GetEdgeBottom(double *aEdgeBottom)
michael@0 486 {
michael@0 487 NS_ENSURE_ARG_POINTER(aEdgeBottom);
michael@0 488 *aEdgeBottom = NS_TWIPS_TO_INCHES(mEdge.bottom);
michael@0 489 return NS_OK;
michael@0 490 }
michael@0 491 NS_IMETHODIMP nsPrintSettings::SetEdgeBottom(double aEdgeBottom)
michael@0 492 {
michael@0 493 mEdge.bottom = NS_INCHES_TO_INT_TWIPS(float(aEdgeBottom));
michael@0 494 return NS_OK;
michael@0 495 }
michael@0 496
michael@0 497 /* attribute double edgeRight; */
michael@0 498 NS_IMETHODIMP nsPrintSettings::GetEdgeRight(double *aEdgeRight)
michael@0 499 {
michael@0 500 NS_ENSURE_ARG_POINTER(aEdgeRight);
michael@0 501 *aEdgeRight = NS_TWIPS_TO_INCHES(mEdge.right);
michael@0 502 return NS_OK;
michael@0 503 }
michael@0 504 NS_IMETHODIMP nsPrintSettings::SetEdgeRight(double aEdgeRight)
michael@0 505 {
michael@0 506 mEdge.right = NS_INCHES_TO_INT_TWIPS(float(aEdgeRight));
michael@0 507 return NS_OK;
michael@0 508 }
michael@0 509
michael@0 510 /* attribute double unwriteableMarginTop; */
michael@0 511 NS_IMETHODIMP nsPrintSettings::GetUnwriteableMarginTop(double *aUnwriteableMarginTop)
michael@0 512 {
michael@0 513 NS_ENSURE_ARG_POINTER(aUnwriteableMarginTop);
michael@0 514 *aUnwriteableMarginTop = NS_TWIPS_TO_INCHES(mUnwriteableMargin.top);
michael@0 515 return NS_OK;
michael@0 516 }
michael@0 517 NS_IMETHODIMP nsPrintSettings::SetUnwriteableMarginTop(double aUnwriteableMarginTop)
michael@0 518 {
michael@0 519 if (aUnwriteableMarginTop >= 0.0) {
michael@0 520 mUnwriteableMargin.top = NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginTop);
michael@0 521 }
michael@0 522 return NS_OK;
michael@0 523 }
michael@0 524
michael@0 525 /* attribute double unwriteableMarginLeft; */
michael@0 526 NS_IMETHODIMP nsPrintSettings::GetUnwriteableMarginLeft(double *aUnwriteableMarginLeft)
michael@0 527 {
michael@0 528 NS_ENSURE_ARG_POINTER(aUnwriteableMarginLeft);
michael@0 529 *aUnwriteableMarginLeft = NS_TWIPS_TO_INCHES(mUnwriteableMargin.left);
michael@0 530 return NS_OK;
michael@0 531 }
michael@0 532 NS_IMETHODIMP nsPrintSettings::SetUnwriteableMarginLeft(double aUnwriteableMarginLeft)
michael@0 533 {
michael@0 534 if (aUnwriteableMarginLeft >= 0.0) {
michael@0 535 mUnwriteableMargin.left = NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginLeft);
michael@0 536 }
michael@0 537 return NS_OK;
michael@0 538 }
michael@0 539
michael@0 540 /* attribute double unwriteableMarginBottom; */
michael@0 541 NS_IMETHODIMP nsPrintSettings::GetUnwriteableMarginBottom(double *aUnwriteableMarginBottom)
michael@0 542 {
michael@0 543 NS_ENSURE_ARG_POINTER(aUnwriteableMarginBottom);
michael@0 544 *aUnwriteableMarginBottom = NS_TWIPS_TO_INCHES(mUnwriteableMargin.bottom);
michael@0 545 return NS_OK;
michael@0 546 }
michael@0 547 NS_IMETHODIMP nsPrintSettings::SetUnwriteableMarginBottom(double aUnwriteableMarginBottom)
michael@0 548 {
michael@0 549 if (aUnwriteableMarginBottom >= 0.0) {
michael@0 550 mUnwriteableMargin.bottom = NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginBottom);
michael@0 551 }
michael@0 552 return NS_OK;
michael@0 553 }
michael@0 554
michael@0 555 /* attribute double unwriteableMarginRight; */
michael@0 556 NS_IMETHODIMP nsPrintSettings::GetUnwriteableMarginRight(double *aUnwriteableMarginRight)
michael@0 557 {
michael@0 558 NS_ENSURE_ARG_POINTER(aUnwriteableMarginRight);
michael@0 559 *aUnwriteableMarginRight = NS_TWIPS_TO_INCHES(mUnwriteableMargin.right);
michael@0 560 return NS_OK;
michael@0 561 }
michael@0 562 NS_IMETHODIMP nsPrintSettings::SetUnwriteableMarginRight(double aUnwriteableMarginRight)
michael@0 563 {
michael@0 564 if (aUnwriteableMarginRight >= 0.0) {
michael@0 565 mUnwriteableMargin.right = NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginRight);
michael@0 566 }
michael@0 567 return NS_OK;
michael@0 568 }
michael@0 569
michael@0 570 /* attribute double scaling; */
michael@0 571 NS_IMETHODIMP nsPrintSettings::GetScaling(double *aScaling)
michael@0 572 {
michael@0 573 NS_ENSURE_ARG_POINTER(aScaling);
michael@0 574 *aScaling = mScaling;
michael@0 575 return NS_OK;
michael@0 576 }
michael@0 577
michael@0 578 NS_IMETHODIMP nsPrintSettings::SetScaling(double aScaling)
michael@0 579 {
michael@0 580 mScaling = aScaling;
michael@0 581 return NS_OK;
michael@0 582 }
michael@0 583
michael@0 584 /* attribute boolean printBGColors; */
michael@0 585 NS_IMETHODIMP nsPrintSettings::GetPrintBGColors(bool *aPrintBGColors)
michael@0 586 {
michael@0 587 NS_ENSURE_ARG_POINTER(aPrintBGColors);
michael@0 588 *aPrintBGColors = mPrintBGColors;
michael@0 589 return NS_OK;
michael@0 590 }
michael@0 591 NS_IMETHODIMP nsPrintSettings::SetPrintBGColors(bool aPrintBGColors)
michael@0 592 {
michael@0 593 mPrintBGColors = aPrintBGColors;
michael@0 594 return NS_OK;
michael@0 595 }
michael@0 596
michael@0 597 /* attribute boolean printBGImages; */
michael@0 598 NS_IMETHODIMP nsPrintSettings::GetPrintBGImages(bool *aPrintBGImages)
michael@0 599 {
michael@0 600 NS_ENSURE_ARG_POINTER(aPrintBGImages);
michael@0 601 *aPrintBGImages = mPrintBGImages;
michael@0 602 return NS_OK;
michael@0 603 }
michael@0 604 NS_IMETHODIMP nsPrintSettings::SetPrintBGImages(bool aPrintBGImages)
michael@0 605 {
michael@0 606 mPrintBGImages = aPrintBGImages;
michael@0 607 return NS_OK;
michael@0 608 }
michael@0 609
michael@0 610 /* attribute long printRange; */
michael@0 611 NS_IMETHODIMP nsPrintSettings::GetPrintRange(int16_t *aPrintRange)
michael@0 612 {
michael@0 613 NS_ENSURE_ARG_POINTER(aPrintRange);
michael@0 614 *aPrintRange = mPrintRange;
michael@0 615 return NS_OK;
michael@0 616 }
michael@0 617 NS_IMETHODIMP nsPrintSettings::SetPrintRange(int16_t aPrintRange)
michael@0 618 {
michael@0 619 mPrintRange = aPrintRange;
michael@0 620 return NS_OK;
michael@0 621 }
michael@0 622
michael@0 623 /* attribute wstring docTitle; */
michael@0 624 NS_IMETHODIMP nsPrintSettings::GetTitle(char16_t * *aTitle)
michael@0 625 {
michael@0 626 NS_ENSURE_ARG_POINTER(aTitle);
michael@0 627 if (!mTitle.IsEmpty()) {
michael@0 628 *aTitle = ToNewUnicode(mTitle);
michael@0 629 } else {
michael@0 630 *aTitle = nullptr;
michael@0 631 }
michael@0 632 return NS_OK;
michael@0 633 }
michael@0 634 NS_IMETHODIMP nsPrintSettings::SetTitle(const char16_t * aTitle)
michael@0 635 {
michael@0 636 if (aTitle) {
michael@0 637 mTitle = aTitle;
michael@0 638 } else {
michael@0 639 mTitle.SetLength(0);
michael@0 640 }
michael@0 641 return NS_OK;
michael@0 642 }
michael@0 643
michael@0 644 /* attribute wstring docURL; */
michael@0 645 NS_IMETHODIMP nsPrintSettings::GetDocURL(char16_t * *aDocURL)
michael@0 646 {
michael@0 647 NS_ENSURE_ARG_POINTER(aDocURL);
michael@0 648 if (!mURL.IsEmpty()) {
michael@0 649 *aDocURL = ToNewUnicode(mURL);
michael@0 650 } else {
michael@0 651 *aDocURL = nullptr;
michael@0 652 }
michael@0 653 return NS_OK;
michael@0 654 }
michael@0 655 NS_IMETHODIMP nsPrintSettings::SetDocURL(const char16_t * aDocURL)
michael@0 656 {
michael@0 657 if (aDocURL) {
michael@0 658 mURL = aDocURL;
michael@0 659 } else {
michael@0 660 mURL.SetLength(0);
michael@0 661 }
michael@0 662 return NS_OK;
michael@0 663 }
michael@0 664
michael@0 665 /** ---------------------------------------------------
michael@0 666 * See documentation in nsPrintSettingsImpl.h
michael@0 667 * @update 1/12/01 rods
michael@0 668 */
michael@0 669 NS_IMETHODIMP
michael@0 670 nsPrintSettings::GetPrintOptions(int32_t aType, bool *aTurnOnOff)
michael@0 671 {
michael@0 672 NS_ENSURE_ARG_POINTER(aTurnOnOff);
michael@0 673 *aTurnOnOff = mPrintOptions & aType ? true : false;
michael@0 674 return NS_OK;
michael@0 675 }
michael@0 676 /** ---------------------------------------------------
michael@0 677 * See documentation in nsPrintSettingsImpl.h
michael@0 678 * @update 1/12/01 rods
michael@0 679 */
michael@0 680 NS_IMETHODIMP
michael@0 681 nsPrintSettings::SetPrintOptions(int32_t aType, bool aTurnOnOff)
michael@0 682 {
michael@0 683 if (aTurnOnOff) {
michael@0 684 mPrintOptions |= aType;
michael@0 685 } else {
michael@0 686 mPrintOptions &= ~aType;
michael@0 687 }
michael@0 688 return NS_OK;
michael@0 689 }
michael@0 690
michael@0 691 /** ---------------------------------------------------
michael@0 692 * See documentation in nsPrintSettingsImpl.h
michael@0 693 * @update 1/12/01 rods
michael@0 694 */
michael@0 695 NS_IMETHODIMP
michael@0 696 nsPrintSettings::GetPrintOptionsBits(int32_t *aBits)
michael@0 697 {
michael@0 698 NS_ENSURE_ARG_POINTER(aBits);
michael@0 699 *aBits = mPrintOptions;
michael@0 700 return NS_OK;
michael@0 701 }
michael@0 702
michael@0 703 /* attribute wstring docTitle; */
michael@0 704 nsresult
michael@0 705 nsPrintSettings::GetMarginStrs(char16_t * *aTitle,
michael@0 706 nsHeaderFooterEnum aType,
michael@0 707 int16_t aJust)
michael@0 708 {
michael@0 709 NS_ENSURE_ARG_POINTER(aTitle);
michael@0 710 *aTitle = nullptr;
michael@0 711 if (aType == eHeader) {
michael@0 712 switch (aJust) {
michael@0 713 case kJustLeft: *aTitle = ToNewUnicode(mHeaderStrs[0]);break;
michael@0 714 case kJustCenter: *aTitle = ToNewUnicode(mHeaderStrs[1]);break;
michael@0 715 case kJustRight: *aTitle = ToNewUnicode(mHeaderStrs[2]);break;
michael@0 716 } //switch
michael@0 717 } else {
michael@0 718 switch (aJust) {
michael@0 719 case kJustLeft: *aTitle = ToNewUnicode(mFooterStrs[0]);break;
michael@0 720 case kJustCenter: *aTitle = ToNewUnicode(mFooterStrs[1]);break;
michael@0 721 case kJustRight: *aTitle = ToNewUnicode(mFooterStrs[2]);break;
michael@0 722 } //switch
michael@0 723 }
michael@0 724 return NS_OK;
michael@0 725 }
michael@0 726
michael@0 727 nsresult
michael@0 728 nsPrintSettings::SetMarginStrs(const char16_t * aTitle,
michael@0 729 nsHeaderFooterEnum aType,
michael@0 730 int16_t aJust)
michael@0 731 {
michael@0 732 NS_ENSURE_ARG_POINTER(aTitle);
michael@0 733 if (aType == eHeader) {
michael@0 734 switch (aJust) {
michael@0 735 case kJustLeft: mHeaderStrs[0] = aTitle;break;
michael@0 736 case kJustCenter: mHeaderStrs[1] = aTitle;break;
michael@0 737 case kJustRight: mHeaderStrs[2] = aTitle;break;
michael@0 738 } //switch
michael@0 739 } else {
michael@0 740 switch (aJust) {
michael@0 741 case kJustLeft: mFooterStrs[0] = aTitle;break;
michael@0 742 case kJustCenter: mFooterStrs[1] = aTitle;break;
michael@0 743 case kJustRight: mFooterStrs[2] = aTitle;break;
michael@0 744 } //switch
michael@0 745 }
michael@0 746 return NS_OK;
michael@0 747 }
michael@0 748
michael@0 749 /* attribute wstring Header String Left */
michael@0 750 NS_IMETHODIMP nsPrintSettings::GetHeaderStrLeft(char16_t * *aTitle)
michael@0 751 {
michael@0 752 return GetMarginStrs(aTitle, eHeader, kJustLeft);
michael@0 753 }
michael@0 754 NS_IMETHODIMP nsPrintSettings::SetHeaderStrLeft(const char16_t * aTitle)
michael@0 755 {
michael@0 756 return SetMarginStrs(aTitle, eHeader, kJustLeft);
michael@0 757 }
michael@0 758
michael@0 759 /* attribute wstring Header String Center */
michael@0 760 NS_IMETHODIMP nsPrintSettings::GetHeaderStrCenter(char16_t * *aTitle)
michael@0 761 {
michael@0 762 return GetMarginStrs(aTitle, eHeader, kJustCenter);
michael@0 763 }
michael@0 764 NS_IMETHODIMP nsPrintSettings::SetHeaderStrCenter(const char16_t * aTitle)
michael@0 765 {
michael@0 766 return SetMarginStrs(aTitle, eHeader, kJustCenter);
michael@0 767 }
michael@0 768
michael@0 769 /* attribute wstring Header String Right */
michael@0 770 NS_IMETHODIMP nsPrintSettings::GetHeaderStrRight(char16_t * *aTitle)
michael@0 771 {
michael@0 772 return GetMarginStrs(aTitle, eHeader, kJustRight);
michael@0 773 }
michael@0 774 NS_IMETHODIMP nsPrintSettings::SetHeaderStrRight(const char16_t * aTitle)
michael@0 775 {
michael@0 776 return SetMarginStrs(aTitle, eHeader, kJustRight);
michael@0 777 }
michael@0 778
michael@0 779
michael@0 780 /* attribute wstring Footer String Left */
michael@0 781 NS_IMETHODIMP nsPrintSettings::GetFooterStrLeft(char16_t * *aTitle)
michael@0 782 {
michael@0 783 return GetMarginStrs(aTitle, eFooter, kJustLeft);
michael@0 784 }
michael@0 785 NS_IMETHODIMP nsPrintSettings::SetFooterStrLeft(const char16_t * aTitle)
michael@0 786 {
michael@0 787 return SetMarginStrs(aTitle, eFooter, kJustLeft);
michael@0 788 }
michael@0 789
michael@0 790 /* attribute wstring Footer String Center */
michael@0 791 NS_IMETHODIMP nsPrintSettings::GetFooterStrCenter(char16_t * *aTitle)
michael@0 792 {
michael@0 793 return GetMarginStrs(aTitle, eFooter, kJustCenter);
michael@0 794 }
michael@0 795 NS_IMETHODIMP nsPrintSettings::SetFooterStrCenter(const char16_t * aTitle)
michael@0 796 {
michael@0 797 return SetMarginStrs(aTitle, eFooter, kJustCenter);
michael@0 798 }
michael@0 799
michael@0 800 /* attribute wstring Footer String Right */
michael@0 801 NS_IMETHODIMP nsPrintSettings::GetFooterStrRight(char16_t * *aTitle)
michael@0 802 {
michael@0 803 return GetMarginStrs(aTitle, eFooter, kJustRight);
michael@0 804 }
michael@0 805 NS_IMETHODIMP nsPrintSettings::SetFooterStrRight(const char16_t * aTitle)
michael@0 806 {
michael@0 807 return SetMarginStrs(aTitle, eFooter, kJustRight);
michael@0 808 }
michael@0 809
michael@0 810 /* attribute short printFrameTypeUsage; */
michael@0 811 NS_IMETHODIMP nsPrintSettings::GetPrintFrameTypeUsage(int16_t *aPrintFrameTypeUsage)
michael@0 812 {
michael@0 813 NS_ENSURE_ARG_POINTER(aPrintFrameTypeUsage);
michael@0 814 *aPrintFrameTypeUsage = mPrintFrameTypeUsage;
michael@0 815 return NS_OK;
michael@0 816 }
michael@0 817 NS_IMETHODIMP nsPrintSettings::SetPrintFrameTypeUsage(int16_t aPrintFrameTypeUsage)
michael@0 818 {
michael@0 819 mPrintFrameTypeUsage = aPrintFrameTypeUsage;
michael@0 820 return NS_OK;
michael@0 821 }
michael@0 822
michael@0 823 /* attribute long printFrameType; */
michael@0 824 NS_IMETHODIMP nsPrintSettings::GetPrintFrameType(int16_t *aPrintFrameType)
michael@0 825 {
michael@0 826 NS_ENSURE_ARG_POINTER(aPrintFrameType);
michael@0 827 *aPrintFrameType = (int32_t)mPrintFrameType;
michael@0 828 return NS_OK;
michael@0 829 }
michael@0 830 NS_IMETHODIMP nsPrintSettings::SetPrintFrameType(int16_t aPrintFrameType)
michael@0 831 {
michael@0 832 mPrintFrameType = aPrintFrameType;
michael@0 833 return NS_OK;
michael@0 834 }
michael@0 835
michael@0 836 /* attribute boolean printSilent; */
michael@0 837 NS_IMETHODIMP nsPrintSettings::GetPrintSilent(bool *aPrintSilent)
michael@0 838 {
michael@0 839 NS_ENSURE_ARG_POINTER(aPrintSilent);
michael@0 840 *aPrintSilent = mPrintSilent;
michael@0 841 return NS_OK;
michael@0 842 }
michael@0 843 NS_IMETHODIMP nsPrintSettings::SetPrintSilent(bool aPrintSilent)
michael@0 844 {
michael@0 845 mPrintSilent = aPrintSilent;
michael@0 846 return NS_OK;
michael@0 847 }
michael@0 848
michael@0 849 /* attribute boolean shrinkToFit; */
michael@0 850 NS_IMETHODIMP nsPrintSettings::GetShrinkToFit(bool *aShrinkToFit)
michael@0 851 {
michael@0 852 NS_ENSURE_ARG_POINTER(aShrinkToFit);
michael@0 853 *aShrinkToFit = mShrinkToFit;
michael@0 854 return NS_OK;
michael@0 855 }
michael@0 856 NS_IMETHODIMP nsPrintSettings::SetShrinkToFit(bool aShrinkToFit)
michael@0 857 {
michael@0 858 mShrinkToFit = aShrinkToFit;
michael@0 859 return NS_OK;
michael@0 860 }
michael@0 861
michael@0 862 /* attribute boolean showPrintProgress; */
michael@0 863 NS_IMETHODIMP nsPrintSettings::GetShowPrintProgress(bool *aShowPrintProgress)
michael@0 864 {
michael@0 865 NS_ENSURE_ARG_POINTER(aShowPrintProgress);
michael@0 866 *aShowPrintProgress = mShowPrintProgress;
michael@0 867 return NS_OK;
michael@0 868 }
michael@0 869 NS_IMETHODIMP nsPrintSettings::SetShowPrintProgress(bool aShowPrintProgress)
michael@0 870 {
michael@0 871 mShowPrintProgress = aShowPrintProgress;
michael@0 872 return NS_OK;
michael@0 873 }
michael@0 874
michael@0 875 /* attribute wstring paperName; */
michael@0 876 NS_IMETHODIMP nsPrintSettings::GetPaperName(char16_t * *aPaperName)
michael@0 877 {
michael@0 878 NS_ENSURE_ARG_POINTER(aPaperName);
michael@0 879 if (!mPaperName.IsEmpty()) {
michael@0 880 *aPaperName = ToNewUnicode(mPaperName);
michael@0 881 } else {
michael@0 882 *aPaperName = nullptr;
michael@0 883 }
michael@0 884 return NS_OK;
michael@0 885 }
michael@0 886 NS_IMETHODIMP nsPrintSettings::SetPaperName(const char16_t * aPaperName)
michael@0 887 {
michael@0 888 if (aPaperName) {
michael@0 889 mPaperName = aPaperName;
michael@0 890 } else {
michael@0 891 mPaperName.SetLength(0);
michael@0 892 }
michael@0 893 return NS_OK;
michael@0 894 }
michael@0 895
michael@0 896 /* attribute wstring plexName; */
michael@0 897 NS_IMETHODIMP nsPrintSettings::GetPlexName(char16_t * *aPlexName)
michael@0 898 {
michael@0 899 NS_ENSURE_ARG_POINTER(aPlexName);
michael@0 900 if (!mPlexName.IsEmpty()) {
michael@0 901 *aPlexName = ToNewUnicode(mPlexName);
michael@0 902 } else {
michael@0 903 *aPlexName = nullptr;
michael@0 904 }
michael@0 905 return NS_OK;
michael@0 906 }
michael@0 907 NS_IMETHODIMP nsPrintSettings::SetPlexName(const char16_t * aPlexName)
michael@0 908 {
michael@0 909 if (aPlexName) {
michael@0 910 mPlexName = aPlexName;
michael@0 911 } else {
michael@0 912 mPlexName.SetLength(0);
michael@0 913 }
michael@0 914 return NS_OK;
michael@0 915 }
michael@0 916
michael@0 917 /* attribute boolean howToEnableFrameUI; */
michael@0 918 NS_IMETHODIMP nsPrintSettings::GetHowToEnableFrameUI(int16_t *aHowToEnableFrameUI)
michael@0 919 {
michael@0 920 NS_ENSURE_ARG_POINTER(aHowToEnableFrameUI);
michael@0 921 *aHowToEnableFrameUI = mHowToEnableFrameUI;
michael@0 922 return NS_OK;
michael@0 923 }
michael@0 924 NS_IMETHODIMP nsPrintSettings::SetHowToEnableFrameUI(int16_t aHowToEnableFrameUI)
michael@0 925 {
michael@0 926 mHowToEnableFrameUI = aHowToEnableFrameUI;
michael@0 927 return NS_OK;
michael@0 928 }
michael@0 929
michael@0 930 /* attribute long isCancelled; */
michael@0 931 NS_IMETHODIMP nsPrintSettings::GetIsCancelled(bool *aIsCancelled)
michael@0 932 {
michael@0 933 NS_ENSURE_ARG_POINTER(aIsCancelled);
michael@0 934 *aIsCancelled = mIsCancelled;
michael@0 935 return NS_OK;
michael@0 936 }
michael@0 937 NS_IMETHODIMP nsPrintSettings::SetIsCancelled(bool aIsCancelled)
michael@0 938 {
michael@0 939 mIsCancelled = aIsCancelled;
michael@0 940 return NS_OK;
michael@0 941 }
michael@0 942
michael@0 943 /* attribute double paperWidth; */
michael@0 944 NS_IMETHODIMP nsPrintSettings::GetPaperWidth(double *aPaperWidth)
michael@0 945 {
michael@0 946 NS_ENSURE_ARG_POINTER(aPaperWidth);
michael@0 947 *aPaperWidth = mPaperWidth;
michael@0 948 return NS_OK;
michael@0 949 }
michael@0 950 NS_IMETHODIMP nsPrintSettings::SetPaperWidth(double aPaperWidth)
michael@0 951 {
michael@0 952 mPaperWidth = aPaperWidth;
michael@0 953 return NS_OK;
michael@0 954 }
michael@0 955
michael@0 956 /* attribute double paperHeight; */
michael@0 957 NS_IMETHODIMP nsPrintSettings::GetPaperHeight(double *aPaperHeight)
michael@0 958 {
michael@0 959 NS_ENSURE_ARG_POINTER(aPaperHeight);
michael@0 960 *aPaperHeight = mPaperHeight;
michael@0 961 return NS_OK;
michael@0 962 }
michael@0 963 NS_IMETHODIMP nsPrintSettings::SetPaperHeight(double aPaperHeight)
michael@0 964 {
michael@0 965 mPaperHeight = aPaperHeight;
michael@0 966 return NS_OK;
michael@0 967 }
michael@0 968
michael@0 969 /* attribute short PaperSizeUnit; */
michael@0 970 NS_IMETHODIMP nsPrintSettings::GetPaperSizeUnit(int16_t *aPaperSizeUnit)
michael@0 971 {
michael@0 972 NS_ENSURE_ARG_POINTER(aPaperSizeUnit);
michael@0 973 *aPaperSizeUnit = mPaperSizeUnit;
michael@0 974 return NS_OK;
michael@0 975 }
michael@0 976 NS_IMETHODIMP nsPrintSettings::SetPaperSizeUnit(int16_t aPaperSizeUnit)
michael@0 977 {
michael@0 978 mPaperSizeUnit = aPaperSizeUnit;
michael@0 979 return NS_OK;
michael@0 980 }
michael@0 981
michael@0 982 /* attribute short PaperSizeType; */
michael@0 983 NS_IMETHODIMP nsPrintSettings::GetPaperSizeType(int16_t *aPaperSizeType)
michael@0 984 {
michael@0 985 NS_ENSURE_ARG_POINTER(aPaperSizeType);
michael@0 986 *aPaperSizeType = mPaperSizeType;
michael@0 987 return NS_OK;
michael@0 988 }
michael@0 989 NS_IMETHODIMP nsPrintSettings::SetPaperSizeType(int16_t aPaperSizeType)
michael@0 990 {
michael@0 991 mPaperSizeType = aPaperSizeType;
michael@0 992 return NS_OK;
michael@0 993 }
michael@0 994
michael@0 995 /* attribute short PaperData; */
michael@0 996 NS_IMETHODIMP nsPrintSettings::GetPaperData(int16_t *aPaperData)
michael@0 997 {
michael@0 998 NS_ENSURE_ARG_POINTER(aPaperData);
michael@0 999 *aPaperData = mPaperData;
michael@0 1000 return NS_OK;
michael@0 1001 }
michael@0 1002 NS_IMETHODIMP nsPrintSettings::SetPaperData(int16_t aPaperData)
michael@0 1003 {
michael@0 1004 mPaperData = aPaperData;
michael@0 1005 return NS_OK;
michael@0 1006 }
michael@0 1007
michael@0 1008 /** ---------------------------------------------------
michael@0 1009 * See documentation in nsPrintOptionsImpl.h
michael@0 1010 * @update 6/21/00 dwc
michael@0 1011 * @update 1/12/01 rods
michael@0 1012 */
michael@0 1013 NS_IMETHODIMP
michael@0 1014 nsPrintSettings::SetMarginInTwips(nsIntMargin& aMargin)
michael@0 1015 {
michael@0 1016 mMargin = aMargin;
michael@0 1017 return NS_OK;
michael@0 1018 }
michael@0 1019
michael@0 1020 NS_IMETHODIMP
michael@0 1021 nsPrintSettings::SetEdgeInTwips(nsIntMargin& aEdge)
michael@0 1022 {
michael@0 1023 mEdge = aEdge;
michael@0 1024 return NS_OK;
michael@0 1025 }
michael@0 1026
michael@0 1027 // NOTE: Any subclass implementation of this function should make sure
michael@0 1028 // to check for negative margin values in aUnwriteableMargin (which
michael@0 1029 // would indicate that we should use the system default unwriteable margin.)
michael@0 1030 NS_IMETHODIMP
michael@0 1031 nsPrintSettings::SetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin)
michael@0 1032 {
michael@0 1033 if (aUnwriteableMargin.top >= 0) {
michael@0 1034 mUnwriteableMargin.top = aUnwriteableMargin.top;
michael@0 1035 }
michael@0 1036 if (aUnwriteableMargin.left >= 0) {
michael@0 1037 mUnwriteableMargin.left = aUnwriteableMargin.left;
michael@0 1038 }
michael@0 1039 if (aUnwriteableMargin.bottom >= 0) {
michael@0 1040 mUnwriteableMargin.bottom = aUnwriteableMargin.bottom;
michael@0 1041 }
michael@0 1042 if (aUnwriteableMargin.right >= 0) {
michael@0 1043 mUnwriteableMargin.right = aUnwriteableMargin.right;
michael@0 1044 }
michael@0 1045 return NS_OK;
michael@0 1046 }
michael@0 1047
michael@0 1048 /** ---------------------------------------------------
michael@0 1049 * See documentation in nsPrintOptionsImpl.h
michael@0 1050 * @update 6/21/00 dwc
michael@0 1051 */
michael@0 1052 NS_IMETHODIMP
michael@0 1053 nsPrintSettings::GetMarginInTwips(nsIntMargin& aMargin)
michael@0 1054 {
michael@0 1055 aMargin = mMargin;
michael@0 1056 return NS_OK;
michael@0 1057 }
michael@0 1058
michael@0 1059 NS_IMETHODIMP
michael@0 1060 nsPrintSettings::GetEdgeInTwips(nsIntMargin& aEdge)
michael@0 1061 {
michael@0 1062 aEdge = mEdge;
michael@0 1063 return NS_OK;
michael@0 1064 }
michael@0 1065
michael@0 1066 NS_IMETHODIMP
michael@0 1067 nsPrintSettings::GetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin)
michael@0 1068 {
michael@0 1069 aUnwriteableMargin = mUnwriteableMargin;
michael@0 1070 return NS_OK;
michael@0 1071 }
michael@0 1072
michael@0 1073 /** ---------------------------------------------------
michael@0 1074 * Stub - platform-specific implementations can use this function.
michael@0 1075 */
michael@0 1076 NS_IMETHODIMP
michael@0 1077 nsPrintSettings::SetupSilentPrinting()
michael@0 1078 {
michael@0 1079 return NS_OK;
michael@0 1080 }
michael@0 1081
michael@0 1082 /** ---------------------------------------------------
michael@0 1083 * See documentation in nsPrintOptionsImpl.h
michael@0 1084 */
michael@0 1085 NS_IMETHODIMP
michael@0 1086 nsPrintSettings::GetEffectivePageSize(double *aWidth, double *aHeight)
michael@0 1087 {
michael@0 1088 if (mPaperSizeUnit == kPaperSizeInches) {
michael@0 1089 *aWidth = NS_INCHES_TO_TWIPS(float(mPaperWidth));
michael@0 1090 *aHeight = NS_INCHES_TO_TWIPS(float(mPaperHeight));
michael@0 1091 } else {
michael@0 1092 *aWidth = NS_MILLIMETERS_TO_TWIPS(float(mPaperWidth));
michael@0 1093 *aHeight = NS_MILLIMETERS_TO_TWIPS(float(mPaperHeight));
michael@0 1094 }
michael@0 1095 if (kLandscapeOrientation == mOrientation) {
michael@0 1096 double temp = *aWidth;
michael@0 1097 *aWidth = *aHeight;
michael@0 1098 *aHeight = temp;
michael@0 1099 }
michael@0 1100 return NS_OK;
michael@0 1101 }
michael@0 1102
michael@0 1103 NS_IMETHODIMP
michael@0 1104 nsPrintSettings::GetPageRanges(nsTArray<int32_t> &aPages)
michael@0 1105 {
michael@0 1106 aPages.Clear();
michael@0 1107 return NS_OK;
michael@0 1108 }
michael@0 1109
michael@0 1110 nsresult
michael@0 1111 nsPrintSettings::_Clone(nsIPrintSettings **_retval)
michael@0 1112 {
michael@0 1113 nsPrintSettings* printSettings = new nsPrintSettings(*this);
michael@0 1114 return printSettings->QueryInterface(NS_GET_IID(nsIPrintSettings), (void**)_retval); // ref counts
michael@0 1115 }
michael@0 1116
michael@0 1117 /* nsIPrintSettings clone (); */
michael@0 1118 NS_IMETHODIMP
michael@0 1119 nsPrintSettings::Clone(nsIPrintSettings **_retval)
michael@0 1120 {
michael@0 1121 NS_ENSURE_ARG_POINTER(_retval);
michael@0 1122 return _Clone(_retval);
michael@0 1123 }
michael@0 1124
michael@0 1125 /* void assign (in nsIPrintSettings aPS); */
michael@0 1126 nsresult
michael@0 1127 nsPrintSettings::_Assign(nsIPrintSettings *aPS)
michael@0 1128 {
michael@0 1129 nsPrintSettings *ps = static_cast<nsPrintSettings*>(aPS);
michael@0 1130 *this = *ps;
michael@0 1131 return NS_OK;
michael@0 1132 }
michael@0 1133
michael@0 1134 /* void assign (in nsIPrintSettings aPS); */
michael@0 1135 NS_IMETHODIMP
michael@0 1136 nsPrintSettings::Assign(nsIPrintSettings *aPS)
michael@0 1137 {
michael@0 1138 NS_ENSURE_ARG(aPS);
michael@0 1139 return _Assign(aPS);
michael@0 1140 }
michael@0 1141
michael@0 1142 //-------------------------------------------
michael@0 1143 nsPrintSettings& nsPrintSettings::operator=(const nsPrintSettings& rhs)
michael@0 1144 {
michael@0 1145 if (this == &rhs) {
michael@0 1146 return *this;
michael@0 1147 }
michael@0 1148
michael@0 1149 mStartPageNum = rhs.mStartPageNum;
michael@0 1150 mEndPageNum = rhs.mEndPageNum;
michael@0 1151 mMargin = rhs.mMargin;
michael@0 1152 mEdge = rhs.mEdge;
michael@0 1153 mUnwriteableMargin = rhs.mUnwriteableMargin;
michael@0 1154 mScaling = rhs.mScaling;
michael@0 1155 mPrintBGColors = rhs.mPrintBGColors;
michael@0 1156 mPrintBGImages = rhs.mPrintBGImages;
michael@0 1157 mPrintRange = rhs.mPrintRange;
michael@0 1158 mTitle = rhs.mTitle;
michael@0 1159 mURL = rhs.mURL;
michael@0 1160 mHowToEnableFrameUI = rhs.mHowToEnableFrameUI;
michael@0 1161 mIsCancelled = rhs.mIsCancelled;
michael@0 1162 mPrintFrameTypeUsage = rhs.mPrintFrameTypeUsage;
michael@0 1163 mPrintFrameType = rhs.mPrintFrameType;
michael@0 1164 mPrintSilent = rhs.mPrintSilent;
michael@0 1165 mShrinkToFit = rhs.mShrinkToFit;
michael@0 1166 mShowPrintProgress = rhs.mShowPrintProgress;
michael@0 1167 mPaperName = rhs.mPaperName;
michael@0 1168 mPlexName = rhs.mPlexName;
michael@0 1169 mPaperSizeType = rhs.mPaperSizeType;
michael@0 1170 mPaperData = rhs.mPaperData;
michael@0 1171 mPaperWidth = rhs.mPaperWidth;
michael@0 1172 mPaperHeight = rhs.mPaperHeight;
michael@0 1173 mPaperSizeUnit = rhs.mPaperSizeUnit;
michael@0 1174 mPrintReversed = rhs.mPrintReversed;
michael@0 1175 mPrintInColor = rhs.mPrintInColor;
michael@0 1176 mOrientation = rhs.mOrientation;
michael@0 1177 mPrintCommand = rhs.mPrintCommand;
michael@0 1178 mNumCopies = rhs.mNumCopies;
michael@0 1179 mPrinter = rhs.mPrinter;
michael@0 1180 mPrintToFile = rhs.mPrintToFile;
michael@0 1181 mToFileName = rhs.mToFileName;
michael@0 1182 mOutputFormat = rhs.mOutputFormat;
michael@0 1183 mPrintPageDelay = rhs.mPrintPageDelay;
michael@0 1184
michael@0 1185 for (int32_t i=0;i<NUM_HEAD_FOOT;i++) {
michael@0 1186 mHeaderStrs[i] = rhs.mHeaderStrs[i];
michael@0 1187 mFooterStrs[i] = rhs.mFooterStrs[i];
michael@0 1188 }
michael@0 1189
michael@0 1190 return *this;
michael@0 1191 }
michael@0 1192

mercurial