Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / core / inc / ftnboss.hxx
blob109c9df74e297c95fbe9320fc3c39d72c5ce5950
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
23 #include "layfrm.hxx"
25 class SwFootnoteBossFrame;
26 class SwFootnoteContFrame;
27 class SwFootnoteFrame;
28 class SwTextFootnote;
30 // Set max. footnote area.
31 // Restoration of the old value in DTor. Implementation in ftnfrm.cxx
32 class SwSaveFootnoteHeight
34 SwFrameDeleteGuard aGuard;
35 SwFootnoteBossFrame *pBoss;
36 const SwTwips nOldHeight;
37 SwTwips nNewHeight;
38 public:
39 SwSaveFootnoteHeight( SwFootnoteBossFrame *pBs, const SwTwips nDeadLine );
40 ~SwSaveFootnoteHeight();
43 enum class SwNeighbourAdjust {
44 OnlyAdjust, GrowShrink, GrowAdjust, AdjustGrow
47 typedef std::vector<SwFootnoteFrame*> SwFootnoteFrames;
49 class SW_DLLPUBLIC SwFootnoteBossFrame: public SwLayoutFrame
51 // for private footnote operations
52 friend class SwFrame;
53 friend class SwSaveFootnoteHeight;
54 friend class SwPageFrame; // for setting of MaxFootnoteHeight
56 // max. height of the footnote container on this page
57 SwTwips m_nMaxFootnoteHeight;
59 SwFootnoteContFrame *MakeFootnoteCont();
60 SwFootnoteFrame *FindFirstFootnote();
61 SwNeighbourAdjust NeighbourhoodAdjustment_() const;
63 static void CollectFootnotes_(const SwContentFrame*, SwFootnoteFrame*,
64 SwFootnoteFrames&, const SwFootnoteBossFrame*);
66 protected:
67 void InsertFootnote( SwFootnoteFrame * );
68 static void ResetFootnote( const SwFootnoteFrame *pAssumed );
70 public:
71 SwFootnoteBossFrame( SwFrameFormat* pFormat, SwFrame* pSib )
72 : SwLayoutFrame( pFormat, pSib )
73 , m_nMaxFootnoteHeight(0)
76 SwLayoutFrame *FindBodyCont();
77 inline const SwLayoutFrame *FindBodyCont() const;
78 void SetMaxFootnoteHeight( const SwTwips nNewMax ) { m_nMaxFootnoteHeight = nNewMax; }
80 // footnote interface
81 void AppendFootnote( SwContentFrame *, SwTextFootnote * );
82 bool RemoveFootnote(const SwContentFrame *, const SwTextFootnote *, bool bPrep = true);
83 static SwFootnoteFrame *FindFootnote( const SwContentFrame *, const SwTextFootnote * );
84 SwFootnoteContFrame *FindFootnoteCont();
85 inline const SwFootnoteContFrame *FindFootnoteCont() const;
86 const SwFootnoteFrame *FindFirstFootnote( SwContentFrame const * ) const;
87 SwFootnoteContFrame *FindNearestFootnoteCont( bool bDontLeave = false );
89 static void ChangeFootnoteRef( const SwContentFrame *pOld, const SwTextFootnote *,
90 SwContentFrame *pNew );
91 void RearrangeFootnotes( const SwTwips nDeadLine, const bool bLock,
92 const SwTextFootnote *pAttr = nullptr );
94 // Set DeadLine (in document coordinates) so that the text formatter can
95 // temporarily limit footnote height.
96 void SetFootnoteDeadLine( const SwTwips nDeadLine );
97 SwTwips GetMaxFootnoteHeight() const { return m_nMaxFootnoteHeight; }
99 // returns value for remaining space until the body reaches minimal height
100 SwTwips GetVarSpace() const;
102 // methods needed for layouting
103 // The parameter <_bCollectOnlyPreviousFootnotes> controls if only footnotes
104 // that are positioned before the this footnote boss-frame have to be
105 // collected.
106 void CollectFootnotes( const SwContentFrame* _pRef,
107 SwFootnoteBossFrame* _pOld,
108 SwFootnoteFrames& _rFootnoteArr,
109 const bool _bCollectOnlyPreviousFootnotes = false );
110 void MoveFootnotes_( SwFootnoteFrames &rFootnoteArr, bool bCalc = false );
111 void MoveFootnotes( const SwContentFrame *pSrc, SwContentFrame *pDest,
112 SwTextFootnote const *pAttr );
114 // should AdjustNeighbourhood be called (or Grow/Shrink)?
115 SwNeighbourAdjust NeighbourhoodAdjustment() const
116 { return IsPageFrame() ? SwNeighbourAdjust::OnlyAdjust : NeighbourhoodAdjustment_(); }
119 inline const SwLayoutFrame *SwFootnoteBossFrame::FindBodyCont() const
121 return const_cast<SwFootnoteBossFrame*>(this)->FindBodyCont();
124 inline const SwFootnoteContFrame *SwFootnoteBossFrame::FindFootnoteCont() const
126 return const_cast<SwFootnoteBossFrame*>(this)->FindFootnoteCont();
129 #endif
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */