Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / core / inc / sectfrm.hxx
blob80d8185bc1c014a3d3e40c89f01478df861371ab
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 .
19 #ifndef INCLUDED_SW_SOURCE_CORE_INC_SECTFRM_HXX
20 #define INCLUDED_SW_SOURCE_CORE_INC_SECTFRM_HXX
22 #include "layfrm.hxx"
23 #include "flowfrm.hxx"
25 #include <svl/listener.hxx>
27 class SwSection;
28 class SwSectionFormat;
29 class SwAttrSetChg;
30 class SwFootnoteContFrame;
31 class SwLayouter;
33 enum class SwFindMode
35 None = 0, EndNote = 1, LastCnt = 2, MyLast = 4
38 enum class SwSectionFrameInvFlags : sal_uInt8
40 NONE = 0x00,
41 InvalidateSize = 0x01,
42 SetCompletePaint = 0x10,
45 namespace o3tl {
46 template<> struct typed_flags<SwSectionFrameInvFlags> : is_typed_flags<SwSectionFrameInvFlags, 0x0011> {};
49 class SwSectionFrame final: public SwLayoutFrame, public SwFlowFrame
50 , public SvtListener // TODO?
52 SwSection* m_pSection;
53 bool m_bFootnoteAtEnd; // footnotes at the end of section
54 bool m_bEndnAtEnd; // endnotes at the end of section
55 bool m_bContentLock; // content locked
56 bool m_bOwnFootnoteNum; // special numbering of footnotes
57 bool m_bFootnoteLock; // ftn, don't leave this section bwd
59 void UpdateAttr_( const SfxPoolItem*, const SfxPoolItem*, SwSectionFrameInvFlags &,
60 SwAttrSetChg *pa = nullptr, SwAttrSetChg *pb = nullptr );
61 void Cut_( bool bRemove );
62 // Is there a FootnoteContainer?
63 // An empty sectionfrm without FootnoteCont is superfluous
64 bool IsSuperfluous() const { return !ContainsAny() && !ContainsFootnoteCont(); }
65 void CalcFootnoteAtEndFlag();
66 void CalcEndAtEndFlag();
67 const SwSectionFormat* GetEndSectFormat_() const;
68 bool IsEndnoteAtMyEnd() const;
70 virtual void DestroyImpl() override;
71 virtual ~SwSectionFrame() override;
73 virtual void MakeAll(vcl::RenderContext* pRenderContext) override;
74 virtual bool ShouldBwdMoved( SwLayoutFrame *pNewUpper, bool &rReformat ) override;
75 virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override;
76 virtual void Notify(SfxHint const& rHint) override;
77 virtual void SwClientNotify( const SwModify&, const SfxHint& ) override;
79 public:
80 SwSectionFrame( SwSection &, SwFrame* ); // Content is not created!
81 SwSectionFrame( SwSectionFrame &, bool bMaster ); // _ONLY_ for creating Master/Follows!
83 void Init();
84 virtual void CheckDirection( bool bVert ) override;
86 virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) const override;
88 virtual void Cut() override;
89 virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
91 inline const SwSectionFrame *GetFollow() const;
92 inline SwSectionFrame *GetFollow();
93 SwSectionFrame* FindMaster() const;
95 SwContentFrame *FindLastContent( SwFindMode nMode = SwFindMode::None );
96 inline const SwContentFrame *FindLastContent() const;
97 SwSection* GetSection() { return m_pSection; }
98 const SwSection* GetSection() const { return m_pSection; }
99 void ColLock() { mbColLocked = true; }
100 void ColUnlock() { mbColLocked = false; }
102 void CalcFootnoteContent();
103 void SimpleFormat();
104 bool IsDescendantFrom( const SwSectionFormat* pSect ) const;
105 bool HasToBreak( const SwFrame* pFrame ) const;
106 void MergeNext( SwSectionFrame* pNxt );
109 * Splits the SectionFrame surrounding the pFrame up in two parts:
110 * pFrame and the start of the 2nd part
112 SwSectionFrame* SplitSect( SwFrame* pFrameStartAfter, SwFrame* pFramePutAfter );
113 void DelEmpty( bool bRemove ); // Like Cut(), except for that Follow chaining is maintained
114 SwFootnoteContFrame* ContainsFootnoteCont( const SwFootnoteContFrame* pCont = nullptr ) const;
115 bool Growable() const;
116 SwTwips Shrink_( SwTwips, bool bTst );
117 SwTwips Grow_ ( SwTwips, bool bTst );
120 * A sectionfrm has to maximize, if he has a follow or a ftncontainer at
121 * the end of the page. A superfluous follow will be ignored,
122 * if bCheckFollow is set.
124 bool ToMaximize( bool bCheckFollow ) const;
125 bool ToMaximize_() const {
126 if( !m_pSection ) return false;
127 return ToMaximize( false );
129 bool MoveAllowed( const SwFrame* ) const;
130 bool CalcMinDiff( SwTwips& rMinDiff ) const;
133 * Returns the size delta that the section would like to be
134 * greater if it has undersized TextFrames in it.
136 * The return value is > 0 for undersized Frames, or 0 otherwise.
138 * If necessary the undersized-flag is corrected.
139 * We need this in the FormatWidthCols to "deflate" columns there.
141 SwTwips Undersize();
142 SwTwips CalcUndersize() const;
144 /// Adapt size to surroundings
145 void CheckClipping( bool bGrow, bool bMaximize );
147 void InvalidateFootnotePos();
148 void CollectEndnotes( SwLayouter* pLayouter );
149 const SwSectionFormat* GetEndSectFormat() const {
150 if( IsEndnAtEnd() ) return GetEndSectFormat_();
151 return nullptr;
154 static void MoveContentAndDelete( SwSectionFrame* pDel, bool bSave );
156 bool IsBalancedSection() const;
158 virtual void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override;
159 virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override;
161 bool IsFootnoteAtEnd() const { return m_bFootnoteAtEnd; }
162 bool IsEndnAtEnd() const { return m_bEndnAtEnd; }
163 bool IsAnyNoteAtEnd() const { return m_bFootnoteAtEnd || m_bEndnAtEnd; }
165 void SetContentLock( bool bNew ) { m_bContentLock = bNew; }
166 bool IsContentLocked() const { return m_bContentLock; }
168 bool IsOwnFootnoteNum() const { return m_bOwnFootnoteNum; }
170 void SetFootnoteLock( bool bNew ) { m_bFootnoteLock = bNew; }
171 bool IsFootnoteLock() const { return m_bFootnoteLock; }
174 inline const SwSectionFrame *SwSectionFrame::GetFollow() const
176 return static_cast<const SwSectionFrame*>(SwFlowFrame::GetFollow());
178 inline SwSectionFrame *SwSectionFrame::GetFollow()
180 return static_cast<SwSectionFrame*>(SwFlowFrame::GetFollow());
182 inline const SwContentFrame *SwSectionFrame::FindLastContent() const
184 return const_cast<SwSectionFrame*>(this)->FindLastContent();
187 #endif // INCLUDED_SW_SOURCE_CORE_INC_SECTFRM_HXX
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */