xref: /aoo4110/main/sw/source/core/inc/sectfrm.hxx (revision b1cdbd2c)
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 #ifndef _SECTFRM_HXX
24 #define _SECTFRM_HXX
25 #include <tools/mempool.hxx>
26 
27 #include "layfrm.hxx"
28 #include "flowfrm.hxx"
29 
30 class SwSection;
31 class SwSectionFmt;
32 class SwAttrSetChg;
33 class SwFtnContFrm;
34 class SwLayouter;
35 
36 #define FINDMODE_ENDNOTE 1
37 #define FINDMODE_LASTCNT 2
38 #define FINDMODE_MYLAST  4
39 
40 class SwSectionFrm: public SwLayoutFrm, public SwFlowFrm
41 {
42 	SwSection* pSection;
43 
44 	void _UpdateAttr( const SfxPoolItem*, const SfxPoolItem*, sal_uInt8 &,
45 					  SwAttrSetChg *pa = 0, SwAttrSetChg *pb = 0 );
46 	void _Cut( sal_Bool bRemove );
47 	// Is there a FtnContainer?
48 	// An empty sectionfrm without FtnCont is superfluous
IsSuperfluous() const49 	sal_Bool IsSuperfluous() const { return !ContainsAny() && !ContainsFtnCont(); }
50 	void CalcFtnAtEndFlag();
51 	void CalcEndAtEndFlag();
52 	const SwSectionFmt* _GetEndSectFmt() const;
53 	sal_Bool IsEndnoteAtMyEnd() const;
54 protected:
55 	virtual void MakeAll();
56 	virtual sal_Bool ShouldBwdMoved( SwLayoutFrm *pNewUpper, sal_Bool bHead, sal_Bool &rReformat );
57 	virtual void Format( const SwBorderAttrs *pAttrs = 0 );
58 	virtual	void Modify( const SfxPoolItem*, const SfxPoolItem* );
59 	virtual void SwClientNotify( const SwModify&, const SfxHint& );
60 
61 public:
62 	SwSectionFrm( SwSection &, SwFrm* );				 //Inhalt wird nicht erzeugt!
63     SwSectionFrm( SwSectionFrm &, sal_Bool bMaster );//_Nur_ zum Erzeugen von Master/Follows
64 	~SwSectionFrm();
65 
66     void Init();
67     virtual void  CheckDirection( sal_Bool bVert );
68 
69 	virtual void Cut();
70 	virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 );
71 
72 	inline const SwSectionFrm *GetFollow() const;
73 	inline		 SwSectionFrm *GetFollow();
74     SwSectionFrm* FindMaster() const;
75 
76                  SwCntntFrm *FindLastCntnt( sal_uInt8 nMode = 0 );
77 	inline const SwCntntFrm *FindLastCntnt( sal_uInt8 nMode = 0 ) const;
GetSection()78 	inline SwSection* GetSection() { return pSection; }
GetSection() const79 	inline const SwSection* GetSection() const { return pSection; }
ColLock()80 	inline void ColLock()		{ bColLocked = sal_True; }
ColUnlock()81 	inline void ColUnlock()   	{ bColLocked = sal_False; }
82 
83 	void CalcFtnCntnt();
84 	void SimpleFormat();
85 	sal_Bool IsDescendantFrom( const SwSectionFmt* pSect ) const;
86 	sal_Bool HasToBreak( const SwFrm* pFrm ) const;
87 	void MergeNext( SwSectionFrm* pNxt );
88 	//Zerlegt den pFrm umgebenden SectionFrm in zwei Teile,
89 	//pFrm an den Anfang des 2. Teils
90 	sal_Bool SplitSect( SwFrm* pFrm, sal_Bool bApres );
91 	void DelEmpty( sal_Bool bRemove ); 	// wie Cut(), Follow-Verkettung wird aber mitgepflegt
IsToIgnore() const92 	sal_Bool IsToIgnore() const			// Keine Groesse, kein Inhalt, muss ignoriert werden
93 	{ return !Frm().Height() && !ContainsCntnt(); }
94     SwFtnContFrm* ContainsFtnCont( const SwFtnContFrm* pCont = NULL ) const;
95 	sal_Bool Growable() const;
96     SwTwips _Shrink( SwTwips, sal_Bool bTst );
97     SwTwips _Grow  ( SwTwips, sal_Bool bTst );
98 
99 	// A sectionfrm has to maximize, if he has a follow or a ftncontainer at
100 	// the end of the page. A superfluous follow will be ignored,
101 	// if bCheckFollow is set.
102 	sal_Bool ToMaximize( sal_Bool bCheckFollow ) const;
_ToMaximize() const103 	inline sal_Bool _ToMaximize() const
104 		{ if( !pSection ) return sal_False; return ToMaximize( sal_False );	}
105 	sal_Bool MoveAllowed( const SwFrm* ) const;
106 	sal_Bool CalcMinDiff( SwTwips& rMinDiff ) const;
107 	// Uebergibt man kein bOverSize bzw. sal_False, so ist der Returnwert
108 	// >0 fuer Undersized-Frames, ==0 sonst.
109 	// Uebergibt man sal_True, so kann es auch einen negativen Returnwert geben,
110 	// wenn der SectionFrm nicht vollstaendig ausgefuellt ist, was z.B. bei
111 	// SectionFrm mit Follow meist vorkommt. Benoetigt wird dies im
112 	// FormatWidthCols, um "Luft" aus den Spalten zu lassen.
113 	long Undersize( sal_Bool bOverSize = sal_False );
114 	// Groesse an die Umgebung anpassen
115 	void _CheckClipping( sal_Bool bGrow, sal_Bool bMaximize );
116 
117 	void InvalidateFtnPos();
118 	void CollectEndnotes( SwLayouter* pLayouter );
GetEndSectFmt() const119 	const SwSectionFmt* GetEndSectFmt() const
120 		{ if( IsEndnAtEnd() ) return _GetEndSectFmt(); return NULL; }
121 
122 	static void MoveCntntAndDelete( SwSectionFrm* pDel, sal_Bool bSave );
123 
124     bool IsBalancedSection() const;
125 
126 	DECL_FIXEDMEMPOOL_NEWDEL(SwSectionFrm)
127 };
128 
129 typedef SwSectionFrm* SwSectionFrmPtr;
130 SV_DECL_PTRARR_SORT( SwDestroyList, SwSectionFrmPtr, 1, 5)
131 
GetFollow() const132 inline const SwSectionFrm *SwSectionFrm::GetFollow() const
133 {
134 	return (const SwSectionFrm*)SwFlowFrm::GetFollow();
135 }
GetFollow()136 inline SwSectionFrm *SwSectionFrm::GetFollow()
137 {
138 	return (SwSectionFrm*)SwFlowFrm::GetFollow();
139 }
FindLastCntnt(sal_uInt8 nMode) const140 inline const SwCntntFrm *SwSectionFrm::FindLastCntnt( sal_uInt8 nMode ) const
141 {
142 	return ((SwSectionFrm*)this)->FindLastCntnt( nMode );
143 }
144 
145 
146 #endif	//_SECTFRM_HXX
147