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