LibreOffice Module sw (master)  1
pagechg.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 <comphelper/lok.hxx>
21 #include <ndole.hxx>
22 #include <sal/log.hxx>
23 #include <osl/diagnose.h>
24 #include <svl/itemiter.hxx>
25 #include <fmtfsize.hxx>
26 #include <fmthdft.hxx>
27 #include <fmtclds.hxx>
28 #include <fmtpdsc.hxx>
29 #include <fmtornt.hxx>
30 #include <fmtsrnd.hxx>
31 #include <ftninfo.hxx>
32 #include <frmtool.hxx>
33 #include <tgrditem.hxx>
34 #include <viewopt.hxx>
35 #include <docsh.hxx>
36 #include <wrtsh.hxx>
37 #include <view.hxx>
38 #include <edtwin.hxx>
39 #include <frameformats.hxx>
40 
41 #include <viewimp.hxx>
42 #include <pagefrm.hxx>
43 #include <rootfrm.hxx>
47 #include <dcontact.hxx>
48 #include <hints.hxx>
49 #include <FrameControlsManager.hxx>
50 
51 #include <ftnidx.hxx>
52 #include <bodyfrm.hxx>
53 #include <ftnfrm.hxx>
54 #include <tabfrm.hxx>
55 #include <txtfrm.hxx>
56 #include <notxtfrm.hxx>
57 #include <layact.hxx>
58 #include <flyfrms.hxx>
59 #include <htmltbl.hxx>
60 #include <pagedesc.hxx>
61 #include <editeng/frmdiritem.hxx>
62 #include <sortedobjs.hxx>
63 #include <calbck.hxx>
64 #include <txtfly.hxx>
65 
66 using namespace ::com::sun::star;
67 
69  SwLayoutFrame( pFormat, pSib )
70 {
72 }
73 
74 void SwBodyFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorderAttrs * )
75 {
76  // Formatting of the body is too simple, thus, it gets its own format method.
77  // Borders etc. are not taken into account here.
78  // Width is taken from the PrtArea of the Upper. Height is the height of the
79  // PrtArea of the Upper minus any neighbors (for robustness).
80  // The PrtArea has always the size of the frame.
81 
82  if ( !isFrameAreaSizeValid() )
83  {
84  SwTwips nHeight = GetUpper()->getFramePrintArea().Height();
85  SwTwips nWidth = GetUpper()->getFramePrintArea().Width();
86  const SwFrame *pFrame = GetUpper()->Lower();
87  do
88  {
89  if ( pFrame != this )
90  {
91  if( pFrame->IsVertical() )
92  nWidth -= pFrame->getFrameArea().Width();
93  else
94  nHeight -= pFrame->getFrameArea().Height();
95  }
96  pFrame = pFrame->GetNext();
97  } while ( pFrame );
98 
99  if ( nHeight < 0 )
100  {
101  nHeight = 0;
102  }
103 
105  aFrm.Height( nHeight );
106 
107  if( IsVertical() && !IsVertLR() && nWidth != aFrm.Width() )
108  {
109  aFrm.Pos().setX(aFrm.Pos().getX() + aFrm.Width() - nWidth);
110  }
111 
112  aFrm.Width( nWidth );
113  }
114 
115  bool bNoGrid = true;
116  if( GetUpper()->IsPageFrame() && static_cast<SwPageFrame*>(GetUpper())->HasGrid() )
117  {
118  SwTextGridItem const*const pGrid(
119  GetGridItem(static_cast<SwPageFrame*>(GetUpper())));
120  if( pGrid )
121  {
122  bNoGrid = false;
123  tools::Long nSum = pGrid->GetBaseHeight() + pGrid->GetRubyHeight();
124  SwRectFnSet aRectFnSet(this);
125  tools::Long nSize = aRectFnSet.GetWidth(getFrameArea());
126  tools::Long nBorder = 0;
127  if( GRID_LINES_CHARS == pGrid->GetGridType() )
128  {
129  //for textgrid refactor
130  SwDoc *pDoc = GetFormat()->GetDoc();
131  nBorder = nSize % (GetGridWidth(*pGrid, *pDoc));
132  nSize -= nBorder;
133  nBorder /= 2;
134  }
135 
137  aRectFnSet.SetPosX( aPrt, nBorder );
138  aRectFnSet.SetWidth( aPrt, nSize );
139 
140  // Height of body frame:
141  nBorder = aRectFnSet.GetHeight(getFrameArea());
142 
143  // Number of possible lines in area of body frame:
144  tools::Long nNumberOfLines = nBorder / nSum;
145  if( nNumberOfLines > pGrid->GetLines() )
146  nNumberOfLines = pGrid->GetLines();
147 
148  // Space required for nNumberOfLines lines:
149  nSize = nNumberOfLines * nSum;
150  nBorder -= nSize;
151  nBorder /= 2;
152 
153  // #i21774# Footnotes and centering the grid does not work together:
154  const bool bAdjust = static_cast<SwPageFrame*>(GetUpper())->GetFormat()->GetDoc()->
155  GetFootnoteIdxs().empty();
156 
157  aRectFnSet.SetPosY( aPrt, bAdjust ? nBorder : 0 );
158  aRectFnSet.SetHeight( aPrt, nSize );
159  }
160  }
161 
162  if( bNoGrid )
163  {
165  aPrt.Pos().setX(0);
166  aPrt.Pos().setY(0);
167  aPrt.Height( getFrameArea().Height() );
168  aPrt.Width( getFrameArea().Width() );
169  }
170 
171  setFrameAreaSizeValid(true);
173 }
174 
176  SwFootnoteBossFrame( pFormat, pSib ),
177  m_pDesc( pPgDsc ),
178  m_nPhyPageNum( 0 )
179 {
180  SetDerivedVert( false );
181  SetDerivedR2L( false );
182  if( m_pDesc )
183  {
184  m_bHasGrid = true;
185  SwTextGridItem const*const pGrid(GetGridItem(this));
186  if( !pGrid )
187  m_bHasGrid = false;
188  }
189  else
190  m_bHasGrid = false;
192  pPgDsc->GetFootnoteInfo().GetHeight() : LONG_MAX );
196 
198  const bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
199  vcl::RenderContext* pRenderContext = pSh ? pSh->GetOut() : nullptr;
200 
201  {
203 
204  if ( bBrowseMode )
205  {
206  aFrm.Height( 0 );
207  tools::Long nWidth = pSh->VisArea().Width();
208 
209  if ( !nWidth )
210  {
211  nWidth = 5000; // changes anyway
212  }
213 
214  aFrm.Width ( nWidth );
215  }
216  else
217  {
218  aFrm.SSize( pFormat->GetFrameSize().GetSize() );
219  }
220  }
221 
222  // create and insert body area if it is not a blank page
223  SwDoc* pDoc(pFormat->GetDoc());
224  m_bEmptyPage = (pFormat == pDoc->GetEmptyPageFormat());
225 
226  if(m_bEmptyPage)
227  {
228  return;
229  }
230 
231  Calc(pRenderContext); // so that the PrtArea is correct
232  SwBodyFrame *pBodyFrame = new SwBodyFrame( pDoc->GetDfltFrameFormat(), this );
233  pBodyFrame->ChgSize( getFramePrintArea().SSize() );
234  pBodyFrame->Paste( this );
235  pBodyFrame->Calc(pRenderContext); // so that the columns can be inserted correctly
236  pBodyFrame->InvalidatePos();
237 
238  if ( bBrowseMode )
239  InvalidateSize_();
240 
241  // insert header/footer,, but only if active.
242  if ( pFormat->GetHeader().IsActive() )
243  PrepareHeader();
244  if ( pFormat->GetFooter().IsActive() )
245  PrepareFooter();
246 
247  const SwFormatCol &rCol = pFormat->GetCol();
248  if ( rCol.GetNumCols() > 1 )
249  {
250  const SwFormatCol aOld; //ChgColumns() needs an old value
251  pBodyFrame->ChgColumns( aOld, rCol );
252  }
253 
254 }
255 
257 {
258  // Cleanup the header-footer controls in the SwEditWin
260  SwWrtShell* pWrtSh = dynamic_cast< SwWrtShell* >( pSh );
261  if ( pWrtSh )
262  {
263  SwEditWin& rEditWin = pWrtSh->GetView().GetEditWin();
264  rEditWin.GetFrameControlsManager( ).RemoveControls( this );
265  }
266 
267  // empty FlyContainer, deletion of the Flys is done by the anchor (in base class SwFrame)
268  if (m_pSortedObjs)
269  {
270  // Objects can be anchored at pages that are before their anchors (why ever...).
271  // In such cases, we would access already freed memory.
272  for (SwAnchoredObject* pAnchoredObj : *m_pSortedObjs)
273  {
274  pAnchoredObj->SetPageFrame( nullptr );
275  }
276  m_pSortedObjs.reset(); // reset to zero to prevent problems when detaching the Flys
277  }
278 
279  // prevent access to destroyed pages
280  SwDoc *pDoc = GetFormat() ? GetFormat()->GetDoc() : nullptr;
281  if( pDoc && !pDoc->IsInDtor() )
282  {
283  if ( pSh )
284  {
285  SwViewShellImp *pImp = pSh->Imp();
286  pImp->SetFirstVisPageInvalid();
287  if ( pImp->IsAction() )
288  pImp->GetLayAction().SetAgain();
289  // #i9719# - retouche area of page
290  // including border and shadow area.
291  const bool bRightSidebar = (SidebarPosition() == sw::sidebarwindows::SidebarPosition::RIGHT);
292  SwRect aRetoucheRect;
293  SwPageFrame::GetBorderAndShadowBoundRect( getFrameArea(), pSh, pSh->GetOut(), aRetoucheRect, IsLeftShadowNeeded(), IsRightShadowNeeded(), bRightSidebar );
294  pSh->AddPaintRect( aRetoucheRect );
295  }
296  }
297 
299 }
300 
302 {
303 }
304 
305 void SwPageFrame::CheckGrid( bool bInvalidate )
306 {
307  bool bOld = m_bHasGrid;
308  m_bHasGrid = true;
309  SwTextGridItem const*const pGrid(GetGridItem(this));
310  m_bHasGrid = nullptr != pGrid;
311  if( !(bInvalidate || bOld != m_bHasGrid) )
312  return;
313 
314  SwLayoutFrame* pBody = FindBodyCont();
315  if( pBody )
316  {
317  pBody->InvalidatePrt();
318  SwContentFrame* pFrame = pBody->ContainsContent();
319  while( pBody->IsAnLower( pFrame ) )
320  {
321  static_cast<SwTextFrame*>(pFrame)->Prepare();
322  pFrame = pFrame->GetNextContentFrame();
323  }
324  }
326 }
327 
328 void SwPageFrame::CheckDirection( bool bVert )
329 {
330  SvxFrameDirection nDir = GetFormat()->GetFormatAttr( RES_FRAMEDIR ).GetValue();
331  if( bVert )
332  {
333  if( SvxFrameDirection::Horizontal_LR_TB == nDir || SvxFrameDirection::Horizontal_RL_TB == nDir )
334  {
335  mbVertLR = false;
336  mbVertical = false;
337  }
338  else
339  {
340  const SwViewShell *pSh = getRootFrame()->GetCurrShell();
341  if( pSh && pSh->GetViewOptions()->getBrowseMode() )
342  {
343  mbVertLR = false;
344  mbVertical = false;
345  }
346  else
347  {
348  mbVertical = true;
349 
350  if(SvxFrameDirection::Vertical_RL_TB == nDir)
351  mbVertLR = false;
352  else if(SvxFrameDirection::Vertical_LR_TB==nDir)
353  mbVertLR = true;
354  }
355  }
356 
357  mbInvalidVert = false;
358  }
359  else
360  {
361  if( SvxFrameDirection::Horizontal_RL_TB == nDir )
362  mbRightToLeft = true;
363  else
364  mbRightToLeft = false;
365  mbInvalidR2L = false;
366  }
367 }
368 
370 static void lcl_FormatLay( SwLayoutFrame *pLay )
371 {
372  vcl::RenderContext* pRenderContext = pLay->getRootFrame()->GetCurrShell()->GetOut();
373  // format all LayoutFrames - no tables, Flys etc.
374 
375  SwFrame *pTmp = pLay->Lower();
376  // first the low-level ones
377  while ( pTmp )
378  {
382  if ( pTmp->GetType() & nTypes )
383  ::lcl_FormatLay( static_cast<SwLayoutFrame*>(pTmp) );
384  pTmp = pTmp->GetNext();
385  }
386  pLay->Calc(pRenderContext);
387 }
388 
390 static void lcl_MakeObjs( const SwFrameFormats &rTable, SwPageFrame *pPage )
391 {
392  // formats are in the special table of the document
393 
394  for ( size_t i = 0; i < rTable.size(); ++i )
395  {
396  SwFrameFormat *pFormat = rTable[i];
397  const SwFormatAnchor &rAnch = pFormat->GetAnchor();
398  if ( rAnch.GetPageNum() == pPage->GetPhyPageNum() )
399  {
400  if( rAnch.GetContentAnchor() )
401  {
402  if (RndStdIds::FLY_AT_PAGE == rAnch.GetAnchorId())
403  {
404  SwFormatAnchor aAnch( rAnch );
405  aAnch.SetAnchor( nullptr );
406  pFormat->SetFormatAttr( aAnch );
407  }
408  else
409  continue;
410  }
411 
412  // is it a border or a SdrObject?
413  bool bSdrObj = RES_DRAWFRMFMT == pFormat->Which();
414  SdrObject *pSdrObj = nullptr;
415  if ( bSdrObj && nullptr == (pSdrObj = pFormat->FindSdrObject()) )
416  {
417  OSL_FAIL( "DrawObject not found." );
418  pFormat->GetDoc()->DelFrameFormat( pFormat );
419  --i;
420  continue;
421  }
422  // The object might be anchored to another page, e.g. when inserting
423  // a new page due to a page descriptor change. In such cases, the
424  // object needs to be moved.
425  // In some cases the object is already anchored to the correct page.
426  // This will be handled here and does not need to be coded extra.
427  SwPageFrame *pPg = pPage->IsEmptyPage() ? static_cast<SwPageFrame*>(pPage->GetNext()) : pPage;
428  if ( bSdrObj )
429  {
430  // OD 23.06.2003 #108784# - consider 'virtual' drawing objects
431  SwDrawContact *pContact =
432  static_cast<SwDrawContact*>(::GetUserCall(pSdrObj));
433  if ( auto pDrawVirtObj = dynamic_cast<SwDrawVirtObj *>( pSdrObj ) )
434  {
435  if ( pContact )
436  {
437  pDrawVirtObj->RemoveFromWriterLayout();
438  pDrawVirtObj->RemoveFromDrawingPage();
439  pPg->AppendDrawObj( *(pContact->GetAnchoredObj( pDrawVirtObj )) );
440  }
441  }
442  else
443  {
444  if ( pContact->GetAnchorFrame() )
445  pContact->DisconnectFromLayout( false );
446  pPg->AppendDrawObj( *(pContact->GetAnchoredObj( pSdrObj )) );
447  }
448  }
449  else
450  {
451  SwIterator<SwFlyFrame,SwFormat> aIter( *pFormat );
452  SwFlyFrame *pFly = aIter.First();
453  if ( pFly)
454  {
455  if( pFly->GetAnchorFrame() )
456  pFly->AnchorFrame()->RemoveFly( pFly );
457  }
458  else
459  pFly = new SwFlyLayFrame( static_cast<SwFlyFrameFormat*>(pFormat), pPg, pPg );
460  pPg->AppendFly( pFly );
461  ::RegistFlys( pPg, pFly );
462  }
463  }
464  }
465 }
466 
468 {
469  SetFootnotePage( bFootnote );
470 
471  // #i82258#
472  // Due to made change on OOo 2.0 code line, method <::lcl_FormatLay(..)> has
473  // the side effect, that the content of page header and footer are formatted.
474  // For this formatting it is needed that the anchored objects are registered
475  // at the <SwPageFrame> instance.
476  // Thus, first calling <::RegistFlys(..)>, then call <::lcl_FormatLay(..)>
477  ::RegistFlys( this, this );
478 
479  if ( Lower() )
480  {
481  ::lcl_FormatLay( this );
482  }
483 
484  // Flys and draw objects that are still attached to the document.
485  // Footnote pages do not have page-bound Flys!
486  // There might be Flys or draw objects that want to be placed on
487  // empty pages, however, the empty pages ignore that and the following
488  // pages take care of them.
489  if ( !bFootnote && !IsEmptyPage() )
490  {
491  SwDoc *pDoc = GetFormat()->GetDoc();
492 
493  if ( GetPrev() && static_cast<SwPageFrame*>(GetPrev())->IsEmptyPage() )
494  lcl_MakeObjs( *pDoc->GetSpzFrameFormats(), static_cast<SwPageFrame*>(GetPrev()) );
495  lcl_MakeObjs( *pDoc->GetSpzFrameFormats(), this );
496  }
497 }
498 
499 void SwPageFrame::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
500 {
501  if(typeid(sw::PageFootnoteHint) == typeid(rHint))
502  {
503  // currently the savest way:
504  static_cast<SwRootFrame*>(GetUpper())->SetSuperfluous();
506  if(!GetMaxFootnoteHeight())
509  // here, the page might be destroyed:
510  static_cast<SwRootFrame*>(GetUpper())->RemoveFootnotes(nullptr, false, true);
511  }
512  else if(auto pLegacy = dynamic_cast<const sw::LegacyModifyHint*>(&rHint))
513  {
514  if(auto pSh = getRootFrame()->GetCurrShell())
515  pSh->SetFirstVisPageInvalid();
516 
518  if(pLegacy->m_pNew && RES_ATTRSET_CHG == pLegacy->m_pNew->Which())
519  {
520  auto& rOldSetChg = *static_cast<const SwAttrSetChg*>(pLegacy->m_pOld);
521  auto& rNewSetChg = *static_cast<const SwAttrSetChg*>(pLegacy->m_pNew);
522  SfxItemIter aOIter(*rOldSetChg.GetChgSet());
523  SfxItemIter aNIter(*rNewSetChg.GetChgSet());
524  const SfxPoolItem* pOItem = aOIter.GetCurItem();
525  const SfxPoolItem* pNItem = aNIter.GetCurItem();
526  SwAttrSetChg aOldSet(rOldSetChg);
527  SwAttrSetChg aNewSet(rNewSetChg);
528  do
529  {
530  UpdateAttr_(pOItem, pNItem, eInvFlags, &aOldSet, &aNewSet);
531  pOItem = aOIter.NextItem();
532  pNItem = aNIter.NextItem();
533  } while(pNItem);
534  if(aOldSet.Count() || aNewSet.Count())
535  SwLayoutFrame::SwClientNotify(rModify, sw::LegacyModifyHint(&aOldSet, &aNewSet));
536  }
537  else
538  UpdateAttr_(pLegacy->m_pOld, pLegacy->m_pNew, eInvFlags);
539 
540  if (eInvFlags == SwPageFrameInvFlags::NONE)
541  return;
542 
543  InvalidatePage( this );
544  if(eInvFlags & SwPageFrameInvFlags::InvalidatePrt)
545  InvalidatePrt_();
548  if(eInvFlags & SwPageFrameInvFlags::InvalidateNextPos && GetNext() )
549  GetNext()->InvalidatePos();
550  if(eInvFlags & SwPageFrameInvFlags::PrepareHeader)
551  PrepareHeader();
552  if(eInvFlags & SwPageFrameInvFlags::PrepareFooter)
553  PrepareFooter();
554  if(eInvFlags & SwPageFrameInvFlags::CheckGrid)
556  } else
557  SwFrame::SwClientNotify(rModify, rHint);
558 }
559 
560 void SwPageFrame::UpdateAttr_( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
561  SwPageFrameInvFlags &rInvFlags,
562  SwAttrSetChg *pOldSet, SwAttrSetChg *pNewSet )
563 {
564  bool bClear = true;
565  const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
566  switch( nWhich )
567  {
568  case RES_FMT_CHG:
569  {
570  // state of m_bEmptyPage needs to be determined newly
571  const bool bNewState(GetFormat() == GetFormat()->GetDoc()->GetEmptyPageFormat());
572 
573  if(m_bEmptyPage != bNewState)
574  {
575  // copy new state
576  m_bEmptyPage = bNewState;
577 
578  if(nullptr == GetLower())
579  {
580  // if we were an empty page before there is not yet a BodyArea in the
581  // form of a SwBodyFrame, see constructor
582  SwViewShell* pSh(getRootFrame()->GetCurrShell());
583  vcl::RenderContext* pRenderContext(pSh ? pSh->GetOut() : nullptr);
584  Calc(pRenderContext); // so that the PrtArea is correct
585  SwBodyFrame* pBodyFrame = new SwBodyFrame(GetFormat(), this);
586  pBodyFrame->ChgSize(getFramePrintArea().SSize());
587  pBodyFrame->Paste(this);
588  pBodyFrame->InvalidatePos();
589  }
590  }
591 
592  // If the frame format is changed, several things might also change:
593  // 1. columns:
594  assert(pOld && pNew); //FMT_CHG Missing Format
595  const SwFormat *const pOldFormat = static_cast<const SwFormatChg*>(pOld)->pChangedFormat;
596  const SwFormat *const pNewFormat = static_cast<const SwFormatChg*>(pNew)->pChangedFormat;
597  assert(pOldFormat && pNewFormat); //FMT_CHG Missing Format
598  const SwFormatCol &rOldCol = pOldFormat->GetCol();
599  const SwFormatCol &rNewCol = pNewFormat->GetCol();
600  if( rOldCol != rNewCol )
601  {
602  SwLayoutFrame *pB = FindBodyCont();
603  assert(pB && "Page without Body.");
604  pB->ChgColumns( rOldCol, rNewCol );
605  rInvFlags |= SwPageFrameInvFlags::CheckGrid;
606  }
607 
608  // 2. header and footer:
609  const SwFormatHeader &rOldH = pOldFormat->GetHeader();
610  const SwFormatHeader &rNewH = pNewFormat->GetHeader();
611  if( rOldH != rNewH )
613 
614  const SwFormatFooter &rOldF = pOldFormat->GetFooter();
615  const SwFormatFooter &rNewF = pNewFormat->GetFooter();
616  if( rOldF != rNewF )
618  CheckDirChange();
619 
620  [[fallthrough]];
621  }
622  case RES_FRM_SIZE:
623  {
624  const SwRect aOldPageFrameRect( getFrameArea() );
626  if( pSh && pSh->GetViewOptions()->getBrowseMode() )
627  {
628  setFrameAreaSizeValid(false);
629  // OD 28.10.2002 #97265# - Don't call <SwPageFrame::MakeAll()>
630  // Calculation of the page is not necessary, because its size is
631  // invalidated here and further invalidation is done in the
632  // calling method <SwPageFrame::Modify(..)> and probably by calling
633  // <SwLayoutFrame::SwClientNotify(..)> at the end.
634  // It can also causes inconsistences, because the lowers are
635  // adjusted, but not calculated, and a <SwPageFrame::MakeAll()> of
636  // a next page is called. This is performed on the switch to the
637  // online layout.
638  //MakeAll();
639  }
640  else if (pNew)
641  {
642  const SwFormatFrameSize &rSz = nWhich == RES_FMT_CHG ?
643  static_cast<const SwFormatChg*>(pNew)->pChangedFormat->GetFrameSize() :
644  static_cast<const SwFormatFrameSize&>(*pNew);
645 
646  {
648  aFrm.Height( std::max( rSz.GetHeight(), tools::Long(MINLAY) ) );
649  aFrm.Width ( std::max( rSz.GetWidth(), tools::Long(MINLAY) ) );
650  }
651 
652  if ( GetUpper() )
653  {
654  static_cast<SwRootFrame*>(GetUpper())->CheckViewLayout( nullptr, nullptr );
655  }
656  }
657  // cleanup Window
658  if( pSh && pSh->GetWin() && aOldPageFrameRect.HasArea() )
659  {
660  // #i9719# - consider border and shadow of
661  // page frame for determine 'old' rectangle - it's used for invalidating.
662  const bool bRightSidebar = (SidebarPosition() == sw::sidebarwindows::SidebarPosition::RIGHT);
663  SwRect aOldRectWithBorderAndShadow;
664  SwPageFrame::GetBorderAndShadowBoundRect( aOldPageFrameRect, pSh, pSh->GetOut(), aOldRectWithBorderAndShadow,
665  IsLeftShadowNeeded(), IsRightShadowNeeded(), bRightSidebar );
666  pSh->InvalidateWindows( aOldRectWithBorderAndShadow );
667  }
669  if ( aOldPageFrameRect.Height() != getFrameArea().Height() )
671  }
672  break;
673 
674  case RES_COL:
675  assert(pOld && pNew); //COL Missing Format
676  if (pOld && pNew)
677  {
678  SwLayoutFrame *pB = FindBodyCont();
679  assert(pB); //page without body
680  pB->ChgColumns( *static_cast<const SwFormatCol*>(pOld), *static_cast<const SwFormatCol*>(pNew) );
682  }
683  break;
684 
685  case RES_HEADER:
687  break;
688 
689  case RES_FOOTER:
691  break;
692  case RES_TEXTGRID:
694  break;
695  case RES_FRAMEDIR :
696  CheckDirChange();
697  break;
698 
699  default:
700  bClear = false;
701  }
702  if ( !bClear )
703  return;
704 
705  if ( pOldSet || pNewSet )
706  {
707  if ( pOldSet )
708  pOldSet->ClearItem( nWhich );
709  if ( pNewSet )
710  pNewSet->ClearItem( nWhich );
711  }
712  else
713  {
714  SwModify aMod;
716  }
717 }
718 
720 bool SwPageFrame::GetInfo( SfxPoolItem & rInfo ) const
721 {
722  if( RES_AUTOFMT_DOCNODE == rInfo.Which() )
723  {
724  // a page frame exists, so use this one
725  return false;
726  }
727  return true; // continue searching
728 }
729 
731 {
732  m_pDesc = pNew;
733  if ( pFormat )
734  SetFrameFormat( pFormat );
735 }
736 
737 /* determine the right PageDesc:
738  * 0. from the document for footnote and endnote pages
739  * 1. from the first BodyContent below a page
740  * 2. from PageDesc of the predecessor page
741  * 3. from PageDesc of the previous page if blank page
742  * 3.1 from PageDesc of the next page if no predecessor exists
743  * 4. default PageDesc
744  * 5. In BrowseMode use the first paragraph or default PageDesc.
745  */
747 {
748  // 0.
749  if ( IsFootnotePage() )
750  {
751  SwDoc *pDoc = GetFormat()->GetDoc();
752  if ( IsEndNotePage() )
753  return pDoc->GetEndNoteInfo().GetPageDesc( *pDoc );
754  else
755  return pDoc->GetFootnoteInfo().GetPageDesc( *pDoc );
756  }
757 
758  SwPageDesc *pRet = nullptr;
759 
760  //5.
761  const SwViewShell *pSh = getRootFrame()->GetCurrShell();
762  if( pSh && pSh->GetViewOptions()->getBrowseMode() )
763  {
764  SwContentFrame *pFrame = GetUpper()->ContainsContent();
765  while (pFrame && !pFrame->IsInDocBody())
766  pFrame = pFrame->GetNextContentFrame();
767  if (pFrame)
768  {
769  SwFrame *pFlow = pFrame;
770  if ( pFlow->IsInTab() )
771  pFlow = pFlow->FindTabFrame();
772  pRet = const_cast<SwPageDesc*>(pFlow->GetPageDescItem().GetPageDesc());
773  }
774  if ( !pRet )
775  pRet = &GetFormat()->GetDoc()->GetPageDesc( 0 );
776  return pRet;
777  }
778 
779  SwFrame *pFlow = FindFirstBodyContent();
780  if ( pFlow && pFlow->IsInTab() )
781  pFlow = pFlow->FindTabFrame();
782 
783  //1.
784  if ( pFlow )
785  {
786  SwFlowFrame *pTmp = SwFlowFrame::CastFlowFrame( pFlow );
787  if ( !pTmp->IsFollow() )
788  pRet = const_cast<SwPageDesc*>(pFlow->GetPageDescItem().GetPageDesc());
789  }
790 
791  //3. and 3.1
792  if ( !pRet && IsEmptyPage() )
793  // FME 2008-03-03 #i81544# lijian/fme: an empty page should have
794  // the same page description as its prev, just like after construction
795  // of the empty page.
796  pRet = GetPrev() ? static_cast<SwPageFrame*>(GetPrev())->GetPageDesc() :
797  GetNext() ? static_cast<SwPageFrame*>(GetNext())->GetPageDesc() : nullptr;
798 
799  //2.
800  if ( !pRet )
801  pRet = GetPrev() ?
802  static_cast<SwPageFrame*>(GetPrev())->GetPageDesc()->GetFollow() : nullptr;
803 
804  //4.
805  if ( !pRet )
806  pRet = &GetFormat()->GetDoc()->GetPageDesc( 0 );
807 
808  OSL_ENSURE( pRet, "could not find page descriptor." );
809  return pRet;
810 }
811 
812 // Notify if the RootFrame changes its size
814 {
815  const bool bOld = pRoot->IsSuperfluous();
816  pRoot->mbCheckSuperfluous = false;
817  if ( pRoot->GetCurrShell() )
818  {
819  for(SwViewShell& rSh : pRoot->GetCurrShell()->GetRingContainer())
820  {
821  if( pRoot == rSh.GetLayout() )
822  {
823  rSh.SizeChgNotify();
824  if ( rSh.Imp() )
825  rSh.Imp()->NotifySizeChg( pRoot->getFrameArea().SSize() );
826  }
827  }
828  }
829  pRoot->mbCheckSuperfluous = bOld;
830 }
831 
832 inline void SetLastPage( SwPageFrame *pPage )
833 {
834  static_cast<SwRootFrame*>(pPage->GetUpper())->mpLastPage = pPage;
835 }
836 
838 {
840  if ( !IsEmptyPage() )
841  {
842  if ( GetNext() )
843  GetNext()->InvalidatePos();
844 
845  // move Flys whose anchor is on a different page (draw objects are not relevant here)
846  if ( GetSortedObjs() )
847  {
848  size_t i = 0;
849  while ( GetSortedObjs() && i < GetSortedObjs()->size() )
850  {
851  // #i28701#
852  SwAnchoredObject* pAnchoredObj = (*GetSortedObjs())[i];
853 
854  if ( auto pFly = dynamic_cast<SwFlyAtContentFrame *>( pAnchoredObj ) )
855  {
856  SwPageFrame *pAnchPage = pFly->GetAnchorFrame() ?
857  pFly->AnchorFrame()->FindPageFrame() : nullptr;
858  if ( pAnchPage && (pAnchPage != this) )
859  {
860  MoveFly( pFly, pAnchPage );
861  pFly->InvalidateSize();
862  pFly->InvalidatePos_();
863  // Do not increment index, in this case
864  continue;
865  }
866  }
867  ++i;
868  }
869  }
870  // cleanup Window
871  if ( pSh && pSh->GetWin() )
873  }
874 
875  // decrease the root's page number
876  static_cast<SwRootFrame*>(GetUpper())->DecrPhyPageNums();
877  SwPageFrame *pPg = static_cast<SwPageFrame*>(GetNext());
878  if ( pPg )
879  {
880  while ( pPg )
881  {
882  --pPg->m_nPhyPageNum;
883  pPg = static_cast<SwPageFrame*>(pPg->GetNext());
884  }
885  }
886  else
887  ::SetLastPage( static_cast<SwPageFrame*>(GetPrev()) );
888 
889  SwFrame* pRootFrame = GetUpper();
890 
891  // cut all connections
893 
894  if ( pRootFrame )
895  static_cast<SwRootFrame*>(pRootFrame)->CheckViewLayout( nullptr, nullptr );
896 }
897 
898 void SwPageFrame::Paste( SwFrame* pParent, SwFrame* pSibling )
899 {
900  OSL_ENSURE( pParent->IsRootFrame(), "Parent is no Root." );
901  OSL_ENSURE( pParent, "No parent for Paste()." );
902  OSL_ENSURE( pParent != this, "I'm my own parent." );
903  OSL_ENSURE( pSibling != this, "I'm my own neighbour." );
904  OSL_ENSURE( !GetPrev() && !GetNext() && !GetUpper(),
905  "I am still registered somewhere." );
906 
907  // insert into tree structure
908  InsertBefore( static_cast<SwLayoutFrame*>(pParent), pSibling );
909 
910  // increase the root's page number
911  static_cast<SwRootFrame*>(GetUpper())->IncrPhyPageNums();
912  if( GetPrev() )
913  SetPhyPageNum( static_cast<SwPageFrame*>(GetPrev())->GetPhyPageNum() + 1 );
914  else
915  SetPhyPageNum( 1 );
916  SwPageFrame *pPg = static_cast<SwPageFrame*>(GetNext());
917  if ( pPg )
918  {
919  while ( pPg )
920  {
921  ++pPg->m_nPhyPageNum;
922  pPg->InvalidatePos_();
923  pPg->InvalidateLayout();
924  pPg = static_cast<SwPageFrame*>(pPg->GetNext());
925  }
926  }
927  else
928  ::SetLastPage( this );
929 
930  if( getFrameArea().Width() != pParent->getFramePrintArea().Width() )
931  InvalidateSize_();
932 
933  InvalidatePos();
934 
936  if ( pSh )
937  pSh->SetFirstVisPageInvalid();
938 
939  getRootFrame()->CheckViewLayout( nullptr, nullptr );
940 }
941 
943 {
944  pFrame->Prepare( PrepareHint::Register );
945  if( !pFrame->GetDrawObjs() )
946  return;
947 
948  for(SwAnchoredObject* pAnchoredObj : *pFrame->GetDrawObjs())
949  {
950  // #i28701#
951  if ( auto pFly = dynamic_cast<SwFlyInContentFrame *>( pAnchoredObj ) )
952  {
953  SwContentFrame *pCnt = pFly->ContainsContent();
954  while ( pCnt )
955  {
956  lcl_PrepFlyInCntRegister( pCnt );
957  pCnt = pCnt->GetNextContentFrame();
958  }
959  }
960  }
961 }
962 
964 {
966  while( pFrame )
967  {
968  lcl_PrepFlyInCntRegister( pFrame );
969  pFrame = pFrame->GetNextContentFrame();
970  if( !IsAnLower( pFrame ) )
971  break;
972  }
973  if( !GetSortedObjs() )
974  return;
975 
976  for(SwAnchoredObject* pAnchoredObj : *GetSortedObjs())
977  {
978  // #i28701#
979  if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
980  {
981  pFrame = pFly->ContainsContent();
982  while ( pFrame )
983  {
984  ::lcl_PrepFlyInCntRegister( pFrame );
985  pFrame = pFrame->GetNextContentFrame();
986  }
987  }
988  }
989 }
990 
991 namespace sw {
992 
994 bool IsPageFrameEmpty(SwPageFrame const& rPage)
995 {
996  bool bExistEssentialObjs = (nullptr != rPage.GetSortedObjs());
997  if (bExistEssentialObjs)
998  {
999  // Only because the page has Flys does not mean that it is needed. If all Flys are
1000  // attached to generic content it is also superfluous (checking DocBody should be enough)
1001  // OD 19.06.2003 - consider that drawing objects in
1002  // header/footer are supported now.
1003  bool bOnlySuperfluousObjs = true;
1004  SwSortedObjs const& rObjs = *rPage.GetSortedObjs();
1005  for (size_t i = 0; bOnlySuperfluousObjs && i < rObjs.size(); ++i)
1006  {
1007  // #i28701#
1008  SwAnchoredObject* pAnchoredObj = rObjs[i];
1009  // do not consider hidden objects
1011  pAnchoredObj->GetDrawObj()->GetLayer() ) &&
1012  !pAnchoredObj->GetAnchorFrame()->FindFooterOrHeader() )
1013  {
1014  bOnlySuperfluousObjs = false;
1015  }
1016  }
1017  bExistEssentialObjs = !bOnlySuperfluousObjs;
1018  }
1019 
1020  // optimization: check first if essential objects exist.
1021  const SwLayoutFrame* pBody = nullptr;
1022  if ( bExistEssentialObjs ||
1023  rPage.FindFootnoteCont() ||
1024  (nullptr != (pBody = rPage.FindBodyCont()) &&
1025  ( pBody->ContainsContent() ||
1026  // #i47580#
1027  // Do not delete page if there's an empty tabframe
1028  // left. I think it might be correct to use ContainsAny()
1029  // instead of ContainsContent() to cover the empty-table-case,
1030  // but I'm not fully sure, since ContainsAny() also returns
1031  // SectionFrames. Therefore I prefer to do it the safe way:
1032  ( pBody->Lower() && pBody->Lower()->IsTabFrame() ) ) ) )
1033  {
1034  return false;
1035  }
1036  else
1037  {
1038  return true;
1039  }
1040 }
1041 
1042 } // namespace sw
1043 
1044 //FIXME: provide missing documentation
1055 void SwFrame::CheckPageDescs( SwPageFrame *pStart, bool bNotifyFields, SwPageFrame** ppPrev )
1056 {
1057  SAL_INFO( "sw.pageframe", "(CheckPageDescs in phy: " << pStart->GetPhyPageNum() );
1058  assert(pStart && "no starting page.");
1059 
1060  SwViewShell *pSh = pStart->getRootFrame()->GetCurrShell();
1061  SwViewShellImp *pImp = pSh ? pSh->Imp() : nullptr;
1062 
1063  if ( pImp && pImp->IsAction() && !pImp->GetLayAction().IsCheckPages() )
1064  {
1065  pImp->GetLayAction().SetCheckPageNum( pStart->GetPhyPageNum() );
1066  SAL_INFO( "sw.pageframe", "CheckPageDescs out fast - via SetCheckPageNum: "
1067  << pStart->GetPhyPageNum() << ")" );
1068  return;
1069  }
1070 
1071  // For the update of page numbering fields, nDocPos provides
1072  // the page position from where invalidation should start.
1073  SwTwips nDocPos = LONG_MAX;
1074 
1075  SwRootFrame *pRoot = static_cast<SwRootFrame*>(pStart->GetUpper());
1076  SwDoc* pDoc = pStart->GetFormat()->GetDoc();
1077  const bool bFootnotes = !pDoc->GetFootnoteIdxs().empty();
1078 
1079  SwPageFrame *pPage = pStart;
1080  if( pPage->GetPrev() && static_cast<SwPageFrame*>(pPage->GetPrev())->IsEmptyPage() )
1081  pPage = static_cast<SwPageFrame*>(pPage->GetPrev());
1082  while ( pPage )
1083  {
1084  SwPageFrame *pPrevPage = static_cast<SwPageFrame*>(pPage->GetPrev());
1085  SwPageFrame *pNextPage = static_cast<SwPageFrame*>(pPage->GetNext());
1086 
1087  SwPageDesc *pDesc = pPage->FindPageDesc();
1089  bool bIsEmpty = pPage->IsEmptyPage();
1090  // false for intentionally empty pages, they need additional check
1091  bool isPageFrameEmpty(!bIsEmpty && sw::IsPageFrameEmpty(*pPage));
1092  bool bIsOdd = pPage->OnRightPage();
1093  bool bWantOdd = pPage->WannaRightPage();
1094  bool bFirst = pPage->OnFirstPage();
1095  SwFrameFormat *pFormatWish = bWantOdd
1096  ? pDesc->GetRightFormat(bFirst) : pDesc->GetLeftFormat(bFirst);
1097 
1098  if ( bIsOdd != bWantOdd ||
1099  pDesc != pPage->GetPageDesc() || // wrong Desc
1100  ( pFormatWish != pPage->GetFormat() && // wrong format and
1101  ( !bIsEmpty || pFormatWish ) // not blank /empty
1102  )
1103  )
1104  {
1105  // Updating a page might take a while, so check the WaitCursor
1106  if( pImp )
1107  pImp->CheckWaitCursor();
1108 
1109  // invalidate the field, starting from here
1110  if ( nDocPos == LONG_MAX )
1111  nDocPos = pPrevPage ? pPrevPage->getFrameArea().Top() : pPage->getFrameArea().Top();
1112 
1113  // Cases:
1114  // 1. Empty page should be "normal" page -> remove empty page and take next one
1115  // 2. Empty page should have different descriptor -> change
1116  // 3. Normal page should be empty -> insert empty page if previous page
1117  // is not empty, otherwise see (6).
1118  // 4. Normal page should have different descriptor -> change
1119  // 5. Normal page should have different format -> change
1120  // 6. No "wish" format provided -> take the "other" format (left/right) of the PageDesc
1121 
1122  if ( bIsEmpty && ( pFormatWish || //1.
1123  ( !bWantOdd && !pPrevPage ) ) )
1124  {
1125  // Check all cases for the next page, so we don't oscillate empty pages
1126  // Skip case 1 and 2, as we require a non-empty next page to save the empty page
1127  // Case 3 is the one we actually want to predict and skip
1128  // We can skip the empty check of case 3, as we just work on an existing next page
1129  bool bNextWantOdd;
1130  SwPageDesc *pNextDesc;
1131  if ( pNextPage && !pNextPage->IsEmptyPage() && //3.
1132  pNextPage->OnRightPage() == (bNextWantOdd = pNextPage->WannaRightPage()) &&
1133  pNextPage->GetPageDesc() == (pNextDesc = pNextPage->FindPageDesc()) ) //4.
1134  {
1135  bool bNextFirst = pNextPage->OnFirstPage();
1136  SwFrameFormat *pNextFormatWish = bNextWantOdd ? //5.
1137  pNextDesc->GetRightFormat(bNextFirst) : pNextDesc->GetLeftFormat(bNextFirst);
1138  if ( !pNextFormatWish ) // 6.
1139  pNextFormatWish = bNextWantOdd ? pNextDesc->GetLeftFormat() : pNextDesc->GetRightFormat();
1140  if ( pNextFormatWish && pNextPage->GetFormat() == pNextFormatWish )
1141  {
1142  SAL_INFO( "sw.pageframe", "CheckPageDescs phys: " << pPage->GetPhyPageNum()
1143  << " c: 1+3 - skip next page of p: " << pPage );
1144  if (pPrevPage && pPage->GetPageDesc() != pPrevPage->GetPageDesc())
1145  pPage->SetPageDesc( pPrevPage->GetPageDesc(), nullptr );
1146  // We can skip the next page, as all checks were already done!
1147  pPage = static_cast<SwPageFrame*>(pNextPage->GetNext());
1148  continue;
1149  }
1150  }
1151 
1152  pPage->Cut();
1153  bool bUpdatePrev = false;
1154  if (ppPrev && *ppPrev == pPage)
1155  bUpdatePrev = true;
1156  SAL_INFO( "sw.pageframe", "CheckPageDescs phys: " << pPage->GetPhyPageNum()
1157  << " c: 1 - destroy p: " << pPage );
1158  SwFrame::DestroyFrame(pPage);
1159  if ( pStart == pPage )
1160  pStart = pNextPage;
1161  pPage = pNextPage;
1162  if (bUpdatePrev)
1163  *ppPrev = pNextPage;
1164  continue;
1165  }
1166  else if ( bIsEmpty && !pFormatWish && //2.
1167  pDesc != pPage->GetPageDesc() )
1168  {
1169  SAL_INFO( "sw.pageframe", "CheckPageDescs phys: " << pPage->GetPhyPageNum()
1170  << " c: 2 - set desc p: " << pPage << " d: " << pDesc );
1171  pPage->SetPageDesc( pDesc, nullptr );
1172  }
1173  else if ( !bIsEmpty && //3.
1174  bIsOdd != bWantOdd &&
1175  ( ( !pPrevPage && !bWantOdd ) ||
1176  ( pPrevPage && !pPrevPage->IsEmptyPage() )
1177  )
1178  )
1179  {
1180  if ( pPrevPage )
1181  pDesc = pPrevPage->GetPageDesc();
1182  SwPageFrame *pTmp = new SwPageFrame( pDoc->GetEmptyPageFormat(), pRoot, pDesc );
1183  SAL_INFO( "sw.pageframe", "CheckPageDescs phys: " << pPage->GetPhyPageNum()
1184  << " c: 3 - insert empty p: " << pTmp << " d: " << pDesc );
1185  pTmp->Paste( pRoot, pPage );
1186  pTmp->PreparePage( false );
1187  pPage = pTmp;
1188  isPageFrameEmpty = false; // don't delete it right away!
1189  }
1190  else if ( pPage->GetPageDesc() != pDesc ) //4.
1191  {
1192  SwPageDesc *pOld = pPage->GetPageDesc();
1193  pPage->SetPageDesc( pDesc, pFormatWish );
1194  SAL_INFO( "sw.pageframe", "CheckPageDescs phys: " << pPage->GetPhyPageNum()
1195  << " c: 4 - set desc + format p: " << pPage
1196  << " d: " << pDesc << " f: " << pFormatWish );
1197  if ( bFootnotes )
1198  {
1199  // If specific values of the FootnoteInfo are changed, something has to happen.
1200  // We try to limit the damage...
1201  // If the page has no FootnoteCont it might be problematic.
1202  // Let's hope that invalidation is enough.
1203  SwFootnoteContFrame *pCont = pPage->FindFootnoteCont();
1204  if ( pCont && !(pOld->GetFootnoteInfo() == pDesc->GetFootnoteInfo()) )
1205  pCont->InvalidateAll_();
1206  }
1207  }
1208  else if ( pFormatWish && pPage->GetFormat() != pFormatWish ) //5.
1209  {
1210  pPage->SetFrameFormat( pFormatWish );
1211  SAL_INFO( "sw.pageframe", "CheckPageDescs phys: " << pPage->GetPhyPageNum()
1212  << " c: 5 - set format p: " << pPage << " f: " << pFormatWish );
1213  }
1214  else if ( !pFormatWish ) //6.
1215  {
1216  // get format with inverted logic
1217  pFormatWish = bWantOdd ? pDesc->GetLeftFormat() : pDesc->GetRightFormat();
1218  if ( pFormatWish && pPage->GetFormat() != pFormatWish )
1219  {
1220  pPage->SetFrameFormat( pFormatWish );
1221  SAL_INFO( "sw.pageframe", "CheckPageDescs phys: " << pPage->GetPhyPageNum()
1222  << " c: 6 - set format p: " << pPage << " f: " << pFormatWish );
1223  }
1224  }
1225 #if OSL_DEBUG_LEVEL > 0
1226  else
1227  {
1228  OSL_FAIL( "CheckPageDescs, missing solution" );
1229  }
1230 #endif
1231  }
1232  assert(!bIsEmpty || !isPageFrameEmpty);
1233  const bool bWantRemovePage = bIsEmpty || isPageFrameEmpty;
1234  if (bWantRemovePage && !pPage->IsDeleteForbidden())
1235  {
1236  // It also might be that an empty page is not needed at all.
1237  // However, the algorithm above cannot determine that. It is not needed if the following
1238  // page can live without it. Do obtain that information, we need to dig deeper...
1239  SwPageFrame *pPg = static_cast<SwPageFrame*>(pPage->GetNext());
1240  if (isPageFrameEmpty || !pPg || pPage->OnRightPage() == pPg->WannaRightPage())
1241  {
1242  // The following page can find a FrameFormat or has no successor -> empty page not needed
1243  SwPageFrame *pTmp = static_cast<SwPageFrame*>(pPage->GetNext());
1244  if (isPageFrameEmpty && pPage->GetPrev())
1245  { // check previous *again* vs. its new next! see "ooo321_stylepagenumber.odt"
1246  pTmp = static_cast<SwPageFrame*>(pPage->GetPrev());
1247  }
1248  pPage->Cut();
1249  bool bUpdatePrev = false;
1250  if (ppPrev && *ppPrev == pPage)
1251  bUpdatePrev = true;
1252  SwFrame::DestroyFrame(pPage);
1253  SAL_INFO( "sw.pageframe", "CheckPageDescs - handle bIsEmpty - destroy p: " << pPage );
1254  if ( pStart == pPage )
1255  pStart = pTmp;
1256  pPage = pTmp;
1257  if (bUpdatePrev)
1258  *ppPrev = pTmp;
1259  continue;
1260  }
1261  }
1262  pPage = static_cast<SwPageFrame*>(pPage->GetNext());
1263  }
1264 
1265  pRoot->SetAssertFlyPages();
1266  SwRootFrame::AssertPageFlys( pStart );
1267 
1268  if ( bNotifyFields && (!pImp || !pImp->IsUpdateExpFields()) )
1269  {
1270  SwDocPosUpdate aMsgHint( nDocPos );
1271  pDoc->getIDocumentFieldsAccess().UpdatePageFields( &aMsgHint );
1272  }
1273 
1274 #if OSL_DEBUG_LEVEL > 0
1275  //1. check if two empty pages are behind one another
1276  bool bEmpty = false;
1277  SwPageFrame *pPg = pStart;
1278  while ( pPg )
1279  {
1280  if ( pPg->IsEmptyPage() )
1281  {
1282  if ( bEmpty )
1283  {
1284  OSL_FAIL( "double empty pages." );
1285  break; // once is enough
1286  }
1287  bEmpty = true;
1288  }
1289  else
1290  bEmpty = false;
1291 
1292  pPg = static_cast<SwPageFrame*>(pPg->GetNext());
1293  }
1294 #endif
1295  SAL_INFO( "sw.pageframe", "CheckPageDescs out)" );
1296 }
1297 
1298 namespace
1299 {
1300  bool isDeleteForbidden(const SwPageFrame *pDel)
1301  {
1302  if (pDel->IsDeleteForbidden())
1303  return true;
1304  const SwLayoutFrame* pBody = pDel->FindBodyCont();
1305  const SwFrame* pBodyContent = pBody ? pBody->Lower() : nullptr;
1306  return pBodyContent && pBodyContent->IsDeleteForbidden();
1307  }
1308 
1309  bool doInsertPage( SwRootFrame *pRoot, SwPageFrame **pRefSibling,
1310  SwFrameFormat *pFormat, SwPageDesc *pDesc,
1311  bool bFootnote, SwPageFrame **pRefPage )
1312  {
1313  SwPageFrame *pPage = new SwPageFrame(pFormat, pRoot, pDesc);
1314  SwPageFrame *pSibling = *pRefSibling;
1315  if ( pRefPage )
1316  {
1317  *pRefPage = pPage;
1318  SAL_INFO( "sw.pageframe", "doInsertPage p: " << pPage
1319  << " d: " << pDesc << " f: " << pFormat );
1320  }
1321  else
1322  SAL_INFO( "sw.pageframe", "doInsertPage - insert empty p: "
1323  << pPage << " d: " << pDesc );
1324  pPage->Paste( pRoot, pSibling );
1325 
1326  SwViewShell* pViewShell = pRoot->GetCurrShell();
1327  if (pViewShell && pViewShell->GetViewOptions()->IsHideWhitespaceMode())
1328  {
1329  // Hide-whitespace mode does not shrink the last page, so resize the page that used to
1330  // be the last one.
1331  if (SwFrame* pPrevPage = pPage->GetPrev())
1332  {
1333  pPrevPage->InvalidateSize();
1334  }
1335  }
1336 
1337  pPage->PreparePage( bFootnote );
1338  // If the sibling has no body text, destroy it as long as it is no footnote page.
1339  if ( pSibling && !pSibling->IsFootnotePage() &&
1340  !pSibling->FindFirstBodyContent() &&
1341  (!pRefPage || !isDeleteForbidden(pSibling)) )
1342  {
1343  pRoot->RemovePage( pRefSibling, SwRemoveResult::Next ) ;
1344  return false;
1345  }
1346  return true;
1347  }
1348 }
1349 
1350 SwPageFrame *SwFrame::InsertPage( SwPageFrame *pPrevPage, bool bFootnote )
1351 {
1352  SwRootFrame *pRoot = static_cast<SwRootFrame*>(pPrevPage->GetUpper());
1353  SwPageFrame *pSibling = static_cast<SwPageFrame*>(pPrevPage->GetNext());
1354  SwPageDesc *pDesc = nullptr;
1355 
1356  // insert right (odd) or left (even) page?
1357  bool bNextRightPage = !pPrevPage->OnRightPage();
1358  bool bWishedRightPage = bNextRightPage;
1359 
1360  // Which PageDesc is relevant?
1361  // For ContentFrame take the one from format if provided,
1362  // otherwise from the Follow of the PrevPage
1363  if ( IsFlowFrame() && !SwFlowFrame::CastFlowFrame( this )->IsFollow() )
1364  {
1365  SwFormatPageDesc &rDesc = const_cast<SwFormatPageDesc&>(GetPageDescItem());
1366  pDesc = rDesc.GetPageDesc();
1367  if ( rDesc.GetNumOffset() )
1368  {
1369  ::std::optional<sal_uInt16> oNumOffset = rDesc.GetNumOffset();
1370  bWishedRightPage = sw::IsRightPageByNumber(*pRoot, *oNumOffset);
1371  // use the opportunity to set the flag at root
1372  pRoot->SetVirtPageNum( true );
1373  }
1374  }
1375  if ( !pDesc )
1376  pDesc = pPrevPage->GetPageDesc()->GetFollow();
1377 
1378  assert(pDesc && "Missing PageDesc");
1379  if( !(bWishedRightPage ? pDesc->GetRightFormat() : pDesc->GetLeftFormat()) )
1380  bWishedRightPage = !bWishedRightPage;
1381  bool const bWishedFirst = pDesc != pPrevPage->GetPageDesc();
1382 
1383  SwDoc *pDoc = pPrevPage->GetFormat()->GetDoc();
1384  bool bCheckPages = false;
1385  // If there is no FrameFormat for this page, create an empty page.
1386  if (bWishedRightPage != bNextRightPage)
1387  {
1388  if( doInsertPage( pRoot, &pSibling, pDoc->GetEmptyPageFormat(),
1389  pPrevPage->GetPageDesc(), bFootnote, nullptr ) )
1390  bCheckPages = true;
1391  }
1392  SwFrameFormat *const pFormat( bWishedRightPage
1393  ? pDesc->GetRightFormat(bWishedFirst)
1394  : pDesc->GetLeftFormat(bWishedFirst) );
1395  assert(pFormat);
1396  SwPageFrame *pPage = nullptr;
1397  if( doInsertPage( pRoot, &pSibling, pFormat, pDesc, bFootnote, &pPage ) )
1398  bCheckPages = true;
1399 
1400  if ( pSibling )
1401  {
1402  if ( bCheckPages )
1403  {
1404  CheckPageDescs( pSibling, false );
1406  SwViewShellImp *pImp = pSh ? pSh->Imp() : nullptr;
1407  if ( pImp && pImp->IsAction() && !pImp->GetLayAction().IsCheckPages() )
1408  {
1409  const sal_uInt16 nNum = pImp->GetLayAction().GetCheckPageNum();
1410  if ( nNum == pPrevPage->GetPhyPageNum() + 1 )
1411  {
1413  pSibling->GetPhyPageNum() );
1414  SAL_INFO( "sw.pageframe", "InsertPage - SetCheckPageNumDirect: "
1415  << pSibling->GetPhyPageNum() );
1416  }
1417  return pPage;
1418  }
1419  }
1420  else
1421  SwRootFrame::AssertPageFlys( pSibling );
1422  }
1423 
1424  // For the update of page numbering fields, nDocPos provides
1425  // the page position from where invalidation should start.
1427  if ( !pSh || !pSh->Imp()->IsUpdateExpFields() )
1428  {
1429  SwDocPosUpdate aMsgHint( pPrevPage->getFrameArea().Top() );
1430  pDoc->getIDocumentFieldsAccess().UpdatePageFields( &aMsgHint );
1431  }
1432  return pPage;
1433 }
1434 
1436 {
1438  if( !pSh || pSh->GetViewOptions()->getBrowseMode() )
1439  {
1441  }
1442  else
1443  {
1444  const bool bLTR = getRootFrame()->IsLeftToRightViewLayout();
1445  const bool bBookMode = pSh->GetViewOptions()->IsViewLayoutBookMode();
1446  const bool bRightSidebar = bLTR ? (!bBookMode || OnRightPage()) : (bBookMode && !OnRightPage());
1447 
1448  return bRightSidebar
1451  }
1452 }
1453 
1454 SwTwips SwRootFrame::GrowFrame( SwTwips nDist, bool bTst, bool )
1455 {
1456  if ( !bTst )
1457  {
1459  aFrm.AddHeight(nDist );
1460  }
1461 
1462  return nDist;
1463 }
1464 
1465 SwTwips SwRootFrame::ShrinkFrame( SwTwips nDist, bool bTst, bool )
1466 {
1467  OSL_ENSURE( nDist >= 0, "nDist < 0." );
1468  OSL_ENSURE( nDist <= getFrameArea().Height(), "nDist greater than current size." );
1469 
1470  if ( !bTst )
1471  {
1473  aFrm.AddHeight( -nDist );
1474  }
1475 
1476  return nDist;
1477 }
1478 
1480 {
1481  SwPageFrame *pDel = *pDelRef;
1482  (*pDelRef) = static_cast<SwPageFrame*>(
1483  eResult == SwRemoveResult::Next ? pDel->GetNext() : pDel->GetPrev() );
1484  if ( !GetFormat()->GetDoc()->GetFootnoteIdxs().empty() )
1485  RemoveFootnotes( pDel, true );
1486  pDel->Cut();
1487  SwFrame::DestroyFrame( pDel );
1488 }
1489 
1492 {
1493  // A page is empty if the body text area has no ContentFrame, but not if there
1494  // is at least one Fly or one footnote attached to the page. Two runs are
1495  // needed: one for endnote pages and one for the pages of the body text.
1496 
1497  if ( !IsSuperfluous() )
1498  return;
1499  mbCheckSuperfluous = false;
1500 
1501  SwPageFrame *pPage = GetLastPage();
1502  tools::Long nDocPos = LONG_MAX;
1503 
1504  // Check the corresponding last page if it is empty and stop loop at the last non-empty page.
1505  do
1506  {
1507  if (!sw::IsPageFrameEmpty(*pPage))
1508  {
1509  if ( pPage->IsFootnotePage() )
1510  {
1511  while ( pPage->IsFootnotePage() )
1512  {
1513  pPage = static_cast<SwPageFrame*>(pPage->GetPrev());
1514  OSL_ENSURE( pPage, "only endnote pages remain." );
1515  }
1516  continue;
1517  }
1518  else
1519  pPage = nullptr;
1520  }
1521 
1522  if ( pPage )
1523  {
1524  SAL_INFO( "sw.pageframe", "RemoveSuperfluous - DestroyFrm p: " << pPage );
1525  RemovePage( &pPage, SwRemoveResult::Prev );
1526  nDocPos = pPage ? pPage->getFrameArea().Top() : 0;
1527  }
1528  } while ( pPage );
1529 
1531  if ( nDocPos != LONG_MAX &&
1532  (!pSh || !pSh->Imp()->IsUpdateExpFields()) )
1533  {
1534  SwDocPosUpdate aMsgHint( nDocPos );
1536  }
1537 }
1538 
1541 {
1542  if ( !IsAssertFlyPages() )
1543  return;
1544  mbAssertFlyPages = false;
1545 
1546  SwDoc *pDoc = GetFormat()->GetDoc();
1547  const SwFrameFormats *pTable = pDoc->GetSpzFrameFormats();
1548 
1549  // what page targets the "last" Fly?
1550  // note the needed pages in a set
1551  sal_uInt16 nMaxPg(0);
1553  neededPages.reserve(pTable->size());
1554 
1555  for ( size_t i = 0; i < pTable->size(); ++i )
1556  {
1557  const SwFormatAnchor &rAnch = (*pTable)[i]->GetAnchor();
1558  if(!rAnch.GetContentAnchor())
1559  {
1560  const sal_uInt16 nPageNum(rAnch.GetPageNum());
1561 
1562  // calc MaxPage (as before)
1563  nMaxPg = std::max(nMaxPg, nPageNum);
1564 
1565  // note as needed page
1566  neededPages.insert(nPageNum);
1567  }
1568  }
1569 
1570  // How many pages exist at the moment?
1571  // And are there EmptyPages that are needed?
1572  SwPageFrame* pPage(static_cast<SwPageFrame*>(Lower()));
1573  SwPageFrame* pPrevPage(nullptr);
1574  SwPageFrame* pFirstRevivedEmptyPage(nullptr);
1575 
1576  while(pPage) // moved two while-conditions to break-statements (see below)
1577  {
1578  const sal_uInt16 nPageNum(pPage->GetPhyPageNum());
1579 
1580  if(pPage->IsEmptyPage() &&
1581  nullptr != pPrevPage &&
1582  neededPages.find(nPageNum) != neededPages.end())
1583  {
1584  // This is an empty page, but it *is* needed since a SwFrame
1585  // is anchored at it directly. Initially these SwFrames are
1586  // not fully initialized. Need to change the format of this SwFrame
1587  // and let the ::Notify mechanism newly evaluate
1588  // m_bEmptyPage (see SwPageFrame::UpdateAttr_). Code is taken and
1589  // adapted from ::InsertPage (used below), this needs previous page
1590  bool bWishedRightPage(!pPrevPage->OnRightPage());
1591  SwPageDesc* pDesc(pPrevPage->GetPageDesc()->GetFollow());
1592  assert(pDesc && "Missing PageDesc");
1593 
1594  if (!(bWishedRightPage ? pDesc->GetRightFormat() : pDesc->GetLeftFormat()))
1595  {
1596  bWishedRightPage = !bWishedRightPage;
1597  }
1598 
1599  bool const bWishedFirst(pDesc != pPrevPage->GetPageDesc());
1600  SwFrameFormat* pFormat(bWishedRightPage ? pDesc->GetRightFormat(bWishedFirst) : pDesc->GetLeftFormat(bWishedFirst));
1601 
1602  // set SwFrameFormat, this will trigger SwPageFrame::UpdateAttr_ and re-evaluate
1603  // m_bEmptyPage, too
1604  pPage->SetFrameFormat(pFormat);
1605 
1606  if(nullptr == pFirstRevivedEmptyPage)
1607  {
1608  // remember first (lowest) SwPageFrame which needed correction
1609  pFirstRevivedEmptyPage = pPage;
1610  }
1611  }
1612 
1613  // original while-condition II
1614  if(nullptr == pPage->GetNext())
1615  {
1616  break;
1617  }
1618 
1619  // original while-condition III
1620  if(static_cast< SwPageFrame* >(pPage->GetNext())->IsFootnotePage())
1621  {
1622  break;
1623  }
1624 
1625  pPrevPage = pPage;
1626  pPage = static_cast<SwPageFrame*>(pPage->GetNext());
1627  }
1628 
1629  if ( nMaxPg > pPage->GetPhyPageNum() )
1630  {
1631  for ( sal_uInt16 i = pPage->GetPhyPageNum(); i < nMaxPg; ++i )
1632  pPage = InsertPage( pPage, false );
1633 
1634  // If the endnote pages are now corrupt, destroy them.
1635  if ( !pDoc->GetFootnoteIdxs().empty() )
1636  {
1637  pPage = static_cast<SwPageFrame*>(Lower());
1638  while ( pPage && !pPage->IsFootnotePage() )
1639  pPage = static_cast<SwPageFrame*>(pPage->GetNext());
1640 
1641  if ( pPage )
1642  {
1643  SwPageDesc *pTmpDesc = pPage->FindPageDesc();
1644  bool isRightPage = pPage->OnRightPage();
1645  if ( pPage->GetFormat() !=
1646  (isRightPage ? pTmpDesc->GetRightFormat() : pTmpDesc->GetLeftFormat()) )
1647  RemoveFootnotes( pPage, false, true );
1648  }
1649  }
1650  }
1651 
1652  // if we corrected SwFrameFormat and changed one (or more) m_bEmptyPage
1653  // flags, we need to correct evtl. currently wrong positioned SwFrame(s)
1654  // which did think until now that these Page(s) are empty.
1655  // After trying to correct myself I found SwRootFrame::AssertPageFlys
1656  // directly below that already does that, so use it.
1657  if(nullptr != pFirstRevivedEmptyPage)
1658  {
1659  AssertPageFlys(pFirstRevivedEmptyPage);
1660  }
1661 
1662 #if OSL_DEBUG_LEVEL > 0
1663  pPage = static_cast<SwPageFrame*>(Lower());
1664  while ( pPage && pPage->GetNext() &&
1665  !static_cast<SwPageFrame*>(pPage->GetNext())->IsFootnotePage() )
1666  {
1667  SAL_INFO( "sw.pageframe", "AssertFlyPages p: " << pPage << " d: " << pPage->GetPageDesc()
1668  << " f: " << pPage->GetFormat() << " virt: " << pPage->GetVirtPageNum()
1669  << " phys: " << pPage->GetPhyPageNum() << " empty: " << pPage->IsEmptyPage() );
1670  pPage = static_cast<SwPageFrame*>(pPage->GetNext());
1671  }
1672  SAL_INFO( "sw.pageframe", "AssertFlyPages p: " << pPage << " d: " << pPage->GetPageDesc()
1673  << " f: " << pPage->GetFormat() << " virt: " << pPage->GetVirtPageNum()
1674  << " phys: " << pPage->GetPhyPageNum() << " empty: " << pPage->IsEmptyPage() );
1675 #endif
1676 }
1677 
1680 {
1681  SAL_INFO( "sw.pageframe", "(AssertPageFlys in" );
1682  while ( pPage )
1683  {
1684  if (pPage->GetSortedObjs())
1685  {
1686  size_t i = 0;
1687  while ( pPage->GetSortedObjs() && i< pPage->GetSortedObjs()->size() )
1688  {
1689  // #i28701#
1690  SwFrameFormat& rFormat = (*pPage->GetSortedObjs())[i]->GetFrameFormat();
1691  const SwFormatAnchor &rAnch = rFormat.GetAnchor();
1692  const sal_uInt16 nPg = rAnch.GetPageNum();
1693  if ((rAnch.GetAnchorId() == RndStdIds::FLY_AT_PAGE) &&
1694  nPg != pPage->GetPhyPageNum() )
1695  {
1696  SAL_INFO( "sw.pageframe", nPg << " " << pPage->GetPhyPageNum() );
1697  // If on the wrong page, check if previous page is empty
1698  if( nPg && !(pPage->GetPhyPageNum()-1 == nPg &&
1699  static_cast<SwPageFrame*>(pPage->GetPrev())->IsEmptyPage()) )
1700  {
1701  // It can move by itself. Just send a modify to its anchor attribute.
1702 #if OSL_DEBUG_LEVEL > 1
1703  const size_t nCnt = pPage->GetSortedObjs()->size();
1704  rFormat.CallSwClientNotify(sw::LegacyModifyHint(nullptr, &rAnch));
1705  OSL_ENSURE( !pPage->GetSortedObjs() ||
1706  nCnt != pPage->GetSortedObjs()->size(),
1707  "Object couldn't be reattached!" );
1708 #else
1709  rFormat.CallSwClientNotify(sw::LegacyModifyHint(nullptr, &rAnch));
1710 #endif
1711  // Do not increment index, in this case
1712  continue;
1713  }
1714  }
1715  ++i;
1716  }
1717  }
1718  pPage = static_cast<SwPageFrame*>(pPage->GetNext());
1719  }
1720  SAL_INFO( "sw.pageframe", "AssertPageFlys out)" );
1721 }
1722 
1723 Size SwRootFrame::ChgSize( const Size& aNewSize )
1724 {
1725  {
1727  aFrm.SSize(aNewSize);
1728  }
1729 
1730  InvalidatePrt_();
1731  mbFixSize = false;
1732  return getFrameArea().SSize();
1733 }
1734 
1735 void SwRootFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/)
1736 {
1737  if ( !isFrameAreaPositionValid() )
1738  {
1741  aFrm.Pos().setX(DOCUMENTBORDER);
1742  aFrm.Pos().setY(DOCUMENTBORDER);
1743  }
1744 
1745  if ( !isFramePrintAreaValid() )
1746  {
1747  setFramePrintAreaValid(true);
1749  aPrt.Pos().setX(0);
1750  aPrt.Pos().setY(0);
1751  aPrt.SSize( getFrameArea().SSize() );
1752  }
1753 
1754  if ( !isFrameAreaSizeValid() )
1755  {
1756  // SSize is set by the pages (Cut/Paste).
1757  setFrameAreaSizeValid(true);
1758  }
1759 }
1760 
1762 {
1763  mbBrowseWidthValid = false;
1764  SwFrame *pPg = Lower();
1765  while ( pPg )
1766  {
1767  pPg->InvalidateSize();
1768  pPg = pPg->GetNext();
1769  }
1770 }
1771 
1773 {
1774  OSL_ENSURE( GetCurrShell() && GetCurrShell()->GetViewOptions()->getBrowseMode(),
1775  "CalcBrowseWidth and not in BrowseView" );
1776 
1777  // The (minimal) with is determined from borders, tables and paint objects.
1778  // It is calculated based on the attributes. Thus, it is not relevant how wide they are
1779  // currently but only how wide they want to be.
1780  // Frames and paint objects inside other objects (frames, tables) do not count.
1781  // Borders and columns are not taken into account.
1782 
1783  SwFrame *pFrame = ContainsContent();
1784  while ( pFrame && !pFrame->IsInDocBody() )
1785  pFrame = static_cast<SwContentFrame*>(pFrame)->GetNextContentFrame();
1786  if ( !pFrame )
1787  return;
1788 
1789  mbBrowseWidthValid = true;
1791  mnBrowseWidth = (!comphelper::LibreOfficeKit::isActive() && pSh)? MINLAY + 2 * pSh->GetOut()-> PixelToLogic( pSh->GetBrowseBorder() ).Width(): MIN_BROWSE_WIDTH;
1792 
1793  do
1794  {
1795  if ( pFrame->IsInTab() )
1796  pFrame = pFrame->FindTabFrame();
1797 
1798  if ( pFrame->IsTabFrame() &&
1799  !static_cast<SwLayoutFrame*>(pFrame)->GetFormat()->GetFrameSize().GetWidthPercent() )
1800  {
1801  SwBorderAttrAccess aAccess( SwFrame::GetCache(), pFrame );
1802  const SwBorderAttrs &rAttrs = *aAccess.Get();
1803  const SwFormatHoriOrient &rHori = rAttrs.GetAttrSet().GetHoriOrient();
1804  tools::Long nWidth = rAttrs.GetSize().Width();
1805  if ( nWidth < int(USHRT_MAX)-2000 && //-2k, because USHRT_MAX gets missing while trying to resize! (and cast to int to avoid -Wsign-compare due to broken USHRT_MAX on Android)
1806  text::HoriOrientation::FULL != rHori.GetHoriOrient() )
1807  {
1808  const SwHTMLTableLayout *pLayoutInfo =
1809  static_cast<const SwTabFrame *>(pFrame)->GetTable()
1810  ->GetHTMLTableLayout();
1811  if ( pLayoutInfo )
1812  nWidth = std::min( nWidth, pLayoutInfo->GetBrowseWidthMin() );
1813 
1814  switch ( rHori.GetHoriOrient() )
1815  {
1817  // OD 23.01.2003 #106895# - add 1st param to <SwBorderAttrs::CalcRight(..)>
1818  nWidth += rAttrs.CalcLeft( pFrame ) + rAttrs.CalcRight( pFrame );
1819  break;
1820  case text::HoriOrientation::LEFT_AND_WIDTH:
1821  nWidth += rAttrs.CalcLeft( pFrame );
1822  break;
1823  default:
1824  break;
1825  }
1826  mnBrowseWidth = std::max( mnBrowseWidth, nWidth );
1827  }
1828  }
1829  else if ( pFrame->GetDrawObjs() )
1830  {
1831  for ( size_t i = 0; i < pFrame->GetDrawObjs()->size(); ++i )
1832  {
1833  // #i28701#
1834  SwAnchoredObject* pAnchoredObj = (*pFrame->GetDrawObjs())[i];
1835  const SwFrameFormat& rFormat = pAnchoredObj->GetFrameFormat();
1836  const bool bFly = dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr;
1837  if ((bFly && (FAR_AWAY == pAnchoredObj->GetObjRect().Width()))
1838  || rFormat.GetFrameSize().GetWidthPercent())
1839  {
1840  continue;
1841  }
1842 
1843  tools::Long nWidth = 0;
1844  switch ( rFormat.GetAnchor().GetAnchorId() )
1845  {
1846  case RndStdIds::FLY_AS_CHAR:
1847  nWidth = bFly ? rFormat.GetFrameSize().GetWidth() :
1848  pAnchoredObj->GetObjRect().Width();
1849  break;
1850  case RndStdIds::FLY_AT_PARA:
1851  {
1852  // #i33170#
1853  // Reactivated old code because
1854  // nWidth = pAnchoredObj->GetObjRect().Right()
1855  // gives wrong results for objects that are still
1856  // at position FAR_AWAY.
1857  if ( bFly )
1858  {
1859  nWidth = rFormat.GetFrameSize().GetWidth();
1860  const SwFormatHoriOrient &rHori = rFormat.GetHoriOrient();
1861  switch ( rHori.GetHoriOrient() )
1862  {
1864  nWidth += rHori.GetPos();
1865  break;
1866  case text::HoriOrientation::INSIDE:
1867  case text::HoriOrientation::LEFT:
1868  if ( text::RelOrientation::PRINT_AREA == rHori.GetRelationOrient() )
1869  nWidth += pFrame->getFramePrintArea().Left();
1870  break;
1871  default:
1872  break;
1873  }
1874  }
1875  else
1876  // Paint objects to not have attributes and
1877  // are defined by their current size
1878  nWidth = pAnchoredObj->GetObjRect().Right() -
1879  pAnchoredObj->GetDrawObj()->GetAnchorPos().X();
1880  }
1881  break;
1882  default: /* do nothing */;
1883  }
1884  mnBrowseWidth = std::max( mnBrowseWidth, nWidth );
1885  }
1886  }
1887  pFrame = pFrame->FindNextCnt();
1888  } while ( pFrame );
1889 }
1890 
1892 {
1893  if ( GetCurrShell() )
1894  for(SwViewShell& rSh : GetCurrShell()->GetRingContainer())
1895  {
1896  if ( auto pCursorShell = dynamic_cast<SwCursorShell*>( &rSh) )
1897  pCursorShell->StartAction();
1898  else
1899  rSh.StartAction();
1900  }
1901 }
1902 
1903 void SwRootFrame::EndAllAction( bool bVirDev )
1904 {
1905  if ( !GetCurrShell() )
1906  return;
1907 
1908  for(SwViewShell& rSh : GetCurrShell()->GetRingContainer())
1909  {
1910  const bool bOldEndActionByVirDev = rSh.IsEndActionByVirDev();
1911  rSh.SetEndActionByVirDev( bVirDev );
1912  if ( auto pCursorShell = dynamic_cast<SwCursorShell*>( &rSh) )
1913  {
1914  pCursorShell->EndAction();
1915  pCursorShell->CallChgLnk();
1916  if ( auto pFEShell = dynamic_cast<SwFEShell*>( &rSh) )
1917  pFEShell->SetChainMarker();
1918  }
1919  else
1920  rSh.EndAction();
1921  rSh.SetEndActionByVirDev( bOldEndActionByVirDev );
1922  }
1923 }
1924 
1926 {
1927  if ( !GetCurrShell() )
1928  return;
1929 
1930  for(SwViewShell& rSh : GetCurrShell()->GetRingContainer())
1931  {
1932  // #i84729#
1933  // No end action, if <SwViewShell> instance is currently in its end action.
1934  // Recursives calls to <::EndAction()> are not allowed.
1935  if ( !rSh.IsInEndAction() )
1936  {
1937  OSL_ENSURE(!rSh.GetRestoreActions(), "Restore action count is already set!");
1938  bool bCursor = dynamic_cast<const SwCursorShell*>( &rSh) != nullptr;
1939  bool bFE = dynamic_cast<const SwFEShell*>( &rSh) != nullptr;
1940  sal_uInt16 nRestore = 0;
1941  while( rSh.ActionCount() )
1942  {
1943  if( bCursor )
1944  {
1945  static_cast<SwCursorShell*>(&rSh)->EndAction();
1946  static_cast<SwCursorShell*>(&rSh)->CallChgLnk();
1947  if ( bFE )
1948  static_cast<SwFEShell*>(&rSh)->SetChainMarker();
1949  }
1950  else
1951  rSh.EndAction();
1952  nRestore++;
1953  }
1954  rSh.SetRestoreActions(nRestore);
1955  }
1956  rSh.LockView(true);
1957  }
1958 }
1959 
1961 {
1962  if ( !GetCurrShell() )
1963  return;
1964 
1965  for(SwViewShell& rSh : GetCurrShell()->GetRingContainer())
1966  {
1967  sal_uInt16 nActions = rSh.GetRestoreActions();
1968  while( nActions-- )
1969  {
1970  if ( auto pCursorShell = dynamic_cast<SwCursorShell*>( &rSh) )
1971  pCursorShell->StartAction();
1972  else
1973  rSh.StartAction();
1974  }
1975  rSh.SetRestoreActions(0);
1976  rSh.LockView(false);
1977  }
1978 }
1979 
1980 // Helper functions for SwRootFrame::CheckViewLayout
1981 static void lcl_MoveAllLowers( SwFrame* pFrame, const Point& rOffset );
1982 
1983 static void lcl_MoveAllLowerObjs( SwFrame* pFrame, const Point& rOffset )
1984 {
1985  const bool bPage = pFrame->IsPageFrame();
1986  const SwSortedObjs* pSortedObj = bPage
1987  ? static_cast<SwPageFrame*>(pFrame)->GetSortedObjs()
1988  : pFrame->GetDrawObjs();
1989  if (pSortedObj == nullptr)
1990  return;
1991 
1992  // note: pSortedObj elements may be removed and inserted from
1993  // MoveObjectIfActive(), invalidating iterators
1994  // DO NOT CONVERT THIS TO A C++11 FOR LOOP, IT DID NOT WORK THE LAST 2 TIMES
1995  for (size_t i = 0; i < pSortedObj->size(); ++i)
1996  {
1997  SwAnchoredObject *const pAnchoredObj = (*pSortedObj)[i];
1998  const SwFrameFormat& rObjFormat = pAnchoredObj->GetFrameFormat();
1999  const SwFormatAnchor& rAnchor = rObjFormat.GetAnchor();
2000 
2001  // all except from the as character anchored objects are moved
2002  // when processing the page frame:
2003  if ( !bPage && (rAnchor.GetAnchorId() != RndStdIds::FLY_AS_CHAR) )
2004  continue;
2005 
2006  SwObjPositioningInProgress aPosInProgress( *pAnchoredObj );
2007 
2008  if ( auto pFlyFrame = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
2009  {
2010  lcl_MoveAllLowers( pFlyFrame, rOffset );
2011  // tdf#138785 update position specific to as-char flys
2012  if (pFlyFrame->IsFlyInContentFrame())
2013  {
2014  static_cast<SwFlyInContentFrame*>(pFlyFrame)->AddRefOfst(rOffset);
2015  }
2016  pFlyFrame->NotifyDrawObj();
2017  // --> let the active embedded object be moved
2018  SwFrame* pLower = pFlyFrame->Lower();
2019  if ( pLower && pLower->IsNoTextFrame() )
2020  {
2021  SwRootFrame* pRoot = pLower->getRootFrame();
2022  SwViewShell *pSh = pRoot ? pRoot->GetCurrShell() : nullptr;
2023  if ( pSh )
2024  {
2025  SwNoTextFrame *const pContentFrame = static_cast<SwNoTextFrame*>(pLower);
2026  SwOLENode* pNode = pContentFrame->GetNode()->GetOLENode();
2027  if ( pNode )
2028  {
2029  svt::EmbeddedObjectRef& xObj = pNode->GetOLEObj().GetObject();
2030  if ( xObj.is() )
2031  {
2032  for(SwViewShell& rSh : pSh->GetRingContainer())
2033  {
2034  SwFEShell* pFEShell = dynamic_cast< SwFEShell* >( &rSh );
2035  if ( pFEShell )
2036  pFEShell->MoveObjectIfActive( xObj, rOffset );
2037  }
2038  }
2039  }
2040  }
2041  }
2042  }
2043  else if ( auto pAnchoredDrawObj = dynamic_cast<SwAnchoredDrawObject *>( pAnchoredObj ) )
2044  {
2045  // don't touch objects that are not yet positioned:
2046  if ( pAnchoredDrawObj->NotYetPositioned() )
2047  continue;
2048 
2049  const Point& aCurrAnchorPos = pAnchoredDrawObj->GetDrawObj()->GetAnchorPos();
2050  const Point aNewAnchorPos( aCurrAnchorPos + rOffset );
2051  pAnchoredDrawObj->DrawObj()->SetAnchorPos( aNewAnchorPos );
2052  pAnchoredDrawObj->SetLastObjRect( pAnchoredDrawObj->GetObjRect().SVRect() );
2053 
2054  // clear contour cache
2055  if ( pAnchoredDrawObj->GetFrameFormat().GetSurround().IsContour() )
2056  ClrContourCache( pAnchoredDrawObj->GetDrawObj() );
2057  }
2058  // #i92511#
2059  // cache for object rectangle inclusive spaces has to be invalidated.
2060  pAnchoredObj->InvalidateObjRectWithSpaces();
2061  }
2062 }
2063 
2064 static void lcl_MoveAllLowers( SwFrame* pFrame, const Point& rOffset )
2065 {
2066  const SwRect aFrame( pFrame->getFrameArea() );
2067 
2068  // first move the current frame
2069  // RotateFlyFrame3: moved to transform_translate instead of
2070  // direct modification to allow the SwFrame evtl. needed own reactions
2071  pFrame->transform_translate(rOffset);
2072 
2073  // Don't forget accessibility:
2074  if( pFrame->IsAccessibleFrame() )
2075  {
2076  SwRootFrame *pRootFrame = pFrame->getRootFrame();
2077  if( pRootFrame && pRootFrame->IsAnyShellAccessible() &&
2078  pRootFrame->GetCurrShell() )
2079  {
2080  pRootFrame->GetCurrShell()->Imp()->MoveAccessibleFrame( pFrame, aFrame );
2081  }
2082  }
2083 
2084  // the move any objects
2085  lcl_MoveAllLowerObjs( pFrame, rOffset );
2086 
2087  // finally, for layout frames we have to call this function recursively:
2088  if ( dynamic_cast< const SwLayoutFrame *>( pFrame ) != nullptr )
2089  {
2090  SwFrame* pLowerFrame = pFrame->GetLower();
2091  while ( pLowerFrame )
2092  {
2093  lcl_MoveAllLowers( pLowerFrame, rOffset );
2094  pLowerFrame = pLowerFrame->GetNext();
2095  }
2096  }
2097 }
2098 
2099 // Calculate how the pages have to be positioned
2100 void SwRootFrame::CheckViewLayout( const SwViewOption* pViewOpt, const SwRect* pVisArea )
2101 {
2102  SwViewShell* pSh = GetCurrShell();
2103  vcl::RenderContext* pRenderContext = pSh ? pSh->GetOut() : nullptr;
2104  // #i91432#
2105  // No calculation of page positions, if only an empty page is present.
2106  // This situation occurs when <SwRootFrame> instance is in construction
2107  // and the document contains only left pages.
2108  if ( Lower()->GetNext() == nullptr &&
2109  static_cast<SwPageFrame*>(Lower())->IsEmptyPage() )
2110  {
2111  return;
2112  }
2113 
2114  if ( !pVisArea )
2115  {
2116  // no early return for bNewPage
2117  if ( mnViewWidth < 0 )
2118  mnViewWidth = 0;
2119  }
2120  else
2121  {
2122  assert(pViewOpt && "CheckViewLayout required ViewOptions");
2123 
2124  const sal_uInt16 nColumns = pViewOpt->GetViewLayoutColumns();
2125  const bool bBookMode = pViewOpt->IsViewLayoutBookMode();
2126 
2127  if ( nColumns == mnColumns && bBookMode == mbBookMode && pVisArea->Width() == mnViewWidth && !mbSidebarChanged )
2128  return;
2129 
2130  mnColumns = nColumns;
2131  mbBookMode = bBookMode;
2132  mnViewWidth = pVisArea->Width();
2133  mbSidebarChanged = false;
2134  }
2135 
2136  if( GetFormat()->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE ) )
2137  {
2138  mnColumns = 1;
2139  mbBookMode = false;
2140  }
2141 
2142  Calc(pRenderContext);
2143 
2144  const bool bOldCallbackActionEnabled = IsCallbackActionEnabled();
2145  SetCallbackActionEnabled( false );
2146 
2147  maPageRects.clear();
2148 
2149  const tools::Long nBorder = getFrameArea().Pos().getX();
2150  const tools::Long nVisWidth = mnViewWidth - 2 * nBorder;
2151  const tools::Long nGapBetweenPages = pViewOpt ? pViewOpt->GetGapBetweenPages()
2152  : (pSh ? pSh->GetViewOptions()->GetGapBetweenPages()
2154 
2155  // check how many pages fit into the first page layout row:
2156  SwPageFrame* pPageFrame = static_cast<SwPageFrame*>(Lower());
2157 
2158  // will contain the number of pages per row. 0 means that
2159  // the page does not fit.
2160  tools::Long nWidthRemain = nVisWidth;
2161 
2162  // after one row has been processed, these variables contain
2163  // the width of the row and the maximum of the page heights
2164  tools::Long nCurrentRowHeight = 0;
2165  tools::Long nCurrentRowWidth = 0;
2166 
2167  // these variables are used to finally set the size of the
2168  // root frame
2169  tools::Long nSumRowHeight = 0;
2170  SwTwips nMinPageLeft = TWIPS_MAX;
2171  SwTwips nMaxPageRight = 0;
2172  SwPageFrame* pStartOfRow = pPageFrame;
2173  sal_uInt16 nNumberOfPagesInRow = mbBookMode ? 1 : 0; // in book view, start with right page
2174  bool bFirstRow = true;
2175 
2176  bool bPageChanged = false;
2177  const bool bRTL = !IsLeftToRightViewLayout();
2178  const SwTwips nSidebarWidth = SwPageFrame::GetSidebarBorderWidth( pSh );
2179 
2180  while ( pPageFrame )
2181  {
2182  // we consider the current page to be "start of row" if
2183  // 1. it is the first page in the current row or
2184  // 2. it is the second page in the row and the first page is an empty page in non-book view:
2185  const bool bStartOfRow = pPageFrame == pStartOfRow ||
2186  ( pStartOfRow->IsEmptyPage() && pPageFrame == pStartOfRow->GetNext() && !mbBookMode );
2187 
2188  const bool bEmptyPage = pPageFrame->IsEmptyPage() && !mbBookMode;
2189 
2190  // no half doc border space for first page in each row and
2191  tools::Long nPageWidth = 0;
2192  tools::Long nPageHeight = 0;
2193 
2194  if ( mbBookMode )
2195  {
2196  const SwFrame& rFormatPage = pPageFrame->GetFormatPage();
2197 
2198  nPageWidth = rFormatPage.getFrameArea().Width() + nSidebarWidth + ((bStartOfRow || 1 == (pPageFrame->GetPhyPageNum()%2)) ? 0 : nGapBetweenPages);
2199  nPageHeight = rFormatPage.getFrameArea().Height() + nGapBetweenPages;
2200  }
2201  else
2202  {
2203  if ( !pPageFrame->IsEmptyPage() )
2204  {
2205  nPageWidth = pPageFrame->getFrameArea().Width() + nSidebarWidth + (bStartOfRow ? 0 : nGapBetweenPages);
2206  nPageHeight = pPageFrame->getFrameArea().Height() + nGapBetweenPages;
2207  }
2208  }
2209 
2210  if ( !bEmptyPage )
2211  ++nNumberOfPagesInRow;
2212 
2213  // finish current row if
2214  // 1. in dynamic mode the current page does not fit anymore or
2215  // 2. the current page exceeds the maximum number of columns
2216  bool bRowFinished = (0 == mnColumns && nWidthRemain < nPageWidth ) ||
2217  (0 != mnColumns && mnColumns < nNumberOfPagesInRow);
2218 
2219  // make sure that at least one page goes to the current row:
2220  if ( !bRowFinished || bStartOfRow )
2221  {
2222  // current page is allowed to be in current row
2223  nWidthRemain = nWidthRemain - nPageWidth;
2224 
2225  nCurrentRowWidth = nCurrentRowWidth + nPageWidth;
2226  nCurrentRowHeight = std::max( nCurrentRowHeight, nPageHeight );
2227 
2228  pPageFrame = static_cast<SwPageFrame*>(pPageFrame->GetNext());
2229 
2230  if ( !pPageFrame )
2231  bRowFinished = true;
2232  }
2233 
2234  if ( bRowFinished )
2235  {
2236  // pPageFrame now points to the first page in the new row or null
2237  // pStartOfRow points to the first page in the current row
2238 
2239  // special centering for last row. pretend to fill the last row with virtual copies of the last page before centering:
2240  if ( !pPageFrame && nWidthRemain > 0 )
2241  {
2242  // find last page in current row:
2243  const SwPageFrame* pLastPageInCurrentRow = pStartOfRow;
2244  while( pLastPageInCurrentRow->GetNext() )
2245  pLastPageInCurrentRow = static_cast<const SwPageFrame*>(pLastPageInCurrentRow->GetNext());
2246 
2247  if ( pLastPageInCurrentRow->IsEmptyPage() )
2248  pLastPageInCurrentRow = static_cast<const SwPageFrame*>(pLastPageInCurrentRow->GetPrev());
2249 
2250  // check how many times the last page would still fit into the remaining space:
2251  sal_uInt16 nNumberOfVirtualPages = 0;
2252  const sal_uInt16 nMaxNumberOfVirtualPages = mnColumns > 0 ? mnColumns - nNumberOfPagesInRow : USHRT_MAX;
2253  SwTwips nRemain = nWidthRemain;
2254  SwTwips nVirtualPagesWidth = 0;
2255  SwTwips nLastPageWidth = pLastPageInCurrentRow->getFrameArea().Width() + nSidebarWidth;
2256 
2257  while ( ( mnColumns > 0 || nRemain > 0 ) && nNumberOfVirtualPages < nMaxNumberOfVirtualPages )
2258  {
2259  SwTwips nLastPageWidthWithGap = nLastPageWidth;
2260  if ( !mbBookMode || ( 0 == (nNumberOfVirtualPages + nNumberOfPagesInRow) %2) )
2261  nLastPageWidthWithGap += nGapBetweenPages;
2262 
2263  if ( mnColumns > 0 || nLastPageWidthWithGap < nRemain )
2264  {
2265  ++nNumberOfVirtualPages;
2266  nVirtualPagesWidth += nLastPageWidthWithGap;
2267  }
2268  nRemain = nRemain - nLastPageWidthWithGap;
2269  }
2270 
2271  nCurrentRowWidth = nCurrentRowWidth + nVirtualPagesWidth;
2272  }
2273 
2274  // first page in book mode is always special:
2275  if ( bFirstRow && mbBookMode )
2276  {
2277  // #i88036#
2278  nCurrentRowWidth +=
2279  pStartOfRow->GetFormatPage().getFrameArea().Width() + nSidebarWidth;
2280  }
2281 
2282  // center page if possible
2283  tools::Long nSizeDiff = 0;
2284  if (nVisWidth > nCurrentRowWidth && !comphelper::LibreOfficeKit::isActive())
2285  nSizeDiff = ( nVisWidth - nCurrentRowWidth ) / 2;
2286 
2287  // adjust positions of pages in current row
2288  tools::Long nX = nSizeDiff;
2289 
2290  const tools::Long nRowStart = nBorder + nSizeDiff;
2291  const tools::Long nRowEnd = nRowStart + nCurrentRowWidth;
2292 
2293  if ( bFirstRow && mbBookMode )
2294  {
2295  // #i88036#
2296  nX += pStartOfRow->GetFormatPage().getFrameArea().Width() + nSidebarWidth;
2297  }
2298 
2299  SwPageFrame* pEndOfRow = pPageFrame;
2300  SwPageFrame* pPageToAdjust = pStartOfRow;
2301 
2302  do
2303  {
2304  const SwPageFrame* pFormatPage = pPageToAdjust;
2305  if ( mbBookMode )
2306  pFormatPage = &pPageToAdjust->GetFormatPage();
2307 
2308  const SwTwips nCurrentPageWidth = pFormatPage->getFrameArea().Width() + (pFormatPage->IsEmptyPage() ? 0 : nSidebarWidth);
2309  const Point aOldPagePos = pPageToAdjust->getFrameArea().Pos();
2310  const bool bLeftSidebar = pPageToAdjust->SidebarPosition() == sw::sidebarwindows::SidebarPosition::LEFT;
2311  const SwTwips nLeftPageAddOffset = bLeftSidebar ?
2312  nSidebarWidth :
2313  0;
2314 
2315  Point aNewPagePos( nBorder + nX, nBorder + nSumRowHeight );
2316  Point aNewPagePosWithLeftOffset( nBorder + nX + nLeftPageAddOffset, nBorder + nSumRowHeight );
2317 
2318  // RTL view layout: Calculate mirrored page position
2319  if ( bRTL )
2320  {
2321  const tools::Long nXOffsetInRow = aNewPagePos.getX() - nRowStart;
2322  aNewPagePos.setX(nRowEnd - nXOffsetInRow - nCurrentPageWidth);
2323  aNewPagePosWithLeftOffset = aNewPagePos;
2324  aNewPagePosWithLeftOffset.setX(aNewPagePosWithLeftOffset.getX() + nLeftPageAddOffset);
2325  }
2326 
2327  if ( aNewPagePosWithLeftOffset != aOldPagePos )
2328  {
2329  lcl_MoveAllLowers( pPageToAdjust, aNewPagePosWithLeftOffset - aOldPagePos );
2330  pPageToAdjust->SetCompletePaint();
2331  bPageChanged = true;
2332  }
2333 
2334  // calculate area covered by the current page and store to
2335  // maPageRects. This is used e.g., for cursor setting
2336  const bool bFirstColumn = pPageToAdjust == pStartOfRow;
2337  const bool bLastColumn = pPageToAdjust->GetNext() == pEndOfRow;
2338  const bool bLastRow = !pEndOfRow;
2339 
2340  nMinPageLeft = std::min( nMinPageLeft, SwTwips(aNewPagePos.getX()) );
2341  nMaxPageRight = std::max( nMaxPageRight, SwTwips(aNewPagePos.getX() + nCurrentPageWidth));
2342 
2343  // border of nGapBetweenPages around the current page:
2344  SwRect aPageRectWithBorders( aNewPagePos.getX() - nGapBetweenPages,
2345  aNewPagePos.getY(),
2346  pPageToAdjust->getFrameArea().SSize().Width() + nGapBetweenPages + nSidebarWidth,
2347  nCurrentRowHeight );
2348 
2349  static const tools::Long nOuterClickDiff = 1000000;
2350 
2351  // adjust borders for these special cases:
2352  if ( (bFirstColumn && !bRTL) || (bLastColumn && bRTL) )
2353  aPageRectWithBorders.SubLeft( nOuterClickDiff );
2354  if ( (bLastColumn && !bRTL) || (bFirstColumn && bRTL) )
2355  aPageRectWithBorders.AddRight( nOuterClickDiff );
2356  if ( bFirstRow )
2357  aPageRectWithBorders.SubTop( nOuterClickDiff );
2358  if ( bLastRow )
2359  aPageRectWithBorders.AddBottom( nOuterClickDiff );
2360 
2361  maPageRects.push_back( aPageRectWithBorders );
2362 
2363  nX = nX + nCurrentPageWidth;
2364  pPageToAdjust = static_cast<SwPageFrame*>(pPageToAdjust->GetNext());
2365 
2366  // distance to next page
2367  if ( pPageToAdjust && pPageToAdjust != pEndOfRow )
2368  {
2369  // in book view, we add the x gap before left (even) pages:
2370  if ( mbBookMode )
2371  {
2372  if ( 0 == (pPageToAdjust->GetPhyPageNum()%2) )
2373  nX = nX + nGapBetweenPages;
2374  }
2375  else
2376  {
2377  // in non-book view, don't add x gap before
2378  // 1. the last empty page in a row
2379  // 2. after an empty page
2380  const bool bDontAddGap = ( pPageToAdjust->IsEmptyPage() && pPageToAdjust->GetNext() == pEndOfRow ) ||
2381  ( static_cast<SwPageFrame*>(pPageToAdjust->GetPrev())->IsEmptyPage() );
2382 
2383  if ( !bDontAddGap )
2384  nX = nX + nGapBetweenPages;
2385  }
2386  }
2387  }
2388  while (pPageToAdjust && pPageToAdjust != pEndOfRow);
2389 
2390  // adjust values for root frame size
2391  nSumRowHeight = nSumRowHeight + nCurrentRowHeight;
2392 
2393  // start new row:
2394  nCurrentRowHeight = 0;
2395  nCurrentRowWidth = 0;
2396  pStartOfRow = pEndOfRow;
2397  nWidthRemain = nVisWidth;
2398  nNumberOfPagesInRow = 0;
2399  bFirstRow = false;
2400  } // end row finished
2401  } // end while
2402 
2403  // set size of root frame:
2404  const Size aOldSize( getFrameArea().SSize() );
2405  const Size aNewSize( nMaxPageRight - nBorder, nSumRowHeight - nGapBetweenPages );
2406 
2407  if ( bPageChanged || aNewSize != aOldSize )
2408  {
2409  ChgSize( aNewSize );
2410  ::AdjustSizeChgNotify( this );
2411  Calc(pRenderContext);
2412 
2413  if ( pSh && pSh->GetDoc()->GetDocShell() )
2414  {
2415  pSh->SetFirstVisPageInvalid();
2416  if (bOldCallbackActionEnabled)
2417  {
2419  pSh->GetDoc()->GetDocShell()->Broadcast(SfxHint(SfxHintId::DocChanged));
2420  }
2421  }
2422  }
2423 
2425  maPagesArea.SSize( aNewSize );
2426  if ( TWIPS_MAX != nMinPageLeft )
2427  maPagesArea.Left_( nMinPageLeft );
2428 
2429  SetCallbackActionEnabled( bOldCallbackActionEnabled );
2430 }
2431 
2433 {
2434  // Layout direction determined by layout direction of the first page.
2435  // #i88036#
2436  // Only ask a non-empty page frame for its layout direction
2437  assert(dynamic_cast<const SwPageFrame *>(Lower()) != nullptr);
2438  const SwPageFrame& rPage = static_cast<const SwPageFrame&>(*Lower()).GetFormatPage();
2439  return !rPage.IsRightToLeft() && !rPage.IsVertical();
2440 }
2441 
2443 {
2444  const SwPageFrame* pRet = this;
2445  if ( IsEmptyPage() )
2446  {
2447  pRet = static_cast<const SwPageFrame*>( OnRightPage() ? GetNext() : GetPrev() );
2448  // #i88035#
2449  // Typically a right empty page frame has a next non-empty page frame and
2450  // a left empty page frame has a previous non-empty page frame.
2451  // But under certain circumstances this assumption is not true -
2452  // e.g. during insertion of a left page at the end of the document right
2453  // after a left page in an intermediate state a right empty page does not
2454  // have a next page frame.
2455  if ( pRet == nullptr )
2456  {
2457  if ( OnRightPage() )
2458  {
2459  pRet = static_cast<const SwPageFrame*>( GetPrev() );
2460  }
2461  else
2462  {
2463  pRet = static_cast<const SwPageFrame*>( GetNext() );
2464  }
2465  }
2466  assert(pRet &&
2467  "<SwPageFrame::GetFormatPage()> - inconsistent layout: empty page without previous and next page frame --> crash.");
2468  }
2469  return *pRet;
2470 }
2471 
2472 bool SwPageFrame::IsOverHeaderFooterArea( const Point& rPt, FrameControlType &rControl ) const
2473 {
2474  tools::Long nUpperLimit = 0;
2475  tools::Long nLowerLimit = 0;
2476  const SwFrame* pFrame = Lower();
2477  while ( pFrame )
2478  {
2479  if ( pFrame->IsBodyFrame() )
2480  {
2481  nUpperLimit = pFrame->getFrameArea().Top();
2482  nLowerLimit = pFrame->getFrameArea().Bottom();
2483  }
2484  else if ( pFrame->IsFootnoteContFrame() )
2485  nLowerLimit = pFrame->getFrameArea().Bottom();
2486 
2487  pFrame = pFrame->GetNext();
2488  }
2489 
2490  SwRect aHeaderArea( getFrameArea().TopLeft(),
2491  Size( getFrameArea().Width(), nUpperLimit - getFrameArea().Top() ) );
2492 
2493  SwViewShell* pViewShell = getRootFrame()->GetCurrShell();
2494  const bool bHideWhitespaceMode = pViewShell->GetViewOptions()->IsHideWhitespaceMode();
2495  if ( aHeaderArea.IsInside( rPt ) )
2496  {
2497  if (!bHideWhitespaceMode || static_cast<const SwFrameFormat*>(GetDep())->GetHeader().IsActive())
2498  {
2499  rControl = FrameControlType::Header;
2500  return true;
2501  }
2502  }
2503  else
2504  {
2505  SwRect aFooterArea( Point( getFrameArea().Left(), nLowerLimit ),
2506  Size( getFrameArea().Width(), getFrameArea().Bottom() - nLowerLimit ) );
2507 
2508  if ( aFooterArea.IsInside( rPt ) &&
2509  (!bHideWhitespaceMode || static_cast<const SwFrameFormat*>(GetDep())->GetFooter().IsActive()) )
2510  {
2511  rControl = FrameControlType::Footer;
2512  return true;
2513  }
2514  }
2515 
2516  return false;
2517 }
2518 
2520 {
2521  SwViewShell* pShell = getRootFrame()->GetCurrShell();
2522  if (pShell && pShell->GetViewOptions()->IsWhitespaceHidden())
2523  {
2524  // When whitespace is hidden, the page frame has two heights: the
2525  // nominal (defined by the frame format), and the actual (which is
2526  // at most the nominal height, but can be smaller in case there is
2527  // no content for the whole page).
2528  // The layout size is the actual one, but we want to move the
2529  // content frame to a new page only in case it doesn't fit the
2530  // nominal size.
2531  if (nDiff < 0)
2532  {
2533  // Content frame doesn't fit the actual size, check if it fits the nominal one.
2534  const SwFrameFormat* pPageFormat = static_cast<const SwFrameFormat*>(GetDep());
2535  const Size& rPageSize = pPageFormat->GetFrameSize().GetSize();
2536  tools::Long nWhitespace = rPageSize.getHeight() - getFrameArea().Height();
2537  if (nWhitespace > -nDiff)
2538  {
2539  // It does: don't move it and invalidate our page frame so
2540  // that it gets a larger height.
2541  return false;
2542  }
2543  }
2544  }
2545 
2546  return true;
2547 }
2548 
2550 {
2551  const SwFrame* pLowerFrame = Lower();
2552  while (pLowerFrame)
2553  {
2554  if (pLowerFrame->IsHeaderFrame())
2555  return dynamic_cast<const SwHeaderFrame*>(pLowerFrame);
2556  pLowerFrame = pLowerFrame->GetNext();
2557  }
2558  return nullptr;
2559 }
2560 
2562 {
2563  const SwFrame* pLowerFrame = Lower();
2564  while (pLowerFrame)
2565  {
2566  if (pLowerFrame->IsFooterFrame())
2567  return dynamic_cast<const SwFooterFrame*>(pLowerFrame);
2568  pLowerFrame = pLowerFrame->GetNext();
2569  }
2570  return nullptr;
2571 }
2572 
2573 SwTextGridItem const* GetGridItem(SwPageFrame const*const pPage)
2574 {
2575  if (pPage && pPage->HasGrid())
2576  {
2577  SwTextGridItem const& rGridItem(
2578  pPage->GetPageDesc()->GetMaster().GetTextGrid());
2579  if (GRID_NONE != rGridItem.GetGridType())
2580  {
2581  return &rGridItem;
2582  }
2583  }
2584  return nullptr;
2585 }
2586 
2587 sal_uInt16 GetGridWidth(SwTextGridItem const& rG, SwDoc const& rDoc)
2588 {
2589  return (rDoc.IsSquaredPageMode()) ? rG.GetBaseHeight() : rG.GetBaseWidth();
2590 }
2591 
2592 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void InsertBefore(SwLayoutFrame *pParent, SwFrame *pBehind)
Insert SwFrame into existing structure.
Definition: wsfrm.cxx:832
static SwTwips GetSidebarBorderWidth(const SwViewShell *)
Definition: paintfrm.cxx:6184
bool IsAnLower(const SwFrame *) const
Definition: findfrm.cxx:207
vcl::RenderContext * GetOut() const
Definition: viewsh.hxx:338
void SetPageDesc(SwPageDesc *, SwFrameFormat *)
Definition: pagechg.cxx:730
SwFrame * FindFooterOrHeader()
Definition: findfrm.cxx:548
Base class of the Writer layout elements.
Definition: frame.hxx:313
Base class that provides the general functionalities for frames that are allowed at page breaks (flow...
Definition: flowfrm.hxx:58
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:157
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(120)
tools::Long GetWidth() const
const ::std::optional< sal_uInt16 > & GetNumOffset() const
Definition: fmtpdsc.hxx:64
virtual SwRect GetObjRect() const =0
void NotifyDrawObj()
Definition: fly.cxx:2475
bool IsOverHeaderFooterArea(const Point &rPt, FrameControlType &rControl) const
If in header or footer area, it also indicates the exact area in rControl.
Definition: pagechg.cxx:2472
void Right(const tools::Long nRight)
Definition: swrect.hxx:200
void SetFootnotePage(bool b)
Definition: pagefrm.hxx:201
bool IsFollow() const
Definition: flowfrm.hxx:166
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:563
void SetCallbackActionEnabled(bool b)
Definition: rootfrm.hxx:385
const SwFormatCol & GetCol(bool=true) const
Definition: fmtclds.hxx:168
bool m_bHasGrid
Definition: pagefrm.hxx:80
SwPageDesc * FindPageDesc()
Definition: pagechg.cxx:746
SwContentFrame * GetNextContentFrame() const
Definition: cntfrm.hxx:98
bool IsInDocBody() const
Definition: frame.hxx:939
Header in the document layout, inside a page.
Definition: hffrm.hxx:43
bool IsRootFrame() const
Definition: frame.hxx:1170
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:35
void SetPosY(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1397
tools::Long mnBrowseWidth
For BrowseMode mnBrowseWidth is the outer margin of the object most to the right. ...
Definition: rootfrm.hxx:130
const SwTextGridItem & GetTextGrid(bool=true) const
Definition: tgrditem.hxx:112
void RemoveFootnotes(SwPageFrame *pPage=nullptr, bool bPageOnly=false, bool bEndNotes=false)
Remove all footnotes (but no references)
Definition: ftnfrm.cxx:960
SwOLENode * GetOLENode()
Inline methods from Node.hxx.
Definition: ndole.hxx:161
bool IsAnyShellAccessible() const
Definition: rootfrm.hxx:388
SwPageDesc * GetPageDesc()
Definition: fmtpdsc.hxx:61
const SwOLEObj & GetOLEObj() const
Definition: ndole.hxx:112
SwViewShellImp * Imp()
Definition: viewsh.hxx:182
bool mbInvalidVert
Definition: frame.hxx:419
void DisconnectFromLayout(bool _bMoveMasterToInvisibleLayer=true)
Definition: dcontact.cxx:1643
virtual void Format(vcl::RenderContext *pRenderContext, const SwBorderAttrs *pAttrs=nullptr) override
"Formats" the Frame; Frame and PrtArea.
Definition: pagechg.cxx:74
void Left_(const tools::Long nLeft)
Definition: swrect.cxx:148
static void CheckPageDescs(SwPageFrame *pStart, bool bNotifyFields=true, SwPageFrame **ppPrev=nullptr)
Check all pages (starting from the given one) if they use the appropriate frame format.
Definition: pagechg.cxx:1055
const SwFormatHeader & GetHeader(bool=true) const
Definition: fmthdft.hxx:97
sal_uInt16 GetBaseWidth() const
Definition: tgrditem.hxx:97
SwDocShell * GetDocShell()
Definition: doc.hxx:1353
constexpr TypedWhichId< SwFormatHeader > RES_HEADER(96)
constexpr TypedWhichId< SwFormatChg > RES_FMT_CHG(162)
constexpr TypedWhichId< SwFormatCol > RES_COL(109)
void SubLeft(const tools::Long nSub)
Definition: swrect.cxx:163
bool mbBrowseWidthValid
Definition: rootfrm.hxx:114
virtual void UpdatePageFields(SfxPoolItem *)=0
void Left(const tools::Long nLeft)
Definition: swrect.hxx:195
virtual void MoveObjectIfActive(svt::EmbeddedObjectRef &xObj, const Point &rOffset)
The layout has been changed, so the active object has to be moved after that.
Definition: fews.cxx:1315
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
void SetCompletePaint() const
Definition: frame.hxx:990
virtual bool Prepare(const PrepareHint ePrep=PrepareHint::Clear, const void *pVoid=nullptr, bool bNotify=true)
Definition: wsfrm.cxx:599
sal_uInt16 char char * pDesc
virtual void DestroyImpl() override
Definition: pagechg.cxx:256
SwFrameType GetType() const
Definition: frame.hxx:518
sal_uInt16 GetPageNum() const
Definition: fmtanchr.hxx:66
bool m_bInvalidFlyLayout
Definition: pagefrm.hxx:71
void SetDerivedR2L(bool bNew)
Definition: frame.hxx:630
SwTwips GetPos() const
Definition: fmtornt.hxx:92
long Long
const SwRect & getFramePrintArea() const
Definition: frame.hxx:179
bool mbSidebarChanged
Definition: rootfrm.hxx:101
#define MINLAY
Definition: swtypes.hxx:66
static SwCache & GetCache()
Definition: frame.hxx:520
SwTabFrame is one table in the document layout, containing rows (which contain cells).
Definition: tabfrm.hxx:30
tools::Long CalcRight(const SwFrame *pCaller) const
Definition: frmtool.cxx:2243
void InvalidateSize_()
Definition: frame.hxx:769
Definition: doc.hxx:187
void SetColMaxFootnoteHeight()
Adapt the max. footnote height in each single column.
Definition: ftnfrm.cxx:2634
void SetMaxFootnoteHeight(const SwTwips nNewMax)
Definition: ftnboss.hxx:77
bool IsLeftToRightViewLayout() const
Definition: pagechg.cxx:2432
void InvalidatePos()
Definition: frame.hxx:1039
const SwPageFrame & GetFormatPage() const
Definition: pagechg.cxx:2442
bool mbAssertFlyPages
Definition: rootfrm.hxx:116
const_iterator find(const Value &x) const
sw::sidebarwindows::SidebarPosition SidebarPosition() const
asks the page on which side a margin should be shown, e.g for notes returns true for left side...
Definition: pagechg.cxx:1435
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: wsfrm.cxx:1330
#define TWIPS_MAX
Definition: swtypes.hxx:53
SwTextGridItem const * GetGridItem(SwPageFrame const *const pPage)
Definition: pagechg.cxx:2573
SwEditWin & GetEditWin()
Definition: view.hxx:416
SvxFrameDirection
static void DestroyFrame(SwFrame *const pFrame)
this is the only way to delete a SwFrame instance
Definition: ssfrm.cxx:384
void Pos(const Point &rNew)
Definition: swrect.hxx:169
Dialog to specify the properties of date form field.
SwTwips GetMaxFootnoteHeight() const
Definition: ftnboss.hxx:96
Helper class for notify that positioning of an anchored object is in progress.
virtual void Calc(vcl::RenderContext *pRenderContext) const
Definition: trvlfrm.cxx:1788
bool IsFootnotePage() const
Foot note interface.
Definition: pagefrm.hxx:199
virtual Size ChgSize(const Size &aNewSize) override
Definition: pagechg.cxx:1723
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
void AssertFlyPages()
Ensures that enough pages exist, so that all page bound frames and draw objects can be placed...
Definition: pagechg.cxx:1540
SwContentFrame * FindFirstBodyContent()
Definition: pagefrm.hxx:350
virtual const SwFormatPageDesc & GetPageDescItem() const
Definition: findfrm.cxx:660
tools::Long GetWidth(const SwRect &rRect) const
Definition: frame.hxx:1377
void PrepareRegisterChg()
Definition: pagechg.cxx:963
static SwFlowFrame * CastFlowFrame(SwFrame *pFrame)
Definition: flowfrm.cxx:2703
bool mbVertLR
Definition: frame.hxx:423
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
SwContact * GetUserCall(const SdrObject *pObj)
Returns the UserCall if applicable from the group object.
Definition: dcontact.cxx:171
bool m_bInvalidLayout
Definition: pagefrm.hxx:69
virtual SwTwips ShrinkFrame(SwTwips, bool bTst=false, bool bInfo=false) override
Definition: pagechg.cxx:1465
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:743
void RemoveControls(const SwFrame *pFrame)
static bool bFootnote
Definition: insfnote.cxx:33
bool m_bInvalidWordCount
Definition: pagefrm.hxx:79
void CheckDirChange()
checks the layout direction and invalidates the lower frames recursively, if necessary.
Definition: ssfrm.cxx:192
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:155
bool IsActive() const
Definition: fmthdft.hxx:89
void CheckViewLayout(const SwViewOption *pViewOpt, const SwRect *pVisArea)
Definition: pagechg.cxx:2100
sal_uInt16 GetPhyPageNum() const
Definition: pagefrm.hxx:204
void CheckGrid(bool bInvalidate)
Definition: pagechg.cxx:305
Used by the UI to modify the document model.
Definition: wrtsh.hxx:91
constexpr tools::Long Width() const
bool AddPaintRect(const SwRect &rRect)
Definition: viewsh.cxx:528
std::vector< SwRect > maPageRects
Definition: rootfrm.hxx:94
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:357
const SwPageFootnoteInfo & GetFootnoteInfo() const
Definition: pagedesc.hxx:206
bool WannaRightPage() const
Decides if the page want to be a right page or not.
Definition: trvlfrm.cxx:1714
bool HasGrid() const
Definition: pagefrm.hxx:186
wrapper class for the positioning of Writer fly frames and drawing objects
void SetFirstVisPageInvalid()
Definition: viewimp.hxx:146
virtual bool IsVisibleLayerId(SdrLayerID _nLayerId) const =0
method to determine, if a layer ID belongs to the visible ones.
const SwView & GetView() const
Definition: wrtsh.hxx:429
void AppendFly(SwFlyFrame *pNew)
Definition: fly.cxx:2177
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
SwFrameControlsManager & GetFrameControlsManager()
Definition: edtwin.cxx:6666
void UnoRestoreAllActions()
Definition: pagechg.cxx:1960
const SwFrame * GetAnchorFrame(const SdrObject *_pDrawObj=nullptr) const
Definition: dcontact.cxx:804
const SwRect & getFrameArea() const
Definition: frame.hxx:178
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
SwFootnoteContFrame * FindFootnoteCont()
Definition: ftnfrm.cxx:1024
bool getBrowseMode() const
Definition: viewopt.hxx:472
virtual Size ChgSize(const Size &aNewSize)
Definition: wsfrm.cxx:733
bool IsEmptyPage() const
Definition: pagefrm.hxx:157
bool IsInTab() const
Definition: frame.hxx:951
sal_uInt16 GetCheckPageNum() const
Definition: layact.hxx:174
svt::EmbeddedObjectRef & GetObject()
Definition: ndole.cxx:967
const SwPageFrame * GetLastPage() const
Definition: rootfrm.hxx:361
Footer, for pageformats Client of FrameFormat describing the footer.
Definition: fmthdft.hxx:64
bool mbCheckSuperfluous
Definition: rootfrm.hxx:112
virtual ~SwPageFrame() override
Definition: pagechg.cxx:301
void reserve(size_type amount)
sal_uInt16 m_nPhyPageNum
Physical page number: index into list of SwRootFrame lowers.
Definition: pagefrm.hxx:66
void Width(tools::Long nNew)
Definition: swrect.hxx:187
void setFramePrintAreaValid(bool bNew)
Definition: wsfrm.cxx:99
bool m_bInvalidSpelling
Definition: pagefrm.hxx:76
bool OnRightPage() const
Definition: frame.hxx:731
SwTwips GetHeight() const
Definition: pagedesc.hxx:61
sal_uInt16 GetGridWidth(SwTextGridItem const &rG, SwDoc const &rDoc)
Definition: pagechg.cxx:2587
SwDoc * GetDoc() const
Definition: viewsh.hxx:281
constexpr tools::Long getHeight() const
virtual void DestroyImpl() override
Definition: ssfrm.cxx:481
void CheckWaitCursor()
If an Action is running we ask it to check whether it's time to enable the WaitCursor.
Definition: viewimp.cxx:139
void PrepareFooter()
Creates or removes footer.
Definition: hffrm.cxx:723
void AdjustSizeChgNotify(SwRootFrame *pRoot)
Definition: pagechg.cxx:813
bool IsFlowFrame() const
Definition: frame.hxx:1238
void InvalidateLayout() const
Definition: pagefrm.hxx:376
SwBodyFrame(SwFrameFormat *, SwFrame *)
Definition: pagechg.cxx:68
SwFrame * AnchorFrame()
static void lcl_PrepFlyInCntRegister(SwContentFrame *pFrame)
Definition: pagechg.cxx:942
Specific frame formats (frames, DrawObjects).
bool IsCheckPages() const
Definition: layact.hxx:170
bool IsAssertFlyPages() const
Definition: rootfrm.hxx:281
Base class for various Writer styles.
Definition: format.hxx:46
sal_uInt16 GetVirtPageNum() const
Definition: trvlfrm.cxx:1806
void ImplInvalidateBrowseWidth()
Definition: pagechg.cxx:1761
void SetDerivedVert(bool bNew)
Definition: frame.hxx:627
Style of a layout element.
Definition: frmfmt.hxx:58
#define SAL_MAX_INT32
void SetCheckPageNumDirect(sal_uInt16 nNew)
Definition: layact.hxx:161
bool CheckPageHeightValidForHideWhitespace(SwTwips nDiff)
Is bottom-of-page-frame - bottom-of-text-frame difference valid in case whitespace is hidden...
Definition: pagechg.cxx:2519
void RemoveFly(SwFlyFrame *pToRemove)
Definition: fly.cxx:2195
const SdrObject * GetDrawObj() const
void InvalidatePrt()
Definition: frame.hxx:1032
const SwSortedObjs * GetSortedObjs() const
Definition: pagefrm.hxx:132
sw::BroadcastingModify * GetDep()
use these so we can grep for SwFrame's GetRegisteredIn accesses beware that SwTextFrame may return sw...
Definition: frame.hxx:475
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
int i
const SwFooterFrame * GetFooterFrame() const
Definition: pagechg.cxx:2561
void MoveAccessibleFrame(const SwFrame *pFrame, const SwRect &rOldFrame)
Definition: viewimp.hxx:288
const SwRect & VisArea() const
Definition: viewsh.cxx:563
void SetFrameFormat(SwFrameFormat *)
Definition: ssfrm.cxx:405
bool IsViewLayoutBookMode() const
Definition: viewopt.hxx:479
void SetAssertFlyPages()
Makes sure that all requested page-bound Flys find a Page.
Definition: rootfrm.hxx:279
SwFrameType
Definition: frame.hxx:73
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:58
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
const SwPageDesc & GetPageDesc(const size_t i) const
Definition: doc.hxx:882
void ImplCalcBrowseWidth()
Definition: pagechg.cxx:1772
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
size_t size() const
Definition: sortedobjs.cxx:43
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
tools::Long CalcLeft(const SwFrame *pCaller) const
Definition: frmtool.cxx:2305
SwPageFrame * FindPageFrame()
Definition: frame.hxx:678
virtual bool IsDeleteForbidden() const
Definition: frame.hxx:883
SwFrameFormat * GetLeftFormat(bool const bFirst=false)
Definition: pagedesc.cxx:382
virtual void Cut() override
Definition: pagechg.cxx:837
const SwFrame * Lower() const
Definition: layfrm.hxx:101
SwContentFrame * FindNextCnt(const bool _bInSameFootnote=false)
Definition: findfrm.cxx:191
TElementType * First()
Definition: calbck.hxx:325
SwPageDesc * GetPageDesc()
Definition: pagefrm.hxx:143
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: wsfrm.cxx:476
static void lcl_MoveAllLowers(SwFrame *pFrame, const Point &rOffset)
Definition: pagechg.cxx:2064
virtual void CheckDirection(bool bVert) override
Definition: pagechg.cxx:328
void InvalidatePage(const SwPageFrame *pPage=nullptr) const
Invalidates the page in which the Frame is currently placed.
Definition: wsfrm.cxx:609
tools::Long GetHeight(const SwRect &rRect) const
Definition: frame.hxx:1378
FlyAnchors.
Definition: fmtanchr.hxx:34
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:103
SwRemoveResult
Definition: rootfrm.hxx:69
void ChgColumns(const SwFormatCol &rOld, const SwFormatCol &rNew, const bool bChgFootnote=false)
add or remove columns from a layoutframe.
Definition: colfrm.cxx:188
const SwFrameFormat * GetEmptyPageFormat() const
Definition: doc.hxx:748
static void lcl_MoveAllLowerObjs(SwFrame *pFrame, const Point &rOffset)
Definition: pagechg.cxx:1983
bool IsAction() const
SS for the Lay-/IdleAction and relatives.
Definition: viewimp.hxx:186
bool mbInvalidR2L
Definition: frame.hxx:416
bool m_bFootnotePage
Definition: pagefrm.hxx:73
SwLayoutFrame * GetUpper()
Definition: frame.hxx:676
bool HasArea() const
Definition: swrect.hxx:288
bool mbVertical
Definition: frame.hxx:421
void AddHeight(const tools::Long nAdd)
Definition: swrect.cxx:161
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(163)
bool isFramePrintAreaValid() const
Definition: frame.hxx:167
bool IsEndNotePage() const
Definition: pagefrm.hxx:200
const SwFormatFooter & GetFooter(bool=true) const
Definition: fmthdft.hxx:99
sal_Int16 GetHoriOrient() const
Definition: fmtornt.hxx:87
bool m_bInvalidFlyInCnt
Definition: pagefrm.hxx:72
tools::Long mnViewWidth
Definition: rootfrm.hxx:98
constexpr TypedWhichId< SwAutoFormatGetDocNode > RES_AUTOFMT_DOCNODE(173)
SwFrame * GetPrev()
Definition: frame.hxx:675
size
const SwAttrSet & GetAttrSet() const
Definition: frmtool.hxx:384
bool isFrameAreaPositionValid() const
Definition: frame.hxx:165
ring_container GetRingContainer()
Definition: ring.hxx:240
static constexpr sal_uInt16 defGapBetweenPages
Definition: viewopt.hxx:452
const_iterator end() const
void SetPhyPageNum(sal_uInt16 nNum)
Definition: pagefrm.hxx:205
SwPageFrame(SwFrameFormat *, SwFrame *, SwPageDesc *)
Definition: pagechg.cxx:175
bool IsUpdateExpFields()
Definition: viewimp.cxx:150
bool empty() const
void MoveFly(SwFlyFrame *pToMove, SwPageFrame *pDest)
Definition: flylay.cxx:935
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:123
sal_uInt8 GetWidthPercent() const
Definition: fmtfsize.hxx:91
void SSize(const Size &rNew)
Definition: swrect.hxx:178
void PrepareHeader()
Make this public, so that the SwViewShell can access it when switching from browse mode Add/remove he...
Definition: hffrm.cxx:682
tools::Long GetHeight() const
bool isFrameAreaSizeValid() const
Definition: frame.hxx:166
virtual SwTwips GrowFrame(SwTwips, bool bTst=false, bool bInfo=false) override
Definition: pagechg.cxx:1454
void InvalidatePos_()
Definition: frame.hxx:785
SwPageDesc * m_pDesc
Definition: pagefrm.hxx:63
A page of the document layout.
Definition: pagefrm.hxx:57
tools::Long SwTwips
Definition: swtypes.hxx:49
bool IsLeftShadowNeeded() const
Definition: paintfrm.cxx:5759
void InvalidateWindows(const SwRect &rRect)
Definition: viewsh.cxx:544
const long LONG_MAX
sal_uInt16 GetLines() const
Definition: tgrditem.hxx:72
void SetVirtPageNum(const bool bOf) const
Definition: rootfrm.hxx:442
SwBorderAttrs * Get()
Definition: frmtool.cxx:2615
void InvalidateSize()
Definition: frame.hxx:1025
virtual SdrLayerID GetLayer() const
SwLayoutFrame * FindBodyCont()
Searches the first ContentFrame in BodyText below the page.
Definition: findfrm.cxx:43
const SwPageDesc * GetFollow() const
Definition: pagedesc.hxx:268
bool m_bInvalidContent
Definition: pagefrm.hxx:68
tools::Long const nBorder
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:450
bool IsHideWhitespaceMode() const
Definition: viewopt.hxx:483
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
void setFrameAreaPositionValid(bool bNew)
Definition: wsfrm.cxx:83
sal_uInt16 Count() const
Definition: hints.hxx:287
void SetPosX(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1396
FrameControlType
Definition: swtypes.hxx:238
SwFrameFormat & GetMaster()
Definition: pagedesc.hxx:239
void Bottom(const tools::Long nBottom)
Definition: swrect.hxx:209
static constexpr sal_Int64 MIN_BROWSE_WIDTH
Width of the HTML / Web document if not defined otherwise: 20cm.
Definition: rootfrm.hxx:110
const SwContentNode * GetNode() const
Definition: notxtfrm.hxx:66
constexpr TypedWhichId< SwTextGridItem > RES_TEXTGRID(115)
tools::Long GetBrowseWidthMin() const
Definition: htmltbl.hxx:426
void SetWidth(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1386
virtual bool GetInfo(SfxPoolItem &) const override
Get info from Client.
Definition: pagechg.cxx:720
bool IsVertLR() const
Definition: frame.hxx:975
bool IsSquaredPageMode() const
Definition: docdesc.cxx:1035
SwPageDesc * GetPageDesc(SwDoc &rDoc) const
Definition: docftn.cxx:105
bool m_bEmptyPage
Definition: pagefrm.hxx:74
SwLayAction & GetLayAction()
Definition: viewimp.hxx:188
bool IsTabFrame() const
Definition: frame.hxx:1214
general base class for all free-flowing frames
Definition: flyfrm.hxx:78
bool IsPageFrameEmpty(SwPageFrame const &rPage)
check if there's content on the page that requires it to exist
Definition: pagechg.cxx:994
bool IsRightPageByNumber(SwRootFrame const &rLayout, sal_uInt16 nPageNum)
Definition: frmtool.cxx:3044
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:88
void RemoveSuperfluous()
remove pages that are not needed at all
Definition: pagechg.cxx:1491
bool mbFixSize
Definition: frame.hxx:427
virtual SwFrameFormat & GetFrameFormat()=0
void SetAgain()
Definition: layact.hxx:157
void UnoRemoveAllActions()
Certain UNO Actions (e.g.
Definition: pagechg.cxx:1925
void ClrContourCache(const SdrObject *pObj)
Definition: txtfly.cxx:134
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:423
vcl::Window * GetWin() const
Definition: viewsh.hxx:337
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:254
void InvalidateAll_()
Definition: frame.hxx:801
virtual const SwAnchoredObject * GetAnchoredObj(const SdrObject *_pSdrObj) const override
Definition: dcontact.cxx:762
#define SAL_INFO(area, stream)
bool IsInside(const Point &rPOINT) const
Definition: swrect.cxx:105
SwFrameFormat * GetRightFormat(bool const bFirst=false)
Layout uses the following methods to obtain a format in order to be able to create a page...
Definition: pagedesc.cxx:389
void SetHeight(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1387
bool IsNoTextFrame() const
Definition: frame.hxx:1234
bool m_bInvalidAutoCmplWrds
Definition: pagefrm.hxx:78
void RemoveFromLayout()
Definition: wsfrm.cxx:1009
bool mbBookMode
Definition: rootfrm.hxx:100
bool IsRightToLeft() const
Definition: frame.hxx:983
SwRect maPagesArea
Definition: rootfrm.hxx:97
void Top(const tools::Long nTop)
Definition: swrect.hxx:204
void setFrameAreaSizeValid(bool bNew)
Definition: wsfrm.cxx:91
void InvalidateObjRectWithSpaces() const
bool m_bInvalidFlyContent
Definition: pagefrm.hxx:70
SwFrame * GetLower()
Definition: findfrm.cxx:170
SwFrameType mnFrameType
Definition: frame.hxx:413
bool IsPageFrame() const
Definition: frame.hxx:1174
const Size & GetBrowseBorder() const
Definition: viewsh.cxx:1991
const SfxPoolItem & GetFormatAttr(sal_uInt16 nWhich, bool bInParents=true) const
If bInParents is FALSE, search only in this format for attribute.
Definition: format.cxx:369
void PreparePage(bool bFootnote)
Always call after Paste Creates the page-bound frames and formats the generic content.
Definition: pagechg.cxx:467
Header, for PageFormats Client of FrameFormat describing the header.
Definition: fmthdft.hxx:33
#define FAR_AWAY
Definition: frmtool.hxx:53
const Point & GetAnchorPos() const
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
const Size & GetSize() const
Definition: frmtool.hxx:401
virtual void CallSwClientNotify(const SfxHint &rHint) const override
Definition: calbck.cxx:324
static void lcl_MakeObjs(const SwFrameFormats &rTable, SwPageFrame *pPage)
Create Flys or register draw objects.
Definition: pagechg.cxx:390
void AppendDrawObj(SwAnchoredObject &_rNewObj)
Definition: fly.cxx:2235
bool OnFirstPage() const
Definition: trvlfrm.cxx:1768
static void AssertPageFlys(SwPageFrame *)
Makes sure that, starting from the passed Page, all page-bound Frames are on the right Page (pagenumb...
Definition: pagechg.cxx:1679
void DelFrameFormat(SwFrameFormat *pFormat, bool bBroadcast=false)
Definition: docfmt.cxx:686
bool mbRightToLeft
Definition: frame.hxx:418
static void lcl_FormatLay(SwLayoutFrame *pLay)
create specific Flys for this page and format generic content
Definition: pagechg.cxx:370
bool IsVertical() const
Definition: frame.hxx:969
sal_uInt16 GetNumCols() const
Definition: fmtclds.hxx:114
bool IsInDtor() const
Definition: doc.hxx:403
SwDocPosUpdate is sent to signal that only the frames from or to a specified document-global position...
Definition: hints.hxx:225
SwPageFrameInvFlags
Definition: pagefrm.hxx:39
bool IsAccessibleFrame() const
Definition: frame.hxx:1246
constexpr TypedWhichId< SwFormatFooter > RES_FOOTER(97)
void InvalidatePrt_()
Definition: frame.hxx:777
SwFootnoteIdxs & GetFootnoteIdxs()
Definition: doc.hxx:633
void ClearItem(sal_uInt16 nWhichL)
Definition: hints.cxx:128
void SetLastPage(SwPageFrame *pPage)
Definition: pagechg.cxx:832
void UpdateAttr_(const SfxPoolItem *, const SfxPoolItem *, SwPageFrameInvFlags &, SwAttrSetChg *pa=nullptr, SwAttrSetChg *pb=nullptr)
Definition: pagechg.cxx:560
size_t size() const
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: pagechg.cxx:898
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
Definition: layfrm.hxx:35
SwTextGrid GetGridType() const
Definition: tgrditem.hxx:81
Left
void RegistFlys(SwPageFrame *, const SwLayoutFrame *)
Definition: frmtool.cxx:3160
void StartAllAction()
Set up Start-/EndAction for all Shells on an as high as possible (Shell section) level.
Definition: pagechg.cxx:1891
const SwFrame * GetAnchorFrame() const
void SetFirstVisPageInvalid()
Definition: viewsh.cxx:1029
SwPageFrame * InsertPage(SwPageFrame *pSibling, bool bFootnote)
Definition: pagechg.cxx:1350
bool IsActive() const
Definition: fmthdft.hxx:58
std::pair< const_iterator, bool > insert(Value &&x)
sal_uInt16 GetBaseHeight() const
Definition: tgrditem.hxx:75
static void GetBorderAndShadowBoundRect(const SwRect &_rPageRect, const SwViewShell *_pViewShell, OutputDevice const *pRenderContext, SwRect &_orBorderAndShadowBoundRect, const bool bLeftShadow, const bool bRightShadow, const bool bRightSidebar)
get bound rectangle of border and shadow for repaints
Definition: paintfrm.cxx:6142
sal_uInt16 mnColumns
Definition: rootfrm.hxx:99
bool IsFootnoteContFrame() const
Definition: frame.hxx:1194
void EndAllAction(bool bVirDev=false)
Definition: pagechg.cxx:1903
friend void AdjustSizeChgNotify(SwRootFrame *pRoot)
Definition: pagechg.cxx:813
#define DOCUMENTBORDER
Definition: swtypes.hxx:82
bool IsWhitespaceHidden() const
Definition: viewopt.hxx:488
const SwContentFrame * ContainsContent() const
Checks if the frame contains one or more ContentFrame's anywhere in his subsidiary structure; if so t...
Definition: findfrm.cxx:67
void RemovePage(SwPageFrame **pDel, SwRemoveResult eResult)
Definition: pagechg.cxx:1479
bool IsBodyFrame() const
Definition: frame.hxx:1202
bool m_bInvalidSmartTags
Definition: pagefrm.hxx:77
const SwHeaderFrame * GetHeaderFrame() const
Definition: pagechg.cxx:2549
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:208
virtual void MakeAll(vcl::RenderContext *pRenderContext) override
Definition: pagechg.cxx:1735
class for collecting anchored objects
Definition: sortedobjs.hxx:48
void SetCheckPageNum(sal_uInt16 nNew)
Definition: layact.hxx:209
void Height(tools::Long nNew)
Definition: swrect.hxx:191
Container of body content (i.e.
Definition: bodyfrm.hxx:28
bool IsSuperfluous() const
Definition: rootfrm.hxx:301
SdrObject * FindSdrObject()
Definition: frmfmt.hxx:138
Footer in the document layout, inside a page.
Definition: hffrm.hxx:50
sal_uInt16 GetRubyHeight() const
Definition: tgrditem.hxx:78
sal_uInt16 GetViewLayoutColumns() const
Definition: viewopt.hxx:481
bool IsFooterFrame() const
Definition: frame.hxx:1190
const SwFootnoteInfo & GetFootnoteInfo() const
Definition: doc.hxx:629
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: pagechg.cxx:499
sal_uInt16 Which() const
SwRootFrame * getRootFrame()
Definition: frame.hxx:677
const SwEndNoteInfo & GetEndNoteInfo() const
Definition: doc.hxx:631
virtual void transform_translate(const Point &rOffset)
Definition: wsfrm.cxx:147
bool IsCallbackActionEnabled() const
Definition: rootfrm.hxx:386
std::unique_ptr< SwSortedObjs > m_pSortedObjs
Definition: pagefrm.hxx:61
bool m_bEndNotePage
Definition: pagefrm.hxx:75
const Size & GetSize() const
sal_uInt16 GetGapBetweenPages() const
Definition: viewopt.hxx:457
bool IsRightShadowNeeded() const
Definition: paintfrm.cxx:5746
bool IsHeaderFrame() const
Definition: frame.hxx:1186
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1494
void EndAction(const bool bIdleEnd=false)
Definition: crsrsh.cxx:243
virtual const SwFrameFormat * GetFormat() const
Definition: ssfrm.cxx:395
SwTabFrame * FindTabFrame()
Definition: frame.hxx:1095
SwFrame * GetNext()
Definition: frame.hxx:674