1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26
27 #include "pagefrm.hxx"
28 #include "viewsh.hxx"
29 #include "doc.hxx"
30 #include "errhdl.hxx"
31 #include <fmtcntnt.hxx>
32 #include <fmthdft.hxx>
33 #include <fmtfsize.hxx>
34 #include "viewopt.hxx"
35 #include "hffrm.hxx"
36 #include "rootfrm.hxx"
37 #include "txtfrm.hxx"
38 #include "sectfrm.hxx"
39 #include "flyfrm.hxx"
40 #include "frmtool.hxx"
41 #include "dflyobj.hxx"
42 #include "frmfmt.hxx"
43 #include "ndindex.hxx"
44 #include "hfspacingitem.hxx"
45 // OD 2004-05-24 #i28701#
46 #include <sortedobjs.hxx>
47 // --> OD 2005-03-03 #i43771#
48 #include <objectformatter.hxx>
49 // <--
50
51 extern sal_Bool bObjsDirect; //frmtool.cxx
52
lcl_GetFrmMinHeight(const SwLayoutFrm & rFrm)53 static SwTwips lcl_GetFrmMinHeight(const SwLayoutFrm & rFrm)
54 {
55 const SwFmtFrmSize &rSz = rFrm.GetFmt()->GetFrmSize();
56 SwTwips nMinHeight;
57
58 switch (rSz.GetHeightSizeType())
59 {
60 case ATT_MIN_SIZE:
61 nMinHeight = rSz.GetHeight();
62
63 break;
64
65 default:
66 nMinHeight = 0;
67 }
68
69
70 return nMinHeight;
71 }
72
73
lcl_CalcContentHeight(SwLayoutFrm & frm)74 static SwTwips lcl_CalcContentHeight(SwLayoutFrm & frm)
75 {
76 SwFrm* pFrm = frm.Lower();
77
78 SwTwips nRemaining = 0;
79 sal_uInt16 nNum = 0;
80 pFrm = frm.Lower();
81 while ( pFrm )
82 {
83 SwTwips nTmp;
84
85 nTmp = pFrm->Frm().Height();
86 nRemaining += nTmp;
87 if( pFrm->IsTxtFrm() && ((SwTxtFrm*)pFrm)->IsUndersized() )
88 {
89 nTmp = ((SwTxtFrm*)pFrm)->GetParHeight()
90 - pFrm->Prt().Height();
91 // Dieser TxtFrm waere gern ein bisschen groesser
92 nRemaining += nTmp;
93 }
94 else if( pFrm->IsSctFrm() && ((SwSectionFrm*)pFrm)->IsUndersized() )
95 {
96 nTmp = ((SwSectionFrm*)pFrm)->Undersize();
97 nRemaining += nTmp;
98 }
99 pFrm = pFrm->GetNext();
100
101 nNum++;
102 }
103
104 return nRemaining;
105 }
106
lcl_LayoutFrmEnsureMinHeight(SwLayoutFrm & rFrm,const SwBorderAttrs *)107 static void lcl_LayoutFrmEnsureMinHeight(SwLayoutFrm & rFrm,
108 const SwBorderAttrs * )
109 {
110 SwTwips nMinHeight = lcl_GetFrmMinHeight(rFrm);
111
112 if (rFrm.Frm().Height() < nMinHeight)
113 {
114 rFrm.Grow(nMinHeight - rFrm.Frm().Height());
115 }
116 }
117
SwHeadFootFrm(SwFrmFmt * pFmt,SwFrm * pSib,sal_uInt16 nTypeIn)118 SwHeadFootFrm::SwHeadFootFrm( SwFrmFmt * pFmt, SwFrm* pSib, sal_uInt16 nTypeIn)
119 : SwLayoutFrm( pFmt, pSib )
120 {
121 nType = nTypeIn;
122 SetDerivedVert( sal_False );
123
124 const SwFmtCntnt &rCnt = pFmt->GetCntnt();
125
126 ASSERT( rCnt.GetCntntIdx(), "Kein Inhalt fuer Header." );
127
128 //Fuer Header Footer die Objekte gleich erzeugen lassen.
129 sal_Bool bOld = bObjsDirect;
130 bObjsDirect = sal_True;
131 sal_uLong nIndex = rCnt.GetCntntIdx()->GetIndex();
132 ::_InsertCnt( this, pFmt->GetDoc(), ++nIndex );
133 bObjsDirect = bOld;
134 }
135
FormatPrt(SwTwips & nUL,const SwBorderAttrs * pAttrs)136 void SwHeadFootFrm::FormatPrt(SwTwips & nUL, const SwBorderAttrs * pAttrs)
137 {
138 if (GetEatSpacing())
139 {
140 /* The minimal height of the print area is the minimal height of the
141 frame without the height needed for borders and shadow. */
142 SwTwips nMinHeight = lcl_GetFrmMinHeight(*this);
143
144 nMinHeight -= pAttrs->CalcTop();
145 nMinHeight -= pAttrs->CalcBottom();
146
147 /* If the minimal height of the print area is negative, try to
148 compensate by overlapping */
149 SwTwips nOverlap = 0;
150 if (nMinHeight < 0)
151 {
152 nOverlap = -nMinHeight;
153 nMinHeight = 0;
154 }
155
156 /* Calculate desired height of content. The minimal height has to be
157 adhered. */
158 SwTwips nHeight;
159
160 if ( ! HasFixSize() )
161 nHeight = lcl_CalcContentHeight(*this);
162 else
163 nHeight = nMinHeight;
164
165 if (nHeight < nMinHeight)
166 nHeight = nMinHeight;
167
168 /* calculate initial spacing/line space */
169 SwTwips nSpace, nLine;
170
171 if (IsHeaderFrm())
172 {
173 nSpace = pAttrs->CalcBottom();
174 nLine = pAttrs->CalcBottomLine();
175 }
176 else
177 {
178 nSpace = pAttrs->CalcTop();
179 nLine = pAttrs->CalcTopLine();
180 }
181
182 /* calculate overlap and correct spacing */
183 nOverlap += nHeight - nMinHeight;
184 if (nOverlap < nSpace - nLine)
185 nSpace -= nOverlap;
186 else
187 nSpace = nLine;
188
189 /* calculate real vertical space between frame and print area */
190 if (IsHeaderFrm())
191 nUL = pAttrs->CalcTop() + nSpace;
192 else
193 nUL = pAttrs->CalcBottom() + nSpace;
194
195 /* set print area */
196 // OD 23.01.2003 #106895# - add first parameter to <SwBorderAttrs::CalcRight(..)>
197 SwTwips nLR = pAttrs->CalcLeft( this ) + pAttrs->CalcRight( this );
198
199 aPrt.Left(pAttrs->CalcLeft(this));
200
201 if (IsHeaderFrm())
202 aPrt.Top(pAttrs->CalcTop());
203 else
204 aPrt.Top(nSpace);
205
206 aPrt.Width(aFrm.Width() - nLR);
207
208 SwTwips nNewHeight;
209
210 if (nUL < aFrm.Height())
211 nNewHeight = aFrm.Height() - nUL;
212 else
213 nNewHeight = 0;
214
215 aPrt.Height(nNewHeight);
216
217 }
218 else
219 {
220 //Position einstellen.
221 aPrt.Left( pAttrs->CalcLeft( this ) );
222 aPrt.Top ( pAttrs->CalcTop() );
223
224 //Sizes einstellen; die Groesse gibt der umgebende Frm vor, die
225 //die Raender werden einfach abgezogen.
226 // OD 23.01.2003 #106895# - add first parameter to <SwBorderAttrs::CalcRight(..)>
227 SwTwips nLR = pAttrs->CalcLeft( this ) + pAttrs->CalcRight( this );
228 aPrt.Width ( aFrm.Width() - nLR );
229 aPrt.Height( aFrm.Height()- nUL );
230
231 }
232
233 bValidPrtArea = sal_True;
234 }
235
FormatSize(SwTwips nUL,const SwBorderAttrs * pAttrs)236 void SwHeadFootFrm::FormatSize(SwTwips nUL, const SwBorderAttrs * pAttrs)
237 {
238 if ( !HasFixSize() )
239 {
240 if( !IsColLocked() )
241 {
242 bValidSize = bValidPrtArea = sal_True;
243
244 const SwTwips nBorder = nUL;
245 SwTwips nMinHeight = lcl_GetFrmMinHeight(*this);
246 nMinHeight -= pAttrs->CalcTop();
247 nMinHeight -= pAttrs->CalcBottom();
248
249 if (nMinHeight < 0)
250 nMinHeight = 0;
251
252 ColLock();
253
254 SwTwips nMaxHeight = LONG_MAX;
255 SwTwips nRemaining, nOldHeight;
256 // --> OD 2006-05-24 #i64301#
257 // use the position of the footer printing area to control invalidation
258 // of the first footer content.
259 Point aOldFooterPrtPos;
260 // <--
261
262 do
263 {
264 nOldHeight = Prt().Height();
265 SwFrm* pFrm = Lower();
266 // --> OD 2006-05-24 #i64301#
267 if ( pFrm &&
268 aOldFooterPrtPos != ( Frm().Pos() + Prt().Pos() ) )
269 {
270 pFrm->_InvalidatePos();
271 aOldFooterPrtPos = Frm().Pos() + Prt().Pos();
272 }
273 // <--
274 while( pFrm )
275 {
276 pFrm->Calc();
277 // --> OD 2005-03-03 #i43771# - format also object anchored
278 // at the frame
279 // --> OD 2005-05-03 #i46941# - frame has to be valid.
280 // Note: frame could be invalid after calling its format,
281 // if it's locked
282 ASSERT( StackHack::IsLocked() || !pFrm->IsTxtFrm() ||
283 pFrm->IsValid() ||
284 static_cast<SwTxtFrm*>(pFrm)->IsJoinLocked(),
285 "<SwHeadFootFrm::FormatSize(..)> - text frame invalid and not locked." );
286 if ( pFrm->IsTxtFrm() && pFrm->IsValid() )
287 {
288 if ( !SwObjectFormatter::FormatObjsAtFrm( *pFrm,
289 *(pFrm->FindPageFrm()) ) )
290 {
291 // restart format with first content
292 pFrm = Lower();
293 continue;
294 }
295 }
296 // <--
297 pFrm = pFrm->GetNext();
298 }
299 nRemaining = 0;
300 pFrm = Lower();
301
302 while ( pFrm )
303 {
304 nRemaining += pFrm->Frm().Height();
305
306 if( pFrm->IsTxtFrm() &&
307 ((SwTxtFrm*)pFrm)->IsUndersized() )
308 // Dieser TxtFrm waere gern ein bisschen groesser
309 nRemaining += ((SwTxtFrm*)pFrm)->GetParHeight()
310 - pFrm->Prt().Height();
311 else if( pFrm->IsSctFrm() &&
312 ((SwSectionFrm*)pFrm)->IsUndersized() )
313 nRemaining += ((SwSectionFrm*)pFrm)->Undersize();
314 pFrm = pFrm->GetNext();
315 }
316 if ( nRemaining < nMinHeight )
317 nRemaining = nMinHeight;
318
319 SwTwips nDiff = nRemaining - nOldHeight;
320
321 if( !nDiff )
322 break;
323 if( nDiff < 0 )
324 {
325 nMaxHeight = nOldHeight;
326
327 if( nRemaining <= nMinHeight )
328 nRemaining = ( nMaxHeight + nMinHeight + 1 ) / 2;
329 }
330 else
331 {
332 if (nOldHeight > nMinHeight)
333 nMinHeight = nOldHeight;
334
335 if( nRemaining >= nMaxHeight )
336 nRemaining = ( nMaxHeight + nMinHeight + 1 ) / 2;
337 }
338
339 nDiff = nRemaining - nOldHeight;
340
341 if ( nDiff )
342 {
343 ColUnlock();
344 if ( nDiff > 0 )
345 {
346 if ( Grow( nDiff ) )
347 {
348 pFrm = Lower();
349
350 while ( pFrm )
351 {
352 if( pFrm->IsTxtFrm())
353 {
354 SwTxtFrm * pTmpFrm = (SwTxtFrm*) pFrm;
355 if (pTmpFrm->IsUndersized() )
356 {
357 pTmpFrm->InvalidateSize();
358 pTmpFrm->Prepare(PREP_ADJUST_FRM);
359 }
360 }
361 /* #i3568# Undersized sections need to be
362 invalidated too. */
363 else if (pFrm->IsSctFrm())
364 {
365 SwSectionFrm * pTmpFrm =
366 (SwSectionFrm*) pFrm;
367 if (pTmpFrm->IsUndersized() )
368 {
369 pTmpFrm->InvalidateSize();
370 pTmpFrm->Prepare(PREP_ADJUST_FRM);
371 }
372 }
373 pFrm = pFrm->GetNext();
374 }
375 }
376 }
377 else
378 Shrink( -nDiff );
379 //Schnell auf dem kurzen Dienstweg die Position updaten.
380
381 MakePos();
382 ColLock();
383 }
384 else
385 break;
386 //Unterkante des Uppers nicht ueberschreiten.
387 if ( GetUpper() && Frm().Height() )
388 {
389 const SwTwips nDeadLine = GetUpper()->Frm().Top() +
390 GetUpper()->Prt().Bottom();
391 const SwTwips nBot = Frm().Bottom();
392 if ( nBot > nDeadLine )
393 {
394 Frm().Bottom( nDeadLine );
395 Prt().SSize().Height() = Frm().Height() - nBorder;
396 }
397 }
398 bValidSize = bValidPrtArea = sal_True;
399 } while( nRemaining<=nMaxHeight && nOldHeight!=Prt().Height() );
400 ColUnlock();
401 }
402 bValidSize = bValidPrtArea = sal_True;
403 }
404 else //if ( GetType() & 0x0018 )
405 {
406 do
407 {
408 if ( Frm().Height() != pAttrs->GetSize().Height() )
409 ChgSize( Size( Frm().Width(), pAttrs->GetSize().Height()));
410 bValidSize = sal_True;
411 MakePos();
412 } while ( !bValidSize );
413 }
414 }
415
Format(const SwBorderAttrs * pAttrs)416 void SwHeadFootFrm::Format(const SwBorderAttrs * pAttrs)
417 {
418 ASSERT( pAttrs, "SwFooterFrm::Format, pAttrs ist 0." );
419
420 if ( bValidPrtArea && bValidSize )
421 return;
422
423 if ( ! GetEatSpacing() && IsHeaderFrm())
424 {
425 SwLayoutFrm::Format(pAttrs);
426 }
427 else
428 {
429 lcl_LayoutFrmEnsureMinHeight(*this, pAttrs);
430
431 long nUL = pAttrs->CalcTop() + pAttrs->CalcBottom();
432
433 if ( !bValidPrtArea )
434 FormatPrt(nUL, pAttrs);
435
436 if ( !bValidSize )
437 FormatSize(nUL, pAttrs);
438 }
439 }
440
GrowFrm(SwTwips nDist,sal_Bool bTst,sal_Bool bInfo)441 SwTwips SwHeadFootFrm::GrowFrm( SwTwips nDist, sal_Bool bTst, sal_Bool bInfo )
442 {
443 SwTwips nResult;
444
445 if ( IsColLocked() )
446 {
447 nResult = 0;
448 }
449 else if (!GetEatSpacing())
450 {
451 nResult = SwLayoutFrm::GrowFrm(nDist, bTst, bInfo);
452 }
453 else
454 {
455 nResult = 0;
456
457 SwBorderAttrAccess * pAccess =
458 new SwBorderAttrAccess( SwFrm::GetCache(), this );
459 ASSERT(pAccess, "no border attributes");
460
461 SwBorderAttrs * pAttrs = pAccess->Get();
462
463 /* First assume the whole amount to grow can be provided by eating
464 spacing. */
465 SwTwips nEat = nDist;
466 SwTwips nMaxEat;
467
468 /* calculate maximum eatable spacing */
469 if (IsHeaderFrm())
470 nMaxEat = aFrm.Height() - aPrt.Top() - aPrt.Height() - pAttrs->CalcBottomLine();
471 else
472 nMaxEat = aPrt.Top() - pAttrs->CalcTopLine();
473
474 delete pAccess;
475
476 if (nMaxEat < 0)
477 nMaxEat = 0;
478
479 /* If the frame is too small, eat less spacing thus letting the frame
480 grow more. */
481 SwTwips nMinHeight = lcl_GetFrmMinHeight(*this);
482 SwTwips nFrameTooSmall = nMinHeight - Frm().Height();
483
484 if (nFrameTooSmall > 0)
485 nEat -= nFrameTooSmall;
486
487 /* No negative eating, not eating more than allowed. */
488 if (nEat < 0)
489 nEat = 0;
490 else if (nEat > nMaxEat)
491 nEat = nMaxEat;
492
493 // OD 10.04.2003 #108719# - Notify fly frame, if header frame
494 // grows. Consider, that 'normal' grow of layout frame already notifys
495 // the fly frames.
496 sal_Bool bNotifyFlys = sal_False;
497 if (nEat > 0)
498 {
499 if ( ! bTst)
500 {
501 if (! IsHeaderFrm())
502 {
503 aPrt.Top(aPrt.Top() - nEat);
504 aPrt.Height(aPrt.Height() - nEat);
505 }
506
507 InvalidateAll();
508 }
509
510 nResult += nEat;
511 // OD 14.04.2003 #108719# - trigger fly frame notify.
512 if ( IsHeaderFrm() )
513 {
514 bNotifyFlys = sal_True;
515 }
516 }
517
518 if (nDist - nEat > 0)
519 {
520 SwTwips nFrmGrow =
521 SwLayoutFrm::GrowFrm( nDist - nEat, bTst, bInfo );
522
523 nResult += nFrmGrow;
524 if ( nFrmGrow > 0 )
525 {
526 bNotifyFlys = sal_False;
527 }
528 }
529
530 // OD 10.04.2003 #108719# - notify fly frames, if necessary and triggered.
531 if ( ( nResult > 0 ) && bNotifyFlys )
532 {
533 NotifyLowerObjs();
534 }
535 }
536
537 if ( nResult && !bTst )
538 SetCompletePaint();
539
540 return nResult;
541 }
542
ShrinkFrm(SwTwips nDist,sal_Bool bTst,sal_Bool bInfo)543 SwTwips SwHeadFootFrm::ShrinkFrm( SwTwips nDist, sal_Bool bTst, sal_Bool bInfo )
544 {
545 SwTwips nResult;
546
547 if ( IsColLocked() )
548 {
549 nResult = 0;
550 }
551 else if (! GetEatSpacing())
552 {
553 nResult = SwLayoutFrm::ShrinkFrm(nDist, bTst, bInfo);
554 }
555 else
556 {
557 nResult = 0;
558
559 SwTwips nMinHeight = lcl_GetFrmMinHeight(*this);
560 SwTwips nOldHeight = Frm().Height();
561 SwTwips nRest = 0; // Amount to shrink by spitting out spacing
562
563 if ( nOldHeight >= nMinHeight )
564 {
565 /* If the frame's height is bigger than its minimum height, shrink
566 the frame towards its minimum height. If this is not sufficient
567 to provide the shrinking requested provide the rest by spitting
568 out spacing. */
569
570 SwTwips nBiggerThanMin = nOldHeight - nMinHeight;
571
572 if (nBiggerThanMin < nDist)
573 {
574 nRest = nDist - nBiggerThanMin;
575 }
576 /* info: declaration of nRest -> else nRest = 0 */
577 }
578 else
579 /* The frame cannot shrink. Provide shrinking by spitting out
580 spacing. */
581 nRest = nDist;
582
583 // OD 10.04.2003 #108719# - Notify fly frame, if header/footer frame
584 // shrinks. Consider, that 'normal' shrink of layout frame already notifys
585 // the fly frames.
586 sal_Bool bNotifyFlys = sal_False;
587 if (nRest > 0)
588 {
589
590 SwBorderAttrAccess * pAccess =
591 new SwBorderAttrAccess( SwFrm::GetCache(), this );
592 ASSERT(pAccess, "no border attributes");
593
594 SwBorderAttrs * pAttrs = pAccess->Get();
595
596 /* minimal height of print area */
597 SwTwips nMinPrtHeight = nMinHeight
598 - pAttrs->CalcTop()
599 - pAttrs->CalcBottom();
600
601 if (nMinPrtHeight < 0)
602 nMinPrtHeight = 0;
603
604 delete pAccess;
605
606 /* assume all shrinking can be provided */
607 SwTwips nShrink = nRest;
608
609 /* calculate maximum shrinking */
610 SwTwips nMaxShrink = aPrt.Height() - nMinPrtHeight;
611
612 /* shrink no more than maximum shrinking */
613 if (nShrink > nMaxShrink)
614 {
615 //nRest -= nShrink - nMaxShrink;
616 nShrink = nMaxShrink;
617 }
618
619 if (!bTst)
620 {
621 if (! IsHeaderFrm() )
622 {
623 aPrt.Top(aPrt.Top() + nShrink);
624 aPrt.Height(aPrt.Height() - nShrink);
625 }
626
627 InvalidateAll();
628 }
629 nResult += nShrink;
630 // OD 14.04.2003 #108719# - trigger fly frame notify.
631 if ( IsHeaderFrm() )
632 {
633 bNotifyFlys = sal_True;
634 }
635 }
636
637 /* The shrinking not providable by spitting out spacing has to be done
638 by the frame. */
639 if (nDist - nRest > 0)
640 {
641 SwTwips nShrinkAmount = SwLayoutFrm::ShrinkFrm( nDist - nRest, bTst, bInfo );
642 nResult += nShrinkAmount;
643 if ( nShrinkAmount > 0 )
644 {
645 bNotifyFlys = sal_False;
646 }
647 }
648
649 // OD 10.04.2003 #108719# - notify fly frames, if necessary.
650 if ( ( nResult > 0 ) && bNotifyFlys )
651 {
652 NotifyLowerObjs();
653 }
654 }
655
656 return nResult;
657 }
658
GetEatSpacing() const659 sal_Bool SwHeadFootFrm::GetEatSpacing() const
660 {
661 const SwFrmFmt * pFmt = GetFmt();
662 ASSERT(pFmt, "SwHeadFootFrm: no format?");
663
664 if (pFmt->GetHeaderAndFooterEatSpacing().GetValue())
665 return sal_True;
666
667 return sal_False;
668 }
669
670
671 /*************************************************************************
672 |*
673 |* SwPageFrm::PrepareHeader()
674 |*
675 |* Beschreibung Erzeugt oder Entfernt Header
676 |* Ersterstellung MA 04. Feb. 93
677 |* Letzte Aenderung MA 12. May. 96
678 |*
679 |*************************************************************************/
680
681
DelFlys(SwLayoutFrm * pFrm,SwPageFrm * pPage)682 void DelFlys( SwLayoutFrm *pFrm, SwPageFrm *pPage )
683 {
684 for ( int i = 0; pPage->GetSortedObjs() &&
685 pPage->GetSortedObjs()->Count() &&
686 i < (int)pPage->GetSortedObjs()->Count(); ++i )
687 {
688 SwAnchoredObject* pObj = (*pPage->GetSortedObjs())[i];
689 if ( pObj->ISA(SwFlyFrm) )
690 {
691 SwFlyFrm* pFlyFrm = static_cast<SwFlyFrm*>(pObj);
692 if ( pFrm->IsAnLower( pFlyFrm ) )
693 {
694 delete pFlyFrm;
695 --i;
696 }
697 }
698 }
699 }
700
701
702
PrepareHeader()703 void SwPageFrm::PrepareHeader()
704 {
705 SwLayoutFrm *pLay = (SwLayoutFrm*)Lower();
706 if ( !pLay )
707 return;
708
709 const SwFmtHeader &rH = ((SwFrmFmt*)GetRegisteredIn())->GetHeader();
710
711 const ViewShell *pSh = getRootFrm()->GetCurrShell();
712 const sal_Bool bOn = !(pSh && pSh->GetViewOptions()->getBrowseMode());
713
714 if ( bOn && rH.IsActive() )
715 { //Header einsetzen, vorher entfernen falls vorhanden.
716 ASSERT( rH.GetHeaderFmt(), "FrmFmt fuer Header nicht gefunden." );
717
718 if ( pLay->GetFmt() == (SwFrmFmt*)rH.GetHeaderFmt() )
719 return; //Der Footer ist bereits der richtige
720
721 if ( pLay->IsHeaderFrm() )
722 { SwLayoutFrm *pDel = pLay;
723 pLay = (SwLayoutFrm*)pLay->GetNext();
724 ::DelFlys( pDel, this );
725 pDel->Cut();
726 delete pDel;
727 }
728 ASSERT( pLay, "Wohin mit dem Header?" );
729 SwHeaderFrm *pH = new SwHeaderFrm( (SwFrmFmt*)rH.GetHeaderFmt(), this );
730 pH->Paste( this, pLay );
731 if ( GetUpper() )
732 ::RegistFlys( this, pH );
733 }
734 else if ( pLay && pLay->IsHeaderFrm() )
735 { //Header entfernen falls vorhanden.
736 ::DelFlys( pLay, this );
737 pLay->Cut();
738 delete pLay;
739 }
740 }
741 /*************************************************************************
742 |*
743 |* SwPageFrm::PrepareFooter()
744 |*
745 |* Beschreibung Erzeugt oder Entfernt Footer
746 |* Ersterstellung MA 04. Feb. 93
747 |* Letzte Aenderung MA 12. May. 96
748 |*
749 |*************************************************************************/
750
751
PrepareFooter()752 void SwPageFrm::PrepareFooter()
753 {
754 SwLayoutFrm *pLay = (SwLayoutFrm*)Lower();
755 if ( !pLay )
756 return;
757
758 const SwFmtFooter &rF = ((SwFrmFmt*)GetRegisteredIn())->GetFooter();
759 while ( pLay->GetNext() )
760 pLay = (SwLayoutFrm*)pLay->GetNext();
761
762 const ViewShell *pSh = getRootFrm()->GetCurrShell();
763 const sal_Bool bOn = !(pSh && pSh->GetViewOptions()->getBrowseMode());
764
765 if ( bOn && rF.IsActive() )
766 { //Footer einsetzen, vorher entfernen falls vorhanden.
767 ASSERT( rF.GetFooterFmt(), "FrmFmt fuer Footer nicht gefunden." );
768
769 if ( pLay->GetFmt() == (SwFrmFmt*)rF.GetFooterFmt() )
770 return; //Der Footer ist bereits der richtige.
771
772 if ( pLay->IsFooterFrm() )
773 { ::DelFlys( pLay, this );
774 pLay->Cut();
775 delete pLay;
776 }
777 SwFooterFrm *pF = new SwFooterFrm( (SwFrmFmt*)rF.GetFooterFmt(), this );
778 pF->Paste( this );
779 if ( GetUpper() )
780 ::RegistFlys( this, pF );
781 }
782 else if ( pLay && pLay->IsFooterFrm() )
783 { //Footer entfernen falls vorhanden.
784 ::DelFlys( pLay, this );
785 ViewShell *pShell;
786 if ( pLay->GetPrev() && 0 != (pShell = getRootFrm()->GetCurrShell()) &&
787 pShell->VisArea().HasArea() )
788 pShell->InvalidateWindows( pShell->VisArea() );
789 pLay->Cut();
790 delete pLay;
791 }
792 }
793
794
795
796