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