LibreOffice Module sw (master)  1
rootfrm.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_ROOTFRM_HXX
20 #define INCLUDED_SW_SOURCE_CORE_INC_ROOTFRM_HXX
21 
22 #include "layfrm.hxx"
23 #include <viewsh.hxx>
24 #include <doc.hxx>
25 #include <IDocumentTimerAccess.hxx>
26 #include <o3tl/typed_flags_set.hxx>
27 #include <tools/UnitConversion.hxx>
28 #include <set>
29 #include <vector>
30 
31 class SwContentFrame;
32 class SdrPage;
33 class SwFrameFormat;
34 class SwPaM;
35 class SwCursor;
36 class SwShellCursor;
37 class SwTableCursor;
38 class SwLayVout;
39 class SwViewOption;
40 class SwSelectionList;
41 struct SwPosition;
42 struct SwCursorMoveState;
43 
44 namespace sw {
45  enum class RedlineMode
46  {
47  Shown, Hidden
48  };
49 };
50 
52 {
53  Size = 0x01,
54  PrtArea = 0x02,
55  Pos = 0x04,
56  Table = 0x08,
57  Section = 0x10,
58  LineNum = 0x20,
59  Direction = 0x40,
60 };
61 
62 namespace o3tl
63 {
64  template<> struct typed_flags<SwInvalidateFlags> : is_typed_flags<SwInvalidateFlags, 0x7f> {};
65 };
66 
67 enum class SwRemoveResult
68 {
69  Next,
70  Prev
71 };
72 
73 using SwCurrShells = std::set<CurrShell*>;
74 
75 class SwSectionFrame;
77 
80 class SAL_DLLPUBLIC_RTTI SwRootFrame: public SwLayoutFrame
81 {
82  // Needs to disable the Superfluous temporarily
83  friend void AdjustSizeChgNotify( SwRootFrame *pRoot );
84 
85  // Maintains the mpLastPage (Cut() and Paste() of SwPageFrame
86  friend inline void SetLastPage( SwPageFrame* );
87 
88  // For creating and destroying of the virtual output device manager
89  friend void FrameInit(); // Creates s_pVout
90  friend void FrameFinit(); // Destroys s_pVout
91 
92  std::vector<SwRect> maPageRects;// returns the current rectangle for each page frame
93  // the rectangle is extended to the top/bottom/left/right
94  // for pages located at the outer margins
95  SwRect maPagesArea; // the area covered by the pages
96  long mnViewWidth; // the current page layout bases on this view width
97  sal_uInt16 mnColumns; // the current page layout bases on this number of columns
98  bool mbBookMode; // the current page layout is in book view
99  bool mbSidebarChanged; // the notes sidebar state has changed
100 
101  bool mbNeedGrammarCheck; // true when sth needs to be checked (not necessarily started yet!)
102 
104  static bool s_isInPaint; // Protection against double Paints
105  static bool s_isNoVirDev;// No virt. Device for SystemPaints
106 
108  static constexpr sal_Int64 MIN_BROWSE_WIDTH = convertMm100ToTwip(20000);
109 
110  bool mbCheckSuperfluous :1; // Search for empty Pages?
111  bool mbIdleFormat :1; // Trigger Idle Formatter?
112  bool mbBrowseWidthValid :1; // Is mnBrowseWidth valid?
113  bool mbTurboAllowed :1;
114  bool mbAssertFlyPages :1; // Insert more Pages for Flys if needed?
115  bool mbIsVirtPageNum :1; // Do we have a virtual pagenumber?
116  bool mbIsNewLayout :1; // Layout loaded or newly created
117  bool mbCallbackActionEnabled:1; // No Action in Notification desired
118  // @see dcontact.cxx, ::Changed()
121 
128 
131 
134 
157  friend class CurrShell;
158  friend void SetShell( SwViewShell *pSh );
159  friend void InitCurrShells( SwRootFrame *pRoot );
162  std::unique_ptr<SwCurrShells> mpCurrShells;
163 
166 
167  std::unique_ptr<SwDestroyList> mpDestroy;
168 
169  sal_uInt16 mnPhyPageNums;
170  sal_uInt16 mnAccessibleShells; // Number of accessible shells
171 
172  void ImplCalcBrowseWidth();
173  void ImplInvalidateBrowseWidth();
174 
175  void DeleteEmptySct_(); // Destroys the registered SectionFrames
176  void RemoveFromList_( SwSectionFrame* pSct ); // Removes SectionFrames from the Delete List
177 
178  virtual void DestroyImpl() override;
179  virtual ~SwRootFrame() override;
180 
181 protected:
182 
183  virtual void MakeAll(vcl::RenderContext* pRenderContext) override;
184 
185 public:
186 
188  static void RemoveMasterObjs( SdrPage *pPg );
189 
190  void AllCheckPageDescs() const;
191  void AllInvalidateAutoCompleteWords() const;
192  void AllAddPaintRect() const;
193  void AllRemoveFootnotes() ;
194  void AllInvalidateSmartTagsOrSpelling(bool bSmartTags) const;
195 
197  static bool FlushVout();
198 
200  static bool HasSameRect( const SwRect& rRect );
201 
203  void Init(SwFrameFormat*);
204 
205  SwViewShell *GetCurrShell() const { return mpCurrShell; }
206  void DeRegisterShell( SwViewShell *pSh );
207 
215  void StartAllAction();
216  void EndAllAction( bool bVirDev = false );
217 
222  void UnoRemoveAllActions();
223  void UnoRestoreAllActions();
224 
225  const SdrPage* GetDrawPage() const { return mpDrawPage; }
226  SdrPage* GetDrawPage() { return mpDrawPage; }
227  void SetDrawPage( SdrPage* pNew ){ mpDrawPage = pNew; }
228 
229  virtual bool GetModelPositionForViewPoint( SwPosition *, Point&,
230  SwCursorMoveState* = nullptr, bool bTestBackground = false ) const override;
231 
232  virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const&,
233  SwPrintData const*const pPrintData = nullptr ) const override;
234  virtual SwTwips ShrinkFrame( SwTwips, bool bTst = false, bool bInfo = false ) override;
235  virtual SwTwips GrowFrame ( SwTwips, bool bTst = false, bool bInfo = false ) override;
236 #ifdef DBG_UTIL
237  virtual void Cut() override;
238  virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
239 #endif
240 
241  virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const override;
242 
243  Point GetNextPrevContentPos( const Point &rPoint, bool bNext ) const;
244 
245  virtual Size ChgSize( const Size& aNewSize ) override;
246 
248  {
249  mbIdleFormat = true;
250 
251  SwViewShell* pCurrShell = GetCurrShell();
252  // May be NULL if called from SfxBaseModel::dispose
253  // (this happens in the build test 'rtfexport').
254  if (pCurrShell != nullptr)
255  pCurrShell->GetDoc()->getIDocumentTimerAccess().StartIdling();
256  }
257  bool IsIdleFormat() const { return mbIdleFormat; }
258  void ResetIdleFormat() { mbIdleFormat = false; }
259 
260  bool IsNeedGrammarCheck() const { return mbNeedGrammarCheck; }
261  void SetNeedGrammarCheck( bool bVal )
262  {
263  mbNeedGrammarCheck = bVal;
264 
265  if ( bVal )
266  {
267  SwViewShell* pCurrShell = GetCurrShell();
268  // May be NULL if called from SfxBaseModel::dispose
269  // (this happens in the build test 'rtfexport').
270  if (pCurrShell != nullptr)
271  pCurrShell->GetDoc()->getIDocumentTimerAccess().StartIdling();
272  }
273  }
274 
276  void SetAssertFlyPages() { mbAssertFlyPages = true; }
277  void AssertFlyPages();
278  bool IsAssertFlyPages() const { return mbAssertFlyPages; }
279 
284  static void AssertPageFlys( SwPageFrame * );
285 
287  void InvalidateAllContent( SwInvalidateFlags nInvalidate );
288 
294  void InvalidateAllObjPos();
295 
297  void SetSuperfluous() { mbCheckSuperfluous = true; }
298  bool IsSuperfluous() const { return mbCheckSuperfluous; }
299  void RemoveSuperfluous();
300 
305  sal_uInt16 GetCurrPage( const SwPaM* ) const;
306  sal_uInt16 SetCurrPage( SwCursor*, sal_uInt16 nPageNum );
307  Point GetPagePos( sal_uInt16 nPageNum ) const;
308  sal_uInt16 GetPageNum() const { return mnPhyPageNums; }
309  void DecrPhyPageNums() { --mnPhyPageNums; }
310  void IncrPhyPageNums() { ++mnPhyPageNums; }
311  bool IsVirtPageNum() const { return mbIsVirtPageNum; }
312  inline void SetVirtPageNum( const bool bOf ) const;
313  bool IsDummyPage( sal_uInt16 nPageNum ) const;
314 
322  const SwPageFrame* GetPageAtPos( const Point& rPt, const Size* pSize = nullptr, bool bExtend = false ) const;
323 
331  bool IsBetweenPages(const Point& rPt) const;
332 
333  void CalcFrameRects( SwShellCursor& );
334 
341  bool MakeTableCursors( SwTableCursor& );
342 
343  void DisallowTurbo() const { const_cast<SwRootFrame*>(this)->mbTurboAllowed = false; }
344  void ResetTurboFlag() const { const_cast<SwRootFrame*>(this)->mbTurboAllowed = true; }
345  bool IsTurboAllowed() const { return mbTurboAllowed; }
346  void SetTurbo( const SwContentFrame *pContent ) { mpTurbo = pContent; }
347  void ResetTurbo() { mpTurbo = nullptr; }
348  const SwContentFrame *GetTurbo() const { return mpTurbo; }
349 
351  void UpdateFootnoteNums(); // Only for page by page numbering!
352 
354  void RemoveFootnotes( SwPageFrame *pPage = nullptr, bool bPageOnly = false,
355  bool bEndNotes = false );
356  void CheckFootnotePageDescs( bool bEndNote );
357 
358  const SwPageFrame *GetLastPage() const { return mpLastPage; }
359  SwPageFrame *GetLastPage() { return mpLastPage; }
360 
361  static bool IsInPaint() { return s_isInPaint; }
362 
363  static void SetNoVirDev(const bool bNew) { s_isNoVirDev = bNew; }
364 
365  inline long GetBrowseWidth() const;
366  inline void InvalidateBrowseWidth();
367 
368  bool IsNewLayout() const { return mbIsNewLayout; }
369  void ResetNewLayout() { mbIsNewLayout = false;}
370 
375  void InsertEmptySct( SwSectionFrame* pDel );
376  void DeleteEmptySct() { if( mpDestroy ) DeleteEmptySct_(); }
377  void RemoveFromList( SwSectionFrame* pSct ) { if( mpDestroy ) RemoveFromList_( pSct ); }
378 #ifdef DBG_UTIL
379  bool IsInDelList( SwSectionFrame* pSct ) const;
380 #endif
381 
382  void SetCallbackActionEnabled( bool b ) { mbCallbackActionEnabled = b; }
383  bool IsCallbackActionEnabled() const { return mbCallbackActionEnabled; }
384 
385  bool IsAnyShellAccessible() const { return mnAccessibleShells > 0; }
386  void AddAccessibleShell() { ++mnAccessibleShells; }
387  void RemoveAccessibleShell() { --mnAccessibleShells; }
388 
401  SwPageFrame* GetPageByPageNum( sal_uInt16 _nPageNum ) const;
402 
403  void CheckViewLayout( const SwViewOption* pViewOpt, const SwRect* pVisArea );
404  bool IsLeftToRightViewLayout() const;
405  const SwRect& GetPagesArea() const { return maPagesArea; }
406  void SetSidebarChanged() { mbSidebarChanged = true; }
407 
408  bool IsLayoutFreezed() const { return mbLayoutFreezed; }
409  void FreezeLayout( bool freeze ) { mbLayoutFreezed = freeze; }
410 
411  void RemovePage( SwPageFrame **pDel, SwRemoveResult eResult );
412 
417  bool IsHideRedlines() const { return mbHideRedlines; }
418  void SetHideRedlines(bool);
419 };
420 
421 inline long SwRootFrame::GetBrowseWidth() const
422 {
423  if ( !mbBrowseWidthValid )
424  const_cast<SwRootFrame*>(this)->ImplCalcBrowseWidth();
425  return mnBrowseWidth;
426 }
427 
429 {
430  if ( mbBrowseWidthValid )
432 }
433 
434 inline void SwRootFrame::SetVirtPageNum( const bool bOf) const
435 {
436  const_cast<SwRootFrame*>(this)->mbIsVirtPageNum = bOf;
437 }
438 
442 {
443  private:
446 
447  public:
448  explicit DisableCallbackAction(SwRootFrame & rRootFrame)
449  : m_rRootFrame(rRootFrame)
450  , m_bOldCallbackActionState(rRootFrame.IsCallbackActionEnabled())
451  {
452  m_rRootFrame.SetCallbackActionEnabled(false);
453  }
454 
456  {
457  m_rRootFrame.SetCallbackActionEnabled(m_bOldCallbackActionState);
458  }
459 };
460 
461 #endif // INCLUDED_SW_SOURCE_CORE_INC_ROOTFRM_HXX
462 
463 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DisableCallbackAction(SwRootFrame &rRootFrame)
Definition: rootfrm.hxx:448
Base class of the Writer layout elements.
Definition: frame.hxx:297
SdrPage * mpDrawPage
One Page per DrawModel per Document; is always the size of the Root.
Definition: rootfrm.hxx:165
void RemoveFromList(SwSectionFrame *pSct)
Definition: rootfrm.hxx:377
void SetCallbackActionEnabled(bool b)
Definition: rootfrm.hxx:382
Marks a position in the document model.
Definition: pam.hxx:35
void Init()
void DeleteEmptySct()
Definition: rootfrm.hxx:376
bool IsAnyShellAccessible() const
Definition: rootfrm.hxx:385
void FrameFinit()
Definition: newfrm.cxx:305
void ResetTurboFlag() const
Definition: rootfrm.hxx:344
static bool IsInPaint()
Definition: rootfrm.hxx:361
bool mbBrowseWidthValid
Definition: rootfrm.hxx:112
void FrameInit()
Definition: newfrm.cxx:294
static void SetNoVirDev(const bool bNew)
Definition: rootfrm.hxx:363
void SetNeedGrammarCheck(bool bVal)
Definition: rootfrm.hxx:261
void SetShell(SwViewShell *pSh)
Definition: newfrm.cxx:351
SwViewShell * mpCurrShell
Definition: rootfrm.hxx:160
const SdrPage * GetDrawPage() const
Definition: rootfrm.hxx:225
long GetBrowseWidth() const
Definition: rootfrm.hxx:421
long mnViewWidth
Definition: rootfrm.hxx:96
bool mbSidebarChanged
Definition: rootfrm.hxx:99
SwPageFrame * GetLastPage()
Definition: rootfrm.hxx:359
helper class to disable creation of an action by a callback event in particular, change event from a ...
Definition: rootfrm.hxx:441
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: wsfrm.cxx:1303
bool mbLayoutFreezed
Definition: rootfrm.hxx:119
long SwTwips
Definition: swtypes.hxx:49
bool IsNeedGrammarCheck() const
Definition: rootfrm.hxx:260
void SetTurbo(const SwContentFrame *pContent)
Definition: rootfrm.hxx:346
This class is used as parameter for creation of a block cursor selection.
Dialog to specify the properties of date form field.
void SetDrawPage(SdrPage *pNew)
Definition: rootfrm.hxx:227
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
sal_uInt16 mnAccessibleShells
Page count.
Definition: rootfrm.hxx:170
SwRootFrame & m_rRootFrame
Definition: rootfrm.hxx:444
The root element of a Writer document layout.
Definition: rootfrm.hxx:80
bool mbIsVirtPageNum
Definition: rootfrm.hxx:115
bool IsTurboAllowed() const
Definition: rootfrm.hxx:345
std::vector< SwRect > maPageRects
Definition: rootfrm.hxx:92
virtual void PaintSwFrame(vcl::RenderContext &rRenderContext, SwRect const &, SwPrintData const *const pPrintData=nullptr) const override
Definition: paintfrm.cxx:3364
virtual Size ChgSize(const Size &aNewSize)
Definition: wsfrm.cxx:721
const SwPageFrame * GetLastPage() const
Definition: rootfrm.hxx:358
void DecrPhyPageNums()
Definition: rootfrm.hxx:309
virtual void StartIdling()=0
Start the idle task.
void SetSuperfluous()
Remove superfluous Pages.
Definition: rootfrm.hxx:297
SwInvalidateFlags
Definition: rootfrm.hxx:51
bool m_bOldCallbackActionState
Definition: rootfrm.hxx:445
SwPageFrame * mpLastPage
We should not need to always struggle to find the last page, so store it here.
Definition: rootfrm.hxx:133
void SetSidebarChanged()
Definition: rootfrm.hxx:406
SwDoc * GetDoc() const
Definition: viewsh.hxx:281
void InitCurrShells(SwRootFrame *pRoot)
Definition: newfrm.cxx:388
void InvalidateBrowseWidth()
Definition: rootfrm.hxx:428
virtual void DestroyImpl() override
Definition: ssfrm.cxx:473
long mnBrowseWidth
For BrowseMode mnBrowseWidth is the outer margin of the object most to the right. ...
Definition: rootfrm.hxx:127
void AdjustSizeChgNotify(SwRootFrame *pRoot)
Definition: pagechg.cxx:813
void SetIdleFlags()
Definition: rootfrm.hxx:247
void FreezeLayout(bool freeze)
Definition: rootfrm.hxx:409
bool IsAssertFlyPages() const
Definition: rootfrm.hxx:278
const SwContentFrame * mpTurbo
If we only have to format one ContentFrame, its in mpTurbo.
Definition: rootfrm.hxx:130
SdrPage * GetDrawPage()
Definition: rootfrm.hxx:226
void ResetTurbo()
Definition: rootfrm.hxx:347
void ImplInvalidateBrowseWidth()
Definition: pagechg.cxx:1735
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
Style of a layout element.
Definition: frmfmt.hxx:57
SwViewShell * mpWaitingCurrShell
Definition: rootfrm.hxx:161
void ResetIdleFormat()
Definition: rootfrm.hxx:258
void SetAssertFlyPages()
Makes sure that all requested page-bound Flys find a Page.
Definition: rootfrm.hxx:276
void ImplCalcBrowseWidth()
Definition: pagechg.cxx:1746
virtual void Cut() override
Definition: wsfrm.cxx:1400
bool mbNeedGrammarCheck
Definition: rootfrm.hxx:101
void ResetNewLayout()
Definition: rootfrm.hxx:369
SwRemoveResult
Definition: rootfrm.hxx:67
void IncrPhyPageNums()
Definition: rootfrm.hxx:310
const SwRect & GetPagesArea() const
Definition: rootfrm.hxx:405
static bool s_isNoVirDev
Definition: rootfrm.hxx:105
A page of the document layout.
Definition: pagefrm.hxx:41
void AddAccessibleShell()
Definition: rootfrm.hxx:386
bool IsLayoutFreezed() const
Definition: rootfrm.hxx:408
std::set< CurrShell * > SwCurrShells
Definition: rootfrm.hxx:73
RedlineMode
Definition: rootfrm.hxx:45
void SetVirtPageNum(const bool bOf) const
Definition: rootfrm.hxx:434
void RemoveAccessibleShell()
Definition: rootfrm.hxx:387
virtual SwTwips ShrinkFrame(SwTwips, bool bTst=false, bool bInfo=false) override
Definition: wsfrm.cxx:2752
Direction
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const override
Searches the ContentFrame owning the PrtArea containing the point.
Definition: trvlfrm.cxx:150
sal_uInt16 mnPhyPageNums
Definition: rootfrm.hxx:169
bool mbBookMode
Definition: rootfrm.hxx:98
static SwLayVout * s_pVout
Definition: rootfrm.hxx:103
SwRect maPagesArea
Definition: rootfrm.hxx:95
bool mbHideRedlines
Definition: rootfrm.hxx:120
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding)...
Definition: rootfrm.hxx:417
static bool s_isInPaint
Definition: rootfrm.hxx:104
constexpr sal_Int64 convertMm100ToTwip(sal_Int64 n)
const SwContentFrame * GetTurbo() const
Definition: rootfrm.hxx:348
void DisallowTurbo() const
Definition: rootfrm.hxx:343
void SetLastPage(SwPageFrame *pPage)
Definition: pagechg.cxx:832
bool IsIdleFormat() const
Definition: rootfrm.hxx:257
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
Definition: layfrm.hxx:35
std::unique_ptr< SwCurrShells > mpCurrShells
Definition: rootfrm.hxx:162
bool IsNewLayout() const
Definition: rootfrm.hxx:368
virtual SwTwips GrowFrame(SwTwips, bool bTst=false, bool bInfo=false) override
Definition: wsfrm.cxx:2580
sal_uInt16 mnColumns
Definition: rootfrm.hxx:97
virtual void MakeAll(vcl::RenderContext *pRenderContext) override
Definition: calcmove.cxx:951
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:205
bool IsSuperfluous() const
Definition: rootfrm.hxx:298
sal_uInt16 GetPageNum() const
Definition: rootfrm.hxx:308
bool IsCallbackActionEnabled() const
Definition: rootfrm.hxx:383
std::unique_ptr< SwDestroyList > mpDestroy
Definition: rootfrm.hxx:167
IDocumentTimerAccess const & getIDocumentTimerAccess() const
Definition: doc.cxx:249
bool IsVirtPageNum() const
Definition: rootfrm.hxx:311
virtual bool FillSelection(SwSelectionList &rList, const SwRect &rRect) const override
Definition: trvlfrm.cxx:366