1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sectfrm.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #include <tools/mempool.hxx>
35 #include "flowfrm.hxx"
43 #define FINDMODE_ENDNOTE 1
44 #define FINDMODE_LASTCNT 2
45 #define FINDMODE_MYLAST 4
47 class SwSectionFrm
: public SwLayoutFrm
, public SwFlowFrm
51 void _UpdateAttr( SfxPoolItem
*, SfxPoolItem
*, BYTE
&,
52 SwAttrSetChg
*pa
= 0, SwAttrSetChg
*pb
= 0 );
53 void _Cut( BOOL bRemove
);
54 // Is there a FtnContainer?
55 // An empty sectionfrm without FtnCont is superfluous
56 BOOL
IsSuperfluous() const { return !ContainsAny() && !ContainsFtnCont(); }
57 void CalcFtnAtEndFlag();
58 void CalcEndAtEndFlag();
59 const SwSectionFmt
* _GetEndSectFmt() const;
60 BOOL
IsEndnoteAtMyEnd() const;
62 virtual void MakeAll();
63 virtual BOOL
ShouldBwdMoved( SwLayoutFrm
*pNewUpper
, BOOL bHead
, BOOL
&rReformat
);
64 virtual void Format( const SwBorderAttrs
*pAttrs
= 0 );
66 SwSectionFrm( SwSection
& ); //Inhalt wird nicht erzeugt!
67 SwSectionFrm( SwSectionFrm
&, BOOL bMaster
);//_Nur_ zum Erzeugen von Master/Follows
71 virtual void CheckDirection( BOOL bVert
);
74 virtual void Paste( SwFrm
* pParent
, SwFrm
* pSibling
= 0 );
75 virtual void Modify( SfxPoolItem
*, SfxPoolItem
* );
77 inline const SwSectionFrm
*GetFollow() const;
78 inline SwSectionFrm
*GetFollow();
79 SwSectionFrm
* FindMaster() const;
81 SwCntntFrm
*FindLastCntnt( BYTE nMode
= 0 );
82 inline const SwCntntFrm
*FindLastCntnt( BYTE nMode
= 0 ) const;
83 inline SwSection
* GetSection() { return pSection
; }
84 inline const SwSection
* GetSection() const { return pSection
; }
85 inline void ColLock() { bColLocked
= TRUE
; }
86 inline void ColUnlock() { bColLocked
= FALSE
; }
90 BOOL
IsDescendantFrom( const SwSectionFmt
* pSect
) const;
91 BOOL
HasToBreak( const SwFrm
* pFrm
) const;
92 void MergeNext( SwSectionFrm
* pNxt
);
93 //Zerlegt den pFrm umgebenden SectionFrm in zwei Teile,
94 //pFrm an den Anfang des 2. Teils
95 BOOL
SplitSect( SwFrm
* pFrm
, BOOL bApres
);
96 void DelEmpty( BOOL bRemove
); // wie Cut(), Follow-Verkettung wird aber mitgepflegt
97 BOOL
IsToIgnore() const // Keine Groesse, kein Inhalt, muss ignoriert werden
98 { return !Frm().Height() && !ContainsCntnt(); }
99 SwFtnContFrm
* ContainsFtnCont( const SwFtnContFrm
* pCont
= NULL
) const;
100 BOOL
Growable() const;
101 SwTwips
_Shrink( SwTwips
, BOOL bTst
);
102 SwTwips
_Grow ( SwTwips
, BOOL bTst
);
104 // A sectionfrm has to maximize, if he has a follow or a ftncontainer at
105 // the end of the page. A superfluous follow will be ignored,
106 // if bCheckFollow is set.
107 BOOL
ToMaximize( BOOL bCheckFollow
) const;
108 inline BOOL
_ToMaximize() const
109 { if( !pSection
) return FALSE
; return ToMaximize( FALSE
); }
110 BOOL
MoveAllowed( const SwFrm
* ) const;
111 BOOL
CalcMinDiff( SwTwips
& rMinDiff
) const;
112 // Uebergibt man kein bOverSize bzw. FALSE, so ist der Returnwert
113 // >0 fuer Undersized-Frames, ==0 sonst.
114 // Uebergibt man TRUE, so kann es auch einen negativen Returnwert geben,
115 // wenn der SectionFrm nicht vollstaendig ausgefuellt ist, was z.B. bei
116 // SectionFrm mit Follow meist vorkommt. Benoetigt wird dies im
117 // FormatWidthCols, um "Luft" aus den Spalten zu lassen.
118 long Undersize( BOOL bOverSize
= FALSE
);
119 // Groesse an die Umgebung anpassen
120 void _CheckClipping( BOOL bGrow
, BOOL bMaximize
);
122 void InvalidateFtnPos();
123 void CollectEndnotes( SwLayouter
* pLayouter
);
124 const SwSectionFmt
* GetEndSectFmt() const
125 { if( IsEndnAtEnd() ) return _GetEndSectFmt(); return NULL
; }
127 static void MoveCntntAndDelete( SwSectionFrm
* pDel
, BOOL bSave
);
129 bool IsBalancedSection() const;
131 DECL_FIXEDMEMPOOL_NEWDEL(SwSectionFrm
)
134 typedef SwSectionFrm
* SwSectionFrmPtr
;
135 SV_DECL_PTRARR_SORT( SwDestroyList
, SwSectionFrmPtr
, 1, 5)
137 inline const SwSectionFrm
*SwSectionFrm::GetFollow() const
139 return (const SwSectionFrm
*)SwFlowFrm::GetFollow();
141 inline SwSectionFrm
*SwSectionFrm::GetFollow()
143 return (SwSectionFrm
*)SwFlowFrm::GetFollow();
145 inline const SwCntntFrm
*SwSectionFrm::FindLastCntnt( BYTE nMode
) const
147 return ((SwSectionFrm
*)this)->FindLastCntnt( nMode
);
151 #endif //_SECTFRM_HXX