xref: /aoo4110/main/sw/source/core/inc/flowfrm.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 _FLOWFRM_HXX
24 #define _FLOWFRM_HXX
25 
26 //Der FlowFrm gibt die Funktionalitaet fuer alle Frms vor, die fliessen und
27 //die sich aufspalten koennen (wie CntntFrm oder TabFrm).
28 //Teile der Funktionalitaet sind im FlowFrm implementiert, andere Teile werden
29 //von den spezifischen Frms implementiert.
30 //Der FlowFrm ist kein eigenstaender Frm, es kann also auch niemals eine
31 //eigenstaendige Instanz vom FlowFrm existieren.
32 //Der FlowFrm ist nicht einmal ein echter Frm. Die naheliegende Implementierung
33 //waere ein FlowFrm der virtual vom SwFrm abgeleitet ist und direkt auf den
34 //eigenen Instanzdaten arbeitet. Abgeleitete Klassen muessten sich
35 //vom FlowFrm und (ueber mehrere Basisklassen weil der Klassenbaum sich direkt
36 //vom SwFrm zu SwCntntFrm und zum SwLayoutFrm spaltet) virtual vom SwFrm
37 //ableiten.
38 //Leider entstehen dadurch - neben Problemen mit Compilern und Debuggern -
39 //erhebliche zusaetzliche Kosten, die wir uns heutzutage IMHO nicht erlauben
40 //koennen.
41 //Ich greife deshalb auf eine andere Technik zurueck: Der FlowFrm hat eine
42 //Referenz auf den SwFrm - der er genau betrachtet selbst ist - und ist mit
43 //diesem befreundet. So kann der FlowFrm anstelle des this-Pointer mit der
44 //Referenz auf den SwFrm arbeiten.
45 
46 //#include "frame.hxx"   //fuer inlines
47 
48 class SwPageFrm;
49 class SwRect;
50 class SwBorderAttrs;
51 class SwDoc;
52 class SwNodeIndex;
53 // --> OD 2005-03-04 #i44049#
54 class SwObjectFormatterTxtFrm;
55 // <--
56 
57 void MakeFrms( SwDoc *, const SwNodeIndex &, const SwNodeIndex & );
58 
59 class SwFlowFrm
60 {
61 	//PrepareMake darf Locken/Unlocken (Robustheit)
62 	friend inline void PrepareLock  ( SwFlowFrm * );
63 	friend inline void PrepareUnlock( SwFlowFrm * );
64     friend inline void TableSplitRecalcLock( SwFlowFrm * );
65     friend inline void TableSplitRecalcUnlock( SwFlowFrm * );
66     // --> OD 2005-03-04 #i44049#
67     friend class SwObjectFormatterTxtFrm;
68     // <--
69 
70 	//TblSel darf das Follow-Bit zuruecksetzen.
71 	friend inline void UnsetFollow( SwFlowFrm *pFlow );
72 
73 	friend void MakeFrms( SwDoc *, const SwNodeIndex &, const SwNodeIndex & );
74 
75 	friend class SwNode2LayImpl;
76 
77 	SwFrm &rThis;
78 
79 	//Hilfsfunktionen fuer MoveSubTree()
80 	static SwLayoutFrm *CutTree( SwFrm* );
81 	static sal_Bool   PasteTree( SwFrm *, SwLayoutFrm *, SwFrm *, SwFrm* );
82 
83 	//Wird fuer das Zusammenspiel von _GetPrevxxx und MoveBwd gebraucht, damit
84 	//mehrere Blaetter gleichzeitig uebersprungen werden koennen.
85 	//Wird auch vom MoveBwd des TabFrm ausgewertet!
86 	static sal_Bool bMoveBwdJump;
87 
88     /** helper method to determine previous frame for calculation of the
89         upper space
90 
91         OD 2004-03-10 #i11860#
92 
93         @param _pProposedPrevFrm
94         optional input parameter - pointer to frame, which should be used
95         instead of the direct previous frame.
96 
97         @author OD
98     */
99     const SwFrm* _GetPrevFrmForUpperSpaceCalc( const SwFrm* _pProposedPrevFrm = 0L ) const;
100 
101     /** method to detemine the upper space amount, which is considered for
102         the previous frame
103 
104         OD 2004-03-11 #i11860#
105 
106         @author OD
107     */
108     SwTwips _GetUpperSpaceAmountConsideredForPrevFrm() const;
109 
110     /** method to detemine the upper space amount, which is considered for
111         the page grid
112 
113         OD 2004-03-12 #i11860#
114 
115         @author OD
116     */
117     SwTwips _GetUpperSpaceAmountConsideredForPageGrid(
118                                 const SwTwips _nUpperSpaceWithoutGrid ) const;
119 
120 protected:
121 
122 	SwFlowFrm *pFollow;
123 
124 	sal_Bool bIsFollow	:1;	//Ist's ein Follow
125 	sal_Bool bLockJoin	:1;	//Join (und damit deleten) verboten wenn sal_True!
126 	sal_Bool bUndersized:1; // wir sind kleiner als gewuenscht
127 	sal_Bool bFtnAtEnd	:1; // For sectionfrms only: footnotes at the end of section
128 	sal_Bool bEndnAtEnd	:1; // 	"		"		 " : endnotes at the end of section
129 	sal_Bool bCntntLock	:1; //  "       "        " : content locked
130 	sal_Bool bOwnFtnNum	:1; //  "       "        " : special numbering of footnotes
131 	sal_Bool bFtnLock	:1; //  "       "        " : ftn, don't leave this section bwd
132     sal_Bool bFlyLock   :1; //  Stop positioning of at-character flyframes
133 
134 	//Prueft ob Vorwaertsfluss noch Sinn macht Endloswanderschaften (unterbinden)
135 	inline sal_Bool IsFwdMoveAllowed();
136     // --> OD 2005-03-08 #i44049# - method <CalcCntnt(..)> has to check this property.
137     friend void CalcCntnt( SwLayoutFrm *pLay, bool bNoColl, bool bNoCalcFollow );
138     // <--
139 	sal_Bool IsKeepFwdMoveAllowed();	//Wie oben, Move fuer Keep.
140 
141 	//Prueft ob ein Obj das Umlauf wuenscht ueberlappt.
142 	//eine Null bedeutet, kein Objekt ueberlappt,
143 	// 1 heisst, Objekte, die am FlowFrm selbst verankert sind, ueberlappen
144 	// 2 heisst, Objekte, die woanders verankert sind, ueberlappen
145 	// 3 heistt, beiderlei verankerte Objekte ueberlappen
146 	sal_uInt8 BwdMoveNecessary( const SwPageFrm *pPage, const SwRect &rRect );
147 
LockJoin()148 	void LockJoin()   { bLockJoin = sal_True;  }
UnlockJoin()149 	void UnlockJoin() { bLockJoin = sal_False; }
150 
151 			sal_Bool CheckMoveFwd( sal_Bool &rbMakePage, sal_Bool bKeep, sal_Bool bMovedBwd );
152 			sal_Bool MoveFwd( sal_Bool bMakePage, sal_Bool bPageBreak, sal_Bool bMoveAlways = sal_False );
153 	virtual sal_Bool ShouldBwdMoved( SwLayoutFrm *pNewUpper, sal_Bool bHead, sal_Bool &rReformat )=0;
154 			sal_Bool MoveBwd( sal_Bool &rbReformat );
155 
156 public:
157 	SwFlowFrm( SwFrm &rFrm );
158 
GetFrm() const159 	const SwFrm *GetFrm() const 		   { return &rThis; }
GetFrm()160 		  SwFrm *GetFrm()				   { return &rThis; }
161 
IsMoveBwdJump()162 	static sal_Bool IsMoveBwdJump()			   { return bMoveBwdJump; }
SetMoveBwdJump(sal_Bool bNew)163 	static void SetMoveBwdJump( sal_Bool bNew ){ bMoveBwdJump = bNew; }
164 
SetUndersized(const sal_Bool bNew)165 	inline void SetUndersized( const sal_Bool bNew ) { bUndersized = bNew; }
IsUndersized() const166 	inline sal_Bool IsUndersized() 	const { return bUndersized;	}
167 
168 	sal_Bool IsPrevObjMove() const;
169 
170 	//Die Kette mit minimalen Operationen und Benachrichtigungen unter den
171 	//neuen Parent Moven.
172 	void MoveSubTree( SwLayoutFrm* pParent, SwFrm* pSibling = 0 );
173 
HasFollow() const174 		   sal_Bool 	  HasFollow() const    { return pFollow ? sal_True : sal_False; }
IsFollow() const175 		   sal_Bool		  IsFollow()     const { return bIsFollow; }
_SetIsFollow(sal_Bool bSet)176 	inline void		  _SetIsFollow( sal_Bool bSet ) { bIsFollow = bSet; }
GetFollow() const177 	const  SwFlowFrm *GetFollow() const	   { return pFollow;   }
GetFollow()178 		   SwFlowFrm *GetFollow()	   	   { return pFollow;   }
179 		   sal_Bool  	  IsAnFollow( const SwFlowFrm *pFlow ) const;
SetFollow(SwFlowFrm * pNew)180 	inline void   	  SetFollow( SwFlowFrm *pNew ) { pFollow = pNew; }
181 
IsJoinLocked() const182     sal_Bool IsJoinLocked() const { return bLockJoin; }
IsAnyJoinLocked() const183     sal_Bool IsAnyJoinLocked() const { return bLockJoin || HasLockedFollow(); }
IsFtnAtEnd() const184 	sal_Bool IsFtnAtEnd() const { return bFtnAtEnd;	}
IsEndnAtEnd() const185 	sal_Bool IsEndnAtEnd() const { return bEndnAtEnd;	}
IsAnyNoteAtEnd() const186 	sal_Bool IsAnyNoteAtEnd() const { return bFtnAtEnd || bEndnAtEnd; }
AreNotesAtEnd() const187 	sal_Bool AreNotesAtEnd() const { return bFtnAtEnd && bEndnAtEnd; }
188 
189 	sal_Bool IsPageBreak( sal_Bool bAct ) const;
190 	sal_Bool IsColBreak( sal_Bool bAct ) const;
191 
192     //Ist ein Keep zu beruecksichtigen (Breaks!)
193     sal_Bool IsKeep( const SwAttrSet& rAttrs, bool bBreakCheck = false ) const;
194 
195     sal_Bool HasLockedFollow() const;
196 
197     sal_Bool HasParaSpaceAtPages( sal_Bool bSct ) const;
198 
199     /** method to determine the upper space hold by the frame
200 
201         OD 2004-03-12 #i11860# - add 3rd parameter <_bConsiderGrid> to get
202         the upper space with and without considering the page grid
203         (default value: <sal_True>)
204 
205         @author ?
206     */
207     SwTwips CalcUpperSpace( const SwBorderAttrs *pAttrs = NULL,
208                             const SwFrm* pPr = NULL,
209                             const bool _bConsiderGrid = true ) const;
210 
211     /** method to determine the upper space amount, which is considered for
212         the previous frame and the page grid, if option 'Use former object
213         positioning' is OFF
214 
215         OD 2004-03-18 #i11860#
216 
217         @author OD
218     */
219     SwTwips GetUpperSpaceAmountConsideredForPrevFrmAndPageGrid() const;
220 
221     /** calculation of lower space
222 
223         OD 2004-03-02 #106629#
224 
225         @author OD
226     */
227     SwTwips CalcLowerSpace( const SwBorderAttrs* _pAttrs = 0L ) const;
228 
229     /** calculation of the additional space to be considered, if flow frame
230         is the last inside a table cell
231 
232         OD 2004-07-16 #i26250
233 
234         @author OD
235 
236         @param _pAttrs
237         optional input parameter - border attributes of the flow frame.
238         Used for optimization, if caller has already determined the border
239         attributes.
240 
241         @return SwTwips
242     */
243     SwTwips CalcAddLowerSpaceAsLastInTableCell(
244                                     const SwBorderAttrs* _pAttrs = 0L ) const;
245 
246     void CheckKeep();
247 
SetFtnLock(sal_Bool bNew)248 	void SetFtnLock( sal_Bool bNew ){ bFtnLock = bNew; }
IsFtnLock() const249 	sal_Bool IsFtnLock() const {	return bFtnLock; }
SetFlyLock(sal_Bool bNew)250     void SetFlyLock( sal_Bool bNew ){ bFlyLock = bNew; }
IsFlyLock() const251     sal_Bool IsFlyLock() const {    return bFlyLock; }
SetOwnFtnNum(sal_Bool bNew)252 	void SetOwnFtnNum( sal_Bool bNew ){ bOwnFtnNum = bNew; }
IsOwnFtnNum() const253 	sal_Bool IsOwnFtnNum() const {	return bOwnFtnNum; }
SetCntntLock(sal_Bool bNew)254 	void SetCntntLock( sal_Bool bNew ){ bCntntLock = bNew; }
IsCntntLocked() const255 	sal_Bool IsCntntLocked() const {	return bCntntLock; }
256 
257 	//casten einen Frm auf einen FlowFrm - wenns denn einer ist, sonst 0
258 	//Diese Methoden muessen fuer neue Ableitungen geaendert werden!
259 	static 		 SwFlowFrm *CastFlowFrm( SwFrm *pFrm );
260 	static const SwFlowFrm *CastFlowFrm( const SwFrm *pFrm );
261 };
262 
IsFwdMoveAllowed()263 inline sal_Bool SwFlowFrm::IsFwdMoveAllowed()
264 {
265 	return rThis.GetIndPrev() != 0;
266 }
267 
268 
269 #endif
270