Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / core / layout / newfrm.cxx
blobf68b24ef72e6a2df8488304df2aa224bccf75bbd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
22 #include <o3tl/safeint.hxx>
23 #include <svx/svdpage.hxx>
24 #include <osl/diagnose.h>
25 #include <drawdoc.hxx>
26 #include <fmtpdsc.hxx>
27 #include <swtable.hxx>
28 #include <rootfrm.hxx>
29 #include <pagefrm.hxx>
30 #include <dflyobj.hxx>
31 #include <frmtool.hxx>
32 #include "virtoutp.hxx"
33 #include <notxtfrm.hxx>
34 #include <pagedesc.hxx>
35 #include <viewimp.hxx>
36 #include <hints.hxx>
37 #include <viewopt.hxx>
38 #include <set>
39 #include <IDocumentDrawModelAccess.hxx>
40 #include <IDocumentSettingAccess.hxx>
41 #include <IDocumentFieldsAccess.hxx>
42 #include <DocumentLayoutManager.hxx>
43 #include <DocumentRedlineManager.hxx>
44 #include <ndindex.hxx>
46 SwLayVout *SwRootFrame::s_pVout = nullptr;
47 bool SwRootFrame::s_isInPaint = false;
48 bool SwRootFrame::s_isNoVirDev = false;
49 SwRootFrame* SwRootFrame::s_pLast = nullptr;
51 SwCache *SwFrame::spCache = nullptr;
53 static tools::Long FirstMinusSecond( tools::Long nFirst, tools::Long nSecond )
54 { return nFirst - nSecond; }
55 static tools::Long SecondMinusFirst( tools::Long nFirst, tools::Long nSecond )
56 { return nSecond - nFirst; }
57 static tools::Long SwIncrement( tools::Long nA, tools::Long nAdd )
58 { return nA + nAdd; }
59 static tools::Long SwDecrement( tools::Long nA, tools::Long nSub )
60 { return nA - nSub; }
62 static SwRectFnCollection aHorizontal = {
63 /*.fnGetTop =*/&SwRect::Top_,
64 /*.fnGetBottom =*/&SwRect::Bottom_,
65 /*.fnGetLeft =*/&SwRect::Left_,
66 /*.fnGetRight =*/&SwRect::Right_,
67 /*.fnGetWidth =*/&SwRect::Width_,
68 /*.fnGetHeight =*/&SwRect::Height_,
69 /*.fnGetPos =*/&SwRect::TopLeft,
70 /*.fnGetSize =*/&SwRect::Size_,
72 /*.fnSetTop =*/&SwRect::Top_,
73 /*.fnSetBottom =*/&SwRect::Bottom_,
74 /*.fnSetLeft =*/&SwRect::Left_,
75 /*.fnSetRight =*/&SwRect::Right_,
76 /*.fnSetWidth =*/&SwRect::Width_,
77 /*.fnSetHeight =*/&SwRect::Height_,
79 /*.fnSubTop =*/&SwRect::SubTop,
80 /*.fnAddBottom =*/&SwRect::AddBottom,
81 /*.fnSubLeft =*/&SwRect::SubLeft,
82 /*.fnAddRight =*/&SwRect::AddRight,
83 /*.fnAddWidth =*/&SwRect::AddWidth,
84 /*.fnAddHeight =*/&SwRect::AddHeight,
86 /*.fnSetPosX =*/&SwRect::SetPosX,
87 /*.fnSetPosY =*/&SwRect::SetPosY,
89 /*.fnGetTopMargin =*/&SwFrame::GetTopMargin,
90 /*.fnGetBottomMargin =*/&SwFrame::GetBottomMargin,
91 /*.fnGetLeftMargin =*/&SwFrame::GetLeftMargin,
92 /*.fnGetRightMargin =*/&SwFrame::GetRightMargin,
93 /*.fnSetXMargins =*/&SwFrame::SetLeftRightMargins,
94 /*.fnSetYMargins =*/&SwFrame::SetTopBottomMargins,
95 /*.fnGetPrtTop =*/&SwFrame::GetPrtTop,
96 /*.fnGetPrtBottom =*/&SwFrame::GetPrtBottom,
97 /*.fnGetPrtLeft =*/&SwFrame::GetPrtLeft,
98 /*.fnGetPrtRight =*/&SwFrame::GetPrtRight,
99 /*.fnTopDist =*/&SwRect::GetTopDistance,
100 /*.fnBottomDist =*/&SwRect::GetBottomDistance,
101 /*.fnLeftDist =*/&SwRect::GetLeftDistance,
102 /*.fnRightDist =*/&SwRect::GetRightDistance,
103 /*.fnSetLimit =*/&SwFrame::SetMaxBottom,
104 /*.fnOverStep =*/&SwRect::OverStepBottom,
106 /*.fnSetPos =*/&SwRect::SetUpperLeftCorner,
107 /*.fnMakePos =*/&SwFrame::MakeBelowPos,
108 /*.fnXDiff =*/&FirstMinusSecond,
109 /*.fnYDiff =*/&FirstMinusSecond,
110 /*.fnXInc =*/&SwIncrement,
111 /*.fnYInc =*/&o3tl::saturating_add<tools::Long>,
113 /*.fnSetLeftAndWidth =*/&SwRect::SetLeftAndWidth,
114 /*.fnSetTopAndHeight =*/&SwRect::SetTopAndHeight
117 static SwRectFnCollection aVertical = {
118 /*.fnGetTop =*/&SwRect::Right_,
119 /*.fnGetBottom =*/&SwRect::Left_,
120 /*.fnGetLeft =*/&SwRect::Top_,
121 /*.fnGetRight =*/&SwRect::Bottom_,
122 /*.fnGetWidth =*/&SwRect::Height_,
123 /*.fnGetHeight =*/&SwRect::Width_,
124 /*.fnGetPos =*/&SwRect::TopRight,
125 /*.fnGetSize =*/&SwRect::SwappedSize,
127 /*.fnSetTop =*/&SwRect::Right_,
128 /*.fnSetBottom =*/&SwRect::Left_,
129 /*.fnSetLeft =*/&SwRect::Top_,
130 /*.fnSetRight =*/&SwRect::Bottom_,
131 /*.fnSetWidth =*/&SwRect::Height_,
132 /*.fnSetHeight =*/&SwRect::Width_,
134 /*.fnSubTop =*/&SwRect::AddRight,
135 /*.fnAddBottom =*/&SwRect::SubLeft,
136 /*.fnSubLeft =*/&SwRect::SubTop,
137 /*.fnAddRight =*/&SwRect::AddBottom,
138 /*.fnAddWidth =*/&SwRect::AddHeight,
139 /*.fnAddHeight =*/&SwRect::AddWidth,
141 /*.fnSetPosX =*/&SwRect::SetPosY,
142 /*.fnSetPosY =*/&SwRect::SetPosX,
144 /*.fnGetTopMargin =*/&SwFrame::GetRightMargin,
145 /*.fnGetBottomMargin =*/&SwFrame::GetLeftMargin,
146 /*.fnGetLeftMargin =*/&SwFrame::GetTopMargin,
147 /*.fnGetRightMargin =*/&SwFrame::GetBottomMargin,
148 /*.fnSetXMargins =*/&SwFrame::SetTopBottomMargins,
149 /*.fnSetYMargins =*/&SwFrame::SetRightLeftMargins,
150 /*.fnGetPrtTop =*/&SwFrame::GetPrtRight,
151 /*.fnGetPrtBottom =*/&SwFrame::GetPrtLeft,
152 /*.fnGetPrtLeft =*/&SwFrame::GetPrtTop,
153 /*.fnGetPrtRight =*/&SwFrame::GetPrtBottom,
154 /*.fnTopDist =*/&SwRect::GetRightDistance,
155 /*.fnBottomDist =*/&SwRect::GetLeftDistance,
156 /*.fnLeftDist =*/&SwRect::GetTopDistance,
157 /*.fnRightDist =*/&SwRect::GetBottomDistance,
158 /*.fnSetLimit =*/&SwFrame::SetMinLeft,
159 /*.fnOverStep =*/&SwRect::OverStepLeft,
161 /*.fnSetPos =*/&SwRect::SetUpperRightCorner,
162 /*.fnMakePos =*/&SwFrame::MakeLeftPos,
163 /*.fnXDiff =*/&FirstMinusSecond,
164 /*.fnYDiff =*/&SecondMinusFirst,
165 /*.fnXInc =*/&SwIncrement,
166 /*.fnYInc =*/&SwDecrement,
168 /*.fnSetLeftAndWidth =*/&SwRect::SetTopAndHeight,
169 /*.fnSetTopAndHeight =*/&SwRect::SetRightAndWidth
172 static SwRectFnCollection aVerticalLeftToRight = {
173 /*.fnGetTop =*/&SwRect::Left_,
174 /*.fnGetBottom =*/&SwRect::Right_,
175 /*.fnGetLeft =*/&SwRect::Top_,
176 /*.fnGetRight =*/&SwRect::Bottom_,
177 /*.fnGetWidth =*/&SwRect::Height_,
178 /*.fnGetHeight =*/&SwRect::Width_,
179 /*.fnGetPos =*/&SwRect::TopLeft,
180 /*.fnGetSize =*/&SwRect::SwappedSize,
182 /*.fnSetTop =*/&SwRect::Left_,
183 /*.fnSetBottom =*/&SwRect::Right_,
184 /*.fnSetLeft =*/&SwRect::Top_,
185 /*.fnSetRight =*/&SwRect::Bottom_,
186 /*.fnSetWidth =*/&SwRect::Height_,
187 /*.fnSetHeight =*/&SwRect::Width_,
189 /*.fnSubTop =*/&SwRect::SubLeft,
190 /*.fnAddBottom =*/&SwRect::AddRight,
191 /*.fnSubLeft =*/&SwRect::SubTop,
192 /*.fnAddRight =*/&SwRect::AddBottom,
193 /*.fnAddWidth =*/&SwRect::AddHeight,
194 /*.fnAddHeight =*/&SwRect::AddWidth,
196 /*.fnSetPosX =*/&SwRect::SetPosY,
197 /*.fnSetPosY =*/&SwRect::SetPosX,
199 /*.fnGetTopMargin =*/&SwFrame::GetLeftMargin,
200 /*.fnGetBottomMargin =*/&SwFrame::GetRightMargin,
201 /*.fnGetLeftMargin =*/&SwFrame::GetTopMargin,
202 /*.fnGetRightMargin =*/&SwFrame::GetBottomMargin,
203 /*.fnSetXMargins =*/&SwFrame::SetTopBottomMargins,
204 /*.fnSetYMargins =*/&SwFrame::SetLeftRightMargins,
205 /*.fnGetPrtTop =*/&SwFrame::GetPrtLeft,
206 /*.fnGetPrtBottom =*/&SwFrame::GetPrtRight,
207 /*.fnGetPrtLeft =*/&SwFrame::GetPrtTop,
208 /*.fnGetPrtRight =*/&SwFrame::GetPrtBottom,
209 /*.fnTopDist =*/&SwRect::GetLeftDistance,
210 /*.fnBottomDist =*/&SwRect::GetRightDistance,
211 /*.fnLeftDist =*/&SwRect::GetTopDistance,
212 /*.fnRightDist =*/&SwRect::GetBottomDistance,
213 /*.fnSetLimit =*/&SwFrame::SetMaxRight,
214 /*.fnOverStep =*/&SwRect::OverStepRight,
216 /*.fnSetPos =*/&SwRect::SetUpperLeftCorner,
217 /*.fnMakePos =*/&SwFrame::MakeRightPos,
218 /*.fnXDiff =*/&FirstMinusSecond,
219 /*.fnYDiff =*/&FirstMinusSecond,
220 /*.fnXInc =*/&SwIncrement,
221 /*.fnYInc =*/&SwIncrement,
223 /*.fnSetLeftAndWidth =*/&SwRect::SetTopAndHeight,
224 /*.fnSetTopAndHeight =*/&SwRect::SetLeftAndWidth
228 * This is the same as horizontal, but rotated counter-clockwise by 90 degrees.
229 * This means logical top is physical left, bottom is right, left is bottom,
230 * finally right is top. Values map from logical to physical.
232 static SwRectFnCollection aVerticalLeftToRightBottomToTop = {
233 /*.fnGetTop =*/&SwRect::Left_,
234 /*.fnGetBottom =*/&SwRect::Right_,
235 /*.fnGetLeft =*/&SwRect::Bottom_,
236 /*.fnGetRight =*/&SwRect::Top_,
237 /*.fnGetWidth =*/&SwRect::Height_,
238 /*.fnGetHeight =*/&SwRect::Width_,
239 /*.fnGetPos =*/&SwRect::BottomLeft,
240 /*.fnGetSize =*/&SwRect::SwappedSize,
242 /*.fnSetTop =*/&SwRect::Left_,
243 /*.fnSetBottom =*/&SwRect::Right_,
244 /*.fnSetLeft =*/&SwRect::Bottom_,
245 /*.fnSetRight =*/&SwRect::Top_,
246 /*.fnSetWidth =*/&SwRect::Height_,
247 /*.fnSetHeight =*/&SwRect::Width_,
249 /*.fnSubTop =*/&SwRect::SubLeft,
250 /*.fnAddBottom =*/&SwRect::AddRight,
251 /*.fnSubLeft =*/&SwRect::AddBottom,
252 /*.fnAddRight =*/&SwRect::SubTop,
253 /*.fnAddWidth =*/&SwRect::AddHeight,
254 /*.fnAddHeight =*/&SwRect::AddWidth,
256 /*.fnSetPosX =*/&SwRect::SetPosY,
257 /*.fnSetPosY =*/&SwRect::SetPosX,
259 /*.fnGetTopMargin =*/&SwFrame::GetLeftMargin,
260 /*.fnGetBottomMargin =*/&SwFrame::GetRightMargin,
261 /*.fnGetLeftMargin =*/&SwFrame::GetBottomMargin,
262 /*.fnGetRightMargin =*/&SwFrame::GetTopMargin,
263 /*.fnSetXMargins =*/&SwFrame::SetTopBottomMargins,
264 /*.fnSetYMargins =*/&SwFrame::SetLeftRightMargins,
265 /*.fnGetPrtTop =*/&SwFrame::GetPrtLeft,
266 /*.fnGetPrtBottom =*/&SwFrame::GetPrtRight,
267 /*.fnGetPrtLeft =*/&SwFrame::GetPrtBottom,
268 /*.fnGetPrtRight =*/&SwFrame::GetPrtTop,
269 /*.fnTopDist =*/&SwRect::GetLeftDistance,
270 /*.fnBottomDist =*/&SwRect::GetRightDistance,
271 /*.fnLeftDist =*/&SwRect::GetBottomDistance,
272 /*.fnRightDist =*/&SwRect::GetTopDistance,
273 /*.fnSetLimit =*/&SwFrame::SetMaxRight,
274 /*.fnOverStep =*/&SwRect::OverStepRight,
276 /*.fnSetPos =*/&SwRect::SetLowerLeftCorner,
277 /*.fnMakePos =*/&SwFrame::MakeRightPos,
278 /*.fnXDiff =*/&SecondMinusFirst,
279 /*.fnYDiff =*/&FirstMinusSecond,
280 /*.fnXInc =*/&SwDecrement,
281 /*.fnYInc =*/&SwIncrement,
283 /*.fnSetLeftAndWidth =*/&SwRect::SetBottomAndHeight,
284 /*.fnSetTopAndHeight =*/&SwRect::SetLeftAndWidth
287 SwRectFn fnRectHori = &aHorizontal;
288 SwRectFn fnRectVert = &aVertical;
289 SwRectFn fnRectVertL2R = &aVerticalLeftToRight;
290 SwRectFn fnRectVertL2RB2T = &aVerticalLeftToRightBottomToTop;
292 // #i65250#
293 sal_uInt32 SwFrameAreaDefinition::snLastFrameId=0;
296 void FrameInit()
298 SwRootFrame::s_pVout = new SwLayVout();
299 SwCache *pNew = new SwCache( 100
300 #ifdef DBG_UTIL
301 , "static SwBorderAttrs::pCache"
302 #endif
304 SwFrame::SetCache( pNew );
307 void FrameFinit()
309 #if OSL_DEBUG_LEVEL > 0
310 // The cache may only contain null pointers at this time.
311 for( size_t n = SwFrame::GetCachePtr()->size(); n; )
312 if( (*SwFrame::GetCachePtr())[ --n ] )
314 SwCacheObj* pObj = (*SwFrame::GetCachePtr())[ n ];
315 OSL_ENSURE( !pObj, "Who didn't deregister?");
317 #endif
318 delete SwRootFrame::s_pVout;
319 delete SwFrame::GetCachePtr();
322 // RootFrame::Everything that belongs to CurrShell
324 CurrShell::CurrShell( SwViewShell *pNew )
326 OSL_ENSURE( pNew, "insert 0-Shell?" );
327 pRoot = pNew->GetLayout();
328 if ( pRoot )
330 pPrev = pRoot->mpCurrShell;
331 pRoot->mpCurrShell = pNew;
332 pRoot->mpCurrShells->insert( this );
334 else
335 pPrev = nullptr;
338 CurrShell::~CurrShell()
340 if ( pRoot )
342 pRoot->mpCurrShells->erase( this );
343 if ( pPrev )
344 pRoot->mpCurrShell = pPrev;
345 if ( pRoot->mpCurrShells->empty() && pRoot->mpWaitingCurrShell )
347 pRoot->mpCurrShell = pRoot->mpWaitingCurrShell;
348 pRoot->mpWaitingCurrShell = nullptr;
353 void SetShell( SwViewShell *pSh )
355 SwRootFrame *pRoot = pSh->GetLayout();
356 if ( pRoot->mpCurrShells->empty() )
357 pRoot->mpCurrShell = pSh;
358 else
359 pRoot->mpWaitingCurrShell = pSh;
362 void SwRootFrame::DeRegisterShell( SwViewShell *pSh )
364 // Activate some shell if possible
365 if ( mpCurrShell == pSh )
367 mpCurrShell = nullptr;
368 for(SwViewShell& rShell : pSh->GetRingContainer())
370 if(&rShell != pSh)
372 mpCurrShell = &rShell;
373 break;
378 // Doesn't matter anymore
379 if ( mpWaitingCurrShell == pSh )
380 mpWaitingCurrShell = nullptr;
382 // Remove references
383 for ( CurrShell *pC : *mpCurrShells )
385 if (pC->pPrev == pSh)
386 pC->pPrev = nullptr;
390 void InitCurrShells( SwRootFrame *pRoot )
392 pRoot->mpCurrShells.reset( new SwCurrShells );
396 |* The RootFrame requests an own FrameFormat from the document, which it is
397 |* going to delete again in the dtor. The own FrameFormat is derived from
398 |* the passed FrameFormat.
400 SwRootFrame::SwRootFrame( SwFrameFormat *pFormat, SwViewShell * pSh ) :
401 SwLayoutFrame( pFormat->GetDoc()->MakeFrameFormat(
402 "Root", pFormat ), nullptr ),
403 mnViewWidth( -1 ),
404 mnColumns( 0 ),
405 mbBookMode( false ),
406 mbSidebarChanged( false ),
407 mbNeedGrammarCheck( false ),
408 mbCheckSuperfluous( false ),
409 mbIdleFormat( true ),
410 mbBrowseWidthValid( false ),
411 mbTurboAllowed( true ),
412 mbAssertFlyPages( true ),
413 mbTableUpdateInProgress( false ),
414 mbIsVirtPageNum( false ),
415 mbIsNewLayout( true ),
416 mbCallbackActionEnabled ( false ),
417 mbLayoutFreezed ( false ),
418 mbHideRedlines(pFormat->GetDoc()->GetDocumentRedlineManager().IsHideRedlines()),
419 m_FieldmarkMode(pSh->GetViewOptions()->IsFieldName()
420 ? sw::FieldmarkMode::ShowCommand
421 : sw::FieldmarkMode::ShowResult),
422 m_ParagraphBreakMode(pSh->GetViewOptions()->IsParagraph()
423 ? sw::ParagraphBreakMode::Shown
424 : sw::ParagraphBreakMode::Hidden),
425 mnBrowseWidth(MIN_BROWSE_WIDTH),
426 mpTurbo( nullptr ),
427 mpLastPage( nullptr ),
428 mpCurrShell( pSh ),
429 mpWaitingCurrShell( nullptr ),
430 mpDrawPage( nullptr ),
431 mnPhyPageNums( 0 ),
432 mnAccessibleShells( 0 )
434 mnFrameType = SwFrameType::Root;
435 setRootFrame( this );
437 s_pLast = this;
440 void SwRootFrame::Init( SwFrameFormat* pFormat )
442 InitCurrShells( this );
444 IDocumentTimerAccess& rTimerAccess = pFormat->getIDocumentTimerAccess();
445 IDocumentLayoutAccess& rLayoutAccess = pFormat->getIDocumentLayoutAccess();
446 IDocumentFieldsAccess& rFieldsAccess = pFormat->getIDocumentFieldsAccess();
447 const IDocumentSettingAccess& rSettingAccess = pFormat->getIDocumentSettingAccess();
448 rTimerAccess.StopIdling();
449 // For creating the Flys by MakeFrames()
450 rLayoutAccess.SetCurrentViewShell( GetCurrShell() );
451 mbCallbackActionEnabled = false; // needs to be set to true before leaving!
453 SwDrawModel* pMd = pFormat->getIDocumentDrawModelAccess().GetDrawModel();
454 if ( pMd )
456 // Disable "multiple layout"
457 mpDrawPage = pMd->GetPage(0);
459 mpDrawPage->SetSize( getFrameArea().SSize() );
462 // Initialize the layout: create pages, link content with Content etc.
463 // First, initialize some stuff, then get hold of the first
464 // node (which will be needed for the PageDesc).
466 SwDoc* pDoc = pFormat->GetDoc();
467 SwNodeIndex aIndex( *pDoc->GetNodes().GetEndOfContent().StartOfSectionNode() );
468 SwContentNode *pNode = pDoc->GetNodes().GoNextSection( &aIndex, true, false );
469 // #123067# pNode = 0 can really happen
470 SwTableNode *pTableNd= pNode ? pNode->FindTableNode() : nullptr;
472 // Get hold of PageDesc (either via FrameFormat of the first node or the initial one).
473 SwPageDesc *pDesc = nullptr;
474 ::std::optional<sal_uInt16> oPgNum;
476 if ( pTableNd )
478 const SwFormatPageDesc &rDesc = pTableNd->GetTable().GetFrameFormat()->GetPageDesc();
479 pDesc = const_cast<SwPageDesc*>(rDesc.GetPageDesc());
480 //#19104# respect the page number offset!!
481 oPgNum = rDesc.GetNumOffset();
482 if (oPgNum)
483 mbIsVirtPageNum = true;
485 else if ( pNode )
487 const SwFormatPageDesc &rDesc = pNode->GetSwAttrSet().GetPageDesc();
488 pDesc = const_cast<SwPageDesc*>(rDesc.GetPageDesc());
489 //#19104# respect the page number offset!!
490 oPgNum = rDesc.GetNumOffset();
491 if (oPgNum)
492 mbIsVirtPageNum = true;
494 else
495 mbIsVirtPageNum = false;
496 if ( !pDesc )
497 pDesc = &pDoc->GetPageDesc( 0 );
499 // Create a page and put it in the layout
500 // The first page is always a right-page and always a first-page
501 SwPageFrame* pPage = ::InsertNewPage(
502 *pDesc, /*pUpper=*/this, /*isRightPage=*/true, /*bFirst=*/true, /*bInsertEmpty=*/false,
503 /*bFootnote=*/false, /*pSibling=*/nullptr, /*bVeryFirstPage=*/true);
505 // Find the first page in the Bodytext section.
506 SwLayoutFrame *pLay = pPage->FindBodyCont();
507 while( pLay->Lower() )
508 pLay = static_cast<SwLayoutFrame*>(pLay->Lower());
510 SwNodeIndex aTmp( *pDoc->GetNodes().GetEndOfContent().StartOfSectionNode(), 1 );
511 ::InsertCnt_( pLay, pDoc, aTmp.GetIndex(), true );
513 // tdf#156077 create all pages for at-page anchored flys now because all
514 // these flys must be attached to some page when Init() is finished
515 AssertFlyPages();
517 if( rSettingAccess.get(DocumentSettingId::GLOBAL_DOCUMENT) )
518 rFieldsAccess.UpdateRefFields();
519 //b6433357: Update page fields after loading
520 if ( !mpCurrShell || !mpCurrShell->Imp()->IsUpdateExpFields() )
522 rFieldsAccess.UpdatePageFields(pPage->getFrameArea().Top());
525 rTimerAccess.StartIdling();
526 mbCallbackActionEnabled = true;
528 SwViewShell *pViewSh = GetCurrShell();
529 if (pViewSh)
530 mbNeedGrammarCheck = pViewSh->GetViewOptions()->IsOnlineSpell();
533 void SwRootFrame::DestroyImpl()
535 mbTurboAllowed = false;
536 mpTurbo = nullptr;
538 SwFrameFormat *pRegisteredInNonConst = static_cast<SwFrameFormat*>(GetDep());
539 if ( pRegisteredInNonConst )
541 SwDoc *pDoc = pRegisteredInNonConst->GetDoc();
542 pDoc->DelFrameFormat( pRegisteredInNonConst );
543 // do this before calling RemoveFootnotes() because footnotes
544 // can contain anchored objects
545 pDoc->GetDocumentLayoutManager().ClearSwLayouterEntries();
548 mpDestroy.reset();
550 // Remove references
551 for ( auto& rpCurrShell : *mpCurrShells )
552 rpCurrShell->pRoot = nullptr;
554 mpCurrShells.reset();
556 // Some accessible shells are left => problems on second SwFrame::Destroy call
557 assert(0 == mnAccessibleShells);
559 // fdo#39510 crash on document close with footnotes
560 // Object ownership in writer and esp. in layout are a mess: Before the
561 // document/layout split SwDoc and SwRootFrame were essentially one object
562 // and magically/uncleanly worked around their common destruction by call
563 // to SwDoc::IsInDtor() -- even from the layout. As of now destruction of
564 // the layout proceeds forward through the frames. Since SwTextFootnote::DelFrames
565 // also searches backwards to find the master of footnotes, they must be
566 // considered to be owned by the SwRootFrame and also be destroyed here,
567 // before tearing down the (now footnote free) rest of the layout.
568 RemoveFootnotes(nullptr, false, true);
570 SwLayoutFrame::DestroyImpl();
573 SwRootFrame::~SwRootFrame()
575 s_pLast = nullptr;
578 void SwRootFrame::RemoveMasterObjs( SdrPage *pPg )
580 // Remove all master objects from the Page. But don't delete!
581 for( size_t i = pPg ? pPg->GetObjCount() : 0; i; )
583 SdrObject* pObj = pPg->GetObj( --i );
584 if( dynamic_cast< const SwFlyDrawObj *>( pObj ) != nullptr )
585 pPg->RemoveObject( i );
589 void SwRootFrame::AllCheckPageDescs() const
591 if ( !IsLayoutFreezed() )
592 CheckPageDescs( const_cast<SwPageFrame*>(static_cast<const SwPageFrame*>(Lower())) );
595 void SwRootFrame::AllInvalidateAutoCompleteWords() const
597 SwPageFrame *pPage = const_cast<SwPageFrame*>(static_cast<const SwPageFrame*>(Lower()));
598 while ( pPage )
600 pPage->InvalidateAutoCompleteWords();
601 pPage = static_cast<SwPageFrame*>(pPage->GetNext());
605 void SwRootFrame::AllAddPaintRect() const
607 GetCurrShell()->AddPaintRect( getFrameArea() );
610 void SwRootFrame::AllRemoveFootnotes()
612 RemoveFootnotes();
615 void SwRootFrame::AllInvalidateSmartTagsOrSpelling(bool bSmartTags) const
617 SwPageFrame *pPage = const_cast<SwPageFrame*>(static_cast<const SwPageFrame*>(Lower()));
618 while ( pPage )
620 if ( bSmartTags )
621 pPage->InvalidateSmartTags();
623 pPage->InvalidateSpelling();
624 pPage = static_cast<SwPageFrame*>(pPage->GetNext());
628 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */