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 {
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 protected:
60  virtual void MakeAll(vcl::RenderContext* pRenderContext) override;
61  virtual bool ShouldBwdMoved( SwLayoutFrame *pNewUpper, bool bHead, bool &rReformat ) override;
62  virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override;
63  virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override;
64  virtual void SwClientNotify( const SwModify&, const SfxHint& ) override;
65 
66 public:
67  SwSectionFrame( SwSection &, SwFrame* ); // Content is not created!
68  SwSectionFrame( SwSectionFrame &, bool bMaster ); // _ONLY_ for creating Master/Follows!
69 
70  void Init();
71  virtual void CheckDirection( bool bVert ) override;
72 
73  virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) const override;
74 
75  virtual void Cut() override;
76  virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
77 
78  inline const SwSectionFrame *GetFollow() const;
79  inline SwSectionFrame *GetFollow();
80  SwSectionFrame* FindMaster() const;
81 
83  inline const SwContentFrame *FindLastContent() const;
85  const SwSection* GetSection() const { return m_pSection; }
86  void ColLock() { mbColLocked = true; }
87  void ColUnlock() { mbColLocked = false; }
88 
89  void CalcFootnoteContent();
90  void SimpleFormat();
91  bool IsDescendantFrom( const SwSectionFormat* pSect ) const;
92  bool HasToBreak( const SwFrame* pFrame ) const;
93  void MergeNext( SwSectionFrame* pNxt );
94 
99  bool SplitSect( SwFrame* pFrame, bool bApres );
100  void DelEmpty( bool bRemove ); // Like Cut(), except for that Follow chaining is maintained
101  SwFootnoteContFrame* ContainsFootnoteCont( const SwFootnoteContFrame* pCont = nullptr ) const;
102  bool Growable() const;
103  SwTwips Shrink_( SwTwips, bool bTst );
104  SwTwips Grow_ ( SwTwips, bool bTst );
105 
111  bool ToMaximize( bool bCheckFollow ) const;
112  bool ToMaximize_() const {
113  if( !m_pSection ) return false;
114  return ToMaximize( false );
115  }
116  bool MoveAllowed( const SwFrame* ) const;
117  bool CalcMinDiff( SwTwips& rMinDiff ) const;
118 
128  SwTwips Undersize();
129  SwTwips CalcUndersize() const;
130 
132  void CheckClipping( bool bGrow, bool bMaximize );
133 
134  void InvalidateFootnotePos();
135  void CollectEndnotes( SwLayouter* pLayouter );
137  if( IsEndnAtEnd() ) return GetEndSectFormat_();
138  return nullptr;
139  }
140 
141  static void MoveContentAndDelete( SwSectionFrame* pDel, bool bSave );
142 
143  bool IsBalancedSection() const;
144 
145  virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override;
146 
147  bool IsFootnoteAtEnd() const { return m_bFootnoteAtEnd; }
148  bool IsEndnAtEnd() const { return m_bEndnAtEnd; }
149  bool IsAnyNoteAtEnd() const { return m_bFootnoteAtEnd || m_bEndnAtEnd; }
150 
151  void SetContentLock( bool bNew ) { m_bContentLock = bNew; }
152  bool IsContentLocked() const { return m_bContentLock; }
153 
154  bool IsOwnFootnoteNum() const { return m_bOwnFootnoteNum; }
155 
156  void SetFootnoteLock( bool bNew ) { m_bFootnoteLock = bNew; }
157  bool IsFootnoteLock() const { return m_bFootnoteLock; }
158 };
159 
161 {
162  return static_cast<const SwSectionFrame*>(SwFlowFrame::GetFollow());
163 }
165 {
166  return static_cast<SwSectionFrame*>(SwFlowFrame::GetFollow());
167 }
169 {
170  return const_cast<SwSectionFrame*>(this)->FindLastContent();
171 }
172 
173 #endif // INCLUDED_SW_SOURCE_CORE_INC_SECTFRM_HXX
174 
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetFootnoteLock(bool bNew)
Definition: sectfrm.hxx:156
SwSectionFrame * FindMaster() const
Definition: flowfrm.cxx:694
virtual void CheckDirection(bool bVert) override
Definition: wsfrm.cxx:405
Base class of the Writer layout elements.
Definition: frame.hxx:295
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:2522
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: sectfrm.cxx:2599
bool MoveAllowed(const SwFrame *) const
Definition: sectfrm.cxx:2384
SwTwips Shrink_(SwTwips, bool bTst)
Definition: sectfrm.cxx:2281
bool IsEndnAtEnd() const
Definition: sectfrm.hxx:148
virtual ~SwSectionFrame() override
Definition: sectfrm.cxx:181
SwFindMode
Definition: sectfrm.hxx:31
void DelEmpty(bool bRemove)
Definition: sectfrm.cxx:185
virtual void Format(vcl::RenderContext *pRenderContext, const SwBorderAttrs *pAttrs=nullptr) override
"formats" the frame; Frame and PrtArea
Definition: sectfrm.cxx:1326
bool IsOwnFootnoteNum() const
Definition: sectfrm.hxx:154
void ColLock()
Definition: sectfrm.hxx:86
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:506
void InvalidateFootnotePos()
Definition: sectfrm.cxx:2787
void Cut_(bool bRemove)
Definition: sectfrm.cxx:254
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:2804
long SwTwips
Definition: swtypes.hxx:49
virtual void DestroyImpl() override
Definition: sectfrm.cxx:148
void UpdateAttr_(const SfxPoolItem *, const SfxPoolItem *, sal_uInt8 &, SwAttrSetChg *pa=nullptr, SwAttrSetChg *pb=nullptr)
Definition: sectfrm.cxx:2611
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:440
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:2729
bool m_bContentLock
Definition: sectfrm.hxx:41
const SwSection * GetSection() const
Definition: sectfrm.hxx:85
SwSection * m_pSection
Definition: sectfrm.hxx:38
void SetContentLock(bool bNew)
Definition: sectfrm.hxx:151
SwTwips Grow_(SwTwips, bool bTst)
Definition: sectfrm.cxx:2146
const SwContentFrame * FindLastContent() const
Definition: sectfrm.hxx:168
SwTwips CalcUndersize() const
Definition: sectfrm.cxx:2798
static void MoveContentAndDelete(SwSectionFrame *pDel, bool bSave)
Definition: sectfrm.cxx:661
bool IsDescendantFrom(const SwSectionFormat *pSect) const
Definition: sectfrm.cxx:2507
bool IsFootnoteLock() const
Definition: sectfrm.hxx:157
struct _xmlTextWriter * xmlTextWriterPtr
bool IsBalancedSection() const
Definition: sectfrm.cxx:2904
bool m_bFootnoteAtEnd
Definition: sectfrm.hxx:39
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: sectfrm.cxx:334
virtual void MakeAll(vcl::RenderContext *pRenderContext) override
Definition: sectfrm.cxx:766
const SwSectionFrame * GetFollow() const
Definition: sectfrm.hxx:160
SwSection * GetSection()
Definition: sectfrm.hxx:84
virtual void PaintSubsidiaryLines(const SwPageFrame *, const SwRect &) const override
Definition: paintfrm.cxx:6718
virtual void Modify(const SfxPoolItem *, const SfxPoolItem *) override
Definition: sectfrm.cxx:2564
bool m_bFootnoteLock
Definition: sectfrm.hxx:43
void CalcEndAtEndFlag()
Definition: sectfrm.cxx:2550
A page of the document layout.
Definition: pagefrm.hxx:40
void CollectEndnotes(SwLayouter *pLayouter)
Definition: sectfrm.cxx:1039
virtual bool ShouldBwdMoved(SwLayoutFrame *pNewUpper, bool bHead, bool &rReformat) override
Definition: sectfrm.cxx:856
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:2136
bool m_bEndnAtEnd
Definition: sectfrm.hxx:40
void SimpleFormat()
Definition: sectfrm.cxx:1160
void ColUnlock()
Definition: sectfrm.hxx:87
unsigned char sal_uInt8
const SwSectionFormat * GetEndSectFormat_() const
Definition: sectfrm.cxx:862
const SwFrame * ContainsAny(const bool _bInvestigateFootnoteForSections=false) const
Method doesn't investigate content of footnotes by default.
Definition: findfrm.cxx:125
const SwSectionFormat * GetEndSectFormat() const
Definition: sectfrm.hxx:136
bool m_bOwnFootnoteNum
Definition: sectfrm.hxx:42
bool IsAnyNoteAtEnd() const
Definition: sectfrm.hxx:149
bool mbColLocked
Definition: frame.hxx:424
bool ToMaximize_() const
Definition: sectfrm.hxx:112
void CheckClipping(bool bGrow, bool bMaximize)
Adapt size to surroundings.
Definition: sectfrm.cxx:1067
virtual void Cut() override
Definition: sectfrm.cxx:249
void CalcFootnoteContent()
Definition: sectfrm.cxx:2811
bool IsContentLocked() const
Definition: sectfrm.hxx:152
SwFootnoteContFrame * ContainsFootnoteCont(const SwFootnoteContFrame *pCont=nullptr) const
Check every Column for FootnoteContFrames.
Definition: sectfrm.cxx:2758
bool IsFootnoteAtEnd() const
Definition: sectfrm.hxx:147
void MergeNext(SwSectionFrame *pNxt)
|* Merges two SectionFrames, in case it's about the same section.
Definition: sectfrm.cxx:463
bool IsEndnoteAtMyEnd() const
Definition: sectfrm.cxx:2545
bool CalcMinDiff(SwTwips &rMinDiff) const
Definition: sectfrm.cxx:942
SwSectionFrame(SwSection &, SwFrame *)
Definition: sectfrm.cxx:66
const SwFlowFrame * GetFollow() const
Definition: flowfrm.hxx:168
virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override
Definition: xmldump.cxx:550