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 
36 class SwSectionFrame final: public SwLayoutFrame, public SwFlowFrame
37 {
39  bool m_bFootnoteAtEnd; // footnotes at the end of section
40  bool m_bEndnAtEnd; // endnotes at the end of section
41  bool m_bContentLock; // content locked
42  bool m_bOwnFootnoteNum; // special numbering of footnotes
43  bool m_bFootnoteLock; // ftn, don't leave this section bwd
44 
45  void UpdateAttr_( const SfxPoolItem*, const SfxPoolItem*, sal_uInt8 &,
46  SwAttrSetChg *pa = nullptr, SwAttrSetChg *pb = nullptr );
47  void Cut_( bool bRemove );
48  // Is there a FootnoteContainer?
49  // An empty sectionfrm without FootnoteCont is superfluous
50  bool IsSuperfluous() const { return !ContainsAny() && !ContainsFootnoteCont(); }
51  void CalcFootnoteAtEndFlag();
52  void CalcEndAtEndFlag();
53  const SwSectionFormat* GetEndSectFormat_() const;
54  bool IsEndnoteAtMyEnd() const;
55 
56  virtual void DestroyImpl() override;
57  virtual ~SwSectionFrame() override;
58 
59  virtual void MakeAll(vcl::RenderContext* pRenderContext) override;
60  virtual bool ShouldBwdMoved( SwLayoutFrame *pNewUpper, bool &rReformat ) override;
61  virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override;
62  virtual void SwClientNotify( const SwModify&, const SfxHint& ) override;
63 
64 public:
65  SwSectionFrame( SwSection &, SwFrame* ); // Content is not created!
66  SwSectionFrame( SwSectionFrame &, bool bMaster ); // _ONLY_ for creating Master/Follows!
67 
68  void Init();
69  virtual void CheckDirection( bool bVert ) override;
70 
71  virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) const override;
72 
73  virtual void Cut() override;
74  virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
75 
76  inline const SwSectionFrame *GetFollow() const;
77  inline SwSectionFrame *GetFollow();
78  SwSectionFrame* FindMaster() const;
79 
81  inline const SwContentFrame *FindLastContent() const;
83  const SwSection* GetSection() const { return m_pSection; }
84  void ColLock() { mbColLocked = true; }
85  void ColUnlock() { mbColLocked = false; }
86 
87  void CalcFootnoteContent();
88  void SimpleFormat();
89  bool IsDescendantFrom( const SwSectionFormat* pSect ) const;
90  bool HasToBreak( const SwFrame* pFrame ) const;
91  void MergeNext( SwSectionFrame* pNxt );
92 
97  bool SplitSect( SwFrame* pFrame, bool bApres );
98  void DelEmpty( bool bRemove ); // Like Cut(), except for that Follow chaining is maintained
99  SwFootnoteContFrame* ContainsFootnoteCont( const SwFootnoteContFrame* pCont = nullptr ) const;
100  bool Growable() const;
101  SwTwips Shrink_( SwTwips, bool bTst );
102  SwTwips Grow_ ( SwTwips, bool bTst );
103 
109  bool ToMaximize( bool bCheckFollow ) const;
110  bool ToMaximize_() const {
111  if( !m_pSection ) return false;
112  return ToMaximize( false );
113  }
114  bool MoveAllowed( const SwFrame* ) const;
115  bool CalcMinDiff( SwTwips& rMinDiff ) const;
116 
126  SwTwips Undersize();
127  SwTwips CalcUndersize() const;
128 
130  void CheckClipping( bool bGrow, bool bMaximize );
131 
132  void InvalidateFootnotePos();
133  void CollectEndnotes( SwLayouter* pLayouter );
135  if( IsEndnAtEnd() ) return GetEndSectFormat_();
136  return nullptr;
137  }
138 
139  static void MoveContentAndDelete( SwSectionFrame* pDel, bool bSave );
140 
141  bool IsBalancedSection() const;
142 
143  virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override;
144 
145  bool IsFootnoteAtEnd() const { return m_bFootnoteAtEnd; }
146  bool IsEndnAtEnd() const { return m_bEndnAtEnd; }
147  bool IsAnyNoteAtEnd() const { return m_bFootnoteAtEnd || m_bEndnAtEnd; }
148 
149  void SetContentLock( bool bNew ) { m_bContentLock = bNew; }
150  bool IsContentLocked() const { return m_bContentLock; }
151 
152  bool IsOwnFootnoteNum() const { return m_bOwnFootnoteNum; }
153 
154  void SetFootnoteLock( bool bNew ) { m_bFootnoteLock = bNew; }
155  bool IsFootnoteLock() const { return m_bFootnoteLock; }
156 };
157 
159 {
160  return static_cast<const SwSectionFrame*>(SwFlowFrame::GetFollow());
161 }
163 {
164  return static_cast<SwSectionFrame*>(SwFlowFrame::GetFollow());
165 }
167 {
168  return const_cast<SwSectionFrame*>(this)->FindLastContent();
169 }
170 
171 #endif // INCLUDED_SW_SOURCE_CORE_INC_SECTFRM_HXX
172 
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetFootnoteLock(bool bNew)
Definition: sectfrm.hxx:154
SwSectionFrame * FindMaster() const
Definition: flowfrm.cxx:753
virtual void CheckDirection(bool bVert) override
Definition: wsfrm.cxx:408
Base class of the Writer layout elements.
Definition: frame.hxx:298
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:2527
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: sectfrm.cxx:2569
bool MoveAllowed(const SwFrame *) const
Definition: sectfrm.cxx:2391
SwTwips Shrink_(SwTwips, bool bTst)
Definition: sectfrm.cxx:2288
bool IsEndnAtEnd() const
Definition: sectfrm.hxx:146
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:1333
bool IsOwnFootnoteNum() const
Definition: sectfrm.hxx:152
void ColLock()
Definition: sectfrm.hxx:84
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:509
void InvalidateFootnotePos()
Definition: sectfrm.cxx:2794
void Cut_(bool bRemove)
Definition: sectfrm.cxx:255
bool IsSuperfluous() const
Definition: sectfrm.hxx:50
SwTwips Undersize()
Returns the size delta that the section would like to be greater if it has undersized TextFrames in i...
Definition: sectfrm.cxx:2811
virtual void DestroyImpl() override
Definition: sectfrm.cxx:149
void UpdateAttr_(const SfxPoolItem *, const SfxPoolItem *, sal_uInt8 &, SwAttrSetChg *pa=nullptr, SwAttrSetChg *pb=nullptr)
Definition: sectfrm.cxx:2615
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
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:443
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:2736
bool m_bContentLock
Definition: sectfrm.hxx:41
const SwSection * GetSection() const
Definition: sectfrm.hxx:83
SwSection * m_pSection
Definition: sectfrm.hxx:38
void SetContentLock(bool bNew)
Definition: sectfrm.hxx:149
SwTwips Grow_(SwTwips, bool bTst)
Definition: sectfrm.cxx:2153
virtual bool ShouldBwdMoved(SwLayoutFrame *pNewUpper, bool &rReformat) override
Definition: sectfrm.cxx:859
const SwContentFrame * FindLastContent() const
Definition: sectfrm.hxx:166
SwTwips CalcUndersize() const
Definition: sectfrm.cxx:2805
static void MoveContentAndDelete(SwSectionFrame *pDel, bool bSave)
Definition: sectfrm.cxx:664
bool IsDescendantFrom(const SwSectionFormat *pSect) const
Definition: sectfrm.cxx:2512
bool IsFootnoteLock() const
Definition: sectfrm.hxx:155
struct _xmlTextWriter * xmlTextWriterPtr
bool IsBalancedSection() const
Definition: sectfrm.cxx:2911
bool m_bFootnoteAtEnd
Definition: sectfrm.hxx:39
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: sectfrm.cxx:337
virtual void MakeAll(vcl::RenderContext *pRenderContext) override
Definition: sectfrm.cxx:769
const SwSectionFrame * GetFollow() const
Definition: sectfrm.hxx:158
SwSection * GetSection()
Definition: sectfrm.hxx:82
virtual void PaintSubsidiaryLines(const SwPageFrame *, const SwRect &) const override
Definition: paintfrm.cxx:6784
bool m_bFootnoteLock
Definition: sectfrm.hxx:43
void CalcEndAtEndFlag()
Definition: sectfrm.cxx:2555
A page of the document layout.
Definition: pagefrm.hxx:41
tools::Long SwTwips
Definition: swtypes.hxx:49
void CollectEndnotes(SwLayouter *pLayouter)
Definition: sectfrm.cxx:1042
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:2143
bool m_bEndnAtEnd
Definition: sectfrm.hxx:40
void SimpleFormat()
Definition: sectfrm.cxx:1163
void ColUnlock()
Definition: sectfrm.hxx:85
unsigned char sal_uInt8
const SwSectionFormat * GetEndSectFormat_() const
Definition: sectfrm.cxx:865
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:134
bool m_bOwnFootnoteNum
Definition: sectfrm.hxx:42
bool IsAnyNoteAtEnd() const
Definition: sectfrm.hxx:147
bool mbColLocked
Definition: frame.hxx:427
bool ToMaximize_() const
Definition: sectfrm.hxx:110
void CheckClipping(bool bGrow, bool bMaximize)
Adapt size to surroundings.
Definition: sectfrm.cxx:1070
virtual void Cut() override
Definition: sectfrm.cxx:250
void CalcFootnoteContent()
Definition: sectfrm.cxx:2818
bool IsContentLocked() const
Definition: sectfrm.hxx:150
SwFootnoteContFrame * ContainsFootnoteCont(const SwFootnoteContFrame *pCont=nullptr) const
Check every Column for FootnoteContFrames.
Definition: sectfrm.cxx:2765
bool IsFootnoteAtEnd() const
Definition: sectfrm.hxx:145
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:466
bool IsEndnoteAtMyEnd() const
Definition: sectfrm.cxx:2550
bool CalcMinDiff(SwTwips &rMinDiff) const
Definition: sectfrm.cxx:945
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:554