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