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>
27#include <set>
28#include <vector>
29
30class SwContentFrame;
31class SdrPage;
32class SwFrameFormat;
33class SwPaM;
34class SwCursor;
35class SwShellCursor;
36class SwTableCursor;
37class SwLayVout;
38class SwViewOption;
39class SwSelectionList;
40struct SwPosition;
42
43namespace sw {
44 enum class RedlineMode
45 {
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
63namespace o3tl
64{
65 template<> struct typed_flags<SwInvalidateFlags> : is_typed_flags<SwInvalidateFlags, 0x7f> {};
66};
67
69{
70 Next,
71 Prev
72};
73
74using SwCurrShells = std::set<CurrShell*>;
75
76class 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?
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
186public:
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
443inline 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 {
462 }
463
465 {
467 }
468};
469
470#endif // INCLUDED_SW_SOURCE_CORE_INC_ROOTFRM_HXX
471
472/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwRootFrame * pRoot
Definition: viewsh.hxx:594
helper class to disable creation of an action by a callback event in particular, change event from a ...
Definition: rootfrm.hxx:451
SwRootFrame & m_rRootFrame
Definition: rootfrm.hxx:453
DisableCallbackAction(SwRootFrame &rRootFrame)
Definition: rootfrm.hxx:457
bool m_bOldCallbackActionState
Definition: rootfrm.hxx:454
virtual void StartIdling()=0
Start the idle task.
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Definition: cntfrm.hxx:58
IDocumentTimerAccess const & getIDocumentTimerAccess() const
Definition: doc.cxx:250
Style of a layout element.
Definition: frmfmt.hxx:62
Base class of the Writer layout elements.
Definition: frame.hxx:315
virtual Size ChgSize(const Size &aNewSize)
Definition: wsfrm.cxx:737
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame.
Definition: layfrm.hxx:36
virtual void MakeAll(vcl::RenderContext *pRenderContext) override
Definition: calcmove.cxx:944
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
virtual SwTwips GrowFrame(SwTwips, bool bTst=false, bool bInfo=false) override
Definition: wsfrm.cxx:2633
virtual bool FillSelection(SwSelectionList &rList, const SwRect &rRect) const override
Definition: trvlfrm.cxx:367
virtual void DestroyImpl() override
Definition: ssfrm.cxx:485
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: wsfrm.cxx:1344
virtual SwTwips ShrinkFrame(SwTwips, bool bTst=false, bool bInfo=false) override
Definition: wsfrm.cxx:2817
virtual void PaintSwFrame(vcl::RenderContext &rRenderContext, SwRect const &, SwPrintData const *const pPrintData=nullptr) const override
Definition: paintfrm.cxx:3493
virtual void Cut() override
Definition: wsfrm.cxx:1441
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:187
A page of the document layout.
Definition: pagefrm.hxx:58
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
void AddAccessibleShell()
Definition: rootfrm.hxx:390
bool IsAssertFlyPages() const
Definition: rootfrm.hxx:279
void DeleteEmptySct()
Definition: rootfrm.hxx:380
bool IsNewLayout() const
Definition: rootfrm.hxx:372
SwPageFrame * mpLastPage
We should not need to always struggle to find the last page, so store it here.
Definition: rootfrm.hxx:136
SwViewShell * mpCurrShell
Definition: rootfrm.hxx:163
void ResetTurboFlag() const
Definition: rootfrm.hxx:348
void SetVirtPageNum(const bool bOf) const
Definition: rootfrm.hxx:443
void FreezeLayout(bool freeze)
Definition: rootfrm.hxx:413
bool IsSuperfluous() const
Definition: rootfrm.hxx:302
std::unique_ptr< SwCurrShells > mpCurrShells
Definition: rootfrm.hxx:165
const SwContentFrame * mpTurbo
If we only have to format one ContentFrame, its in mpTurbo.
Definition: rootfrm.hxx:133
static bool s_isInPaint
Definition: rootfrm.hxx:105
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:206
static bool IsInPaint()
Definition: rootfrm.hxx:365
bool IsVirtPageNum() const
Definition: rootfrm.hxx:315
bool mbIdleFormat
Definition: rootfrm.hxx:112
std::unique_ptr< SwDestroyList > mpDestroy
Definition: rootfrm.hxx:170
bool IsLayoutFreezed() const
Definition: rootfrm.hxx:412
void ImplInvalidateBrowseWidth()
Definition: pagechg.cxx:1781
SdrPage * GetDrawPage()
Definition: rootfrm.hxx:227
sal_uInt16 mnAccessibleShells
Page count.
Definition: rootfrm.hxx:173
const SwContentFrame * GetTurbo() const
Definition: rootfrm.hxx:352
tools::Long GetBrowseWidth() const
Definition: rootfrm.hxx:430
void SetSuperfluous()
Remove superfluous Pages.
Definition: rootfrm.hxx:301
bool HasMergedParas() const
Definition: rootfrm.hxx:425
bool mbIsVirtPageNum
Definition: rootfrm.hxx:117
bool IsAnyShellAccessible() const
Definition: rootfrm.hxx:389
bool mbTableUpdateInProgress
Definition: rootfrm.hxx:116
const SdrPage * GetDrawPage() const
Definition: rootfrm.hxx:226
std::vector< SwRect > maPageRects
Definition: rootfrm.hxx:93
void InvalidateBrowseWidth()
Definition: rootfrm.hxx:437
sal_uInt16 GetPageNum() const
Definition: rootfrm.hxx:312
void SetTurbo(const SwContentFrame *pContent)
Definition: rootfrm.hxx:350
void SetIdleFlags()
Definition: rootfrm.hxx:248
const SwRect & GetPagesArea() const
Definition: rootfrm.hxx:409
SwRect maPagesArea
Definition: rootfrm.hxx:96
bool IsTableUpdateInProgress() const
Definition: rootfrm.hxx:282
sal_uInt16 mnPhyPageNums
Definition: rootfrm.hxx:172
sal_uInt16 mnColumns
Definition: rootfrm.hxx:98
void ResetIdleFormat()
Definition: rootfrm.hxx:259
void DecrPhyPageNums()
Definition: rootfrm.hxx:313
bool mbLayoutFreezed
Definition: rootfrm.hxx:121
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding).
Definition: rootfrm.hxx:421
bool IsCallbackActionEnabled() const
Definition: rootfrm.hxx:387
bool mbCallbackActionEnabled
Definition: rootfrm.hxx:119
SwViewShell * mpWaitingCurrShell
Definition: rootfrm.hxx:164
void SetNeedGrammarCheck(bool bVal)
Definition: rootfrm.hxx:262
bool mbBrowseWidthValid
Definition: rootfrm.hxx:113
SwPageFrame * GetLastPage()
Definition: rootfrm.hxx:363
bool mbAssertFlyPages
Definition: rootfrm.hxx:115
const SwPageFrame * GetLastPage() const
Definition: rootfrm.hxx:362
SdrPage * mpDrawPage
One Page per DrawModel per Document; is always the size of the Root.
Definition: rootfrm.hxx:168
void RemoveAccessibleShell()
Definition: rootfrm.hxx:391
bool IsIdleFormat() const
Definition: rootfrm.hxx:258
bool mbSidebarChanged
Definition: rootfrm.hxx:100
sw::FieldmarkMode GetFieldmarkMode() const
Definition: rootfrm.hxx:423
void ResetNewLayout()
Definition: rootfrm.hxx:373
tools::Long mnViewWidth
Definition: rootfrm.hxx:97
void SetDrawPage(SdrPage *pNew)
Definition: rootfrm.hxx:228
void DisallowTurbo() const
Definition: rootfrm.hxx:347
tools::Long mnBrowseWidth
For BrowseMode mnBrowseWidth is the outer margin of the object most to the right.
Definition: rootfrm.hxx:130
bool mbBookMode
Definition: rootfrm.hxx:99
static void SetNoVirDev(const bool bNew)
Definition: rootfrm.hxx:367
void RemoveFromList(SwSectionFrame *pSct)
Definition: rootfrm.hxx:381
void SetCallbackActionEnabled(bool b)
Definition: rootfrm.hxx:386
void SetTableUpdateInProgress(bool bValue)
Definition: rootfrm.hxx:281
bool IsTurboAllowed() const
Definition: rootfrm.hxx:349
bool mbCheckSuperfluous
Definition: rootfrm.hxx:111
sw::FieldmarkMode m_FieldmarkMode
Definition: rootfrm.hxx:123
void ResetTurbo()
Definition: rootfrm.hxx:351
void SetSidebarChanged()
Definition: rootfrm.hxx:410
void SetAssertFlyPages()
Makes sure that all requested page-bound Flys find a Page.
Definition: rootfrm.hxx:277
bool mbTurboAllowed
Definition: rootfrm.hxx:114
void IncrPhyPageNums()
Definition: rootfrm.hxx:314
static bool s_isNoVirDev
Definition: rootfrm.hxx:106
static SwLayVout * s_pVout
Definition: rootfrm.hxx:104
bool mbNeedGrammarCheck
Definition: rootfrm.hxx:102
bool IsNeedGrammarCheck() const
Definition: rootfrm.hxx:261
void ImplCalcBrowseWidth()
Definition: pagechg.cxx:1792
bool mbHideRedlines
Definition: rootfrm.hxx:122
bool mbIsNewLayout
Definition: rootfrm.hxx:118
This class is used as parameter for creation of a block cursor selection.
SwDoc * GetDoc() const
Definition: viewsh.hxx:290
void Init()
constexpr auto toTwips(N number, Length from)
Dialog to specify the properties of date form field.
FieldmarkMode
Definition: rootfrm.hxx:49
RedlineMode
Definition: rootfrm.hxx:45
long Long
void FrameInit()
Definition: newfrm.cxx:295
void SetShell(SwViewShell *pSh)
Definition: newfrm.cxx:352
void FrameFinit()
Definition: newfrm.cxx:306
void InitCurrShells(SwRootFrame *pRoot)
Definition: newfrm.cxx:389
void AdjustSizeChgNotify(SwRootFrame *pRoot)
Definition: pagechg.cxx:822
void SetLastPage(SwPageFrame *pPage)
Definition: pagechg.cxx:841
SwInvalidateFlags
Definition: rootfrm.hxx:53
std::set< CurrShell * > SwCurrShells
Definition: rootfrm.hxx:74
SwRemoveResult
Definition: rootfrm.hxx:69
Marks a position in the document model.
Definition: pam.hxx:37
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
tools::Long SwTwips
Definition: swtypes.hxx:51