Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _FTNBOSS_HXX
30 : : #define _FTNBOSS_HXX
31 : :
32 : : #include "layfrm.hxx"
33 : :
34 : : class SwFtnBossFrm;
35 : : class SwFtnContFrm;
36 : : class SwFtnFrm;
37 : : class SwTxtFtn;
38 : :
39 : : // Set max. footnote area.
40 : : // Restoration of the old value in DTor. Implementation in ftnfrm.cxx
41 : : class SwSaveFtnHeight
42 : : {
43 : : SwFtnBossFrm *pBoss;
44 : : const SwTwips nOldHeight;
45 : : SwTwips nNewHeight;
46 : : public:
47 : : SwSaveFtnHeight( SwFtnBossFrm *pBs, const SwTwips nDeadLine );
48 : : ~SwSaveFtnHeight();
49 : : };
50 : :
51 : : #define NA_ONLY_ADJUST 0
52 : : #define NA_GROW_SHRINK 1
53 : : #define NA_GROW_ADJUST 2
54 : : #define NA_ADJUST_GROW 3
55 : :
56 : : typedef std::vector<SwFtnFrm*> SwFtnFrms;
57 : :
58 [ - + ]: 1450 : class SwFtnBossFrm: public SwLayoutFrm
59 : : {
60 : : // for private footnote operations
61 : : friend class SwFrm;
62 : : friend class SwSaveFtnHeight;
63 : : friend class SwPageFrm; // for setting of MaxFtnHeight
64 : :
65 : : // max. height of the footnote container on this page
66 : : SwTwips nMaxFtnHeight;
67 : :
68 : : SwFtnContFrm *MakeFtnCont();
69 : : SwFtnFrm *FindFirstFtn();
70 : : sal_uInt8 _NeighbourhoodAdjustment( const SwFrm* pFrm ) const;
71 : :
72 : : protected:
73 : : void InsertFtn( SwFtnFrm * );
74 : : static void ResetFtn( const SwFtnFrm *pAssumed );
75 : :
76 : : public:
77 : 1543 : inline SwFtnBossFrm( SwFrmFmt* pFmt, SwFrm* pSib ) : SwLayoutFrm( pFmt, pSib ) {}
78 : :
79 : : SwLayoutFrm *FindBodyCont();
80 : : inline const SwLayoutFrm *FindBodyCont() const;
81 : 1667 : inline void SetMaxFtnHeight( const SwTwips nNewMax ) { nMaxFtnHeight = nNewMax; }
82 : :
83 : : // footnote interface
84 : : void AppendFtn( SwCntntFrm *, SwTxtFtn * );
85 : : void RemoveFtn( const SwCntntFrm *, const SwTxtFtn *, sal_Bool bPrep = sal_True );
86 : : static SwFtnFrm *FindFtn( const SwCntntFrm *, const SwTxtFtn * );
87 : : SwFtnContFrm *FindFtnCont();
88 : : inline const SwFtnContFrm *FindFtnCont() const;
89 : : const SwFtnFrm *FindFirstFtn( SwCntntFrm* ) const;
90 : : SwFtnContFrm *FindNearestFtnCont( sal_Bool bDontLeave = sal_False );
91 : :
92 : : void ChangeFtnRef( const SwCntntFrm *pOld, const SwTxtFtn *,
93 : : SwCntntFrm *pNew );
94 : : void RearrangeFtns( const SwTwips nDeadLine, const sal_Bool bLock = sal_False,
95 : : const SwTxtFtn *pAttr = 0 );
96 : :
97 : : // Set DeadLine (in document coordinates) so that the text formatter can
98 : : // temporarily limit footnote height.
99 : : void SetFtnDeadLine( const SwTwips nDeadLine );
100 : 4342 : SwTwips GetMaxFtnHeight() const { return nMaxFtnHeight; }
101 : :
102 : : // returns value for remaining space until the body reaches minimal height
103 : : SwTwips GetVarSpace() const;
104 : :
105 : : // methods needed for layouting
106 : : // The parameters <_bCollectOnlyPreviousFtns> and <_pRefFtnBossFrm> control
107 : : // if only footnotes that are positioned before the given reference
108 : : // footnote boss-frame have to be collected.
109 : : // Note: if parameter <_bCollectOnlyPreviousFtns> is true, then parameter
110 : : // <_pRefFtnBossFrm> has to be referenced by an object.
111 : : static void _CollectFtns( const SwCntntFrm* _pRef,
112 : : SwFtnFrm* _pFtn,
113 : : SwFtnFrms& _rFtnArr,
114 : : const sal_Bool _bCollectOnlyPreviousFtns = sal_False,
115 : : const SwFtnBossFrm* _pRefFtnBossFrm = NULL);
116 : : // The parameter <_bCollectOnlyPreviousFtns> controls if only footnotes
117 : : // that are positioned before the footnote boss-frame <this> have to be
118 : : // collected.
119 : : void CollectFtns( const SwCntntFrm* _pRef,
120 : : SwFtnBossFrm* _pOld,
121 : : SwFtnFrms& _rFtnArr,
122 : : const sal_Bool _bCollectOnlyPreviousFtns = sal_False );
123 : : void _MoveFtns( SwFtnFrms &rFtnArr, sal_Bool bCalc = sal_False );
124 : : void MoveFtns( const SwCntntFrm *pSrc, SwCntntFrm *pDest,
125 : : SwTxtFtn *pAttr );
126 : :
127 : : // should AdjustNeighbourhood be called (or Grow/Shrink)?
128 : 2409 : sal_uInt8 NeighbourhoodAdjustment( const SwFrm* pFrm ) const
129 [ + + ]: 2409 : { return IsPageFrm() ? NA_ONLY_ADJUST : _NeighbourhoodAdjustment( pFrm ); }
130 : : };
131 : :
132 : 19555 : inline const SwLayoutFrm *SwFtnBossFrm::FindBodyCont() const
133 : : {
134 : 19555 : return ((SwFtnBossFrm*)this)->FindBodyCont();
135 : : }
136 : :
137 : 123 : inline const SwFtnContFrm *SwFtnBossFrm::FindFtnCont() const
138 : : {
139 : 123 : return ((SwFtnBossFrm*)this)->FindFtnCont();
140 : : }
141 : :
142 : : #endif
143 : :
144 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|