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 
25 #include <SidebarWindowsTypes.hxx>
26 
27 class SwFlyFrame;
28 class SwFlyFrameFormat;
29 class SwPageDesc;
30 class SwContentFrame;
31 struct SwPosition;
32 struct SwCursorMoveState;
33 class SwAttrSetChg;
34 namespace vcl { class Font; }
35 class SwSortedObjs;
36 class SwAnchoredObject;
37 
40 class SAL_DLLPUBLIC_RTTI SwPageFrame: public SwFootnoteBossFrame
41 {
42  friend class SwFrame;
43 
44  std::unique_ptr<SwSortedObjs> m_pSortedObjs;
45 
46  SwPageDesc *m_pDesc; //PageDesc that describes the Page
47 
48  sal_uInt16 m_nPhyPageNum; // Physical page number
49 
50  bool m_bInvalidContent :1;
51  bool m_bInvalidLayout :1;
52  bool m_bInvalidFlyContent :1;
53  bool m_bInvalidFlyLayout :1;
54  bool m_bInvalidFlyInCnt :1;
55  bool m_bFootnotePage :1; // This Page is for document end footnotes
56  bool m_bEmptyPage :1; // This Page is an explicitly empty page
57  bool m_bEndNotePage :1; // 'Footnote page' for end notes
58  bool m_bInvalidSpelling :1; // We need online spelling
59  bool m_bInvalidSmartTags :1; // We need checking for smarttags
60  bool m_bInvalidAutoCmplWrds :1; // Update auto complete word list
61  bool m_bInvalidWordCount :1;
62  bool m_bHasGrid :1; // Grid for Asian layout
63 
64  static const sal_Int8 mnShadowPxWidth;
65 
66  void UpdateAttr_( const SfxPoolItem*, const SfxPoolItem*, sal_uInt8 &,
67  SwAttrSetChg *pa = nullptr, SwAttrSetChg *pb = nullptr );
68 
70  void SetColMaxFootnoteHeight();
71 
90  static void GetHorizontalShadowRect( const SwRect& _rPageRect,
91  const SwViewShell* _pViewShell,
92  OutputDevice const * pRenderContext,
93  SwRect& _orBottomShadowRect,
94  bool bPaintLeftShadow,
95  bool bPaintRightShadow,
96  bool bRightSidebar );
97 
98  virtual void DestroyImpl() override;
99  virtual ~SwPageFrame() override;
100 
101 protected:
102  virtual void MakeAll(vcl::RenderContext* pRenderContext) override;
103  virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override;
104  virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
105 
107  size_t GetContentHeight(const long nTop, const long nBottom) const;
108 
109 public:
111 
114  void PrepareHeader();
115  void PrepareFooter();
116 
117  const SwSortedObjs *GetSortedObjs() const { return m_pSortedObjs.get(); }
118  SwSortedObjs *GetSortedObjs() { return m_pSortedObjs.get(); }
119 
120  void AppendDrawObjToPage( SwAnchoredObject& _rNewObj );
121  void RemoveDrawObjFromPage( SwAnchoredObject& _rToRemoveObj );
122 
123  void AppendFlyToPage( SwFlyFrame *pNew );
124  void RemoveFlyFromPage( SwFlyFrame *pToRemove );
125  void MoveFly( SwFlyFrame *pToMove, SwPageFrame *pDest ); // Optimized Remove/Append
126 
127  void SetPageDesc( SwPageDesc *, SwFrameFormat * );
128  SwPageDesc *GetPageDesc() { return m_pDesc; }
129  const SwPageDesc *GetPageDesc() const { return m_pDesc; }
131 
132  SwContentFrame *FindLastBodyContent();
133  inline SwContentFrame *FindFirstBodyContent();
134  inline const SwContentFrame *FindFirstBodyContent() const;
135  inline const SwContentFrame *FindLastBodyContent() const;
136 
137  SwRect GetBoundRect(OutputDevice const * pOutputDevice) const;
138 
139  // Specialized GetContentPos() for Field in Frames
140  void GetContentPosition( const Point &rPt, SwPosition &rPos ) const;
141 
142  bool IsEmptyPage() const { return m_bEmptyPage; } // Explicitly empty page
143 
144  void UpdateFootnoteNum();
145 
148  void PreparePage( bool bFootnote );
149 
150  // Sends a Prepare() to all ContentFrames caused by a changed register template
151  void PrepareRegisterChg();
152 
153  // Appends a fly frame - the given one or a new one - at the page frame.
154  // Needed for <Modify> and <MakeFrames>
155  // - return value not needed any more
156  // - second parameter is of type <SwFlyFrameFormat*>
157  // - third parameter only needed for assertion, but calling method assures
158  // this assertion. Thus, delete it.
159  void PlaceFly( SwFlyFrame* pFly, SwFlyFrameFormat* pFormat );
160 
161  virtual bool GetCursorOfst( SwPosition *, Point&,
162  SwCursorMoveState* = nullptr, bool bTestBackground = false ) const override;
164  virtual bool GetInfo( SfxPoolItem& ) const override;
165 
166  virtual void Cut() override;
167  virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
168  virtual void CheckDirection( bool bVert ) override;
169  void CheckGrid( bool bInvalidate );
170  void PaintGrid( OutputDevice const * pOut, SwRect const &rRect ) const;
171  bool HasGrid() const { return m_bHasGrid; }
172 
173  void PaintDecorators( ) const;
174  virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) const override;
175  virtual void PaintBreak() const override;
176 
178  void RefreshExtraData( const SwRect & ) const;
179 
181  void RefreshSubsidiary( const SwRect& ) const;
182 
184  bool IsFootnotePage() const { return m_bFootnotePage; }
185  bool IsEndNotePage() const { return m_bEndNotePage; }
186  void SetFootnotePage( bool b ) { m_bFootnotePage = b; }
187  void SetEndNotePage( bool b ) { m_bEndNotePage = b; }
188 
189  sal_uInt16 GetPhyPageNum() const { return m_nPhyPageNum;}
190  void SetPhyPageNum( sal_uInt16 nNum ) { m_nPhyPageNum = nNum;}
191 
194  inline void InvalidateFlyLayout() const;
195  inline void InvalidateFlyContent() const;
196  inline void InvalidateFlyInCnt() const;
197  inline void InvalidateLayout() const;
198  inline void InvalidateContent() const;
199  inline void InvalidateSpelling() const;
200  inline void InvalidateSmartTags() const;
201  inline void InvalidateAutoCompleteWords() const;
202  inline void InvalidateWordCount() const;
203  inline void ValidateFlyLayout() const;
204  inline void ValidateFlyContent() const;
205  inline void ValidateFlyInCnt() const;
206  inline void ValidateLayout() const;
207  inline void ValidateContent() const;
208  inline void ValidateSpelling() const;
209  inline void ValidateSmartTags() const;
210  inline void ValidateAutoCompleteWords() const;
211  inline void ValidateWordCount() const;
212  inline bool IsInvalid() const;
213  inline bool IsInvalidFly() const;
214  bool IsRightShadowNeeded() const;
215  bool IsLeftShadowNeeded() const;
216  bool IsInvalidFlyLayout() const { return m_bInvalidFlyLayout; }
217  bool IsInvalidFlyContent() const { return m_bInvalidFlyContent; }
218  bool IsInvalidFlyInCnt() const { return m_bInvalidFlyInCnt; }
219  bool IsInvalidLayout() const { return m_bInvalidLayout; }
220  bool IsInvalidContent() const { return (m_bInvalidContent || m_bInvalidFlyInCnt); }
221  bool IsInvalidSpelling() const { return m_bInvalidSpelling; }
222  bool IsInvalidSmartTags() const { return m_bInvalidSmartTags; }
223  bool IsInvalidAutoCompleteWords() const { return m_bInvalidAutoCmplWrds; }
224  bool IsInvalidWordCount() const { return m_bInvalidWordCount; }
225 
233  const Color GetDrawBackgrdColor() const;
234 
248  void PaintMarginArea( const SwRect& _rOutputRect,
249  SwViewShell const * _pViewShell ) const;
250 
273  static void PaintBorderAndShadow( const SwRect& _rPageRect,
274  const SwViewShell* _pViewShell,
275  bool bPaintLeftShadow,
276  bool bPaintRightShadow,
277  bool bRightSidebar );
278 
294  static void GetBorderAndShadowBoundRect( const SwRect& _rPageRect,
295  const SwViewShell* _pViewShell,
296  OutputDevice const * pRenderContext,
297  SwRect& _orBorderAndShadowBoundRect,
298  const bool bLeftShadow,
299  const bool bRightShadow,
300  const bool bRightSidebar
301  );
302 
303  static void PaintNotesSidebar(const SwRect& _rPageRect, SwViewShell* _pViewShell, sal_uInt16 nPageNum, bool bRight);
304  static void PaintNotesSidebarArrows(const Point &rMiddleFirst, const Point &rMiddleSecond, SwViewShell const * _pViewShell, const Color& rColorUp, const Color& rColorDown);
310 
311  virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const override;
312 
313  const SwRect PrtWithoutHeaderAndFooter() const;
314 
315  // in case this is am empty page, this function returns the 'reference' page
316  const SwPageFrame& GetFormatPage() const;
317 
320  bool IsOverHeaderFooterArea( const Point& rPt, FrameControlType &rControl ) const;
321 
322  // return font used to paint the "empty page" string
323  static const vcl::Font& GetEmptyPageFont();
324 
325  static SwTwips GetSidebarBorderWidth( const SwViewShell* );
326 
329  bool CheckPageHeightValidForHideWhitespace(SwTwips nDiff);
330 };
331 
333 {
334  SwLayoutFrame *pBody = FindBodyCont();
335  return pBody ? pBody->ContainsContent() : nullptr;
336 }
338 {
339  const SwLayoutFrame *pBody = FindBodyCont();
340  return pBody ? pBody->ContainsContent() : nullptr;
341 }
343 {
344  return const_cast<SwPageFrame*>(this)->FindLastBodyContent();
345 }
347 {
348  const_cast<SwPageFrame*>(this)->m_bInvalidFlyLayout = true;
349 }
351 {
352  const_cast<SwPageFrame*>(this)->m_bInvalidFlyContent = true;
353 }
355 {
356  const_cast<SwPageFrame*>(this)->m_bInvalidFlyInCnt = true;
357 }
358 inline void SwPageFrame::InvalidateLayout() const
359 {
360  const_cast<SwPageFrame*>(this)->m_bInvalidLayout = true;
361 }
363 {
364  const_cast<SwPageFrame*>(this)->m_bInvalidContent = true;
365 }
367 {
368  const_cast<SwPageFrame*>(this)->m_bInvalidSpelling = true;
369 }
370 
372 {
373  const_cast<SwPageFrame*>(this)->m_bInvalidSmartTags = true;
374 }
376 {
377  const_cast<SwPageFrame*>(this)->m_bInvalidAutoCmplWrds = true;
378 }
380 {
381  const_cast<SwPageFrame*>(this)->m_bInvalidWordCount = true;
382 }
384 {
385  const_cast<SwPageFrame*>(this)->m_bInvalidFlyLayout = false;
386 }
388 {
389  const_cast<SwPageFrame*>(this)->m_bInvalidFlyContent = false;
390 }
391 inline void SwPageFrame::ValidateFlyInCnt() const
392 {
393  const_cast<SwPageFrame*>(this)->m_bInvalidFlyInCnt = false;
394 }
395 inline void SwPageFrame::ValidateLayout() const
396 {
397  const_cast<SwPageFrame*>(this)->m_bInvalidLayout = false;
398 }
399 inline void SwPageFrame::ValidateContent() const
400 {
401  const_cast<SwPageFrame*>(this)->m_bInvalidContent = false;
402 }
403 inline void SwPageFrame::ValidateSpelling() const
404 {
405  const_cast<SwPageFrame*>(this)->m_bInvalidSpelling = false;
406 }
407 
409 {
410  const_cast<SwPageFrame*>(this)->m_bInvalidSmartTags = false;
411 }
413 {
414  const_cast<SwPageFrame*>(this)->m_bInvalidAutoCmplWrds = false;
415 }
417 {
418  const_cast<SwPageFrame*>(this)->m_bInvalidWordCount = false;
419 }
420 
421 inline bool SwPageFrame::IsInvalid() const
422 {
424 }
425 inline bool SwPageFrame::IsInvalidFly() const
426 {
428 }
429 
430 
431 class SwTextGridItem;
432 
433 SwTextGridItem const* GetGridItem(SwPageFrame const*const);
434 
435 sal_uInt16 GetGridWidth(SwTextGridItem const&, SwDoc const&);
436 
437 #endif // INCLUDED_SW_SOURCE_CORE_INC_PAGEFRM_HXX
438 
439 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class of the Writer layout elements.
Definition: frame.hxx:295
void SetFootnotePage(bool b)
Definition: pagefrm.hxx:186
Marks a position in the document model.
Definition: pam.hxx:35
bool IsInvalidWordCount() const
Definition: pagefrm.hxx:224
signed char sal_Int8
void ValidateSpelling() const
Definition: pagefrm.hxx:403
bool m_bInvalidFlyLayout
Definition: pagefrm.hxx:53
virtual void Modify(const SfxPoolItem *, const SfxPoolItem *) override
Definition: wsfrm.cxx:466
Definition: doc.hxx:185
void ValidateFlyContent() const
Definition: pagefrm.hxx:387
void ValidateContent() const
Definition: pagefrm.hxx:399
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: wsfrm.cxx:1289
long SwTwips
Definition: swtypes.hxx:49
This class is used as parameter for creation of a block cursor selection.
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: calbck.cxx:108
bool IsFootnotePage() const
Foot note interface.
Definition: pagefrm.hxx:184
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
SwContentFrame * FindFirstBodyContent()
Definition: pagefrm.hxx:332
void InvalidateFlyInCnt() const
Definition: pagefrm.hxx:354
bool m_bInvalidLayout
Definition: pagefrm.hxx:51
static bool bFootnote
Definition: insfnote.cxx:40
void RefreshExtraData(const SwRect &) const
Definition: paintfrm.cxx:6918
bool m_bInvalidWordCount
Definition: pagefrm.hxx:61
void ValidateWordCount() const
Definition: pagefrm.hxx:416
sal_uInt16 GetPhyPageNum() const
Definition: pagefrm.hxx:189
void ValidateAutoCompleteWords() const
Definition: pagefrm.hxx:412
bool HasGrid() const
Definition: pagefrm.hxx:171
wrapper class for the positioning of Writer fly frames and drawing objects
bool IsInvalidFlyInCnt() const
Definition: pagefrm.hxx:218
bool IsEmptyPage() const
Definition: pagefrm.hxx:142
bool IsInvalidAutoCompleteWords() const
Definition: pagefrm.hxx:223
void InvalidateFlyContent() const
Definition: pagefrm.hxx:350
sal_uInt16 m_nPhyPageNum
Definition: pagefrm.hxx:48
bool m_bInvalidSpelling
Definition: pagefrm.hxx:58
bool IsInvalidSpelling() const
Definition: pagefrm.hxx:221
bool IsInvalidSmartTags() const
Definition: pagefrm.hxx:222
virtual void DestroyImpl() override
Definition: ssfrm.cxx:499
void InvalidateLayout() const
Definition: pagefrm.hxx:358
void InvalidateContent() const
Definition: pagefrm.hxx:362
bool IsInvalidContent() const
Definition: pagefrm.hxx:220
void ValidateFlyLayout() const
Definition: pagefrm.hxx:383
bool IsInvalidFly() const
Definition: pagefrm.hxx:425
bool IsInvalidFlyContent() const
Definition: pagefrm.hxx:217
void InvalidateAutoCompleteWords() const
Definition: pagefrm.hxx:375
Style of a layout element.
Definition: frmfmt.hxx:57
const SwSortedObjs * GetSortedObjs() const
Definition: pagefrm.hxx:117
void InvalidateSpelling() const
Definition: pagefrm.hxx:366
void ValidateFlyInCnt() const
Definition: pagefrm.hxx:391
virtual void Cut() override
Definition: wsfrm.cxx:1386
SwTextGridItem const * GetGridItem(SwPageFrame const *const)
Definition: pagechg.cxx:2516
SwPageDesc * GetPageDesc()
Definition: pagefrm.hxx:128
void InvalidateSmartTags() const
Definition: pagefrm.hxx:371
bool IsEndNotePage() const
Definition: pagefrm.hxx:185
bool m_bInvalidFlyInCnt
Definition: pagefrm.hxx:54
void SetPhyPageNum(sal_uInt16 nNum)
Definition: pagefrm.hxx:190
virtual bool GetCursorOfst(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const override
Searches the ContentFrame owning the PrtArea containing the point.
Definition: trvlfrm.cxx:146
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:346
SwPageDesc * m_pDesc
Definition: pagefrm.hxx:46
A page of the document layout.
Definition: pagefrm.hxx:40
SwLayoutFrame * FindBodyCont()
Searches the first ContentFrame in BodyText below the page.
Definition: findfrm.cxx:42
bool m_bInvalidContent
Definition: pagefrm.hxx:50
bool IsInvalidFlyLayout() const
Definition: pagefrm.hxx:216
void ValidateLayout() const
Definition: pagefrm.hxx:395
virtual void CheckDirection(bool bVert)
Definition: wsfrm.cxx:381
void ValidateSmartTags() const
Definition: pagefrm.hxx:408
FrameControlType
Definition: swtypes.hxx:246
SwContentFrame * FindLastBodyContent()
Searches the last ContentFrame in BodyText below the page.
Definition: findfrm.cxx:51
virtual void PaintSubsidiaryLines(const SwPageFrame *, const SwRect &) const
Definition: paintfrm.cxx:6763
general base class for all free-flowing frames
Definition: flyfrm.hxx:60
unsigned char sal_uInt8
bool m_bInvalidAutoCmplWrds
Definition: pagefrm.hxx:60
virtual void PaintBreak() const
Definition: paintfrm.cxx:3615
bool m_bInvalidFlyContent
Definition: pagefrm.hxx:52
static const sal_Int8 mnShadowPxWidth
Definition: pagefrm.hxx:64
sal_uInt16 GetGridWidth(SwTextGridItem const &, SwDoc const &)
Definition: pagechg.cxx:2530
virtual bool GetInfo(SfxPoolItem &) const
Definition: calbck.hxx:164
bool SetPageDesc(const css::uno::Any &rValue, SwDoc &rDoc, SfxItemSet &rSet)
bool IsInvalid() const
Definition: pagefrm.hxx:421
const SwPageDesc * GetPageDesc() const
Definition: pagefrm.hxx:129
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:66
void InvalidateWordCount() const
Definition: pagefrm.hxx:379
bool m_bInvalidSmartTags
Definition: pagefrm.hxx:59
void SetEndNotePage(bool b)
Definition: pagefrm.hxx:187
virtual void MakeAll(vcl::RenderContext *pRenderContext) override
Definition: calcmove.cxx:890
class for collecting anchored objects
Definition: sortedobjs.hxx:48
bool IsInvalidLayout() const
Definition: pagefrm.hxx:219
static SwPageDesc * FindPageDesc(SwDoc *pDoc, sal_uInt16 nPoolId)
Definition: htmlcss1.cxx:1328
std::unique_ptr< SwSortedObjs > m_pSortedObjs
Definition: pagefrm.hxx:44
SwSortedObjs * GetSortedObjs()
Definition: pagefrm.hxx:118
virtual bool FillSelection(SwSelectionList &rList, const SwRect &rRect) const override
Definition: trvlfrm.cxx:361