nsPrintData.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef nsPrintData_h___
  6. #define nsPrintData_h___
  7. #include "mozilla/Attributes.h"
  8. // Interfaces
  9. #include "nsDeviceContext.h"
  10. #include "nsIPrintProgressParams.h"
  11. #include "nsIPrintSettings.h"
  12. #include "nsISupportsImpl.h"
  13. #include "nsTArray.h"
  14. #include "nsCOMArray.h"
  15. // Classes
  16. class nsPrintObject;
  17. class nsPrintPreviewListener;
  18. class nsIWebProgressListener;
  19. //------------------------------------------------------------------------
  20. // nsPrintData Class
  21. //
  22. // mPreparingForPrint - indicates that we have started Printing but
  23. // have not gone to the timer to start printing the pages. It gets turned
  24. // off right before we go to the timer.
  25. //
  26. // mDocWasToBeDestroyed - Gets set when "someone" tries to unload the document
  27. // while we were prparing to Print. This typically happens if a user starts
  28. // to print while a page is still loading. If they start printing and pause
  29. // at the print dialog and then the page comes in, we then abort printing
  30. // because the document is no longer stable.
  31. //
  32. //------------------------------------------------------------------------
  33. class nsPrintData {
  34. public:
  35. typedef enum {eIsPrinting, eIsPrintPreview } ePrintDataType;
  36. explicit nsPrintData(ePrintDataType aType);
  37. NS_INLINE_DECL_REFCOUNTING(nsPrintData)
  38. // Listener Helper Methods
  39. void OnEndPrinting();
  40. void OnStartPrinting();
  41. void DoOnProgressChange(int32_t aProgress,
  42. int32_t aMaxProgress,
  43. bool aDoStartStop,
  44. int32_t aFlag);
  45. void DoOnStatusChange(nsresult aStatus);
  46. ePrintDataType mType; // the type of data this is (Printing or Print Preview)
  47. RefPtr<nsDeviceContext> mPrintDC;
  48. FILE *mDebugFilePtr; // a file where information can go to when printing
  49. nsPrintObject * mPrintObject;
  50. nsPrintObject * mSelectedPO;
  51. nsCOMArray<nsIWebProgressListener> mPrintProgressListeners;
  52. nsCOMPtr<nsIPrintProgressParams> mPrintProgressParams;
  53. nsCOMPtr<nsPIDOMWindowOuter> mCurrentFocusWin; // cache a pointer to the currently focused window
  54. nsTArray<nsPrintObject*> mPrintDocList;
  55. bool mIsIFrameSelected;
  56. bool mIsParentAFrameSet;
  57. bool mOnStartSent;
  58. bool mIsAborted; // tells us the document is being aborted
  59. bool mPreparingForPrint; // see comments above
  60. bool mDocWasToBeDestroyed; // see comments above
  61. bool mShrinkToFit;
  62. int16_t mPrintFrameType;
  63. int32_t mNumPrintablePages;
  64. int32_t mNumPagesPrinted;
  65. float mShrinkRatio;
  66. float mOrigDCScale;
  67. nsCOMPtr<nsIPrintSettings> mPrintSettings;
  68. nsPrintPreviewListener* mPPEventListeners;
  69. char16_t* mBrandName; // needed as a substitute name for a document
  70. private:
  71. nsPrintData() = delete;
  72. nsPrintData& operator=(const nsPrintData& aOther) = delete;
  73. ~nsPrintData(); // non-virtual
  74. };
  75. #endif /* nsPrintData_h___ */