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