LibreOffice Module sw (master)  1
sectfrm.hxx
Go to the documentation of this file.
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 #ifndef INCLUDED_SW_SOURCE_CORE_INC_SECTFRM_HXX
20 #define INCLUDED_SW_SOURCE_CORE_INC_SECTFRM_HXX
21 
22 #include "layfrm.hxx"
23 #include "flowfrm.hxx"
24 
25 #include <svl/listener.hxx>
26 
27 class SwSection;
28 class SwSectionFormat;
29 class SwAttrSetChg;
31 class SwLayouter;
32 
33 enum class SwFindMode
34 {
35  None = 0, EndNote = 1, LastCnt = 2, MyLast = 4
36 };
37 
39 {
40  NONE = 0x00,
41  InvalidateSize = 0x01,
42  SetCompletePaint = 0x10,
43 };
44 
45 namespace o3tl {
46  template<> struct typed_flags<SwSectionFrameInvFlags> : is_typed_flags<SwSectionFrameInvFlags, 0x0011> {};
47 }
48 
49 class SwSectionFrame final: public SwLayoutFrame, public SwFlowFrame
50  , public SvtListener // TODO?
51 {
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
58 
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;
69 
70  virtual void DestroyImpl() override;
71  virtual ~SwSectionFrame() override;
72 
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;
78 
79 public:
80  SwSectionFrame( SwSection &, SwFrame* ); // Content is not created!
81  SwSectionFrame( SwSectionFrame &, bool bMaster ); // _ONLY_ for creating Master/Follows!
82 
83  void Init();
84  virtual void CheckDirection( bool bVert ) override;
85 
86  virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) const override;
87 
88  virtual void Cut() override;
89  virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
90 
91  inline const SwSectionFrame *GetFollow() const;
92  inline SwSectionFrame *GetFollow();
93  SwSectionFrame* FindMaster() const;
94 
96  inline const SwContentFrame *FindLastContent() const;
98  const SwSection* GetSection() const { return m_pSection; }
99  void ColLock() { mbColLocked = true; }
100  void ColUnlock() { mbColLocked = false; }
101 
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 );
107 
112  bool SplitSect( SwFrame* pFrame, bool bApres );
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 );
118 
124  bool ToMaximize( bool bCheckFollow ) const;
125  bool ToMaximize_() const {
126  if( !m_pSection ) return false;
127  return ToMaximize( false );
128  }
129  bool MoveAllowed( const SwFrame* ) const;
130  bool CalcMinDiff( SwTwips& rMinDiff ) const;
131 
141  SwTwips Undersize();
142  SwTwips CalcUndersize() const;
143 
145  void CheckClipping( bool bGrow, bool bMaximize );
146 
147  void InvalidateFootnotePos();
148  void CollectEndnotes( SwLayouter* pLayouter );
150  if( IsEndnAtEnd() ) return GetEndSectFormat_();
151  return nullptr;
152  }
153 
154  static void MoveContentAndDelete( SwSectionFrame* pDel, bool bSave );
155 
156  bool IsBalancedSection() const;
157 
158  virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override;
159 
160  bool IsFootnoteAtEnd() const { return m_bFootnoteAtEnd; }
161  bool IsEndnAtEnd() const { return m_bEndnAtEnd; }
162  bool IsAnyNoteAtEnd() const { return m_bFootnoteAtEnd || m_bEndnAtEnd; }
163 
164  void SetContentLock( bool bNew ) { m_bContentLock = bNew; }
165  bool IsContentLocked() const { return m_bContentLock; }
166 
167  bool IsOwnFootnoteNum() const { return m_bOwnFootnoteNum; }
168 
169  void SetFootnoteLock( bool bNew ) { m_bFootnoteLock = bNew; }
170  bool IsFootnoteLock() const { return m_bFootnoteLock; }
171 };
172 
174 {
175  return static_cast<const SwSectionFrame*>(SwFlowFrame::GetFollow());
176 }
178 {
179  return static_cast<SwSectionFrame*>(SwFlowFrame::GetFollow());
180 }
182 {
183  return const_cast<SwSectionFrame*>(this)->FindLastContent();
184 }
185 
186 #endif // INCLUDED_SW_SOURCE_CORE_INC_SECTFRM_HXX
187 
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetFootnoteLock(bool bNew)
Definition: sectfrm.hxx:169
SwSectionFrame * FindMaster() const
Definition: flowfrm.cxx:754
virtual void CheckDirection(bool bVert) override
Definition: wsfrm.cxx:406
Base class of the Writer layout elements.
Definition: frame.hxx:315
Base class that provides the general functionalities for frames that are allowed at page breaks (flow...
Definition: flowfrm.hxx:58
void CalcFootnoteAtEndFlag()
Definition: sectfrm.cxx:2532
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: sectfrm.cxx:2581
bool MoveAllowed(const SwFrame *) const
Definition: sectfrm.cxx:2396
SwTwips Shrink_(SwTwips, bool bTst)
Definition: sectfrm.cxx:2293
bool IsEndnAtEnd() const
Definition: sectfrm.hxx:161
virtual ~SwSectionFrame() override
Definition: sectfrm.cxx:186
SwFindMode
Definition: sectfrm.hxx:33
void DelEmpty(bool bRemove)
Definition: sectfrm.cxx:190
virtual void Format(vcl::RenderContext *pRenderContext, const SwBorderAttrs *pAttrs=nullptr) override
"formats" the frame; Frame and PrtArea
Definition: sectfrm.cxx:1338
bool IsOwnFootnoteNum() const
Definition: sectfrm.hxx:167
void ColLock()
Definition: sectfrm.hxx:99
bool SplitSect(SwFrame *pFrame, bool bApres)
Splits the SectionFrame surrounding the pFrame up in two parts: pFrame and the start of the 2nd part...
Definition: sectfrm.cxx:515
void InvalidateFootnotePos()
Definition: sectfrm.cxx:2807
SwSectionFrameInvFlags
Definition: sectfrm.hxx:38
void UpdateAttr_(const SfxPoolItem *, const SfxPoolItem *, SwSectionFrameInvFlags &, SwAttrSetChg *pa=nullptr, SwAttrSetChg *pb=nullptr)
Definition: sectfrm.cxx:2628
void Cut_(bool bRemove)
Definition: sectfrm.cxx:261
bool IsSuperfluous() const
Definition: sectfrm.hxx:64
SwTwips Undersize()
Returns the size delta that the section would like to be greater if it has undersized TextFrames in i...
Definition: sectfrm.cxx:2824
virtual void Notify(SfxHint const &rHint) override
Definition: sectfrm.cxx:2574
virtual void DestroyImpl() override
Definition: sectfrm.cxx:153
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
bool HasToBreak(const SwFrame *pFrame) const
|* Here it's decided whether the this-SectionFrame should break up |* the passed (Section)frm (or not...
Definition: sectfrm.cxx:449
bool ToMaximize(bool bCheckFollow) const
A sectionfrm has to maximize, if he has a follow or a ftncontainer at the end of the page...
Definition: sectfrm.cxx:2749
bool m_bContentLock
Definition: sectfrm.hxx:55
const SwSection * GetSection() const
Definition: sectfrm.hxx:98
SwSection * m_pSection
Definition: sectfrm.hxx:52
void SetContentLock(bool bNew)
Definition: sectfrm.hxx:164
SwTwips Grow_(SwTwips, bool bTst)
Definition: sectfrm.cxx:2158
virtual bool ShouldBwdMoved(SwLayoutFrame *pNewUpper, bool &rReformat) override
Definition: sectfrm.cxx:865
const SwContentFrame * FindLastContent() const
Definition: sectfrm.hxx:181
SwTwips CalcUndersize() const
Definition: sectfrm.cxx:2818
static void MoveContentAndDelete(SwSectionFrame *pDel, bool bSave)
Definition: sectfrm.cxx:670
bool IsDescendantFrom(const SwSectionFormat *pSect) const
Definition: sectfrm.cxx:2517
bool IsFootnoteLock() const
Definition: sectfrm.hxx:170
bool IsBalancedSection() const
Definition: sectfrm.cxx:2924
bool m_bFootnoteAtEnd
Definition: sectfrm.hxx:53
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: sectfrm.cxx:343
virtual void MakeAll(vcl::RenderContext *pRenderContext) override
Definition: sectfrm.cxx:775
const SwSectionFrame * GetFollow() const
Definition: sectfrm.hxx:173
SwSection * GetSection()
Definition: sectfrm.hxx:97
virtual void PaintSubsidiaryLines(const SwPageFrame *, const SwRect &) const override
Definition: paintfrm.cxx:6939
bool m_bFootnoteLock
Definition: sectfrm.hxx:57
void CalcEndAtEndFlag()
Definition: sectfrm.cxx:2560
A page of the document layout.
Definition: pagefrm.hxx:57
tools::Long SwTwips
Definition: swtypes.hxx:52
void CollectEndnotes(SwLayouter *pLayouter)
Definition: sectfrm.cxx:1048
bool Growable() const
checks whether the SectionFrame is still able to grow, as case may be the environment has to be asked...
Definition: sectfrm.cxx:2148
bool m_bEndnAtEnd
Definition: sectfrm.hxx:54
void SimpleFormat()
Definition: sectfrm.cxx:1169
void ColUnlock()
Definition: sectfrm.hxx:100
unsigned char sal_uInt8
const SwSectionFormat * GetEndSectFormat_() const
Definition: sectfrm.cxx:871
const SwFrame * ContainsAny(const bool _bInvestigateFootnoteForSections=false) const
Method doesn't investigate content of footnotes by default.
Definition: findfrm.cxx:129
const SwSectionFormat * GetEndSectFormat() const
Definition: sectfrm.hxx:149
bool m_bOwnFootnoteNum
Definition: sectfrm.hxx:56
bool IsAnyNoteAtEnd() const
Definition: sectfrm.hxx:162
bool mbColLocked
Definition: frame.hxx:444
bool ToMaximize_() const
Definition: sectfrm.hxx:125
void CheckClipping(bool bGrow, bool bMaximize)
Adapt size to surroundings.
Definition: sectfrm.cxx:1076
virtual void Cut() override
Definition: sectfrm.cxx:256
void CalcFootnoteContent()
Definition: sectfrm.cxx:2831
bool IsContentLocked() const
Definition: sectfrm.hxx:165
SwFootnoteContFrame * ContainsFootnoteCont(const SwFootnoteContFrame *pCont=nullptr) const
Check every Column for FootnoteContFrames.
Definition: sectfrm.cxx:2778
bool IsFootnoteAtEnd() const
Definition: sectfrm.hxx:160
struct _xmlTextWriter * xmlTextWriterPtr
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
Definition: layfrm.hxx:35
void MergeNext(SwSectionFrame *pNxt)
|* Merges two SectionFrames, in case it's about the same section.
Definition: sectfrm.cxx:472
bool IsEndnoteAtMyEnd() const
Definition: sectfrm.cxx:2555
bool CalcMinDiff(SwTwips &rMinDiff) const
Definition: sectfrm.cxx:951
SwSectionFrame(SwSection &, SwFrame *)
Definition: sectfrm.cxx:67
const SwFlowFrame * GetFollow() const
Definition: flowfrm.hxx:168
virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override
Definition: xmldump.cxx:629