|
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 |
|
11 // Interfaces |
|
12 #include "nsIDOMWindow.h" |
|
13 #include "nsDeviceContext.h" |
|
14 #include "nsIPrintProgressParams.h" |
|
15 #include "nsIPrintOptions.h" |
|
16 #include "nsTArray.h" |
|
17 #include "nsCOMArray.h" |
|
18 #include "nsAutoPtr.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 |
|
42 typedef enum {eIsPrinting, eIsPrintPreview } ePrintDataType; |
|
43 |
|
44 nsPrintData(ePrintDataType aType); |
|
45 ~nsPrintData(); // non-virtual |
|
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 |
|
56 ePrintDataType mType; // the type of data this is (Printing or Print Preview) |
|
57 nsRefPtr<nsDeviceContext> mPrintDC; |
|
58 FILE *mDebugFilePtr; // a file where information can go to when printing |
|
59 |
|
60 nsPrintObject * mPrintObject; |
|
61 nsPrintObject * mSelectedPO; |
|
62 |
|
63 nsCOMArray<nsIWebProgressListener> mPrintProgressListeners; |
|
64 nsCOMPtr<nsIPrintProgressParams> mPrintProgressParams; |
|
65 |
|
66 nsCOMPtr<nsIDOMWindow> mCurrentFocusWin; // cache a pointer to the currently focused window |
|
67 |
|
68 nsTArray<nsPrintObject*> mPrintDocList; |
|
69 bool mIsIFrameSelected; |
|
70 bool mIsParentAFrameSet; |
|
71 bool mOnStartSent; |
|
72 bool mIsAborted; // tells us the document is being aborted |
|
73 bool mPreparingForPrint; // see comments above |
|
74 bool mDocWasToBeDestroyed; // see comments above |
|
75 bool mShrinkToFit; |
|
76 int16_t mPrintFrameType; |
|
77 int32_t mNumPrintablePages; |
|
78 int32_t mNumPagesPrinted; |
|
79 float mShrinkRatio; |
|
80 float mOrigDCScale; |
|
81 |
|
82 nsCOMPtr<nsIPrintSettings> mPrintSettings; |
|
83 nsPrintPreviewListener* mPPEventListeners; |
|
84 |
|
85 char16_t* mBrandName; // needed as a substitute name for a document |
|
86 |
|
87 private: |
|
88 nsPrintData() MOZ_DELETE; |
|
89 nsPrintData& operator=(const nsPrintData& aOther) MOZ_DELETE; |
|
90 |
|
91 }; |
|
92 |
|
93 #endif /* nsPrintData_h___ */ |
|
94 |