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