1*1d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*1d2dbeb0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*1d2dbeb0SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*1d2dbeb0SAndrew Rist * distributed with this work for additional information
6*1d2dbeb0SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*1d2dbeb0SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*1d2dbeb0SAndrew Rist * "License"); you may not use this file except in compliance
9*1d2dbeb0SAndrew Rist * with the License. You may obtain a copy of the License at
10*1d2dbeb0SAndrew Rist *
11*1d2dbeb0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*1d2dbeb0SAndrew Rist *
13*1d2dbeb0SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*1d2dbeb0SAndrew Rist * software distributed under the License is distributed on an
15*1d2dbeb0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1d2dbeb0SAndrew Rist * KIND, either express or implied. See the License for the
17*1d2dbeb0SAndrew Rist * specific language governing permissions and limitations
18*1d2dbeb0SAndrew Rist * under the License.
19*1d2dbeb0SAndrew Rist *
20*1d2dbeb0SAndrew Rist *************************************************************/
21*1d2dbeb0SAndrew Rist
22*1d2dbeb0SAndrew Rist
23cdf0e10cSrcweir #ifndef _SECTFRM_HXX
24cdf0e10cSrcweir #define _SECTFRM_HXX
25cdf0e10cSrcweir #include <tools/mempool.hxx>
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "layfrm.hxx"
28cdf0e10cSrcweir #include "flowfrm.hxx"
29cdf0e10cSrcweir
30cdf0e10cSrcweir class SwSection;
31cdf0e10cSrcweir class SwSectionFmt;
32cdf0e10cSrcweir class SwAttrSetChg;
33cdf0e10cSrcweir class SwFtnContFrm;
34cdf0e10cSrcweir class SwLayouter;
35cdf0e10cSrcweir
36cdf0e10cSrcweir #define FINDMODE_ENDNOTE 1
37cdf0e10cSrcweir #define FINDMODE_LASTCNT 2
38cdf0e10cSrcweir #define FINDMODE_MYLAST 4
39cdf0e10cSrcweir
40cdf0e10cSrcweir class SwSectionFrm: public SwLayoutFrm, public SwFlowFrm
41cdf0e10cSrcweir {
42cdf0e10cSrcweir SwSection* pSection;
43cdf0e10cSrcweir
44cdf0e10cSrcweir void _UpdateAttr( const SfxPoolItem*, const SfxPoolItem*, sal_uInt8 &,
45cdf0e10cSrcweir SwAttrSetChg *pa = 0, SwAttrSetChg *pb = 0 );
46cdf0e10cSrcweir void _Cut( sal_Bool bRemove );
47cdf0e10cSrcweir // Is there a FtnContainer?
48cdf0e10cSrcweir // An empty sectionfrm without FtnCont is superfluous
IsSuperfluous() const49cdf0e10cSrcweir sal_Bool IsSuperfluous() const { return !ContainsAny() && !ContainsFtnCont(); }
50cdf0e10cSrcweir void CalcFtnAtEndFlag();
51cdf0e10cSrcweir void CalcEndAtEndFlag();
52cdf0e10cSrcweir const SwSectionFmt* _GetEndSectFmt() const;
53cdf0e10cSrcweir sal_Bool IsEndnoteAtMyEnd() const;
54cdf0e10cSrcweir protected:
55cdf0e10cSrcweir virtual void MakeAll();
56cdf0e10cSrcweir virtual sal_Bool ShouldBwdMoved( SwLayoutFrm *pNewUpper, sal_Bool bHead, sal_Bool &rReformat );
57cdf0e10cSrcweir virtual void Format( const SwBorderAttrs *pAttrs = 0 );
58cdf0e10cSrcweir virtual void Modify( const SfxPoolItem*, const SfxPoolItem* );
59cdf0e10cSrcweir virtual void SwClientNotify( const SwModify&, const SfxHint& );
60cdf0e10cSrcweir
61cdf0e10cSrcweir public:
62cdf0e10cSrcweir SwSectionFrm( SwSection &, SwFrm* ); //Inhalt wird nicht erzeugt!
63cdf0e10cSrcweir SwSectionFrm( SwSectionFrm &, sal_Bool bMaster );//_Nur_ zum Erzeugen von Master/Follows
64cdf0e10cSrcweir ~SwSectionFrm();
65cdf0e10cSrcweir
66cdf0e10cSrcweir void Init();
67cdf0e10cSrcweir virtual void CheckDirection( sal_Bool bVert );
68cdf0e10cSrcweir
69cdf0e10cSrcweir virtual void Cut();
70cdf0e10cSrcweir virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 );
71cdf0e10cSrcweir
72cdf0e10cSrcweir inline const SwSectionFrm *GetFollow() const;
73cdf0e10cSrcweir inline SwSectionFrm *GetFollow();
74cdf0e10cSrcweir SwSectionFrm* FindMaster() const;
75cdf0e10cSrcweir
76cdf0e10cSrcweir SwCntntFrm *FindLastCntnt( sal_uInt8 nMode = 0 );
77cdf0e10cSrcweir inline const SwCntntFrm *FindLastCntnt( sal_uInt8 nMode = 0 ) const;
GetSection()78cdf0e10cSrcweir inline SwSection* GetSection() { return pSection; }
GetSection() const79cdf0e10cSrcweir inline const SwSection* GetSection() const { return pSection; }
ColLock()80cdf0e10cSrcweir inline void ColLock() { bColLocked = sal_True; }
ColUnlock()81cdf0e10cSrcweir inline void ColUnlock() { bColLocked = sal_False; }
82cdf0e10cSrcweir
83cdf0e10cSrcweir void CalcFtnCntnt();
84cdf0e10cSrcweir void SimpleFormat();
85cdf0e10cSrcweir sal_Bool IsDescendantFrom( const SwSectionFmt* pSect ) const;
86cdf0e10cSrcweir sal_Bool HasToBreak( const SwFrm* pFrm ) const;
87cdf0e10cSrcweir void MergeNext( SwSectionFrm* pNxt );
88cdf0e10cSrcweir //Zerlegt den pFrm umgebenden SectionFrm in zwei Teile,
89cdf0e10cSrcweir //pFrm an den Anfang des 2. Teils
90cdf0e10cSrcweir sal_Bool SplitSect( SwFrm* pFrm, sal_Bool bApres );
91cdf0e10cSrcweir void DelEmpty( sal_Bool bRemove ); // wie Cut(), Follow-Verkettung wird aber mitgepflegt
IsToIgnore() const92cdf0e10cSrcweir sal_Bool IsToIgnore() const // Keine Groesse, kein Inhalt, muss ignoriert werden
93cdf0e10cSrcweir { return !Frm().Height() && !ContainsCntnt(); }
94cdf0e10cSrcweir SwFtnContFrm* ContainsFtnCont( const SwFtnContFrm* pCont = NULL ) const;
95cdf0e10cSrcweir sal_Bool Growable() const;
96cdf0e10cSrcweir SwTwips _Shrink( SwTwips, sal_Bool bTst );
97cdf0e10cSrcweir SwTwips _Grow ( SwTwips, sal_Bool bTst );
98cdf0e10cSrcweir
99cdf0e10cSrcweir // A sectionfrm has to maximize, if he has a follow or a ftncontainer at
100cdf0e10cSrcweir // the end of the page. A superfluous follow will be ignored,
101cdf0e10cSrcweir // if bCheckFollow is set.
102cdf0e10cSrcweir sal_Bool ToMaximize( sal_Bool bCheckFollow ) const;
_ToMaximize() const103cdf0e10cSrcweir inline sal_Bool _ToMaximize() const
104cdf0e10cSrcweir { if( !pSection ) return sal_False; return ToMaximize( sal_False ); }
105cdf0e10cSrcweir sal_Bool MoveAllowed( const SwFrm* ) const;
106cdf0e10cSrcweir sal_Bool CalcMinDiff( SwTwips& rMinDiff ) const;
107cdf0e10cSrcweir // Uebergibt man kein bOverSize bzw. sal_False, so ist der Returnwert
108cdf0e10cSrcweir // >0 fuer Undersized-Frames, ==0 sonst.
109cdf0e10cSrcweir // Uebergibt man sal_True, so kann es auch einen negativen Returnwert geben,
110cdf0e10cSrcweir // wenn der SectionFrm nicht vollstaendig ausgefuellt ist, was z.B. bei
111cdf0e10cSrcweir // SectionFrm mit Follow meist vorkommt. Benoetigt wird dies im
112cdf0e10cSrcweir // FormatWidthCols, um "Luft" aus den Spalten zu lassen.
113cdf0e10cSrcweir long Undersize( sal_Bool bOverSize = sal_False );
114cdf0e10cSrcweir // Groesse an die Umgebung anpassen
115cdf0e10cSrcweir void _CheckClipping( sal_Bool bGrow, sal_Bool bMaximize );
116cdf0e10cSrcweir
117cdf0e10cSrcweir void InvalidateFtnPos();
118cdf0e10cSrcweir void CollectEndnotes( SwLayouter* pLayouter );
GetEndSectFmt() const119cdf0e10cSrcweir const SwSectionFmt* GetEndSectFmt() const
120cdf0e10cSrcweir { if( IsEndnAtEnd() ) return _GetEndSectFmt(); return NULL; }
121cdf0e10cSrcweir
122cdf0e10cSrcweir static void MoveCntntAndDelete( SwSectionFrm* pDel, sal_Bool bSave );
123cdf0e10cSrcweir
124cdf0e10cSrcweir bool IsBalancedSection() const;
125cdf0e10cSrcweir
126cdf0e10cSrcweir DECL_FIXEDMEMPOOL_NEWDEL(SwSectionFrm)
127cdf0e10cSrcweir };
128cdf0e10cSrcweir
129cdf0e10cSrcweir typedef SwSectionFrm* SwSectionFrmPtr;
130cdf0e10cSrcweir SV_DECL_PTRARR_SORT( SwDestroyList, SwSectionFrmPtr, 1, 5)
131cdf0e10cSrcweir
GetFollow() const132cdf0e10cSrcweir inline const SwSectionFrm *SwSectionFrm::GetFollow() const
133cdf0e10cSrcweir {
134cdf0e10cSrcweir return (const SwSectionFrm*)SwFlowFrm::GetFollow();
135cdf0e10cSrcweir }
GetFollow()136cdf0e10cSrcweir inline SwSectionFrm *SwSectionFrm::GetFollow()
137cdf0e10cSrcweir {
138cdf0e10cSrcweir return (SwSectionFrm*)SwFlowFrm::GetFollow();
139cdf0e10cSrcweir }
FindLastCntnt(sal_uInt8 nMode) const140cdf0e10cSrcweir inline const SwCntntFrm *SwSectionFrm::FindLastCntnt( sal_uInt8 nMode ) const
141cdf0e10cSrcweir {
142cdf0e10cSrcweir return ((SwSectionFrm*)this)->FindLastCntnt( nMode );
143cdf0e10cSrcweir }
144cdf0e10cSrcweir
145cdf0e10cSrcweir
146cdf0e10cSrcweir #endif //_SECTFRM_HXX
147