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