Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef INCLUDED_SW_SOURCE_CORE_INC_PAGEFRM_HXX
20 : #define INCLUDED_SW_SOURCE_CORE_INC_PAGEFRM_HXX
21 :
22 : #include <viewsh.hxx>
23 : #include "ftnboss.hxx"
24 : #include <tools/mempool.hxx>
25 :
26 : #include <SidebarWindowsTypes.hxx>
27 :
28 : class SwFlyFrm;
29 : class SwFlyFrmFmt;
30 : class SwPageDesc;
31 : class SwCntntFrm;
32 : struct SwPosition;
33 : struct SwCrsrMoveState;
34 : class SwAttrSetChg;
35 : namespace vcl { class Font; }
36 : class SwSortedObjs;
37 : class SwAnchoredObject;
38 :
39 : enum SwPageChg
40 : {
41 : CHG_NEWPAGE,
42 : CHG_CUTPAGE,
43 : CHG_CHGPAGE
44 : };
45 :
46 : /// A page of the document layout.
47 : class SwPageFrm: public SwFtnBossFrm
48 : {
49 : friend class SwFrm;
50 :
51 : SwSortedObjs *pSortedObjs;
52 :
53 : SwPageDesc *pDesc; //PageDesc that describes the Page
54 :
55 : sal_uInt16 nPhyPageNum; // Physical page number
56 :
57 : bool bInvalidCntnt :1;
58 : bool bInvalidLayout :1;
59 : bool bInvalidFlyCntnt :1;
60 : bool bInvalidFlyLayout :1;
61 : bool bInvalidFlyInCnt :1;
62 : bool bFtnPage :1; // This Page is for document end footnotes
63 : bool bEmptyPage :1; // This Page is an explicitly empty page
64 : bool bEndNotePage :1; // 'Footnote page' for end notes
65 : bool bInvalidSpelling :1; // We need online spelling
66 : bool bInvalidSmartTags :1; // We need checking for smarttags
67 : bool bInvalidAutoCmplWrds :1; // Update auto complete word list
68 : bool bInvalidWordCount :1;
69 : bool bHasGrid :1; // Grid for Asian layout
70 :
71 : static const sal_Int8 mnShadowPxWidth;
72 :
73 : void _UpdateAttr( const SfxPoolItem*, const SfxPoolItem*, sal_uInt8 &,
74 : SwAttrSetChg *pa = 0, SwAttrSetChg *pb = 0 );
75 :
76 : /// Adapt the max. footnote height in each single column
77 : void SetColMaxFtnHeight();
78 :
79 : /** determine rectangle for horizontal page shadow
80 :
81 : #i9719#
82 :
83 : @param _rPageRect
84 : input parameter - constant instance reference of the page rectangle.
85 : Generally, it's the frame area of the page, but for empty pages in print
86 : preview, this parameter is useful.
87 :
88 : @param _pViewShell
89 : input parameter - instance of the view shell, for which the rectangle
90 : has to be generated.
91 :
92 : @param _orBottomShadowRect
93 : output parameter - instance reference of the bottom shadow rectangle for
94 : the given page rectangle
95 : */
96 :
97 : static void GetHorizontalShadowRect( const SwRect& _rPageRect,
98 : const SwViewShell* _pViewShell,
99 : SwRect& _orBottomShadowRect,
100 : bool bPaintLeftShadow,
101 : bool bPaintRightShadow,
102 : bool bRightSidebar );
103 :
104 : protected:
105 : virtual void MakeAll() SAL_OVERRIDE;
106 : virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) SAL_OVERRIDE;
107 :
108 : public:
109 15060 : DECL_FIXEDMEMPOOL_NEWDEL(SwPageFrm)
110 :
111 : SwPageFrm( SwFrmFmt*, SwFrm*, SwPageDesc* );
112 : virtual ~SwPageFrm();
113 :
114 : /// Make this public, so that the SwViewShell can access it when switching from browse mode
115 : /// Add/remove header/footer
116 : void PrepareHeader();
117 : void PrepareFooter();
118 :
119 695163 : const SwSortedObjs *GetSortedObjs() const { return pSortedObjs; }
120 391862 : SwSortedObjs *GetSortedObjs() { return pSortedObjs; }
121 :
122 : void AppendDrawObjToPage( SwAnchoredObject& _rNewObj );
123 : void RemoveDrawObjFromPage( SwAnchoredObject& _rToRemoveObj );
124 :
125 : void AppendFlyToPage( SwFlyFrm *pNew );
126 : void RemoveFlyFromPage( SwFlyFrm *pToRemove );
127 : void MoveFly( SwFlyFrm *pToMove, SwPageFrm *pDest ); // Optimized Remove/Append
128 :
129 : void SetPageDesc( SwPageDesc *, SwFrmFmt * );
130 17716 : SwPageDesc *GetPageDesc() { return pDesc; }
131 47355 : const SwPageDesc *GetPageDesc() const { return pDesc; }
132 : SwPageDesc *FindPageDesc();
133 :
134 : SwCntntFrm *FindLastBodyCntnt();
135 : inline SwCntntFrm *FindFirstBodyCntnt();
136 : inline const SwCntntFrm *FindFirstBodyCntnt() const;
137 : inline const SwCntntFrm *FindLastBodyCntnt() const;
138 :
139 : SwRect GetBoundRect() const;
140 :
141 : // Specialized GetCntntPos() for Field in Frames
142 : void GetCntntPosition( const Point &rPt, SwPosition &rPos ) const;
143 :
144 623803 : bool IsEmptyPage() const { return bEmptyPage; } // Explicitly empty page
145 :
146 : void UpdateFtnNum();
147 :
148 : /// Always call after Paste
149 : /// Creates the page-bound frames and formats the generic content
150 : void PreparePage( bool bFtn );
151 :
152 : // Sends a Prepare() to all ContentFrames caused by a changed register template
153 : void PrepareRegisterChg();
154 :
155 : // Appends a fly frame - the given one or a new one - at the page frame.
156 : // Needed for <Modify> and <MakeFrms>
157 : // - return value not needed any more
158 : // - second parameter is of type <SwFlyFrmFmt*>
159 : // - third parameter only needed for assertion, but calling method assures
160 : // this assertion. Thus, delete it.
161 : void PlaceFly( SwFlyFrm* pFly, SwFlyFrmFmt* pFmt );
162 :
163 : virtual bool GetCrsrOfst( SwPosition *, Point&,
164 : SwCrsrMoveState* = 0, bool bTestBackground = false ) const SAL_OVERRIDE;
165 : /// Get info from Client
166 : virtual bool GetInfo( SfxPoolItem& ) const SAL_OVERRIDE;
167 :
168 : virtual void Cut() SAL_OVERRIDE;
169 : virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 ) SAL_OVERRIDE;
170 : virtual void CheckDirection( bool bVert ) SAL_OVERRIDE;
171 : void CheckGrid( bool bInvalidate );
172 : void PaintGrid( OutputDevice* pOut, SwRect &rRect ) const;
173 827797 : bool HasGrid() const { return bHasGrid; }
174 :
175 : void PaintDecorators( ) const;
176 : virtual void PaintSubsidiaryLines( const SwPageFrm*, const SwRect& ) const SAL_OVERRIDE;
177 : virtual void PaintBreak() const SAL_OVERRIDE;
178 :
179 : /// Paint line number etc.
180 : void RefreshExtraData( const SwRect & ) const;
181 :
182 : /// Paint helper lines
183 : void RefreshSubsidiary( const SwRect& ) const;
184 :
185 : /// Foot note interface
186 52387 : bool IsFtnPage() const { return bFtnPage; }
187 630 : bool IsEndNotePage() const { return bEndNotePage; }
188 7532 : void SetFtnPage( bool b ) { bFtnPage = b; }
189 22 : void SetEndNotePage( bool b ) { bEndNotePage = b; }
190 :
191 271852 : inline sal_uInt16 GetPhyPageNum() const { return nPhyPageNum;}
192 7532 : inline void SetPhyPageNum( sal_uInt16 nNum ) { nPhyPageNum = nNum;}
193 170 : inline void DecrPhyPageNum() { --nPhyPageNum; }
194 244 : inline void IncrPhyPageNum() { ++nPhyPageNum; }
195 :
196 : /// Validate, invalidate and query the Page status
197 : /// Layout/Cntnt and Fly/non-Fly respectively are inspected separately
198 : inline void InvalidateFlyLayout() const;
199 : inline void InvalidateFlyCntnt() const;
200 : inline void InvalidateFlyInCnt() const;
201 : inline void InvalidateLayout() const;
202 : inline void InvalidateCntnt() const;
203 : inline void InvalidateSpelling() const;
204 : inline void InvalidateSmartTags() const;
205 : inline void InvalidateAutoCompleteWords() const;
206 : inline void InvalidateWordCount() const;
207 : inline void ValidateFlyLayout() const;
208 : inline void ValidateFlyCntnt() const;
209 : inline void ValidateFlyInCnt() const;
210 : inline void ValidateLayout() const;
211 : inline void ValidateCntnt() const;
212 : inline void ValidateSpelling() const;
213 : inline void ValidateSmartTags() const;
214 : inline void ValidateAutoCompleteWords() const;
215 : inline void ValidateWordCount() const;
216 : inline bool IsInvalid() const;
217 : inline bool IsInvalidFly() const;
218 : bool IsRightShadowNeeded() const;
219 : bool IsLeftShadowNeeded() const;
220 668 : bool IsInvalidFlyLayout() const { return bInvalidFlyLayout; }
221 666 : bool IsInvalidFlyCntnt() const { return bInvalidFlyCntnt; }
222 1195 : bool IsInvalidFlyInCnt() const { return bInvalidFlyInCnt; }
223 145572 : bool IsInvalidLayout() const { return bInvalidLayout; }
224 28025 : bool IsInvalidCntnt() const { return (bInvalidCntnt || bInvalidFlyInCnt); }
225 662 : bool IsInvalidSpelling() const { return bInvalidSpelling; }
226 0 : bool IsInvalidSmartTags() const { return bInvalidSmartTags; }
227 243 : bool IsInvalidAutoCompleteWords() const { return bInvalidAutoCmplWrds; }
228 243 : bool IsInvalidWordCount() const { return bInvalidWordCount; }
229 :
230 : /** SwPageFrm::GetDrawBackgrdColor
231 :
232 : determine the color, that is respectively will be drawn as background
233 : for the page frame.
234 :
235 : @return reference to an instance of class Color
236 : */
237 : const Color GetDrawBackgrdColor() const;
238 :
239 : /** paint margin area of a page
240 :
241 : implement paint of margin area; margin area will be painted for a
242 : view shell with a window and if the document is not in online layout.
243 :
244 : @param _rOutputRect
245 : input parameter - constant instance reference of the rectangle, for
246 : which an output has to be generated.
247 :
248 : @param _pViewShell
249 : input parameter - instance of the view shell, on which the output
250 : has to be generated.
251 : */
252 : void PaintMarginArea( const SwRect& _rOutputRect,
253 : SwViewShell* _pViewShell ) const;
254 :
255 : /** paint page border and shadow
256 :
257 : @param _rPageRect
258 : input parameter - constant instance reference of the page rectangle.
259 : Generally, it's the frame area of the page, but for empty pages in print
260 : preview, this parameter is useful.
261 :
262 : @param _pViewShell
263 : input parameter - instance of the view shell, on which the output
264 : has to be generated.
265 :
266 : @param bPaintRightShadow
267 : Should we paint shadow on the right or not (used in book mode)
268 :
269 : @param bFullBottomShadow
270 : Should we have a bottom shadow of the same size as the pages or
271 : not (for right pages in book mode in a LTR environment).
272 :
273 : @param bRightSidebar
274 : Is the note sidebar on the right or not (used to adjust the
275 : shadow with & position).
276 : */
277 : static void PaintBorderAndShadow( const SwRect& _rPageRect,
278 : const SwViewShell* _pViewShell,
279 : bool bPaintLeftShadow,
280 : bool bPaintRightShadow,
281 : bool bRightSidebar );
282 :
283 : /** get bound rectangle of border and shadow for repaints
284 :
285 : @param _rPageRect
286 : input parameter - constant instance reference of the page rectangle.
287 : Generally, it's the frame area of the page, but for empty pages in print
288 : preview, this parameter is useful.
289 :
290 : @param _pViewShell
291 : input parameter - instance of the view shell, for which the rectangle
292 : has to be generated.
293 :
294 : @param _orBorderAndShadowBoundRect
295 : output parameter - instance reference of the bounded border and shadow
296 : rectangle for the given page rectangle
297 : */
298 : static void GetBorderAndShadowBoundRect( const SwRect& _rPageRect,
299 : const SwViewShell* _pViewShell,
300 : SwRect& _orBorderAndShadowBoundRect,
301 : const bool bLeftShadow,
302 : const bool bRightShadow,
303 : const bool bRightSidebar
304 : );
305 :
306 : static void PaintNotesSidebar(const SwRect& _rPageRect, SwViewShell* _pViewShell, sal_uInt16 nPageNum, bool bRight);
307 : static void PaintNotesSidebarArrows(const Point &aMiddleFirst, const Point &aMiddleSecond, SwViewShell* _pViewShell, const Color aColorUp, const Color aColorDown);
308 : /**
309 : asks the page on which side a margin should be shown, e.g for notes
310 : returns true for left side, false for right side
311 : */
312 : sw::sidebarwindows::SidebarPosition SidebarPosition() const;
313 :
314 : virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const SAL_OVERRIDE;
315 :
316 : inline sal_Int8 ShadowPxWidth() const
317 : {
318 : return mnShadowPxWidth;
319 : }
320 :
321 : const SwRect PrtWithoutHeaderAndFooter() const;
322 :
323 : // in case this is am empty page, this function returns the 'reference' page
324 : const SwPageFrm& GetFormatPage() const;
325 :
326 : /// If in header or footer area, it also indicates the exact area in rControl.
327 : bool IsOverHeaderFooterArea( const Point& rPt, FrameControlType &rControl ) const;
328 :
329 : // return font used to paint the "empty page" string
330 : static const vcl::Font& GetEmptyPageFont();
331 :
332 : static SwTwips GetSidebarBorderWidth( const SwViewShell* );
333 : };
334 :
335 68211 : inline SwCntntFrm *SwPageFrm::FindFirstBodyCntnt()
336 : {
337 68211 : SwLayoutFrm *pBody = FindBodyCont();
338 68211 : return pBody ? pBody->ContainsCntnt() : 0;
339 : }
340 2016 : inline const SwCntntFrm *SwPageFrm::FindFirstBodyCntnt() const
341 : {
342 2016 : const SwLayoutFrm *pBody = FindBodyCont();
343 2016 : return pBody ? pBody->ContainsCntnt() : 0;
344 : }
345 0 : inline const SwCntntFrm *SwPageFrm::FindLastBodyCntnt() const
346 : {
347 0 : return ((SwPageFrm*)this)->FindLastBodyCntnt();
348 : }
349 25227 : inline void SwPageFrm::InvalidateFlyLayout() const
350 : {
351 25227 : ((SwPageFrm*)this)->bInvalidFlyLayout = true;
352 25227 : }
353 18653 : inline void SwPageFrm::InvalidateFlyCntnt() const
354 : {
355 18653 : ((SwPageFrm*)this)->bInvalidFlyCntnt = true;
356 18653 : }
357 13034 : inline void SwPageFrm::InvalidateFlyInCnt() const
358 : {
359 13034 : ((SwPageFrm*)this)->bInvalidFlyInCnt = true;
360 13034 : }
361 171092 : inline void SwPageFrm::InvalidateLayout() const
362 : {
363 171092 : ((SwPageFrm*)this)->bInvalidLayout = true;
364 171092 : }
365 261347 : inline void SwPageFrm::InvalidateCntnt() const
366 : {
367 261347 : ((SwPageFrm*)this)->bInvalidCntnt = true;
368 261347 : }
369 62579 : inline void SwPageFrm::InvalidateSpelling() const
370 : {
371 62579 : ((SwPageFrm*)this)->bInvalidSpelling = true;
372 62579 : }
373 :
374 62578 : inline void SwPageFrm::InvalidateSmartTags() const
375 : {
376 62578 : ((SwPageFrm*)this)->bInvalidSmartTags = true;
377 62578 : }
378 62570 : inline void SwPageFrm::InvalidateAutoCompleteWords() const
379 : {
380 62570 : ((SwPageFrm*)this)->bInvalidAutoCmplWrds = true;
381 62570 : }
382 62570 : inline void SwPageFrm::InvalidateWordCount() const
383 : {
384 62570 : ((SwPageFrm*)this)->bInvalidWordCount = true;
385 62570 : }
386 36571 : inline void SwPageFrm::ValidateFlyLayout() const
387 : {
388 36571 : ((SwPageFrm*)this)->bInvalidFlyLayout = false;
389 36571 : }
390 36571 : inline void SwPageFrm::ValidateFlyCntnt() const
391 : {
392 36571 : ((SwPageFrm*)this)->bInvalidFlyCntnt = false;
393 36571 : }
394 17656 : inline void SwPageFrm::ValidateFlyInCnt() const
395 : {
396 17656 : ((SwPageFrm*)this)->bInvalidFlyInCnt = false;
397 17656 : }
398 10724 : inline void SwPageFrm::ValidateLayout() const
399 : {
400 10724 : ((SwPageFrm*)this)->bInvalidLayout = false;
401 10724 : }
402 17658 : inline void SwPageFrm::ValidateCntnt() const
403 : {
404 17658 : ((SwPageFrm*)this)->bInvalidCntnt = false;
405 17658 : }
406 439 : inline void SwPageFrm::ValidateSpelling() const
407 : {
408 439 : ((SwPageFrm*)this)->bInvalidSpelling = false;
409 439 : }
410 :
411 0 : inline void SwPageFrm::ValidateSmartTags() const
412 : {
413 0 : ((SwPageFrm*)this)->bInvalidSmartTags = false;
414 0 : }
415 1278 : inline void SwPageFrm::ValidateAutoCompleteWords() const
416 : {
417 1278 : ((SwPageFrm*)this)->bInvalidAutoCmplWrds = false;
418 1278 : }
419 639 : inline void SwPageFrm::ValidateWordCount() const
420 : {
421 639 : ((SwPageFrm*)this)->bInvalidWordCount = false;
422 639 : }
423 :
424 187220 : inline bool SwPageFrm::IsInvalid() const
425 : {
426 187220 : return (bInvalidCntnt || bInvalidLayout || bInvalidFlyInCnt);
427 : }
428 145966 : inline bool SwPageFrm::IsInvalidFly() const
429 : {
430 145966 : return bInvalidFlyLayout || bInvalidFlyCntnt;
431 : }
432 :
433 :
434 : class SwTextGridItem;
435 :
436 : SwTextGridItem const* GetGridItem(SwPageFrm const*const);
437 :
438 : sal_uInt16 GetGridWidth(SwTextGridItem const&, SwDoc const&);
439 :
440 : #endif // INCLUDED_SW_SOURCE_CORE_INC_PAGEFRM_HXX
441 :
442 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|