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_TABFRM_HXX
20 : #define INCLUDED_SW_SOURCE_CORE_INC_TABFRM_HXX
21 :
22 : #include <tools/mempool.hxx>
23 : #include "layfrm.hxx"
24 : #include "flowfrm.hxx"
25 :
26 : class SwTable;
27 : class SwBorderAttrs;
28 : class SwAttrSetChg;
29 :
30 : /// SwTabFrm is one table in the document layout, containing rows (which contain cells).
31 : class SwTabFrm: public SwLayoutFrm, public SwFlowFrm
32 : {
33 : friend void CalcContent( SwLayoutFrm *pLay, bool bNoColl, bool bNoCalcFollow );
34 :
35 : // does the special treatment for _Get[Next|Prev]Leaf()
36 : using SwFrm::GetLeaf;
37 : SwLayoutFrm *GetLeaf( MakePageType eMakePage, bool bFwd );
38 :
39 : SwTable * m_pTable;
40 :
41 : bool m_bComplete :1; /// Set entries for Repaint without needing to
42 : /// set the base class' CompletePaint
43 : /// With that we would want to avoid unnecessary
44 : /// table repaints
45 : bool m_bCalcLowers :1; /// For stability of the content in MakeAll
46 : bool m_bLowersFormatted :1; /// Communication between MakeAll and Layact
47 : bool m_bLockBackMove :1; /// The Master took care of the BackMove test
48 : bool m_bResizeHTMLTable :1; /// Call the Resize of the HTMLTableLayout in the MakeAll
49 : /// This is an optimization, so that we don't have to call
50 : /// it in ContentFrm::Grow; there it might be called for
51 : /// _every_ Cell
52 :
53 : bool m_bONECalcLowers :1; /// Primarily for the StarONE SS
54 : /// The Contents are formatted via Calc() on MakeAll in any
55 : /// case. There are no further invalidations and that path can
56 : /// hardly give any guarantees
57 :
58 : bool m_bHasFollowFlowLine :1; /// Means that the first line in the follow
59 : /// is indented to contain content from a broken
60 : /// cell
61 : bool m_bIsRebuildLastLine :1; /// Means that currently the last line of the
62 : /// TabFrame is rebuilt. In this case we do not
63 : // want any notification to the master table
64 :
65 : bool m_bRestrictTableGrowth :1; // Usually, the table may grow infinitely,
66 : // as the table can be split in SwTabFrm::MakeAll
67 : // In MakeAll, this flag is set to indicate that
68 : // the table may only grow inside its upper. This
69 : // is necessary, in order to let the text flow into
70 : // the FollowFlowLine
71 :
72 : bool m_bRemoveFollowFlowLinePending :1;
73 :
74 : // #i26945#
75 : bool m_bConsiderObjsForMinCellHeight :1; // Usually, the floating screen objects
76 : // are considered during the calculation
77 : // for the minimal cell height.
78 : // For the splitting table rows algorithm
79 : // we need not to consider floating
80 : // screen object for the preparation
81 : // of the re-calculation of the
82 : // last table row.
83 : // #i26945#
84 : bool m_bObjsDoesFit :1; // For splitting table rows algorithm, this boolean
85 : // indicates, if the floating screen objects fits
86 :
87 : bool m_bInRecalcLowerRow : 1;
88 :
89 : /**
90 : * Split() splits the Frm at the specified position: a Follow is
91 : * created and constructed and inserted directly after this.
92 : * Join() gets the Follow's content and destroys it.
93 : */
94 : bool Split( const SwTwips nCutPos, bool bTryToSplit, bool bTableRowKeep );
95 : bool Join();
96 :
97 : void _UpdateAttr(
98 : const SfxPoolItem*,
99 : const SfxPoolItem*, sal_uInt8 &,
100 : SwAttrSetChg *pa = 0,
101 : SwAttrSetChg *pb = 0 );
102 :
103 : virtual bool ShouldBwdMoved( SwLayoutFrm *pNewUpper, bool bHead, bool &rReformat ) SAL_OVERRIDE;
104 :
105 : virtual void DestroyImpl() SAL_OVERRIDE;
106 : virtual ~SwTabFrm();
107 :
108 : protected:
109 : virtual void MakeAll() SAL_OVERRIDE;
110 : virtual void Format( const SwBorderAttrs *pAttrs = 0 ) SAL_OVERRIDE;
111 : virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) SAL_OVERRIDE;
112 : // only changes the Framesize, not the PrtArea size
113 : virtual SwTwips GrowFrm ( SwTwips, bool bTst = false, bool bInfo = false ) SAL_OVERRIDE;
114 :
115 : public:
116 : SwTabFrm( SwTable &, SwFrm* ); // calling Regist Flys always after creation _and_pasting!
117 : SwTabFrm( SwTabFrm & ); // _only_ for the creation of follows
118 :
119 : void JoinAndDelFollows(); // for DelFrms of the TableNodes!
120 :
121 : // calls thr RegistFlys of the rows
122 : void RegistFlys();
123 :
124 : inline const SwTabFrm *GetFollow() const;
125 : inline SwTabFrm *GetFollow();
126 : SwTabFrm* FindMaster( bool bFirstMaster = false ) const;
127 :
128 : virtual bool GetInfo( SfxPoolItem &rHint ) const SAL_OVERRIDE;
129 : virtual void Paint( SwRect const&,
130 : SwPrintData const*const pPrintData = NULL ) const SAL_OVERRIDE;
131 : virtual void CheckDirection( bool bVert ) SAL_OVERRIDE;
132 :
133 : virtual void Cut() SAL_OVERRIDE;
134 : virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 ) SAL_OVERRIDE;
135 :
136 : virtual bool Prepare( const PrepareHint ePrep = PREP_CLEAR,
137 : const void *pVoid = 0, bool bNotify = true ) SAL_OVERRIDE;
138 :
139 : SwContentFrm *FindLastContent();
140 : inline const SwContentFrm *FindLastContent() const;
141 :
142 49552 : const SwTable *GetTable() const { return m_pTable; }
143 28968 : SwTable *GetTable() { return m_pTable; }
144 :
145 1589 : bool IsComplete() { return m_bComplete; }
146 13270 : void SetComplete() { m_bComplete = true; }
147 526 : void ResetComplete() { m_bComplete = false; }
148 :
149 2731 : bool IsLowersFormatted() const { return m_bLowersFormatted; }
150 2434 : void SetLowersFormatted(bool b) { m_bLowersFormatted = b; }
151 :
152 6 : void SetCalcLowers() { m_bCalcLowers = true; } // use rarely
153 114 : void SetResizeHTMLTable() { m_bResizeHTMLTable = true; } // same
154 355 : void SetONECalcLowers() { m_bONECalcLowers = true; }
155 :
156 : // Start: New stuff for breaking table rows
157 :
158 30726 : bool HasFollowFlowLine() const { return m_bHasFollowFlowLine; }
159 22183 : void SetFollowFlowLine(bool bNew) { m_bHasFollowFlowLine = bNew; }
160 : //return the SwTabFrm (if any) that this SwTabFrm is a follow flow line for
161 : SwTabFrm* GetFollowFlowLineFor();
162 :
163 23066 : bool IsRebuildLastLine() const { return m_bIsRebuildLastLine; }
164 166 : void SetRebuildLastLine(bool bNew) { m_bIsRebuildLastLine = bNew; }
165 :
166 9517 : bool IsRestrictTableGrowth() const { return m_bRestrictTableGrowth; }
167 15429 : void SetRestrictTableGrowth( bool bNew ) { m_bRestrictTableGrowth = bNew; }
168 :
169 4301 : bool IsRemoveFollowFlowLinePending() const { return m_bRemoveFollowFlowLinePending; }
170 3 : void SetRemoveFollowFlowLinePending(bool bNew) { m_bRemoveFollowFlowLinePending = bNew; }
171 :
172 208 : bool IsInRecalcLowerRow() const
173 : {
174 208 : return m_bInRecalcLowerRow;
175 : }
176 264 : void SetInRecalcLowerRow( bool bNew )
177 : {
178 264 : m_bInRecalcLowerRow = bNew;
179 264 : }
180 :
181 : // #i26945#
182 40939 : bool IsConsiderObjsForMinCellHeight() const
183 : {
184 40939 : return m_bConsiderObjsForMinCellHeight;
185 : }
186 166 : void SetConsiderObjsForMinCellHeight(bool const bConsiderObjsForMinCellHeight)
187 : {
188 166 : m_bConsiderObjsForMinCellHeight = bConsiderObjsForMinCellHeight;
189 166 : }
190 :
191 : // #i26945#
192 55 : bool DoesObjsFit() const
193 : {
194 55 : return m_bObjsDoesFit;
195 : }
196 166 : void SetDoesObjsFit(bool const bObjsDoesFit)
197 : {
198 166 : m_bObjsDoesFit = bObjsDoesFit;
199 166 : }
200 :
201 : bool RemoveFollowFlowLine();
202 :
203 : // End: New stuff for breaking table rows
204 :
205 : bool CalcFlyOffsets(
206 : SwTwips& rUpper,
207 : long& rLeftOffset,
208 : long& rRightOffset ) const;
209 :
210 : SwTwips CalcHeightOfFirstContentLine() const;
211 :
212 : bool IsInHeadline( const SwFrm& rFrm ) const;
213 : SwRowFrm* GetFirstNonHeadlineRow() const;
214 :
215 : bool IsLayoutSplitAllowed() const;
216 :
217 : // #i29550#
218 : bool IsCollapsingBorders() const;
219 :
220 : sal_uInt16 GetBottomLineSize() const;
221 :
222 : virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const SAL_OVERRIDE;
223 :
224 1818 : DECL_FIXEDMEMPOOL_NEWDEL(SwTabFrm)
225 : };
226 :
227 31 : inline const SwContentFrm *SwTabFrm::FindLastContent() const
228 : {
229 31 : return const_cast<SwTabFrm*>(this)->FindLastContent();
230 : }
231 :
232 92618 : inline const SwTabFrm *SwTabFrm::GetFollow() const
233 : {
234 92618 : return static_cast<const SwTabFrm*>(SwFlowFrm::GetFollow());
235 : }
236 120248 : inline SwTabFrm *SwTabFrm::GetFollow()
237 : {
238 120248 : return static_cast<SwTabFrm*>(SwFlowFrm::GetFollow());
239 : }
240 :
241 : #endif // INCLUDED_SW_SOURCE_CORE_INC_TABFRM_HXX
242 :
243 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|