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