docthemes: Save themes def. to a file when added to ColorSets
[LibreOffice.git] / sw / source / core / inc / sectfrm.hxx
blob4222a6e6443d6d367006b826e32846f51044356c
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 SAL_DLLPUBLIC_RTTI 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 /// If this is a section for endnotes, then the SwSection is not backed by an SwSectionNode.
56 bool m_bEndNoteSection = false;
57 bool m_bContentLock; // content locked
58 bool m_bOwnFootnoteNum; // special numbering of footnotes
59 bool m_bFootnoteLock; // ftn, don't leave this section bwd
61 void UpdateAttr_( const SfxPoolItem*, const SfxPoolItem*, SwSectionFrameInvFlags &,
62 SwAttrSetChg *pa = nullptr, SwAttrSetChg *pb = nullptr );
63 void UpdateAttrForFormatChange( SwSectionFrameInvFlags & );
64 void Cut_( bool bRemove );
65 // Is there a FootnoteContainer?
66 // An empty sectionfrm without FootnoteCont is superfluous
67 bool IsSuperfluous() const { return !ContainsAny() && !ContainsFootnoteCont(); }
68 void CalcFootnoteAtEndFlag();
69 void CalcEndAtEndFlag();
70 const SwSectionFormat* GetEndSectFormat_() const;
71 bool IsEndnoteAtMyEnd() const;
73 virtual void DestroyImpl() override;
74 virtual ~SwSectionFrame() override;
76 virtual void MakeAll(vcl::RenderContext* pRenderContext) override;
77 virtual bool ShouldBwdMoved( SwLayoutFrame *pNewUpper, bool &rReformat ) override;
78 virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override;
79 virtual void Notify(SfxHint const& rHint) override;
80 virtual void SwClientNotify( const SwModify&, const SfxHint& ) override;
82 public:
83 SwSectionFrame( SwSection &, SwFrame* ); // Content is not created!
84 SwSectionFrame( SwSectionFrame &, bool bMaster ); // _ONLY_ for creating Master/Follows!
86 void Init();
87 virtual void CheckDirection( bool bVert ) override;
89 virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) const override;
91 virtual void Cut() override;
92 virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
94 virtual bool IsHiddenNow() const override;
96 inline const SwSectionFrame *GetFollow() const;
97 inline SwSectionFrame *GetFollow();
98 SwSectionFrame* FindMaster() const;
100 SwContentFrame *FindLastContent( SwFindMode nMode = SwFindMode::None );
101 inline const SwContentFrame *FindLastContent() const;
102 SwSection* GetSection() { return m_pSection; }
103 const SwSection* GetSection() const { return m_pSection; }
104 void ColLock() { mbColLocked = true; }
105 void ColUnlock() { mbColLocked = false; }
107 void CalcFootnoteContent();
108 void SimpleFormat();
109 bool IsDescendantFrom( const SwSectionFormat* pSect ) const;
110 bool HasToBreak( const SwFrame* pFrame ) const;
111 void MergeNext( SwSectionFrame* pNxt );
114 * Splits the SectionFrame surrounding the pFrame up in two parts:
115 * pFrame and the start of the 2nd part
117 SwSectionFrame* SplitSect( SwFrame* pFrameStartAfter, SwFrame* pFramePutAfter );
118 void DelEmpty( bool bRemove ); // Like Cut(), except for that Follow chaining is maintained
119 SwFootnoteContFrame* ContainsFootnoteCont( const SwFootnoteContFrame* pCont = nullptr ) const;
120 bool Growable() const;
121 SwTwips Shrink_( SwTwips, bool bTst );
122 SwTwips Grow_(SwTwips, SwResizeLimitReason&, bool bTst);
125 * A sectionfrm has to maximize, if he has a follow or a ftncontainer at
126 * the end of the page. A superfluous follow will be ignored,
127 * if bCheckFollow is set.
129 bool ToMaximize( bool bCheckFollow ) const;
130 bool ToMaximize_() const {
131 if( !m_pSection ) return false;
132 return ToMaximize( false );
134 bool MoveAllowed( const SwFrame* ) const;
135 bool CalcMinDiff( SwTwips& rMinDiff ) const;
138 * Returns the size delta that the section would like to be
139 * greater if it has undersized TextFrames in it.
141 * The return value is > 0 for undersized Frames, or 0 otherwise.
143 * If necessary the undersized-flag is corrected.
144 * We need this in the FormatWidthCols to "deflate" columns there.
146 SwTwips Undersize();
147 SwTwips CalcUndersize() const;
149 /// Adapt size to surroundings
150 void CheckClipping( bool bGrow, bool bMaximize );
152 void InvalidateFootnotePos();
153 void CollectEndnotes( SwLayouter* pLayouter );
154 const SwSectionFormat* GetEndSectFormat() const {
155 if( IsEndnAtEnd() ) return GetEndSectFormat_();
156 return nullptr;
159 static void MoveContentAndDelete( SwSectionFrame* pDel, bool bSave );
161 bool IsBalancedSection() const;
163 virtual void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override;
164 void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override;
166 bool IsFootnoteAtEnd() const { return m_bFootnoteAtEnd; }
167 bool IsEndnAtEnd() const { return m_bEndnAtEnd; }
168 bool IsAnyNoteAtEnd() const { return m_bFootnoteAtEnd || m_bEndnAtEnd; }
170 void SetContentLock( bool bNew ) { m_bContentLock = bNew; }
171 bool IsContentLocked() const { return m_bContentLock; }
173 bool IsOwnFootnoteNum() const { return m_bOwnFootnoteNum; }
175 void SetFootnoteLock( bool bNew ) { m_bFootnoteLock = bNew; }
176 bool IsFootnoteLock() const { return m_bFootnoteLock; }
177 void SetEndNoteSection(bool bEndNoteSection) { m_bEndNoteSection = bEndNoteSection; }
178 bool IsEndNoteSection() const { return m_bEndNoteSection; }
181 inline const SwSectionFrame *SwSectionFrame::GetFollow() const
183 return static_cast<const SwSectionFrame*>(SwFlowFrame::GetFollow());
185 inline SwSectionFrame *SwSectionFrame::GetFollow()
187 return static_cast<SwSectionFrame*>(SwFlowFrame::GetFollow());
189 inline const SwContentFrame *SwSectionFrame::FindLastContent() const
191 return const_cast<SwSectionFrame*>(this)->FindLastContent();
194 #endif // INCLUDED_SW_SOURCE_CORE_INC_SECTFRM_HXX
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */