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