LibreOffice Module sw (master)  1
newfrm.cxx
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 
20 #include <sal/config.h>
21 
22 #include <o3tl/safeint.hxx>
23 #include <svx/svdpage.hxx>
24 #include <drawdoc.hxx>
25 #include <fmtpdsc.hxx>
26 #include <swtable.hxx>
27 #include <rootfrm.hxx>
28 #include <pagefrm.hxx>
29 #include <dflyobj.hxx>
30 #include <frmtool.hxx>
31 #include "virtoutp.hxx"
32 #include <blink.hxx>
33 #include <notxtfrm.hxx>
34 #include <pagedesc.hxx>
35 #include <viewimp.hxx>
36 #include <hints.hxx>
37 #include <viewopt.hxx>
38 #include <set>
44 #include <ndindex.hxx>
45 
47 bool SwRootFrame::s_isInPaint = false;
48 bool SwRootFrame::s_isNoVirDev = false;
49 
50 SwCache *SwFrame::mpCache = nullptr;
51 
52 static long FirstMinusSecond( long nFirst, long nSecond )
53  { return nFirst - nSecond; }
54 static long SecondMinusFirst( long nFirst, long nSecond )
55  { return nSecond - nFirst; }
56 static long SwIncrement( long nA, long nAdd )
57  { return nA + nAdd; }
58 static long SwDecrement( long nA, long nSub )
59  { return nA - nSub; }
60 
62  /*.fnGetTop =*/&SwRect::Top_,
63  /*.fnGetBottom =*/&SwRect::Bottom_,
64  /*.fnGetLeft =*/&SwRect::Left_,
65  /*.fnGetRight =*/&SwRect::Right_,
66  /*.fnGetWidth =*/&SwRect::Width_,
67  /*.fnGetHeight =*/&SwRect::Height_,
68  /*.fnGetPos =*/&SwRect::TopLeft,
69  /*.fnGetSize =*/&SwRect::Size_,
70 
71  /*.fnSetTop =*/&SwRect::Top_,
72  /*.fnSetBottom =*/&SwRect::Bottom_,
73  /*.fnSetLeft =*/&SwRect::Left_,
74  /*.fnSetRight =*/&SwRect::Right_,
75  /*.fnSetWidth =*/&SwRect::Width_,
76  /*.fnSetHeight =*/&SwRect::Height_,
77 
78  /*.fnSubTop =*/&SwRect::SubTop,
79  /*.fnAddBottom =*/&SwRect::AddBottom,
80  /*.fnSubLeft =*/&SwRect::SubLeft,
81  /*.fnAddRight =*/&SwRect::AddRight,
82  /*.fnAddWidth =*/&SwRect::AddWidth,
83  /*.fnAddHeight =*/&SwRect::AddHeight,
84 
85  /*.fnSetPosX =*/&SwRect::SetPosX,
86  /*.fnSetPosY =*/&SwRect::SetPosY,
87 
88  /*.fnGetTopMargin =*/&SwFrame::GetTopMargin,
89  /*.fnGetBottomMargin =*/&SwFrame::GetBottomMargin,
90  /*.fnGetLeftMargin =*/&SwFrame::GetLeftMargin,
91  /*.fnGetRightMargin =*/&SwFrame::GetRightMargin,
92  /*.fnSetXMargins =*/&SwFrame::SetLeftRightMargins,
93  /*.fnSetYMargins =*/&SwFrame::SetTopBottomMargins,
94  /*.fnGetPrtTop =*/&SwFrame::GetPrtTop,
95  /*.fnGetPrtBottom =*/&SwFrame::GetPrtBottom,
96  /*.fnGetPrtLeft =*/&SwFrame::GetPrtLeft,
97  /*.fnGetPrtRight =*/&SwFrame::GetPrtRight,
98  /*.fnTopDist =*/&SwRect::GetTopDistance,
99  /*.fnBottomDist =*/&SwRect::GetBottomDistance,
100  /*.fnLeftDist =*/&SwRect::GetLeftDistance,
101  /*.fnRightDist =*/&SwRect::GetRightDistance,
102  /*.fnSetLimit =*/&SwFrame::SetMaxBottom,
103  /*.fnOverStep =*/&SwRect::OverStepBottom,
104 
105  /*.fnSetPos =*/&SwRect::SetUpperLeftCorner,
106  /*.fnMakePos =*/&SwFrame::MakeBelowPos,
107  /*.fnXDiff =*/&FirstMinusSecond,
108  /*.fnYDiff =*/&FirstMinusSecond,
109  /*.fnXInc =*/&SwIncrement,
110  /*.fnYInc =*/&o3tl::saturating_add<long>,
111 
112  /*.fnSetLeftAndWidth =*/&SwRect::SetLeftAndWidth,
113  /*.fnSetTopAndHeight =*/&SwRect::SetTopAndHeight
114 };
115 
117  /*.fnGetTop =*/&SwRect::Right_,
118  /*.fnGetBottom =*/&SwRect::Left_,
119  /*.fnGetLeft =*/&SwRect::Top_,
120  /*.fnGetRight =*/&SwRect::Bottom_,
121  /*.fnGetWidth =*/&SwRect::Height_,
122  /*.fnGetHeight =*/&SwRect::Width_,
123  /*.fnGetPos =*/&SwRect::TopRight,
124  /*.fnGetSize =*/&SwRect::SwappedSize,
125 
126  /*.fnSetTop =*/&SwRect::Right_,
127  /*.fnSetBottom =*/&SwRect::Left_,
128  /*.fnSetLeft =*/&SwRect::Top_,
129  /*.fnSetRight =*/&SwRect::Bottom_,
130  /*.fnSetWidth =*/&SwRect::Height_,
131  /*.fnSetHeight =*/&SwRect::Width_,
132 
133  /*.fnSubTop =*/&SwRect::AddRight,
134  /*.fnAddBottom =*/&SwRect::SubLeft,
135  /*.fnSubLeft =*/&SwRect::SubTop,
136  /*.fnAddRight =*/&SwRect::AddBottom,
137  /*.fnAddWidth =*/&SwRect::AddHeight,
138  /*.fnAddHeight =*/&SwRect::AddWidth,
139 
140  /*.fnSetPosX =*/&SwRect::SetPosY,
141  /*.fnSetPosY =*/&SwRect::SetPosX,
142 
143  /*.fnGetTopMargin =*/&SwFrame::GetRightMargin,
144  /*.fnGetBottomMargin =*/&SwFrame::GetLeftMargin,
145  /*.fnGetLeftMargin =*/&SwFrame::GetTopMargin,
146  /*.fnGetRightMargin =*/&SwFrame::GetBottomMargin,
147  /*.fnSetXMargins =*/&SwFrame::SetTopBottomMargins,
148  /*.fnSetYMargins =*/&SwFrame::SetRightLeftMargins,
149  /*.fnGetPrtTop =*/&SwFrame::GetPrtRight,
150  /*.fnGetPrtBottom =*/&SwFrame::GetPrtLeft,
151  /*.fnGetPrtLeft =*/&SwFrame::GetPrtTop,
152  /*.fnGetPrtRight =*/&SwFrame::GetPrtBottom,
153  /*.fnTopDist =*/&SwRect::GetRightDistance,
154  /*.fnBottomDist =*/&SwRect::GetLeftDistance,
155  /*.fnLeftDist =*/&SwRect::GetTopDistance,
156  /*.fnRightDist =*/&SwRect::GetBottomDistance,
157  /*.fnSetLimit =*/&SwFrame::SetMinLeft,
158  /*.fnOverStep =*/&SwRect::OverStepLeft,
159 
160  /*.fnSetPos =*/&SwRect::SetUpperRightCorner,
161  /*.fnMakePos =*/&SwFrame::MakeLeftPos,
162  /*.fnXDiff =*/&FirstMinusSecond,
163  /*.fnYDiff =*/&SecondMinusFirst,
164  /*.fnXInc =*/&SwIncrement,
165  /*.fnYInc =*/&SwDecrement,
166 
167  /*.fnSetLeftAndWidth =*/&SwRect::SetTopAndHeight,
168  /*.fnSetTopAndHeight =*/&SwRect::SetRightAndWidth
169 };
170 
172  /*.fnGetTop =*/&SwRect::Left_,
173  /*.fnGetBottom =*/&SwRect::Right_,
174  /*.fnGetLeft =*/&SwRect::Top_,
175  /*.fnGetRight =*/&SwRect::Bottom_,
176  /*.fnGetWidth =*/&SwRect::Height_,
177  /*.fnGetHeight =*/&SwRect::Width_,
178  /*.fnGetPos =*/&SwRect::TopLeft,
179  /*.fnGetSize =*/&SwRect::SwappedSize,
180 
181  /*.fnSetTop =*/&SwRect::Left_,
182  /*.fnSetBottom =*/&SwRect::Right_,
183  /*.fnSetLeft =*/&SwRect::Top_,
184  /*.fnSetRight =*/&SwRect::Bottom_,
185  /*.fnSetWidth =*/&SwRect::Height_,
186  /*.fnSetHeight =*/&SwRect::Width_,
187 
188  /*.fnSubTop =*/&SwRect::SubLeft,
189  /*.fnAddBottom =*/&SwRect::AddRight,
190  /*.fnSubLeft =*/&SwRect::SubTop,
191  /*.fnAddRight =*/&SwRect::AddBottom,
192  /*.fnAddWidth =*/&SwRect::AddHeight,
193  /*.fnAddHeight =*/&SwRect::AddWidth,
194 
195  /*.fnSetPosX =*/&SwRect::SetPosY,
196  /*.fnSetPosY =*/&SwRect::SetPosX,
197 
198  /*.fnGetTopMargin =*/&SwFrame::GetLeftMargin,
199  /*.fnGetBottomMargin =*/&SwFrame::GetRightMargin,
200  /*.fnGetLeftMargin =*/&SwFrame::GetTopMargin,
201  /*.fnGetRightMargin =*/&SwFrame::GetBottomMargin,
202  /*.fnSetXMargins =*/&SwFrame::SetTopBottomMargins,
203  /*.fnSetYMargins =*/&SwFrame::SetLeftRightMargins,
204  /*.fnGetPrtTop =*/&SwFrame::GetPrtLeft,
205  /*.fnGetPrtBottom =*/&SwFrame::GetPrtRight,
206  /*.fnGetPrtLeft =*/&SwFrame::GetPrtTop,
207  /*.fnGetPrtRight =*/&SwFrame::GetPrtBottom,
208  /*.fnTopDist =*/&SwRect::GetLeftDistance,
209  /*.fnBottomDist =*/&SwRect::GetRightDistance,
210  /*.fnLeftDist =*/&SwRect::GetTopDistance,
211  /*.fnRightDist =*/&SwRect::GetBottomDistance,
212  /*.fnSetLimit =*/&SwFrame::SetMaxRight,
213  /*.fnOverStep =*/&SwRect::OverStepRight,
214 
215  /*.fnSetPos =*/&SwRect::SetUpperLeftCorner,
216  /*.fnMakePos =*/&SwFrame::MakeRightPos,
217  /*.fnXDiff =*/&FirstMinusSecond,
218  /*.fnYDiff =*/&FirstMinusSecond,
219  /*.fnXInc =*/&SwIncrement,
220  /*.fnYInc =*/&SwIncrement,
221 
222  /*.fnSetLeftAndWidth =*/&SwRect::SetTopAndHeight,
223  /*.fnSetTopAndHeight =*/&SwRect::SetLeftAndWidth
224 };
225 
232  /*.fnGetTop =*/&SwRect::Left_,
233  /*.fnGetBottom =*/&SwRect::Right_,
234  /*.fnGetLeft =*/&SwRect::Bottom_,
235  /*.fnGetRight =*/&SwRect::Top_,
236  /*.fnGetWidth =*/&SwRect::Height_,
237  /*.fnGetHeight =*/&SwRect::Width_,
238  /*.fnGetPos =*/&SwRect::BottomLeft,
239  /*.fnGetSize =*/&SwRect::SwappedSize,
240 
241  /*.fnSetTop =*/&SwRect::Left_,
242  /*.fnSetBottom =*/&SwRect::Right_,
243  /*.fnSetLeft =*/&SwRect::Bottom_,
244  /*.fnSetRight =*/&SwRect::Top_,
245  /*.fnSetWidth =*/&SwRect::Height_,
246  /*.fnSetHeight =*/&SwRect::Width_,
247 
248  /*.fnSubTop =*/&SwRect::SubLeft,
249  /*.fnAddBottom =*/&SwRect::AddRight,
250  /*.fnSubLeft =*/&SwRect::AddBottom,
251  /*.fnAddRight =*/&SwRect::SubTop,
252  /*.fnAddWidth =*/&SwRect::AddHeight,
253  /*.fnAddHeight =*/&SwRect::AddWidth,
254 
255  /*.fnSetPosX =*/&SwRect::SetPosY,
256  /*.fnSetPosY =*/&SwRect::SetPosX,
257 
258  /*.fnGetTopMargin =*/&SwFrame::GetLeftMargin,
259  /*.fnGetBottomMargin =*/&SwFrame::GetRightMargin,
260  /*.fnGetLeftMargin =*/&SwFrame::GetBottomMargin,
261  /*.fnGetRightMargin =*/&SwFrame::GetTopMargin,
262  /*.fnSetXMargins =*/&SwFrame::SetTopBottomMargins,
263  /*.fnSetYMargins =*/&SwFrame::SetLeftRightMargins,
264  /*.fnGetPrtTop =*/&SwFrame::GetPrtLeft,
265  /*.fnGetPrtBottom =*/&SwFrame::GetPrtRight,
266  /*.fnGetPrtLeft =*/&SwFrame::GetPrtBottom,
267  /*.fnGetPrtRight =*/&SwFrame::GetPrtTop,
268  /*.fnTopDist =*/&SwRect::GetLeftDistance,
269  /*.fnBottomDist =*/&SwRect::GetRightDistance,
270  /*.fnLeftDist =*/&SwRect::GetBottomDistance,
271  /*.fnRightDist =*/&SwRect::GetTopDistance,
272  /*.fnSetLimit =*/&SwFrame::SetMaxRight,
273  /*.fnOverStep =*/&SwRect::OverStepRight,
274 
275  /*.fnSetPos =*/&SwRect::SetLowerLeftCorner,
276  /*.fnMakePos =*/&SwFrame::MakeRightPos,
277  /*.fnXDiff =*/&SecondMinusFirst,
278  /*.fnYDiff =*/&FirstMinusSecond,
279  /*.fnXInc =*/&SwDecrement,
280  /*.fnYInc =*/&SwIncrement,
281 
282  /*.fnSetLeftAndWidth =*/&SwRect::SetBottomAndHeight,
283  /*.fnSetTopAndHeight =*/&SwRect::SetLeftAndWidth
284 };
285 
290 
291 // #i65250#
293 
294 
295 void FrameInit()
296 {
297  SwRootFrame::s_pVout = new SwLayVout();
298  SwCache *pNew = new SwCache( 100
299 #ifdef DBG_UTIL
300  , "static SwBorderAttrs::pCache"
301 #endif
302  );
303  SwFrame::SetCache( pNew );
304 }
305 
307 {
308 #if OSL_DEBUG_LEVEL > 0
309  // The cache may only contain null pointers at this time.
310  for( size_t n = SwFrame::GetCachePtr()->size(); n; )
311  if( (*SwFrame::GetCachePtr())[ --n ] )
312  {
313  SwCacheObj* pObj = (*SwFrame::GetCachePtr())[ n ];
314  OSL_ENSURE( !pObj, "Who didn't deregister?");
315  }
316 #endif
317  delete SwRootFrame::s_pVout;
318  delete SwFrame::GetCachePtr();
319 }
320 
321 // RootFrame::Everything that belongs to CurrShell
322 
324 {
325  OSL_ENSURE( pNew, "insert 0-Shell?" );
326  pRoot = pNew->GetLayout();
327  if ( pRoot )
328  {
330  pRoot->mpCurrShell = pNew;
331  pRoot->mpCurrShells->insert( this );
332  }
333  else
334  pPrev = nullptr;
335 }
336 
338 {
339  if ( pRoot )
340  {
341  pRoot->mpCurrShells->erase( this );
342  if ( pPrev )
344  if ( pRoot->mpCurrShells->empty() && pRoot->mpWaitingCurrShell )
345  {
347  pRoot->mpWaitingCurrShell = nullptr;
348  }
349  }
350 }
351 
352 void SetShell( SwViewShell *pSh )
353 {
354  SwRootFrame *pRoot = pSh->GetLayout();
355  if ( pRoot->mpCurrShells->empty() )
356  pRoot->mpCurrShell = pSh;
357  else
358  pRoot->mpWaitingCurrShell = pSh;
359 }
360 
362 {
363  // Activate some shell if possible
364  if ( mpCurrShell == pSh )
365  {
366  mpCurrShell = nullptr;
367  for(SwViewShell& rShell : pSh->GetRingContainer())
368  {
369  if(&rShell != pSh)
370  {
371  mpCurrShell = &rShell;
372  break;
373  }
374  }
375  }
376 
377  // Doesn't matter anymore
378  if ( mpWaitingCurrShell == pSh )
379  mpWaitingCurrShell = nullptr;
380 
381  // Remove references
382  for ( CurrShell *pC : *mpCurrShells )
383  {
384  if (pC->pPrev == pSh)
385  pC->pPrev = nullptr;
386  }
387 }
388 
390 {
391  pRoot->mpCurrShells.reset( new SwCurrShells );
392 }
393 
394 /*
395 |* The RootFrame requests an own FrameFormat from the document, which it is
396 |* going to delete again in the dtor. The own FrameFormat is derived from
397 |* the passed FrameFormat.
398 |*/
400  SwLayoutFrame( pFormat->GetDoc()->MakeFrameFormat(
401  "Root", pFormat ), nullptr ),
402  maPagesArea(),
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  mbIsVirtPageNum( false ),
414  mbIsNewLayout( true ),
415  mbCallbackActionEnabled ( false ),
416  mbLayoutFreezed ( false ),
417  mbHideRedlines(pFormat->GetDoc()->GetDocumentRedlineManager().IsHideRedlines()),
418  mnBrowseWidth(MIN_BROWSE_WIDTH),
419  mpTurbo( nullptr ),
420  mpLastPage( nullptr ),
421  mpCurrShell( pSh ),
422  mpWaitingCurrShell( nullptr ),
423  mpDrawPage( nullptr ),
424  mnPhyPageNums( 0 ),
425  mnAccessibleShells( 0 )
426 {
428  setRootFrame( this );
429 }
430 
432 {
433  InitCurrShells( this );
434 
435  IDocumentTimerAccess& rTimerAccess = pFormat->getIDocumentTimerAccess();
436  IDocumentLayoutAccess& rLayoutAccess = pFormat->getIDocumentLayoutAccess();
437  IDocumentFieldsAccess& rFieldsAccess = pFormat->getIDocumentFieldsAccess();
438  const IDocumentSettingAccess& rSettingAccess = pFormat->getIDocumentSettingAccess();
439  rTimerAccess.StopIdling();
440  // For creating the Flys by MakeFrames()
441  rLayoutAccess.SetCurrentViewShell( GetCurrShell() );
442  mbCallbackActionEnabled = false; // needs to be set to true before leaving!
443 
445  if ( pMd )
446  {
447  // Disable "multiple layout"
448  mpDrawPage = pMd->GetPage(0);
449 
451  }
452 
453  // Initialize the layout: create pages, link content with Content etc.
454  // First, initialize some stuff, then get hold of the first
455  // node (which will be needed for the PageDesc).
456 
457  SwDoc* pDoc = pFormat->GetDoc();
459  SwContentNode *pNode = pDoc->GetNodes().GoNextSection( &aIndex, true, false );
460  // #123067# pNode = 0 can really happen
461  SwTableNode *pTableNd= pNode ? pNode->FindTableNode() : nullptr;
462 
463  // Get hold of PageDesc (either via FrameFormat of the first node or the initial one).
464  SwPageDesc *pDesc = nullptr;
465  ::o3tl::optional<sal_uInt16> oPgNum;
466 
467  if ( pTableNd )
468  {
469  const SwFormatPageDesc &rDesc = pTableNd->GetTable().GetFrameFormat()->GetPageDesc();
470  pDesc = const_cast<SwPageDesc*>(rDesc.GetPageDesc());
471  //#19104# respect the page number offset!!
472  oPgNum = rDesc.GetNumOffset();
473  if (oPgNum)
474  mbIsVirtPageNum = true;
475  }
476  else if ( pNode )
477  {
478  const SwFormatPageDesc &rDesc = pNode->GetSwAttrSet().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;
484  }
485  else
486  mbIsVirtPageNum = false;
487  if ( !pDesc )
488  pDesc = &pDoc->GetPageDesc( 0 );
489 
490  const bool bOdd = !oPgNum || 0 != ( *oPgNum % 2 );
491  const bool bFirst = true;
492  // Even page numbers are supposed to be printed as left pages. So if a
493  // page number has been explicitly set for this first page, then we must
494  // insert a blank page before it to make it a left page.
495  const bool bInsertEmpty = !bOdd;
496 
497  // Create a page and put it in the layout
498  SwPageFrame *pPage = ::InsertNewPage( *pDesc, this, bOdd, bFirst, bInsertEmpty, false, nullptr );
499 
500  // Find the first page in the Bodytext section.
501  SwLayoutFrame *pLay = pPage->FindBodyCont();
502  while( pLay->Lower() )
503  pLay = static_cast<SwLayoutFrame*>(pLay->Lower());
504 
505  SwNodeIndex aTmp( *pDoc->GetNodes().GetEndOfContent().StartOfSectionNode(), 1 );
506  ::InsertCnt_( pLay, pDoc, aTmp.GetIndex(), true );
507  //Remove masters that haven't been replaced yet from the list.
509  if( rSettingAccess.get(DocumentSettingId::GLOBAL_DOCUMENT) )
510  rFieldsAccess.UpdateRefFields();
511  //b6433357: Update page fields after loading
512  if ( !mpCurrShell || !mpCurrShell->Imp()->IsUpdateExpFields() )
513  {
514  SwDocPosUpdate aMsgHint( pPage->getFrameArea().Top() );
515  rFieldsAccess.UpdatePageFields( &aMsgHint );
516  }
517 
518  rTimerAccess.StartIdling();
520 
521  SwViewShell *pViewSh = GetCurrShell();
522  if (pViewSh)
524 }
525 
527 {
528  mbTurboAllowed = false;
529  mpTurbo = nullptr;
530 
531  if(pBlink)
532  pBlink->FrameDelete( this );
533  SwFrameFormat *pRegisteredInNonConst = static_cast<SwFrameFormat*>(GetDep());
534  if ( pRegisteredInNonConst )
535  {
536  SwDoc *pDoc = pRegisteredInNonConst->GetDoc();
537  pDoc->DelFrameFormat( pRegisteredInNonConst );
538  // do this before calling RemoveFootnotes() because footnotes
539  // can contain anchored objects
541  }
542 
543  mpDestroy.reset();
544 
545  // Remove references
546  for ( auto& rpCurrShell : *mpCurrShells )
547  rpCurrShell->pRoot = nullptr;
548 
549  mpCurrShells.reset();
550 
551  // Some accessible shells are left => problems on second SwFrame::Destroy call
552  assert(0 == mnAccessibleShells);
553 
554  // fdo#39510 crash on document close with footnotes
555  // Object ownership in writer and esp. in layout are a mess: Before the
556  // document/layout split SwDoc and SwRootFrame were essentially one object
557  // and magically/uncleanly worked around their common destruction by call
558  // to SwDoc::IsInDtor() -- even from the layout. As of now destruction of
559  // the layout proceeds forward through the frames. Since SwTextFootnote::DelFrames
560  // also searches backwards to find the master of footnotes, they must be
561  // considered to be owned by the SwRootFrame and also be destroyed here,
562  // before tearing down the (now footnote free) rest of the layout.
563  RemoveFootnotes(nullptr, false, true);
564 
566 }
567 
569 {
570 }
571 
573 {
574  // Remove all master objects from the Page. But don't delete!
575  for( size_t i = pPg ? pPg->GetObjCount() : 0; i; )
576  {
577  SdrObject* pObj = pPg->GetObj( --i );
578  if( dynamic_cast< const SwFlyDrawObj *>( pObj ) != nullptr )
579  pPg->RemoveObject( i );
580  }
581 }
582 
584 {
585  if ( !IsLayoutFreezed() )
586  CheckPageDescs( const_cast<SwPageFrame*>(static_cast<const SwPageFrame*>(Lower())) );
587 }
588 
590 {
591  SwPageFrame *pPage = const_cast<SwPageFrame*>(static_cast<const SwPageFrame*>(Lower()));
592  while ( pPage )
593  {
595  pPage = static_cast<SwPageFrame*>(pPage->GetNext());
596  }
597 }
598 
600 {
602 }
603 
605 {
606  RemoveFootnotes();
607 }
608 
610 {
611  SwPageFrame *pPage = const_cast<SwPageFrame*>(static_cast<const SwPageFrame*>(Lower()));
612  while ( pPage )
613  {
614  if ( bSmartTags )
615  pPage->InvalidateSmartTags();
616 
617  pPage->InvalidateSpelling();
618  pPage = static_cast<SwPageFrame*>(pPage->GetNext());
619  }
620 }
621 
622 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
long GetPrtLeft() const
Definition: ssfrm.cxx:47
Size Size_() const
Definition: swrect.cxx:171
void AllRemoveFootnotes()
Definition: newfrm.cxx:604
SwRootFrame * pRoot
Definition: viewsh.hxx:581
bool OverStepLeft(long) const
Definition: swrect.cxx:185
SdrPage * mpDrawPage
One Page per DrawModel per Document; is always the size of the Root.
Definition: rootfrm.hxx:164
virtual void SetSize(const Size &aSiz)
void InsertCnt_(SwLayoutFrame *pLay, SwDoc *pDoc, sal_uLong nIndex, bool bPages=false, sal_uLong nEndIndex=0, SwFrame *pPrv=nullptr, sw::FrameMode eMode=sw::FrameMode::New)
Definition: frmtool.cxx:1381
long Bottom_() const
Definition: swrect.cxx:160
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:35
void RemoveFootnotes(SwPageFrame *pPage=nullptr, bool bPageOnly=false, bool bEndNotes=false)
Remove all footnotes (but no references)
Definition: ftnfrm.cxx:901
SwPageDesc * GetPageDesc()
Definition: fmtpdsc.hxx:62
void FrameFinit()
Definition: newfrm.cxx:306
SwViewShellImp * Imp()
Definition: viewsh.hxx:185
static void CheckPageDescs(SwPageFrame *pStart, bool bNotifyFields=true, SwPageFrame **ppPrev=nullptr)
Check all pages (starting from the given one) if they use the right frame format. ...
Definition: pagechg.cxx:1002
virtual void UpdatePageFields(SfxPoolItem *)=0
static SwRectFnCollection aVertical
Definition: newfrm.cxx:116
void FrameInit()
Definition: newfrm.cxx:295
long GetBottomDistance(long) const
Definition: swrect.cxx:181
sal_uInt16 char char * pDesc
void MakeLeftPos(const SwFrame *, const SwFrame *, bool)
Definition: ssfrm.cxx:125
SwModify * GetDep()
use these so we can grep for SwFrame's GetRegisteredIn accesses beware that SwTextFrame may return sw...
Definition: frame.hxx:457
void SetShell(SwViewShell *pSh)
Definition: newfrm.cxx:352
SwViewShell * mpCurrShell
Definition: rootfrm.hxx:159
Handle the background jobs of a Writer document.
sal_Int64 n
SdrObject * GetObj(size_t nNum) const
Definition: doc.hxx:185
size_t GetObjCount() const
virtual void StopIdling()=0
Stop idle processing.
::sw::DocumentLayoutManager const & GetDocumentLayoutManager() const
Definition: doc.cxx:414
void SetRightLeftMargins(long, long)
Definition: ssfrm.cxx:182
void SetPosX(const long nNew)
Definition: swrect.cxx:168
SwRootFrame(SwFrameFormat *, SwViewShell *)
Definition: newfrm.cxx:399
sal_uInt16 mnAccessibleShells
Page count.
Definition: rootfrm.hxx:169
long GetLeftDistance(long) const
Definition: swrect.cxx:180
IDocumentTimerAccess & getIDocumentTimerAccess()
Provides access to the document idle timer interface.
Definition: format.cxx:762
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
SwTableFormat * GetFrameFormat()
Definition: swtable.hxx:201
bool mbIsVirtPageNum
Definition: rootfrm.hxx:114
static SwRectFnCollection aVerticalLeftToRightBottomToTop
This is the same as horizontal, but rotated counter-clockwise by 90 degrees.
Definition: newfrm.cxx:231
bool AddPaintRect(const SwRect &rRect)
Definition: viewsh.cxx:523
Point TopLeft() const
Definition: swrect.cxx:174
bool mbCallbackActionEnabled
Definition: rootfrm.hxx:116
long Left_() const
Definition: swrect.cxx:157
void SetTopBottomMargins(long, long)
Definition: ssfrm.cxx:168
void Top(const long nTop)
Definition: swrect.hxx:202
static void SetCache(SwCache *pNew)
Definition: frame.hxx:502
const SwRect & getFrameArea() const
Definition: frame.hxx:175
static sal_uInt32 mnLastFrameId
Definition: frame.hxx:148
void setRootFrame(SwRootFrame *pRoot)
Definition: frame.hxx:436
virtual void StartIdling()=0
Start the idle task.
const SwTable & GetTable() const
Definition: node.hxx:497
void InitCurrShells(SwRootFrame *pRoot)
Definition: newfrm.cxx:389
SwRectFn fnRectVertL2R
Definition: newfrm.cxx:288
virtual void DestroyImpl() override
Definition: ssfrm.cxx:473
long GetRightDistance(long) const
Definition: swrect.cxx:183
virtual void DestroyImpl() override
Definition: newfrm.cxx:526
static void RemoveMasterObjs(SdrPage *pPg)
Remove MasterObjects from the Page (called by the ctors)
Definition: newfrm.cxx:572
void SubLeft(const long nSub)
Definition: swrect.cxx:164
SwPageFrame * InsertNewPage(SwPageDesc &rDesc, SwFrame *pUpper, bool bOdd, bool bFirst, bool bInsertEmpty, bool bFootnote, SwFrame *pSibling)
Definition: frmtool.cxx:2886
static SwRectFnCollection aVerticalLeftToRight
Definition: newfrm.cxx:171
void Init(SwFrameFormat *)
Definition: newfrm.cxx:431
const SwContentFrame * mpTurbo
If we only have to format one ContentFrame, its in mpTurbo.
Definition: rootfrm.hxx:129
IDocumentFieldsAccess & getIDocumentFieldsAccess()
Provides access to the document idle timer interface.
Definition: format.cxx:763
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:163
bool SetMaxRight(long)
Definition: ssfrm.cxx:88
void SetLeftAndWidth(long nLeft, long nNew)
Definition: swrect.cxx:194
friend void InitCurrShells(SwRootFrame *pRoot)
Definition: newfrm.cxx:389
void MakeBelowPos(const SwFrame *, const SwFrame *, bool)
Definition: ssfrm.cxx:104
void InvalidateAutoCompleteWords() const
Definition: pagefrm.hxx:376
virtual void UpdateRefFields()=0
Style of a layout element.
Definition: frmfmt.hxx:57
long Height_() const
Definition: swrect.cxx:156
~CurrShell()
Definition: newfrm.cxx:337
SwViewShell * mpWaitingCurrShell
Definition: rootfrm.hxx:160
void InvalidateSpelling() const
Definition: pagefrm.hxx:367
static SwRectFnCollection aHorizontal
Definition: newfrm.cxx:61
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:131
long Width_() const
Definition: swrect.cxx:155
const IDocumentLayoutAccess & getIDocumentLayoutAccess() const
Provides access to the document layout interface.
Definition: format.cxx:760
const SwPageDesc & GetPageDesc(const size_t i) const
Definition: doc.hxx:878
void SubTop(const long nSub)
Definition: swrect.cxx:166
Document fields related interfaces.
void AddWidth(const long nAdd)
Definition: swrect.cxx:162
void AllCheckPageDescs() const
Definition: newfrm.cxx:583
SwViewShell * pPrev
Definition: viewsh.hxx:580
void SetPosY(const long nNew)
Definition: swrect.cxx:169
const SwFrame * Lower() const
Definition: layfrm.hxx:101
int i
bool mbNeedGrammarCheck
Definition: rootfrm.hxx:100
void AddRight(const long nAdd)
Definition: swrect.cxx:165
const SdrPage * GetPage(sal_uInt16 nPgNum) const
virtual const SwDrawModel * GetDrawModel() const =0
Draw Model and id accessors.
void InvalidateSmartTags() const
Definition: pagefrm.hxx:372
long GetPrtTop() const
Definition: ssfrm.cxx:53
void AddHeight(const long nAdd)
Definition: swrect.cxx:163
static long FirstMinusSecond(long nFirst, long nSecond)
Definition: newfrm.cxx:52
Provides access to settings of a document.
void DeRegisterShell(SwViewShell *pSh)
Definition: newfrm.cxx:361
size
Marks a node in the document model.
Definition: ndindex.hxx:31
static bool s_isNoVirDev
Definition: rootfrm.hxx:104
ring_container GetRingContainer()
Definition: ring.hxx:240
bool IsOnlineSpell() const
Definition: viewopt.hxx:332
long GetTopMargin() const
Definition: ssfrm.cxx:39
bool IsUpdateExpFields()
Definition: viewimp.cxx:150
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:119
const IDocumentSettingAccess & getIDocumentSettingAccess() const
Provides access to the document settings interface.
Definition: format.cxx:757
A page of the document layout.
Definition: pagefrm.hxx:40
virtual SdrObject * RemoveObject(size_t nObjNum)
void MakeRightPos(const SwFrame *, const SwFrame *, bool)
Definition: ssfrm.cxx:147
bool IsLayoutFreezed() const
Definition: rootfrm.hxx:407
std::set< CurrShell * > SwCurrShells
Definition: rootfrm.hxx:72
void SetUpperLeftCorner(const Point &rNew)
Definition: swrect.cxx:214
SwRectFn fnRectVert
Definition: newfrm.cxx:287
SwLayoutFrame * FindBodyCont()
Searches the first ContentFrame in BodyText below the page.
Definition: findfrm.cxx:42
static SwCache * GetCachePtr()
Definition: frame.hxx:501
long GetBottomMargin() const
Definition: ssfrm.cxx:41
void SetRightAndWidth(long nRight, long nNew)
Definition: swrect.cxx:204
bool OverStepBottom(long) const
Definition: swrect.cxx:187
long GetPrtRight() const
Definition: ssfrm.cxx:51
SwRectFn fnRectHori
Definition: newfrm.cxx:286
void AllInvalidateAutoCompleteWords() const
Definition: newfrm.cxx:589
virtual ~SwRootFrame() override
Definition: newfrm.cxx:568
void SetUpperRightCorner(const Point &rNew)
Definition: swrect.cxx:216
void SetTopAndHeight(long nTop, long nNew)
Definition: swrect.cxx:199
std::deque< AttacherIndex_Impl > aIndex
long GetRightMargin() const
Definition: ssfrm.cxx:45
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:426
The Cache object base class Users of the Cache must derive a class from the SwCacheObj and store thei...
Definition: swcache.hxx:133
long GetTopDistance(long) const
Definition: swrect.cxx:182
static long SwDecrement(long nA, long nSub)
Definition: newfrm.cxx:58
void SetLowerLeftCorner(const Point &rNew)
Definition: swrect.cxx:218
SwNodes & GetNodes()
Definition: doc.hxx:403
static SwLayVout * s_pVout
Definition: rootfrm.hxx:102
static long SwIncrement(long nA, long nAdd)
Definition: newfrm.cxx:56
SwFrameType mnFrameType
Definition: frame.hxx:395
void SetLeftRightMargins(long, long)
Definition: ssfrm.cxx:175
bool SetMaxBottom(long)
Definition: ssfrm.cxx:72
bool mbTurboAllowed
Definition: rootfrm.hxx:112
static SwCache * mpCache
Definition: frame.hxx:315
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
static bool s_isInPaint
Definition: rootfrm.hxx:103
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:349
void AllInvalidateSmartTagsOrSpelling(bool bSmartTags) const
Definition: newfrm.cxx:609
Size SwappedSize() const
Definition: swrect.cxx:172
void DelFrameFormat(SwFrameFormat *pFormat, bool bBroadcast=false)
Definition: docfmt.cxx:683
Point TopRight() const
Definition: swrect.cxx:175
void AddBottom(const long nAdd)
Definition: swrect.cxx:167
SwDocPosUpdate is sent to signal that only the frames from or to a specified document-global position...
Definition: hints.hxx:183
Provides access to the layout of a document.
virtual void SetCurrentViewShell(SwViewShell *pNew)=0
!!!The old layout must be deleted!!!
SwContentNode * GoNextSection(SwNodeIndex *, bool bSkipHidden=true, bool bSkipProtect=true) const
Go to next content-node that is not protected or hidden (Both set FALSE ==> GoNext/GoPrevious!!!).
Definition: nodes.cxx:1900
void SetBottomAndHeight(long nBottom, long nNew)
Definition: swrect.cxx:209
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:161
bool OverStepRight(long) const
Definition: swrect.cxx:191
const SwFormatPageDesc & GetPageDesc(bool=true) const
Definition: fmtpdsc.hxx:79
long Top_() const
Definition: swrect.cxx:159
CurrShell(SwViewShell *pNew)
Definition: newfrm.cxx:323
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2062
long GetLeftMargin() const
Definition: ssfrm.cxx:43
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:204
SwRectFn fnRectVertL2RB2T
Definition: newfrm.cxx:289
long GetPrtBottom() const
Definition: ssfrm.cxx:49
void AllAddPaintRect() const
Definition: newfrm.cxx:599
const ::o3tl::optional< sal_uInt16 > & GetNumOffset() const
Definition: fmtpdsc.hxx:65
bool SetMinLeft(long)
Definition: ssfrm.cxx:56
std::unique_ptr< SwDestroyList > mpDestroy
Definition: rootfrm.hxx:166
long Right_() const
Definition: swrect.cxx:158
const IDocumentDrawModelAccess & getIDocumentDrawModelAccess() const
Provides access to the document draw model interface.
Definition: format.cxx:758
static long SecondMinusFirst(long nFirst, long nSecond)
Definition: newfrm.cxx:54
Point BottomLeft() const
Definition: swrect.cxx:176
SwFrame * GetNext()
Definition: frame.hxx:654