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 INCLUDED_SW_SOURCE_CORE_INC_FTNBOSS_HXX
21 : #define INCLUDED_SW_SOURCE_CORE_INC_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 9006 : 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 9010 : inline SwFtnBossFrm( SwFrmFmt* pFmt, SwFrm* pSib )
69 : : SwLayoutFrm( pFmt, pSib )
70 9010 : , nMaxFtnHeight(0)
71 9010 : {}
72 :
73 : SwLayoutFrm *FindBodyCont();
74 : inline const SwLayoutFrm *FindBodyCont() const;
75 10488 : inline void SetMaxFtnHeight( const SwTwips nNewMax ) { nMaxFtnHeight = nNewMax; }
76 :
77 : // footnote interface
78 : void AppendFtn( SwCntntFrm *, SwTxtFtn * );
79 : void RemoveFtn( const SwCntntFrm *, const SwTxtFtn *, bool bPrep = true );
80 : static SwFtnFrm *FindFtn( const SwCntntFrm *, const SwTxtFtn * );
81 : SwFtnContFrm *FindFtnCont();
82 : inline const SwFtnContFrm *FindFtnCont() const;
83 : const SwFtnFrm *FindFirstFtn( SwCntntFrm* ) const;
84 : SwFtnContFrm *FindNearestFtnCont( bool bDontLeave = false );
85 :
86 : void ChangeFtnRef( const SwCntntFrm *pOld, const SwTxtFtn *,
87 : SwCntntFrm *pNew );
88 : void RearrangeFtns( const SwTwips nDeadLine, const bool bLock = false,
89 : const SwTxtFtn *pAttr = 0 );
90 :
91 : // Set DeadLine (in document coordinates) so that the text formatter can
92 : // temporarily limit footnote height.
93 : void SetFtnDeadLine( const SwTwips nDeadLine );
94 21146 : SwTwips GetMaxFtnHeight() const { return nMaxFtnHeight; }
95 :
96 : // returns value for remaining space until the body reaches minimal height
97 : SwTwips GetVarSpace() const;
98 :
99 : // methods needed for layouting
100 : // The parameters <_bCollectOnlyPreviousFtns> and <_pRefFtnBossFrm> control
101 : // if only footnotes that are positioned before the given reference
102 : // footnote boss-frame have to be collected.
103 : // Note: if parameter <_bCollectOnlyPreviousFtns> is true, then parameter
104 : // <_pRefFtnBossFrm> has to be referenced by an object.
105 : static void _CollectFtns( const SwCntntFrm* _pRef,
106 : SwFtnFrm* _pFtn,
107 : SwFtnFrms& _rFtnArr,
108 : const bool _bCollectOnlyPreviousFtns = false,
109 : const SwFtnBossFrm* _pRefFtnBossFrm = NULL);
110 : // The parameter <_bCollectOnlyPreviousFtns> controls if only footnotes
111 : // that are positioned before the footnote boss-frame <this> have to be
112 : // collected.
113 : void CollectFtns( const SwCntntFrm* _pRef,
114 : SwFtnBossFrm* _pOld,
115 : SwFtnFrms& _rFtnArr,
116 : const bool _bCollectOnlyPreviousFtns = false );
117 : void _MoveFtns( SwFtnFrms &rFtnArr, bool bCalc = false );
118 : void MoveFtns( const SwCntntFrm *pSrc, SwCntntFrm *pDest,
119 : SwTxtFtn *pAttr );
120 :
121 : // should AdjustNeighbourhood be called (or Grow/Shrink)?
122 27568 : sal_uInt8 NeighbourhoodAdjustment( const SwFrm* pFrm ) const
123 27568 : { return IsPageFrm() ? NA_ONLY_ADJUST : _NeighbourhoodAdjustment( pFrm ); }
124 : };
125 :
126 42969 : inline const SwLayoutFrm *SwFtnBossFrm::FindBodyCont() const
127 : {
128 42969 : return ((SwFtnBossFrm*)this)->FindBodyCont();
129 : }
130 :
131 130 : inline const SwFtnContFrm *SwFtnBossFrm::FindFtnCont() const
132 : {
133 130 : return ((SwFtnBossFrm*)this)->FindFtnCont();
134 : }
135 :
136 : #endif
137 :
138 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|