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/svdmodel.hxx>
24 #include <svx/svdpage.hxx>
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 <blink.hxx>
34 #include <sectfrm.hxx>
35 #include <notxtfrm.hxx>
36 #include <pagedesc.hxx>
37 #include <viewimp.hxx>
38 #include <hints.hxx>
39 #include <viewopt.hxx>
40 #include <set>
46 #include <ndindex.hxx>
47 
49 bool SwRootFrame::s_isInPaint = false;
50 bool SwRootFrame::s_isNoVirDev = false;
51 
52 SwCache *SwFrame::mpCache = nullptr;
53 
54 static long FirstMinusSecond( long nFirst, long nSecond )
55  { return nFirst - nSecond; }
56 static long SecondMinusFirst( long nFirst, long nSecond )
57  { return nSecond - nFirst; }
58 static long SwIncrement( long nA, long nAdd )
59  { return nA + nAdd; }
60 static long SwDecrement( long nA, long nSub )
61  { return nA - nSub; }
62 
64  /*.fnGetTop =*/&SwRect::Top_,
65  /*.fnGetBottom =*/&SwRect::Bottom_,
66  /*.fnGetLeft =*/&SwRect::Left_,
67  /*.fnGetRight =*/&SwRect::Right_,
68  /*.fnGetWidth =*/&SwRect::Width_,
69  /*.fnGetHeight =*/&SwRect::Height_,
70  /*.fnGetPos =*/&SwRect::TopLeft,
71  /*.fnGetSize =*/&SwRect::Size_,
72 
73  /*.fnSetTop =*/&SwRect::Top_,
74  /*.fnSetBottom =*/&SwRect::Bottom_,
75  /*.fnSetLeft =*/&SwRect::Left_,
76  /*.fnSetRight =*/&SwRect::Right_,
77  /*.fnSetWidth =*/&SwRect::Width_,
78  /*.fnSetHeight =*/&SwRect::Height_,
79 
80  /*.fnSubTop =*/&SwRect::SubTop,
81  /*.fnAddBottom =*/&SwRect::AddBottom,
82  /*.fnSubLeft =*/&SwRect::SubLeft,
83  /*.fnAddRight =*/&SwRect::AddRight,
84  /*.fnAddWidth =*/&SwRect::AddWidth,
85  /*.fnAddHeight =*/&SwRect::AddHeight,
86 
87  /*.fnSetPosX =*/&SwRect::SetPosX,
88  /*.fnSetPosY =*/&SwRect::SetPosY,
89 
90  /*.fnGetTopMargin =*/&SwFrame::GetTopMargin,
91  /*.fnGetBottomMargin =*/&SwFrame::GetBottomMargin,
92  /*.fnGetLeftMargin =*/&SwFrame::GetLeftMargin,
93  /*.fnGetRightMargin =*/&SwFrame::GetRightMargin,
94  /*.fnSetXMargins =*/&SwFrame::SetLeftRightMargins,
95  /*.fnSetYMargins =*/&SwFrame::SetTopBottomMargins,
96  /*.fnGetPrtTop =*/&SwFrame::GetPrtTop,
97  /*.fnGetPrtBottom =*/&SwFrame::GetPrtBottom,
98  /*.fnGetPrtLeft =*/&SwFrame::GetPrtLeft,
99  /*.fnGetPrtRight =*/&SwFrame::GetPrtRight,
100  /*.fnTopDist =*/&SwRect::GetTopDistance,
101  /*.fnBottomDist =*/&SwRect::GetBottomDistance,
102  /*.fnLeftDist =*/&SwRect::GetLeftDistance,
103  /*.fnRightDist =*/&SwRect::GetRightDistance,
104  /*.fnSetLimit =*/&SwFrame::SetMaxBottom,
105  /*.fnOverStep =*/&SwRect::OverStepBottom,
106 
107  /*.fnSetPos =*/&SwRect::SetUpperLeftCorner,
108  /*.fnMakePos =*/&SwFrame::MakeBelowPos,
109  /*.fnXDiff =*/&FirstMinusSecond,
110  /*.fnYDiff =*/&FirstMinusSecond,
111  /*.fnXInc =*/&SwIncrement,
112  /*.fnYInc =*/&o3tl::saturating_add<long>,
113 
114  /*.fnSetLeftAndWidth =*/&SwRect::SetLeftAndWidth,
115  /*.fnSetTopAndHeight =*/&SwRect::SetTopAndHeight
116 };
117 
119  /*.fnGetTop =*/&SwRect::Right_,
120  /*.fnGetBottom =*/&SwRect::Left_,
121  /*.fnGetLeft =*/&SwRect::Top_,
122  /*.fnGetRight =*/&SwRect::Bottom_,
123  /*.fnGetWidth =*/&SwRect::Height_,
124  /*.fnGetHeight =*/&SwRect::Width_,
125  /*.fnGetPos =*/&SwRect::TopRight,
126  /*.fnGetSize =*/&SwRect::SwappedSize,
127 
128  /*.fnSetTop =*/&SwRect::Right_,
129  /*.fnSetBottom =*/&SwRect::Left_,
130  /*.fnSetLeft =*/&SwRect::Top_,
131  /*.fnSetRight =*/&SwRect::Bottom_,
132  /*.fnSetWidth =*/&SwRect::Height_,
133  /*.fnSetHeight =*/&SwRect::Width_,
134 
135  /*.fnSubTop =*/&SwRect::AddRight,
136  /*.fnAddBottom =*/&SwRect::SubLeft,
137  /*.fnSubLeft =*/&SwRect::SubTop,
138  /*.fnAddRight =*/&SwRect::AddBottom,
139  /*.fnAddWidth =*/&SwRect::AddHeight,
140  /*.fnAddHeight =*/&SwRect::AddWidth,
141 
142  /*.fnSetPosX =*/&SwRect::SetPosY,
143  /*.fnSetPosY =*/&SwRect::SetPosX,
144 
145  /*.fnGetTopMargin =*/&SwFrame::GetRightMargin,
146  /*.fnGetBottomMargin =*/&SwFrame::GetLeftMargin,
147  /*.fnGetLeftMargin =*/&SwFrame::GetTopMargin,
148  /*.fnGetRightMargin =*/&SwFrame::GetBottomMargin,
149  /*.fnSetXMargins =*/&SwFrame::SetTopBottomMargins,
150  /*.fnSetYMargins =*/&SwFrame::SetRightLeftMargins,
151  /*.fnGetPrtTop =*/&SwFrame::GetPrtRight,
152  /*.fnGetPrtBottom =*/&SwFrame::GetPrtLeft,
153  /*.fnGetPrtLeft =*/&SwFrame::GetPrtTop,
154  /*.fnGetPrtRight =*/&SwFrame::GetPrtBottom,
155  /*.fnTopDist =*/&SwRect::GetRightDistance,
156  /*.fnBottomDist =*/&SwRect::GetLeftDistance,
157  /*.fnLeftDist =*/&SwRect::GetTopDistance,
158  /*.fnRightDist =*/&SwRect::GetBottomDistance,
159  /*.fnSetLimit =*/&SwFrame::SetMinLeft,
160  /*.fnOverStep =*/&SwRect::OverStepLeft,
161 
162  /*.fnSetPos =*/&SwRect::SetUpperRightCorner,
163  /*.fnMakePos =*/&SwFrame::MakeLeftPos,
164  /*.fnXDiff =*/&FirstMinusSecond,
165  /*.fnYDiff =*/&SecondMinusFirst,
166  /*.fnXInc =*/&SwIncrement,
167  /*.fnYInc =*/&SwDecrement,
168 
169  /*.fnSetLeftAndWidth =*/&SwRect::SetTopAndHeight,
170  /*.fnSetTopAndHeight =*/&SwRect::SetRightAndWidth
171 };
172 
174  /*.fnGetTop =*/&SwRect::Left_,
175  /*.fnGetBottom =*/&SwRect::Right_,
176  /*.fnGetLeft =*/&SwRect::Top_,
177  /*.fnGetRight =*/&SwRect::Bottom_,
178  /*.fnGetWidth =*/&SwRect::Height_,
179  /*.fnGetHeight =*/&SwRect::Width_,
180  /*.fnGetPos =*/&SwRect::TopLeft,
181  /*.fnGetSize =*/&SwRect::SwappedSize,
182 
183  /*.fnSetTop =*/&SwRect::Left_,
184  /*.fnSetBottom =*/&SwRect::Right_,
185  /*.fnSetLeft =*/&SwRect::Top_,
186  /*.fnSetRight =*/&SwRect::Bottom_,
187  /*.fnSetWidth =*/&SwRect::Height_,
188  /*.fnSetHeight =*/&SwRect::Width_,
189 
190  /*.fnSubTop =*/&SwRect::SubLeft,
191  /*.fnAddBottom =*/&SwRect::AddRight,
192  /*.fnSubLeft =*/&SwRect::SubTop,
193  /*.fnAddRight =*/&SwRect::AddBottom,
194  /*.fnAddWidth =*/&SwRect::AddHeight,
195  /*.fnAddHeight =*/&SwRect::AddWidth,
196 
197  /*.fnSetPosX =*/&SwRect::SetPosY,
198  /*.fnSetPosY =*/&SwRect::SetPosX,
199 
200  /*.fnGetTopMargin =*/&SwFrame::GetLeftMargin,
201  /*.fnGetBottomMargin =*/&SwFrame::GetRightMargin,
202  /*.fnGetLeftMargin =*/&SwFrame::GetTopMargin,
203  /*.fnGetRightMargin =*/&SwFrame::GetBottomMargin,
204  /*.fnSetXMargins =*/&SwFrame::SetTopBottomMargins,
205  /*.fnSetYMargins =*/&SwFrame::SetLeftRightMargins,
206  /*.fnGetPrtTop =*/&SwFrame::GetPrtLeft,
207  /*.fnGetPrtBottom =*/&SwFrame::GetPrtRight,
208  /*.fnGetPrtLeft =*/&SwFrame::GetPrtTop,
209  /*.fnGetPrtRight =*/&SwFrame::GetPrtBottom,
210  /*.fnTopDist =*/&SwRect::GetLeftDistance,
211  /*.fnBottomDist =*/&SwRect::GetRightDistance,
212  /*.fnLeftDist =*/&SwRect::GetTopDistance,
213  /*.fnRightDist =*/&SwRect::GetBottomDistance,
214  /*.fnSetLimit =*/&SwFrame::SetMaxRight,
215  /*.fnOverStep =*/&SwRect::OverStepRight,
216 
217  /*.fnSetPos =*/&SwRect::SetUpperLeftCorner,
218  /*.fnMakePos =*/&SwFrame::MakeRightPos,
219  /*.fnXDiff =*/&FirstMinusSecond,
220  /*.fnYDiff =*/&FirstMinusSecond,
221  /*.fnXInc =*/&SwIncrement,
222  /*.fnYInc =*/&SwIncrement,
223 
224  /*.fnSetLeftAndWidth =*/&SwRect::SetTopAndHeight,
225  /*.fnSetTopAndHeight =*/&SwRect::SetLeftAndWidth
226 };
227 
234  /*.fnGetTop =*/&SwRect::Left_,
235  /*.fnGetBottom =*/&SwRect::Right_,
236  /*.fnGetLeft =*/&SwRect::Bottom_,
237  /*.fnGetRight =*/&SwRect::Top_,
238  /*.fnGetWidth =*/&SwRect::Height_,
239  /*.fnGetHeight =*/&SwRect::Width_,
240  /*.fnGetPos =*/&SwRect::BottomLeft,
241  /*.fnGetSize =*/&SwRect::SwappedSize,
242 
243  /*.fnSetTop =*/&SwRect::Left_,
244  /*.fnSetBottom =*/&SwRect::Right_,
245  /*.fnSetLeft =*/&SwRect::Bottom_,
246  /*.fnSetRight =*/&SwRect::Top_,
247  /*.fnSetWidth =*/&SwRect::Height_,
248  /*.fnSetHeight =*/&SwRect::Width_,
249 
250  /*.fnSubTop =*/&SwRect::SubLeft,
251  /*.fnAddBottom =*/&SwRect::AddRight,
252  /*.fnSubLeft =*/&SwRect::AddBottom,
253  /*.fnAddRight =*/&SwRect::SubTop,
254  /*.fnAddWidth =*/&SwRect::AddHeight,
255  /*.fnAddHeight =*/&SwRect::AddWidth,
256 
257  /*.fnSetPosX =*/&SwRect::SetPosY,
258  /*.fnSetPosY =*/&SwRect::SetPosX,
259 
260  /*.fnGetTopMargin =*/&SwFrame::GetLeftMargin,
261  /*.fnGetBottomMargin =*/&SwFrame::GetRightMargin,
262  /*.fnGetLeftMargin =*/&SwFrame::GetBottomMargin,
263  /*.fnGetRightMargin =*/&SwFrame::GetTopMargin,
264  /*.fnSetXMargins =*/&SwFrame::SetTopBottomMargins,
265  /*.fnSetYMargins =*/&SwFrame::SetLeftRightMargins,
266  /*.fnGetPrtTop =*/&SwFrame::GetPrtLeft,
267  /*.fnGetPrtBottom =*/&SwFrame::GetPrtRight,
268  /*.fnGetPrtLeft =*/&SwFrame::GetPrtBottom,
269  /*.fnGetPrtRight =*/&SwFrame::GetPrtTop,
270  /*.fnTopDist =*/&SwRect::GetLeftDistance,
271  /*.fnBottomDist =*/&SwRect::GetRightDistance,
272  /*.fnLeftDist =*/&SwRect::GetBottomDistance,
273  /*.fnRightDist =*/&SwRect::GetTopDistance,
274  /*.fnSetLimit =*/&SwFrame::SetMaxRight,
275  /*.fnOverStep =*/&SwRect::OverStepRight,
276 
277  /*.fnSetPos =*/&SwRect::SetLowerLeftCorner,
278  /*.fnMakePos =*/&SwFrame::MakeRightPos,
279  /*.fnXDiff =*/&SecondMinusFirst,
280  /*.fnYDiff =*/&FirstMinusSecond,
281  /*.fnXInc =*/&SwDecrement,
282  /*.fnYInc =*/&SwIncrement,
283 
284  /*.fnSetLeftAndWidth =*/&SwRect::SetBottomAndHeight,
285  /*.fnSetTopAndHeight =*/&SwRect::SetLeftAndWidth
286 };
287 
292 
293 // #i65250#
295 
296 
297 void FrameInit()
298 {
299  SwRootFrame::s_pVout = new SwLayVout();
300  SwCache *pNew = new SwCache( 100
301 #ifdef DBG_UTIL
302  , "static SwBorderAttrs::pCache"
303 #endif
304  );
305  SwFrame::SetCache( pNew );
306 }
307 
309 {
310 #if OSL_DEBUG_LEVEL > 0
311  // The cache may only contain null pointers at this time.
312  for( size_t n = SwFrame::GetCachePtr()->size(); n; )
313  if( (*SwFrame::GetCachePtr())[ --n ] )
314  {
315  SwCacheObj* pObj = (*SwFrame::GetCachePtr())[ n ];
316  OSL_ENSURE( !pObj, "Who didn't deregister?");
317  }
318 #endif
319  delete SwRootFrame::s_pVout;
320  delete SwFrame::GetCachePtr();
321 }
322 
323 // RootFrame::Everything that belongs to CurrShell
324 
326 {
327  OSL_ENSURE( pNew, "insert 0-Shell?" );
328  pRoot = pNew->GetLayout();
329  if ( pRoot )
330  {
332  pRoot->mpCurrShell = pNew;
333  pRoot->mpCurrShells->insert( this );
334  }
335  else
336  pPrev = nullptr;
337 }
338 
340 {
341  if ( pRoot )
342  {
343  pRoot->mpCurrShells->erase( this );
344  if ( pPrev )
346  if ( pRoot->mpCurrShells->empty() && pRoot->mpWaitingCurrShell )
347  {
349  pRoot->mpWaitingCurrShell = nullptr;
350  }
351  }
352 }
353 
354 void SetShell( SwViewShell *pSh )
355 {
356  SwRootFrame *pRoot = pSh->GetLayout();
357  if ( pRoot->mpCurrShells->empty() )
358  pRoot->mpCurrShell = pSh;
359  else
360  pRoot->mpWaitingCurrShell = pSh;
361 }
362 
364 {
365  // Activate some shell if possible
366  if ( mpCurrShell == pSh )
367  {
368  mpCurrShell = nullptr;
369  for(SwViewShell& rShell : pSh->GetRingContainer())
370  {
371  if(&rShell != pSh)
372  {
373  mpCurrShell = &rShell;
374  break;
375  }
376  }
377  }
378 
379  // Doesn't matter anymore
380  if ( mpWaitingCurrShell == pSh )
381  mpWaitingCurrShell = nullptr;
382 
383  // Remove references
384  for ( CurrShell *pC : *mpCurrShells )
385  {
386  if (pC->pPrev == pSh)
387  pC->pPrev = nullptr;
388  }
389 }
390 
392 {
393  pRoot->mpCurrShells.reset( new SwCurrShells );
394 }
395 
396 /*
397 |* The RootFrame requests an own FrameFormat from the document, which it is
398 |* going to delete again in the dtor. The own FrameFormat is derived from
399 |* the passed FrameFormat.
400 |*/
402  SwLayoutFrame( pFormat->GetDoc()->MakeFrameFormat(
403  "Root", pFormat ), nullptr ),
404  maPagesArea(),
405  mnViewWidth( -1 ),
406  mnColumns( 0 ),
407  mbBookMode( false ),
408  mbSidebarChanged( false ),
409  mbNeedGrammarCheck( false ),
410  mbCheckSuperfluous( false ),
411  mbIdleFormat( true ),
412  mbBrowseWidthValid( false ),
413  mbTurboAllowed( true ),
414  mbAssertFlyPages( true ),
415  mbIsVirtPageNum( false ),
416  mbIsNewLayout( true ),
417  mbCallbackActionEnabled ( false ),
418  mbLayoutFreezed ( false ),
419  mbHideRedlines(pFormat->GetDoc()->GetDocumentRedlineManager().IsHideRedlines()),
420  mnBrowseWidth(MIN_BROWSE_WIDTH),
421  mpTurbo( nullptr ),
422  mpLastPage( nullptr ),
423  mpCurrShell( pSh ),
424  mpWaitingCurrShell( nullptr ),
425  mpDrawPage( nullptr ),
426  mnPhyPageNums( 0 ),
427  mnAccessibleShells( 0 )
428 {
430  setRootFrame( this );
431 }
432 
434 {
435  InitCurrShells( this );
436 
437  IDocumentTimerAccess& rTimerAccess = pFormat->getIDocumentTimerAccess();
438  IDocumentLayoutAccess& rLayoutAccess = pFormat->getIDocumentLayoutAccess();
439  IDocumentFieldsAccess& rFieldsAccess = pFormat->getIDocumentFieldsAccess();
440  const IDocumentSettingAccess& rSettingAccess = pFormat->getIDocumentSettingAccess();
441  rTimerAccess.StopIdling();
442  // For creating the Flys by MakeFrames()
443  rLayoutAccess.SetCurrentViewShell( GetCurrShell() );
444  mbCallbackActionEnabled = false; // needs to be set to true before leaving!
445 
447  if ( pMd )
448  {
449  // Disable "multiple layout"
450  mpDrawPage = pMd->GetPage(0);
451 
453  }
454 
455  // Initialize the layout: create pages, link content with Content etc.
456  // First, initialize some stuff, then get hold of the first
457  // node (which will be needed for the PageDesc).
458 
459  SwDoc* pDoc = pFormat->GetDoc();
461  SwContentNode *pNode = pDoc->GetNodes().GoNextSection( &aIndex, true, false );
462  // #123067# pNode = 0 can really happen
463  SwTableNode *pTableNd= pNode ? pNode->FindTableNode() : nullptr;
464 
465  // Get hold of PageDesc (either via FrameFormat of the first node or the initial one).
466  SwPageDesc *pDesc = nullptr;
468 
469  if ( pTableNd )
470  {
471  const SwFormatPageDesc &rDesc = pTableNd->GetTable().GetFrameFormat()->GetPageDesc();
472  pDesc = const_cast<SwPageDesc*>(rDesc.GetPageDesc());
473  //#19104# respect the page number offset!!
474  oPgNum = rDesc.GetNumOffset();
475  if (oPgNum)
476  mbIsVirtPageNum = true;
477  }
478  else if ( pNode )
479  {
480  const SwFormatPageDesc &rDesc = pNode->GetSwAttrSet().GetPageDesc();
481  pDesc = const_cast<SwPageDesc*>(rDesc.GetPageDesc());
482  //#19104# respect the page number offset!!
483  oPgNum = rDesc.GetNumOffset();
484  if (oPgNum)
485  mbIsVirtPageNum = true;
486  }
487  else
488  mbIsVirtPageNum = false;
489  if ( !pDesc )
490  pDesc = &pDoc->GetPageDesc( 0 );
491 
492  const bool bOdd = !oPgNum || 0 != ( oPgNum.get() % 2 );
493  const bool bFirst = true;
494  // Even page numbers are supposed to be printed as left pages. So if a
495  // page number has been explicitly set for this first page, then we must
496  // insert a blank page before it to make it a left page.
497  const bool bInsertEmpty = !bOdd;
498 
499  // Create a page and put it in the layout
500  SwPageFrame *pPage = ::InsertNewPage( *pDesc, this, bOdd, bFirst, bInsertEmpty, false, nullptr );
501 
502  // Find the first page in the Bodytext section.
503  SwLayoutFrame *pLay = pPage->FindBodyCont();
504  while( pLay->Lower() )
505  pLay = static_cast<SwLayoutFrame*>(pLay->Lower());
506 
507  SwNodeIndex aTmp( *pDoc->GetNodes().GetEndOfContent().StartOfSectionNode(), 1 );
508  ::InsertCnt_( pLay, pDoc, aTmp.GetIndex(), true );
509  //Remove masters that haven't been replaced yet from the list.
511  if( rSettingAccess.get(DocumentSettingId::GLOBAL_DOCUMENT) )
512  rFieldsAccess.UpdateRefFields();
513  //b6433357: Update page fields after loading
514  if ( !mpCurrShell || !mpCurrShell->Imp()->IsUpdateExpFields() )
515  {
516  SwDocPosUpdate aMsgHint( pPage->getFrameArea().Top() );
517  rFieldsAccess.UpdatePageFields( &aMsgHint );
518  }
519 
520  rTimerAccess.StartIdling();
522 
523  SwViewShell *pViewSh = GetCurrShell();
524  if (pViewSh)
526 }
527 
529 {
530  mbTurboAllowed = false;
531  mpTurbo = nullptr;
532 
533  if(pBlink)
534  pBlink->FrameDelete( this );
535  SwFrameFormat *pRegisteredInNonConst = static_cast<SwFrameFormat*>(GetDep());
536  if ( pRegisteredInNonConst )
537  {
538  SwDoc *pDoc = pRegisteredInNonConst->GetDoc();
539  pDoc->DelFrameFormat( pRegisteredInNonConst );
540  // do this before calling RemoveFootnotes() because footnotes
541  // can contain anchored objects
543  }
544 
545  mpDestroy.reset();
546 
547  // Remove references
548  for ( auto& rpCurrShell : *mpCurrShells )
549  rpCurrShell->pRoot = nullptr;
550 
551  mpCurrShells.reset();
552 
553  // Some accessible shells are left => problems on second SwFrame::Destroy call
554  assert(0 == mnAccessibleShells);
555 
556  // fdo#39510 crash on document close with footnotes
557  // Object ownership in writer and esp. in layout are a mess: Before the
558  // document/layout split SwDoc and SwRootFrame were essentially one object
559  // and magically/uncleanly worked around their common destruction by call
560  // to SwDoc::IsInDtor() -- even from the layout. As of now destruction of
561  // the layout proceeds forward through the frames. Since SwTextFootnote::DelFrames
562  // also searches backwards to find the master of footnotes, they must be
563  // considered to be owned by the SwRootFrame and also be destroyed here,
564  // before tearing down the (now footnote free) rest of the layout.
565  RemoveFootnotes(nullptr, false, true);
566 
568 }
569 
571 {
572 }
573 
575 {
576  // Remove all master objects from the Page. But don't delete!
577  for( size_t i = pPg ? pPg->GetObjCount() : 0; i; )
578  {
579  SdrObject* pObj = pPg->GetObj( --i );
580  if( dynamic_cast< const SwFlyDrawObj *>( pObj ) != nullptr )
581  pPg->RemoveObject( i );
582  }
583 }
584 
586 {
587  if ( !IsLayoutFreezed() )
588  CheckPageDescs( const_cast<SwPageFrame*>(static_cast<const SwPageFrame*>(Lower())) );
589 }
590 
592 {
593  SwPageFrame *pPage = const_cast<SwPageFrame*>(static_cast<const SwPageFrame*>(Lower()));
594  while ( pPage )
595  {
597  pPage = static_cast<SwPageFrame*>(pPage->GetNext());
598  }
599 }
600 
602 {
604 }
605 
607 {
608  RemoveFootnotes();
609 }
610 
612 {
613  SwPageFrame *pPage = const_cast<SwPageFrame*>(static_cast<const SwPageFrame*>(Lower()));
614  while ( pPage )
615  {
616  if ( bSmartTags )
617  pPage->InvalidateSmartTags();
618 
619  pPage->InvalidateSpelling();
620  pPage = static_cast<SwPageFrame*>(pPage->GetNext());
621  }
622 }
623 
624 /* 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:606
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:900
SwPageDesc * GetPageDesc()
Definition: fmtpdsc.hxx:62
void FrameFinit()
Definition: newfrm.cxx:308
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:1004
virtual void UpdatePageFields(SfxPoolItem *)=0
static SwRectFnCollection aVertical
Definition: newfrm.cxx:118
void FrameInit()
Definition: newfrm.cxx:297
long GetBottomDistance(long) const
Definition: swrect.cxx:181
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:354
SwViewShell * mpCurrShell
Definition: rootfrm.hxx:159
Handle the background jobs of a Writer document.
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:447
sal_uInt16 sal_Char sal_Char * pDesc
void SetRightLeftMargins(long, long)
Definition: ssfrm.cxx:182
void SetPosX(const long nNew)
Definition: swrect.cxx:168
SwRootFrame(SwFrameFormat *, SwViewShell *)
Definition: newfrm.cxx:401
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:233
bool AddPaintRect(const SwRect &rRect)
Definition: viewsh.cxx:534
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:391
SwRectFn fnRectVertL2R
Definition: newfrm.cxx:290
virtual void DestroyImpl() override
Definition: ssfrm.cxx:473
long GetRightDistance(long) const
Definition: swrect.cxx:183
virtual void DestroyImpl() override
Definition: newfrm.cxx:528
static void RemoveMasterObjs(SdrPage *pPg)
Remove MasterObjects from the Page (called by the ctors)
Definition: newfrm.cxx:574
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:2870
static SwRectFnCollection aVerticalLeftToRight
Definition: newfrm.cxx:173
void Init(SwFrameFormat *)
Definition: newfrm.cxx:433
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:164
bool SetMaxRight(long)
Definition: ssfrm.cxx:88
const ::boost::optional< sal_uInt16 > & GetNumOffset() const
Definition: fmtpdsc.hxx:65
void SetLeftAndWidth(long nLeft, long nNew)
Definition: swrect.cxx:194
friend void InitCurrShells(SwRootFrame *pRoot)
Definition: newfrm.cxx:391
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:339
SwViewShell * mpWaitingCurrShell
Definition: rootfrm.hxx:160
void InvalidateSpelling() const
Definition: pagefrm.hxx:367
static SwRectFnCollection aHorizontal
Definition: newfrm.cxx:63
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:876
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:585
SwViewShell * pPrev
Definition: viewsh.hxx:580
void SetPosY(const long nNew)
Definition: swrect.cxx:169
const SwFrame * Lower() const
Definition: layfrm.hxx:100
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:54
Provides access to settings of a document.
void DeRegisterShell(SwViewShell *pSh)
Definition: newfrm.cxx:363
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:157
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:289
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:288
void AllInvalidateAutoCompleteWords() const
Definition: newfrm.cxx:591
virtual ~SwRootFrame() override
Definition: newfrm.cxx:570
void SetUpperRightCorner(const Point &rNew)
Definition: swrect.cxx:216
void SetTopAndHeight(long nTop, long nNew)
Definition: swrect.cxx:199
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:60
void SetLowerLeftCorner(const Point &rNew)
Definition: swrect.cxx:218
SwNodes & GetNodes()
Definition: doc.hxx:402
static SwLayVout * s_pVout
Definition: rootfrm.hxx:102
static long SwIncrement(long nA, long nAdd)
Definition: newfrm.cxx:58
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:351
void AllInvalidateSmartTagsOrSpelling(bool bSmartTags) const
Definition: newfrm.cxx:611
Size SwappedSize() const
Definition: swrect.cxx:172
void DelFrameFormat(SwFrameFormat *pFormat, bool bBroadcast=false)
Definition: docfmt.cxx:715
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:1923
void SetBottomAndHeight(long nBottom, long nNew)
Definition: swrect.cxx:209
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:325
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2071
long GetLeftMargin() const
Definition: ssfrm.cxx:43
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:204
SwRectFn fnRectVertL2RB2T
Definition: newfrm.cxx:291
long GetPrtBottom() const
Definition: ssfrm.cxx:49
void AllAddPaintRect() const
Definition: newfrm.cxx:601
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:56
Point BottomLeft() const
Definition: swrect.cxx:176
SwFrame * GetNext()
Definition: frame.hxx:654