1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SW_SOURCE_CORE_INC_FTNBOSS_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_FTNBOSS_HXX
25 class SwFootnoteBossFrame
;
26 class SwFootnoteContFrame
;
27 class SwFootnoteFrame
;
30 // Set max. footnote area.
31 // Restoration of the old value in DTor. Implementation in ftnfrm.cxx
32 class SwSaveFootnoteHeight
34 SwFootnoteBossFrame
*pBoss
;
35 const SwTwips nOldHeight
;
38 SwSaveFootnoteHeight( SwFootnoteBossFrame
*pBs
, const SwTwips nDeadLine
);
39 ~SwSaveFootnoteHeight();
42 enum class SwNeighbourAdjust
{
43 OnlyAdjust
, GrowShrink
, GrowAdjust
, AdjustGrow
46 typedef std::vector
<SwFootnoteFrame
*> SwFootnoteFrames
;
48 class SAL_DLLPUBLIC_RTTI SwFootnoteBossFrame
: public SwLayoutFrame
50 // for private footnote operations
52 friend class SwSaveFootnoteHeight
;
53 friend class SwPageFrame
; // for setting of MaxFootnoteHeight
55 // max. height of the footnote container on this page
56 SwTwips m_nMaxFootnoteHeight
;
58 SwFootnoteContFrame
*MakeFootnoteCont();
59 SwFootnoteFrame
*FindFirstFootnote();
60 SwNeighbourAdjust
NeighbourhoodAdjustment_() const;
62 static void CollectFootnotes_(const SwContentFrame
*, SwFootnoteFrame
*,
63 SwFootnoteFrames
&, const SwFootnoteBossFrame
*);
66 void InsertFootnote( SwFootnoteFrame
* );
67 static void ResetFootnote( const SwFootnoteFrame
*pAssumed
);
70 SwFootnoteBossFrame( SwFrameFormat
* pFormat
, SwFrame
* pSib
)
71 : SwLayoutFrame( pFormat
, pSib
)
72 , m_nMaxFootnoteHeight(0)
75 SwLayoutFrame
*FindBodyCont();
76 inline const SwLayoutFrame
*FindBodyCont() const;
77 void SetMaxFootnoteHeight( const SwTwips nNewMax
) { m_nMaxFootnoteHeight
= nNewMax
; }
80 void AppendFootnote( SwContentFrame
*, SwTextFootnote
* );
81 bool RemoveFootnote(const SwContentFrame
*, const SwTextFootnote
*, bool bPrep
= true);
82 static SwFootnoteFrame
*FindFootnote( const SwContentFrame
*, const SwTextFootnote
* );
83 SwFootnoteContFrame
*FindFootnoteCont();
84 inline const SwFootnoteContFrame
*FindFootnoteCont() const;
85 const SwFootnoteFrame
*FindFirstFootnote( SwContentFrame
const * ) const;
86 SwFootnoteContFrame
*FindNearestFootnoteCont( bool bDontLeave
= false );
88 static void ChangeFootnoteRef( const SwContentFrame
*pOld
, const SwTextFootnote
*,
89 SwContentFrame
*pNew
);
90 void RearrangeFootnotes( const SwTwips nDeadLine
, const bool bLock
,
91 const SwTextFootnote
*pAttr
= nullptr );
93 // Set DeadLine (in document coordinates) so that the text formatter can
94 // temporarily limit footnote height.
95 void SetFootnoteDeadLine( const SwTwips nDeadLine
);
96 SwTwips
GetMaxFootnoteHeight() const { return m_nMaxFootnoteHeight
; }
98 // returns value for remaining space until the body reaches minimal height
99 SwTwips
GetVarSpace() const;
101 // methods needed for layouting
102 // The parameter <_bCollectOnlyPreviousFootnotes> controls if only footnotes
103 // that are positioned before the this footnote boss-frame have to be
105 void CollectFootnotes( const SwContentFrame
* _pRef
,
106 SwFootnoteBossFrame
* _pOld
,
107 SwFootnoteFrames
& _rFootnoteArr
,
108 const bool _bCollectOnlyPreviousFootnotes
= false );
109 void MoveFootnotes_( SwFootnoteFrames
&rFootnoteArr
, bool bCalc
= false );
110 void MoveFootnotes( const SwContentFrame
*pSrc
, SwContentFrame
*pDest
,
111 SwTextFootnote
const *pAttr
);
113 // should AdjustNeighbourhood be called (or Grow/Shrink)?
114 SwNeighbourAdjust
NeighbourhoodAdjustment() const
115 { return IsPageFrame() ? SwNeighbourAdjust::OnlyAdjust
: NeighbourhoodAdjustment_(); }
118 inline const SwLayoutFrame
*SwFootnoteBossFrame::FindBodyCont() const
120 return const_cast<SwFootnoteBossFrame
*>(this)->FindBodyCont();
123 inline const SwFootnoteContFrame
*SwFootnoteBossFrame::FindFootnoteCont() const
125 return const_cast<SwFootnoteBossFrame
*>(this)->FindFootnoteCont();
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */