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 class SwSection;
26 class SwSectionFormat;
27 class SwAttrSetChg;
29 class SwLayouter;
30 
31 enum class SwFindMode
32 {
33  None = 0, EndNote = 1, LastCnt = 2, MyLast = 4
34 };
35 
37 {
38  NONE = 0x00,
39  InvalidateSize = 0x01,
40  SetCompletePaint = 0x10,
41 };
42 
43 namespace o3tl {
44  template<> struct typed_flags<SwSectionFrameInvFlags> : is_typed_flags<SwSectionFrameInvFlags, 0x0011> {};
45 }
46 
47 class SwSectionFrame final: public SwLayoutFrame, public SwFlowFrame
48 {
50  bool m_bFootnoteAtEnd; // footnotes at the end of section
51  bool m_bEndnAtEnd; // endnotes at the end of section
52  bool m_bContentLock; // content locked
53  bool m_bOwnFootnoteNum; // special numbering of footnotes
54  bool m_bFootnoteLock; // ftn, don't leave this section bwd
55 
57  SwAttrSetChg *pa = nullptr, SwAttrSetChg *pb = nullptr );
58  void Cut_( bool bRemove );
59  // Is there a FootnoteContainer?
60  // An empty sectionfrm without FootnoteCont is superfluous
61  bool IsSuperfluous() const { return !ContainsAny() && !ContainsFootnoteCont(); }
62  void CalcFootnoteAtEndFlag();
63  void CalcEndAtEndFlag();
64  const SwSectionFormat* GetEndSectFormat_() const;
65  bool IsEndnoteAtMyEnd() const;
66 
67  virtual void DestroyImpl() override;
68  virtual ~SwSectionFrame() override;
69 
70  virtual void MakeAll(vcl::RenderContext* pRenderContext) override;
71  virtual bool ShouldBwdMoved( SwLayoutFrame *pNewUpper, bool &rReformat ) override;
72  virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override;
73  virtual void SwClientNotify( const SwModify&, const SfxHint& ) override;
74 
75 public:
76  SwSectionFrame( SwSection &, SwFrame* ); // Content is not created!
77  SwSectionFrame( SwSectionFrame &, bool bMaster ); // _ONLY_ for creating Master/Follows!
78 
79  void Init();
80  virtual void CheckDirection( bool bVert ) override;
81 
82  virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) const override;
83 
84  virtual void Cut() override;
85  virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
86 
87  inline const SwSectionFrame *GetFollow() const;
88  inline SwSectionFrame *GetFollow();
89  SwSectionFrame* FindMaster() const;
90 
92  inline const SwContentFrame *FindLastContent() const;
94  const SwSection* GetSection() const { return m_pSection; }
95  void ColLock() { mbColLocked = true; }
96  void ColUnlock() { mbColLocked = false; }
97 
98  void CalcFootnoteContent();
99  void SimpleFormat();
100  bool IsDescendantFrom( const SwSectionFormat* pSect ) const;
101  bool HasToBreak( const SwFrame* pFrame ) const;
102  void MergeNext( SwSectionFrame* pNxt );
103 
108  bool SplitSect( SwFrame* pFrame, bool bApres );
109  void DelEmpty( bool bRemove ); // Like Cut(), except for that Follow chaining is maintained
110  SwFootnoteContFrame* ContainsFootnoteCont( const SwFootnoteContFrame* pCont = nullptr ) const;
111  bool Growable() const;
112  SwTwips Shrink_( SwTwips, bool bTst );
113  SwTwips Grow_ ( SwTwips, bool bTst );
114 
120  bool ToMaximize( bool bCheckFollow ) const;
121  bool ToMaximize_() const {
122  if( !m_pSection ) return false;
123  return ToMaximize( false );
124  }
125  bool MoveAllowed( const SwFrame* ) const;
126  bool CalcMinDiff( SwTwips& rMinDiff ) const;
127 
137  SwTwips Undersize();
138  SwTwips CalcUndersize() const;
139 
141  void CheckClipping( bool bGrow, bool bMaximize );
142 
143  void InvalidateFootnotePos();
144  void CollectEndnotes( SwLayouter* pLayouter );
146  if( IsEndnAtEnd() ) return GetEndSectFormat_();
147  return nullptr;
148  }
149 
150  static void MoveContentAndDelete( SwSectionFrame* pDel, bool bSave );
151 
152  bool IsBalancedSection() const;
153 
154  virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override;
155 
156  bool IsFootnoteAtEnd() const { return m_bFootnoteAtEnd; }
157  bool IsEndnAtEnd() const { return m_bEndnAtEnd; }
158  bool IsAnyNoteAtEnd() const { return m_bFootnoteAtEnd || m_bEndnAtEnd; }
159 
160  void SetContentLock( bool bNew ) { m_bContentLock = bNew; }
161  bool IsContentLocked() const { return m_bContentLock; }
162 
163  bool IsOwnFootnoteNum() const { return m_bOwnFootnoteNum; }
164 
165  void SetFootnoteLock( bool bNew ) { m_bFootnoteLock = bNew; }
166  bool IsFootnoteLock() const { return m_bFootnoteLock; }
167 };
168 
170 {
171  return static_cast<const SwSectionFrame*>(SwFlowFrame::GetFollow());
172 }
174 {
175  return static_cast<SwSectionFrame*>(SwFlowFrame::GetFollow());
176 }
178 {
179  return const_cast<SwSectionFrame*>(this)->FindLastContent();
180 }
181 
182 #endif // INCLUDED_SW_SOURCE_CORE_INC_SECTFRM_HXX
183 
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetFootnoteLock(bool bNew)
Definition: sectfrm.hxx:165
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:2528
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: sectfrm.cxx:2570
bool MoveAllowed(const SwFrame *) const
Definition: sectfrm.cxx:2392
SwTwips Shrink_(SwTwips, bool bTst)
Definition: sectfrm.cxx:2289
bool IsEndnAtEnd() const
Definition: sectfrm.hxx:157
virtual ~SwSectionFrame() override
Definition: sectfrm.cxx:182
SwFindMode
Definition: sectfrm.hxx:31
void DelEmpty(bool bRemove)
Definition: sectfrm.cxx:186
virtual void Format(vcl::RenderContext *pRenderContext, const SwBorderAttrs *pAttrs=nullptr) override
"formats" the frame; Frame and PrtArea
Definition: sectfrm.cxx:1334
bool IsOwnFootnoteNum() const
Definition: sectfrm.hxx:163
void ColLock()
Definition: sectfrm.hxx:95
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:511
void InvalidateFootnotePos()
Definition: sectfrm.cxx:2796
SwSectionFrameInvFlags
Definition: sectfrm.hxx:36
void UpdateAttr_(const SfxPoolItem *, const SfxPoolItem *, SwSectionFrameInvFlags &, SwAttrSetChg *pa=nullptr, SwAttrSetChg *pb=nullptr)
Definition: sectfrm.cxx:2617
void Cut_(bool bRemove)
Definition: sectfrm.cxx:257
bool IsSuperfluous() const
Definition: sectfrm.hxx:61
SwTwips Undersize()
Returns the size delta that the section would like to be greater if it has undersized TextFrames in i...
Definition: sectfrm.cxx:2813
virtual void DestroyImpl() override
Definition: sectfrm.cxx:149
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:445
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:2738
bool m_bContentLock
Definition: sectfrm.hxx:52
const SwSection * GetSection() const
Definition: sectfrm.hxx:94
SwSection * m_pSection
Definition: sectfrm.hxx:49
void SetContentLock(bool bNew)
Definition: sectfrm.hxx:160
SwTwips Grow_(SwTwips, bool bTst)
Definition: sectfrm.cxx:2154
virtual bool ShouldBwdMoved(SwLayoutFrame *pNewUpper, bool &rReformat) override
Definition: sectfrm.cxx:861
const SwContentFrame * FindLastContent() const
Definition: sectfrm.hxx:177
SwTwips CalcUndersize() const
Definition: sectfrm.cxx:2807
static void MoveContentAndDelete(SwSectionFrame *pDel, bool bSave)
Definition: sectfrm.cxx:666
bool IsDescendantFrom(const SwSectionFormat *pSect) const
Definition: sectfrm.cxx:2513
bool IsFootnoteLock() const
Definition: sectfrm.hxx:166
struct _xmlTextWriter * xmlTextWriterPtr
bool IsBalancedSection() const
Definition: sectfrm.cxx:2913
bool m_bFootnoteAtEnd
Definition: sectfrm.hxx:50
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: sectfrm.cxx:339
virtual void MakeAll(vcl::RenderContext *pRenderContext) override
Definition: sectfrm.cxx:771
const SwSectionFrame * GetFollow() const
Definition: sectfrm.hxx:169
SwSection * GetSection()
Definition: sectfrm.hxx:93
virtual void PaintSubsidiaryLines(const SwPageFrame *, const SwRect &) const override
Definition: paintfrm.cxx:6861
bool m_bFootnoteLock
Definition: sectfrm.hxx:54
void CalcEndAtEndFlag()
Definition: sectfrm.cxx:2556
A page of the document layout.
Definition: pagefrm.hxx:57
tools::Long SwTwips
Definition: swtypes.hxx:52
void CollectEndnotes(SwLayouter *pLayouter)
Definition: sectfrm.cxx:1044
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:2144
bool m_bEndnAtEnd
Definition: sectfrm.hxx:51
void SimpleFormat()
Definition: sectfrm.cxx:1165
void ColUnlock()
Definition: sectfrm.hxx:96
unsigned char sal_uInt8
const SwSectionFormat * GetEndSectFormat_() const
Definition: sectfrm.cxx:867
const SwFrame * ContainsAny(const bool _bInvestigateFootnoteForSections=false) const
Method doesn't investigate content of footnotes by default.
Definition: findfrm.cxx:126
const SwSectionFormat * GetEndSectFormat() const
Definition: sectfrm.hxx:145
bool m_bOwnFootnoteNum
Definition: sectfrm.hxx:53
bool IsAnyNoteAtEnd() const
Definition: sectfrm.hxx:158
bool mbColLocked
Definition: frame.hxx:444
bool ToMaximize_() const
Definition: sectfrm.hxx:121
void CheckClipping(bool bGrow, bool bMaximize)
Adapt size to surroundings.
Definition: sectfrm.cxx:1072
virtual void Cut() override
Definition: sectfrm.cxx:252
void CalcFootnoteContent()
Definition: sectfrm.cxx:2820
bool IsContentLocked() const
Definition: sectfrm.hxx:161
SwFootnoteContFrame * ContainsFootnoteCont(const SwFootnoteContFrame *pCont=nullptr) const
Check every Column for FootnoteContFrames.
Definition: sectfrm.cxx:2767
bool IsFootnoteAtEnd() const
Definition: sectfrm.hxx:156
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:468
bool IsEndnoteAtMyEnd() const
Definition: sectfrm.cxx:2551
bool CalcMinDiff(SwTwips &rMinDiff) const
Definition: sectfrm.cxx:947
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:633