Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _FTNBOSS_HXX
21 : #define _FTNBOSS_HXX
22 :
23 : #include "layfrm.hxx"
24 :
25 : class SwFtnBossFrm;
26 : class SwFtnContFrm;
27 : class SwFtnFrm;
28 : class SwTxtFtn;
29 :
30 : // Set max. footnote area.
31 : // Restoration of the old value in DTor. Implementation in ftnfrm.cxx
32 : class SwSaveFtnHeight
33 : {
34 : SwFtnBossFrm *pBoss;
35 : const SwTwips nOldHeight;
36 : SwTwips nNewHeight;
37 : public:
38 : SwSaveFtnHeight( SwFtnBossFrm *pBs, const SwTwips nDeadLine );
39 : ~SwSaveFtnHeight();
40 : };
41 :
42 : #define NA_ONLY_ADJUST 0
43 : #define NA_GROW_SHRINK 1
44 : #define NA_GROW_ADJUST 2
45 : #define NA_ADJUST_GROW 3
46 :
47 : typedef std::vector<SwFtnFrm*> SwFtnFrms;
48 :
49 970 : class SwFtnBossFrm: public SwLayoutFrm
50 : {
51 : // for private footnote operations
52 : friend class SwFrm;
53 : friend class SwSaveFtnHeight;
54 : friend class SwPageFrm; // for setting of MaxFtnHeight
55 :
56 : // max. height of the footnote container on this page
57 : SwTwips nMaxFtnHeight;
58 :
59 : SwFtnContFrm *MakeFtnCont();
60 : SwFtnFrm *FindFirstFtn();
61 : sal_uInt8 _NeighbourhoodAdjustment( const SwFrm* pFrm ) const;
62 :
63 : protected:
64 : void InsertFtn( SwFtnFrm * );
65 : static void ResetFtn( const SwFtnFrm *pAssumed );
66 :
67 : public:
68 972 : inline SwFtnBossFrm( SwFrmFmt* pFmt, SwFrm* pSib ) : SwLayoutFrm( pFmt, pSib ) {}
69 :
70 : SwLayoutFrm *FindBodyCont();
71 : inline const SwLayoutFrm *FindBodyCont() const;
72 1032 : inline void SetMaxFtnHeight( const SwTwips nNewMax ) { nMaxFtnHeight = nNewMax; }
73 :
74 : // footnote interface
75 : void AppendFtn( SwCntntFrm *, SwTxtFtn * );
76 : void RemoveFtn( const SwCntntFrm *, const SwTxtFtn *, sal_Bool bPrep = sal_True );
77 : static SwFtnFrm *FindFtn( const SwCntntFrm *, const SwTxtFtn * );
78 : SwFtnContFrm *FindFtnCont();
79 : inline const SwFtnContFrm *FindFtnCont() const;
80 : const SwFtnFrm *FindFirstFtn( SwCntntFrm* ) const;
81 : SwFtnContFrm *FindNearestFtnCont( sal_Bool bDontLeave = sal_False );
82 :
83 : void ChangeFtnRef( const SwCntntFrm *pOld, const SwTxtFtn *,
84 : SwCntntFrm *pNew );
85 : void RearrangeFtns( const SwTwips nDeadLine, const sal_Bool bLock = sal_False,
86 : const SwTxtFtn *pAttr = 0 );
87 :
88 : // Set DeadLine (in document coordinates) so that the text formatter can
89 : // temporarily limit footnote height.
90 : void SetFtnDeadLine( const SwTwips nDeadLine );
91 2226 : SwTwips GetMaxFtnHeight() const { return nMaxFtnHeight; }
92 :
93 : // returns value for remaining space until the body reaches minimal height
94 : SwTwips GetVarSpace() const;
95 :
96 : // methods needed for layouting
97 : // The parameters <_bCollectOnlyPreviousFtns> and <_pRefFtnBossFrm> control
98 : // if only footnotes that are positioned before the given reference
99 : // footnote boss-frame have to be collected.
100 : // Note: if parameter <_bCollectOnlyPreviousFtns> is true, then parameter
101 : // <_pRefFtnBossFrm> has to be referenced by an object.
102 : static void _CollectFtns( const SwCntntFrm* _pRef,
103 : SwFtnFrm* _pFtn,
104 : SwFtnFrms& _rFtnArr,
105 : const sal_Bool _bCollectOnlyPreviousFtns = sal_False,
106 : const SwFtnBossFrm* _pRefFtnBossFrm = NULL);
107 : // The parameter <_bCollectOnlyPreviousFtns> controls if only footnotes
108 : // that are positioned before the footnote boss-frame <this> have to be
109 : // collected.
110 : void CollectFtns( const SwCntntFrm* _pRef,
111 : SwFtnBossFrm* _pOld,
112 : SwFtnFrms& _rFtnArr,
113 : const sal_Bool _bCollectOnlyPreviousFtns = sal_False );
114 : void _MoveFtns( SwFtnFrms &rFtnArr, sal_Bool bCalc = sal_False );
115 : void MoveFtns( const SwCntntFrm *pSrc, SwCntntFrm *pDest,
116 : SwTxtFtn *pAttr );
117 :
118 : // should AdjustNeighbourhood be called (or Grow/Shrink)?
119 1589 : sal_uInt8 NeighbourhoodAdjustment( const SwFrm* pFrm ) const
120 1589 : { return IsPageFrm() ? NA_ONLY_ADJUST : _NeighbourhoodAdjustment( pFrm ); }
121 : };
122 :
123 10440 : inline const SwLayoutFrm *SwFtnBossFrm::FindBodyCont() const
124 : {
125 10440 : return ((SwFtnBossFrm*)this)->FindBodyCont();
126 : }
127 :
128 64 : inline const SwFtnContFrm *SwFtnBossFrm::FindFtnCont() const
129 : {
130 64 : return ((SwFtnBossFrm*)this)->FindFtnCont();
131 : }
132 :
133 : #endif
134 :
135 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|