LibreOffice Module sw (master)  1
hffrm.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 <pagefrm.hxx>
21 #include <fmtcntnt.hxx>
22 #include <fmthdft.hxx>
23 #include <fmtfsize.hxx>
24 #include <viewopt.hxx>
25 #include <hffrm.hxx>
26 #include <rootfrm.hxx>
27 #include <txtfrm.hxx>
28 #include <sectfrm.hxx>
29 #include <flyfrm.hxx>
30 #include <frmtool.hxx>
31 #include <hfspacingitem.hxx>
32 #include <sortedobjs.hxx>
33 #include <objectformatter.hxx>
34 #include <ndindex.hxx>
35 #include <sal/log.hxx>
36 
38 {
39  const SwFormatFrameSize &rSz = rFrame.GetFormat()->GetFrameSize();
40  SwTwips nMinHeight;
41 
42  switch (rSz.GetHeightSizeType())
43  {
44  case ATT_MIN_SIZE:
45  nMinHeight = rSz.GetHeight();
46 
47  break;
48 
49  default:
50  nMinHeight = 0;
51  }
52 
53  return nMinHeight;
54 }
55 
57 {
58  SwTwips nRemaining = 0;
59  SwFrame* pFrame = frm.Lower();
60 
61  while ( pFrame )
62  {
63  SwTwips nTmp;
64 
65  nTmp = pFrame->getFrameArea().Height();
66  nRemaining += nTmp;
67  if( pFrame->IsTextFrame() && static_cast<SwTextFrame*>(pFrame)->IsUndersized() )
68  {
69  nTmp = static_cast<SwTextFrame*>(pFrame)->GetParHeight()
70  - pFrame->getFramePrintArea().Height();
71  // This TextFrame would like to be a bit bigger
72  nRemaining += nTmp;
73  }
74  else if( pFrame->IsSctFrame() && static_cast<SwSectionFrame*>(pFrame)->IsUndersized() )
75  {
76  nTmp = static_cast<SwSectionFrame*>(pFrame)->Undersize();
77  nRemaining += nTmp;
78  }
79  pFrame = pFrame->GetNext();
80  }
81 
82  return nRemaining;
83 }
84 
86 {
87  SwTwips nMinHeight = lcl_GetFrameMinHeight(rFrame);
88 
89  if (rFrame.getFrameArea().Height() < nMinHeight)
90  {
91  rFrame.Grow(nMinHeight - rFrame.getFrameArea().Height());
92  }
93 }
94 
96  : SwLayoutFrame( pFormat, pSib )
97 {
98  mnFrameType = nTypeIn;
99  SetDerivedVert( false );
100 
101  const SwFormatContent &rCnt = pFormat->GetContent();
102 
103  OSL_ENSURE( rCnt.GetContentIdx(), "No content for Header." );
104 
105  // Have the objects created right now for header and footer
106  bool bOld = bObjsDirect;
107  bObjsDirect = true;
108  sal_uLong nIndex = rCnt.GetContentIdx()->GetIndex();
109  ::InsertCnt_( this, pFormat->GetDoc(), ++nIndex );
110  bObjsDirect = bOld;
111 }
112 
114 {
115  if (GetEatSpacing())
116  {
117  /* The minimal height of the print area is the minimal height of the
118  frame without the height needed for borders and shadow. */
119  SwTwips nMinHeight = lcl_GetFrameMinHeight(*this);
120 
121  nMinHeight -= pAttrs->CalcTop();
122  nMinHeight -= pAttrs->CalcBottom();
123 
124  /* If the minimal height of the print area is negative, try to
125  compensate by overlapping */
126  SwTwips nOverlap = 0;
127  if (nMinHeight < 0)
128  {
129  nOverlap = -nMinHeight;
130  nMinHeight = 0;
131  }
132 
133  /* Calculate desired height of content. The minimal height has to be
134  adhered. */
135  SwTwips nHeight;
136 
137  if ( ! HasFixSize() )
138  nHeight = lcl_CalcContentHeight(*this);
139  else
140  nHeight = nMinHeight;
141 
142  if (nHeight < nMinHeight)
143  nHeight = nMinHeight;
144 
145  /* calculate initial spacing/line space */
146  SwTwips nSpace, nLine;
147 
148  if (IsHeaderFrame())
149  {
150  nSpace = pAttrs->CalcBottom();
151  nLine = pAttrs->CalcBottomLine();
152  }
153  else
154  {
155  nSpace = pAttrs->CalcTop();
156  nLine = pAttrs->CalcTopLine();
157  }
158 
159  /* calculate overlap and correct spacing */
160  nOverlap += nHeight - nMinHeight;
161  if (nOverlap < nSpace - nLine)
162  nSpace -= nOverlap;
163  else
164  nSpace = nLine;
165 
166  /* calculate real vertical space between frame and print area */
167  if (IsHeaderFrame())
168  nUL = pAttrs->CalcTop() + nSpace;
169  else
170  nUL = pAttrs->CalcBottom() + nSpace;
171 
172  /* set print area */
173  // OD 23.01.2003 #106895# - add first parameter to <SwBorderAttrs::CalcRight(..)>
174  SwTwips nLR = pAttrs->CalcLeft( this ) + pAttrs->CalcRight( this );
176 
177  aPrt.Left(pAttrs->CalcLeft(this));
178 
179  if (IsHeaderFrame())
180  {
181  aPrt.Top(pAttrs->CalcTop());
182  }
183  else
184  {
185  aPrt.Top(nSpace);
186  }
187 
188  aPrt.Width(getFrameArea().Width() - nLR);
189 
190  SwTwips nNewHeight;
191 
192  if (nUL < getFrameArea().Height())
193  {
194  nNewHeight = getFrameArea().Height() - nUL;
195  }
196  else
197  {
198  nNewHeight = 0;
199  }
200 
201  aPrt.Height(nNewHeight);
202  }
203  else
204  {
205  // Set position
207  aPrt.Left( pAttrs->CalcLeft( this ) );
208  aPrt.Top ( pAttrs->CalcTop() );
209 
210  // Set sizes - the sizes are given by the surrounding Frame, just
211  // subtract the borders.
212  // OD 23.01.2003 #106895# - add first parameter to <SwBorderAttrs::CalcRight(..)>
213  SwTwips nLR = pAttrs->CalcLeft( this ) + pAttrs->CalcRight( this );
214  aPrt.Width ( getFrameArea().Width() - nLR );
215  aPrt.Height( getFrameArea().Height()- nUL );
216  }
217 
219 }
220 
222 {
223  if ( !HasFixSize() )
224  {
225  if( !IsColLocked() )
226  {
228  setFrameAreaSizeValid(true);
229 
230  const SwTwips nBorder = nUL;
231  SwTwips nMinHeight = lcl_GetFrameMinHeight(*this);
232  nMinHeight -= pAttrs->CalcTop();
233  nMinHeight -= pAttrs->CalcBottom();
234 
235  if (nMinHeight < 0)
236  nMinHeight = 0;
237 
238  ColLock();
239 
240  SwTwips nMaxHeight = LONG_MAX;
241  SwTwips nRemaining, nOldHeight;
242  // #i64301#
243  // use the position of the footer printing area to control invalidation
244  // of the first footer content.
245  Point aOldFooterPrtPos;
246 
247  do
248  {
249  nOldHeight = getFramePrintArea().Height();
250  SwFrame* pFrame = Lower();
251  // #i64301#
252  if ( pFrame &&
253  aOldFooterPrtPos != ( getFrameArea().Pos() + getFramePrintArea().Pos() ) )
254  {
255  pFrame->InvalidatePos_();
256  aOldFooterPrtPos = getFrameArea().Pos() + getFramePrintArea().Pos();
257  }
258  int nLoopControl = 0;
259  while( pFrame )
260  {
261  pFrame->Calc(getRootFrame()->GetCurrShell()->GetOut());
262  // #i43771# - format also object anchored
263  // at the frame
264  // #i46941# - frame has to be valid.
265  // Note: frame could be invalid after calling its format,
266  // if it's locked
267  OSL_ENSURE( StackHack::IsLocked() || !pFrame->IsTextFrame() ||
268  pFrame->isFrameAreaDefinitionValid() ||
269  static_cast<SwTextFrame*>(pFrame)->IsJoinLocked(),
270  "<SwHeadFootFrame::FormatSize(..)> - text frame invalid and not locked." );
271 
272  if ( pFrame->IsTextFrame() && pFrame->isFrameAreaDefinitionValid() )
273  {
275  *(pFrame->FindPageFrame()) ) )
276  {
277  if (nLoopControl++ < 20)
278  {
279  // restart format with first content
280  pFrame = Lower();
281  continue;
282  }
283  else
284  SAL_WARN("sw", "SwHeadFootFrame::FormatSize: loop detection triggered");
285  }
286  }
287  pFrame = pFrame->GetNext();
288  }
289  nRemaining = 0;
290  pFrame = Lower();
291 
292  while ( pFrame )
293  {
294  nRemaining += pFrame->getFrameArea().Height();
295 
296  if( pFrame->IsTextFrame() &&
297  static_cast<SwTextFrame*>(pFrame)->IsUndersized() )
298  // This TextFrame would like to be a bit bigger
299  nRemaining += static_cast<SwTextFrame*>(pFrame)->GetParHeight()
300  - pFrame->getFramePrintArea().Height();
301  else if( pFrame->IsSctFrame() &&
302  static_cast<SwSectionFrame*>(pFrame)->IsUndersized() )
303  nRemaining += static_cast<SwSectionFrame*>(pFrame)->Undersize();
304  pFrame = pFrame->GetNext();
305  }
306  if ( nRemaining < nMinHeight )
307  nRemaining = nMinHeight;
308 
309  SwTwips nDiff = nRemaining - nOldHeight;
310 
311  if( !nDiff )
312  break;
313  if( nDiff < 0 )
314  {
315  nMaxHeight = nOldHeight;
316 
317  if( nRemaining <= nMinHeight )
318  nRemaining = ( nMaxHeight + nMinHeight + 1 ) / 2;
319  }
320  else
321  {
322  if (nOldHeight > nMinHeight)
323  nMinHeight = nOldHeight;
324 
325  if( nRemaining >= nMaxHeight )
326  nRemaining = ( nMaxHeight + nMinHeight + 1 ) / 2;
327  }
328 
329  nDiff = nRemaining - nOldHeight;
330 
331  if ( nDiff )
332  {
333  ColUnlock();
334  if ( nDiff > 0 )
335  {
336  if ( Grow( nDiff ) )
337  {
338  pFrame = Lower();
339 
340  while ( pFrame )
341  {
342  if( pFrame->IsTextFrame())
343  {
344  SwTextFrame * pTmpFrame = static_cast<SwTextFrame*>(pFrame);
345  if (pTmpFrame->IsUndersized() )
346  {
347  pTmpFrame->InvalidateSize();
348  pTmpFrame->Prepare(PREP_ADJUST_FRM);
349  }
350  }
351  /* #i3568# Undersized sections need to be
352  invalidated too. */
353  else if (pFrame->IsSctFrame())
354  {
355  SwSectionFrame * pTmpFrame =
356  static_cast<SwSectionFrame*>(pFrame);
357  if (pTmpFrame->IsUndersized() )
358  {
359  pTmpFrame->InvalidateSize();
360  pTmpFrame->Prepare(PREP_ADJUST_FRM);
361  }
362  }
363  pFrame = pFrame->GetNext();
364  }
365  }
366  }
367  else
368  Shrink( -nDiff );
369  // Quickly update the position
370 
371  MakePos();
372  ColLock();
373  }
374  else
375  break;
376  // Don't overwrite the lower edge of the upper
377  if ( GetUpper() && getFrameArea().Height() )
378  {
379  const SwTwips nDeadLine = GetUpper()->getFrameArea().Top() + GetUpper()->getFramePrintArea().Bottom();
380  const SwTwips nBot = getFrameArea().Bottom();
381 
382  if ( nBot > nDeadLine )
383  {
385  aFrm.Bottom( nDeadLine );
386 
388  aPrt.SSize().setHeight( getFrameArea().Height() - nBorder );
389  }
390  }
391 
393  setFrameAreaSizeValid(true);
394  } while( nRemaining<=nMaxHeight && nOldHeight!=getFramePrintArea().Height() );
395  ColUnlock();
396  }
397 
399  setFrameAreaSizeValid(true);
400  }
401  else //if (GetType() & FRM_HEADFOOT)
402  {
403  do
404  {
405  if ( getFrameArea().Height() != pAttrs->GetSize().Height() )
406  {
407  ChgSize( Size( getFrameArea().Width(), pAttrs->GetSize().Height()));
408  }
409 
410  setFrameAreaSizeValid(true);
411  MakePos();
412  } while ( !isFrameAreaSizeValid() );
413  }
414 }
415 
416 void SwHeadFootFrame::Format(vcl::RenderContext* pRenderContext, const SwBorderAttrs * pAttrs)
417 {
418  OSL_ENSURE( pAttrs, "SwFooterFrame::Format, pAttrs is 0." );
419 
421  return;
422 
423  if ( ! GetEatSpacing() && IsHeaderFrame())
424  {
425  SwLayoutFrame::Format(pRenderContext, pAttrs);
426  }
427  else
428  {
430 
431  long nUL = pAttrs->CalcTop() + pAttrs->CalcBottom();
432 
433  if ( !isFramePrintAreaValid() )
434  FormatPrt(nUL, pAttrs);
435 
436  if ( !isFrameAreaSizeValid() )
437  FormatSize(nUL, pAttrs);
438  }
439 }
440 
441 SwTwips SwHeadFootFrame::GrowFrame( SwTwips nDist, bool bTst, bool bInfo )
442 {
443  SwTwips nResult;
444 
445  if ( IsColLocked() )
446  {
447  nResult = 0;
448  }
449  else if (!GetEatSpacing())
450  {
451  nResult = SwLayoutFrame::GrowFrame(nDist, bTst, bInfo);
452  }
453  else
454  {
455  nResult = 0;
456 
457  auto pAccess = std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), this);
458  OSL_ENSURE(pAccess, "no border attributes");
459 
460  SwBorderAttrs * pAttrs = pAccess->Get();
461 
462  /* First assume the whole amount to grow can be provided by eating
463  spacing. */
464  SwTwips nEat = nDist;
465  SwTwips nMaxEat;
466 
467  /* calculate maximum eatable spacing */
468  if (IsHeaderFrame())
469  nMaxEat = getFrameArea().Height() - getFramePrintArea().Top() - getFramePrintArea().Height() - pAttrs->CalcBottomLine();
470  else
471  nMaxEat = getFramePrintArea().Top() - pAttrs->CalcTopLine();
472 
473  if (nMaxEat < 0)
474  nMaxEat = 0;
475 
476  /* If the frame is too small, eat less spacing thus letting the frame
477  grow more. */
478  SwTwips nMinHeight = lcl_GetFrameMinHeight(*this);
479  SwTwips nFrameTooSmall = nMinHeight - getFrameArea().Height();
480 
481  if (nFrameTooSmall > 0)
482  nEat -= nFrameTooSmall;
483 
484  /* No negative eating, not eating more than allowed. */
485  if (nEat < 0)
486  nEat = 0;
487  else if (nEat > nMaxEat)
488  nEat = nMaxEat;
489 
490  // OD 10.04.2003 #108719# - Notify fly frame, if header frame
491  // grows. Consider, that 'normal' grow of layout frame already notifys
492  // the fly frames.
493  bool bNotifyFlys = false;
494  if (nEat > 0)
495  {
496  if ( ! bTst)
497  {
498  if (! IsHeaderFrame())
499  {
501  aPrt.Top(aPrt.Top() - nEat);
502  aPrt.Height(aPrt.Height() - nEat);
503  }
504 
505  InvalidateAll();
506  }
507 
508  nResult += nEat;
509  // OD 14.04.2003 #108719# - trigger fly frame notify.
510  if ( IsHeaderFrame() )
511  {
512  bNotifyFlys = true;
513  }
514  }
515 
516  if (nDist - nEat > 0)
517  {
518  const SwTwips nFrameGrow =
519  SwLayoutFrame::GrowFrame( nDist - nEat, bTst, bInfo );
520 
521  nResult += nFrameGrow;
522  if ( nFrameGrow > 0 )
523  {
524  bNotifyFlys = false;
525  }
526  }
527 
528  // OD 10.04.2003 #108719# - notify fly frames, if necessary and triggered.
529  if ( ( nResult > 0 ) && bNotifyFlys )
530  {
531  NotifyLowerObjs();
532  }
533  }
534 
535  if ( nResult && !bTst )
537 
538  return nResult;
539 }
540 
541 SwTwips SwHeadFootFrame::ShrinkFrame( SwTwips nDist, bool bTst, bool bInfo )
542 {
543  SwTwips nResult;
544 
545  if ( IsColLocked() )
546  {
547  nResult = 0;
548  }
549  else if (! GetEatSpacing())
550  {
551  nResult = SwLayoutFrame::ShrinkFrame(nDist, bTst, bInfo);
552  }
553  else
554  {
555  nResult = 0;
556 
557  SwTwips nMinHeight = lcl_GetFrameMinHeight(*this);
558  SwTwips nOldHeight = getFrameArea().Height();
559  SwTwips nRest = 0; // Amount to shrink by spitting out spacing
560 
561  if ( nOldHeight >= nMinHeight )
562  {
563  /* If the frame's height is bigger than its minimum height, shrink
564  the frame towards its minimum height. If this is not sufficient
565  to provide the shrinking requested provide the rest by spitting
566  out spacing. */
567 
568  SwTwips nBiggerThanMin = nOldHeight - nMinHeight;
569 
570  if (nBiggerThanMin < nDist)
571  {
572  nRest = nDist - nBiggerThanMin;
573  }
574  /* info: declaration of nRest -> else nRest = 0 */
575  }
576  else
577  /* The frame cannot shrink. Provide shrinking by spitting out
578  spacing. */
579  nRest = nDist;
580 
581  // OD 10.04.2003 #108719# - Notify fly frame, if header/footer frame
582  // shrinks. Consider, that 'normal' shrink of layout frame already notifys
583  // the fly frames.
584  bool bNotifyFlys = false;
585  if (nRest > 0)
586  {
587  auto pAccess = std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), this);
588  OSL_ENSURE(pAccess, "no border attributes");
589 
590  SwBorderAttrs * pAttrs = pAccess->Get();
591 
592  /* minimal height of print area */
593  SwTwips nMinPrtHeight = nMinHeight
594  - pAttrs->CalcTop()
595  - pAttrs->CalcBottom();
596 
597  if (nMinPrtHeight < 0)
598  nMinPrtHeight = 0;
599 
600  /* assume all shrinking can be provided */
601  SwTwips nShrink = nRest;
602 
603  /* calculate maximum shrinking */
604  SwTwips nMaxShrink = getFramePrintArea().Height() - nMinPrtHeight;
605 
606  /* shrink no more than maximum shrinking */
607  if (nShrink > nMaxShrink)
608  {
609  //nRest -= nShrink - nMaxShrink;
610  nShrink = nMaxShrink;
611  }
612 
613  if (!bTst)
614  {
615  if (! IsHeaderFrame() )
616  {
618  aPrt.Top(aPrt.Top() + nShrink);
619  aPrt.Height(aPrt.Height() - nShrink);
620  }
621 
622  InvalidateAll();
623  }
624  nResult += nShrink;
625  // OD 14.04.2003 #108719# - trigger fly frame notify.
626  if ( IsHeaderFrame() )
627  {
628  bNotifyFlys = true;
629  }
630  }
631 
632  /* The shrinking not providable by spitting out spacing has to be done
633  by the frame. */
634  if (nDist - nRest > 0)
635  {
636  SwTwips nShrinkAmount = SwLayoutFrame::ShrinkFrame( nDist - nRest, bTst, bInfo );
637  nResult += nShrinkAmount;
638  if ( nShrinkAmount > 0 )
639  {
640  bNotifyFlys = false;
641  }
642  }
643 
644  // OD 10.04.2003 #108719# - notify fly frames, if necessary.
645  if ( ( nResult > 0 ) && bNotifyFlys )
646  {
647  NotifyLowerObjs();
648  }
649  }
650 
651  return nResult;
652 }
653 
655 {
656  const SwFrameFormat * pFormat = GetFormat();
657  OSL_ENSURE(pFormat, "SwHeadFootFrame: no format?");
658 
659  return pFormat->GetHeaderAndFooterEatSpacing().GetValue();
660 }
661 
662 static void DelFlys( SwLayoutFrame const *pFrame, SwPageFrame *pPage )
663 {
664  size_t i = 0;
665  while ( pPage->GetSortedObjs() &&
666  pPage->GetSortedObjs()->size() &&
667  i < pPage->GetSortedObjs()->size() )
668  {
669  SwAnchoredObject* pObj = (*pPage->GetSortedObjs())[i];
670  if ( dynamic_cast< const SwFlyFrame *>( pObj ) != nullptr )
671  {
672  SwFlyFrame* pFlyFrame = static_cast<SwFlyFrame*>(pObj);
673  if ( pFrame->IsAnLower( pFlyFrame ) )
674  {
675  SwFrame::DestroyFrame(pFlyFrame);
676  // Do not increment index, in this case
677  continue;
678  }
679  }
680  ++i;
681  }
682 }
683 
686 {
687  SwLayoutFrame *pLay = static_cast<SwLayoutFrame*>(Lower());
688  if ( !pLay )
689  return;
690 
691  const SwFormatHeader &rH = static_cast<SwFrameFormat*>(GetDep())->GetHeader();
692 
693  const SwViewShell *pSh = getRootFrame()->GetCurrShell();
694  const bool bOn = !(pSh && (pSh->GetViewOptions()->getBrowseMode() ||
696 
697  if ( bOn && rH.IsActive() )
698  { //Implant header, but remove first, if already present
699  OSL_ENSURE( rH.GetHeaderFormat(), "FrameFormat for Header not found." );
700 
701  if ( pLay->GetFormat() == rH.GetHeaderFormat() )
702  return; // Header is already the correct one.
703 
704  if ( pLay->IsHeaderFrame() )
705  { SwLayoutFrame *pDel = pLay;
706  pLay = static_cast<SwLayoutFrame*>(pLay->GetNext());
707  ::DelFlys( pDel, this );
708  pDel->Cut();
709  SwFrame::DestroyFrame(pDel);
710  }
711  OSL_ENSURE( pLay, "Where to with the Header?" );
712  SwHeaderFrame *pH = new SwHeaderFrame( const_cast<SwFrameFormat*>(rH.GetHeaderFormat()), this );
713  pH->Paste( this, pLay );
714  if ( GetUpper() )
715  ::RegistFlys( this, pH );
716  }
717  else if (pLay->IsHeaderFrame())
718  { // Remove header if present.
719  ::DelFlys( pLay, this );
720  pLay->Cut();
721  SwFrame::DestroyFrame(pLay);
722  }
723 }
724 
727 {
728  SwLayoutFrame *pLay = static_cast<SwLayoutFrame*>(Lower());
729  if ( !pLay )
730  return;
731 
732  const SwFormatFooter &rF = static_cast<SwFrameFormat*>(GetDep())->GetFooter();
733  while ( pLay->GetNext() )
734  pLay = static_cast<SwLayoutFrame*>(pLay->GetNext());
735 
736  const SwViewShell *pSh = getRootFrame()->GetCurrShell();
737  const bool bOn = !(pSh && (pSh->GetViewOptions()->getBrowseMode() ||
739 
740  if ( bOn && rF.IsActive() )
741  { //Implant footer, but remove first, if already present
742  OSL_ENSURE( rF.GetFooterFormat(), "FrameFormat for Footer not found." );
743 
744  if ( pLay->GetFormat() == rF.GetFooterFormat() )
745  return; // Footer is already the correct one.
746 
747  if ( pLay->IsFooterFrame() )
748  {
749  ::DelFlys( pLay, this );
750  pLay->Cut();
751  SwFrame::DestroyFrame(pLay);
752  }
753  SwFooterFrame *pF = new SwFooterFrame( const_cast<SwFrameFormat*>(rF.GetFooterFormat()), this );
754  pF->Paste( this );
755  if ( GetUpper() )
756  ::RegistFlys( this, pF );
757  }
758  else if ( pLay->IsFooterFrame() )
759  { // Remove footer if already present
760  ::DelFlys( pLay, this );
761  SwViewShell *pShell;
762  if ( pLay->GetPrev() && nullptr != (pShell = getRootFrame()->GetCurrShell()) &&
763  pShell->VisArea().HasArea() )
764  pShell->InvalidateWindows( pShell->VisArea() );
765  pLay->Cut();
766  SwFrame::DestroyFrame(pLay);
767  }
768 }
769 
770 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsAnLower(const SwFrame *) const
Definition: findfrm.cxx:206
bool GetValue() const
sal_uInt16 CalcBottomLine() const
Definition: frmtool.hxx:481
Base class of the Writer layout elements.
Definition: frame.hxx:295
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
static SwTwips lcl_GetFrameMinHeight(const SwLayoutFrame &rFrame)
Definition: hffrm.cxx:37
virtual SwTwips ShrinkFrame(SwTwips, bool bTst=false, bool bInfo=false) override
Definition: hffrm.cxx:541
Header in the document layout, inside a page.
Definition: hffrm.hxx:43
void FormatPrt(SwTwips &nUL, const SwBorderAttrs *pAttrs)
Definition: hffrm.cxx:113
SwTwips Grow(SwTwips, bool bTst=false, bool bInfo=false)
Definition: wsfrm.cxx:1462
virtual void Format(vcl::RenderContext *pRenderContext, const SwBorderAttrs *pAttrs=nullptr) override
"Formats" the Frame; Frame and PrtArea.
Definition: wsfrm.cxx:3355
bool IsColLocked() const
Definition: frame.hxx:862
long Height() const
void SetCompletePaint() const
Definition: frame.hxx:970
SwModify * GetDep()
use these so we can grep for SwFrame's GetRegisteredIn accesses beware that SwTextFrame may return sw...
Definition: frame.hxx:457
sal_uIntPtr sal_uLong
const SwRect & getFramePrintArea() const
Definition: frame.hxx:176
static SwCache & GetCache()
Definition: frame.hxx:500
void Height(long nNew)
Definition: swrect.hxx:189
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: wsfrm.cxx:1296
long SwTwips
Definition: swtypes.hxx:49
Content, content of frame (header, footer, fly).
Definition: fmtcntnt.hxx:31
sal_uInt16 CalcTopLine() const
Definition: frmtool.hxx:475
static void DestroyFrame(SwFrame *const pFrame)
this is the only way to delete a SwFrame instance
Definition: ssfrm.cxx:382
void Pos(const Point &rNew)
Definition: swrect.hxx:167
virtual void Calc(vcl::RenderContext *pRenderContext) const
Definition: trvlfrm.cxx:1787
long CalcRight(const SwFrame *pCaller) const
Definition: frmtool.cxx:2045
bool isFrameAreaDefinitionValid() const
Definition: frame.hxx:167
bool IsActive() const
Definition: fmthdft.hxx:89
long CalcLeft(const SwFrame *pCaller) const
Definition: frmtool.cxx:2093
wrapper class for the positioning of Writer fly frames and drawing objects
Value in Var-direction gives minimum (can be exceeded but not be less).
Definition: fmtfsize.hxx:39
void Top(const long nTop)
Definition: swrect.hxx:202
void InsertCnt_(SwLayoutFrame *pLay, SwDoc *pDoc, sal_uLong nIndex, bool bPages=false, sal_uLong nEndIndex=0, SwFrame *pPrv=nullptr)
Definition: frmtool.cxx:1322
const SwRect & getFrameArea() const
Definition: frame.hxx:175
bool getBrowseMode() const
Definition: viewopt.hxx:426
virtual Size ChgSize(const Size &aNewSize)
Definition: wsfrm.cxx:721
void FormatSize(SwTwips nUL, const SwBorderAttrs *pAttrs)
Definition: hffrm.cxx:221
Footer, for pageformats Client of FrameFormat describing the footer.
Definition: fmthdft.hxx:64
sal_uLong GetIndex() const
Definition: ndindex.hxx:151
bool IsTextFrame() const
Definition: frame.hxx:1210
void setFramePrintAreaValid(bool bNew)
Definition: wsfrm.cxx:96
bool IsSctFrame() const
Definition: frame.hxx:1190
void PrepareFooter()
Creates or removes footer.
Definition: hffrm.cxx:726
virtual bool Prepare(const PrepareHint ePrep=PREP_CLEAR, const void *pVoid=nullptr, bool bNotify=true) override
SwContentFrame: the shortcut for the Frames If the void* casts wrongly, it's its own fault! The void*...
Definition: txtfrm.cxx:2710
void SetDerivedVert(bool bNew)
Definition: frame.hxx:607
Style of a layout element.
Definition: frmfmt.hxx:57
const SwSortedObjs * GetSortedObjs() const
Definition: pagefrm.hxx:118
const SwRect & VisArea() const
Definition: viewsh.cxx:570
const SwFrameFormat * GetFooterFormat() const
Definition: fmthdft.hxx:85
SwFrameType
Definition: frame.hxx:72
virtual SwTwips GrowFrame(SwTwips, bool bTst=false, bool bInfo=false) override
Definition: hffrm.cxx:441
size_t size() const
Definition: sortedobjs.cxx:42
void ColUnlock()
Definition: frame.hxx:430
SwPageFrame * FindPageFrame()
Definition: frame.hxx:658
virtual void Cut() override
Definition: wsfrm.cxx:1393
const SwFrame * Lower() const
Definition: layfrm.hxx:100
int i
SwLayoutFrame * GetUpper()
Definition: frame.hxx:656
bool HasArea() const
Definition: swrect.hxx:290
bool isFramePrintAreaValid() const
Definition: frame.hxx:164
bool IsUndersized() const
Definition: flowfrm.hxx:158
long const nBorder
SwFrame * GetPrev()
Definition: frame.hxx:655
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:119
void SSize(const Size &rNew)
Definition: swrect.hxx:176
void PrepareHeader()
Make this public, so that the SwViewShell can access it when switching from browse mode Add/remove he...
Definition: hffrm.cxx:685
bool HasFixSize() const
Definition: frame.hxx:648
bool bObjsDirect
Definition: frmtool.cxx:79
bool isFrameAreaSizeValid() const
Definition: frame.hxx:163
void InvalidatePos_()
Definition: frame.hxx:765
A page of the document layout.
Definition: pagefrm.hxx:40
void InvalidateWindows(const SwRect &rRect)
Definition: viewsh.cxx:551
static void DelFlys(SwLayoutFrame const *pFrame, SwPageFrame *pPage)
Definition: hffrm.cxx:662
const long LONG_MAX
sal_uInt16 CalcTop() const
Definition: frmtool.hxx:499
SwTwips Shrink(SwTwips, bool bTst=false, bool bInfo=false)
Definition: wsfrm.cxx:1507
void InvalidateSize()
Definition: frame.hxx:1005
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
SwHeadFootFrame(SwFrameFormat *pFrame, SwFrame *, SwFrameType aType)
Definition: hffrm.cxx:95
static bool FormatObjsAtFrame(SwFrame &_rAnchorFrame, const SwPageFrame &_rPageFrame, SwLayAction *_pLayAction=nullptr)
method to format all floating screen objects at the given anchor frame
void Left(const long nLeft)
Definition: swrect.hxx:193
void Bottom(const long nBottom)
Definition: swrect.hxx:207
general base class for all free-flowing frames
Definition: flyfrm.hxx:60
virtual SwTwips ShrinkFrame(SwTwips, bool bTst=false, bool bInfo=false) override
Definition: wsfrm.cxx:2747
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:426
void Width(long nNew)
Definition: swrect.hxx:185
void NotifyLowerObjs(const bool _bUnlockPosOfObjs=false)
force an unlockposition call for the lower objects.
Definition: fly.cxx:2367
sal_uInt16 CalcBottom() const
Definition: frmtool.hxx:505
static void lcl_LayoutFrameEnsureMinHeight(SwLayoutFrame &rFrame)
Definition: hffrm.cxx:85
void setFrameAreaSizeValid(bool bNew)
Definition: wsfrm.cxx:88
SwFrameType mnFrameType
Definition: frame.hxx:395
Header, for PageFormats Client of FrameFormat describing the header.
Definition: fmthdft.hxx:33
static bool IsLocked()
Definition: frmtool.hxx:443
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
const Size & GetSize() const
Definition: frmtool.hxx:376
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
const SwHeaderAndFooterEatSpacingItem & GetHeaderAndFooterEatSpacing(bool=true) const
#define SAL_WARN(area, stream)
void InvalidateAll()
Definition: frame.hxx:1031
bool GetEatSpacing() const
Definition: hffrm.cxx:654
void RegistFlys(SwPageFrame *, const SwLayoutFrame *)
Definition: frmtool.cxx:2908
virtual void MakePos()
Definition: calcmove.cxx:521
virtual SwTwips GrowFrame(SwTwips, bool bTst=false, bool bInfo=false) override
Definition: wsfrm.cxx:2575
bool IsActive() const
Definition: fmthdft.hxx:58
virtual void Format(vcl::RenderContext *pRenderContext, const SwBorderAttrs *pAttrs=nullptr) override
"Formats" the Frame; Frame and PrtArea.
Definition: hffrm.cxx:416
virtual bool Prepare(const PrepareHint ePrep=PREP_CLEAR, const void *pVoid=nullptr, bool bNotify=true)
Definition: wsfrm.cxx:587
bool IsWhitespaceHidden() const
Definition: viewopt.hxx:442
long GetHeight() const
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:204
void ColLock()
Definition: frame.hxx:429
Footer in the document layout, inside a page.
Definition: hffrm.hxx:50
bool IsFooterFrame() const
Definition: frame.hxx:1170
SwRootFrame * getRootFrame()
Definition: frame.hxx:657
static SwTwips lcl_CalcContentHeight(SwLayoutFrame &frm)
Definition: hffrm.cxx:56
const SwFrameFormat * GetHeaderFormat() const
Definition: fmthdft.hxx:54
bool IsHeaderFrame() const
Definition: frame.hxx:1166
virtual const SwFrameFormat * GetFormat() const
Definition: ssfrm.cxx:393
SwFrameSize GetHeightSizeType() const
Definition: fmtfsize.hxx:80
SwFrame * GetNext()
Definition: frame.hxx:654