Line data Source code
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_LAYFRM_HXX
20 : #define INCLUDED_SW_SOURCE_CORE_INC_LAYFRM_HXX
21 :
22 : #include "frame.hxx"
23 :
24 : class SwAnchoredObject;
25 : class SwContentFrm;
26 : class SwFlowFrm;
27 : class SwFormatCol;
28 : struct SwCrsrMoveState;
29 : class SwFrameFormat;
30 : class SwBorderAttrs;
31 : class SwFormatFrmSize;
32 : class SwCellFrm;
33 :
34 : class SwLayoutFrm: public SwFrm
35 : {
36 : // The SwFrm in disguise
37 : friend class SwFlowFrm;
38 : friend class SwFrm;
39 :
40 : // Releases the Lower while restructuring columns
41 : friend SwFrm* SaveContent( SwLayoutFrm *, SwFrm * );
42 : friend void RestoreContent( SwFrm *, SwLayoutFrm *, SwFrm *pSibling, bool bGrow );
43 :
44 : #ifdef DBG_UTIL
45 : //removes empty SwSectionFrms from a chain
46 : friend SwFrm* SwClearDummies( SwFrm* pFrm );
47 : #endif
48 :
49 : void CopySubtree( const SwLayoutFrm *pDest );
50 :
51 : protected:
52 :
53 : virtual void DestroyImpl() SAL_OVERRIDE;
54 : virtual ~SwLayoutFrm();
55 :
56 : virtual void Format( const SwBorderAttrs *pAttrs = 0 ) SAL_OVERRIDE;
57 : virtual void MakeAll() SAL_OVERRIDE;
58 :
59 : SwFrm * m_pLower;
60 : std::vector<SwAnchoredObject*> m_VertPosOrientFrmsFor;
61 :
62 : virtual SwTwips ShrinkFrm( SwTwips, bool bTst = false, bool bInfo = false ) SAL_OVERRIDE;
63 : virtual SwTwips GrowFrm ( SwTwips, bool bTst = false, bool bInfo = false ) SAL_OVERRIDE;
64 :
65 : long CalcRel( const SwFormatFrmSize &rSz, bool bWidth ) const;
66 :
67 : public:
68 : // --> #i28701#
69 : TYPEINFO_OVERRIDE();
70 :
71 : virtual void PaintSubsidiaryLines( const SwPageFrm*, const SwRect& ) const;
72 : void RefreshLaySubsidiary( const SwPageFrm*, const SwRect& ) const;
73 : void RefreshExtraData( const SwRect & ) const;
74 :
75 : /// Change size of lowers proportionally
76 : void ChgLowersProp( const Size& rOldSize );
77 :
78 : void AdjustColumns( const SwFormatCol *pCol, bool bAdjustAttributes );
79 :
80 : void ChgColumns( const SwFormatCol &rOld, const SwFormatCol &rNew,
81 : const bool bChgFootnote = false );
82 :
83 : /// Paints the column separation line for the inner columns
84 : void PaintColLines( const SwRect &, const SwFormatCol &,
85 : const SwPageFrm * ) const;
86 :
87 : virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const SAL_OVERRIDE;
88 :
89 : virtual bool GetCrsrOfst( SwPosition *, Point&,
90 : SwCrsrMoveState* = 0, bool bTestBackground = false ) const SAL_OVERRIDE;
91 :
92 : virtual void Cut() SAL_OVERRIDE;
93 : virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 ) SAL_OVERRIDE;
94 :
95 : /**
96 : * Finds the closest Content for the SPoint
97 : * Is used for Pages, Flys and Cells if GetCrsrOfst failed
98 : */
99 : const SwContentFrm* GetContentPos( Point &rPoint, const bool bDontLeave,
100 : const bool bBodyOnly = false,
101 : const bool bCalc = false,
102 : const SwCrsrMoveState *pCMS = 0,
103 : const bool bDefaultExpand = true ) const;
104 :
105 : SwLayoutFrm( SwFrameFormat*, SwFrm* );
106 :
107 : virtual void Paint( SwRect const&,
108 : SwPrintData const*const pPrintData = NULL ) const SAL_OVERRIDE;
109 897455415 : const SwFrm *Lower() const { return m_pLower; }
110 125581987 : SwFrm *Lower() { return m_pLower; }
111 : const SwContentFrm *ContainsContent() const;
112 : inline SwContentFrm *ContainsContent();
113 : const SwCellFrm *FirstCell() const;
114 : inline SwCellFrm *FirstCell();
115 :
116 : /**
117 : * Method <ContainsAny()> doesn't investigate content of footnotes by default.
118 : * But under certain circumstances this investigation is intended.
119 : * Thus, introduce new optional parameter <_bInvestigateFootnoteForSections>.
120 : * It's default is <false>, still indicating that content of footnotes isn't
121 : * investigated for sections.
122 : */
123 : const SwFrm *ContainsAny( const bool _bInvestigateFootnoteForSections = false ) const;
124 : inline SwFrm *ContainsAny( const bool _bInvestigateFootnoteForSections = false );
125 : bool IsAnLower( const SwFrm * ) const;
126 :
127 : virtual const SwFrameFormat *GetFormat() const;
128 : virtual SwFrameFormat *GetFormat();
129 : void SetFrameFormat( SwFrameFormat* );
130 :
131 : /**
132 : * Moving the Footnotes of all Lowers - starting from StartContent
133 : *
134 : * @returns true if at least one Footnote was moved
135 : * Calls the page number update if bFootnoteNums is set
136 : */
137 : bool MoveLowerFootnotes( SwContentFrm *pStart, SwFootnoteBossFrm *pOldBoss,
138 : SwFootnoteBossFrm *pNewBoss, const bool bFootnoteNums );
139 :
140 : // --> #i28701# - change purpose of method and its name
141 : // --> #i44016# - add parameter <_bUnlockPosOfObjs> to
142 : /// force an unlockposition call for the lower objects.
143 : void NotifyLowerObjs( const bool _bUnlockPosOfObjs = false );
144 :
145 : /**
146 : * Invalidates the inner Frames, whose width and/or height are
147 : * calculated using percentages.
148 : * Frames that are anchored to this or inner Frames, are also invalidated.
149 : */
150 : void InvaPercentLowers( SwTwips nDiff = 0 );
151 :
152 : /// Called by Format for Frames and Areas with columns
153 : void FormatWidthCols( const SwBorderAttrs &, const SwTwips nBorder,
154 : const SwTwips nMinHeight );
155 :
156 : /**
157 : * InnerHeight returns the height of the content and may be bigger or
158 : * less than the PrtArea-Height of the layoutframe himself
159 : */
160 : SwTwips InnerHeight() const;
161 :
162 : /** method to check relative position of layout frame to
163 : a given layout frame.
164 :
165 : refactoring of pseudo-local method <lcl_Apres(..)> in
166 : <txtftn.cxx> for #104840#.
167 :
168 : @param _aCheckRefLayFrm
169 : constant reference of an instance of class <SwLayoutFrm> which
170 : is used as the reference for the relative position check.
171 :
172 : @return true, if <this> is positioned before the layout frame <p>
173 : */
174 : bool IsBefore( const SwLayoutFrm* _pCheckRefLayFrm ) const;
175 :
176 : const SwFrm* GetLastLower() const;
177 : inline SwFrm* GetLastLower();
178 :
179 : virtual void PaintBreak() const;
180 :
181 4587 : void SetVertPosOrientFrmFor(SwAnchoredObject *pObj)
182 : {
183 4587 : m_VertPosOrientFrmsFor.push_back(pObj);
184 4587 : }
185 :
186 4587 : void ClearVertPosOrientFrmFor(SwAnchoredObject *pObj)
187 : {
188 : m_VertPosOrientFrmsFor.erase(
189 : std::remove(m_VertPosOrientFrmsFor.begin(),
190 : m_VertPosOrientFrmsFor.end(), pObj),
191 4587 : m_VertPosOrientFrmsFor.end());
192 4587 : }
193 : };
194 :
195 : /**
196 : * In order to save us from duplicating implementations, we cast here
197 : * a little.
198 : */
199 129704204 : inline SwContentFrm* SwLayoutFrm::ContainsContent()
200 : {
201 129704204 : return const_cast<SwContentFrm*>(static_cast<const SwLayoutFrm*>(this)->ContainsContent());
202 : }
203 :
204 31 : inline SwCellFrm* SwLayoutFrm::FirstCell()
205 : {
206 31 : return const_cast<SwCellFrm*>(static_cast<const SwLayoutFrm*>(this)->FirstCell());
207 : }
208 :
209 7669 : inline SwFrm* SwLayoutFrm::ContainsAny( const bool _bInvestigateFootnoteForSections )
210 : {
211 7669 : return const_cast<SwFrm*>(static_cast<const SwLayoutFrm*>(this)->ContainsAny( _bInvestigateFootnoteForSections ));
212 : }
213 :
214 : /**
215 : * These SwFrm inlines are here, so that frame.hxx does not need to include layfrm.hxx
216 : */
217 71518 : inline bool SwFrm::IsColBodyFrm() const
218 : {
219 71518 : return mnFrmType == FRM_BODY && GetUpper()->IsColumnFrm();
220 : }
221 :
222 134530 : inline bool SwFrm::IsPageBodyFrm() const
223 : {
224 134530 : return mnFrmType == FRM_BODY && GetUpper()->IsPageFrm();
225 : }
226 :
227 4263 : inline SwFrm* SwLayoutFrm::GetLastLower()
228 : {
229 4263 : return const_cast<SwFrm*>(static_cast<const SwLayoutFrm*>(this)->GetLastLower());
230 : }
231 :
232 : #endif // INCLUDED_SW_SOURCE_CORE_INC_LAYFRM_HXX
233 :
234 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|