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  const SfxPoolItem* pNItem = aNIter.GetCurItem();
511  const SfxPoolItem* pOItem = aOIter.GetCurItem();
512  SwAttrSetChg aOldSet( *static_cast<const SwAttrSetChg*>(pOld) );
513  SwAttrSetChg aNewSet( *static_cast<const SwAttrSetChg*>(pNew) );
514  do
515  {
516  UpdateAttr_(pOItem, pNItem, nInvFlags, &aOldSet, &aNewSet);
517  pNItem = aNIter.NextItem();
518  pOItem = aOIter.NextItem();
519  } while (pNItem);
520  if ( aOldSet.Count() || aNewSet.Count() )
521  SwLayoutFrame::Modify( &aOldSet, &aNewSet );
522  }
523  else
524  UpdateAttr_( pOld, pNew, nInvFlags );
525 
526  if ( nInvFlags != 0 )
527  {
528  InvalidatePage( this );
529  if ( nInvFlags & 0x01 )
530  InvalidatePrt_();
531  if ( nInvFlags & 0x02 )
533  if ( nInvFlags & 0x04 && GetNext() )
534  GetNext()->InvalidatePos();
535  if ( nInvFlags & 0x08 )
536  PrepareHeader();
537  if ( nInvFlags & 0x10 )
538  PrepareFooter();
539  if ( nInvFlags & 0x20 )
540  CheckGrid( nInvFlags & 0x40 );
541  }
542 }
543 
544 
545 void SwPageFrame::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
546 {
547  if(typeid(sw::PageFootnoteHint) == typeid(rHint))
548  {
549  // currently the savest way:
550  static_cast<SwRootFrame*>(GetUpper())->SetSuperfluous();
552  if(!GetMaxFootnoteHeight())
555  // here, the page might be destroyed:
556  static_cast<SwRootFrame*>(GetUpper())->RemoveFootnotes(nullptr, false, true);
557  }
558  else
559  SwFrame::SwClientNotify(rModify, rHint);
560 }
561 
562 void SwPageFrame::UpdateAttr_( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
563  sal_uInt8 &rInvFlags,
564  SwAttrSetChg *pOldSet, SwAttrSetChg *pNewSet )
565 {
566  bool bClear = true;
567  const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
568  switch( nWhich )
569  {
570  case RES_FMT_CHG:
571  {
572  // state of m_bEmptyPage needs to be determined newly
573  const bool bNewState(GetFormat() == GetFormat()->GetDoc()->GetEmptyPageFormat());
574 
575  if(m_bEmptyPage != bNewState)
576  {
577  // copy new state
578  m_bEmptyPage = bNewState;
579 
580  if(nullptr == GetLower())
581  {
582  // if we were an empty page before there is not yet a BodyArea in the
583  // form of a SwBodyFrame, see constructor
584  SwViewShell* pSh(getRootFrame()->GetCurrShell());
585  vcl::RenderContext* pRenderContext(pSh ? pSh->GetOut() : nullptr);
586  Calc(pRenderContext); // so that the PrtArea is correct
587  SwBodyFrame* pBodyFrame = new SwBodyFrame(GetFormat(), this);
588  pBodyFrame->ChgSize(getFramePrintArea().SSize());
589  pBodyFrame->Paste(this);
590  pBodyFrame->InvalidatePos();
591  }
592  }
593 
594  // If the frame format is changed, several things might also change:
595  // 1. columns:
596  assert(pOld && pNew); //FMT_CHG Missing Format
597  const SwFormat *const pOldFormat = static_cast<const SwFormatChg*>(pOld)->pChangedFormat;
598  const SwFormat *const pNewFormat = static_cast<const SwFormatChg*>(pNew)->pChangedFormat;
599  assert(pOldFormat && pNewFormat); //FMT_CHG Missing Format
600  const SwFormatCol &rOldCol = pOldFormat->GetCol();
601  const SwFormatCol &rNewCol = pNewFormat->GetCol();
602  if( rOldCol != rNewCol )
603  {
604  SwLayoutFrame *pB = FindBodyCont();
605  assert(pB && "Page without Body.");
606  pB->ChgColumns( rOldCol, rNewCol );
607  rInvFlags |= 0x20;
608  }
609 
610  // 2. header and footer:
611  const SwFormatHeader &rOldH = pOldFormat->GetHeader();
612  const SwFormatHeader &rNewH = pNewFormat->GetHeader();
613  if( rOldH != rNewH )
614  rInvFlags |= 0x08;
615 
616  const SwFormatFooter &rOldF = pOldFormat->GetFooter();
617  const SwFormatFooter &rNewF = pNewFormat->GetFooter();
618  if( rOldF != rNewF )
619  rInvFlags |= 0x10;
620  CheckDirChange();
621 
622  [[fallthrough]];
623  }
624  case RES_FRM_SIZE:
625  {
626  const SwRect aOldPageFrameRect( getFrameArea() );
628  if( pSh && pSh->GetViewOptions()->getBrowseMode() )
629  {
630  setFrameAreaSizeValid(false);
631  // OD 28.10.2002 #97265# - Don't call <SwPageFrame::MakeAll()>
632  // Calculation of the page is not necessary, because its size is
633  // invalidated here and further invalidation is done in the
634  // calling method <SwPageFrame::Modify(..)> and probably by calling
635  // <SwLayoutFrame::Modify(..)> at the end.
636  // It can also causes inconsistences, because the lowers are
637  // adjusted, but not calculated, and a <SwPageFrame::MakeAll()> of
638  // a next page is called. This is performed on the switch to the
639  // online layout.
640  //MakeAll();
641  }
642  else if (pNew)
643  {
644  const SwFormatFrameSize &rSz = nWhich == RES_FMT_CHG ?
645  static_cast<const SwFormatChg*>(pNew)->pChangedFormat->GetFrameSize() :
646  static_cast<const SwFormatFrameSize&>(*pNew);
647 
648  {
650  aFrm.Height( std::max( rSz.GetHeight(), long(MINLAY) ) );
651  aFrm.Width ( std::max( rSz.GetWidth(), long(MINLAY) ) );
652  }
653 
654  if ( GetUpper() )
655  {
656  static_cast<SwRootFrame*>(GetUpper())->CheckViewLayout( nullptr, nullptr );
657  }
658  }
659  // cleanup Window
660  if( pSh && pSh->GetWin() && aOldPageFrameRect.HasArea() )
661  {
662  // #i9719# - consider border and shadow of
663  // page frame for determine 'old' rectangle - it's used for invalidating.
664  const bool bRightSidebar = (SidebarPosition() == sw::sidebarwindows::SidebarPosition::RIGHT);
665  SwRect aOldRectWithBorderAndShadow;
666  SwPageFrame::GetBorderAndShadowBoundRect( aOldPageFrameRect, pSh, pSh->GetOut(), aOldRectWithBorderAndShadow,
667  IsLeftShadowNeeded(), IsRightShadowNeeded(), bRightSidebar );
668  pSh->InvalidateWindows( aOldRectWithBorderAndShadow );
669  }
670  rInvFlags |= 0x03;
671  if ( aOldPageFrameRect.Height() != getFrameArea().Height() )
672  rInvFlags |= 0x04;
673  }
674  break;
675 
676  case RES_COL:
677  assert(pOld && pNew); //COL Missing Format
678  if (pOld && pNew)
679  {
680  SwLayoutFrame *pB = FindBodyCont();
681  assert(pB); //page without body
682  pB->ChgColumns( *static_cast<const SwFormatCol*>(pOld), *static_cast<const SwFormatCol*>(pNew) );
683  rInvFlags |= 0x22;
684  }
685  break;
686 
687  case RES_HEADER:
688  rInvFlags |= 0x08;
689  break;
690 
691  case RES_FOOTER:
692  rInvFlags |= 0x10;
693  break;
694  case RES_TEXTGRID:
695  rInvFlags |= 0x60;
696  break;
697  case RES_FRAMEDIR :
698  CheckDirChange();
699  break;
700 
701  default:
702  bClear = false;
703  }
704  if ( bClear )
705  {
706  if ( pOldSet || pNewSet )
707  {
708  if ( pOldSet )
709  pOldSet->ClearItem( nWhich );
710  if ( pNewSet )
711  pNewSet->ClearItem( nWhich );
712  }
713  else
714  SwLayoutFrame::Modify( pOld, pNew );
715  }
716 }
717 
719 bool SwPageFrame::GetInfo( SfxPoolItem & rInfo ) const
720 {
721  if( RES_AUTOFMT_DOCNODE == rInfo.Which() )
722  {
723  // a page frame exists, so use this one
724  return false;
725  }
726  return true; // continue searching
727 }
728 
730 {
731  m_pDesc = pNew;
732  if ( pFormat )
733  SetFrameFormat( pFormat );
734 }
735 
736 /* determine the right PageDesc:
737  * 0. from the document for footnote and endnote pages
738  * 1. from the first BodyContent below a page
739  * 2. from PageDesc of the predecessor page
740  * 3. from PageDesc of the previous page if blank page
741  * 3.1 from PageDesc of the next page if no predecessor exists
742  * 4. default PageDesc
743  * 5. In BrowseMode use the first paragraph or default PageDesc.
744  */
746 {
747  // 0.
748  if ( IsFootnotePage() )
749  {
750  SwDoc *pDoc = GetFormat()->GetDoc();
751  if ( IsEndNotePage() )
752  return pDoc->GetEndNoteInfo().GetPageDesc( *pDoc );
753  else
754  return pDoc->GetFootnoteInfo().GetPageDesc( *pDoc );
755  }
756 
757  SwPageDesc *pRet = nullptr;
758 
759  //5.
760  const SwViewShell *pSh = getRootFrame()->GetCurrShell();
761  if( pSh && pSh->GetViewOptions()->getBrowseMode() )
762  {
763  SwContentFrame *pFrame = GetUpper()->ContainsContent();
764  while (pFrame && !pFrame->IsInDocBody())
765  pFrame = pFrame->GetNextContentFrame();
766  if (pFrame)
767  {
768  SwFrame *pFlow = pFrame;
769  if ( pFlow->IsInTab() )
770  pFlow = pFlow->FindTabFrame();
771  pRet = const_cast<SwPageDesc*>(pFlow->GetPageDescItem().GetPageDesc());
772  }
773  if ( !pRet )
774  pRet = &GetFormat()->GetDoc()->GetPageDesc( 0 );
775  return pRet;
776  }
777 
778  SwFrame *pFlow = FindFirstBodyContent();
779  if ( pFlow && pFlow->IsInTab() )
780  pFlow = pFlow->FindTabFrame();
781 
782  //1.
783  if ( pFlow )
784  {
785  SwFlowFrame *pTmp = SwFlowFrame::CastFlowFrame( pFlow );
786  if ( !pTmp->IsFollow() )
787  pRet = const_cast<SwPageDesc*>(pFlow->GetPageDescItem().GetPageDesc());
788  }
789 
790  //3. and 3.1
791  if ( !pRet && IsEmptyPage() )
792  // FME 2008-03-03 #i81544# lijian/fme: an empty page should have
793  // the same page description as its prev, just like after construction
794  // of the empty page.
795  pRet = GetPrev() ? static_cast<SwPageFrame*>(GetPrev())->GetPageDesc() :
796  GetNext() ? static_cast<SwPageFrame*>(GetNext())->GetPageDesc() : nullptr;
797 
798  //2.
799  if ( !pRet )
800  pRet = GetPrev() ?
801  static_cast<SwPageFrame*>(GetPrev())->GetPageDesc()->GetFollow() : nullptr;
802 
803  //4.
804  if ( !pRet )
805  pRet = &GetFormat()->GetDoc()->GetPageDesc( 0 );
806 
807  OSL_ENSURE( pRet, "could not find page descriptor." );
808  return pRet;
809 }
810 
811 // Notify if the RootFrame changes its size
813 {
814  const bool bOld = pRoot->IsSuperfluous();
815  pRoot->mbCheckSuperfluous = false;
816  if ( pRoot->GetCurrShell() )
817  {
818  for(SwViewShell& rSh : pRoot->GetCurrShell()->GetRingContainer())
819  {
820  if( pRoot == rSh.GetLayout() )
821  {
822  rSh.SizeChgNotify();
823  if ( rSh.Imp() )
824  rSh.Imp()->NotifySizeChg( pRoot->getFrameArea().SSize() );
825  }
826  }
827  }
828  pRoot->mbCheckSuperfluous = bOld;
829 }
830 
831 inline void SetLastPage( SwPageFrame *pPage )
832 {
833  static_cast<SwRootFrame*>(pPage->GetUpper())->mpLastPage = pPage;
834 }
835 
837 {
839  if ( !IsEmptyPage() )
840  {
841  if ( GetNext() )
842  GetNext()->InvalidatePos();
843 
844  // move Flys whose anchor is on a different page (draw objects are not relevant here)
845  if ( GetSortedObjs() )
846  {
847  size_t i = 0;
848  while ( GetSortedObjs() && i < GetSortedObjs()->size() )
849  {
850  // #i28701#
851  SwAnchoredObject* pAnchoredObj = (*GetSortedObjs())[i];
852 
853  if ( dynamic_cast< const SwFlyAtContentFrame *>( pAnchoredObj ) != nullptr )
854  {
855  SwFlyFrame* pFly = static_cast<SwFlyAtContentFrame*>(pAnchoredObj);
856  SwPageFrame *pAnchPage = pFly->GetAnchorFrame() ?
857  pFly->AnchorFrame()->FindPageFrame() : nullptr;
858  if ( pAnchPage && (pAnchPage != this) )
859  {
860  MoveFly( pFly, pAnchPage );
861  pFly->InvalidateSize();
862  pFly->InvalidatePos_();
863  // Do not increment index, in this case
864  continue;
865  }
866  }
867  ++i;
868  }
869  }
870  // cleanup Window
871  if ( pSh && pSh->GetWin() )
873  }
874 
875  // decrease the root's page number
876  static_cast<SwRootFrame*>(GetUpper())->DecrPhyPageNums();
877  SwPageFrame *pPg = static_cast<SwPageFrame*>(GetNext());
878  if ( pPg )
879  {
880  while ( pPg )
881  {
882  --pPg->m_nPhyPageNum;
883  pPg = static_cast<SwPageFrame*>(pPg->GetNext());
884  }
885  }
886  else
887  ::SetLastPage( static_cast<SwPageFrame*>(GetPrev()) );
888 
889  SwFrame* pRootFrame = GetUpper();
890 
891  // cut all connections
893 
894  if ( pRootFrame )
895  static_cast<SwRootFrame*>(pRootFrame)->CheckViewLayout( nullptr, nullptr );
896 }
897 
898 void SwPageFrame::Paste( SwFrame* pParent, SwFrame* pSibling )
899 {
900  OSL_ENSURE( pParent->IsRootFrame(), "Parent is no Root." );
901  OSL_ENSURE( pParent, "No parent for Paste()." );
902  OSL_ENSURE( pParent != this, "I'm my own parent." );
903  OSL_ENSURE( pSibling != this, "I'm my own neighbour." );
904  OSL_ENSURE( !GetPrev() && !GetNext() && !GetUpper(),
905  "I am still registered somewhere." );
906 
907  // insert into tree structure
908  InsertBefore( static_cast<SwLayoutFrame*>(pParent), pSibling );
909 
910  // increase the root's page number
911  static_cast<SwRootFrame*>(GetUpper())->IncrPhyPageNums();
912  if( GetPrev() )
913  SetPhyPageNum( static_cast<SwPageFrame*>(GetPrev())->GetPhyPageNum() + 1 );
914  else
915  SetPhyPageNum( 1 );
916  SwPageFrame *pPg = static_cast<SwPageFrame*>(GetNext());
917  if ( pPg )
918  {
919  while ( pPg )
920  {
921  ++pPg->m_nPhyPageNum;
922  pPg->InvalidatePos_();
923  pPg->InvalidateLayout();
924  pPg = static_cast<SwPageFrame*>(pPg->GetNext());
925  }
926  }
927  else
928  ::SetLastPage( this );
929 
930  if( getFrameArea().Width() != pParent->getFramePrintArea().Width() )
931  InvalidateSize_();
932 
933  InvalidatePos();
934 
936  if ( pSh )
937  pSh->SetFirstVisPageInvalid();
938 
939  getRootFrame()->CheckViewLayout( nullptr, nullptr );
940 }
941 
943 {
944  pFrame->Prepare( PREP_REGISTER );
945  if( pFrame->GetDrawObjs() )
946  {
947  for(SwAnchoredObject* pAnchoredObj : *pFrame->GetDrawObjs())
948  {
949  // #i28701#
950  if ( dynamic_cast< const SwFlyInContentFrame *>( pAnchoredObj ) != nullptr )
951  {
952  SwFlyFrame* pFly = static_cast<SwFlyInContentFrame*>(pAnchoredObj);
953  SwContentFrame *pCnt = pFly->ContainsContent();
954  while ( pCnt )
955  {
956  lcl_PrepFlyInCntRegister( pCnt );
957  pCnt = pCnt->GetNextContentFrame();
958  }
959  }
960  }
961  }
962 }
963 
965 {
967  while( pFrame )
968  {
969  lcl_PrepFlyInCntRegister( pFrame );
970  pFrame = pFrame->GetNextContentFrame();
971  if( !IsAnLower( pFrame ) )
972  break;
973  }
974  if( GetSortedObjs() )
975  {
976  for(SwAnchoredObject* pAnchoredObj : *GetSortedObjs())
977  {
978  // #i28701#
979  if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
980  {
981  SwFlyFrame *pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
982  pFrame = pFly->ContainsContent();
983  while ( pFrame )
984  {
985  ::lcl_PrepFlyInCntRegister( pFrame );
986  pFrame = pFrame->GetNextContentFrame();
987  }
988  }
989  }
990  }
991 }
992 
993 //FIXME: provide missing documentation
1002 void SwFrame::CheckPageDescs( SwPageFrame *pStart, bool bNotifyFields, SwPageFrame** ppPrev )
1003 {
1004  SAL_INFO( "sw.pageframe", "(CheckPageDescs in phy: " << pStart->GetPhyPageNum() );
1005  assert(pStart && "no starting page.");
1006 
1007  SwViewShell *pSh = pStart->getRootFrame()->GetCurrShell();
1008  SwViewShellImp *pImp = pSh ? pSh->Imp() : nullptr;
1009 
1010  if ( pImp && pImp->IsAction() && !pImp->GetLayAction().IsCheckPages() )
1011  {
1012  pImp->GetLayAction().SetCheckPageNum( pStart->GetPhyPageNum() );
1013  SAL_INFO( "sw.pageframe", "CheckPageDescs out fast - via SetCheckPageNum: "
1014  << pStart->GetPhyPageNum() << ")" );
1015  return;
1016  }
1017 
1018  // For the update of page numbering fields, nDocPos provides
1019  // the page position from where invalidation should start.
1020  SwTwips nDocPos = LONG_MAX;
1021 
1022  SwRootFrame *pRoot = static_cast<SwRootFrame*>(pStart->GetUpper());
1023  SwDoc* pDoc = pStart->GetFormat()->GetDoc();
1024  const bool bFootnotes = !pDoc->GetFootnoteIdxs().empty();
1025 
1026  SwPageFrame *pPage = pStart;
1027  if( pPage->GetPrev() && static_cast<SwPageFrame*>(pPage->GetPrev())->IsEmptyPage() )
1028  pPage = static_cast<SwPageFrame*>(pPage->GetPrev());
1029  while ( pPage )
1030  {
1031  SwPageFrame *pPrevPage = static_cast<SwPageFrame*>(pPage->GetPrev());
1032  SwPageFrame *pNextPage = static_cast<SwPageFrame*>(pPage->GetNext());
1033 
1034  SwPageDesc *pDesc = pPage->FindPageDesc();
1035  bool bIsEmpty = pPage->IsEmptyPage();
1036  bool bIsOdd = pPage->OnRightPage();
1037  bool bWantOdd = pPage->WannaRightPage();
1038  bool bFirst = pPage->OnFirstPage();
1039  SwFrameFormat *pFormatWish = bWantOdd
1040  ? pDesc->GetRightFormat(bFirst) : pDesc->GetLeftFormat(bFirst);
1041 
1042  if ( bIsOdd != bWantOdd ||
1043  pDesc != pPage->GetPageDesc() || // wrong Desc
1044  ( pFormatWish != pPage->GetFormat() && // wrong format and
1045  ( !bIsEmpty || pFormatWish ) // not blank /empty
1046  )
1047  )
1048  {
1049  // Updating a page might take a while, so check the WaitCursor
1050  if( pImp )
1051  pImp->CheckWaitCursor();
1052 
1053  // invalidate the field, starting from here
1054  if ( nDocPos == LONG_MAX )
1055  nDocPos = pPrevPage ? pPrevPage->getFrameArea().Top() : pPage->getFrameArea().Top();
1056 
1057  // Cases:
1058  // 1. Empty page should be "normal" page -> remove empty page and take next one
1059  // 2. Empty page should have different descriptor -> change
1060  // 3. Normal page should be empty -> insert empty page if previous page
1061  // is not empty, otherwise see (6).
1062  // 4. Normal page should have different descriptor -> change
1063  // 5. Normal page should have different format -> change
1064  // 6. No "wish" format provided -> take the "other" format (left/right) of the PageDesc
1065 
1066  if ( bIsEmpty && ( pFormatWish || //1.
1067  ( !bWantOdd && !pPrevPage ) ) )
1068  {
1069  // Check all cases for the next page, so we don't oscillate empty pages
1070  // Skip case 1 and 2, as we require a non-empty next page to save the empty page
1071  // Case 3 is the one we actually want to predict and skip
1072  // We can skip the empty check of case 3, as we just work on an existing next page
1073  bool bNextWantOdd;
1074  SwPageDesc *pNextDesc;
1075  if ( pNextPage && !pNextPage->IsEmptyPage() && //3.
1076  pNextPage->OnRightPage() == (bNextWantOdd = pNextPage->WannaRightPage()) &&
1077  pNextPage->GetPageDesc() == (pNextDesc = pNextPage->FindPageDesc()) ) //4.
1078  {
1079  bool bNextFirst = pNextPage->OnFirstPage();
1080  SwFrameFormat *pNextFormatWish = bNextWantOdd ? //5.
1081  pNextDesc->GetRightFormat(bNextFirst) : pNextDesc->GetLeftFormat(bNextFirst);
1082  if ( !pNextFormatWish ) // 6.
1083  pNextFormatWish = bNextWantOdd ? pNextDesc->GetLeftFormat() : pNextDesc->GetRightFormat();
1084  if ( pNextFormatWish && pNextPage->GetFormat() == pNextFormatWish )
1085  {
1086  SAL_INFO( "sw.pageframe", "CheckPageDescs phys: " << pPage->GetPhyPageNum()
1087  << " c: 1+3 - skip next page of p: " << pPage );
1088  if (pPrevPage && pPage->GetPageDesc() != pPrevPage->GetPageDesc())
1089  pPage->SetPageDesc( pPrevPage->GetPageDesc(), nullptr );
1090  // We can skip the next page, as all checks were already done!
1091  pPage = static_cast<SwPageFrame*>(pNextPage->GetNext());
1092  continue;
1093  }
1094  }
1095 
1096  pPage->Cut();
1097  bool bUpdatePrev = false;
1098  if (ppPrev && *ppPrev == pPage)
1099  bUpdatePrev = true;
1100  SAL_INFO( "sw.pageframe", "CheckPageDescs phys: " << pPage->GetPhyPageNum()
1101  << " c: 1 - destroy p: " << pPage );
1102  SwFrame::DestroyFrame(pPage);
1103  if ( pStart == pPage )
1104  pStart = pNextPage;
1105  pPage = pNextPage;
1106  if (bUpdatePrev)
1107  *ppPrev = pNextPage;
1108  continue;
1109  }
1110  else if ( bIsEmpty && !pFormatWish && //2.
1111  pDesc != pPage->GetPageDesc() )
1112  {
1113  SAL_INFO( "sw.pageframe", "CheckPageDescs phys: " << pPage->GetPhyPageNum()
1114  << " c: 2 - set desc p: " << pPage << " d: " << pDesc );
1115  pPage->SetPageDesc( pDesc, nullptr );
1116  }
1117  else if ( !bIsEmpty && //3.
1118  bIsOdd != bWantOdd &&
1119  ( ( !pPrevPage && !bWantOdd ) ||
1120  ( pPrevPage && !pPrevPage->IsEmptyPage() )
1121  )
1122  )
1123  {
1124  if ( pPrevPage )
1125  pDesc = pPrevPage->GetPageDesc();
1126  SwPageFrame *pTmp = new SwPageFrame( pDoc->GetEmptyPageFormat(), pRoot, pDesc );
1127  SAL_INFO( "sw.pageframe", "CheckPageDescs phys: " << pPage->GetPhyPageNum()
1128  << " c: 3 - insert empty p: " << pTmp << " d: " << pDesc );
1129  pTmp->Paste( pRoot, pPage );
1130  pTmp->PreparePage( false );
1131  pPage = pTmp;
1132  }
1133  else if ( pPage->GetPageDesc() != pDesc ) //4.
1134  {
1135  SwPageDesc *pOld = pPage->GetPageDesc();
1136  pPage->SetPageDesc( pDesc, pFormatWish );
1137  SAL_INFO( "sw.pageframe", "CheckPageDescs phys: " << pPage->GetPhyPageNum()
1138  << " c: 4 - set desc + format p: " << pPage
1139  << " d: " << pDesc << " f: " << pFormatWish );
1140  if ( bFootnotes )
1141  {
1142  // If specific values of the FootnoteInfo are changed, something has to happen.
1143  // We try to limit the damage...
1144  // If the page has no FootnoteCont it might be problematic.
1145  // Let's hope that invalidation is enough.
1146  SwFootnoteContFrame *pCont = pPage->FindFootnoteCont();
1147  if ( pCont && !(pOld->GetFootnoteInfo() == pDesc->GetFootnoteInfo()) )
1148  pCont->InvalidateAll_();
1149  }
1150  }
1151  else if ( pFormatWish && pPage->GetFormat() != pFormatWish ) //5.
1152  {
1153  pPage->SetFrameFormat( pFormatWish );
1154  SAL_INFO( "sw.pageframe", "CheckPageDescs phys: " << pPage->GetPhyPageNum()
1155  << " c: 5 - set format p: " << pPage << " f: " << pFormatWish );
1156  }
1157  else if ( !pFormatWish ) //6.
1158  {
1159  // get format with inverted logic
1160  pFormatWish = bWantOdd ? pDesc->GetLeftFormat() : pDesc->GetRightFormat();
1161  if ( pFormatWish && pPage->GetFormat() != pFormatWish )
1162  {
1163  pPage->SetFrameFormat( pFormatWish );
1164  SAL_INFO( "sw.pageframe", "CheckPageDescs phys: " << pPage->GetPhyPageNum()
1165  << " c: 6 - set format p: " << pPage << " f: " << pFormatWish );
1166  }
1167  }
1168 #if OSL_DEBUG_LEVEL > 0
1169  else
1170  {
1171  OSL_FAIL( "CheckPageDescs, missing solution" );
1172  }
1173 #endif
1174  }
1175  if ( bIsEmpty )
1176  {
1177  // It also might be that an empty page is not needed at all.
1178  // However, the algorithm above cannot determine that. It is not needed if the following
1179  // page can live without it. Do obtain that information, we need to dig deeper...
1180  SwPageFrame *pPg = static_cast<SwPageFrame*>(pPage->GetNext());
1181  if( !pPg || pPage->OnRightPage() == pPg->WannaRightPage() )
1182  {
1183  // The following page can find a FrameFormat or has no successor -> empty page not needed
1184  SwPageFrame *pTmp = static_cast<SwPageFrame*>(pPage->GetNext());
1185  pPage->Cut();
1186  bool bUpdatePrev = false;
1187  if (ppPrev && *ppPrev == pPage)
1188  bUpdatePrev = true;
1189  SwFrame::DestroyFrame(pPage);
1190  SAL_INFO( "sw.pageframe", "CheckPageDescs - handle bIsEmpty - destroy p: " << pPage );
1191  if ( pStart == pPage )
1192  pStart = pTmp;
1193  pPage = pTmp;
1194  if (bUpdatePrev)
1195  *ppPrev = pTmp;
1196  continue;
1197  }
1198  }
1199  pPage = static_cast<SwPageFrame*>(pPage->GetNext());
1200  }
1201 
1202  pRoot->SetAssertFlyPages();
1203  SwRootFrame::AssertPageFlys( pStart );
1204 
1205  if ( bNotifyFields && (!pImp || !pImp->IsUpdateExpFields()) )
1206  {
1207  SwDocPosUpdate aMsgHint( nDocPos );
1208  pDoc->getIDocumentFieldsAccess().UpdatePageFields( &aMsgHint );
1209  }
1210 
1211 #if OSL_DEBUG_LEVEL > 0
1212  //1. check if two empty pages are behind one another
1213  bool bEmpty = false;
1214  SwPageFrame *pPg = pStart;
1215  while ( pPg )
1216  {
1217  if ( pPg->IsEmptyPage() )
1218  {
1219  if ( bEmpty )
1220  {
1221  OSL_FAIL( "double empty pages." );
1222  break; // once is enough
1223  }
1224  bEmpty = true;
1225  }
1226  else
1227  bEmpty = false;
1228 
1229  pPg = static_cast<SwPageFrame*>(pPg->GetNext());
1230  }
1231 #endif
1232  SAL_INFO( "sw.pageframe", "CheckPageDescs out)" );
1233 }
1234 
1235 namespace
1236 {
1237  bool isDeleteForbidden(const SwPageFrame *pDel)
1238  {
1239  if (pDel->IsDeleteForbidden())
1240  return true;
1241  const SwLayoutFrame* pBody = pDel->FindBodyCont();
1242  const SwFrame* pBodyContent = pBody ? pBody->Lower() : nullptr;
1243  return pBodyContent && pBodyContent->IsDeleteForbidden();
1244  }
1245 
1246  bool doInsertPage( SwRootFrame *pRoot, SwPageFrame **pRefSibling,
1247  SwFrameFormat *pFormat, SwPageDesc *pDesc,
1248  bool bFootnote, SwPageFrame **pRefPage )
1249  {
1250  SwPageFrame *pPage = new SwPageFrame(pFormat, pRoot, pDesc);
1251  SwPageFrame *pSibling = *pRefSibling;
1252  if ( pRefPage )
1253  {
1254  *pRefPage = pPage;
1255  SAL_INFO( "sw.pageframe", "doInsertPage p: " << pPage
1256  << " d: " << pDesc << " f: " << pFormat );
1257  }
1258  else
1259  SAL_INFO( "sw.pageframe", "doInsertPage - insert empty p: "
1260  << pPage << " d: " << pDesc );
1261  pPage->Paste( pRoot, pSibling );
1262 
1263  SwViewShell* pViewShell = pRoot->GetCurrShell();
1264  if (pViewShell && pViewShell->GetViewOptions()->IsHideWhitespaceMode())
1265  {
1266  // Hide-whitespace mode does not shrink the last page, so resize the page that used to
1267  // be the last one.
1268  if (SwFrame* pPrevPage = pPage->GetPrev())
1269  {
1270  pPrevPage->InvalidateSize();
1271  }
1272  }
1273 
1274  pPage->PreparePage( bFootnote );
1275  // If the sibling has no body text, destroy it as long as it is no footnote page.
1276  if ( pSibling && !pSibling->IsFootnotePage() &&
1277  !pSibling->FindFirstBodyContent() &&
1278  (!pRefPage || !isDeleteForbidden(pSibling)) )
1279  {
1280  pRoot->RemovePage( pRefSibling, SwRemoveResult::Next ) ;
1281  return false;
1282  }
1283  return true;
1284  }
1285 }
1286 
1287 SwPageFrame *SwFrame::InsertPage( SwPageFrame *pPrevPage, bool bFootnote )
1288 {
1289  SwRootFrame *pRoot = static_cast<SwRootFrame*>(pPrevPage->GetUpper());
1290  SwPageFrame *pSibling = static_cast<SwPageFrame*>(pPrevPage->GetNext());
1291  SwPageDesc *pDesc = nullptr;
1292 
1293  // insert right (odd) or left (even) page?
1294  bool bNextOdd = !pPrevPage->OnRightPage();
1295  bool bWishedOdd = bNextOdd;
1296 
1297  // Which PageDesc is relevant?
1298  // For ContentFrame take the one from format if provided,
1299  // otherwise from the Follow of the PrevPage
1300  if ( IsFlowFrame() && !SwFlowFrame::CastFlowFrame( this )->IsFollow() )
1301  {
1302  SwFormatPageDesc &rDesc = const_cast<SwFormatPageDesc&>(GetPageDescItem());
1303  pDesc = rDesc.GetPageDesc();
1304  if ( rDesc.GetNumOffset() )
1305  {
1306  ::boost::optional<sal_uInt16> oNumOffset = rDesc.GetNumOffset();
1307  bWishedOdd = oNumOffset && (oNumOffset.get() % 2) != 0;
1308  // use the opportunity to set the flag at root
1309  pRoot->SetVirtPageNum( true );
1310  }
1311  }
1312  if ( !pDesc )
1313  pDesc = pPrevPage->GetPageDesc()->GetFollow();
1314 
1315  assert(pDesc && "Missing PageDesc");
1316  if( !(bWishedOdd ? pDesc->GetRightFormat() : pDesc->GetLeftFormat()) )
1317  bWishedOdd = !bWishedOdd;
1318  bool const bWishedFirst = pDesc != pPrevPage->GetPageDesc();
1319 
1320  SwDoc *pDoc = pPrevPage->GetFormat()->GetDoc();
1321  bool bCheckPages = false;
1322  // If there is no FrameFormat for this page, create an empty page.
1323  if( bWishedOdd != bNextOdd )
1324  {
1325  if( doInsertPage( pRoot, &pSibling, pDoc->GetEmptyPageFormat(),
1326  pPrevPage->GetPageDesc(), bFootnote, nullptr ) )
1327  bCheckPages = true;
1328  }
1329  SwFrameFormat *const pFormat( bWishedOdd
1330  ? pDesc->GetRightFormat(bWishedFirst)
1331  : pDesc->GetLeftFormat(bWishedFirst) );
1332  assert(pFormat);
1333  SwPageFrame *pPage = nullptr;
1334  if( doInsertPage( pRoot, &pSibling, pFormat, pDesc, bFootnote, &pPage ) )
1335  bCheckPages = true;
1336 
1337  if ( pSibling )
1338  {
1339  if ( bCheckPages )
1340  {
1341  CheckPageDescs( pSibling, false );
1343  SwViewShellImp *pImp = pSh ? pSh->Imp() : nullptr;
1344  if ( pImp && pImp->IsAction() && !pImp->GetLayAction().IsCheckPages() )
1345  {
1346  const sal_uInt16 nNum = pImp->GetLayAction().GetCheckPageNum();
1347  if ( nNum == pPrevPage->GetPhyPageNum() + 1 )
1348  {
1350  pSibling->GetPhyPageNum() );
1351  SAL_INFO( "sw.pageframe", "InsertPage - SetCheckPageNumDirect: "
1352  << pSibling->GetPhyPageNum() );
1353  }
1354  return pPage;
1355  }
1356  }
1357  else
1358  SwRootFrame::AssertPageFlys( pSibling );
1359  }
1360 
1361  // For the update of page numbering fields, nDocPos provides
1362  // the page position from where invalidation should start.
1364  if ( !pSh || !pSh->Imp()->IsUpdateExpFields() )
1365  {
1366  SwDocPosUpdate aMsgHint( pPrevPage->getFrameArea().Top() );
1367  pDoc->getIDocumentFieldsAccess().UpdatePageFields( &aMsgHint );
1368  }
1369  return pPage;
1370 }
1371 
1373 {
1375  if( !pSh || pSh->GetViewOptions()->getBrowseMode() )
1376  {
1378  }
1379  else
1380  {
1381  const bool bLTR = getRootFrame()->IsLeftToRightViewLayout();
1382  const bool bBookMode = pSh->GetViewOptions()->IsViewLayoutBookMode();
1383  const bool bRightSidebar = bLTR ? (!bBookMode || OnRightPage()) : (bBookMode && !OnRightPage());
1384 
1385  return bRightSidebar
1388  }
1389 }
1390 
1391 SwTwips SwRootFrame::GrowFrame( SwTwips nDist, bool bTst, bool )
1392 {
1393  if ( !bTst )
1394  {
1396  aFrm.SSize().AdjustHeight(nDist );
1397  }
1398 
1399  return nDist;
1400 }
1401 
1402 SwTwips SwRootFrame::ShrinkFrame( SwTwips nDist, bool bTst, bool )
1403 {
1404  OSL_ENSURE( nDist >= 0, "nDist < 0." );
1405  OSL_ENSURE( nDist <= getFrameArea().Height(), "nDist greater than current size." );
1406 
1407  if ( !bTst )
1408  {
1410  aFrm.SSize().AdjustHeight( -nDist );
1411  }
1412 
1413  return nDist;
1414 }
1415 
1417 {
1418  SwPageFrame *pDel = *pDelRef;
1419  (*pDelRef) = static_cast<SwPageFrame*>(
1420  eResult == SwRemoveResult::Next ? pDel->GetNext() : pDel->GetPrev() );
1421  if ( !GetFormat()->GetDoc()->GetFootnoteIdxs().empty() )
1422  RemoveFootnotes( pDel, true );
1423  pDel->Cut();
1424  SwFrame::DestroyFrame( pDel );
1425 }
1426 
1429 {
1430  // A page is empty if the body text area has no ContentFrame, but not if there
1431  // is at least one Fly or one footnote attached to the page. Two runs are
1432  // needed: one for endnote pages and one for the pages of the body text.
1433 
1434  if ( !IsSuperfluous() )
1435  return;
1436  mbCheckSuperfluous = false;
1437 
1438  SwPageFrame *pPage = GetLastPage();
1439  long nDocPos = LONG_MAX;
1440 
1441  // Check the corresponding last page if it is empty and stop loop at the last non-empty page.
1442  do
1443  {
1444  bool bExistEssentialObjs = ( nullptr != pPage->GetSortedObjs() );
1445  if ( bExistEssentialObjs )
1446  {
1447  // Only because the page has Flys does not mean that it is needed. If all Flys are
1448  // attached to generic content it is also superfluous (checking DocBody should be enough)
1449  // OD 19.06.2003 #108784# - consider that drawing objects in
1450  // header/footer are supported now.
1451  bool bOnlySuperfluosObjs = true;
1452  SwSortedObjs &rObjs = *pPage->GetSortedObjs();
1453  for ( size_t i = 0; bOnlySuperfluosObjs && i < rObjs.size(); ++i )
1454  {
1455  // #i28701#
1456  SwAnchoredObject* pAnchoredObj = rObjs[i];
1457  // OD 2004-01-19 #110582# - do not consider hidden objects
1459  pAnchoredObj->GetDrawObj()->GetLayer() ) &&
1460  !pAnchoredObj->GetAnchorFrame()->FindFooterOrHeader() )
1461  {
1462  bOnlySuperfluosObjs = false;
1463  }
1464  }
1465  bExistEssentialObjs = !bOnlySuperfluosObjs;
1466  }
1467 
1468  // OD 19.06.2003 #108784# - optimization: check first, if essential objects
1469  // exists.
1470  const SwLayoutFrame* pBody = nullptr;
1471  if ( bExistEssentialObjs ||
1472  pPage->FindFootnoteCont() ||
1473  ( nullptr != ( pBody = pPage->FindBodyCont() ) &&
1474  ( pBody->ContainsContent() ||
1475  // #i47580#
1476  // Do not delete page if there's an empty tabframe
1477  // left. I think it might be correct to use ContainsAny()
1478  // instead of ContainsContent() to cover the empty-table-case,
1479  // but I'm not fully sure, since ContainsAny() also returns
1480  // SectionFrames. Therefore I prefer to do it the safe way:
1481  ( pBody->Lower() && pBody->Lower()->IsTabFrame() ) ) ) )
1482  {
1483  if ( pPage->IsFootnotePage() )
1484  {
1485  while ( pPage->IsFootnotePage() )
1486  {
1487  pPage = static_cast<SwPageFrame*>(pPage->GetPrev());
1488  OSL_ENSURE( pPage, "only endnote pages remain." );
1489  }
1490  continue;
1491  }
1492  else
1493  pPage = nullptr;
1494  }
1495 
1496  if ( pPage )
1497  {
1498  SAL_INFO( "sw.pageframe", "RemoveSuperfluous - DestroyFrm p: " << pPage );
1499  RemovePage( &pPage, SwRemoveResult::Prev );
1500  nDocPos = pPage ? pPage->getFrameArea().Top() : 0;
1501  }
1502  } while ( pPage );
1503 
1505  if ( nDocPos != LONG_MAX &&
1506  (!pSh || !pSh->Imp()->IsUpdateExpFields()) )
1507  {
1508  SwDocPosUpdate aMsgHint( nDocPos );
1510  }
1511 }
1512 
1515 {
1516  if ( !IsAssertFlyPages() )
1517  return;
1518  mbAssertFlyPages = false;
1519 
1520  SwDoc *pDoc = GetFormat()->GetDoc();
1521  const SwFrameFormats *pTable = pDoc->GetSpzFrameFormats();
1522 
1523  // what page targets the "last" Fly?
1524  // note the needed pages in a set
1525  sal_uInt16 nMaxPg(0);
1526  std::set< sal_uInt16 > neededPages;
1527 
1528  for ( size_t i = 0; i < pTable->size(); ++i )
1529  {
1530  const SwFormatAnchor &rAnch = (*pTable)[i]->GetAnchor();
1531  if(!rAnch.GetContentAnchor())
1532  {
1533  const sal_uInt16 nPageNum(rAnch.GetPageNum());
1534 
1535  // calc MaxPage (as before)
1536  nMaxPg = std::max(nMaxPg, nPageNum);
1537 
1538  // note as needed page
1539  neededPages.insert(nPageNum);
1540  }
1541  }
1542 
1543  // How many pages exist at the moment?
1544  // And are there EmptyPages that are needed?
1545  SwPageFrame* pPage(static_cast<SwPageFrame*>(Lower()));
1546  SwPageFrame* pPrevPage(nullptr);
1547  SwPageFrame* pFirstRevivedEmptyPage(nullptr);
1548 
1549  while(pPage) // moved two while-conditions to break-statements (see below)
1550  {
1551  const sal_uInt16 nPageNum(pPage->GetPhyPageNum());
1552 
1553  if(pPage->IsEmptyPage() &&
1554  nullptr != pPrevPage &&
1555  neededPages.find(nPageNum) != neededPages.end())
1556  {
1557  // This is an empty page, but it *is* needed since a SwFrame
1558  // is anchored at it directly. Initially these SwFrames are
1559  // not fully initialized. Need to change the format of this SwFrame
1560  // and let the ::Notify mechanism newly evaluate
1561  // m_bEmptyPage (see SwPageFrame::UpdateAttr_). Code is taken and
1562  // adapted from ::InsertPage (used below), this needs previous page
1563  bool bWishedOdd(!pPrevPage->OnRightPage());
1564  SwPageDesc* pDesc(pPrevPage->GetPageDesc()->GetFollow());
1565  assert(pDesc && "Missing PageDesc");
1566 
1567  if(!(bWishedOdd ? pDesc->GetRightFormat() : pDesc->GetLeftFormat()))
1568  {
1569  bWishedOdd = !bWishedOdd;
1570  }
1571 
1572  bool const bWishedFirst(pDesc != pPrevPage->GetPageDesc());
1573  SwFrameFormat* pFormat(bWishedOdd ? pDesc->GetRightFormat(bWishedFirst) : pDesc->GetLeftFormat(bWishedFirst));
1574 
1575  // set SwFrameFormat, this will trigger SwPageFrame::UpdateAttr_ and re-evaluate
1576  // m_bEmptyPage, too
1577  pPage->SetFrameFormat(pFormat);
1578 
1579  if(nullptr == pFirstRevivedEmptyPage)
1580  {
1581  // remember first (lowest) SwPageFrame which needed correction
1582  pFirstRevivedEmptyPage = pPage;
1583  }
1584  }
1585 
1586  // original while-condition II
1587  if(nullptr == pPage->GetNext())
1588  {
1589  break;
1590  }
1591 
1592  // original while-condition III
1593  if(static_cast< SwPageFrame* >(pPage->GetNext())->IsFootnotePage())
1594  {
1595  break;
1596  }
1597 
1598  pPrevPage = pPage;
1599  pPage = static_cast<SwPageFrame*>(pPage->GetNext());
1600  }
1601 
1602  if ( nMaxPg > pPage->GetPhyPageNum() )
1603  {
1604  for ( sal_uInt16 i = pPage->GetPhyPageNum(); i < nMaxPg; ++i )
1605  pPage = InsertPage( pPage, false );
1606 
1607  // If the endnote pages are now corrupt, destroy them.
1608  if ( !pDoc->GetFootnoteIdxs().empty() )
1609  {
1610  pPage = static_cast<SwPageFrame*>(Lower());
1611  while ( pPage && !pPage->IsFootnotePage() )
1612  pPage = static_cast<SwPageFrame*>(pPage->GetNext());
1613 
1614  if ( pPage )
1615  {
1616  SwPageDesc *pTmpDesc = pPage->FindPageDesc();
1617  bool bOdd = pPage->OnRightPage();
1618  if ( pPage->GetFormat() !=
1619  (bOdd ? pTmpDesc->GetRightFormat() : pTmpDesc->GetLeftFormat()) )
1620  RemoveFootnotes( pPage, false, true );
1621  }
1622  }
1623  }
1624 
1625  // if we corrected SwFrameFormat and changed one (or more) m_bEmptyPage
1626  // flags, we need to correct evtl. currently wrong positioned SwFrame(s)
1627  // which did think until now that these Page(s) are empty.
1628  // After trying to correct myself I found SwRootFrame::AssertPageFlys
1629  // directly below that already does that, so use it.
1630  if(nullptr != pFirstRevivedEmptyPage)
1631  {
1632  AssertPageFlys(pFirstRevivedEmptyPage);
1633  }
1634 
1635 #if OSL_DEBUG_LEVEL > 0
1636  pPage = static_cast<SwPageFrame*>(Lower());
1637  while ( pPage && pPage->GetNext() &&
1638  !static_cast<SwPageFrame*>(pPage->GetNext())->IsFootnotePage() )
1639  {
1640  SAL_INFO( "sw.pageframe", "AssertFlyPages p: " << pPage << " d: " << pPage->GetPageDesc()
1641  << " f: " << pPage->GetFormat() << " virt: " << pPage->GetVirtPageNum()
1642  << " phys: " << pPage->GetPhyPageNum() << " empty: " << pPage->IsEmptyPage() );
1643  pPage = static_cast<SwPageFrame*>(pPage->GetNext());
1644  }
1645  SAL_INFO( "sw.pageframe", "AssertFlyPages p: " << pPage << " d: " << pPage->GetPageDesc()
1646  << " f: " << pPage->GetFormat() << " virt: " << pPage->GetVirtPageNum()
1647  << " phys: " << pPage->GetPhyPageNum() << " empty: " << pPage->IsEmptyPage() );
1648 #endif
1649 }
1650 
1653 {
1654  SAL_INFO( "sw.pageframe", "(AssertPageFlys in" );
1655  while ( pPage )
1656  {
1657  if (pPage->GetSortedObjs())
1658  {
1659  size_t i = 0;
1660  while ( pPage->GetSortedObjs() && i< pPage->GetSortedObjs()->size() )
1661  {
1662  // #i28701#
1663  SwFrameFormat& rFormat = (*pPage->GetSortedObjs())[i]->GetFrameFormat();
1664  const SwFormatAnchor &rAnch = rFormat.GetAnchor();
1665  const sal_uInt16 nPg = rAnch.GetPageNum();
1666  if ((rAnch.GetAnchorId() == RndStdIds::FLY_AT_PAGE) &&
1667  nPg != pPage->GetPhyPageNum() )
1668  {
1669  SAL_INFO( "sw.pageframe", nPg << " " << pPage->GetPhyPageNum() );
1670  // If on the wrong page, check if previous page is empty
1671  if( nPg && !(pPage->GetPhyPageNum()-1 == nPg &&
1672  static_cast<SwPageFrame*>(pPage->GetPrev())->IsEmptyPage()) )
1673  {
1674  // It can move by itself. Just send a modify to its anchor attribute.
1675 #if OSL_DEBUG_LEVEL > 1
1676  const size_t nCnt = pPage->GetSortedObjs()->size();
1677  rFormat.NotifyClients( nullptr, &rAnch );
1678  OSL_ENSURE( !pPage->GetSortedObjs() ||
1679  nCnt != pPage->GetSortedObjs()->size(),
1680  "Object couldn't be reattached!" );
1681 #else
1682  rFormat.NotifyClients( nullptr, &rAnch );
1683 #endif
1684  // Do not increment index, in this case
1685  continue;
1686  }
1687  }
1688  ++i;
1689  }
1690  }
1691  pPage = static_cast<SwPageFrame*>(pPage->GetNext());
1692  }
1693  SAL_INFO( "sw.pageframe", "AssertPageFlys out)" );
1694 }
1695 
1696 Size SwRootFrame::ChgSize( const Size& aNewSize )
1697 {
1698  {
1700  aFrm.SSize() = aNewSize;
1701  }
1702 
1703  InvalidatePrt_();
1704  mbFixSize = false;
1705  return getFrameArea().SSize();
1706 }
1707 
1708 void SwRootFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/)
1709 {
1710  if ( !isFrameAreaPositionValid() )
1711  {
1714  aFrm.Pos().setX(DOCUMENTBORDER);
1715  aFrm.Pos().setY(DOCUMENTBORDER);
1716  }
1717 
1718  if ( !isFramePrintAreaValid() )
1719  {
1720  setFramePrintAreaValid(true);
1722  aPrt.Pos().setX(0);
1723  aPrt.Pos().setY(0);
1724  aPrt.SSize( getFrameArea().SSize() );
1725  }
1726 
1727  if ( !isFrameAreaSizeValid() )
1728  {
1729  // SSize is set by the pages (Cut/Paste).
1730  setFrameAreaSizeValid(true);
1731  }
1732 }
1733 
1735 {
1736  mbBrowseWidthValid = false;
1737  SwFrame *pPg = Lower();
1738  while ( pPg )
1739  {
1740  pPg->InvalidateSize();
1741  pPg = pPg->GetNext();
1742  }
1743 }
1744 
1746 {
1747  OSL_ENSURE( GetCurrShell() && GetCurrShell()->GetViewOptions()->getBrowseMode(),
1748  "CalcBrowseWidth and not in BrowseView" );
1749 
1750  // The (minimal) with is determined from borders, tables and paint objects.
1751  // It is calculated based on the attributes. Thus, it is not relevant how wide they are
1752  // currently but only how wide they want to be.
1753  // Frames and paint objects inside other objects (frames, tables) do not count.
1754  // Borders and columns are not taken into account.
1755 
1756  SwFrame *pFrame = ContainsContent();
1757  while ( pFrame && !pFrame->IsInDocBody() )
1758  pFrame = static_cast<SwContentFrame*>(pFrame)->GetNextContentFrame();
1759  if ( !pFrame )
1760  return;
1761 
1762  mbBrowseWidthValid = true;
1764  mnBrowseWidth = (!comphelper::LibreOfficeKit::isActive() && pSh)? MINLAY + 2 * pSh->GetOut()-> PixelToLogic( pSh->GetBrowseBorder() ).Width(): MIN_BROWSE_WIDTH;
1765 
1766  do
1767  {
1768  if ( pFrame->IsInTab() )
1769  pFrame = pFrame->FindTabFrame();
1770 
1771  if ( pFrame->IsTabFrame() &&
1772  !static_cast<SwLayoutFrame*>(pFrame)->GetFormat()->GetFrameSize().GetWidthPercent() )
1773  {
1774  SwBorderAttrAccess aAccess( SwFrame::GetCache(), pFrame );
1775  const SwBorderAttrs &rAttrs = *aAccess.Get();
1776  const SwFormatHoriOrient &rHori = rAttrs.GetAttrSet().GetHoriOrient();
1777  long nWidth = rAttrs.GetSize().Width();
1778  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)
1779  text::HoriOrientation::FULL != rHori.GetHoriOrient() )
1780  {
1781  const SwHTMLTableLayout *pLayoutInfo =
1782  static_cast<const SwTabFrame *>(pFrame)->GetTable()
1783  ->GetHTMLTableLayout();
1784  if ( pLayoutInfo )
1785  nWidth = std::min( nWidth, pLayoutInfo->GetBrowseWidthMin() );
1786 
1787  switch ( rHori.GetHoriOrient() )
1788  {
1790  // OD 23.01.2003 #106895# - add 1st param to <SwBorderAttrs::CalcRight(..)>
1791  nWidth += rAttrs.CalcLeft( pFrame ) + rAttrs.CalcRight( pFrame );
1792  break;
1793  case text::HoriOrientation::LEFT_AND_WIDTH:
1794  nWidth += rAttrs.CalcLeft( pFrame );
1795  break;
1796  default:
1797  break;
1798  }
1799  mnBrowseWidth = std::max( mnBrowseWidth, nWidth );
1800  }
1801  }
1802  else if ( pFrame->GetDrawObjs() )
1803  {
1804  for ( size_t i = 0; i < pFrame->GetDrawObjs()->size(); ++i )
1805  {
1806  // #i28701#
1807  SwAnchoredObject* pAnchoredObj = (*pFrame->GetDrawObjs())[i];
1808  const SwFrameFormat& rFormat = pAnchoredObj->GetFrameFormat();
1809  const bool bFly = dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr;
1810  if ((bFly && (FAR_AWAY == pAnchoredObj->GetObjRect().Width()))
1811  || rFormat.GetFrameSize().GetWidthPercent())
1812  {
1813  continue;
1814  }
1815 
1816  long nWidth = 0;
1817  switch ( rFormat.GetAnchor().GetAnchorId() )
1818  {
1819  case RndStdIds::FLY_AS_CHAR:
1820  nWidth = bFly ? rFormat.GetFrameSize().GetWidth() :
1821  pAnchoredObj->GetObjRect().Width();
1822  break;
1823  case RndStdIds::FLY_AT_PARA:
1824  {
1825  // #i33170#
1826  // Reactivated old code because
1827  // nWidth = pAnchoredObj->GetObjRect().Right()
1828  // gives wrong results for objects that are still
1829  // at position FAR_AWAY.
1830  if ( bFly )
1831  {
1832  nWidth = rFormat.GetFrameSize().GetWidth();
1833  const SwFormatHoriOrient &rHori = rFormat.GetHoriOrient();
1834  switch ( rHori.GetHoriOrient() )
1835  {
1837  nWidth += rHori.GetPos();
1838  break;
1839  case text::HoriOrientation::INSIDE:
1840  case text::HoriOrientation::LEFT:
1841  if ( text::RelOrientation::PRINT_AREA == rHori.GetRelationOrient() )
1842  nWidth += pFrame->getFramePrintArea().Left();
1843  break;
1844  default:
1845  break;
1846  }
1847  }
1848  else
1849  // Paint objects to not have attributes and
1850  // are defined by their current size
1851  nWidth = pAnchoredObj->GetObjRect().Right() -
1852  pAnchoredObj->GetDrawObj()->GetAnchorPos().X();
1853  }
1854  break;
1855  default: /* do nothing */;
1856  }
1857  mnBrowseWidth = std::max( mnBrowseWidth, nWidth );
1858  }
1859  }
1860  pFrame = pFrame->FindNextCnt();
1861  } while ( pFrame );
1862 }
1863 
1865 {
1866  if ( GetCurrShell() )
1867  for(SwViewShell& rSh : GetCurrShell()->GetRingContainer())
1868  {
1869  if ( dynamic_cast<const SwCursorShell*>( &rSh) != nullptr )
1870  static_cast<SwCursorShell*>(&rSh)->StartAction();
1871  else
1872  rSh.StartAction();
1873  }
1874 }
1875 
1876 void SwRootFrame::EndAllAction( bool bVirDev )
1877 {
1878  if ( GetCurrShell() )
1879  for(SwViewShell& rSh : GetCurrShell()->GetRingContainer())
1880  {
1881  const bool bOldEndActionByVirDev = rSh.IsEndActionByVirDev();
1882  rSh.SetEndActionByVirDev( bVirDev );
1883  if ( dynamic_cast<const SwCursorShell*>( &rSh) != nullptr )
1884  {
1885  static_cast<SwCursorShell*>(&rSh)->EndAction();
1886  static_cast<SwCursorShell*>(&rSh)->CallChgLnk();
1887  if ( dynamic_cast<const SwFEShell*>( &rSh) != nullptr )
1888  static_cast<SwFEShell*>(&rSh)->SetChainMarker();
1889  }
1890  else
1891  rSh.EndAction();
1892  rSh.SetEndActionByVirDev( bOldEndActionByVirDev );
1893  }
1894 }
1895 
1897 {
1898  if ( GetCurrShell() )
1899  for(SwViewShell& rSh : GetCurrShell()->GetRingContainer())
1900  {
1901  // #i84729#
1902  // No end action, if <SwViewShell> instance is currently in its end action.
1903  // Recursives calls to <::EndAction()> are not allowed.
1904  if ( !rSh.IsInEndAction() )
1905  {
1906  OSL_ENSURE(!rSh.GetRestoreActions(), "Restore action count is already set!");
1907  bool bCursor = dynamic_cast<const SwCursorShell*>( &rSh) != nullptr;
1908  bool bFE = dynamic_cast<const SwFEShell*>( &rSh) != nullptr;
1909  sal_uInt16 nRestore = 0;
1910  while( rSh.ActionCount() )
1911  {
1912  if( bCursor )
1913  {
1914  static_cast<SwCursorShell*>(&rSh)->EndAction();
1915  static_cast<SwCursorShell*>(&rSh)->CallChgLnk();
1916  if ( bFE )
1917  static_cast<SwFEShell*>(&rSh)->SetChainMarker();
1918  }
1919  else
1920  rSh.EndAction();
1921  nRestore++;
1922  }
1923  rSh.SetRestoreActions(nRestore);
1924  }
1925  rSh.LockView(true);
1926  }
1927 }
1928 
1930 {
1931  if ( GetCurrShell() )
1932  for(SwViewShell& rSh : GetCurrShell()->GetRingContainer())
1933  {
1934  sal_uInt16 nActions = rSh.GetRestoreActions();
1935  while( nActions-- )
1936  {
1937  if ( dynamic_cast<const SwCursorShell*>( &rSh) != nullptr )
1938  static_cast<SwCursorShell*>(&rSh)->StartAction();
1939  else
1940  rSh.StartAction();
1941  }
1942  rSh.SetRestoreActions(0);
1943  rSh.LockView(false);
1944  }
1945 }
1946 
1947 // Helper functions for SwRootFrame::CheckViewLayout
1948 static void lcl_MoveAllLowers( SwFrame* pFrame, const Point& rOffset );
1949 
1950 static void lcl_MoveAllLowerObjs( SwFrame* pFrame, const Point& rOffset )
1951 {
1952  const bool bPage = pFrame->IsPageFrame();
1953  const SwSortedObjs* pSortedObj = bPage
1954  ? static_cast<SwPageFrame*>(pFrame)->GetSortedObjs()
1955  : pFrame->GetDrawObjs();
1956  if (pSortedObj == nullptr)
1957  return;
1958 
1959  // note: pSortedObj elements may be removed and inserted from
1960  // MoveObjectIfActive(), invalidating iterators
1961  // DO NOT CONVERT THIS TO A C++11 FOR LOOP, IT DID NOT WORK THE LAST 2 TIMES
1962  for (size_t i = 0; i < pSortedObj->size(); ++i)
1963  {
1964  SwAnchoredObject *const pAnchoredObj = (*pSortedObj)[i];
1965  const SwFrameFormat& rObjFormat = pAnchoredObj->GetFrameFormat();
1966  const SwFormatAnchor& rAnchor = rObjFormat.GetAnchor();
1967 
1968  // all except from the as character anchored objects are moved
1969  // when processing the page frame:
1970  if ( !bPage && (rAnchor.GetAnchorId() != RndStdIds::FLY_AS_CHAR) )
1971  continue;
1972 
1973  SwObjPositioningInProgress aPosInProgress( *pAnchoredObj );
1974 
1975  if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
1976  {
1977  SwFlyFrame* pFlyFrame( static_cast<SwFlyFrame*>(pAnchoredObj) );
1978  lcl_MoveAllLowers( pFlyFrame, rOffset );
1979  pFlyFrame->NotifyDrawObj();
1980  // --> let the active embedded object be moved
1981  SwFrame* pLower = pFlyFrame->Lower();
1982  if ( pLower && pLower->IsNoTextFrame() )
1983  {
1984  SwRootFrame* pRoot = pLower->getRootFrame();
1985  SwViewShell *pSh = pRoot ? pRoot->GetCurrShell() : nullptr;
1986  if ( pSh )
1987  {
1988  SwNoTextFrame *const pContentFrame = static_cast<SwNoTextFrame*>(pLower);
1989  SwOLENode* pNode = pContentFrame->GetNode()->GetOLENode();
1990  if ( pNode )
1991  {
1992  svt::EmbeddedObjectRef& xObj = pNode->GetOLEObj().GetObject();
1993  if ( xObj.is() )
1994  {
1995  for(SwViewShell& rSh : pSh->GetRingContainer())
1996  {
1997  SwFEShell* pFEShell = dynamic_cast< SwFEShell* >( &rSh );
1998  if ( pFEShell )
1999  pFEShell->MoveObjectIfActive( xObj, rOffset );
2000  }
2001  }
2002  }
2003  }
2004  }
2005  }
2006  else if ( dynamic_cast< const SwAnchoredDrawObject *>( pAnchoredObj ) != nullptr )
2007  {
2008  SwAnchoredDrawObject* pAnchoredDrawObj( static_cast<SwAnchoredDrawObject*>(pAnchoredObj) );
2009 
2010  // don't touch objects that are not yet positioned:
2011  if ( pAnchoredDrawObj->NotYetPositioned() )
2012  continue;
2013 
2014  const Point& aCurrAnchorPos = pAnchoredDrawObj->GetDrawObj()->GetAnchorPos();
2015  const Point aNewAnchorPos( aCurrAnchorPos + rOffset );
2016  pAnchoredDrawObj->DrawObj()->SetAnchorPos( aNewAnchorPos );
2017  pAnchoredDrawObj->SetLastObjRect( pAnchoredDrawObj->GetObjRect().SVRect() );
2018 
2019  // clear contour cache
2020  if ( pAnchoredDrawObj->GetFrameFormat().GetSurround().IsContour() )
2021  ClrContourCache( pAnchoredDrawObj->GetDrawObj() );
2022  }
2023  // #i92511#
2024  // cache for object rectangle inclusive spaces has to be invalidated.
2025  pAnchoredObj->InvalidateObjRectWithSpaces();
2026  }
2027 }
2028 
2029 static void lcl_MoveAllLowers( SwFrame* pFrame, const Point& rOffset )
2030 {
2031  const SwRect aFrame( pFrame->getFrameArea() );
2032 
2033  // first move the current frame
2034  // RotateFlyFrame3: moved to transform_translate instead of
2035  // direct modification to allow the SwFrame evtl. needed own reactions
2036  pFrame->transform_translate(rOffset);
2037 
2038  // Don't forget accessibility:
2039  if( pFrame->IsAccessibleFrame() )
2040  {
2041  SwRootFrame *pRootFrame = pFrame->getRootFrame();
2042  if( pRootFrame && pRootFrame->IsAnyShellAccessible() &&
2043  pRootFrame->GetCurrShell() )
2044  {
2045  pRootFrame->GetCurrShell()->Imp()->MoveAccessibleFrame( pFrame, aFrame );
2046  }
2047  }
2048 
2049  // the move any objects
2050  lcl_MoveAllLowerObjs( pFrame, rOffset );
2051 
2052  // finally, for layout frames we have to call this function recursively:
2053  if ( dynamic_cast< const SwLayoutFrame *>( pFrame ) != nullptr )
2054  {
2055  SwFrame* pLowerFrame = pFrame->GetLower();
2056  while ( pLowerFrame )
2057  {
2058  lcl_MoveAllLowers( pLowerFrame, rOffset );
2059  pLowerFrame = pLowerFrame->GetNext();
2060  }
2061  }
2062 }
2063 
2064 // Calculate how the pages have to be positioned
2065 void SwRootFrame::CheckViewLayout( const SwViewOption* pViewOpt, const SwRect* pVisArea )
2066 {
2067  SwViewShell* pSh = GetCurrShell();
2068  vcl::RenderContext* pRenderContext = pSh ? pSh->GetOut() : nullptr;
2069  // #i91432#
2070  // No calculation of page positions, if only an empty page is present.
2071  // This situation occurs when <SwRootFrame> instance is in construction
2072  // and the document contains only left pages.
2073  if ( Lower()->GetNext() == nullptr &&
2074  static_cast<SwPageFrame*>(Lower())->IsEmptyPage() )
2075  {
2076  return;
2077  }
2078 
2079  if ( !pVisArea )
2080  {
2081  // no early return for bNewPage
2082  if ( mnViewWidth < 0 )
2083  mnViewWidth = 0;
2084  }
2085  else
2086  {
2087  assert(pViewOpt && "CheckViewLayout required ViewOptions");
2088 
2089  const sal_uInt16 nColumns = pViewOpt->GetViewLayoutColumns();
2090  const bool bBookMode = pViewOpt->IsViewLayoutBookMode();
2091 
2092  if ( nColumns == mnColumns && bBookMode == mbBookMode && pVisArea->Width() == mnViewWidth && !mbSidebarChanged )
2093  return;
2094 
2095  mnColumns = nColumns;
2096  mbBookMode = bBookMode;
2097  mnViewWidth = pVisArea->Width();
2098  mbSidebarChanged = false;
2099  }
2100 
2101  if( GetFormat()->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE ) )
2102  {
2103  mnColumns = 1;
2104  mbBookMode = false;
2105  }
2106 
2107  Calc(pRenderContext);
2108 
2109  const bool bOldCallbackActionEnabled = IsCallbackActionEnabled();
2110  SetCallbackActionEnabled( false );
2111 
2112  maPageRects.clear();
2113 
2114  const long nBorder = getFrameArea().Pos().getX();
2115  const long nVisWidth = mnViewWidth - 2 * nBorder;
2116  const long nGapBetweenPages = pViewOpt ? pViewOpt->GetGapBetweenPages()
2117  : (pSh ? pSh->GetViewOptions()->GetGapBetweenPages()
2119 
2120  // check how many pages fit into the first page layout row:
2121  SwPageFrame* pPageFrame = static_cast<SwPageFrame*>(Lower());
2122 
2123  // will contain the number of pages per row. 0 means that
2124  // the page does not fit.
2125  long nWidthRemain = nVisWidth;
2126 
2127  // after one row has been processed, these variables contain
2128  // the width of the row and the maximum of the page heights
2129  long nCurrentRowHeight = 0;
2130  long nCurrentRowWidth = 0;
2131 
2132  // these variables are used to finally set the size of the
2133  // root frame
2134  long nSumRowHeight = 0;
2135  SwTwips nMinPageLeft = TWIPS_MAX;
2136  SwTwips nMaxPageRight = 0;
2137  SwPageFrame* pStartOfRow = pPageFrame;
2138  sal_uInt16 nNumberOfPagesInRow = mbBookMode ? 1 : 0; // in book view, start with right page
2139  bool bFirstRow = true;
2140 
2141  bool bPageChanged = false;
2142  const bool bRTL = !IsLeftToRightViewLayout();
2143  const SwTwips nSidebarWidth = SwPageFrame::GetSidebarBorderWidth( pSh );
2144 
2145  while ( pPageFrame )
2146  {
2147  // we consider the current page to be "start of row" if
2148  // 1. it is the first page in the current row or
2149  // 2. it is the second page in the row and the first page is an empty page in non-book view:
2150  const bool bStartOfRow = pPageFrame == pStartOfRow ||
2151  ( pStartOfRow->IsEmptyPage() && pPageFrame == pStartOfRow->GetNext() && !mbBookMode );
2152 
2153  const bool bEmptyPage = pPageFrame->IsEmptyPage() && !mbBookMode;
2154 
2155  // no half doc border space for first page in each row and
2156  long nPageWidth = 0;
2157  long nPageHeight = 0;
2158 
2159  if ( mbBookMode )
2160  {
2161  const SwFrame& rFormatPage = pPageFrame->GetFormatPage();
2162 
2163  nPageWidth = rFormatPage.getFrameArea().Width() + nSidebarWidth + ((bStartOfRow || 1 == (pPageFrame->GetPhyPageNum()%2)) ? 0 : nGapBetweenPages);
2164  nPageHeight = rFormatPage.getFrameArea().Height() + nGapBetweenPages;
2165  }
2166  else
2167  {
2168  if ( !pPageFrame->IsEmptyPage() )
2169  {
2170  nPageWidth = pPageFrame->getFrameArea().Width() + nSidebarWidth + (bStartOfRow ? 0 : nGapBetweenPages);
2171  nPageHeight = pPageFrame->getFrameArea().Height() + nGapBetweenPages;
2172  }
2173  }
2174 
2175  if ( !bEmptyPage )
2176  ++nNumberOfPagesInRow;
2177 
2178  // finish current row if
2179  // 1. in dynamic mode the current page does not fit anymore or
2180  // 2. the current page exceeds the maximum number of columns
2181  bool bRowFinished = (0 == mnColumns && nWidthRemain < nPageWidth ) ||
2182  (0 != mnColumns && mnColumns < nNumberOfPagesInRow);
2183 
2184  // make sure that at least one page goes to the current row:
2185  if ( !bRowFinished || bStartOfRow )
2186  {
2187  // current page is allowed to be in current row
2188  nWidthRemain = nWidthRemain - nPageWidth;
2189 
2190  nCurrentRowWidth = nCurrentRowWidth + nPageWidth;
2191  nCurrentRowHeight = std::max( nCurrentRowHeight, nPageHeight );
2192 
2193  pPageFrame = static_cast<SwPageFrame*>(pPageFrame->GetNext());
2194 
2195  if ( !pPageFrame )
2196  bRowFinished = true;
2197  }
2198 
2199  if ( bRowFinished )
2200  {
2201  // pPageFrame now points to the first page in the new row or null
2202  // pStartOfRow points to the first page in the current row
2203 
2204  // special centering for last row. pretend to fill the last row with virtual copies of the last page before centering:
2205  if ( !pPageFrame && nWidthRemain > 0 )
2206  {
2207  // find last page in current row:
2208  const SwPageFrame* pLastPageInCurrentRow = pStartOfRow;
2209  while( pLastPageInCurrentRow->GetNext() )
2210  pLastPageInCurrentRow = static_cast<const SwPageFrame*>(pLastPageInCurrentRow->GetNext());
2211 
2212  if ( pLastPageInCurrentRow->IsEmptyPage() )
2213  pLastPageInCurrentRow = static_cast<const SwPageFrame*>(pLastPageInCurrentRow->GetPrev());
2214 
2215  // check how many times the last page would still fit into the remaining space:
2216  sal_uInt16 nNumberOfVirtualPages = 0;
2217  const sal_uInt16 nMaxNumberOfVirtualPages = mnColumns > 0 ? mnColumns - nNumberOfPagesInRow : USHRT_MAX;
2218  SwTwips nRemain = nWidthRemain;
2219  SwTwips nVirtualPagesWidth = 0;
2220  SwTwips nLastPageWidth = pLastPageInCurrentRow->getFrameArea().Width() + nSidebarWidth;
2221 
2222  while ( ( mnColumns > 0 || nRemain > 0 ) && nNumberOfVirtualPages < nMaxNumberOfVirtualPages )
2223  {
2224  SwTwips nLastPageWidthWithGap = nLastPageWidth;
2225  if ( !mbBookMode || ( 0 == (nNumberOfVirtualPages + nNumberOfPagesInRow) %2) )
2226  nLastPageWidthWithGap += nGapBetweenPages;
2227 
2228  if ( mnColumns > 0 || nLastPageWidthWithGap < nRemain )
2229  {
2230  ++nNumberOfVirtualPages;
2231  nVirtualPagesWidth += nLastPageWidthWithGap;
2232  }
2233  nRemain = nRemain - nLastPageWidthWithGap;
2234  }
2235 
2236  nCurrentRowWidth = nCurrentRowWidth + nVirtualPagesWidth;
2237  }
2238 
2239  // first page in book mode is always special:
2240  if ( bFirstRow && mbBookMode )
2241  {
2242  // #i88036#
2243  nCurrentRowWidth +=
2244  pStartOfRow->GetFormatPage().getFrameArea().Width() + nSidebarWidth;
2245  }
2246 
2247  // center page if possible
2248  long nSizeDiff = 0;
2249  if (nVisWidth > nCurrentRowWidth && !comphelper::LibreOfficeKit::isActive())
2250  nSizeDiff = ( nVisWidth - nCurrentRowWidth ) / 2;
2251 
2252  // adjust positions of pages in current row
2253  long nX = nSizeDiff;
2254 
2255  const long nRowStart = nBorder + nSizeDiff;
2256  const long nRowEnd = nRowStart + nCurrentRowWidth;
2257 
2258  if ( bFirstRow && mbBookMode )
2259  {
2260  // #i88036#
2261  nX += pStartOfRow->GetFormatPage().getFrameArea().Width() + nSidebarWidth;
2262  }
2263 
2264  SwPageFrame* pEndOfRow = pPageFrame;
2265  SwPageFrame* pPageToAdjust = pStartOfRow;
2266 
2267  do
2268  {
2269  const SwPageFrame* pFormatPage = pPageToAdjust;
2270  if ( mbBookMode )
2271  pFormatPage = &pPageToAdjust->GetFormatPage();
2272 
2273  const SwTwips nCurrentPageWidth = pFormatPage->getFrameArea().Width() + (pFormatPage->IsEmptyPage() ? 0 : nSidebarWidth);
2274  const Point aOldPagePos = pPageToAdjust->getFrameArea().Pos();
2275  const bool bLeftSidebar = pPageToAdjust->SidebarPosition() == sw::sidebarwindows::SidebarPosition::LEFT;
2276  const SwTwips nLeftPageAddOffset = bLeftSidebar ?
2277  nSidebarWidth :
2278  0;
2279 
2280  Point aNewPagePos( nBorder + nX, nBorder + nSumRowHeight );
2281  Point aNewPagePosWithLeftOffset( nBorder + nX + nLeftPageAddOffset, nBorder + nSumRowHeight );
2282 
2283  // RTL view layout: Calculate mirrored page position
2284  if ( bRTL )
2285  {
2286  const long nXOffsetInRow = aNewPagePos.getX() - nRowStart;
2287  aNewPagePos.setX(nRowEnd - nXOffsetInRow - nCurrentPageWidth);
2288  aNewPagePosWithLeftOffset = aNewPagePos;
2289  aNewPagePosWithLeftOffset.setX(aNewPagePosWithLeftOffset.getX() + nLeftPageAddOffset);
2290  }
2291 
2292  if ( aNewPagePosWithLeftOffset != aOldPagePos )
2293  {
2294  lcl_MoveAllLowers( pPageToAdjust, aNewPagePosWithLeftOffset - aOldPagePos );
2295  pPageToAdjust->SetCompletePaint();
2296  bPageChanged = true;
2297  }
2298 
2299  // calculate area covered by the current page and store to
2300  // maPageRects. This is used e.g., for cursor setting
2301  const bool bFirstColumn = pPageToAdjust == pStartOfRow;
2302  const bool bLastColumn = pPageToAdjust->GetNext() == pEndOfRow;
2303  const bool bLastRow = !pEndOfRow;
2304 
2305  nMinPageLeft = std::min( nMinPageLeft, aNewPagePos.getX() );
2306  nMaxPageRight = std::max( nMaxPageRight, aNewPagePos.getX() + nCurrentPageWidth);
2307 
2308  // border of nGapBetweenPages around the current page:
2309  SwRect aPageRectWithBorders( aNewPagePos.getX() - nGapBetweenPages,
2310  aNewPagePos.getY(),
2311  pPageToAdjust->getFrameArea().SSize().Width() + nGapBetweenPages + nSidebarWidth,
2312  nCurrentRowHeight );
2313 
2314  static const long nOuterClickDiff = 1000000;
2315 
2316  // adjust borders for these special cases:
2317  if ( (bFirstColumn && !bRTL) || (bLastColumn && bRTL) )
2318  aPageRectWithBorders.SubLeft( nOuterClickDiff );
2319  if ( (bLastColumn && !bRTL) || (bFirstColumn && bRTL) )
2320  aPageRectWithBorders.AddRight( nOuterClickDiff );
2321  if ( bFirstRow )
2322  aPageRectWithBorders.SubTop( nOuterClickDiff );
2323  if ( bLastRow )
2324  aPageRectWithBorders.AddBottom( nOuterClickDiff );
2325 
2326  maPageRects.push_back( aPageRectWithBorders );
2327 
2328  nX = nX + nCurrentPageWidth;
2329  pPageToAdjust = static_cast<SwPageFrame*>(pPageToAdjust->GetNext());
2330 
2331  // distance to next page
2332  if ( pPageToAdjust && pPageToAdjust != pEndOfRow )
2333  {
2334  // in book view, we add the x gap before left (even) pages:
2335  if ( mbBookMode )
2336  {
2337  if ( 0 == (pPageToAdjust->GetPhyPageNum()%2) )
2338  nX = nX + nGapBetweenPages;
2339  }
2340  else
2341  {
2342  // in non-book view, don't add x gap before
2343  // 1. the last empty page in a row
2344  // 2. after an empty page
2345  const bool bDontAddGap = ( pPageToAdjust->IsEmptyPage() && pPageToAdjust->GetNext() == pEndOfRow ) ||
2346  ( static_cast<SwPageFrame*>(pPageToAdjust->GetPrev())->IsEmptyPage() );
2347 
2348  if ( !bDontAddGap )
2349  nX = nX + nGapBetweenPages;
2350  }
2351  }
2352  }
2353  while (pPageToAdjust && pPageToAdjust != pEndOfRow);
2354 
2355  // adjust values for root frame size
2356  nSumRowHeight = nSumRowHeight + nCurrentRowHeight;
2357 
2358  // start new row:
2359  nCurrentRowHeight = 0;
2360  nCurrentRowWidth = 0;
2361  pStartOfRow = pEndOfRow;
2362  nWidthRemain = nVisWidth;
2363  nNumberOfPagesInRow = 0;
2364  bFirstRow = false;
2365  } // end row finished
2366  } // end while
2367 
2368  // set size of root frame:
2369  const Size aOldSize( getFrameArea().SSize() );
2370  const Size aNewSize( nMaxPageRight - nBorder, nSumRowHeight - nGapBetweenPages );
2371 
2372  if ( bPageChanged || aNewSize != aOldSize )
2373  {
2374  ChgSize( aNewSize );
2375  ::AdjustSizeChgNotify( this );
2376  Calc(pRenderContext);
2377 
2378  if ( pSh && pSh->GetDoc()->GetDocShell() )
2379  {
2380  pSh->SetFirstVisPageInvalid();
2381  if (bOldCallbackActionEnabled)
2382  {
2384  pSh->GetDoc()->GetDocShell()->Broadcast(SfxHint(SfxHintId::DocChanged));
2385  }
2386  }
2387  }
2388 
2390  maPagesArea.SSize( aNewSize );
2391  if ( TWIPS_MAX != nMinPageLeft )
2392  maPagesArea.Left_( nMinPageLeft );
2393 
2394  SetCallbackActionEnabled( bOldCallbackActionEnabled );
2395 }
2396 
2398 {
2399  // Layout direction determined by layout direction of the first page.
2400  // #i88036#
2401  // Only ask a non-empty page frame for its layout direction
2402  assert(dynamic_cast<const SwPageFrame *>(Lower()) != nullptr);
2403  const SwPageFrame& rPage = static_cast<const SwPageFrame&>(*Lower()).GetFormatPage();
2404  return !rPage.IsRightToLeft() && !rPage.IsVertical();
2405 }
2406 
2408 {
2409  const SwPageFrame* pRet = this;
2410  if ( IsEmptyPage() )
2411  {
2412  pRet = static_cast<const SwPageFrame*>( OnRightPage() ? GetNext() : GetPrev() );
2413  // #i88035#
2414  // Typically a right empty page frame has a next non-empty page frame and
2415  // a left empty page frame has a previous non-empty page frame.
2416  // But under certain circumstances this assumption is not true -
2417  // e.g. during insertion of a left page at the end of the document right
2418  // after a left page in an intermediate state a right empty page does not
2419  // have a next page frame.
2420  if ( pRet == nullptr )
2421  {
2422  if ( OnRightPage() )
2423  {
2424  pRet = static_cast<const SwPageFrame*>( GetPrev() );
2425  }
2426  else
2427  {
2428  pRet = static_cast<const SwPageFrame*>( GetNext() );
2429  }
2430  }
2431  assert(pRet &&
2432  "<SwPageFrame::GetFormatPage()> - inconsistent layout: empty page without previous and next page frame --> crash.");
2433  }
2434  return *pRet;
2435 }
2436 
2438 {
2439  long nUpperLimit = 0;
2440  long nLowerLimit = 0;
2441  const SwFrame* pFrame = Lower();
2442  while ( pFrame )
2443  {
2444  if ( pFrame->IsBodyFrame() )
2445  {
2446  nUpperLimit = pFrame->getFrameArea().Top();
2447  nLowerLimit = pFrame->getFrameArea().Bottom();
2448  }
2449  else if ( pFrame->IsFootnoteContFrame() )
2450  nLowerLimit = pFrame->getFrameArea().Bottom();
2451 
2452  pFrame = pFrame->GetNext();
2453  }
2454 
2455  SwRect aHeaderArea( getFrameArea().TopLeft(),
2456  Size( getFrameArea().Width(), nUpperLimit - getFrameArea().Top() ) );
2457 
2458  SwViewShell* pViewShell = getRootFrame()->GetCurrShell();
2459  const bool bHideWhitespaceMode = pViewShell->GetViewOptions()->IsHideWhitespaceMode();
2460  if ( aHeaderArea.IsInside( rPt ) )
2461  {
2462  if (!bHideWhitespaceMode || static_cast<const SwFrameFormat*>(GetDep())->GetHeader().IsActive())
2463  {
2464  rControl = Header;
2465  return true;
2466  }
2467  }
2468  else
2469  {
2470  SwRect aFooterArea( Point( getFrameArea().Left(), nLowerLimit ),
2471  Size( getFrameArea().Width(), getFrameArea().Bottom() - nLowerLimit ) );
2472 
2473  if ( aFooterArea.IsInside( rPt ) &&
2474  (!bHideWhitespaceMode || static_cast<const SwFrameFormat*>(GetDep())->GetFooter().IsActive()) )
2475  {
2476  rControl = Footer;
2477  return true;
2478  }
2479  }
2480 
2481  return false;
2482 }
2483 
2485 {
2486  SwViewShell* pShell = getRootFrame()->GetCurrShell();
2487  if (pShell && pShell->GetViewOptions()->IsWhitespaceHidden())
2488  {
2489  // When whitespace is hidden, the page frame has two heights: the
2490  // nominal (defined by the frame format), and the actual (which is
2491  // at most the nominal height, but can be smaller in case there is
2492  // no content for the whole page).
2493  // The layout size is the actual one, but we want to move the
2494  // content frame to a new page only in case it doesn't fit the
2495  // nominal size.
2496  if (nDiff < 0)
2497  {
2498  // Content frame doesn't fit the actual size, check if it fits the nominal one.
2499  const SwFrameFormat* pPageFormat = static_cast<const SwFrameFormat*>(GetDep());
2500  const Size& rPageSize = pPageFormat->GetFrameSize().GetSize();
2501  long nWhitespace = rPageSize.getHeight() - getFrameArea().Height();
2502  if (nWhitespace > -nDiff)
2503  {
2504  // It does: don't move it and invalidate our page frame so
2505  // that it gets a larger height.
2506  return false;
2507  }
2508  }
2509  }
2510 
2511  return true;
2512 }
2513 
2514 SwTextGridItem const* GetGridItem(SwPageFrame const*const pPage)
2515 {
2516  if (pPage && pPage->HasGrid())
2517  {
2518  SwTextGridItem const& rGridItem(
2519  pPage->GetPageDesc()->GetMaster().GetTextGrid());
2520  if (GRID_NONE != rGridItem.GetGridType())
2521  {
2522  return &rGridItem;
2523  }
2524  }
2525  return nullptr;
2526 }
2527 
2528 sal_uInt16 GetGridWidth(SwTextGridItem const& rG, SwDoc const& rDoc)
2529 {
2530  return (rDoc.IsSquaredPageMode()) ? rG.GetBaseHeight() : rG.GetBaseWidth();
2531 }
2532 
2533 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void InsertBefore(SwLayoutFrame *pParent, SwFrame *pBehind)
Insert SwFrame into existing structure.
Definition: wsfrm.cxx:820
static SwTwips GetSidebarBorderWidth(const SwViewShell *)
Definition: paintfrm.cxx:6084
bool IsAnLower(const SwFrame *) const
Definition: findfrm.cxx:206
vcl::RenderContext * GetOut() const
Definition: viewsh.hxx:341
void SetPageDesc(SwPageDesc *, SwFrameFormat *)
Definition: pagechg.cxx:729
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:2429
long GetBrowseWidthMin() const
Definition: htmltbl.hxx:426
#define RES_FRM_SIZE
Definition: hintids.hxx:196
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:2437
#define RES_COL
Definition: hintids.hxx:216
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:745
SwContentFrame * GetNextContentFrame() const
Definition: cntfrm.hxx:98
bool IsInDocBody() const
Definition: frame.hxx:919
#define RES_HEADER
Definition: hintids.hxx:203
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:901
SwOLENode * GetOLENode()
Inline methods from Node.hxx.
Definition: ndole.hxx:161
#define RES_AUTOFMT_DOCNODE
Definition: hintids.hxx:297
bool IsAnyShellAccessible() const
Definition: rootfrm.hxx:384
#define RES_ATTRSET_CHG
Definition: hintids.hxx:287
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:1592
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:1002
const SwFormatHeader & GetHeader(bool=true) const
Definition: fmthdft.hxx:97
sal_uInt16 GetBaseWidth() const
Definition: tgrditem.hxx:97
SwDocShell * GetDocShell()
Definition: doc.hxx:1342
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:227
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:2611
void SetMaxFootnoteHeight(const SwTwips nNewMax)
Definition: ftnboss.hxx:74
bool IsLeftToRightViewLayout() const
Definition: pagechg.cxx:2397
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:2407
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:1372
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: wsfrm.cxx:1296
#define TWIPS_MAX
Definition: swtypes.hxx:53
long SwTwips
Definition: swtypes.hxx:49
SwTextGridItem const * GetGridItem(SwPageFrame const *const pPage)
Definition: pagechg.cxx:2514
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:1787
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:1696
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:1514
SwContentFrame * FindFirstBodyContent()
Definition: pagefrm.hxx:333
long CalcRight(const SwFrame *pCaller) const
Definition: frmtool.cxx:2107
virtual const SwFormatPageDesc & GetPageDescItem() const
Definition: findfrm.cxx:659
void PrepareRegisterChg()
Definition: pagechg.cxx:964
static SwFlowFrame * CastFlowFrame(SwFrame *pFrame)
Definition: flowfrm.cxx:2622
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:170
bool m_bInvalidLayout
Definition: pagefrm.hxx:52
virtual SwTwips ShrinkFrame(SwTwips, bool bTst=false, bool bInfo=false) override
Definition: pagechg.cxx:1402
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:154
bool IsActive() const
Definition: fmthdft.hxx:89
void CheckViewLayout(const SwViewOption *pViewOpt, const SwRect *pVisArea)
Definition: pagechg.cxx:2065
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:90
bool AddPaintRect(const SwRect &rRect)
Definition: viewsh.cxx:536
std::vector< SwRect > maPageRects
Definition: rootfrm.hxx:91
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:356
long CalcLeft(const SwFrame *pCaller) const
Definition: frmtool.cxx:2155
const SwPageFootnoteInfo & GetFootnoteInfo() const
Definition: pagedesc.hxx:196
bool WannaRightPage() const
Decides if the page want to be a rightpage or not.
Definition: trvlfrm.cxx:1705
bool HasGrid() const
Definition: pagefrm.hxx:172
const SfxPoolItem * NextItem()
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:428
void AppendFly(SwFlyFrame *pNew)
Definition: fly.cxx:2128
SwFrameControlsManager & GetFrameControlsManager()
Definition: edtwin.cxx:6443
void Top(const long nTop)
Definition: swrect.hxx:202
void UnoRestoreAllActions()
Definition: pagechg.cxx:1929
const SwFrame * GetAnchorFrame(const SdrObject *_pDrawObj=nullptr) const
Definition: dcontact.cxx:781
const SwRect & getFrameArea() const
Definition: frame.hxx:175
void setX(long nX)
SwFootnoteContFrame * FindFootnoteCont()
Definition: ftnfrm.cxx:965
bool getBrowseMode() const
Definition: viewopt.hxx:433
virtual Size ChgSize(const Size &aNewSize)
Definition: wsfrm.cxx:721
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:61
sal_uInt16 GetGridWidth(SwTextGridItem const &rG, SwDoc const &rDoc)
Definition: pagechg.cxx:2528
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:812
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:942
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
bool IsAssertFlyPages() const
Definition: rootfrm.hxx:277
Base class for various Writer styles.
Definition: format.hxx:43
long getY() const
sal_uInt16 GetVirtPageNum() const
Definition: trvlfrm.cxx:1805
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:1734
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:2484
void RemoveFly(SwFlyFrame *pToRemove)
Definition: fly.cxx:2146
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:571
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:877
void ImplCalcBrowseWidth()
Definition: pagechg.cxx:1745
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:362
virtual void Cut() override
Definition: pagechg.cxx:836
const SwFrame * Lower() const
Definition: layfrm.hxx:101
SwContentFrame * FindNextCnt(const bool _bInSameFootnote=false)
Definition: findfrm.cxx:190
TElementType * First()
Definition: calbck.hxx:342
int i
SwPageDesc * GetPageDesc()
Definition: pagefrm.hxx:129
static void lcl_MoveAllLowers(SwFrame *pFrame, const Point &rOffset)
Definition: pagechg.cxx:2029
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:597
FlyAnchors.
Definition: fmtanchr.hxx:34
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:103
SwRemoveResult
Definition: rootfrm.hxx:66
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:1950
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:562
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:1391
void InvalidatePos_()
Definition: frame.hxx:765
SwPageDesc * m_pDesc
Definition: pagefrm.hxx:46
#define RES_FMT_CHG
Definition: hintids.hxx:286
A page of the document layout.
Definition: pagefrm.hxx:40
long X() const
bool IsLeftShadowNeeded() const
Definition: paintfrm.cxx:5659
void InvalidateWindows(const SwRect &rRect)
Definition: viewsh.cxx:552
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:2439
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:246
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:204
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:217
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:719
bool IsVertLR() const
Definition: frame.hxx:955
bool IsSquaredPageMode() const
Definition: docdesc.cxx:913
tools::Rectangle SVRect() const
Definition: swrect.hxx:282
#define RES_TEXTGRID
Definition: hintids.hxx:222
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:1428
bool mbFixSize
Definition: frame.hxx:409
virtual SwFrameFormat & GetFrameFormat()=0
void SetAgain()
Definition: layact.hxx:151
#define RES_DRAWFRMFMT
Definition: hintids.hxx:279
unsigned char sal_uInt8
void UnoRemoveAllActions()
Certain UNO Actions (e.g.
Definition: pagechg.cxx:1896
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:739
#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:369
bool IsNoTextFrame() const
Definition: frame.hxx:1214
bool m_bInvalidAutoCmplWrds
Definition: pagefrm.hxx:61
void RemoveFromLayout()
Definition: wsfrm.cxx:994
void RemoveFromDrawingPage()
Definition: dcontact.cxx:2249
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:1999
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:2186
bool OnFirstPage() const
Definition: trvlfrm.cxx:1759
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:1652
void DelFrameFormat(SwFrameFormat *pFormat, bool bBroadcast=false)
Definition: docfmt.cxx:683
void RemoveFromWriterLayout()
Definition: dcontact.cxx:2210
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:831
size_t size() const
Definition: docary.hxx:225
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: pagechg.cxx:898
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
Definition: layfrm.hxx:35
SwTextGrid GetGridType() const
Definition: tgrditem.hxx:81
Left
void RegistFlys(SwPageFrame *, const SwLayoutFrame *)
Definition: frmtool.cxx:2970
void StartAllAction()
Set up Start-/EndAction for all Shells on an as high as possible (Shell section) level.
Definition: pagechg.cxx:1864
long getHeight() const
const SwFrame * GetAnchorFrame() const
void SetFirstVisPageInvalid()
Definition: viewsh.cxx:1036
SwPageFrame * InsertPage(SwPageFrame *pSibling, bool bFootnote)
Definition: pagechg.cxx:1287
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:6042
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:587
void EndAllAction(bool bVirDev=false)
Definition: pagechg.cxx:1876
friend void AdjustSizeChgNotify(SwRootFrame *pRoot)
Definition: pagechg.cxx:812
#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:1416
bool IsBodyFrame() const
Definition: frame.hxx:1182
bool m_bInvalidSmartTags
Definition: pagefrm.hxx:60
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:204
virtual void MakeAll(vcl::RenderContext *pRenderContext) override
Definition: pagechg.cxx:1708
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:545
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:5646
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1476
virtual const SwFrameFormat * GetFormat() const
Definition: ssfrm.cxx:393
SwTabFrame * FindTabFrame()
Definition: frame.hxx:1075
SwFrame * GetNext()
Definition: frame.hxx:654