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  enum class FieldmarkMode { ShowCommand = 1, ShowResult = 2, ShowBoth = 3 };
50 };
51 
53 {
54  Size = 0x01,
55  PrtArea = 0x02,
56  Pos = 0x04,
57  Table = 0x08,
58  Section = 0x10,
59  LineNum = 0x20,
60  Direction = 0x40,
61 };
62 
63 namespace o3tl
64 {
65  template<> struct typed_flags<SwInvalidateFlags> : is_typed_flags<SwInvalidateFlags, 0x7f> {};
66 };
67 
68 enum class SwRemoveResult
69 {
70  Next,
71  Prev
72 };
73 
74 using SwCurrShells = std::set<CurrShell*>;
75 
76 class SwSectionFrame;
78 
82 {
83  // Needs to disable the Superfluous temporarily
84  friend void AdjustSizeChgNotify( SwRootFrame *pRoot );
85 
86  // Maintains the mpLastPage (Cut() and Paste() of SwPageFrame
87  friend inline void SetLastPage( SwPageFrame* );
88 
89  // For creating and destroying of the virtual output device manager
90  friend void FrameInit(); // Creates s_pVout
91  friend void FrameFinit(); // Destroys s_pVout
92 
93  std::vector<SwRect> maPageRects;// returns the current rectangle for each page frame
94  // the rectangle is extended to the top/bottom/left/right
95  // for pages located at the outer margins
96  SwRect maPagesArea; // the area covered by the pages
97  tools::Long mnViewWidth; // the current page layout bases on this view width
98  sal_uInt16 mnColumns; // the current page layout bases on this number of columns
99  bool mbBookMode; // the current page layout is in book view
100  bool mbSidebarChanged; // the notes sidebar state has changed
101 
102  bool mbNeedGrammarCheck; // true when sth needs to be checked (not necessarily started yet!)
103 
105  static bool s_isInPaint; // Protection against double Paints
106  static bool s_isNoVirDev;// No virt. Device for SystemPaints
107 
109  static constexpr sal_Int64 MIN_BROWSE_WIDTH = o3tl::toTwips(20000, o3tl::Length::mm100);
110 
111  bool mbCheckSuperfluous :1; // Search for empty Pages?
112  bool mbIdleFormat :1; // Trigger Idle Formatter?
113  bool mbBrowseWidthValid :1; // Is mnBrowseWidth valid?
114  bool mbTurboAllowed :1;
115  bool mbAssertFlyPages :1; // Insert more Pages for Flys if needed?
116  bool mbTableUpdateInProgress : 1; // tdf#139426 to allow suppression of AssertFlyPages during TableUpdate
117  bool mbIsVirtPageNum :1; // Do we have a virtual pagenumber?
118  bool mbIsNewLayout :1; // Layout loaded or newly created
119  bool mbCallbackActionEnabled:1; // No Action in Notification desired
120  // @see dcontact.cxx, ::Changed()
124 
131 
134 
137 
160  friend class CurrShell;
161  friend void SetShell( SwViewShell *pSh );
162  friend void InitCurrShells( SwRootFrame *pRoot );
165  std::unique_ptr<SwCurrShells> mpCurrShells;
166 
169 
170  std::unique_ptr<SwDestroyList> mpDestroy;
171 
172  sal_uInt16 mnPhyPageNums;
173  sal_uInt16 mnAccessibleShells; // Number of accessible shells
174 
175  void ImplCalcBrowseWidth();
176  void ImplInvalidateBrowseWidth();
177 
178  void DeleteEmptySct_(); // Destroys the registered SectionFrames
179  void RemoveFromList_( SwSectionFrame* pSct ); // Removes SectionFrames from the Delete List
180 
181  virtual void DestroyImpl() override;
182  virtual ~SwRootFrame() override;
183 
184  virtual void MakeAll(vcl::RenderContext* pRenderContext) override;
185 
186 public:
187 
189  static void RemoveMasterObjs( SdrPage *pPg );
190 
191  void AllCheckPageDescs() const;
192  void AllInvalidateAutoCompleteWords() const;
193  void AllAddPaintRect() const;
194  void AllRemoveFootnotes() ;
195  void AllInvalidateSmartTagsOrSpelling(bool bSmartTags) const;
196 
198  static bool FlushVout();
199 
201  static bool HasSameRect( const SwRect& rRect );
202 
204  void Init(SwFrameFormat*);
205 
206  SwViewShell *GetCurrShell() const { return mpCurrShell; }
207  void DeRegisterShell( SwViewShell *pSh );
208 
216  void StartAllAction();
217  void EndAllAction( bool bVirDev = false );
218 
223  void UnoRemoveAllActions();
224  void UnoRestoreAllActions();
225 
226  const SdrPage* GetDrawPage() const { return mpDrawPage; }
227  SdrPage* GetDrawPage() { return mpDrawPage; }
228  void SetDrawPage( SdrPage* pNew ){ mpDrawPage = pNew; }
229 
230  virtual bool GetModelPositionForViewPoint( SwPosition *, Point&,
231  SwCursorMoveState* = nullptr, bool bTestBackground = false ) const override;
232 
233  virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const&,
234  SwPrintData const*const pPrintData = nullptr ) const override;
235  virtual SwTwips ShrinkFrame( SwTwips, bool bTst = false, bool bInfo = false ) override;
236  virtual SwTwips GrowFrame ( SwTwips, bool bTst = false, bool bInfo = false ) override;
237 #ifdef DBG_UTIL
238  virtual void Cut() override;
239  virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
240 #endif
241 
242  virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const override;
243 
244  Point GetNextPrevContentPos( const Point &rPoint, bool bNext ) const;
245 
246  virtual Size ChgSize( const Size& aNewSize ) override;
247 
249  {
250  mbIdleFormat = true;
251 
252  SwViewShell* pCurrShell = GetCurrShell();
253  // May be NULL if called from SfxBaseModel::dispose
254  // (this happens in the build test 'rtfexport').
255  if (pCurrShell != nullptr)
256  pCurrShell->GetDoc()->getIDocumentTimerAccess().StartIdling();
257  }
258  bool IsIdleFormat() const { return mbIdleFormat; }
259  void ResetIdleFormat() { mbIdleFormat = false; }
260 
261  bool IsNeedGrammarCheck() const { return mbNeedGrammarCheck; }
262  void SetNeedGrammarCheck( bool bVal )
263  {
264  mbNeedGrammarCheck = bVal;
265 
266  if ( bVal )
267  {
268  SwViewShell* pCurrShell = GetCurrShell();
269  // May be NULL if called from SfxBaseModel::dispose
270  // (this happens in the build test 'rtfexport').
271  if (pCurrShell != nullptr)
272  pCurrShell->GetDoc()->getIDocumentTimerAccess().StartIdling();
273  }
274  }
275 
277  void SetAssertFlyPages() { mbAssertFlyPages = true; }
278  void AssertFlyPages();
279  bool IsAssertFlyPages() const { return mbAssertFlyPages; }
280 
281  void SetTableUpdateInProgress(bool bValue) { mbTableUpdateInProgress = bValue; }
282  bool IsTableUpdateInProgress() const { return mbTableUpdateInProgress; }
283 
288  static void AssertPageFlys( SwPageFrame * );
289 
291  void InvalidateAllContent( SwInvalidateFlags nInvalidate );
292 
298  void InvalidateAllObjPos();
299 
301  void SetSuperfluous() { mbCheckSuperfluous = true; }
302  bool IsSuperfluous() const { return mbCheckSuperfluous; }
303  void RemoveSuperfluous();
304 
309  sal_uInt16 GetCurrPage( const SwPaM* ) const;
310  sal_uInt16 SetCurrPage( SwCursor*, sal_uInt16 nPageNum );
311  Point GetPagePos( sal_uInt16 nPageNum ) const;
312  sal_uInt16 GetPageNum() const { return mnPhyPageNums; }
313  void DecrPhyPageNums() { --mnPhyPageNums; }
314  void IncrPhyPageNums() { ++mnPhyPageNums; }
315  bool IsVirtPageNum() const { return mbIsVirtPageNum; }
316  inline void SetVirtPageNum( const bool bOf ) const;
317  bool IsDummyPage( sal_uInt16 nPageNum ) const;
318 
326  const SwPageFrame* GetPageAtPos( const Point& rPt, const Size* pSize = nullptr, bool bExtend = false ) const;
327 
335  bool IsBetweenPages(const Point& rPt) const;
336 
337  void CalcFrameRects( SwShellCursor& );
338 
345  bool MakeTableCursors( SwTableCursor& );
346 
347  void DisallowTurbo() const { const_cast<SwRootFrame*>(this)->mbTurboAllowed = false; }
348  void ResetTurboFlag() const { const_cast<SwRootFrame*>(this)->mbTurboAllowed = true; }
349  bool IsTurboAllowed() const { return mbTurboAllowed; }
350  void SetTurbo( const SwContentFrame *pContent ) { mpTurbo = pContent; }
351  void ResetTurbo() { mpTurbo = nullptr; }
352  const SwContentFrame *GetTurbo() const { return mpTurbo; }
353 
355  void UpdateFootnoteNums(); // Only for page by page numbering!
356 
358  void RemoveFootnotes( SwPageFrame *pPage = nullptr, bool bPageOnly = false,
359  bool bEndNotes = false );
360  void CheckFootnotePageDescs( bool bEndNote );
361 
362  const SwPageFrame *GetLastPage() const { return mpLastPage; }
363  SwPageFrame *GetLastPage() { return mpLastPage; }
364 
365  static bool IsInPaint() { return s_isInPaint; }
366 
367  static void SetNoVirDev(const bool bNew) { s_isNoVirDev = bNew; }
368 
369  inline tools::Long GetBrowseWidth() const;
370  inline void InvalidateBrowseWidth();
371 
372  bool IsNewLayout() const { return mbIsNewLayout; }
373  void ResetNewLayout() { mbIsNewLayout = false;}
374 
379  void InsertEmptySct( SwSectionFrame* pDel );
380  void DeleteEmptySct() { if( mpDestroy ) DeleteEmptySct_(); }
381  void RemoveFromList( SwSectionFrame* pSct ) { if( mpDestroy ) RemoveFromList_( pSct ); }
382 #ifdef DBG_UTIL
383  bool IsInDelList( SwSectionFrame* pSct ) const;
384 #endif
385 
386  void SetCallbackActionEnabled( bool b ) { mbCallbackActionEnabled = b; }
387  bool IsCallbackActionEnabled() const { return mbCallbackActionEnabled; }
388 
389  bool IsAnyShellAccessible() const { return mnAccessibleShells > 0; }
390  void AddAccessibleShell() { ++mnAccessibleShells; }
391  void RemoveAccessibleShell() { --mnAccessibleShells; }
392 
405  SwPageFrame* GetPageByPageNum( sal_uInt16 _nPageNum ) const;
406 
407  void CheckViewLayout( const SwViewOption* pViewOpt, const SwRect* pVisArea );
408  bool IsLeftToRightViewLayout() const;
409  const SwRect& GetPagesArea() const { return maPagesArea; }
410  void SetSidebarChanged() { mbSidebarChanged = true; }
411 
412  bool IsLayoutFreezed() const { return mbLayoutFreezed; }
413  void FreezeLayout( bool freeze ) { mbLayoutFreezed = freeze; }
414 
415  void RemovePage( SwPageFrame **pDel, SwRemoveResult eResult );
416 
421  bool IsHideRedlines() const { return mbHideRedlines; }
422  void SetHideRedlines(bool);
423  sw::FieldmarkMode GetFieldmarkMode() const { return m_FieldmarkMode; }
424  void SetFieldmarkMode(sw::FieldmarkMode);
425  bool HasMergedParas() const {
426  return IsHideRedlines() || GetFieldmarkMode() != sw::FieldmarkMode::ShowBoth;
427  }
428 };
429 
431 {
432  if ( !mbBrowseWidthValid )
433  const_cast<SwRootFrame*>(this)->ImplCalcBrowseWidth();
434  return mnBrowseWidth;
435 }
436 
438 {
439  if ( mbBrowseWidthValid )
441 }
442 
443 inline void SwRootFrame::SetVirtPageNum( const bool bOf) const
444 {
445  const_cast<SwRootFrame*>(this)->mbIsVirtPageNum = bOf;
446 }
447 
451 {
452  private:
455 
456  public:
457  explicit DisableCallbackAction(SwRootFrame & rRootFrame)
458  : m_rRootFrame(rRootFrame)
459  , m_bOldCallbackActionState(rRootFrame.IsCallbackActionEnabled())
460  {
461  m_rRootFrame.SetCallbackActionEnabled(false);
462  }
463 
465  {
466  m_rRootFrame.SetCallbackActionEnabled(m_bOldCallbackActionState);
467  }
468 };
469 
470 #endif // INCLUDED_SW_SOURCE_CORE_INC_ROOTFRM_HXX
471 
472 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DisableCallbackAction(SwRootFrame &rRootFrame)
Definition: rootfrm.hxx:457
Base class of the Writer layout elements.
Definition: frame.hxx:314
SdrPage * mpDrawPage
One Page per DrawModel per Document; is always the size of the Root.
Definition: rootfrm.hxx:168
void RemoveFromList(SwSectionFrame *pSct)
Definition: rootfrm.hxx:381
void SetCallbackActionEnabled(bool b)
Definition: rootfrm.hxx:386
Marks a position in the document model.
Definition: pam.hxx:36
void Init()
void DeleteEmptySct()
Definition: rootfrm.hxx:380
tools::Long mnBrowseWidth
For BrowseMode mnBrowseWidth is the outer margin of the object most to the right. ...
Definition: rootfrm.hxx:130
constexpr auto toTwips(N number, Length from)
bool IsAnyShellAccessible() const
Definition: rootfrm.hxx:389
void FrameFinit()
Definition: newfrm.cxx:306
void ResetTurboFlag() const
Definition: rootfrm.hxx:348
static bool IsInPaint()
Definition: rootfrm.hxx:365
bool mbBrowseWidthValid
Definition: rootfrm.hxx:113
void FrameInit()
Definition: newfrm.cxx:295
static void SetNoVirDev(const bool bNew)
Definition: rootfrm.hxx:367
void SetNeedGrammarCheck(bool bVal)
Definition: rootfrm.hxx:262
void SetShell(SwViewShell *pSh)
Definition: newfrm.cxx:352
SwViewShell * mpCurrShell
Definition: rootfrm.hxx:163
long Long
const SdrPage * GetDrawPage() const
Definition: rootfrm.hxx:226
bool mbSidebarChanged
Definition: rootfrm.hxx:100
SwPageFrame * GetLastPage()
Definition: rootfrm.hxx:363
helper class to disable creation of an action by a callback event in particular, change event from a ...
Definition: rootfrm.hxx:450
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: wsfrm.cxx:1337
bool mbLayoutFreezed
Definition: rootfrm.hxx:121
bool IsNeedGrammarCheck() const
Definition: rootfrm.hxx:261
void SetTurbo(const SwContentFrame *pContent)
Definition: rootfrm.hxx:350
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:228
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
sal_uInt16 mnAccessibleShells
Page count.
Definition: rootfrm.hxx:173
SwRootFrame & m_rRootFrame
Definition: rootfrm.hxx:453
The root element of a Writer document layout.
Definition: rootfrm.hxx:81
bool mbIsVirtPageNum
Definition: rootfrm.hxx:117
FieldmarkMode
Definition: rootfrm.hxx:49
bool IsTurboAllowed() const
Definition: rootfrm.hxx:349
std::vector< SwRect > maPageRects
Definition: rootfrm.hxx:93
tools::Long GetBrowseWidth() const
Definition: rootfrm.hxx:430
virtual void PaintSwFrame(vcl::RenderContext &rRenderContext, SwRect const &, SwPrintData const *const pPrintData=nullptr) const override
Definition: paintfrm.cxx:3492
virtual Size ChgSize(const Size &aNewSize)
Definition: wsfrm.cxx:731
const SwPageFrame * GetLastPage() const
Definition: rootfrm.hxx:362
void DecrPhyPageNums()
Definition: rootfrm.hxx:313
virtual void StartIdling()=0
Start the idle task.
void SetSuperfluous()
Remove superfluous Pages.
Definition: rootfrm.hxx:301
SwInvalidateFlags
Definition: rootfrm.hxx:52
bool m_bOldCallbackActionState
Definition: rootfrm.hxx:454
SwPageFrame * mpLastPage
We should not need to always struggle to find the last page, so store it here.
Definition: rootfrm.hxx:136
void SetSidebarChanged()
Definition: rootfrm.hxx:410
SQLUSMALLINT Direction
SwDoc * GetDoc() const
Definition: viewsh.hxx:282
void InitCurrShells(SwRootFrame *pRoot)
Definition: newfrm.cxx:389
void InvalidateBrowseWidth()
Definition: rootfrm.hxx:437
virtual void DestroyImpl() override
Definition: ssfrm.cxx:485
void AdjustSizeChgNotify(SwRootFrame *pRoot)
Definition: pagechg.cxx:822
void SetIdleFlags()
Definition: rootfrm.hxx:248
void FreezeLayout(bool freeze)
Definition: rootfrm.hxx:413
bool IsAssertFlyPages() const
Definition: rootfrm.hxx:279
const SwContentFrame * mpTurbo
If we only have to format one ContentFrame, its in mpTurbo.
Definition: rootfrm.hxx:133
SdrPage * GetDrawPage()
Definition: rootfrm.hxx:227
void ResetTurbo()
Definition: rootfrm.hxx:351
void ImplInvalidateBrowseWidth()
Definition: pagechg.cxx:1781
bool IsTableUpdateInProgress() const
Definition: rootfrm.hxx:282
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
Style of a layout element.
Definition: frmfmt.hxx:59
SwViewShell * mpWaitingCurrShell
Definition: rootfrm.hxx:164
void ResetIdleFormat()
Definition: rootfrm.hxx:259
void SetAssertFlyPages()
Makes sure that all requested page-bound Flys find a Page.
Definition: rootfrm.hxx:277
sw::FieldmarkMode GetFieldmarkMode() const
Definition: rootfrm.hxx:423
void ImplCalcBrowseWidth()
Definition: pagechg.cxx:1792
virtual void Cut() override
Definition: wsfrm.cxx:1434
bool mbNeedGrammarCheck
Definition: rootfrm.hxx:102
void ResetNewLayout()
Definition: rootfrm.hxx:373
SwRemoveResult
Definition: rootfrm.hxx:68
void IncrPhyPageNums()
Definition: rootfrm.hxx:314
tools::Long mnViewWidth
Definition: rootfrm.hxx:97
void SetTableUpdateInProgress(bool bValue)
Definition: rootfrm.hxx:281
const SwRect & GetPagesArea() const
Definition: rootfrm.hxx:409
static bool s_isNoVirDev
Definition: rootfrm.hxx:106
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Definition: cntfrm.hxx:57
A page of the document layout.
Definition: pagefrm.hxx:57
void AddAccessibleShell()
Definition: rootfrm.hxx:390
bool IsLayoutFreezed() const
Definition: rootfrm.hxx:412
tools::Long SwTwips
Definition: swtypes.hxx:51
std::set< CurrShell * > SwCurrShells
Definition: rootfrm.hxx:74
RedlineMode
Definition: rootfrm.hxx:44
void SetVirtPageNum(const bool bOf) const
Definition: rootfrm.hxx:443
void RemoveAccessibleShell()
Definition: rootfrm.hxx:391
virtual SwTwips ShrinkFrame(SwTwips, bool bTst=false, bool bInfo=false) override
Definition: wsfrm.cxx:2810
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
sw::FieldmarkMode m_FieldmarkMode
Definition: rootfrm.hxx:123
sal_uInt16 mnPhyPageNums
Definition: rootfrm.hxx:172
bool mbBookMode
Definition: rootfrm.hxx:99
static SwLayVout * s_pVout
Definition: rootfrm.hxx:104
SwRect maPagesArea
Definition: rootfrm.hxx:96
bool mbHideRedlines
Definition: rootfrm.hxx:122
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding)...
Definition: rootfrm.hxx:421
static bool s_isInPaint
Definition: rootfrm.hxx:105
const SwContentFrame * GetTurbo() const
Definition: rootfrm.hxx:352
void DisallowTurbo() const
Definition: rootfrm.hxx:347
void SetLastPage(SwPageFrame *pPage)
Definition: pagechg.cxx:841
bool IsIdleFormat() const
Definition: rootfrm.hxx:258
bool HasMergedParas() const
Definition: rootfrm.hxx:425
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:165
bool IsNewLayout() const
Definition: rootfrm.hxx:372
virtual SwTwips GrowFrame(SwTwips, bool bTst=false, bool bInfo=false) override
Definition: wsfrm.cxx:2626
sal_uInt16 mnColumns
Definition: rootfrm.hxx:98
virtual void MakeAll(vcl::RenderContext *pRenderContext) override
Definition: calcmove.cxx:944
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:206
bool IsSuperfluous() const
Definition: rootfrm.hxx:302
sal_uInt16 GetPageNum() const
Definition: rootfrm.hxx:312
bool IsCallbackActionEnabled() const
Definition: rootfrm.hxx:387
std::unique_ptr< SwDestroyList > mpDestroy
Definition: rootfrm.hxx:170
IDocumentTimerAccess const & getIDocumentTimerAccess() const
Definition: doc.cxx:249
bool IsVirtPageNum() const
Definition: rootfrm.hxx:315
virtual bool FillSelection(SwSelectionList &rList, const SwRect &rRect) const override
Definition: trvlfrm.cxx:367