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