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