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 SwFlyFrameFormat;
30 : class SwPageDesc;
31 : class SwContentFrm;
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 SwFootnoteBossFrm
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 bInvalidContent :1;
58 : bool bInvalidLayout :1;
59 : bool bInvalidFlyContent :1;
60 : bool bInvalidFlyLayout :1;
61 : bool bInvalidFlyInCnt :1;
62 : bool bFootnotePage :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 SetColMaxFootnoteHeight();
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 : virtual void DestroyImpl() SAL_OVERRIDE;
105 : virtual ~SwPageFrm();
106 :
107 : protected:
108 : virtual void MakeAll() SAL_OVERRIDE;
109 : virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) SAL_OVERRIDE;
110 : virtual void SwClientNotify(const SwModify&, const SfxHint&) SAL_OVERRIDE;
111 :
112 : public:
113 9119 : DECL_FIXEDMEMPOOL_NEWDEL(SwPageFrm)
114 :
115 : SwPageFrm( SwFrameFormat*, SwFrm*, SwPageDesc* );
116 :
117 : /// Make this public, so that the SwViewShell can access it when switching from browse mode
118 : /// Add/remove header/footer
119 : void PrepareHeader();
120 : void PrepareFooter();
121 :
122 400046 : const SwSortedObjs *GetSortedObjs() const { return pSortedObjs; }
123 119171131 : SwSortedObjs *GetSortedObjs() { return pSortedObjs; }
124 :
125 : void AppendDrawObjToPage( SwAnchoredObject& _rNewObj );
126 : void RemoveDrawObjFromPage( SwAnchoredObject& _rToRemoveObj );
127 :
128 : void AppendFlyToPage( SwFlyFrm *pNew );
129 : void RemoveFlyFromPage( SwFlyFrm *pToRemove );
130 : void MoveFly( SwFlyFrm *pToMove, SwPageFrm *pDest ); // Optimized Remove/Append
131 :
132 : void SetPageDesc( SwPageDesc *, SwFrameFormat * );
133 16539 : SwPageDesc *GetPageDesc() { return pDesc; }
134 40905 : const SwPageDesc *GetPageDesc() const { return pDesc; }
135 : SwPageDesc *FindPageDesc();
136 :
137 : SwContentFrm *FindLastBodyContent();
138 : inline SwContentFrm *FindFirstBodyContent();
139 : inline const SwContentFrm *FindFirstBodyContent() const;
140 : inline const SwContentFrm *FindLastBodyContent() const;
141 :
142 : SwRect GetBoundRect() const;
143 :
144 : // Specialized GetContentPos() for Field in Frames
145 : void GetContentPosition( const Point &rPt, SwPosition &rPos ) const;
146 :
147 632297 : bool IsEmptyPage() const { return bEmptyPage; } // Explicitly empty page
148 :
149 : void UpdateFootnoteNum();
150 :
151 : /// Always call after Paste
152 : /// Creates the page-bound frames and formats the generic content
153 : void PreparePage( bool bFootnote );
154 :
155 : // Sends a Prepare() to all ContentFrames caused by a changed register template
156 : void PrepareRegisterChg();
157 :
158 : // Appends a fly frame - the given one or a new one - at the page frame.
159 : // Needed for <Modify> and <MakeFrms>
160 : // - return value not needed any more
161 : // - second parameter is of type <SwFlyFrameFormat*>
162 : // - third parameter only needed for assertion, but calling method assures
163 : // this assertion. Thus, delete it.
164 : void PlaceFly( SwFlyFrm* pFly, SwFlyFrameFormat* pFormat );
165 :
166 : virtual bool GetCrsrOfst( SwPosition *, Point&,
167 : SwCrsrMoveState* = 0, bool bTestBackground = false ) const SAL_OVERRIDE;
168 : /// Get info from Client
169 : virtual bool GetInfo( SfxPoolItem& ) const SAL_OVERRIDE;
170 :
171 : virtual void Cut() SAL_OVERRIDE;
172 : virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 ) SAL_OVERRIDE;
173 : virtual void CheckDirection( bool bVert ) SAL_OVERRIDE;
174 : void CheckGrid( bool bInvalidate );
175 : void PaintGrid( OutputDevice* pOut, SwRect &rRect ) const;
176 476054 : bool HasGrid() const { return bHasGrid; }
177 :
178 : void PaintDecorators( ) const;
179 : virtual void PaintSubsidiaryLines( const SwPageFrm*, const SwRect& ) const SAL_OVERRIDE;
180 : virtual void PaintBreak() const SAL_OVERRIDE;
181 :
182 : /// Paint line number etc.
183 : void RefreshExtraData( const SwRect & ) const;
184 :
185 : /// Paint helper lines
186 : void RefreshSubsidiary( const SwRect& ) const;
187 :
188 : /// Foot note interface
189 34797 : bool IsFootnotePage() const { return bFootnotePage; }
190 371 : bool IsEndNotePage() const { return bEndNotePage; }
191 4721 : void SetFootnotePage( bool b ) { bFootnotePage = b; }
192 14 : void SetEndNotePage( bool b ) { bEndNotePage = b; }
193 :
194 26945169 : inline sal_uInt16 GetPhyPageNum() const { return nPhyPageNum;}
195 4721 : inline void SetPhyPageNum( sal_uInt16 nNum ) { nPhyPageNum = nNum;}
196 383 : inline void DecrPhyPageNum() { --nPhyPageNum; }
197 420 : inline void IncrPhyPageNum() { ++nPhyPageNum; }
198 :
199 : /// Validate, invalidate and query the Page status
200 : /// Layout/Content and Fly/non-Fly respectively are inspected separately
201 : inline void InvalidateFlyLayout() const;
202 : inline void InvalidateFlyContent() const;
203 : inline void InvalidateFlyInCnt() const;
204 : inline void InvalidateLayout() const;
205 : inline void InvalidateContent() const;
206 : inline void InvalidateSpelling() const;
207 : inline void InvalidateSmartTags() const;
208 : inline void InvalidateAutoCompleteWords() const;
209 : inline void InvalidateWordCount() const;
210 : inline void ValidateFlyLayout() const;
211 : inline void ValidateFlyContent() const;
212 : inline void ValidateFlyInCnt() const;
213 : inline void ValidateLayout() const;
214 : inline void ValidateContent() const;
215 : inline void ValidateSpelling() const;
216 : inline void ValidateSmartTags() const;
217 : inline void ValidateAutoCompleteWords() const;
218 : inline void ValidateWordCount() const;
219 : inline bool IsInvalid() const;
220 : inline bool IsInvalidFly() const;
221 : bool IsRightShadowNeeded() const;
222 : bool IsLeftShadowNeeded() const;
223 26786658 : bool IsInvalidFlyLayout() const { return bInvalidFlyLayout; }
224 26786657 : bool IsInvalidFlyContent() const { return bInvalidFlyContent; }
225 26786812 : bool IsInvalidFlyInCnt() const { return bInvalidFlyInCnt; }
226 26873607 : bool IsInvalidLayout() const { return bInvalidLayout; }
227 26803750 : bool IsInvalidContent() const { return (bInvalidContent || bInvalidFlyInCnt); }
228 26786654 : bool IsInvalidSpelling() const { return bInvalidSpelling; }
229 0 : bool IsInvalidSmartTags() const { return bInvalidSmartTags; }
230 20223 : bool IsInvalidAutoCompleteWords() const { return bInvalidAutoCmplWrds; }
231 20223 : bool IsInvalidWordCount() const { return bInvalidWordCount; }
232 :
233 : /** SwPageFrm::GetDrawBackgrdColor
234 :
235 : determine the color, that is respectively will be drawn as background
236 : for the page frame.
237 :
238 : @return reference to an instance of class Color
239 : */
240 : const Color GetDrawBackgrdColor() const;
241 :
242 : /** paint margin area of a page
243 :
244 : implement paint of margin area; margin area will be painted for a
245 : view shell with a window and if the document is not in online layout.
246 :
247 : @param _rOutputRect
248 : input parameter - constant instance reference of the rectangle, for
249 : which an output has to be generated.
250 :
251 : @param _pViewShell
252 : input parameter - instance of the view shell, on which the output
253 : has to be generated.
254 : */
255 : void PaintMarginArea( const SwRect& _rOutputRect,
256 : SwViewShell* _pViewShell ) const;
257 :
258 : /** paint page border and shadow
259 :
260 : @param _rPageRect
261 : input parameter - constant instance reference of the page rectangle.
262 : Generally, it's the frame area of the page, but for empty pages in print
263 : preview, this parameter is useful.
264 :
265 : @param _pViewShell
266 : input parameter - instance of the view shell, on which the output
267 : has to be generated.
268 :
269 : @param bPaintRightShadow
270 : Should we paint shadow on the right or not (used in book mode)
271 :
272 : @param bFullBottomShadow
273 : Should we have a bottom shadow of the same size as the pages or
274 : not (for right pages in book mode in a LTR environment).
275 :
276 : @param bRightSidebar
277 : Is the note sidebar on the right or not (used to adjust the
278 : shadow with & position).
279 : */
280 : static void PaintBorderAndShadow( const SwRect& _rPageRect,
281 : const SwViewShell* _pViewShell,
282 : bool bPaintLeftShadow,
283 : bool bPaintRightShadow,
284 : bool bRightSidebar );
285 :
286 : /** get bound rectangle of border and shadow for repaints
287 :
288 : @param _rPageRect
289 : input parameter - constant instance reference of the page rectangle.
290 : Generally, it's the frame area of the page, but for empty pages in print
291 : preview, this parameter is useful.
292 :
293 : @param _pViewShell
294 : input parameter - instance of the view shell, for which the rectangle
295 : has to be generated.
296 :
297 : @param _orBorderAndShadowBoundRect
298 : output parameter - instance reference of the bounded border and shadow
299 : rectangle for the given page rectangle
300 : */
301 : static void GetBorderAndShadowBoundRect( const SwRect& _rPageRect,
302 : const SwViewShell* _pViewShell,
303 : SwRect& _orBorderAndShadowBoundRect,
304 : const bool bLeftShadow,
305 : const bool bRightShadow,
306 : const bool bRightSidebar
307 : );
308 :
309 : static void PaintNotesSidebar(const SwRect& _rPageRect, SwViewShell* _pViewShell, sal_uInt16 nPageNum, bool bRight);
310 : static void PaintNotesSidebarArrows(const Point &rMiddleFirst, const Point &rMiddleSecond, SwViewShell* _pViewShell, const Color& rColorUp, const Color& rColorDown);
311 : /**
312 : asks the page on which side a margin should be shown, e.g for notes
313 : returns true for left side, false for right side
314 : */
315 : sw::sidebarwindows::SidebarPosition SidebarPosition() const;
316 :
317 : virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const SAL_OVERRIDE;
318 :
319 : static inline sal_Int8 ShadowPxWidth()
320 : {
321 : return mnShadowPxWidth;
322 : }
323 :
324 : const SwRect PrtWithoutHeaderAndFooter() const;
325 :
326 : // in case this is am empty page, this function returns the 'reference' page
327 : const SwPageFrm& GetFormatPage() const;
328 :
329 : /// If in header or footer area, it also indicates the exact area in rControl.
330 : bool IsOverHeaderFooterArea( const Point& rPt, FrameControlType &rControl ) const;
331 :
332 : // return font used to paint the "empty page" string
333 : static const vcl::Font& GetEmptyPageFont();
334 :
335 : static SwTwips GetSidebarBorderWidth( const SwViewShell* );
336 : };
337 :
338 40106 : inline SwContentFrm *SwPageFrm::FindFirstBodyContent()
339 : {
340 40106 : SwLayoutFrm *pBody = FindBodyCont();
341 40106 : return pBody ? pBody->ContainsContent() : 0;
342 : }
343 3257 : inline const SwContentFrm *SwPageFrm::FindFirstBodyContent() const
344 : {
345 3257 : const SwLayoutFrm *pBody = FindBodyCont();
346 3257 : return pBody ? pBody->ContainsContent() : 0;
347 : }
348 0 : inline const SwContentFrm *SwPageFrm::FindLastBodyContent() const
349 : {
350 0 : return const_cast<SwPageFrm*>(this)->FindLastBodyContent();
351 : }
352 14444 : inline void SwPageFrm::InvalidateFlyLayout() const
353 : {
354 14444 : const_cast<SwPageFrm*>(this)->bInvalidFlyLayout = true;
355 14444 : }
356 10906 : inline void SwPageFrm::InvalidateFlyContent() const
357 : {
358 10906 : const_cast<SwPageFrm*>(this)->bInvalidFlyContent = true;
359 10906 : }
360 7805 : inline void SwPageFrm::InvalidateFlyInCnt() const
361 : {
362 7805 : const_cast<SwPageFrm*>(this)->bInvalidFlyInCnt = true;
363 7805 : }
364 85567 : inline void SwPageFrm::InvalidateLayout() const
365 : {
366 85567 : const_cast<SwPageFrm*>(this)->bInvalidLayout = true;
367 85567 : }
368 148416 : inline void SwPageFrm::InvalidateContent() const
369 : {
370 148416 : const_cast<SwPageFrm*>(this)->bInvalidContent = true;
371 148416 : }
372 32345 : inline void SwPageFrm::InvalidateSpelling() const
373 : {
374 32345 : const_cast<SwPageFrm*>(this)->bInvalidSpelling = true;
375 32345 : }
376 :
377 32344 : inline void SwPageFrm::InvalidateSmartTags() const
378 : {
379 32344 : const_cast<SwPageFrm*>(this)->bInvalidSmartTags = true;
380 32344 : }
381 32340 : inline void SwPageFrm::InvalidateAutoCompleteWords() const
382 : {
383 32340 : const_cast<SwPageFrm*>(this)->bInvalidAutoCmplWrds = true;
384 32340 : }
385 32340 : inline void SwPageFrm::InvalidateWordCount() const
386 : {
387 32340 : const_cast<SwPageFrm*>(this)->bInvalidWordCount = true;
388 32340 : }
389 24848 : inline void SwPageFrm::ValidateFlyLayout() const
390 : {
391 24848 : const_cast<SwPageFrm*>(this)->bInvalidFlyLayout = false;
392 24848 : }
393 24848 : inline void SwPageFrm::ValidateFlyContent() const
394 : {
395 24848 : const_cast<SwPageFrm*>(this)->bInvalidFlyContent = false;
396 24848 : }
397 11318 : inline void SwPageFrm::ValidateFlyInCnt() const
398 : {
399 11318 : const_cast<SwPageFrm*>(this)->bInvalidFlyInCnt = false;
400 11318 : }
401 6593 : inline void SwPageFrm::ValidateLayout() const
402 : {
403 6593 : const_cast<SwPageFrm*>(this)->bInvalidLayout = false;
404 6593 : }
405 11318 : inline void SwPageFrm::ValidateContent() const
406 : {
407 11318 : const_cast<SwPageFrm*>(this)->bInvalidContent = false;
408 11318 : }
409 23609 : inline void SwPageFrm::ValidateSpelling() const
410 : {
411 23609 : const_cast<SwPageFrm*>(this)->bInvalidSpelling = false;
412 23609 : }
413 :
414 0 : inline void SwPageFrm::ValidateSmartTags() const
415 : {
416 0 : const_cast<SwPageFrm*>(this)->bInvalidSmartTags = false;
417 0 : }
418 48535753 : inline void SwPageFrm::ValidateAutoCompleteWords() const
419 : {
420 48535753 : const_cast<SwPageFrm*>(this)->bInvalidAutoCmplWrds = false;
421 48535753 : }
422 21761875 : inline void SwPageFrm::ValidateWordCount() const
423 : {
424 21761875 : const_cast<SwPageFrm*>(this)->bInvalidWordCount = false;
425 21761875 : }
426 :
427 26912167 : inline bool SwPageFrm::IsInvalid() const
428 : {
429 26912167 : return (bInvalidContent || bInvalidLayout || bInvalidFlyInCnt);
430 : }
431 26883915 : inline bool SwPageFrm::IsInvalidFly() const
432 : {
433 26883915 : return bInvalidFlyLayout || bInvalidFlyContent;
434 : }
435 :
436 :
437 : class SwTextGridItem;
438 :
439 : SwTextGridItem const* GetGridItem(SwPageFrm const*const);
440 :
441 : sal_uInt16 GetGridWidth(SwTextGridItem const&, SwDoc const&);
442 :
443 : #endif // INCLUDED_SW_SOURCE_CORE_INC_PAGEFRM_HXX
444 :
445 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|