LibreOffice Module sw (master)  1
pagefrm.hxx
Go to the documentation of this file.
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 "hffrm.hxx"
25 
26 #include <SidebarWindowsTypes.hxx>
27 
28 class SwFlyFrame;
29 class SwFlyFrameFormat;
30 class SwPageDesc;
31 class SwContentFrame;
32 struct SwPosition;
33 struct SwCursorMoveState;
34 class SwAttrSetChg;
35 namespace vcl { class Font; }
36 class SwSortedObjs;
37 class SwAnchoredObject;
38 
40 {
41  NONE = 0x00,
42  InvalidatePrt = 0x01,
43  SetCompletePaint = 0x02,
44  InvalidateNextPos = 0x04,
45  PrepareHeader = 0x08,
46  PrepareFooter = 0x10,
47  CheckGrid = 0x20,
48  InvalidateGrid = 0x40,
49 };
50 
51 namespace o3tl {
52  template<> struct typed_flags<SwPageFrameInvFlags> : is_typed_flags<SwPageFrameInvFlags, 0x007f> {};
53 }
54 
57 class SAL_DLLPUBLIC_RTTI SwPageFrame final: public SwFootnoteBossFrame
58 {
59  friend class SwFrame;
60 
61  std::unique_ptr<SwSortedObjs> m_pSortedObjs;
62 
63  SwPageDesc *m_pDesc; //PageDesc that describes the Page
64 
66  sal_uInt16 m_nPhyPageNum;
67 
68  bool m_bInvalidContent :1;
69  bool m_bInvalidLayout :1;
70  bool m_bInvalidFlyContent :1;
71  bool m_bInvalidFlyLayout :1;
72  bool m_bInvalidFlyInCnt :1;
73  bool m_bFootnotePage :1; // This Page is for document end footnotes
74  bool m_bEmptyPage :1; // This Page is an explicitly empty page
75  bool m_bEndNotePage :1; // 'Footnote page' for end notes
76  bool m_bInvalidSpelling :1; // We need online spelling
77  bool m_bInvalidSmartTags :1; // We need checking for smarttags
78  bool m_bInvalidAutoCmplWrds :1; // Update auto complete word list
79  bool m_bInvalidWordCount :1;
80  bool m_bHasGrid :1; // Grid for Asian layout
81 
82  static const sal_Int8 snShadowPxWidth;
83 
84  void UpdateAttr_( const SfxPoolItem*, const SfxPoolItem*, SwPageFrameInvFlags &,
85  SwAttrSetChg *pa = nullptr, SwAttrSetChg *pb = nullptr );
86 
88  void SetColMaxFootnoteHeight();
89 
108  static void GetHorizontalShadowRect( const SwRect& _rPageRect,
109  const SwViewShell* _pViewShell,
110  OutputDevice const * pRenderContext,
111  SwRect& _orBottomShadowRect,
112  bool bPaintLeftShadow,
113  bool bPaintRightShadow,
114  bool bRightSidebar );
115 
116  virtual void DestroyImpl() override;
117  virtual ~SwPageFrame() override;
118  virtual void MakeAll(vcl::RenderContext* pRenderContext) override;
119  virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
120 
122  size_t GetContentHeight(const tools::Long nTop, const tools::Long nBottom) const;
123 
124 public:
126 
129  void PrepareHeader();
130  void PrepareFooter();
131 
132  const SwSortedObjs *GetSortedObjs() const { return m_pSortedObjs.get(); }
133  SwSortedObjs *GetSortedObjs() { return m_pSortedObjs.get(); }
134 
135  void AppendDrawObjToPage( SwAnchoredObject& _rNewObj );
136  void RemoveDrawObjFromPage( SwAnchoredObject& _rToRemoveObj );
137 
138  void AppendFlyToPage( SwFlyFrame *pNew );
139  void RemoveFlyFromPage( SwFlyFrame *pToRemove );
140  void MoveFly( SwFlyFrame *pToMove, SwPageFrame *pDest ); // Optimized Remove/Append
141 
142  void SetPageDesc( SwPageDesc *, SwFrameFormat * );
143  SwPageDesc *GetPageDesc() { return m_pDesc; }
144  const SwPageDesc *GetPageDesc() const { return m_pDesc; }
146 
147  SwContentFrame *FindLastBodyContent();
148  inline SwContentFrame *FindFirstBodyContent();
149  inline const SwContentFrame *FindFirstBodyContent() const;
150  inline const SwContentFrame *FindLastBodyContent() const;
151 
152  SwRect GetBoundRect(OutputDevice const * pOutputDevice) const;
153 
154  // Specialized GetContentPos() for Field in Frames
155  void GetContentPosition( const Point &rPt, SwPosition &rPos ) const;
156 
157  bool IsEmptyPage() const { return m_bEmptyPage; } // Explicitly empty page
158 
159  void UpdateFootnoteNum();
160 
163  void PreparePage( bool bFootnote );
164 
165  // Sends a Prepare() to all ContentFrames caused by a changed register template
166  void PrepareRegisterChg();
167 
168  // Appends a fly frame - the given one or a new one - at the page frame.
169  // Needed for <Modify> and <MakeFrames>
170  // - return value not needed any more
171  // - second parameter is of type <SwFlyFrameFormat*>
172  // - third parameter only needed for assertion, but calling method assures
173  // this assertion. Thus, delete it.
174  void PlaceFly( SwFlyFrame* pFly, SwFlyFrameFormat* pFormat );
175 
176  virtual bool GetModelPositionForViewPoint( SwPosition *, Point&,
177  SwCursorMoveState* = nullptr, bool bTestBackground = false ) const override;
179  virtual bool GetInfo( SfxPoolItem& ) const override;
180 
181  virtual void Cut() override;
182  virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
183  virtual void CheckDirection( bool bVert ) override;
184  void CheckGrid( bool bInvalidate );
185  void PaintGrid( OutputDevice const * pOut, SwRect const &rRect ) const;
186  bool HasGrid() const { return m_bHasGrid; }
187 
188  void PaintDecorators( ) const;
189  virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) const override;
190  virtual void PaintBreak() const override;
191 
193  void RefreshExtraData( const SwRect & ) const;
194 
196  void RefreshSubsidiary( const SwRect& ) const;
197 
199  bool IsFootnotePage() const { return m_bFootnotePage; }
200  bool IsEndNotePage() const { return m_bEndNotePage; }
201  void SetFootnotePage( bool b ) { m_bFootnotePage = b; }
202  void SetEndNotePage( bool b ) { m_bEndNotePage = b; }
203 
204  sal_uInt16 GetPhyPageNum() const { return m_nPhyPageNum;}
205  void SetPhyPageNum( sal_uInt16 nNum ) { m_nPhyPageNum = nNum;}
206 
209  inline void InvalidateFlyLayout() const;
210  inline void InvalidateFlyContent() const;
211  inline void InvalidateFlyInCnt() const;
212  inline void InvalidateLayout() const;
213  inline void InvalidateContent() const;
214  inline void InvalidateSpelling() const;
215  inline void InvalidateSmartTags() const;
216  inline void InvalidateAutoCompleteWords() const;
217  inline void InvalidateWordCount() const;
218  inline void ValidateFlyLayout() const;
219  inline void ValidateFlyContent() const;
220  inline void ValidateFlyInCnt() const;
221  inline void ValidateLayout() const;
222  inline void ValidateContent() const;
223  inline void ValidateSpelling() const;
224  inline void ValidateSmartTags() const;
225  inline void ValidateAutoCompleteWords() const;
226  inline void ValidateWordCount() const;
227  inline bool IsInvalid() const;
228  inline bool IsInvalidFly() const;
229  bool IsRightShadowNeeded() const;
230  bool IsLeftShadowNeeded() const;
231  bool IsInvalidFlyLayout() const { return m_bInvalidFlyLayout; }
232  bool IsInvalidFlyContent() const { return m_bInvalidFlyContent; }
233  bool IsInvalidFlyInCnt() const { return m_bInvalidFlyInCnt; }
234  bool IsInvalidLayout() const { return m_bInvalidLayout; }
235  bool IsInvalidContent() const { return (m_bInvalidContent || m_bInvalidFlyInCnt); }
236  bool IsInvalidSpelling() const { return m_bInvalidSpelling; }
237  bool IsInvalidSmartTags() const { return m_bInvalidSmartTags; }
238  bool IsInvalidAutoCompleteWords() const { return m_bInvalidAutoCmplWrds; }
239  bool IsInvalidWordCount() const { return m_bInvalidWordCount; }
240 
248  Color GetDrawBackgroundColor() const;
249 
263  void PaintMarginArea( const SwRect& _rOutputRect,
264  SwViewShell const * _pViewShell ) const;
265 
288  static void PaintBorderAndShadow( const SwRect& _rPageRect,
289  const SwViewShell* _pViewShell,
290  bool bPaintLeftShadow,
291  bool bPaintRightShadow,
292  bool bRightSidebar );
293 
309  static void GetBorderAndShadowBoundRect( const SwRect& _rPageRect,
310  const SwViewShell* _pViewShell,
311  OutputDevice const * pRenderContext,
312  SwRect& _orBorderAndShadowBoundRect,
313  const bool bLeftShadow,
314  const bool bRightShadow,
315  const bool bRightSidebar
316  );
317 
318  static void PaintNotesSidebar(const SwRect& _rPageRect, SwViewShell* _pViewShell, sal_uInt16 nPageNum, bool bRight);
319  static void PaintNotesSidebarArrows(const Point &rMiddleFirst, const Point &rMiddleSecond, SwViewShell const * _pViewShell, const Color& rColorUp, const Color& rColorDown);
325 
326  virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const override;
327 
328  SwRect PrtWithoutHeaderAndFooter() const;
329 
330  // in case this is an empty page, this function returns the 'reference' page
331  const SwPageFrame& GetFormatPage() const;
332 
335  bool IsOverHeaderFooterArea( const Point& rPt, FrameControlType &rControl ) const;
336 
337  // return font used to paint the "empty page" string
338  static const vcl::Font& GetEmptyPageFont();
339 
340  static SwTwips GetSidebarBorderWidth( const SwViewShell* );
341 
344  bool CheckPageHeightValidForHideWhitespace(SwTwips nDiff);
345 
346  const SwHeaderFrame* GetHeaderFrame() const;
347  const SwFooterFrame* GetFooterFrame() const;
348 };
349 
351 {
352  SwLayoutFrame *pBody = FindBodyCont();
353  return pBody ? pBody->ContainsContent() : nullptr;
354 }
356 {
357  const SwLayoutFrame *pBody = FindBodyCont();
358  return pBody ? pBody->ContainsContent() : nullptr;
359 }
361 {
362  return const_cast<SwPageFrame*>(this)->FindLastBodyContent();
363 }
365 {
366  const_cast<SwPageFrame*>(this)->m_bInvalidFlyLayout = true;
367 }
369 {
370  const_cast<SwPageFrame*>(this)->m_bInvalidFlyContent = true;
371 }
373 {
374  const_cast<SwPageFrame*>(this)->m_bInvalidFlyInCnt = true;
375 }
376 inline void SwPageFrame::InvalidateLayout() const
377 {
378  const_cast<SwPageFrame*>(this)->m_bInvalidLayout = true;
379 }
381 {
382  const_cast<SwPageFrame*>(this)->m_bInvalidContent = true;
383 }
385 {
386  const_cast<SwPageFrame*>(this)->m_bInvalidSpelling = true;
387 }
388 
390 {
391  const_cast<SwPageFrame*>(this)->m_bInvalidSmartTags = true;
392 }
394 {
395  const_cast<SwPageFrame*>(this)->m_bInvalidAutoCmplWrds = true;
396 }
398 {
399  const_cast<SwPageFrame*>(this)->m_bInvalidWordCount = true;
400 }
402 {
403  const_cast<SwPageFrame*>(this)->m_bInvalidFlyLayout = false;
404 }
406 {
407  const_cast<SwPageFrame*>(this)->m_bInvalidFlyContent = false;
408 }
409 inline void SwPageFrame::ValidateFlyInCnt() const
410 {
411  const_cast<SwPageFrame*>(this)->m_bInvalidFlyInCnt = false;
412 }
413 inline void SwPageFrame::ValidateLayout() const
414 {
415  const_cast<SwPageFrame*>(this)->m_bInvalidLayout = false;
416 }
417 inline void SwPageFrame::ValidateContent() const
418 {
419  const_cast<SwPageFrame*>(this)->m_bInvalidContent = false;
420 }
421 inline void SwPageFrame::ValidateSpelling() const
422 {
423  const_cast<SwPageFrame*>(this)->m_bInvalidSpelling = false;
424 }
425 
427 {
428  const_cast<SwPageFrame*>(this)->m_bInvalidSmartTags = false;
429 }
431 {
432  const_cast<SwPageFrame*>(this)->m_bInvalidAutoCmplWrds = false;
433 }
435 {
436  const_cast<SwPageFrame*>(this)->m_bInvalidWordCount = false;
437 }
438 
439 inline bool SwPageFrame::IsInvalid() const
440 {
442 }
443 inline bool SwPageFrame::IsInvalidFly() const
444 {
446 }
447 
448 
449 class SwTextGridItem;
450 
451 SwTextGridItem const* GetGridItem(SwPageFrame const*const);
452 
453 sal_uInt16 GetGridWidth(SwTextGridItem const&, SwDoc const&);
454 
455 namespace sw { bool IsPageFrameEmpty(SwPageFrame const& rPage); }
456 
457 
458 #endif // INCLUDED_SW_SOURCE_CORE_INC_PAGEFRM_HXX
459 
460 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class of the Writer layout elements.
Definition: frame.hxx:315
void SetFootnotePage(bool b)
Definition: pagefrm.hxx:201
Marks a position in the document model.
Definition: pam.hxx:36
Header in the document layout, inside a page.
Definition: hffrm.hxx:43
bool IsInvalidWordCount() const
Definition: pagefrm.hxx:239
signed char sal_Int8
void ValidateSpelling() const
Definition: pagefrm.hxx:421
bool m_bInvalidFlyLayout
Definition: pagefrm.hxx:71
long Long
Definition: doc.hxx:188
void ValidateFlyContent() const
Definition: pagefrm.hxx:405
void ValidateContent() const
Definition: pagefrm.hxx:417
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: wsfrm.cxx:1337
This class is used as parameter for creation of a block cursor selection.
Dialog to specify the properties of date form field.
bool IsFootnotePage() const
Foot note interface.
Definition: pagefrm.hxx:199
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
SwContentFrame * FindFirstBodyContent()
Definition: pagefrm.hxx:350
void InvalidateFlyInCnt() const
Definition: pagefrm.hxx:372
bool m_bInvalidLayout
Definition: pagefrm.hxx:69
static bool bFootnote
Definition: insfnote.cxx:33
void RefreshExtraData(const SwRect &) const
Definition: paintfrm.cxx:7065
bool m_bInvalidWordCount
Definition: pagefrm.hxx:79
void ValidateWordCount() const
Definition: pagefrm.hxx:434
sal_uInt16 GetPhyPageNum() const
Definition: pagefrm.hxx:204
void ValidateAutoCompleteWords() const
Definition: pagefrm.hxx:430
bool HasGrid() const
Definition: pagefrm.hxx:186
wrapper class for the positioning of Writer fly frames and drawing objects
bool IsInvalidFlyInCnt() const
Definition: pagefrm.hxx:233
bool IsEmptyPage() const
Definition: pagefrm.hxx:157
bool IsInvalidAutoCompleteWords() const
Definition: pagefrm.hxx:238
void InvalidateFlyContent() const
Definition: pagefrm.hxx:368
sal_uInt16 m_nPhyPageNum
Physical page number: index into list of SwRootFrame lowers.
Definition: pagefrm.hxx:66
bool m_bInvalidSpelling
Definition: pagefrm.hxx:76
bool IsInvalidSpelling() const
Definition: pagefrm.hxx:236
bool IsInvalidSmartTags() const
Definition: pagefrm.hxx:237
virtual void DestroyImpl() override
Definition: ssfrm.cxx:481
void InvalidateLayout() const
Definition: pagefrm.hxx:376
void InvalidateContent() const
Definition: pagefrm.hxx:380
bool IsInvalidContent() const
Definition: pagefrm.hxx:235
void ValidateFlyLayout() const
Definition: pagefrm.hxx:401
bool IsInvalidFly() const
Definition: pagefrm.hxx:443
bool IsInvalidFlyContent() const
Definition: pagefrm.hxx:232
void InvalidateAutoCompleteWords() const
Definition: pagefrm.hxx:393
Style of a layout element.
Definition: frmfmt.hxx:59
const SwSortedObjs * GetSortedObjs() const
Definition: pagefrm.hxx:132
void InvalidateSpelling() const
Definition: pagefrm.hxx:384
void ValidateFlyInCnt() const
Definition: pagefrm.hxx:409
virtual void Cut() override
Definition: wsfrm.cxx:1434
SwTextGridItem const * GetGridItem(SwPageFrame const *const)
Definition: pagechg.cxx:2574
SwPageDesc * GetPageDesc()
Definition: pagefrm.hxx:143
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: wsfrm.cxx:474
void InvalidateSmartTags() const
Definition: pagefrm.hxx:389
bool IsEndNotePage() const
Definition: pagefrm.hxx:200
bool m_bInvalidFlyInCnt
Definition: pagefrm.hxx:72
void SetPhyPageNum(sal_uInt16 nNum)
Definition: pagefrm.hxx:205
friend class SwPageFrame
Definition: ftnboss.hxx:53
void InvalidateFlyLayout() const
Validate, invalidate and query the Page status Layout/Content and Fly/non-Fly respectively are inspec...
Definition: pagefrm.hxx:364
SwPageDesc * m_pDesc
Definition: pagefrm.hxx:63
A page of the document layout.
Definition: pagefrm.hxx:57
tools::Long SwTwips
Definition: swtypes.hxx:52
SwLayoutFrame * FindBodyCont()
Searches the first ContentFrame in BodyText below the page.
Definition: findfrm.cxx:43
bool m_bInvalidContent
Definition: pagefrm.hxx:68
bool IsInvalidFlyLayout() const
Definition: pagefrm.hxx:231
void ValidateLayout() const
Definition: pagefrm.hxx:413
virtual void CheckDirection(bool bVert)
Definition: wsfrm.cxx:389
void ValidateSmartTags() const
Definition: pagefrm.hxx:426
FrameControlType
Definition: swtypes.hxx:234
SwContentFrame * FindLastBodyContent()
Searches the last ContentFrame in BodyText below the page.
Definition: findfrm.cxx:52
virtual void PaintSubsidiaryLines(const SwPageFrame *, const SwRect &) const
Definition: paintfrm.cxx:6911
general base class for all free-flowing frames
Definition: flyfrm.hxx:78
static const sal_Int8 snShadowPxWidth
Definition: pagefrm.hxx:82
bool IsPageFrameEmpty(SwPageFrame const &rPage)
check if there's content on the page that requires it to exist
Definition: pagechg.cxx:995
unsigned char sal_uInt8
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const override
Searches the ContentFrame owning the PrtArea containing the point.
Definition: trvlfrm.cxx:151
bool m_bInvalidAutoCmplWrds
Definition: pagefrm.hxx:78
virtual void PaintBreak() const
Definition: paintfrm.cxx:3734
bool m_bInvalidFlyContent
Definition: pagefrm.hxx:70
sal_uInt16 GetGridWidth(SwTextGridItem const &, SwDoc const &)
Definition: pagechg.cxx:2588
virtual bool GetInfo(SfxPoolItem &) const
Definition: calbck.hxx:172
SwPageFrameInvFlags
Definition: pagefrm.hxx:39
bool SetPageDesc(const css::uno::Any &rValue, SwDoc &rDoc, SfxItemSet &rSet)
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
Definition: layfrm.hxx:35
bool IsInvalid() const
Definition: pagefrm.hxx:439
const SwPageDesc * GetPageDesc() const
Definition: pagefrm.hxx:144
const SwContentFrame * ContainsContent() const
Checks if the frame contains one or more ContentFrame's anywhere in his subsidiary structure; if so t...
Definition: findfrm.cxx:67
void InvalidateWordCount() const
Definition: pagefrm.hxx:397
bool m_bInvalidSmartTags
Definition: pagefrm.hxx:77
void SetEndNotePage(bool b)
Definition: pagefrm.hxx:202
virtual void MakeAll(vcl::RenderContext *pRenderContext) override
Definition: calcmove.cxx:957
class for collecting anchored objects
Definition: sortedobjs.hxx:48
Footer in the document layout, inside a page.
Definition: hffrm.hxx:50
bool IsInvalidLayout() const
Definition: pagefrm.hxx:234
static SwPageDesc * FindPageDesc(SwDoc *pDoc, sal_uInt16 nPoolId)
Definition: htmlcss1.cxx:1327
std::unique_ptr< SwSortedObjs > m_pSortedObjs
Definition: pagefrm.hxx:61
SwSortedObjs * GetSortedObjs()
Definition: pagefrm.hxx:133
virtual bool FillSelection(SwSelectionList &rList, const SwRect &rRect) const override
Definition: trvlfrm.cxx:367