xref: /trunk/main/sw/source/core/inc/ftnboss.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 _FTNBOSS_HXX
28 #define _FTNBOSS_HXX
29 
30 #include "layfrm.hxx"
31 
32 class SwFtnBossFrm;
33 class SwFtnContFrm;
34 class SwFtnFrm;
35 class SwTxtFtn;
36 
37 
38 //Setzen des maximalen Fussnotenbereiches. Restaurieren des alten Wertes im DTor.
39 //Implementierung im ftnfrm.cxx
40 class SwSaveFtnHeight
41 {
42     SwFtnBossFrm *pBoss;
43     const SwTwips nOldHeight;
44     SwTwips nNewHeight;
45 public:
46     SwSaveFtnHeight( SwFtnBossFrm *pBs, const SwTwips nDeadLine );
47     ~SwSaveFtnHeight();
48 };
49 
50 #define NA_ONLY_ADJUST 0
51 #define NA_GROW_SHRINK 1
52 #define NA_GROW_ADJUST 2
53 #define NA_ADJUST_GROW 3
54 
55 class SwFtnBossFrm: public SwLayoutFrm
56 {
57     //Fuer die privaten Fussnotenoperationen
58     friend class SwFrm;
59     friend class SwSaveFtnHeight;
60     friend class SwPageFrm; // fuer das Setzen der MaxFtnHeight
61 
62     //Maximale Hoehe des Fussnotencontainers fuer diese Seite.
63     SwTwips nMaxFtnHeight;
64 
65     SwFtnContFrm *MakeFtnCont();
66     SwFtnFrm     *FindFirstFtn();
67     sal_uInt8 _NeighbourhoodAdjustment( const SwFrm* pFrm ) const;
68 protected:
69 
70     void          InsertFtn( SwFtnFrm * );
71     static void   ResetFtn( const SwFtnFrm *pAssumed );
72 public:
73     inline SwFtnBossFrm( SwFrmFmt* pFmt, SwFrm* pSib ) : SwLayoutFrm( pFmt, pSib ) {}
74 
75                  SwLayoutFrm *FindBodyCont();
76     inline const SwLayoutFrm *FindBodyCont() const;
77     inline void SetMaxFtnHeight( const SwTwips nNewMax ) { nMaxFtnHeight = nNewMax; }
78 
79     //Fussnotenschnittstelle
80     void AppendFtn( SwCntntFrm *, SwTxtFtn * );
81     void RemoveFtn( const SwCntntFrm *, const SwTxtFtn *, sal_Bool bPrep = sal_True );
82     static       SwFtnFrm     *FindFtn( const SwCntntFrm *, const SwTxtFtn * );
83                  SwFtnContFrm *FindFtnCont();
84     inline const SwFtnContFrm *FindFtnCont() const;
85            const SwFtnFrm     *FindFirstFtn( SwCntntFrm* ) const;
86                  SwFtnContFrm *FindNearestFtnCont( sal_Bool bDontLeave = sal_False );
87 
88     void ChangeFtnRef( const SwCntntFrm *pOld, const SwTxtFtn *,
89                        SwCntntFrm *pNew );
90     void RearrangeFtns( const SwTwips nDeadLine, const sal_Bool bLock = sal_False,
91                         const SwTxtFtn *pAttr = 0 );
92 
93     //SS damit der Textformatierer Temporaer die Fussnotenhoehe begrenzen
94     //kann. DeadLine in Dokumentkoordinaten.
95     void    SetFtnDeadLine( const SwTwips nDeadLine );
96     SwTwips GetMaxFtnHeight() const { return nMaxFtnHeight; }
97 
98     //Liefert den Wert, der noch uebrig ist, bis der Body seine minimale
99     //Hoehe erreicht hat.
100     SwTwips GetVarSpace() const;
101 
102         //Layoutseitig benoetigte Methoden
103     /// OD 03.04.2003 #108446# - add parameters <_bCollectOnlyPreviousFtns> and
104     /// <_pRefFtnBossFrm> in order to control, if only footnotes, which are positioned
105     /// before the given reference footnote boss frame have to be collected.
106     /// Note: if parameter <_bCollectOnlyPreviousFtns> is true, then parameter
107     /// <_pRefFtnBossFrm> have to be referenced to an object.
108     static void _CollectFtns( const SwCntntFrm*   _pRef,
109                               SwFtnFrm*           _pFtn,
110                               SvPtrarr&           _rFtnArr,
111                               const sal_Bool      _bCollectOnlyPreviousFtns = sal_False,
112                               const SwFtnBossFrm* _pRefFtnBossFrm = NULL);
113     /// OD 03.04.2003 #108446# - add parameter <_bCollectOnlyPreviousFtns> in
114     /// order to control, if only footnotes, which are positioned before the
115     /// footnote boss frame <this> have to be collected.
116     void    CollectFtns( const SwCntntFrm* _pRef,
117                          SwFtnBossFrm*     _pOld,
118                          SvPtrarr&         _rFtnArr,
119                          const sal_Bool    _bCollectOnlyPreviousFtns = sal_False );
120     void    _MoveFtns( SvPtrarr &rFtnArr, sal_Bool bCalc = sal_False );
121     void    MoveFtns( const SwCntntFrm *pSrc, SwCntntFrm *pDest,
122                       SwTxtFtn *pAttr );
123     // Sollte AdjustNeighbourhood gerufen werden (oder Grow/Shrink)?
124     sal_uInt8 NeighbourhoodAdjustment( const SwFrm* pFrm ) const
125         { return IsPageFrm() ? NA_ONLY_ADJUST : _NeighbourhoodAdjustment( pFrm ); }
126 };
127 
128 inline const SwLayoutFrm *SwFtnBossFrm::FindBodyCont() const
129 {
130     return ((SwFtnBossFrm*)this)->FindBodyCont();
131 }
132 inline const SwFtnContFrm *SwFtnBossFrm::FindFtnCont() const
133 {
134     return ((SwFtnBossFrm*)this)->FindFtnCont();
135 }
136 
137 #endif  //_FTNBOSS_HXX
138