1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is mozilla.org code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Netscape Communications Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 1998
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either of the GNU General Public License Version 2 or later (the "GPL"),
26 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 : #ifndef nsSimplePageSequence_h___
38 : #define nsSimplePageSequence_h___
39 :
40 : #include "nsIPageSequenceFrame.h"
41 : #include "nsContainerFrame.h"
42 : #include "nsIPrintSettings.h"
43 : #include "nsIPrintOptions.h"
44 : #include "nsIDateTimeFormat.h"
45 :
46 : //-----------------------------------------------
47 : // This class maintains all the data that
48 : // is used by all the page frame
49 : // It lives while the nsSimplePageSequenceFrame lives
50 : class nsSharedPageData {
51 : public:
52 : nsSharedPageData();
53 : ~nsSharedPageData();
54 :
55 : PRUnichar * mDateTimeStr;
56 : nsFont * mHeadFootFont;
57 : PRUnichar * mPageNumFormat;
58 : PRUnichar * mPageNumAndTotalsFormat;
59 : PRUnichar * mDocTitle;
60 : PRUnichar * mDocURL;
61 :
62 : nsSize mReflowSize;
63 : nsMargin mReflowMargin;
64 : // Extra Margin between the device area and the edge of the page;
65 : // approximates unprintable area
66 : nsMargin mExtraMargin;
67 : // Margin for headers and footers; it defaults to 4/100 of an inch on UNIX
68 : // and 0 elsewhere; I think it has to do with some inconsistency in page size
69 : // computations
70 : nsMargin mEdgePaperMargin;
71 :
72 : nsCOMPtr<nsIPrintSettings> mPrintSettings;
73 : nsCOMPtr<nsIPrintOptions> mPrintOptions;
74 :
75 : nscoord mPageContentXMost; // xmost size from Reflow(width)
76 : nscoord mPageContentSize; // constrained size (width)
77 : };
78 :
79 : // Simple page sequence frame class. Used when we're in paginated mode
80 : class nsSimplePageSequenceFrame : public nsContainerFrame,
81 : public nsIPageSequenceFrame {
82 : public:
83 : friend nsIFrame* NS_NewSimplePageSequenceFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
84 :
85 : NS_DECL_QUERYFRAME
86 : NS_DECL_FRAMEARENA_HELPERS
87 :
88 : // nsIFrame
89 : NS_IMETHOD Reflow(nsPresContext* aPresContext,
90 : nsHTMLReflowMetrics& aDesiredSize,
91 : const nsHTMLReflowState& aMaxSize,
92 : nsReflowStatus& aStatus);
93 :
94 : NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
95 : const nsRect& aDirtyRect,
96 : const nsDisplayListSet& aLists);
97 :
98 : // nsIPageSequenceFrame
99 0 : NS_IMETHOD SetPageNo(PRInt32 aPageNo) { return NS_OK;}
100 0 : NS_IMETHOD SetSelectionHeight(nscoord aYOffset, nscoord aHeight) { mYSelOffset = aYOffset; mSelectionHeight = aHeight; return NS_OK; }
101 0 : NS_IMETHOD SetTotalNumPages(PRInt32 aTotal) { mTotalPages = aTotal; return NS_OK; }
102 :
103 : // For Shrink To Fit
104 : NS_IMETHOD GetSTFPercent(float& aSTFPercent);
105 :
106 : // Async Printing
107 : NS_IMETHOD StartPrint(nsPresContext* aPresContext,
108 : nsIPrintSettings* aPrintSettings,
109 : PRUnichar* aDocTitle,
110 : PRUnichar* aDocURL);
111 : NS_IMETHOD PrintNextPage();
112 : NS_IMETHOD GetCurrentPageNum(PRInt32* aPageNum);
113 : NS_IMETHOD GetNumPages(PRInt32* aNumPages);
114 : NS_IMETHOD IsDoingPrintRange(bool* aDoing);
115 : NS_IMETHOD GetPrintRange(PRInt32* aFromPage, PRInt32* aToPage);
116 : NS_IMETHOD DoPageEnd();
117 :
118 : // We must allow Print Preview UI to have a background, no matter what the
119 : // user's settings
120 0 : virtual bool HonorPrintBackgroundSettings() { return false; }
121 :
122 : /**
123 : * Get the "type" of the frame
124 : *
125 : * @see nsGkAtoms::sequenceFrame
126 : */
127 : virtual nsIAtom* GetType() const;
128 :
129 : #ifdef NS_DEBUG
130 : NS_IMETHOD GetFrameName(nsAString& aResult) const;
131 : #endif
132 :
133 : void PaintPageSequence(nsRenderingContext& aRenderingContext,
134 : const nsRect& aDirtyRect,
135 : nsPoint aPt);
136 :
137 : protected:
138 : nsSimplePageSequenceFrame(nsStyleContext* aContext);
139 : virtual ~nsSimplePageSequenceFrame();
140 :
141 : void SetPageNumberFormat(const char* aPropName, const char* aDefPropVal, bool aPageNumOnly);
142 :
143 : // SharedPageData Helper methods
144 : void SetDateTimeStr(PRUnichar * aDateTimeStr);
145 : void SetPageNumberFormat(PRUnichar * aFormatStr, bool aForPageNumOnly);
146 :
147 : // Sets the frame desired size to the size of the viewport, or the given
148 : // nscoords, whichever is larger. Print scaling is applied in this function.
149 : void SetDesiredSize(nsHTMLReflowMetrics& aDesiredSize,
150 : const nsHTMLReflowState& aReflowState,
151 : nscoord aWidth, nscoord aHeight);
152 :
153 : nsMargin mMargin;
154 :
155 : // I18N date formatter service which we'll want to cache locally.
156 : nsCOMPtr<nsIDateTimeFormat> mDateFormatter;
157 :
158 : nsSize mSize;
159 : nsSharedPageData* mPageData; // data shared by all the nsPageFrames
160 :
161 : // Asynch Printing
162 : nsIFrame * mCurrentPageFrame;
163 : PRInt32 mPageNum;
164 : PRInt32 mTotalPages;
165 : PRInt32 mPrintRangeType;
166 : PRInt32 mFromPageNum;
167 : PRInt32 mToPageNum;
168 : nsTArray<PRInt32> mPageRanges;
169 :
170 : // Selection Printing Info
171 : nscoord mSelectionHeight;
172 : nscoord mYSelOffset;
173 :
174 : // Asynch Printing
175 : bool mPrintThisPage;
176 : bool mDoingPageRange;
177 :
178 : bool mIsPrintingSelection;
179 : };
180 :
181 : #endif /* nsSimplePageSequence_h___ */
182 :
|