Line data Source code
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 :
6 : #ifndef nsPrintData_h___
7 : #define nsPrintData_h___
8 :
9 : #include "mozilla/Attributes.h"
10 : #include "mozilla/UniquePtr.h"
11 :
12 : // Interfaces
13 : #include "nsDeviceContext.h"
14 : #include "nsIPrintProgressParams.h"
15 : #include "nsIPrintSettings.h"
16 : #include "nsISupportsImpl.h"
17 : #include "nsTArray.h"
18 : #include "nsCOMArray.h"
19 :
20 : // Classes
21 : class nsPrintObject;
22 : class nsPrintPreviewListener;
23 : class nsIWebProgressListener;
24 :
25 : //------------------------------------------------------------------------
26 : // nsPrintData Class
27 : //
28 : // mPreparingForPrint - indicates that we have started Printing but
29 : // have not gone to the timer to start printing the pages. It gets turned
30 : // off right before we go to the timer.
31 : //
32 : // mDocWasToBeDestroyed - Gets set when "someone" tries to unload the document
33 : // while we were prparing to Print. This typically happens if a user starts
34 : // to print while a page is still loading. If they start printing and pause
35 : // at the print dialog and then the page comes in, we then abort printing
36 : // because the document is no longer stable.
37 : //
38 : //------------------------------------------------------------------------
39 : class nsPrintData {
40 : public:
41 : typedef enum {eIsPrinting, eIsPrintPreview } ePrintDataType;
42 :
43 : explicit nsPrintData(ePrintDataType aType);
44 :
45 0 : NS_INLINE_DECL_REFCOUNTING(nsPrintData)
46 :
47 : // Listener Helper Methods
48 : void OnEndPrinting();
49 : void OnStartPrinting();
50 : void DoOnProgressChange(int32_t aProgress,
51 : int32_t aMaxProgress,
52 : bool aDoStartStop,
53 : int32_t aFlag);
54 :
55 : void DoOnStatusChange(nsresult aStatus);
56 :
57 :
58 : ePrintDataType mType; // the type of data this is (Printing or Print Preview)
59 : RefPtr<nsDeviceContext> mPrintDC;
60 : FILE *mDebugFilePtr; // a file where information can go to when printing
61 :
62 : mozilla::UniquePtr<nsPrintObject> mPrintObject;
63 :
64 : nsCOMArray<nsIWebProgressListener> mPrintProgressListeners;
65 : nsCOMPtr<nsIPrintProgressParams> mPrintProgressParams;
66 :
67 : nsCOMPtr<nsPIDOMWindowOuter> mCurrentFocusWin; // cache a pointer to the currently focused window
68 :
69 : // Array of non-owning pointers to all the nsPrintObjects owned by this
70 : // nsPrintData. This includes this->mPrintObject, as well as all of its
71 : // mKids (and their mKids, etc.)
72 : nsTArray<nsPrintObject*> mPrintDocList;
73 :
74 : bool mIsIFrameSelected;
75 : bool mIsParentAFrameSet;
76 : bool mOnStartSent;
77 : bool mIsAborted; // tells us the document is being aborted
78 : bool mPreparingForPrint; // see comments above
79 : bool mDocWasToBeDestroyed; // see comments above
80 : bool mShrinkToFit;
81 : int16_t mPrintFrameType;
82 : int32_t mNumPrintablePages;
83 : int32_t mNumPagesPrinted;
84 : float mShrinkRatio;
85 : float mOrigDCScale;
86 :
87 : nsCOMPtr<nsIPrintSettings> mPrintSettings;
88 : nsPrintPreviewListener* mPPEventListeners;
89 :
90 : char16_t* mBrandName; // needed as a substitute name for a document
91 :
92 : private:
93 : nsPrintData() = delete;
94 : nsPrintData& operator=(const nsPrintData& aOther) = delete;
95 :
96 : ~nsPrintData(); // non-virtual
97 : };
98 :
99 : #endif /* nsPrintData_h___ */
100 :
|