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 
82 class SAL_DLLPUBLIC_RTTI SwRootFrame: public SwLayoutFrame
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 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 protected:
185 
186  virtual void MakeAll(vcl::RenderContext* pRenderContext) override;
187 
188 public:
189 
191  static void RemoveMasterObjs( SdrPage *pPg );
192 
193  void AllCheckPageDescs() const;
194  void AllInvalidateAutoCompleteWords() const;
195  void AllAddPaintRect() const;
196  void AllRemoveFootnotes() ;
197  void AllInvalidateSmartTagsOrSpelling(bool bSmartTags) const;
198 
200  static bool FlushVout();
201 
203  static bool HasSameRect( const SwRect& rRect );
204 
206  void Init(SwFrameFormat*);
207 
208  SwViewShell *GetCurrShell() const { return mpCurrShell; }
209  void DeRegisterShell( SwViewShell *pSh );
210 
218  void StartAllAction();
219  void EndAllAction( bool bVirDev = false );
220 
225  void UnoRemoveAllActions();
226  void UnoRestoreAllActions();
227 
228  const SdrPage* GetDrawPage() const { return mpDrawPage; }
229  SdrPage* GetDrawPage() { return mpDrawPage; }
230  void SetDrawPage( SdrPage* pNew ){ mpDrawPage = pNew; }
231 
232  virtual bool GetModelPositionForViewPoint( SwPosition *, Point&,
233  SwCursorMoveState* = nullptr, bool bTestBackground = false ) const override;
234 
235  virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const&,
236  SwPrintData const*const pPrintData = nullptr ) const override;
237  virtual SwTwips ShrinkFrame( SwTwips, bool bTst = false, bool bInfo = false ) override;
238  virtual SwTwips GrowFrame ( SwTwips, bool bTst = false, bool bInfo = false ) override;
239 #ifdef DBG_UTIL
240  virtual void Cut() override;
241  virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
242 #endif
243 
244  virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const override;
245 
246  Point GetNextPrevContentPos( const Point &rPoint, bool bNext ) const;
247 
248  virtual Size ChgSize( const Size& aNewSize ) override;
249 
251  {
252  mbIdleFormat = true;
253 
254  SwViewShell* pCurrShell = GetCurrShell();
255  // May be NULL if called from SfxBaseModel::dispose
256  // (this happens in the build test 'rtfexport').
257  if (pCurrShell != nullptr)
258  pCurrShell->GetDoc()->getIDocumentTimerAccess().StartIdling();
259  }
260  bool IsIdleFormat() const { return mbIdleFormat; }
261  void ResetIdleFormat() { mbIdleFormat = false; }
262 
263  bool IsNeedGrammarCheck() const { return mbNeedGrammarCheck; }
264  void SetNeedGrammarCheck( bool bVal )
265  {
266  mbNeedGrammarCheck = bVal;
267 
268  if ( bVal )
269  {
270  SwViewShell* pCurrShell = GetCurrShell();
271  // May be NULL if called from SfxBaseModel::dispose
272  // (this happens in the build test 'rtfexport').
273  if (pCurrShell != nullptr)
274  pCurrShell->GetDoc()->getIDocumentTimerAccess().StartIdling();
275  }
276  }
277 
279  void SetAssertFlyPages() { mbAssertFlyPages = true; }
280  void AssertFlyPages();
281  bool IsAssertFlyPages() const { return mbAssertFlyPages; }
282 
287  static void AssertPageFlys( SwPageFrame * );
288 
290  void InvalidateAllContent( SwInvalidateFlags nInvalidate );
291 
297  void InvalidateAllObjPos();
298 
300  void SetSuperfluous() { mbCheckSuperfluous = true; }
301  bool IsSuperfluous() const { return mbCheckSuperfluous; }
302  void RemoveSuperfluous();
303 
308  sal_uInt16 GetCurrPage( const SwPaM* ) const;
309  sal_uInt16 SetCurrPage( SwCursor*, sal_uInt16 nPageNum );
310  Point GetPagePos( sal_uInt16 nPageNum ) const;
311  sal_uInt16 GetPageNum() const { return mnPhyPageNums; }
312  void DecrPhyPageNums() { --mnPhyPageNums; }
313  void IncrPhyPageNums() { ++mnPhyPageNums; }
314  bool IsVirtPageNum() const { return mbIsVirtPageNum; }
315  inline void SetVirtPageNum( const bool bOf ) const;
316  bool IsDummyPage( sal_uInt16 nPageNum ) const;
317 
325  const SwPageFrame* GetPageAtPos( const Point& rPt, const Size* pSize = nullptr, bool bExtend = false ) const;
326 
334  bool IsBetweenPages(const Point& rPt) const;
335 
336  void CalcFrameRects( SwShellCursor& );
337 
344  bool MakeTableCursors( SwTableCursor& );
345 
346  void DisallowTurbo() const { const_cast<SwRootFrame*>(this)->mbTurboAllowed = false; }
347  void ResetTurboFlag() const { const_cast<SwRootFrame*>(this)->mbTurboAllowed = true; }
348  bool IsTurboAllowed() const { return mbTurboAllowed; }
349  void SetTurbo( const SwContentFrame *pContent ) { mpTurbo = pContent; }
350  void ResetTurbo() { mpTurbo = nullptr; }
351  const SwContentFrame *GetTurbo() const { return mpTurbo; }
352 
354  void UpdateFootnoteNums(); // Only for page by page numbering!
355 
357  void RemoveFootnotes( SwPageFrame *pPage = nullptr, bool bPageOnly = false,
358  bool bEndNotes = false );
359  void CheckFootnotePageDescs( bool bEndNote );
360 
361  const SwPageFrame *GetLastPage() const { return mpLastPage; }
362  SwPageFrame *GetLastPage() { return mpLastPage; }
363 
364  static bool IsInPaint() { return s_isInPaint; }
365 
366  static void SetNoVirDev(const bool bNew) { s_isNoVirDev = bNew; }
367 
368  inline tools::Long GetBrowseWidth() const;
369  inline void InvalidateBrowseWidth();
370 
371  bool IsNewLayout() const { return mbIsNewLayout; }
372  void ResetNewLayout() { mbIsNewLayout = false;}
373 
378  void InsertEmptySct( SwSectionFrame* pDel );
379  void DeleteEmptySct() { if( mpDestroy ) DeleteEmptySct_(); }
380  void RemoveFromList( SwSectionFrame* pSct ) { if( mpDestroy ) RemoveFromList_( pSct ); }
381 #ifdef DBG_UTIL
382  bool IsInDelList( SwSectionFrame* pSct ) const;
383 #endif
384 
385  void SetCallbackActionEnabled( bool b ) { mbCallbackActionEnabled = b; }
386  bool IsCallbackActionEnabled() const { return mbCallbackActionEnabled; }
387 
388  bool IsAnyShellAccessible() const { return mnAccessibleShells > 0; }
389  void AddAccessibleShell() { ++mnAccessibleShells; }
390  void RemoveAccessibleShell() { --mnAccessibleShells; }
391 
404  SwPageFrame* GetPageByPageNum( sal_uInt16 _nPageNum ) const;
405 
406  void CheckViewLayout( const SwViewOption* pViewOpt, const SwRect* pVisArea );
407  bool IsLeftToRightViewLayout() const;
408  const SwRect& GetPagesArea() const { return maPagesArea; }
409  void SetSidebarChanged() { mbSidebarChanged = true; }
410 
411  bool IsLayoutFreezed() const { return mbLayoutFreezed; }
412  void FreezeLayout( bool freeze ) { mbLayoutFreezed = freeze; }
413 
414  void RemovePage( SwPageFrame **pDel, SwRemoveResult eResult );
415 
420  bool IsHideRedlines() const { return mbHideRedlines; }
421  void SetHideRedlines(bool);
422  sw::FieldmarkMode GetFieldmarkMode() const { return m_FieldmarkMode; }
423  void SetFieldmarkMode(sw::FieldmarkMode);
424  bool HasMergedParas() const {
425  return IsHideRedlines() || GetFieldmarkMode() != sw::FieldmarkMode::ShowBoth;
426  }
427 };
428 
430 {
431  if ( !mbBrowseWidthValid )
432  const_cast<SwRootFrame*>(this)->ImplCalcBrowseWidth();
433  return mnBrowseWidth;
434 }
435 
437 {
438  if ( mbBrowseWidthValid )
440 }
441 
442 inline void SwRootFrame::SetVirtPageNum( const bool bOf) const
443 {
444  const_cast<SwRootFrame*>(this)->mbIsVirtPageNum = bOf;
445 }
446 
450 {
451  private:
454 
455  public:
456  explicit DisableCallbackAction(SwRootFrame & rRootFrame)
457  : m_rRootFrame(rRootFrame)
458  , m_bOldCallbackActionState(rRootFrame.IsCallbackActionEnabled())
459  {
460  m_rRootFrame.SetCallbackActionEnabled(false);
461  }
462 
464  {
465  m_rRootFrame.SetCallbackActionEnabled(m_bOldCallbackActionState);
466  }
467 };
468 
469 #endif // INCLUDED_SW_SOURCE_CORE_INC_ROOTFRM_HXX
470 
471 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DisableCallbackAction(SwRootFrame &rRootFrame)
Definition: rootfrm.hxx:456
Base class of the Writer layout elements.
Definition: frame.hxx:298
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:380
void SetCallbackActionEnabled(bool b)
Definition: rootfrm.hxx:385
Marks a position in the document model.
Definition: pam.hxx:35
void Init()
void DeleteEmptySct()
Definition: rootfrm.hxx:379
tools::Long mnBrowseWidth
For BrowseMode mnBrowseWidth is the outer margin of the object most to the right. ...
Definition: rootfrm.hxx:130
bool IsAnyShellAccessible() const
Definition: rootfrm.hxx:388
void FrameFinit()
Definition: newfrm.cxx:305
void ResetTurboFlag() const
Definition: rootfrm.hxx:347
static bool IsInPaint()
Definition: rootfrm.hxx:364
bool mbBrowseWidthValid
Definition: rootfrm.hxx:114
void FrameInit()
Definition: newfrm.cxx:294
static void SetNoVirDev(const bool bNew)
Definition: rootfrm.hxx:366
void SetNeedGrammarCheck(bool bVal)
Definition: rootfrm.hxx:264
void SetShell(SwViewShell *pSh)
Definition: newfrm.cxx:351
SwViewShell * mpCurrShell
Definition: rootfrm.hxx:163
long Long
const SdrPage * GetDrawPage() const
Definition: rootfrm.hxx:228
bool mbSidebarChanged
Definition: rootfrm.hxx:101
SwPageFrame * GetLastPage()
Definition: rootfrm.hxx:362
helper class to disable creation of an action by a callback event in particular, change event from a ...
Definition: rootfrm.hxx:449
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: wsfrm.cxx:1319
bool mbLayoutFreezed
Definition: rootfrm.hxx:121
bool IsNeedGrammarCheck() const
Definition: rootfrm.hxx:263
void SetTurbo(const SwContentFrame *pContent)
Definition: rootfrm.hxx:349
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:230
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
sal_uInt16 mnAccessibleShells
Page count.
Definition: rootfrm.hxx:173
SwRootFrame & m_rRootFrame
Definition: rootfrm.hxx:452
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
bool mbIsVirtPageNum
Definition: rootfrm.hxx:117
FieldmarkMode
Definition: rootfrm.hxx:50
bool IsTurboAllowed() const
Definition: rootfrm.hxx:348
std::vector< SwRect > maPageRects
Definition: rootfrm.hxx:94
tools::Long GetBrowseWidth() const
Definition: rootfrm.hxx:429
virtual void PaintSwFrame(vcl::RenderContext &rRenderContext, SwRect const &, SwPrintData const *const pPrintData=nullptr) const override
Definition: paintfrm.cxx:3365
virtual Size ChgSize(const Size &aNewSize)
Definition: wsfrm.cxx:722
const SwPageFrame * GetLastPage() const
Definition: rootfrm.hxx:361
void DecrPhyPageNums()
Definition: rootfrm.hxx:312
virtual void StartIdling()=0
Start the idle task.
void SetSuperfluous()
Remove superfluous Pages.
Definition: rootfrm.hxx:300
SwInvalidateFlags
Definition: rootfrm.hxx:53
bool m_bOldCallbackActionState
Definition: rootfrm.hxx:453
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:409
SwDoc * GetDoc() const
Definition: viewsh.hxx:281
void InitCurrShells(SwRootFrame *pRoot)
Definition: newfrm.cxx:388
void InvalidateBrowseWidth()
Definition: rootfrm.hxx:436
virtual void DestroyImpl() override
Definition: ssfrm.cxx:480
void AdjustSizeChgNotify(SwRootFrame *pRoot)
Definition: pagechg.cxx:812
void SetIdleFlags()
Definition: rootfrm.hxx:250
void FreezeLayout(bool freeze)
Definition: rootfrm.hxx:412
bool IsAssertFlyPages() const
Definition: rootfrm.hxx:281
const SwContentFrame * mpTurbo
If we only have to format one ContentFrame, its in mpTurbo.
Definition: rootfrm.hxx:133
SdrPage * GetDrawPage()
Definition: rootfrm.hxx:229
void ResetTurbo()
Definition: rootfrm.hxx:350
void ImplInvalidateBrowseWidth()
Definition: pagechg.cxx:1760
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:164
void ResetIdleFormat()
Definition: rootfrm.hxx:261
void SetAssertFlyPages()
Makes sure that all requested page-bound Flys find a Page.
Definition: rootfrm.hxx:279
sw::FieldmarkMode GetFieldmarkMode() const
Definition: rootfrm.hxx:422
void ImplCalcBrowseWidth()
Definition: pagechg.cxx:1771
virtual void Cut() override
Definition: wsfrm.cxx:1416
bool mbNeedGrammarCheck
Definition: rootfrm.hxx:103
void ResetNewLayout()
Definition: rootfrm.hxx:372
SwRemoveResult
Definition: rootfrm.hxx:69
void IncrPhyPageNums()
Definition: rootfrm.hxx:313
tools::Long mnViewWidth
Definition: rootfrm.hxx:98
const SwRect & GetPagesArea() const
Definition: rootfrm.hxx:408
static bool s_isNoVirDev
Definition: rootfrm.hxx:107
A page of the document layout.
Definition: pagefrm.hxx:41
void AddAccessibleShell()
Definition: rootfrm.hxx:389
bool IsLayoutFreezed() const
Definition: rootfrm.hxx:411
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:442
void RemoveAccessibleShell()
Definition: rootfrm.hxx:390
virtual SwTwips ShrinkFrame(SwTwips, bool bTst=false, bool bInfo=false) override
Definition: wsfrm.cxx:2767
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
sw::FieldmarkMode m_FieldmarkMode
Definition: rootfrm.hxx:123
sal_uInt16 mnPhyPageNums
Definition: rootfrm.hxx:172
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:122
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding)...
Definition: rootfrm.hxx:420
static bool s_isInPaint
Definition: rootfrm.hxx:106
constexpr sal_Int64 convertMm100ToTwip(sal_Int64 n)
const SwContentFrame * GetTurbo() const
Definition: rootfrm.hxx:351
void DisallowTurbo() const
Definition: rootfrm.hxx:346
void SetLastPage(SwPageFrame *pPage)
Definition: pagechg.cxx:831
bool IsIdleFormat() const
Definition: rootfrm.hxx:260
bool HasMergedParas() const
Definition: rootfrm.hxx:424
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:371
virtual SwTwips GrowFrame(SwTwips, bool bTst=false, bool bInfo=false) override
Definition: wsfrm.cxx:2595
sal_uInt16 mnColumns
Definition: rootfrm.hxx:99
virtual void MakeAll(vcl::RenderContext *pRenderContext) override
Definition: calcmove.cxx:954
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:208
bool IsSuperfluous() const
Definition: rootfrm.hxx:301
sal_uInt16 GetPageNum() const
Definition: rootfrm.hxx:311
bool IsCallbackActionEnabled() const
Definition: rootfrm.hxx:386
std::unique_ptr< SwDestroyList > mpDestroy
Definition: rootfrm.hxx:170
IDocumentTimerAccess const & getIDocumentTimerAccess() const
Definition: doc.cxx:249
bool IsVirtPageNum() const
Definition: rootfrm.hxx:314
virtual bool FillSelection(SwSelectionList &rList, const SwRect &rRect) const override
Definition: trvlfrm.cxx:366