xref: /aoo41x/main/sw/source/core/layout/tabfrm.cxx (revision 7b20d707)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #include "pagefrm.hxx"
27cdf0e10cSrcweir #include "rootfrm.hxx"
28cdf0e10cSrcweir #include "cntfrm.hxx"
29cdf0e10cSrcweir #include "viewsh.hxx"
30cdf0e10cSrcweir #include "doc.hxx"
31cdf0e10cSrcweir #include "docsh.hxx"
32cdf0e10cSrcweir #include "viewimp.hxx"
33cdf0e10cSrcweir #include "swtable.hxx"
34cdf0e10cSrcweir #include "dflyobj.hxx"
35cdf0e10cSrcweir #include "flyfrm.hxx"
36cdf0e10cSrcweir #include "frmtool.hxx"
37cdf0e10cSrcweir #include "frmfmt.hxx"
38cdf0e10cSrcweir #include "dcontact.hxx"
39cdf0e10cSrcweir #include <anchoreddrawobject.hxx>
40cdf0e10cSrcweir #include <fmtanchr.hxx>
41cdf0e10cSrcweir #include "viewopt.hxx"
42cdf0e10cSrcweir #include "hints.hxx"
43cdf0e10cSrcweir #include "dbg_lay.hxx"
44cdf0e10cSrcweir #include <ftnidx.hxx>
45cdf0e10cSrcweir #include <svl/itemiter.hxx>
46cdf0e10cSrcweir #include <docary.hxx>
47cdf0e10cSrcweir #include <editeng/keepitem.hxx>
48cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
49cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
50cdf0e10cSrcweir #include <editeng/brshitem.hxx>
51cdf0e10cSrcweir #include <editeng/boxitem.hxx>
52cdf0e10cSrcweir #include <vcl/outdev.hxx>
53cdf0e10cSrcweir #include <fmtlsplt.hxx>
54cdf0e10cSrcweir #include <fmtrowsplt.hxx>
55cdf0e10cSrcweir #include <fmtsrnd.hxx>
56cdf0e10cSrcweir #include <fmtornt.hxx>
57cdf0e10cSrcweir #include <fmtpdsc.hxx>
58cdf0e10cSrcweir #include <fmtfsize.hxx>
59cdf0e10cSrcweir #include <swtblfmt.hxx>
60cdf0e10cSrcweir #include <ndtxt.hxx>
61cdf0e10cSrcweir #include "tabfrm.hxx"
62cdf0e10cSrcweir #include "rowfrm.hxx"
63cdf0e10cSrcweir #include "cellfrm.hxx"
64cdf0e10cSrcweir #include "flyfrms.hxx"
65cdf0e10cSrcweir #include "txtfrm.hxx"		//HasFtn()
66cdf0e10cSrcweir #include "htmltbl.hxx"
67cdf0e10cSrcweir #include "sectfrm.hxx"	//SwSectionFrm
68cdf0e10cSrcweir #include <fmtfollowtextflow.hxx>
69cdf0e10cSrcweir #include <sortedobjs.hxx>
70cdf0e10cSrcweir #include <objectformatter.hxx>
71cdf0e10cSrcweir #include <layouter.hxx>
72cdf0e10cSrcweir #include <switerator.hxx>
73cdf0e10cSrcweir 
74cdf0e10cSrcweir extern void AppendObjs( const SwSpzFrmFmts *pTbl, sal_uLong nIndex,
75cdf0e10cSrcweir 						SwFrm *pFrm, SwPageFrm *pPage );
76cdf0e10cSrcweir 
77cdf0e10cSrcweir using namespace ::com::sun::star;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 
80cdf0e10cSrcweir /*************************************************************************
81cdf0e10cSrcweir |*
82cdf0e10cSrcweir |*	SwTabFrm::SwTabFrm(), ~SwTabFrm()
83cdf0e10cSrcweir |*
84cdf0e10cSrcweir |*	Ersterstellung		MA 09. Mar. 93
85cdf0e10cSrcweir |*	Letzte Aenderung	MA 30. May. 96
86cdf0e10cSrcweir |*
87cdf0e10cSrcweir |*************************************************************************/
SwTabFrm(SwTable & rTab,SwFrm * pSib)88cdf0e10cSrcweir SwTabFrm::SwTabFrm( SwTable &rTab, SwFrm* pSib ):
89cdf0e10cSrcweir 	SwLayoutFrm( rTab.GetFrmFmt(), pSib ),
90cdf0e10cSrcweir 	SwFlowFrm( (SwFrm&)*this ),
91cdf0e10cSrcweir     pTable( &rTab )
92cdf0e10cSrcweir {
93cdf0e10cSrcweir 	bComplete = bCalcLowers = bONECalcLowers = bLowersFormatted = bLockBackMove =
94cdf0e10cSrcweir     bResizeHTMLTable = bHasFollowFlowLine = bIsRebuildLastLine =
95cdf0e10cSrcweir     bRestrictTableGrowth = bRemoveFollowFlowLinePending = sal_False;
96cdf0e10cSrcweir     bConsiderObjsForMinCellHeight = sal_True;
97cdf0e10cSrcweir     bObjsDoesFit = sal_True;
980df44b11SOliver-Rainer Wittmann     mbInRecalcLowerRow = false;
99cdf0e10cSrcweir     bFixSize = sal_False;     //Nicht nochmal auf die Importfilter hereinfallen.
100cdf0e10cSrcweir     nType = FRMC_TAB;
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	//Gleich die Zeilen erzeugen und einfuegen.
103cdf0e10cSrcweir 	const SwTableLines &rLines = rTab.GetTabLines();
104cdf0e10cSrcweir     SwFrm *pTmpPrev = 0;
105cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < rLines.Count(); ++i )
106cdf0e10cSrcweir 	{
107cdf0e10cSrcweir 		SwRowFrm *pNew = new SwRowFrm( *rLines[i], this );
108cdf0e10cSrcweir 		if( pNew->Lower() )
109cdf0e10cSrcweir 		{
110cdf0e10cSrcweir             pNew->InsertBehind( this, pTmpPrev );
111cdf0e10cSrcweir             pTmpPrev = pNew;
112cdf0e10cSrcweir 		}
113cdf0e10cSrcweir 		else
114cdf0e10cSrcweir 			delete pNew;
115cdf0e10cSrcweir 	}
116cdf0e10cSrcweir 	ASSERT( Lower() && Lower()->IsRowFrm(), "SwTabFrm::SwTabFrm: No rows." );
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
SwTabFrm(SwTabFrm & rTab)119cdf0e10cSrcweir SwTabFrm::SwTabFrm( SwTabFrm &rTab ) :
120cdf0e10cSrcweir 	SwLayoutFrm( rTab.GetFmt(), &rTab ),
121cdf0e10cSrcweir 	SwFlowFrm( (SwFrm&)*this ),
122cdf0e10cSrcweir     pTable( rTab.GetTable() )
123cdf0e10cSrcweir {
124cdf0e10cSrcweir 	bIsFollow = sal_True;
125cdf0e10cSrcweir 	bLockJoin = bComplete = bONECalcLowers = bCalcLowers = bLowersFormatted = bLockBackMove =
126cdf0e10cSrcweir     bResizeHTMLTable = bHasFollowFlowLine = bIsRebuildLastLine =
127cdf0e10cSrcweir     bRestrictTableGrowth = bRemoveFollowFlowLinePending = sal_False;
128cdf0e10cSrcweir     bConsiderObjsForMinCellHeight = sal_True;
129cdf0e10cSrcweir     bObjsDoesFit = sal_True;
1300df44b11SOliver-Rainer Wittmann     mbInRecalcLowerRow = false;
131cdf0e10cSrcweir     bFixSize = sal_False;     //Nicht nochmal auf die Importfilter hereinfallen.
132cdf0e10cSrcweir     nType = FRMC_TAB;
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 	SetFollow( rTab.GetFollow() );
135cdf0e10cSrcweir 	rTab.SetFollow( this );
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir extern const SwTable   *pColumnCacheLastTable;
139cdf0e10cSrcweir extern const SwTabFrm  *pColumnCacheLastTabFrm;
140cdf0e10cSrcweir extern const SwFrm     *pColumnCacheLastCellFrm;
141cdf0e10cSrcweir extern const SwTable   *pRowCacheLastTable;
142cdf0e10cSrcweir extern const SwTabFrm  *pRowCacheLastTabFrm;
143cdf0e10cSrcweir extern const SwFrm     *pRowCacheLastCellFrm;
144cdf0e10cSrcweir 
~SwTabFrm()145cdf0e10cSrcweir SwTabFrm::~SwTabFrm()
146cdf0e10cSrcweir {
147cdf0e10cSrcweir     // There is some terrible code in fetab.cxx, that
148cdf0e10cSrcweir     // makes use of these global pointers. Obviously
149cdf0e10cSrcweir     // this code did not consider that a TabFrm can be
150cdf0e10cSrcweir     // deleted.
151cdf0e10cSrcweir     if ( this == pColumnCacheLastTabFrm )
152cdf0e10cSrcweir     {
153cdf0e10cSrcweir         pColumnCacheLastTable  = NULL;
154cdf0e10cSrcweir         pColumnCacheLastTabFrm = NULL;
155cdf0e10cSrcweir         pColumnCacheLastCellFrm= NULL;
156cdf0e10cSrcweir         pRowCacheLastTable  = NULL;
157cdf0e10cSrcweir         pRowCacheLastTabFrm = NULL;
158cdf0e10cSrcweir         pRowCacheLastCellFrm= NULL;
159cdf0e10cSrcweir     }
160cdf0e10cSrcweir }
161cdf0e10cSrcweir 
162cdf0e10cSrcweir /*************************************************************************
163cdf0e10cSrcweir |*
164cdf0e10cSrcweir |*	SwTabFrm::JoinAndDelFollows()
165cdf0e10cSrcweir |*
166cdf0e10cSrcweir |*	Ersterstellung		MA 30. May. 96
167cdf0e10cSrcweir |*	Letzte Aenderung	MA 30. May. 96
168cdf0e10cSrcweir |*
169cdf0e10cSrcweir |*************************************************************************/
JoinAndDelFollows()170cdf0e10cSrcweir void SwTabFrm::JoinAndDelFollows()
171cdf0e10cSrcweir {
172cdf0e10cSrcweir 	SwTabFrm *pFoll = GetFollow();
173cdf0e10cSrcweir 	if ( pFoll->HasFollow() )
174cdf0e10cSrcweir 		pFoll->JoinAndDelFollows();
175cdf0e10cSrcweir 	pFoll->Cut();
176cdf0e10cSrcweir 	SetFollow( pFoll->GetFollow() );
177cdf0e10cSrcweir 	delete pFoll;
178cdf0e10cSrcweir }
179cdf0e10cSrcweir 
180cdf0e10cSrcweir /*************************************************************************
181cdf0e10cSrcweir |*
182cdf0e10cSrcweir |*	SwTabFrm::RegistFlys()
183cdf0e10cSrcweir |*
184cdf0e10cSrcweir |*	Ersterstellung		MA 08. Jul. 93
185cdf0e10cSrcweir |*	Letzte Aenderung	MA 27. Jan. 99
186cdf0e10cSrcweir |*
187cdf0e10cSrcweir |*************************************************************************/
RegistFlys()188cdf0e10cSrcweir void SwTabFrm::RegistFlys()
189cdf0e10cSrcweir {
190cdf0e10cSrcweir 	ASSERT( Lower() && Lower()->IsRowFrm(), "Keine Zeilen." );
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 	SwPageFrm *pPage = FindPageFrm();
193cdf0e10cSrcweir 	if ( pPage )
194cdf0e10cSrcweir 	{
195cdf0e10cSrcweir 		SwRowFrm *pRow = (SwRowFrm*)Lower();
196cdf0e10cSrcweir 		do
197cdf0e10cSrcweir 		{
198cdf0e10cSrcweir             pRow->RegistFlys( pPage );
199cdf0e10cSrcweir 			pRow = (SwRowFrm*)pRow->GetNext();
200cdf0e10cSrcweir 		} while ( pRow );
201cdf0e10cSrcweir 	}
202cdf0e10cSrcweir }
203cdf0e10cSrcweir 
204cdf0e10cSrcweir /*************************************************************************
205cdf0e10cSrcweir |*  Some prototypes
206cdf0e10cSrcweir |*************************************************************************/
207cdf0e10cSrcweir void MA_FASTCALL SwInvalidateAll( SwFrm *pFrm, long nBottom );
208cdf0e10cSrcweir void MA_FASTCALL lcl_RecalcRow( SwRowFrm& rRow, long nBottom );
209cdf0e10cSrcweir sal_Bool lcl_ArrangeLowers( SwLayoutFrm *pLay, long lYStart, sal_Bool bInva );
210cdf0e10cSrcweir // --> OD 2004-10-15 #i26945# - add parameter <_bOnlyRowsAndCells> to control
211cdf0e10cSrcweir // that only row and cell frames are formatted.
212cdf0e10cSrcweir sal_Bool MA_FASTCALL lcl_InnerCalcLayout( SwFrm *pFrm,
213cdf0e10cSrcweir                                       long nBottom,
214cdf0e10cSrcweir                                       bool _bOnlyRowsAndCells = false );
215cdf0e10cSrcweir // <--
216cdf0e10cSrcweir // OD 2004-02-18 #106629# - correct type of 1st parameter
217cdf0e10cSrcweir // --> OD 2004-10-04 #i26945# - add parameter <_bConsiderObjs> in order to
218cdf0e10cSrcweir // control, if floating screen objects have to be considered for the minimal
219cdf0e10cSrcweir // cell height.
220cdf0e10cSrcweir SwTwips MA_FASTCALL lcl_CalcMinRowHeight( const SwRowFrm *pRow,
221cdf0e10cSrcweir                                           const sal_Bool _bConsiderObjs );
222cdf0e10cSrcweir // <--
223cdf0e10cSrcweir SwTwips lcl_CalcTopAndBottomMargin( const SwLayoutFrm&, const SwBorderAttrs& );
224cdf0e10cSrcweir 
225cdf0e10cSrcweir /*************************************************************************
226cdf0e10cSrcweir |*  START: local helper functions for repeated headlines
227cdf0e10cSrcweir |*************************************************************************/
228cdf0e10cSrcweir 
lcl_GetHeightOfRows(const SwFrm * pStart,long nCount)229cdf0e10cSrcweir SwTwips lcl_GetHeightOfRows( const SwFrm* pStart, long nCount )
230cdf0e10cSrcweir {
231cdf0e10cSrcweir     if ( !nCount || !pStart)
232cdf0e10cSrcweir         return 0;
233cdf0e10cSrcweir 
234cdf0e10cSrcweir     SwTwips nRet = 0;
235cdf0e10cSrcweir     SWRECTFN( pStart )
236cdf0e10cSrcweir     while ( pStart && nCount > 0 )
237cdf0e10cSrcweir     {
238cdf0e10cSrcweir         nRet += (pStart->Frm().*fnRect->fnGetHeight)();
239cdf0e10cSrcweir         pStart = pStart->GetNext();
240cdf0e10cSrcweir         --nCount;
241cdf0e10cSrcweir     }
242cdf0e10cSrcweir 
243cdf0e10cSrcweir     return nRet;
244cdf0e10cSrcweir }
245cdf0e10cSrcweir 
246cdf0e10cSrcweir /*************************************************************************
247cdf0e10cSrcweir |*  END: local helper functions for repeated headlines
248cdf0e10cSrcweir |*************************************************************************/
249cdf0e10cSrcweir 
250cdf0e10cSrcweir /*************************************************************************
251cdf0e10cSrcweir |*  START: local helper functions for splitting row frames
252cdf0e10cSrcweir |*************************************************************************/
253cdf0e10cSrcweir 
254cdf0e10cSrcweir //
255cdf0e10cSrcweir // Local helper function to insert a new follow flow line
256cdf0e10cSrcweir //
lcl_InsertNewFollowFlowLine(SwTabFrm & rTab,const SwFrm & rTmpRow,bool bRowSpanLine)257cdf0e10cSrcweir SwRowFrm* lcl_InsertNewFollowFlowLine( SwTabFrm& rTab, const SwFrm& rTmpRow, bool bRowSpanLine )
258cdf0e10cSrcweir {
259cdf0e10cSrcweir     ASSERT( rTmpRow.IsRowFrm(), "No row frame to copy for FollowFlowLine" )
260cdf0e10cSrcweir     const SwRowFrm& rRow = (SwRowFrm&)rTmpRow;
261cdf0e10cSrcweir 
262cdf0e10cSrcweir     rTab.SetFollowFlowLine( sal_True );
263cdf0e10cSrcweir     SwRowFrm *pFollowFlowLine = new SwRowFrm(*rRow.GetTabLine(), &rTab, false );
264cdf0e10cSrcweir     pFollowFlowLine->SetRowSpanLine( bRowSpanLine );
265cdf0e10cSrcweir     SwFrm* pFirstRow = rTab.GetFollow()->GetFirstNonHeadlineRow();
266cdf0e10cSrcweir     pFollowFlowLine->InsertBefore( rTab.GetFollow(), pFirstRow );
267cdf0e10cSrcweir     return pFollowFlowLine;
268cdf0e10cSrcweir }
269cdf0e10cSrcweir 
270cdf0e10cSrcweir // --> OD 2004-11-05 #i26945# - local helper function to invalidate all lower
271cdf0e10cSrcweir // objects. By parameter <_bMoveObjsOutOfRange> it can be controlled, if
272cdf0e10cSrcweir // additionally the objects are moved 'out of range'.
lcl_InvalidateLowerObjs(SwLayoutFrm & _rLayoutFrm,const bool _bMoveObjsOutOfRange=false,SwPageFrm * _pPageFrm=0L)273cdf0e10cSrcweir void lcl_InvalidateLowerObjs( SwLayoutFrm& _rLayoutFrm,
274cdf0e10cSrcweir                               const bool _bMoveObjsOutOfRange = false,
275cdf0e10cSrcweir                               SwPageFrm* _pPageFrm = 0L )
276cdf0e10cSrcweir {
277cdf0e10cSrcweir     // determine page frame, if needed
278cdf0e10cSrcweir     if ( !_pPageFrm )
279cdf0e10cSrcweir     {
280cdf0e10cSrcweir         _pPageFrm = _rLayoutFrm.FindPageFrm();
281cdf0e10cSrcweir         ASSERT( _pPageFrm,
282cdf0e10cSrcweir                 "<lcl_InvalidateLowerObjs(..)> - missing page frame -> no move of lower objects out of range" );
283cdf0e10cSrcweir         if ( !_pPageFrm )
284cdf0e10cSrcweir         {
285cdf0e10cSrcweir             return;
286cdf0e10cSrcweir         }
287cdf0e10cSrcweir     }
288cdf0e10cSrcweir 
289cdf0e10cSrcweir     // loop on lower frames
290cdf0e10cSrcweir     SwFrm* pLowerFrm = _rLayoutFrm.Lower();
291cdf0e10cSrcweir     while ( pLowerFrm )
292cdf0e10cSrcweir     {
293cdf0e10cSrcweir         if ( pLowerFrm->IsLayoutFrm() )
294cdf0e10cSrcweir         {
295cdf0e10cSrcweir             ::lcl_InvalidateLowerObjs( *(static_cast<SwLayoutFrm*>(pLowerFrm)),
296cdf0e10cSrcweir                                        _bMoveObjsOutOfRange, _pPageFrm );
297cdf0e10cSrcweir         }
298cdf0e10cSrcweir         if ( pLowerFrm->GetDrawObjs() )
299cdf0e10cSrcweir         {
300cdf0e10cSrcweir             for ( sal_uInt16 i = 0; i < pLowerFrm->GetDrawObjs()->Count(); ++i )
301cdf0e10cSrcweir             {
302cdf0e10cSrcweir                 SwAnchoredObject* pAnchoredObj = (*pLowerFrm->GetDrawObjs())[i];
303cdf0e10cSrcweir 
304cdf0e10cSrcweir                 // invalidate position of anchored object
305cdf0e10cSrcweir                 pAnchoredObj->SetTmpConsiderWrapInfluence( false );
306cdf0e10cSrcweir                 pAnchoredObj->SetConsiderForTextWrap( false );
307cdf0e10cSrcweir                 pAnchoredObj->UnlockPosition();
308cdf0e10cSrcweir                 pAnchoredObj->InvalidateObjPos();
309cdf0e10cSrcweir 
310cdf0e10cSrcweir                 // move anchored object 'out of range'
311cdf0e10cSrcweir                 if ( _bMoveObjsOutOfRange )
312cdf0e10cSrcweir                 {
313cdf0e10cSrcweir                     // indicate, that positioning is progress to avoid
314cdf0e10cSrcweir                     // modification of the anchored object resp. its attributes
315cdf0e10cSrcweir                     // due to the movement
316cdf0e10cSrcweir                     SwObjPositioningInProgress aObjPosInProgress( *pAnchoredObj );
317cdf0e10cSrcweir                     pAnchoredObj->SetObjLeft( _pPageFrm->Frm().Right() );
318cdf0e10cSrcweir                     // --> OD 2004-11-24 #115759# - reset character rectangle,
319cdf0e10cSrcweir                     // top of line and relative position in order to assure,
320cdf0e10cSrcweir                     // that anchored object is correctly positioned.
321cdf0e10cSrcweir                     pAnchoredObj->ClearCharRectAndTopOfLine();
322cdf0e10cSrcweir                     pAnchoredObj->SetCurrRelPos( Point( 0, 0 ) );
323cdf0e10cSrcweir                     if ( pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId()
324cdf0e10cSrcweir                             == FLY_AS_CHAR )
325cdf0e10cSrcweir                     {
326cdf0e10cSrcweir                         pAnchoredObj->AnchorFrm()
327cdf0e10cSrcweir                                 ->Prepare( PREP_FLY_ATTR_CHG,
328cdf0e10cSrcweir                                            &(pAnchoredObj->GetFrmFmt()) );
329cdf0e10cSrcweir                     }
330cdf0e10cSrcweir                     // <--
331cdf0e10cSrcweir                     if ( pAnchoredObj->ISA(SwFlyFrm) )
332cdf0e10cSrcweir                     {
333cdf0e10cSrcweir                         SwFlyFrm *pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
334cdf0e10cSrcweir                         pFly->GetVirtDrawObj()->SetRectsDirty();
335cdf0e10cSrcweir                         pFly->GetVirtDrawObj()->SetChanged();
336cdf0e10cSrcweir                     }
337cdf0e10cSrcweir                 }
338cdf0e10cSrcweir 
339cdf0e10cSrcweir                 // If anchored object is a fly frame, invalidate its lower objects
340cdf0e10cSrcweir                 if ( pAnchoredObj->ISA(SwFlyFrm) )
341cdf0e10cSrcweir                 {
342cdf0e10cSrcweir                     SwFlyFrm *pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
343cdf0e10cSrcweir                     ::lcl_InvalidateLowerObjs( *pFly, _bMoveObjsOutOfRange, _pPageFrm );
344cdf0e10cSrcweir                 }
345cdf0e10cSrcweir             }
346cdf0e10cSrcweir         }
347cdf0e10cSrcweir         pLowerFrm = pLowerFrm->GetNext();
348cdf0e10cSrcweir     }
349cdf0e10cSrcweir }
350cdf0e10cSrcweir // <--
351cdf0e10cSrcweir //
352cdf0e10cSrcweir // Local helper function to shrink all lowers of rRow to 0 height
353cdf0e10cSrcweir //
lcl_ShrinkCellsAndAllContent(SwRowFrm & rRow)354cdf0e10cSrcweir void lcl_ShrinkCellsAndAllContent( SwRowFrm& rRow )
355cdf0e10cSrcweir {
356cdf0e10cSrcweir     SwCellFrm* pCurrMasterCell = static_cast<SwCellFrm*>(rRow.Lower());
357cdf0e10cSrcweir     SWRECTFN( pCurrMasterCell )
358cdf0e10cSrcweir 
359cdf0e10cSrcweir     while ( pCurrMasterCell )
360cdf0e10cSrcweir     {
361cdf0e10cSrcweir         // NEW TABLES
362cdf0e10cSrcweir         SwCellFrm& rToAdjust = pCurrMasterCell->GetTabBox()->getRowSpan() < 1 ?
363cdf0e10cSrcweir                                const_cast<SwCellFrm&>(pCurrMasterCell->FindStartEndOfRowSpanCell( true, true )) :
364cdf0e10cSrcweir                                *pCurrMasterCell;
365cdf0e10cSrcweir 
366cdf0e10cSrcweir         // --> OD 2004-10-04 #i26945#
367cdf0e10cSrcweir         // all lowers should have the correct position
368cdf0e10cSrcweir         lcl_ArrangeLowers( &rToAdjust,
369cdf0e10cSrcweir                            (rToAdjust.*fnRect->fnGetPrtTop)(),
370cdf0e10cSrcweir                            sal_False );
371cdf0e10cSrcweir         // <--
372cdf0e10cSrcweir         // TODO: Optimize number of frames which are set to 0 height
373cdf0e10cSrcweir         // we have to start with the last lower frame, otherwise
374cdf0e10cSrcweir         // the shrink will not shrink the current cell
375cdf0e10cSrcweir         SwFrm* pTmp = rToAdjust.GetLastLower();
376cdf0e10cSrcweir 
377cdf0e10cSrcweir         if ( pTmp && pTmp->IsRowFrm() )
378cdf0e10cSrcweir         {
379cdf0e10cSrcweir             SwRowFrm* pTmpRow = (SwRowFrm*)pTmp;
380cdf0e10cSrcweir             lcl_ShrinkCellsAndAllContent( *pTmpRow );
381cdf0e10cSrcweir         }
382cdf0e10cSrcweir         else
383cdf0e10cSrcweir         {
384cdf0e10cSrcweir             // TODO: Optimize number of frames which are set to 0 height
385cdf0e10cSrcweir             while ( pTmp )
386cdf0e10cSrcweir             {
387cdf0e10cSrcweir                 // the frames have to be shrunk
388cdf0e10cSrcweir                 if ( pTmp && pTmp->IsTabFrm() )
389cdf0e10cSrcweir                 {
390cdf0e10cSrcweir                     SwRowFrm* pTmpRow = (SwRowFrm*)((SwTabFrm*)pTmp)->Lower();
391cdf0e10cSrcweir                     while ( pTmpRow )
392cdf0e10cSrcweir                     {
393cdf0e10cSrcweir                         lcl_ShrinkCellsAndAllContent( *pTmpRow );
394cdf0e10cSrcweir                         pTmpRow = (SwRowFrm*)pTmpRow->GetNext();
395cdf0e10cSrcweir                     }
396cdf0e10cSrcweir                 }
397cdf0e10cSrcweir                 else
398cdf0e10cSrcweir                 {
399cdf0e10cSrcweir                     pTmp->Shrink( (pTmp->Frm().*fnRect->fnGetHeight)() );
400cdf0e10cSrcweir                     (pTmp->Prt().*fnRect->fnSetTop)( 0 );
401cdf0e10cSrcweir                     (pTmp->Prt().*fnRect->fnSetHeight)( 0 );
402cdf0e10cSrcweir                 }
403cdf0e10cSrcweir 
404cdf0e10cSrcweir                 pTmp = pTmp->GetPrev();
405cdf0e10cSrcweir             }
406cdf0e10cSrcweir 
407cdf0e10cSrcweir             // all lowers should have the correct position
408cdf0e10cSrcweir             lcl_ArrangeLowers( &rToAdjust,
409cdf0e10cSrcweir                                (rToAdjust.*fnRect->fnGetPrtTop)(),
410cdf0e10cSrcweir                                sal_False );
411cdf0e10cSrcweir         }
412cdf0e10cSrcweir 
413cdf0e10cSrcweir         pCurrMasterCell = static_cast<SwCellFrm*>(pCurrMasterCell->GetNext());
414cdf0e10cSrcweir     }
415cdf0e10cSrcweir }
416cdf0e10cSrcweir 
417cdf0e10cSrcweir //
418cdf0e10cSrcweir // Local helper function to move the content from rSourceLine to rDestLine
419cdf0e10cSrcweir // The content is inserted behind the last content in the corresponding
420cdf0e10cSrcweir // cell in rDestLine.
421cdf0e10cSrcweir //
lcl_MoveRowContent(SwRowFrm & rSourceLine,SwRowFrm & rDestLine)422cdf0e10cSrcweir void lcl_MoveRowContent( SwRowFrm& rSourceLine, SwRowFrm& rDestLine )
423cdf0e10cSrcweir {
424cdf0e10cSrcweir     SwCellFrm* pCurrDestCell = (SwCellFrm*)rDestLine.Lower();
425cdf0e10cSrcweir     SwCellFrm* pCurrSourceCell = (SwCellFrm*)rSourceLine.Lower();
426cdf0e10cSrcweir 
427cdf0e10cSrcweir     // Move content of follow cells into master cells
428cdf0e10cSrcweir     while ( pCurrSourceCell )
429cdf0e10cSrcweir     {
430cdf0e10cSrcweir         if ( pCurrSourceCell->Lower() && pCurrSourceCell->Lower()->IsRowFrm() )
431cdf0e10cSrcweir         {
432cdf0e10cSrcweir             SwRowFrm* pTmpSourceRow = (SwRowFrm*)pCurrSourceCell->Lower();
433cdf0e10cSrcweir             while ( pTmpSourceRow )
434cdf0e10cSrcweir             {
435cdf0e10cSrcweir                 // --> FME 2006-01-10 #125926# Achtung! It is possible,
436cdf0e10cSrcweir                 // that pTmpSourceRow->IsFollowFlowRow() but pTmpDestRow
437cdf0e10cSrcweir                 // cannot be found. In this case, we have to move the complete
438cdf0e10cSrcweir                 // row.
439cdf0e10cSrcweir                 SwRowFrm* pTmpDestRow = (SwRowFrm*)pCurrDestCell->Lower();
440cdf0e10cSrcweir                 // <--
441cdf0e10cSrcweir 
442cdf0e10cSrcweir                 if ( pTmpSourceRow->IsFollowFlowRow() && pTmpDestRow )
443cdf0e10cSrcweir                 {
444cdf0e10cSrcweir                     // move content from follow flow row to pTmpDestRow:
445cdf0e10cSrcweir                     while ( pTmpDestRow->GetNext() )
446cdf0e10cSrcweir                         pTmpDestRow = (SwRowFrm*)pTmpDestRow->GetNext();
447cdf0e10cSrcweir 
448cdf0e10cSrcweir                     ASSERT( pTmpDestRow->GetFollowRow() == pTmpSourceRow, "Knoten in der Tabelle" )
449cdf0e10cSrcweir 
450cdf0e10cSrcweir                     lcl_MoveRowContent( *pTmpSourceRow, *pTmpDestRow );
451cdf0e10cSrcweir                     pTmpDestRow->SetFollowRow( pTmpSourceRow->GetFollowRow() );
452cdf0e10cSrcweir                     pTmpSourceRow->Remove();
453cdf0e10cSrcweir                     delete pTmpSourceRow;
454cdf0e10cSrcweir                 }
455cdf0e10cSrcweir                 else
456cdf0e10cSrcweir                 {
457cdf0e10cSrcweir                     // move complete row:
458cdf0e10cSrcweir                     pTmpSourceRow->Remove();
459cdf0e10cSrcweir                     pTmpSourceRow->InsertBefore( pCurrDestCell, 0 );
460cdf0e10cSrcweir                 }
461cdf0e10cSrcweir 
462cdf0e10cSrcweir                 pTmpSourceRow = (SwRowFrm*)pCurrSourceCell->Lower();
463cdf0e10cSrcweir             }
464cdf0e10cSrcweir         }
465cdf0e10cSrcweir         else
466cdf0e10cSrcweir         {
467cdf0e10cSrcweir             SwFrm *pTmp = ::SaveCntnt( (SwCellFrm*)pCurrSourceCell );
468cdf0e10cSrcweir             if ( pTmp )
469cdf0e10cSrcweir             {
470cdf0e10cSrcweir                 // NEW TABLES
471cdf0e10cSrcweir                 SwCellFrm* pDestCell = static_cast<SwCellFrm*>(pCurrDestCell);
472cdf0e10cSrcweir                 if ( pDestCell->GetTabBox()->getRowSpan() < 1 )
473cdf0e10cSrcweir                     pDestCell = & const_cast<SwCellFrm&>(pDestCell->FindStartEndOfRowSpanCell( true, true ));
474cdf0e10cSrcweir 
475cdf0e10cSrcweir                 // Find last content
476cdf0e10cSrcweir                 SwFrm* pFrm = pDestCell->GetLastLower();
477cdf0e10cSrcweir                 ::RestoreCntnt( pTmp, pDestCell, pFrm, true );
478cdf0e10cSrcweir             }
479cdf0e10cSrcweir         }
480cdf0e10cSrcweir         pCurrDestCell = (SwCellFrm*)pCurrDestCell->GetNext();
481cdf0e10cSrcweir         pCurrSourceCell = (SwCellFrm*)pCurrSourceCell->GetNext();
482cdf0e10cSrcweir     }
483cdf0e10cSrcweir }
484cdf0e10cSrcweir 
485cdf0e10cSrcweir //
486cdf0e10cSrcweir // Local helper function to move all footnotes in rRowFrm from
487cdf0e10cSrcweir // the footnote boss of rSource to the footnote boss of rDest.
488cdf0e10cSrcweir //
lcl_MoveFootnotes(SwTabFrm & rSource,SwTabFrm & rDest,SwLayoutFrm & rRowFrm)489cdf0e10cSrcweir void lcl_MoveFootnotes( SwTabFrm& rSource, SwTabFrm& rDest, SwLayoutFrm& rRowFrm )
490cdf0e10cSrcweir {
491cdf0e10cSrcweir     if ( 0 != rSource.GetFmt()->GetDoc()->GetFtnIdxs().Count() )
492cdf0e10cSrcweir     {
493cdf0e10cSrcweir         SwFtnBossFrm* pOldBoss = rSource.FindFtnBossFrm( sal_True );
494cdf0e10cSrcweir         SwFtnBossFrm* pNewBoss = rDest.FindFtnBossFrm( sal_True );
495cdf0e10cSrcweir         rRowFrm.MoveLowerFtns( 0, pOldBoss, pNewBoss, sal_True );
496cdf0e10cSrcweir     }
497cdf0e10cSrcweir }
498cdf0e10cSrcweir 
499cdf0e10cSrcweir //
500cdf0e10cSrcweir // Local helper function to handle nested table cells before the split process
501cdf0e10cSrcweir //
lcl_PreprocessRowsInCells(SwTabFrm & rTab,SwRowFrm & rLastLine,SwRowFrm & rFollowFlowLine,SwTwips nRemain)502cdf0e10cSrcweir void lcl_PreprocessRowsInCells( SwTabFrm& rTab, SwRowFrm& rLastLine,
503cdf0e10cSrcweir                                 SwRowFrm& rFollowFlowLine, SwTwips nRemain )
504cdf0e10cSrcweir {
505cdf0e10cSrcweir     SwCellFrm* pCurrLastLineCell = (SwCellFrm*)rLastLine.Lower();
506cdf0e10cSrcweir     SwCellFrm* pCurrFollowFlowLineCell = (SwCellFrm*)rFollowFlowLine.Lower();
507cdf0e10cSrcweir 
508cdf0e10cSrcweir     SWRECTFN( pCurrLastLineCell )
509cdf0e10cSrcweir 
510cdf0e10cSrcweir     //
511cdf0e10cSrcweir     // Move content of follow cells into master cells
512cdf0e10cSrcweir     //
513cdf0e10cSrcweir     while ( pCurrLastLineCell )
514cdf0e10cSrcweir     {
515cdf0e10cSrcweir         if ( pCurrLastLineCell->Lower() && pCurrLastLineCell->Lower()->IsRowFrm() )
516cdf0e10cSrcweir         {
517cdf0e10cSrcweir             SwTwips nTmpCut = nRemain;
518cdf0e10cSrcweir             SwRowFrm* pTmpLastLineRow = (SwRowFrm*)pCurrLastLineCell->Lower();
519cdf0e10cSrcweir 
520cdf0e10cSrcweir             // --> OD 2004-10-04 #i26945#
521cdf0e10cSrcweir             SwTwips nCurrentHeight =
522cdf0e10cSrcweir                     lcl_CalcMinRowHeight( pTmpLastLineRow,
523cdf0e10cSrcweir                                           rTab.IsConsiderObjsForMinCellHeight() );
524cdf0e10cSrcweir             // <--
525cdf0e10cSrcweir             while ( pTmpLastLineRow && pTmpLastLineRow->GetNext() && nTmpCut > nCurrentHeight )
526cdf0e10cSrcweir             {
527cdf0e10cSrcweir                 nTmpCut -= nCurrentHeight;
528cdf0e10cSrcweir                 pTmpLastLineRow = (SwRowFrm*)pTmpLastLineRow->GetNext();
529cdf0e10cSrcweir                 // --> OD 2004-10-04 #i26945#
530cdf0e10cSrcweir                 nCurrentHeight =
531cdf0e10cSrcweir                     lcl_CalcMinRowHeight( pTmpLastLineRow,
532cdf0e10cSrcweir                                           rTab.IsConsiderObjsForMinCellHeight() );
533cdf0e10cSrcweir                 // <--
534cdf0e10cSrcweir             }
535cdf0e10cSrcweir 
536cdf0e10cSrcweir             //
537cdf0e10cSrcweir             // pTmpLastLineRow does not fit to the line or it is the last line
538cdf0e10cSrcweir             //
539cdf0e10cSrcweir             if ( pTmpLastLineRow )
540cdf0e10cSrcweir             {
541cdf0e10cSrcweir                 //
542cdf0e10cSrcweir                 // Check if we can move pTmpLastLineRow to the follow table,
543cdf0e10cSrcweir                 // or if we have to split the line:
544cdf0e10cSrcweir                 //
545cdf0e10cSrcweir                 SwFrm* pCell = pTmpLastLineRow->Lower();
546cdf0e10cSrcweir                 bool bTableLayoutToComplex = false;
547cdf0e10cSrcweir                 long nMinHeight = 0;
548cdf0e10cSrcweir 
549cdf0e10cSrcweir                 //
550cdf0e10cSrcweir                 // We have to take into account:
551cdf0e10cSrcweir                 // 1. The fixed height of the row
552cdf0e10cSrcweir                 // 2. The borders of the cells inside the row
553cdf0e10cSrcweir                 // 3. The minimum height of the row
554cdf0e10cSrcweir                 //
555cdf0e10cSrcweir                 if ( pTmpLastLineRow->HasFixSize() )
556cdf0e10cSrcweir                     nMinHeight = (pTmpLastLineRow->Frm().*fnRect->fnGetHeight)();
557cdf0e10cSrcweir                 else
558cdf0e10cSrcweir                 {
559cdf0e10cSrcweir                     while ( pCell )
560cdf0e10cSrcweir                     {
561cdf0e10cSrcweir                         if ( ((SwCellFrm*)pCell)->Lower() &&
562cdf0e10cSrcweir                              ((SwCellFrm*)pCell)->Lower()->IsRowFrm() )
563cdf0e10cSrcweir                         {
564cdf0e10cSrcweir                             bTableLayoutToComplex = true;
565cdf0e10cSrcweir                             break;
566cdf0e10cSrcweir                         }
567cdf0e10cSrcweir 
568cdf0e10cSrcweir                 		SwBorderAttrAccess aAccess( SwFrm::GetCache(), pCell );
569cdf0e10cSrcweir 	        	        const SwBorderAttrs &rAttrs = *aAccess.Get();
570cdf0e10cSrcweir                         nMinHeight = Max( nMinHeight, lcl_CalcTopAndBottomMargin( *(SwLayoutFrm*)pCell, rAttrs ) );
571cdf0e10cSrcweir                         pCell = pCell->GetNext();
572cdf0e10cSrcweir                     }
573cdf0e10cSrcweir 
574cdf0e10cSrcweir                 	const SwFmtFrmSize &rSz = pTmpLastLineRow->GetFmt()->GetFrmSize();
575cdf0e10cSrcweir                     if ( rSz.GetHeightSizeType() == ATT_MIN_SIZE )
576cdf0e10cSrcweir 		                nMinHeight = Max( nMinHeight, rSz.GetHeight() );
577cdf0e10cSrcweir                 }
578cdf0e10cSrcweir 
579cdf0e10cSrcweir                 //
580cdf0e10cSrcweir                 // 1. Case:
581cdf0e10cSrcweir                 // The line completely fits into the master table.
582cdf0e10cSrcweir                 // Nevertheless, we build a follow (otherwise painting problems
583cdf0e10cSrcweir                 // with empty cell).
584cdf0e10cSrcweir                 //
585cdf0e10cSrcweir                 // 2. Case:
586cdf0e10cSrcweir                 // The line has to be split, the minimum height still fits into
587cdf0e10cSrcweir                 // the master table, and the table structure is not to complex.
588cdf0e10cSrcweir                 //
589cdf0e10cSrcweir                 if ( nTmpCut > nCurrentHeight ||
590cdf0e10cSrcweir                      ( pTmpLastLineRow->IsRowSplitAllowed() &&
591cdf0e10cSrcweir                       !bTableLayoutToComplex && nMinHeight < nTmpCut ) )
592cdf0e10cSrcweir                 {
593cdf0e10cSrcweir                     // The line has to be split:
594cdf0e10cSrcweir                     SwRowFrm* pNewRow = new SwRowFrm( *pTmpLastLineRow->GetTabLine(), &rTab, false );
595cdf0e10cSrcweir                     pNewRow->SetFollowFlowRow( true );
596cdf0e10cSrcweir                     pNewRow->SetFollowRow( pTmpLastLineRow->GetFollowRow() );
597cdf0e10cSrcweir                     pTmpLastLineRow->SetFollowRow( pNewRow );
598cdf0e10cSrcweir                     pNewRow->InsertBehind( pCurrFollowFlowLineCell, 0 );
599cdf0e10cSrcweir                     pTmpLastLineRow = (SwRowFrm*)pTmpLastLineRow->GetNext();
600cdf0e10cSrcweir                 }
601cdf0e10cSrcweir 
602cdf0e10cSrcweir                 //
603cdf0e10cSrcweir                 // The following lines have to be moved:
604cdf0e10cSrcweir                 //
605cdf0e10cSrcweir                 while ( pTmpLastLineRow )
606cdf0e10cSrcweir                 {
607cdf0e10cSrcweir                     SwRowFrm* pTmp = (SwRowFrm*)pTmpLastLineRow->GetNext();
608cdf0e10cSrcweir                     lcl_MoveFootnotes( rTab, *rTab.GetFollow(), *pTmpLastLineRow );
609cdf0e10cSrcweir                     pTmpLastLineRow->Remove();
610cdf0e10cSrcweir                     pTmpLastLineRow->InsertBefore( pCurrFollowFlowLineCell, 0 );
611cdf0e10cSrcweir                     pTmpLastLineRow->Shrink( ( pTmpLastLineRow->Frm().*fnRect->fnGetHeight)() );
612cdf0e10cSrcweir                     pCurrFollowFlowLineCell->Grow( ( pTmpLastLineRow->Frm().*fnRect->fnGetHeight)() );
613cdf0e10cSrcweir                     pTmpLastLineRow = pTmp;
614cdf0e10cSrcweir                 }
615cdf0e10cSrcweir             }
616cdf0e10cSrcweir         }
617cdf0e10cSrcweir 
618cdf0e10cSrcweir         pCurrLastLineCell = (SwCellFrm*)pCurrLastLineCell->GetNext();
619cdf0e10cSrcweir         pCurrFollowFlowLineCell = (SwCellFrm*)pCurrFollowFlowLineCell->GetNext();
620cdf0e10cSrcweir     }
621cdf0e10cSrcweir }
622cdf0e10cSrcweir 
623cdf0e10cSrcweir //
624cdf0e10cSrcweir // Local helper function to handle nested table cells after the split process
625cdf0e10cSrcweir //
lcl_PostprocessRowsInCells(SwTabFrm & rTab,SwRowFrm & rLastLine)626cdf0e10cSrcweir void lcl_PostprocessRowsInCells( SwTabFrm& rTab, SwRowFrm& rLastLine )
627cdf0e10cSrcweir {
628cdf0e10cSrcweir     SwCellFrm* pCurrMasterCell = (SwCellFrm*)rLastLine.Lower();
629cdf0e10cSrcweir     while ( pCurrMasterCell )
630cdf0e10cSrcweir     {
631cdf0e10cSrcweir         if ( pCurrMasterCell->Lower() &&
632cdf0e10cSrcweir              pCurrMasterCell->Lower()->IsRowFrm() )
633cdf0e10cSrcweir         {
634cdf0e10cSrcweir             SwRowFrm* pRowFrm = static_cast<SwRowFrm*>(pCurrMasterCell->GetLastLower());
635cdf0e10cSrcweir 
636cdf0e10cSrcweir             if ( NULL != pRowFrm->GetPrev() && !pRowFrm->ContainsCntnt() )
637cdf0e10cSrcweir             {
638cdf0e10cSrcweir                 ASSERT( pRowFrm->GetFollowRow(), "Deleting row frame without follow" )
639cdf0e10cSrcweir 
640cdf0e10cSrcweir                 // The footnotes have to be moved:
641cdf0e10cSrcweir                 lcl_MoveFootnotes( rTab, *rTab.GetFollow(), *pRowFrm );
642cdf0e10cSrcweir                 pRowFrm->Cut();
643cdf0e10cSrcweir                 SwRowFrm* pFollowRow = pRowFrm->GetFollowRow();
644cdf0e10cSrcweir                 pRowFrm->Paste( pFollowRow->GetUpper(), pFollowRow );
645cdf0e10cSrcweir                 pRowFrm->SetFollowRow( pFollowRow->GetFollowRow() );
646cdf0e10cSrcweir                 lcl_MoveRowContent( *pFollowRow, *pRowFrm );
647cdf0e10cSrcweir                 pFollowRow->Cut();
648cdf0e10cSrcweir                 delete pFollowRow;
649cdf0e10cSrcweir                 ::SwInvalidateAll( pCurrMasterCell, LONG_MAX );
650cdf0e10cSrcweir             }
651cdf0e10cSrcweir         }
652cdf0e10cSrcweir 
653cdf0e10cSrcweir         pCurrMasterCell = (SwCellFrm*)pCurrMasterCell->GetNext();
654cdf0e10cSrcweir     }
655cdf0e10cSrcweir }
656cdf0e10cSrcweir 
657cdf0e10cSrcweir //
658cdf0e10cSrcweir // Local helper function to re-calculate the split line.
659cdf0e10cSrcweir //
TableSplitRecalcLock(SwFlowFrm * pTab)660cdf0e10cSrcweir inline void TableSplitRecalcLock( SwFlowFrm *pTab ) { pTab->LockJoin(); }
TableSplitRecalcUnlock(SwFlowFrm * pTab)661cdf0e10cSrcweir inline void TableSplitRecalcUnlock( SwFlowFrm *pTab ) { pTab->UnlockJoin(); }
662cdf0e10cSrcweir 
lcl_RecalcSplitLine(SwRowFrm & rLastLine,SwRowFrm & rFollowLine,SwTwips nRemainingSpaceForLastRow)663cdf0e10cSrcweir bool lcl_RecalcSplitLine( SwRowFrm& rLastLine, SwRowFrm& rFollowLine,
664cdf0e10cSrcweir                           SwTwips nRemainingSpaceForLastRow )
665cdf0e10cSrcweir {
666cdf0e10cSrcweir     bool bRet = true;
667cdf0e10cSrcweir 
668cdf0e10cSrcweir     SwTabFrm& rTab = (SwTabFrm&)*rLastLine.GetUpper();
669cdf0e10cSrcweir 
670cdf0e10cSrcweir     //
671cdf0e10cSrcweir     // If there are nested cells in rLastLine, the recalculation of the last
672cdf0e10cSrcweir     // line needs some preprocessing.
673cdf0e10cSrcweir     //
674cdf0e10cSrcweir     lcl_PreprocessRowsInCells( rTab, rLastLine, rFollowLine, nRemainingSpaceForLastRow );
675cdf0e10cSrcweir 
676cdf0e10cSrcweir     //
677cdf0e10cSrcweir     // Here the recalculation process starts:
678cdf0e10cSrcweir     //
679cdf0e10cSrcweir     rTab.SetRebuildLastLine( sal_True );
680cdf0e10cSrcweir     // --> OD 2004-10-15 #i26945#
681cdf0e10cSrcweir     rTab.SetDoesObjsFit( sal_True );
682cdf0e10cSrcweir     // <--
683cdf0e10cSrcweir     SWRECTFN( rTab.GetUpper() )
684cdf0e10cSrcweir 
685cdf0e10cSrcweir     // --> OD 2004-11-05 #i26945# - invalidate and move floating screen
686cdf0e10cSrcweir     // objects 'out of range'
687cdf0e10cSrcweir     ::lcl_InvalidateLowerObjs( rLastLine, true );
688cdf0e10cSrcweir     // <--
689cdf0e10cSrcweir     //
690cdf0e10cSrcweir     // manipulate row and cell sizes
691cdf0e10cSrcweir     //
692cdf0e10cSrcweir     // --> OD 2004-10-04 #i26945# - Do *not* consider floating screen objects
693cdf0e10cSrcweir     // for the minimal cell height.
694cdf0e10cSrcweir     rTab.SetConsiderObjsForMinCellHeight( sal_False );
695cdf0e10cSrcweir     ::lcl_ShrinkCellsAndAllContent( rLastLine );
696cdf0e10cSrcweir     rTab.SetConsiderObjsForMinCellHeight( sal_True );
697cdf0e10cSrcweir     // <--
698cdf0e10cSrcweir 
699cdf0e10cSrcweir     //
700cdf0e10cSrcweir     // invalidate last line
701cdf0e10cSrcweir     //
702cdf0e10cSrcweir     ::SwInvalidateAll( &rLastLine, LONG_MAX );
703cdf0e10cSrcweir 
704cdf0e10cSrcweir     //
705cdf0e10cSrcweir     // Lock this tab frame and its follow
706cdf0e10cSrcweir     //
707cdf0e10cSrcweir     bool bUnlockMaster = false;
708cdf0e10cSrcweir     bool bUnlockFollow = false;
709cdf0e10cSrcweir     SwTabFrm* pMaster = rTab.IsFollow() ? (SwTabFrm*)rTab.FindMaster() : 0;
710cdf0e10cSrcweir     if ( pMaster && !pMaster->IsJoinLocked() )
711cdf0e10cSrcweir     {
712cdf0e10cSrcweir         bUnlockMaster = true;
713cdf0e10cSrcweir         ::TableSplitRecalcLock( pMaster );
714cdf0e10cSrcweir     }
715cdf0e10cSrcweir     if ( !rTab.GetFollow()->IsJoinLocked() )
716cdf0e10cSrcweir     {
717cdf0e10cSrcweir         bUnlockFollow = true;
718cdf0e10cSrcweir         ::TableSplitRecalcLock( rTab.GetFollow() );
719cdf0e10cSrcweir     }
720cdf0e10cSrcweir 
721cdf0e10cSrcweir     //
722cdf0e10cSrcweir     // TODO: e.g., for i71806: What shall we do if the table already
723cdf0e10cSrcweir     // exceeds its upper? I think we have to adjust the heights of the
724cdf0e10cSrcweir     // table, rLastRow and all cells in rLastRow
725cdf0e10cSrcweir     //
726cdf0e10cSrcweir     /*SwTwips nDistanceToUpperPrtBottom =
727cdf0e10cSrcweir             (rTab.Frm().*fnRect->fnBottomDist)( (rTab.GetUpper()->*fnRect->fnGetPrtBottom)());
728cdf0e10cSrcweir 
729cdf0e10cSrcweir     if ( nDistanceToUpperPrtBottom < 0 )
730cdf0e10cSrcweir     {
731cdf0e10cSrcweir         (rTab.Frm().*fnRect->fnAddBottom)( nDistanceToUpperPrtBottom );
732cdf0e10cSrcweir         (rTab.Prt().*fnRect->fnAddBottom)( nDistanceToUpperPrtBottom );
733cdf0e10cSrcweir 
734cdf0e10cSrcweir         (rLastLine.Frm().*fnRect->fnAddBottom)( nDistanceToUpperPrtBottom );
735cdf0e10cSrcweir         (rLastLine.Prt().*fnRect->fnAddBottom)( nDistanceToUpperPrtBottom );
736cdf0e10cSrcweir 
737cdf0e10cSrcweir         SwFrm* pTmpCell = rLastLine.Lower();
738cdf0e10cSrcweir         while ( pTmpCell )
739cdf0e10cSrcweir         {
740cdf0e10cSrcweir             (pTmpCell->Frm().*fnRect->fnAddBottom)( nDistanceToUpperPrtBottom );
741cdf0e10cSrcweir             (pTmpCell->Prt().*fnRect->fnAddBottom)( nDistanceToUpperPrtBottom );
742cdf0e10cSrcweir 
743cdf0e10cSrcweir             pTmpCell = pTmpCell->GetNext();
744cdf0e10cSrcweir         }
745cdf0e10cSrcweir     }*/
746cdf0e10cSrcweir 
747cdf0e10cSrcweir     //
748cdf0e10cSrcweir     // Do the recalculation
749cdf0e10cSrcweir     //
750cdf0e10cSrcweir     lcl_RecalcRow( rLastLine, LONG_MAX );
751cdf0e10cSrcweir     // --> OD 2004-11-23 #115759# - force a format of the last line in order to
752cdf0e10cSrcweir     // get the correct height.
753cdf0e10cSrcweir     rLastLine.InvalidateSize();
754cdf0e10cSrcweir     rLastLine.Calc();
755cdf0e10cSrcweir     // <--
756cdf0e10cSrcweir 
757cdf0e10cSrcweir     //
758cdf0e10cSrcweir     // Unlock this tab frame and its follow
759cdf0e10cSrcweir     //
760cdf0e10cSrcweir     if ( bUnlockFollow )
761cdf0e10cSrcweir         ::TableSplitRecalcUnlock( rTab.GetFollow() );
762cdf0e10cSrcweir     if ( bUnlockMaster )
763cdf0e10cSrcweir         ::TableSplitRecalcUnlock( pMaster );
764cdf0e10cSrcweir 
765cdf0e10cSrcweir     //
766cdf0e10cSrcweir     // If there are nested cells in rLastLine, the recalculation of the last
767cdf0e10cSrcweir     // line needs some postprocessing.
768cdf0e10cSrcweir     //
769cdf0e10cSrcweir     lcl_PostprocessRowsInCells( rTab, rLastLine );
770cdf0e10cSrcweir 
771cdf0e10cSrcweir     //
772cdf0e10cSrcweir     // Do a couple of checks on the current situation.
773cdf0e10cSrcweir     //
774cdf0e10cSrcweir     // If we are not happy with the current situation we return false.
775cdf0e10cSrcweir     // This will start a new try to split the table, this time we do not
776cdf0e10cSrcweir     // try to split the table rows.
777cdf0e10cSrcweir     //
778cdf0e10cSrcweir 
779cdf0e10cSrcweir     //
780cdf0e10cSrcweir     // 1. Check if table fits to its upper.
781cdf0e10cSrcweir     // --> OD 2004-10-15 #i26945# - include check, if objects fit
782cdf0e10cSrcweir     //
783cdf0e10cSrcweir     const SwTwips nDistanceToUpperPrtBottom =
784cdf0e10cSrcweir             (rTab.Frm().*fnRect->fnBottomDist)( (rTab.GetUpper()->*fnRect->fnGetPrtBottom)());
785cdf0e10cSrcweir     if ( nDistanceToUpperPrtBottom < 0 || !rTab.DoesObjsFit() )
786cdf0e10cSrcweir         bRet = false;
787cdf0e10cSrcweir     // <--
788cdf0e10cSrcweir 
789cdf0e10cSrcweir     //
790cdf0e10cSrcweir     // 2. Check if each cell in the last line has at least one content frame.
791cdf0e10cSrcweir     //
792cdf0e10cSrcweir     // Note: a FollowFlowRow may contains empty cells!
793cdf0e10cSrcweir     //
794cdf0e10cSrcweir     if ( bRet )
795cdf0e10cSrcweir     {
796cdf0e10cSrcweir         if ( !rLastLine.IsInFollowFlowRow() )
797cdf0e10cSrcweir         {
798cdf0e10cSrcweir             SwCellFrm* pCurrMasterCell = (SwCellFrm*)rLastLine.Lower();
799cdf0e10cSrcweir             while ( pCurrMasterCell )
800cdf0e10cSrcweir             {
801cdf0e10cSrcweir                 if ( !pCurrMasterCell->ContainsCntnt() && pCurrMasterCell->GetTabBox()->getRowSpan() >= 1 )
802cdf0e10cSrcweir                 {
803cdf0e10cSrcweir                     bRet = false;
804cdf0e10cSrcweir                     break;
805cdf0e10cSrcweir                 }
806cdf0e10cSrcweir                 pCurrMasterCell = (SwCellFrm*)pCurrMasterCell->GetNext();
807cdf0e10cSrcweir             }
808cdf0e10cSrcweir         }
809cdf0e10cSrcweir     }
810cdf0e10cSrcweir 
811cdf0e10cSrcweir     //
812cdf0e10cSrcweir     // 3. Check if last line does not contain any content:
813cdf0e10cSrcweir     //
814cdf0e10cSrcweir     if ( bRet )
815cdf0e10cSrcweir     {
816cdf0e10cSrcweir         if ( !rLastLine.ContainsCntnt() )
817cdf0e10cSrcweir         {
818cdf0e10cSrcweir             bRet = false;
819cdf0e10cSrcweir         }
820cdf0e10cSrcweir     }
821cdf0e10cSrcweir 
822cdf0e10cSrcweir 
823cdf0e10cSrcweir     //
824cdf0e10cSrcweir     // 4. Check if follow flow line does not contain content:
825cdf0e10cSrcweir     //
826cdf0e10cSrcweir     if ( bRet )
827cdf0e10cSrcweir     {
828cdf0e10cSrcweir         if ( !rFollowLine.IsRowSpanLine() && !rFollowLine.ContainsCntnt() )
829cdf0e10cSrcweir         {
830cdf0e10cSrcweir             bRet = false;
831cdf0e10cSrcweir         }
832cdf0e10cSrcweir     }
833cdf0e10cSrcweir 
834cdf0e10cSrcweir     if ( bRet )
835cdf0e10cSrcweir     {
836cdf0e10cSrcweir         //
837cdf0e10cSrcweir         // Everything looks fine. Splitting seems to be successful. We invalidate
838cdf0e10cSrcweir         // rFollowLine to force a new formatting.
839cdf0e10cSrcweir         //
840cdf0e10cSrcweir         ::SwInvalidateAll( &rFollowLine, LONG_MAX );
841cdf0e10cSrcweir     }
842cdf0e10cSrcweir     else
843cdf0e10cSrcweir     {
844cdf0e10cSrcweir         //
845cdf0e10cSrcweir         // Splitting the table row gave us an unexpected result.
846cdf0e10cSrcweir         // Everything has to be prepared for a second try to split
847cdf0e10cSrcweir         // the table, this time without splitting the row.
848cdf0e10cSrcweir         //
849cdf0e10cSrcweir         ::SwInvalidateAll( &rLastLine, LONG_MAX );
850cdf0e10cSrcweir     }
851cdf0e10cSrcweir 
852cdf0e10cSrcweir     rTab.SetRebuildLastLine( sal_False );
853cdf0e10cSrcweir     // --> OD 2004-10-15 #i26945#
854cdf0e10cSrcweir     rTab.SetDoesObjsFit( sal_True );
855cdf0e10cSrcweir     // <--
856cdf0e10cSrcweir 
857cdf0e10cSrcweir     return bRet;
858cdf0e10cSrcweir }
859cdf0e10cSrcweir 
860cdf0e10cSrcweir //
861cdf0e10cSrcweir // Sets the correct height for all spanned cells
862cdf0e10cSrcweir //
lcl_AdjustRowSpanCells(SwRowFrm * pRow)863cdf0e10cSrcweir void lcl_AdjustRowSpanCells( SwRowFrm* pRow )
864cdf0e10cSrcweir {
865cdf0e10cSrcweir     SWRECTFN( pRow )
866cdf0e10cSrcweir     SwCellFrm* pCellFrm = static_cast<SwCellFrm*>(pRow->GetLower());
867cdf0e10cSrcweir     while ( pCellFrm )
868cdf0e10cSrcweir     {
869cdf0e10cSrcweir         const long nLayoutRowSpan = pCellFrm->GetLayoutRowSpan();
870cdf0e10cSrcweir         if ( nLayoutRowSpan > 1 )
871cdf0e10cSrcweir         {
872cdf0e10cSrcweir             // calculate height of cell:
873cdf0e10cSrcweir             const long nNewCellHeight = lcl_GetHeightOfRows( pRow, nLayoutRowSpan );
874cdf0e10cSrcweir             const long nDiff = nNewCellHeight - (pCellFrm->Frm().*fnRect->fnGetHeight)();
875cdf0e10cSrcweir             if ( nDiff )
876cdf0e10cSrcweir                 (pCellFrm->Frm().*fnRect->fnAddBottom)( nDiff );
877cdf0e10cSrcweir         }
878cdf0e10cSrcweir 
879cdf0e10cSrcweir         pCellFrm = static_cast<SwCellFrm*>(pCellFrm->GetNext());
880cdf0e10cSrcweir     }
881cdf0e10cSrcweir }
882cdf0e10cSrcweir 
883cdf0e10cSrcweir //
884cdf0e10cSrcweir // Returns the maximum layout row span of the row
885cdf0e10cSrcweir // Looking for the next row that contains no covered cells:
lcl_GetMaximumLayoutRowSpan(const SwRowFrm & rRow)886cdf0e10cSrcweir long lcl_GetMaximumLayoutRowSpan( const SwRowFrm& rRow )
887cdf0e10cSrcweir {
888cdf0e10cSrcweir     long nRet = 1;
889cdf0e10cSrcweir 
890cdf0e10cSrcweir     const SwRowFrm* pCurrentRowFrm = static_cast<const SwRowFrm*>(rRow.GetNext());
891cdf0e10cSrcweir     bool bNextRow = false;
892cdf0e10cSrcweir 
893cdf0e10cSrcweir     while ( pCurrentRowFrm )
894cdf0e10cSrcweir     {
895cdf0e10cSrcweir         // if there is any covered cell, we proceed to the next row frame
896cdf0e10cSrcweir         const SwCellFrm* pLower = static_cast<const SwCellFrm*>( pCurrentRowFrm->Lower());
897cdf0e10cSrcweir         while ( pLower )
898cdf0e10cSrcweir         {
899cdf0e10cSrcweir             if ( pLower->GetTabBox()->getRowSpan() < 0 )
900cdf0e10cSrcweir             {
901cdf0e10cSrcweir                 ++nRet;
902cdf0e10cSrcweir                 bNextRow = true;
903cdf0e10cSrcweir                 break;
904cdf0e10cSrcweir             }
905cdf0e10cSrcweir             pLower = static_cast<const SwCellFrm*>(pLower->GetNext());
906cdf0e10cSrcweir         }
907cdf0e10cSrcweir         pCurrentRowFrm = bNextRow ?
908cdf0e10cSrcweir                          static_cast<const SwRowFrm*>(pCurrentRowFrm->GetNext() ) :
909cdf0e10cSrcweir                          0;
910cdf0e10cSrcweir     }
911cdf0e10cSrcweir 
912cdf0e10cSrcweir     return nRet;
913cdf0e10cSrcweir }
914cdf0e10cSrcweir 
915cdf0e10cSrcweir /*************************************************************************
916cdf0e10cSrcweir |*  END: local helper functions for splitting row frames
917cdf0e10cSrcweir |*************************************************************************/
918cdf0e10cSrcweir 
919cdf0e10cSrcweir //
920cdf0e10cSrcweir // Function to remove the FollowFlowLine of rTab.
921cdf0e10cSrcweir // The content of the FollowFlowLine is moved to the associated line in the
922cdf0e10cSrcweir // master table.
923cdf0e10cSrcweir //
RemoveFollowFlowLine()924cdf0e10cSrcweir bool SwTabFrm::RemoveFollowFlowLine()
925cdf0e10cSrcweir {
926cdf0e10cSrcweir     // find FollowFlowLine
927cdf0e10cSrcweir     SwRowFrm* pFollowFlowLine = static_cast<SwRowFrm*>(GetFollow()->GetFirstNonHeadlineRow());
928cdf0e10cSrcweir 
929cdf0e10cSrcweir     // find last row in master
930cdf0e10cSrcweir     SwFrm* pLastLine = GetLastLower();
931cdf0e10cSrcweir 
932cdf0e10cSrcweir     ASSERT( HasFollowFlowLine() &&
933cdf0e10cSrcweir             pFollowFlowLine &&
934cdf0e10cSrcweir             pLastLine, "There should be a flowline in the follow" )
935cdf0e10cSrcweir 
936cdf0e10cSrcweir     // We have to reset the flag here, because lcl_MoveRowContent
937cdf0e10cSrcweir     // calls a GrowFrm(), which has a different bahavior if
938cdf0e10cSrcweir     // this flag is set.
939cdf0e10cSrcweir     SetFollowFlowLine( sal_False );
940cdf0e10cSrcweir 
941cdf0e10cSrcweir     // --> FME 2007-07-19 #140081# Make code robust.
942cdf0e10cSrcweir     if ( !pFollowFlowLine || !pLastLine )
943cdf0e10cSrcweir         return true;
944cdf0e10cSrcweir 
945cdf0e10cSrcweir     // Move content
946cdf0e10cSrcweir     lcl_MoveRowContent( *pFollowFlowLine, *(SwRowFrm*)pLastLine );
947cdf0e10cSrcweir 
948cdf0e10cSrcweir     // NEW TABLES
949cdf0e10cSrcweir     // If a row span follow flow line is removed, we want to move the whole span
950cdf0e10cSrcweir     // to the master:
951cdf0e10cSrcweir     SwTwips nGrow = 0;
952cdf0e10cSrcweir     long nRowsToMove = lcl_GetMaximumLayoutRowSpan( *pFollowFlowLine );
953cdf0e10cSrcweir 
954cdf0e10cSrcweir     if ( nRowsToMove > 1 )
955cdf0e10cSrcweir     {
956cdf0e10cSrcweir         SWRECTFN( this )
957cdf0e10cSrcweir         SwFrm* pRow = pFollowFlowLine->GetNext();
958cdf0e10cSrcweir         SwFrm* pInsertBehind = GetLastLower();
959cdf0e10cSrcweir 
960cdf0e10cSrcweir         while ( pRow && nRowsToMove-- > 1 )
961cdf0e10cSrcweir 		{
962cdf0e10cSrcweir 			SwFrm* pNxt = pRow->GetNext();
963cdf0e10cSrcweir             nGrow += (pRow->Frm().*fnRect->fnGetHeight)();
964cdf0e10cSrcweir 
965cdf0e10cSrcweir             // The footnotes have to be moved:
966cdf0e10cSrcweir             lcl_MoveFootnotes( *GetFollow(), *this, (SwRowFrm&)*pRow );
967cdf0e10cSrcweir 
968cdf0e10cSrcweir             pRow->Remove();
969cdf0e10cSrcweir             pRow->InsertBehind( this, pInsertBehind );
970cdf0e10cSrcweir 			pRow->_InvalidateAll();
971cdf0e10cSrcweir             pRow->CheckDirChange();
972cdf0e10cSrcweir             pInsertBehind = pRow;
973cdf0e10cSrcweir             pRow = pNxt;
974cdf0e10cSrcweir         }
975cdf0e10cSrcweir 
976cdf0e10cSrcweir         SwFrm* pFirstRow = Lower();
977cdf0e10cSrcweir         while ( pFirstRow )
978cdf0e10cSrcweir         {
979cdf0e10cSrcweir             lcl_AdjustRowSpanCells( static_cast<SwRowFrm*>(pFirstRow) );
980cdf0e10cSrcweir             pFirstRow = pFirstRow->GetNext();
981cdf0e10cSrcweir         }
982cdf0e10cSrcweir 
983cdf0e10cSrcweir         Grow( nGrow );
984cdf0e10cSrcweir         GetFollow()->Shrink( nGrow );
985cdf0e10cSrcweir     }
986cdf0e10cSrcweir 
987cdf0e10cSrcweir     bool bJoin = !pFollowFlowLine->GetNext();
988cdf0e10cSrcweir     pFollowFlowLine->Cut();
989cdf0e10cSrcweir     delete pFollowFlowLine;
990cdf0e10cSrcweir 
991cdf0e10cSrcweir     return bJoin;
992cdf0e10cSrcweir }
993cdf0e10cSrcweir 
994cdf0e10cSrcweir // --> OD 2004-10-04 #i26945# - Floating screen objects are no longer searched.
lcl_FindSectionsInRow(const SwRowFrm & rRow)995cdf0e10cSrcweir bool lcl_FindSectionsInRow( const SwRowFrm& rRow )
996cdf0e10cSrcweir {
997cdf0e10cSrcweir     bool bRet = false;
998cdf0e10cSrcweir     SwCellFrm* pLower = (SwCellFrm*)rRow.Lower();
999cdf0e10cSrcweir     while ( pLower )
1000cdf0e10cSrcweir     {
1001cdf0e10cSrcweir         if ( pLower->IsVertical() != rRow.IsVertical() )
1002cdf0e10cSrcweir             return true;
1003cdf0e10cSrcweir 
1004cdf0e10cSrcweir         SwFrm* pTmpFrm = pLower->Lower();
1005cdf0e10cSrcweir         while ( pTmpFrm )
1006cdf0e10cSrcweir         {
1007cdf0e10cSrcweir             if ( pTmpFrm->IsRowFrm() )
1008cdf0e10cSrcweir             {
1009cdf0e10cSrcweir                 bRet = lcl_FindSectionsInRow( *(SwRowFrm*)pTmpFrm );
1010cdf0e10cSrcweir             }
1011cdf0e10cSrcweir             else
1012cdf0e10cSrcweir             {
1013cdf0e10cSrcweir                 // --> OD 2004-10-04 #i26945# - search only for sections
1014cdf0e10cSrcweir                 bRet = pTmpFrm->IsSctFrm();
1015cdf0e10cSrcweir                 // <--
1016cdf0e10cSrcweir             }
1017cdf0e10cSrcweir 
1018cdf0e10cSrcweir             if ( bRet )
1019cdf0e10cSrcweir                 return true;
1020cdf0e10cSrcweir             pTmpFrm = pTmpFrm->GetNext();
1021cdf0e10cSrcweir         }
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir         pLower = (SwCellFrm*)pLower->GetNext();
1024cdf0e10cSrcweir     }
1025cdf0e10cSrcweir     return bRet;
1026cdf0e10cSrcweir }
1027cdf0e10cSrcweir 
1028cdf0e10cSrcweir /*************************************************************************
1029cdf0e10cSrcweir |*
1030cdf0e10cSrcweir |*	SwTabFrm::Split(), Join()
1031cdf0e10cSrcweir |*
1032cdf0e10cSrcweir |*	Ersterstellung		MA 03. Jun. 93
1033cdf0e10cSrcweir |*	Letzte Aenderung	MA 03. Sep. 96
1034cdf0e10cSrcweir |*
1035cdf0e10cSrcweir |*************************************************************************/
Split(const SwTwips nCutPos,bool bTryToSplit,bool bTableRowKeep)1036cdf0e10cSrcweir bool SwTabFrm::Split( const SwTwips nCutPos, bool bTryToSplit, bool bTableRowKeep )
1037cdf0e10cSrcweir {
1038cdf0e10cSrcweir     bool bRet = true;
1039cdf0e10cSrcweir 
1040cdf0e10cSrcweir     SWRECTFN( this )
1041cdf0e10cSrcweir     //ASSERT( bVert ? nCutPos >= Frm().Left() &&
1042cdf0e10cSrcweir     //                nCutPos <= Frm().Left() + Frm().Width() :
1043cdf0e10cSrcweir     //                nCutPos >= Frm().Top() && nCutPos <= Frm().Bottom(), "SplitLine out of table." );
1044cdf0e10cSrcweir 
1045cdf0e10cSrcweir     // --> OD 2004-10-14 #i26745# - format row and cell frames of table
1046cdf0e10cSrcweir     {
1047cdf0e10cSrcweir         this->Lower()->_InvalidatePos();
1048cdf0e10cSrcweir         // --> OD 2005-03-30 #i43913# - correction:
1049cdf0e10cSrcweir         // call method <lcl_InnerCalcLayout> with first lower.
1050cdf0e10cSrcweir         lcl_InnerCalcLayout( this->Lower(), LONG_MAX, true );
1051cdf0e10cSrcweir         // <--
1052cdf0e10cSrcweir     }
1053cdf0e10cSrcweir     // <--
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir     //Um die Positionen der Zellen mit der CutPos zu vergleichen muessen sie
1056cdf0e10cSrcweir 	//ausgehend von der Tabelle nacheinander berechnet werden. Sie koennen
1057cdf0e10cSrcweir 	//wg. Positionsaenderungen der Tabelle durchaus ungueltig sein.
1058cdf0e10cSrcweir 	SwRowFrm *pRow = static_cast<SwRowFrm*>(Lower());
1059cdf0e10cSrcweir 	if( !pRow )
1060cdf0e10cSrcweir         return bRet;
1061cdf0e10cSrcweir 
1062cdf0e10cSrcweir     const sal_uInt16 nRepeat = GetTable()->GetRowsToRepeat();
1063cdf0e10cSrcweir     sal_uInt16 nRowCount = 0;           // pRow currently points to the first row
1064cdf0e10cSrcweir 
1065cdf0e10cSrcweir     SwTwips nRemainingSpaceForLastRow =
1066cdf0e10cSrcweir         (*fnRect->fnYDiff)( nCutPos, (Frm().*fnRect->fnGetTop)() );
1067cdf0e10cSrcweir     nRemainingSpaceForLastRow -= (this->*fnRect->fnGetTopMargin)();
1068cdf0e10cSrcweir 
1069cdf0e10cSrcweir     //
1070cdf0e10cSrcweir     // Make pRow point to the line that does not fit anymore:
1071cdf0e10cSrcweir     //
1072cdf0e10cSrcweir     while( pRow->GetNext() &&
1073cdf0e10cSrcweir            nRemainingSpaceForLastRow >= ( (pRow->Frm().*fnRect->fnGetHeight)() +
1074cdf0e10cSrcweir                                            (IsCollapsingBorders() ?
1075cdf0e10cSrcweir                                             pRow->GetBottomLineSize() :
1076cdf0e10cSrcweir                                             0 ) ) )
1077cdf0e10cSrcweir 	{
1078cdf0e10cSrcweir 		if( bTryToSplit || !pRow->IsRowSpanLine() ||
1079cdf0e10cSrcweir 			0 != (pRow->Frm().*fnRect->fnGetHeight)() )
1080cdf0e10cSrcweir 			++nRowCount;
1081cdf0e10cSrcweir         nRemainingSpaceForLastRow -= (pRow->Frm().*fnRect->fnGetHeight)();
1082cdf0e10cSrcweir 		pRow = static_cast<SwRowFrm*>(pRow->GetNext());
1083cdf0e10cSrcweir     }
1084cdf0e10cSrcweir 
1085cdf0e10cSrcweir     //
1086cdf0e10cSrcweir     // bSplitRowAllowed: Row may be split according to its attributes.
1087cdf0e10cSrcweir     // bTryToSplit:      Row will never be split if bTryToSplit = false.
1088cdf0e10cSrcweir     //                   This can either be passed as a parameter, indicating
1089cdf0e10cSrcweir     //                   that we are currently doing the second try to split the
1090cdf0e10cSrcweir     //                   table, or it will be set to falseunder certain
1091cdf0e10cSrcweir     //                   conditions that are not suitable for splitting
1092cdf0e10cSrcweir     //                   the row.
1093cdf0e10cSrcweir     //
1094cdf0e10cSrcweir     bool bSplitRowAllowed = pRow->IsRowSplitAllowed();
1095cdf0e10cSrcweir 
1096cdf0e10cSrcweir     // --> FME 2004-06-03 #i29438#
1097cdf0e10cSrcweir     // --> OD 2004-10-04 #i26945# - Floating screen objects no longer forbid
1098cdf0e10cSrcweir     // a splitting of the table row.
1099cdf0e10cSrcweir     // Special DoNotSplit case 1:
1100cdf0e10cSrcweir     // Search for sections inside pRow:
1101cdf0e10cSrcweir     //
1102cdf0e10cSrcweir     if ( lcl_FindSectionsInRow( *pRow ) )
1103cdf0e10cSrcweir     {
1104cdf0e10cSrcweir         bTryToSplit = false;
1105cdf0e10cSrcweir     }
1106cdf0e10cSrcweir     // <--
1107cdf0e10cSrcweir 
1108cdf0e10cSrcweir     // --> FME 2004-06-07 #i29771#
1109cdf0e10cSrcweir     // To avoid loops, we do some checks before actually trying to split
1110cdf0e10cSrcweir     // the row. Maybe we should keep the next row in this table.
1111cdf0e10cSrcweir     // Note: This is only done if we are at the beginning of our upper
1112cdf0e10cSrcweir     bool bKeepNextRow = false;
1113cdf0e10cSrcweir     if ( nRowCount < nRepeat )
1114cdf0e10cSrcweir     {
1115cdf0e10cSrcweir         //
1116cdf0e10cSrcweir         // First case: One of the repeated headline does not fit to the page anymore.
1117cdf0e10cSrcweir         // At least one more non-heading row has to stay in this table in
1118cdf0e10cSrcweir         // order to avoid loops:
1119cdf0e10cSrcweir         //
1120cdf0e10cSrcweir         ASSERT( !GetIndPrev(), "Table is supposed to be at beginning" )
1121cdf0e10cSrcweir         bKeepNextRow = true;
1122cdf0e10cSrcweir     }
1123cdf0e10cSrcweir     else if ( !GetIndPrev() && nRepeat == nRowCount )
1124cdf0e10cSrcweir     {
1125cdf0e10cSrcweir         //
1126cdf0e10cSrcweir         // Second case: The first non-headline row does not fit to the page.
1127cdf0e10cSrcweir         // If it is not allowed to be split, or it contains a sub-row that
1128cdf0e10cSrcweir         // is not allowed to be split, we keep the row in this table:
1129cdf0e10cSrcweir         //
1130cdf0e10cSrcweir         if ( bTryToSplit && bSplitRowAllowed )
1131cdf0e10cSrcweir         {
1132cdf0e10cSrcweir             // Check if there are (first) rows inside this row,
1133cdf0e10cSrcweir             // which are not allowed to be split.
1134cdf0e10cSrcweir             SwCellFrm* pLowerCell = pRow ? (SwCellFrm*)pRow->Lower() : 0;
1135cdf0e10cSrcweir             while ( pLowerCell )
1136cdf0e10cSrcweir             {
1137cdf0e10cSrcweir                 if ( pLowerCell->Lower() && pLowerCell->Lower()->IsRowFrm() )
1138cdf0e10cSrcweir                 {
1139cdf0e10cSrcweir                     const SwRowFrm* pLowerRow = (SwRowFrm*)pLowerCell->Lower();
1140cdf0e10cSrcweir                     if ( !pLowerRow->IsRowSplitAllowed() &&
1141cdf0e10cSrcweir                         (pLowerRow->Frm().*fnRect->fnGetHeight)() >
1142cdf0e10cSrcweir                         nRemainingSpaceForLastRow )
1143cdf0e10cSrcweir                     {
1144cdf0e10cSrcweir                         bKeepNextRow = true;
1145cdf0e10cSrcweir                         break;
1146cdf0e10cSrcweir                     }
1147cdf0e10cSrcweir                 }
1148cdf0e10cSrcweir                 pLowerCell = (SwCellFrm*)pLowerCell->GetNext();
1149cdf0e10cSrcweir             }
1150cdf0e10cSrcweir         }
1151cdf0e10cSrcweir         else
1152cdf0e10cSrcweir             bKeepNextRow = true;
1153cdf0e10cSrcweir     }
1154cdf0e10cSrcweir 
1155cdf0e10cSrcweir     //
1156cdf0e10cSrcweir     // Better keep the next row in this table:
1157cdf0e10cSrcweir     //
1158cdf0e10cSrcweir     if ( bKeepNextRow )
1159cdf0e10cSrcweir     {
1160cdf0e10cSrcweir         pRow = GetFirstNonHeadlineRow();
1161cdf0e10cSrcweir 		if( pRow && pRow->IsRowSpanLine() && 0 == (pRow->Frm().*fnRect->fnGetHeight)() )
1162cdf0e10cSrcweir             pRow = static_cast<SwRowFrm*>(pRow->GetNext());
1163cdf0e10cSrcweir         if ( pRow )
1164cdf0e10cSrcweir         {
1165cdf0e10cSrcweir             pRow = static_cast<SwRowFrm*>(pRow->GetNext());
1166cdf0e10cSrcweir             ++nRowCount;
1167cdf0e10cSrcweir         }
1168cdf0e10cSrcweir     }
1169cdf0e10cSrcweir 
1170cdf0e10cSrcweir     //
1171cdf0e10cSrcweir     // No more row to split or to move to follow table:
1172cdf0e10cSrcweir     //
1173cdf0e10cSrcweir     if ( !pRow )
1174cdf0e10cSrcweir         return bRet;
1175cdf0e10cSrcweir 
1176cdf0e10cSrcweir     //
1177cdf0e10cSrcweir     // We try to split the row if
1178cdf0e10cSrcweir     // - the attributes of the row are set accordingly and
1179cdf0e10cSrcweir     // - we are allowed to do so
1180cdf0e10cSrcweir     // - the it should not keep with the next row
1181cdf0e10cSrcweir     //
1182cdf0e10cSrcweir     bSplitRowAllowed = bSplitRowAllowed && bTryToSplit &&
1183cdf0e10cSrcweir                        ( !bTableRowKeep ||
1184cdf0e10cSrcweir                          !pRow->ShouldRowKeepWithNext() );
1185cdf0e10cSrcweir 
1186cdf0e10cSrcweir     // Adjust pRow according to the keep-with-next attribute:
1187cdf0e10cSrcweir     if ( !bSplitRowAllowed && bTableRowKeep )
1188cdf0e10cSrcweir     {
1189cdf0e10cSrcweir         SwRowFrm* pTmpRow = static_cast<SwRowFrm*>(pRow->GetPrev());
1190cdf0e10cSrcweir         SwRowFrm* pOldRow = pRow;
1191cdf0e10cSrcweir         while ( pTmpRow && pTmpRow->ShouldRowKeepWithNext() &&
1192cdf0e10cSrcweir                 nRowCount > nRepeat )
1193cdf0e10cSrcweir         {
1194cdf0e10cSrcweir             pRow = pTmpRow;
1195cdf0e10cSrcweir             --nRowCount;
1196cdf0e10cSrcweir             pTmpRow = static_cast<SwRowFrm*>(pTmpRow->GetPrev());
1197cdf0e10cSrcweir         }
1198cdf0e10cSrcweir 
1199cdf0e10cSrcweir         // loop prevention
1200cdf0e10cSrcweir         if ( nRowCount == nRepeat && !GetIndPrev())
1201cdf0e10cSrcweir         {
1202cdf0e10cSrcweir             pRow = pOldRow;
1203cdf0e10cSrcweir         }
1204cdf0e10cSrcweir     }
1205cdf0e10cSrcweir 
1206cdf0e10cSrcweir     //
1207cdf0e10cSrcweir     // If we do not indent to split pRow, we check if we are
1208cdf0e10cSrcweir     // allowed to move pRow to a follow. Otherwise we return
1209cdf0e10cSrcweir     // false, indicating an error
1210cdf0e10cSrcweir     //
1211cdf0e10cSrcweir     if ( !bSplitRowAllowed )
1212cdf0e10cSrcweir     {
1213cdf0e10cSrcweir         SwRowFrm* pFirstNonHeadlineRow = GetFirstNonHeadlineRow();
1214cdf0e10cSrcweir         if ( pRow == pFirstNonHeadlineRow )
1215cdf0e10cSrcweir             return false;
1216cdf0e10cSrcweir 
1217cdf0e10cSrcweir         // --> OD 2008-10-21 #i91764#
1218cdf0e10cSrcweir         // Ignore row span lines
1219cdf0e10cSrcweir         SwRowFrm* pTmpRow = pFirstNonHeadlineRow;
1220cdf0e10cSrcweir         while ( pTmpRow && pTmpRow->IsRowSpanLine() )
1221cdf0e10cSrcweir         {
1222cdf0e10cSrcweir             pTmpRow = static_cast<SwRowFrm*>(pTmpRow->GetNext());
1223cdf0e10cSrcweir         }
1224cdf0e10cSrcweir         if ( !pTmpRow || pRow == pTmpRow )
1225cdf0e10cSrcweir         {
1226cdf0e10cSrcweir             return false;
1227cdf0e10cSrcweir         }
1228cdf0e10cSrcweir         // <--
1229cdf0e10cSrcweir     }
1230cdf0e10cSrcweir 
1231cdf0e10cSrcweir     //
1232cdf0e10cSrcweir     // Build follow table if not already done:
1233cdf0e10cSrcweir     //
1234cdf0e10cSrcweir     sal_Bool bNewFollow;
1235cdf0e10cSrcweir 	SwTabFrm *pFoll;
1236cdf0e10cSrcweir 	if ( GetFollow() )
1237cdf0e10cSrcweir 	{
1238cdf0e10cSrcweir         pFoll = GetFollow();
1239cdf0e10cSrcweir 		bNewFollow = sal_False;
1240cdf0e10cSrcweir 	}
1241cdf0e10cSrcweir 	else
1242cdf0e10cSrcweir 	{
1243cdf0e10cSrcweir         bNewFollow = sal_True;
1244cdf0e10cSrcweir 		pFoll = new SwTabFrm( *this );
1245cdf0e10cSrcweir 
1246cdf0e10cSrcweir         //
1247cdf0e10cSrcweir         // We give the follow table an initial width.
1248cdf0e10cSrcweir         //
1249cdf0e10cSrcweir         (pFoll->Frm().*fnRect->fnAddWidth)( (Frm().*fnRect->fnGetWidth)() );
1250cdf0e10cSrcweir         (pFoll->Prt().*fnRect->fnAddWidth)( (Prt().*fnRect->fnGetWidth)() );
1251cdf0e10cSrcweir         (pFoll->Frm().*fnRect->fnSetLeft)( (Frm().*fnRect->fnGetLeft)() );
1252cdf0e10cSrcweir 
1253cdf0e10cSrcweir         //
1254cdf0e10cSrcweir         // Insert the new follow table
1255cdf0e10cSrcweir         //
1256cdf0e10cSrcweir         pFoll->InsertBehind( GetUpper(), this );
1257cdf0e10cSrcweir 
1258cdf0e10cSrcweir         //
1259cdf0e10cSrcweir         // Repeat the headlines.
1260cdf0e10cSrcweir         //
1261cdf0e10cSrcweir         for ( nRowCount = 0; nRowCount < nRepeat; ++nRowCount )
1262cdf0e10cSrcweir         {
1263cdf0e10cSrcweir             // Insert new headlines:
1264cdf0e10cSrcweir             bDontCreateObjects = sal_True;              //frmtool
1265cdf0e10cSrcweir             SwRowFrm* pHeadline = new SwRowFrm(
1266cdf0e10cSrcweir                                     *GetTable()->GetTabLines()[ nRowCount ], this );
1267cdf0e10cSrcweir             pHeadline->SetRepeatedHeadline( true );
1268cdf0e10cSrcweir             bDontCreateObjects = sal_False;
1269cdf0e10cSrcweir             pHeadline->InsertBefore( pFoll, 0 );
1270cdf0e10cSrcweir 
1271cdf0e10cSrcweir 			SwPageFrm *pPage = pHeadline->FindPageFrm();
1272cdf0e10cSrcweir 			const SwSpzFrmFmts *pTbl = GetFmt()->GetDoc()->GetSpzFrmFmts();
1273cdf0e10cSrcweir 			if( pTbl->Count() )
1274cdf0e10cSrcweir 			{
1275cdf0e10cSrcweir 				sal_uLong nIndex;
1276cdf0e10cSrcweir 				SwCntntFrm* pFrm = pHeadline->ContainsCntnt();
1277cdf0e10cSrcweir 				while( pFrm )
1278cdf0e10cSrcweir 				{
1279cdf0e10cSrcweir 					nIndex = pFrm->GetNode()->GetIndex();
1280cdf0e10cSrcweir 					AppendObjs( pTbl, nIndex, pFrm, pPage );
1281cdf0e10cSrcweir 					pFrm = pFrm->GetNextCntntFrm();
1282cdf0e10cSrcweir 					if( !pHeadline->IsAnLower( pFrm ) )
1283cdf0e10cSrcweir 						break;
1284cdf0e10cSrcweir 				}
1285cdf0e10cSrcweir 			}
1286cdf0e10cSrcweir         }
1287cdf0e10cSrcweir     }
1288cdf0e10cSrcweir 
1289cdf0e10cSrcweir     SwRowFrm* pLastRow = 0;     // will point to the last remaining line in master
1290cdf0e10cSrcweir     SwRowFrm* pFollowRow = 0;   // points to either the follow flow line of the
1291cdf0e10cSrcweir                                 // first regular line in the follow
1292cdf0e10cSrcweir 
1293cdf0e10cSrcweir     if ( bSplitRowAllowed )
1294cdf0e10cSrcweir     {
1295cdf0e10cSrcweir         // If the row that does not fit anymore is allowed
1296cdf0e10cSrcweir         // to be split, the next row has to be moved to the follow table.
1297cdf0e10cSrcweir         pLastRow = pRow;
1298cdf0e10cSrcweir         pRow = static_cast<SwRowFrm*>(pRow->GetNext());
1299cdf0e10cSrcweir 
1300cdf0e10cSrcweir         // new follow flow line for last row of master table
1301cdf0e10cSrcweir         pFollowRow = lcl_InsertNewFollowFlowLine( *this, *pLastRow, false );
1302cdf0e10cSrcweir     }
1303cdf0e10cSrcweir     else
1304cdf0e10cSrcweir     {
1305cdf0e10cSrcweir         pFollowRow = pRow;
1306cdf0e10cSrcweir 
1307cdf0e10cSrcweir         // NEW TABLES
1308cdf0e10cSrcweir         // check if we will break a row span by moving pFollowRow to the follow:
1309cdf0e10cSrcweir         // In this case we want to reformat the last line.
1310cdf0e10cSrcweir         const SwCellFrm* pCellFrm = static_cast<const SwCellFrm*>(pFollowRow->GetLower());
1311cdf0e10cSrcweir         while ( pCellFrm )
1312cdf0e10cSrcweir         {
1313cdf0e10cSrcweir             if ( pCellFrm->GetTabBox()->getRowSpan() < 1 )
1314cdf0e10cSrcweir             {
1315cdf0e10cSrcweir                 pLastRow = static_cast<SwRowFrm*>(pRow->GetPrev());
1316cdf0e10cSrcweir                 break;
1317cdf0e10cSrcweir             }
1318cdf0e10cSrcweir 
1319cdf0e10cSrcweir             pCellFrm = static_cast<const SwCellFrm*>(pCellFrm->GetNext());
1320cdf0e10cSrcweir         }
1321cdf0e10cSrcweir 
1322cdf0e10cSrcweir         // new follow flow line for last row of master table
1323cdf0e10cSrcweir         if ( pLastRow )
1324cdf0e10cSrcweir             pFollowRow = lcl_InsertNewFollowFlowLine( *this, *pLastRow, true );
1325cdf0e10cSrcweir     }
1326cdf0e10cSrcweir 
1327cdf0e10cSrcweir     SwTwips nRet = 0;
1328cdf0e10cSrcweir 
1329cdf0e10cSrcweir 	//Optimierung beim neuen Follow braucht's kein Paste und dann kann
1330cdf0e10cSrcweir 	//das Optimierte Insert verwendet werden (nur dann treten gluecklicher weise
1331cdf0e10cSrcweir 	//auch groessere Mengen von Rows auf).
1332cdf0e10cSrcweir 	if ( bNewFollow )
1333cdf0e10cSrcweir 	{
1334cdf0e10cSrcweir         SwFrm* pNxt = 0;
1335cdf0e10cSrcweir         SwFrm* pInsertBehind = pFoll->GetLastLower();
1336cdf0e10cSrcweir 
1337cdf0e10cSrcweir         while ( pRow )
1338cdf0e10cSrcweir 		{
1339cdf0e10cSrcweir 			pNxt = pRow->GetNext();
1340cdf0e10cSrcweir             nRet += (pRow->Frm().*fnRect->fnGetHeight)();
1341cdf0e10cSrcweir             // The footnotes do not have to be moved, this is done in the
1342cdf0e10cSrcweir             // MoveFwd of the follow table!!!
1343cdf0e10cSrcweir             pRow->Remove();
1344cdf0e10cSrcweir             pRow->InsertBehind( pFoll, pInsertBehind );
1345cdf0e10cSrcweir 			pRow->_InvalidateAll();
1346cdf0e10cSrcweir 			pInsertBehind = pRow;
1347cdf0e10cSrcweir 			pRow = static_cast<SwRowFrm*>(pNxt);
1348cdf0e10cSrcweir 		}
1349cdf0e10cSrcweir     }
1350cdf0e10cSrcweir 	else
1351cdf0e10cSrcweir 	{
1352cdf0e10cSrcweir         SwFrm* pNxt = 0;
1353cdf0e10cSrcweir         SwFrm* pPasteBefore = HasFollowFlowLine() ?
1354cdf0e10cSrcweir                               pFollowRow->GetNext() :
1355cdf0e10cSrcweir                               pFoll->GetFirstNonHeadlineRow();
1356cdf0e10cSrcweir 
1357cdf0e10cSrcweir         while ( pRow )
1358cdf0e10cSrcweir 		{
1359cdf0e10cSrcweir 			pNxt = pRow->GetNext();
1360cdf0e10cSrcweir             nRet += (pRow->Frm().*fnRect->fnGetHeight)();
1361cdf0e10cSrcweir 
1362cdf0e10cSrcweir             // The footnotes have to be moved:
1363cdf0e10cSrcweir             lcl_MoveFootnotes( *this, *GetFollow(), *pRow );
1364cdf0e10cSrcweir 
1365cdf0e10cSrcweir             pRow->Remove();
1366cdf0e10cSrcweir 			pRow->Paste( pFoll, pPasteBefore );
1367cdf0e10cSrcweir 
1368cdf0e10cSrcweir             pRow->CheckDirChange();
1369cdf0e10cSrcweir 			pRow = static_cast<SwRowFrm*>(pNxt);
1370cdf0e10cSrcweir 		}
1371cdf0e10cSrcweir     }
1372cdf0e10cSrcweir 
1373cdf0e10cSrcweir     Shrink( nRet );
1374cdf0e10cSrcweir 
1375cdf0e10cSrcweir     // we rebuild the last line to assure that it will be fully formatted
1376cdf0e10cSrcweir     if ( pLastRow )
1377cdf0e10cSrcweir     {
1378cdf0e10cSrcweir         // recalculate the split line
1379cdf0e10cSrcweir         bRet = lcl_RecalcSplitLine( *pLastRow, *pFollowRow, nRemainingSpaceForLastRow );
1380cdf0e10cSrcweir 
1381cdf0e10cSrcweir         // NEW TABLES
1382cdf0e10cSrcweir         // check if each cell in the row span line has a good height
1383cdf0e10cSrcweir         if ( bRet && pFollowRow->IsRowSpanLine() )
1384cdf0e10cSrcweir             lcl_AdjustRowSpanCells( pFollowRow );
1385cdf0e10cSrcweir 
1386cdf0e10cSrcweir         // We The RowSplitLine stuff did not work. In this case we conceal the split error:
1387cdf0e10cSrcweir         if ( !bRet && !bSplitRowAllowed )
1388cdf0e10cSrcweir         {
1389cdf0e10cSrcweir             bRet = true;
1390cdf0e10cSrcweir         }
1391cdf0e10cSrcweir     }
1392cdf0e10cSrcweir 
1393cdf0e10cSrcweir     return bRet;
1394cdf0e10cSrcweir }
1395cdf0e10cSrcweir 
Join()1396cdf0e10cSrcweir bool SwTabFrm::Join()
1397cdf0e10cSrcweir {
1398cdf0e10cSrcweir     ASSERT( !HasFollowFlowLine(), "Joining follow flow line" )
1399cdf0e10cSrcweir 
1400cdf0e10cSrcweir     SwTabFrm *pFoll = GetFollow();
1401cdf0e10cSrcweir 	SwTwips nHeight = 0;	//Gesamthoehe der eingefuegten Zeilen als Return.
1402cdf0e10cSrcweir 
1403cdf0e10cSrcweir 	if ( !pFoll->IsJoinLocked() )
1404cdf0e10cSrcweir 	{
1405cdf0e10cSrcweir         SWRECTFN( this )
1406cdf0e10cSrcweir 		pFoll->Cut();	//Erst ausschneiden um unuetze Benachrichtigungen zu
1407cdf0e10cSrcweir 						//minimieren.
1408cdf0e10cSrcweir 
1409cdf0e10cSrcweir         SwFrm *pRow = pFoll->GetFirstNonHeadlineRow(),
1410cdf0e10cSrcweir 			  *pNxt;
1411cdf0e10cSrcweir 
1412cdf0e10cSrcweir         SwFrm* pPrv = GetLastLower();
1413cdf0e10cSrcweir 
1414cdf0e10cSrcweir 		while ( pRow )
1415cdf0e10cSrcweir 		{
1416cdf0e10cSrcweir 			pNxt = pRow->GetNext();
1417cdf0e10cSrcweir             nHeight += (pRow->Frm().*fnRect->fnGetHeight)();
1418cdf0e10cSrcweir 			pRow->Remove();
1419cdf0e10cSrcweir 			pRow->_InvalidateAll();
1420cdf0e10cSrcweir 			pRow->InsertBehind( this, pPrv );
1421cdf0e10cSrcweir             pRow->CheckDirChange();
1422cdf0e10cSrcweir 			pPrv = pRow;
1423cdf0e10cSrcweir 			pRow = pNxt;
1424cdf0e10cSrcweir 		}
1425cdf0e10cSrcweir 
1426cdf0e10cSrcweir 		SetFollow( pFoll->GetFollow() );
1427cdf0e10cSrcweir         SetFollowFlowLine( pFoll->HasFollowFlowLine() );
1428cdf0e10cSrcweir         delete pFoll;
1429cdf0e10cSrcweir 
1430cdf0e10cSrcweir         Grow( nHeight );
1431cdf0e10cSrcweir 	}
1432cdf0e10cSrcweir 
1433cdf0e10cSrcweir     return true;
1434cdf0e10cSrcweir }
1435cdf0e10cSrcweir 
1436cdf0e10cSrcweir /*************************************************************************
1437cdf0e10cSrcweir |*
1438cdf0e10cSrcweir |*	SwTabFrm::MakeAll()
1439cdf0e10cSrcweir |*
1440cdf0e10cSrcweir |*	Ersterstellung		MA 09. Mar. 93
1441cdf0e10cSrcweir |*	Letzte Aenderung	MA 10. Apr. 97
1442cdf0e10cSrcweir |*
1443cdf0e10cSrcweir |*************************************************************************/
SwInvalidatePositions(SwFrm * pFrm,long nBottom)1444cdf0e10cSrcweir void MA_FASTCALL SwInvalidatePositions( SwFrm *pFrm, long nBottom )
1445cdf0e10cSrcweir {
1446cdf0e10cSrcweir     // LONG_MAX == nBottom means we have to calculate all
1447cdf0e10cSrcweir     sal_Bool bAll = LONG_MAX == nBottom;
1448cdf0e10cSrcweir     SWRECTFN( pFrm )
1449cdf0e10cSrcweir 	do
1450cdf0e10cSrcweir 	{	pFrm->_InvalidatePos();
1451cdf0e10cSrcweir 		pFrm->_InvalidateSize();
1452cdf0e10cSrcweir 		if( pFrm->IsLayoutFrm() )
1453cdf0e10cSrcweir 		{
1454cdf0e10cSrcweir 			if ( ((SwLayoutFrm*)pFrm)->Lower() )
1455cdf0e10cSrcweir             {
1456cdf0e10cSrcweir 				::SwInvalidatePositions( ((SwLayoutFrm*)pFrm)->Lower(), nBottom);
1457cdf0e10cSrcweir                 // --> OD 2004-11-05 #i26945#
1458cdf0e10cSrcweir                 ::lcl_InvalidateLowerObjs( *(static_cast<SwLayoutFrm*>(pFrm)) );
1459cdf0e10cSrcweir                 // <--
1460cdf0e10cSrcweir             }
1461cdf0e10cSrcweir 		}
1462cdf0e10cSrcweir 		else
1463cdf0e10cSrcweir 			pFrm->Prepare( PREP_ADJUST_FRM );
1464cdf0e10cSrcweir 		pFrm = pFrm->GetNext();
1465cdf0e10cSrcweir     } while ( pFrm &&
1466cdf0e10cSrcweir               ( bAll ||
1467cdf0e10cSrcweir               (*fnRect->fnYDiff)( (pFrm->Frm().*fnRect->fnGetTop)(), nBottom ) < 0 ) );
1468cdf0e10cSrcweir }
1469cdf0e10cSrcweir 
SwInvalidateAll(SwFrm * pFrm,long nBottom)1470cdf0e10cSrcweir void MA_FASTCALL SwInvalidateAll( SwFrm *pFrm, long nBottom )
1471cdf0e10cSrcweir {
1472cdf0e10cSrcweir     // LONG_MAX == nBottom means we have to calculate all
1473cdf0e10cSrcweir     sal_Bool bAll = LONG_MAX == nBottom;
1474cdf0e10cSrcweir     SWRECTFN( pFrm )
1475cdf0e10cSrcweir 	do
1476cdf0e10cSrcweir 	{
1477cdf0e10cSrcweir         pFrm->_InvalidatePos();
1478cdf0e10cSrcweir 		pFrm->_InvalidateSize();
1479cdf0e10cSrcweir 		pFrm->_InvalidatePrt();
1480cdf0e10cSrcweir 		if( pFrm->IsLayoutFrm() )
1481cdf0e10cSrcweir 		{
1482cdf0e10cSrcweir             // NEW TABLES
1483cdf0e10cSrcweir             SwLayoutFrm* pToInvalidate = static_cast<SwLayoutFrm*>(pFrm);
1484cdf0e10cSrcweir             SwCellFrm* pThisCell = dynamic_cast<SwCellFrm*>(pFrm);
1485cdf0e10cSrcweir             if ( pThisCell && pThisCell->GetTabBox()->getRowSpan() < 1 )
1486cdf0e10cSrcweir             {
1487cdf0e10cSrcweir                 pToInvalidate = & const_cast<SwCellFrm&>(pThisCell->FindStartEndOfRowSpanCell( true, true ));
1488cdf0e10cSrcweir 	            pToInvalidate->_InvalidatePos();
1489cdf0e10cSrcweir 		        pToInvalidate->_InvalidateSize();
1490cdf0e10cSrcweir 		        pToInvalidate->_InvalidatePrt();
1491cdf0e10cSrcweir             }
1492cdf0e10cSrcweir 
1493cdf0e10cSrcweir             if ( pToInvalidate->Lower() )
1494cdf0e10cSrcweir                 ::SwInvalidateAll( pToInvalidate->Lower(), nBottom);
1495cdf0e10cSrcweir         }
1496cdf0e10cSrcweir 		else
1497cdf0e10cSrcweir 			pFrm->Prepare( PREP_CLEAR );
1498cdf0e10cSrcweir 
1499cdf0e10cSrcweir 		pFrm = pFrm->GetNext();
1500cdf0e10cSrcweir     } while ( pFrm &&
1501cdf0e10cSrcweir               ( bAll ||
1502cdf0e10cSrcweir               (*fnRect->fnYDiff)( (pFrm->Frm().*fnRect->fnGetTop)(), nBottom ) < 0 ) );
1503cdf0e10cSrcweir }
1504cdf0e10cSrcweir 
1505cdf0e10cSrcweir // --> collapsing borders FME 2005-05-27 #i29550#
lcl_InvalidateAllLowersPrt(SwLayoutFrm * pLayFrm)1506cdf0e10cSrcweir void lcl_InvalidateAllLowersPrt( SwLayoutFrm* pLayFrm )
1507cdf0e10cSrcweir {
1508cdf0e10cSrcweir     pLayFrm->_InvalidatePrt();
1509cdf0e10cSrcweir     pLayFrm->_InvalidateSize();
1510cdf0e10cSrcweir     pLayFrm->SetCompletePaint();
1511cdf0e10cSrcweir 
1512cdf0e10cSrcweir     SwFrm* pFrm = pLayFrm->Lower();
1513cdf0e10cSrcweir 
1514cdf0e10cSrcweir     while ( pFrm )
1515cdf0e10cSrcweir     {
1516cdf0e10cSrcweir         if ( pFrm->IsLayoutFrm() )
1517cdf0e10cSrcweir             lcl_InvalidateAllLowersPrt( (SwLayoutFrm*)pFrm );
1518cdf0e10cSrcweir         else
1519cdf0e10cSrcweir         {
1520cdf0e10cSrcweir             pFrm->_InvalidatePrt();
1521cdf0e10cSrcweir             pFrm->_InvalidateSize();
1522cdf0e10cSrcweir             pFrm->SetCompletePaint();
1523cdf0e10cSrcweir         }
1524cdf0e10cSrcweir 
1525cdf0e10cSrcweir         pFrm = pFrm->GetNext();
1526cdf0e10cSrcweir     }
1527cdf0e10cSrcweir }
1528cdf0e10cSrcweir // <-- collapsing
1529cdf0e10cSrcweir 
CalcLowers(SwLayoutFrm * pLay,const SwLayoutFrm * pDontLeave,long nBottom,bool bSkipRowSpanCells)1530cdf0e10cSrcweir bool SwCntntFrm::CalcLowers( SwLayoutFrm* pLay, const SwLayoutFrm* pDontLeave,
1531cdf0e10cSrcweir                                  long nBottom, bool bSkipRowSpanCells )
1532cdf0e10cSrcweir {
1533cdf0e10cSrcweir     if ( !pLay )
1534cdf0e10cSrcweir         return sal_True;
1535cdf0e10cSrcweir 
1536cdf0e10cSrcweir     // LONG_MAX == nBottom means we have to calculate all
1537cdf0e10cSrcweir     bool bAll = LONG_MAX == nBottom;
1538cdf0e10cSrcweir     bool bRet = sal_False;
1539*7b20d707SMatthias Seidel     bool bPrune;
1540cdf0e10cSrcweir 	SwCntntFrm *pCnt = pLay->ContainsCntnt();
1541cdf0e10cSrcweir     SWRECTFN( pLay )
1542cdf0e10cSrcweir 
1543cdf0e10cSrcweir     // FME 2007-08-30 #i81146# new loop control
1544cdf0e10cSrcweir     sal_uInt16 nLoopControlRuns = 0;
1545cdf0e10cSrcweir     const sal_uInt16 nLoopControlMax = 10;
1546cdf0e10cSrcweir     const SwModify* pLoopControlCond = 0;
1547cdf0e10cSrcweir 
1548cdf0e10cSrcweir     while ( pCnt && pDontLeave->IsAnLower( pCnt ) )
1549cdf0e10cSrcweir 	{
1550cdf0e10cSrcweir         // --> OD 2004-11-23 #115759# - check, if a format of content frame is
1551cdf0e10cSrcweir         // possible. Thus, 'copy' conditions, found at the beginning of
1552cdf0e10cSrcweir         // <SwCntntFrm::MakeAll(..)>, and check these.
1553cdf0e10cSrcweir         const bool bFormatPossible = !pCnt->IsJoinLocked() &&
1554cdf0e10cSrcweir                                      ( !pCnt->IsTxtFrm() ||
1555cdf0e10cSrcweir                                        !static_cast<SwTxtFrm*>(pCnt)->IsLocked() ) &&
1556cdf0e10cSrcweir                                      ( pCnt->IsFollow() || !StackHack::IsLocked() );
1557cdf0e10cSrcweir 
1558cdf0e10cSrcweir         // NEW TABLES
1559cdf0e10cSrcweir         bool bSkipContent = false;
1560cdf0e10cSrcweir         if ( bSkipRowSpanCells && pCnt->IsInTab() )
1561cdf0e10cSrcweir         {
1562cdf0e10cSrcweir             const SwFrm* pCell = pCnt->GetUpper();
1563cdf0e10cSrcweir             while ( pCell && !pCell->IsCellFrm() )
1564cdf0e10cSrcweir                 pCell = pCell->GetUpper();
1565cdf0e10cSrcweir             if ( pCell && 1 != static_cast<const SwCellFrm*>( pCell )->GetLayoutRowSpan() )
1566cdf0e10cSrcweir                 bSkipContent = true;
1567cdf0e10cSrcweir         }
1568cdf0e10cSrcweir 
1569cdf0e10cSrcweir         if ( bFormatPossible && !bSkipContent )
1570cdf0e10cSrcweir         {
1571cdf0e10cSrcweir             bRet |= !pCnt->IsValid();
1572cdf0e10cSrcweir             // --> OD 2004-10-06 #i26945# - no extra invalidation of floating
1573cdf0e10cSrcweir             // screen objects needed.
1574cdf0e10cSrcweir             // Thus, delete call of method <SwFrm::InvalidateObjs( true )>
1575cdf0e10cSrcweir             // <--
1576cdf0e10cSrcweir             pCnt->Calc();
1577cdf0e10cSrcweir             // OD 2004-05-11 #i28701# - usage of new method <::FormatObjsAtFrm(..)>
1578cdf0e10cSrcweir             // to format the floating screen objects
1579cdf0e10cSrcweir             // --> OD 2005-05-03 #i46941# - frame has to be valid
1580cdf0e10cSrcweir             // Note: frame could be invalid after calling its format, if it's locked.
1581cdf0e10cSrcweir             ASSERT( !pCnt->IsTxtFrm() ||
1582cdf0e10cSrcweir                     pCnt->IsValid() ||
1583cdf0e10cSrcweir                     static_cast<SwTxtFrm*>(pCnt)->IsJoinLocked(),
1584cdf0e10cSrcweir                     "<SwCntntFrm::CalcLowers(..)> - text frame invalid and not locked." );
1585cdf0e10cSrcweir             if ( pCnt->IsTxtFrm() && pCnt->IsValid() )
1586cdf0e10cSrcweir             {
1587cdf0e10cSrcweir                 // --> OD 2004-11-02 #i23129#, #i36347# - pass correct page frame to
1588cdf0e10cSrcweir                 // the object formatter
1589cdf0e10cSrcweir                 if ( !SwObjectFormatter::FormatObjsAtFrm( *pCnt,
1590cdf0e10cSrcweir                                                           *(pCnt->FindPageFrm()) ) )
1591cdf0e10cSrcweir                 // <--
1592cdf0e10cSrcweir                 {
1593cdf0e10cSrcweir                     if ( pCnt->GetRegisteredIn() == pLoopControlCond )
1594cdf0e10cSrcweir                         ++nLoopControlRuns;
1595cdf0e10cSrcweir                     else
1596cdf0e10cSrcweir                     {
1597cdf0e10cSrcweir                         nLoopControlRuns = 0;
1598cdf0e10cSrcweir                         pLoopControlCond = pCnt->GetRegisteredIn();
1599cdf0e10cSrcweir                     }
1600cdf0e10cSrcweir 
1601cdf0e10cSrcweir                     if ( nLoopControlRuns < nLoopControlMax )
1602cdf0e10cSrcweir                     {
1603cdf0e10cSrcweir                         // restart format with first content
1604cdf0e10cSrcweir                         pCnt = pLay->ContainsCntnt();
1605cdf0e10cSrcweir                         continue;
1606cdf0e10cSrcweir                     }
1607cdf0e10cSrcweir 
1608cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1609cdf0e10cSrcweir                     ASSERT( false, "LoopControl in SwCntntFrm::CalcLowers" )
1610cdf0e10cSrcweir #endif
1611cdf0e10cSrcweir                 }
1612cdf0e10cSrcweir             }
1613cdf0e10cSrcweir             pCnt->GetUpper()->Calc();
1614cdf0e10cSrcweir         }
1615cdf0e10cSrcweir         // <--
1616*7b20d707SMatthias Seidel         bPrune = !bAll && ( (*fnRect->fnYDiff)((pCnt->Frm().*fnRect->fnGetTop)(), nBottom) > 0 );
1617*7b20d707SMatthias Seidel 		pCnt = pCnt->GetNextCntntFrm( bPrune );
1618cdf0e10cSrcweir 	}
1619cdf0e10cSrcweir 	return bRet;
1620cdf0e10cSrcweir }
1621cdf0e10cSrcweir 
1622cdf0e10cSrcweir // --> OD 2004-10-15 #i26945# - add parameter <_bOnlyRowsAndCells> to control
1623cdf0e10cSrcweir // that only row and cell frames are formatted.
lcl_InnerCalcLayout(SwFrm * pFrm,long nBottom,bool _bOnlyRowsAndCells)1624cdf0e10cSrcweir sal_Bool MA_FASTCALL lcl_InnerCalcLayout( SwFrm *pFrm,
1625cdf0e10cSrcweir                                       long nBottom,
1626cdf0e10cSrcweir                                       bool _bOnlyRowsAndCells )
1627cdf0e10cSrcweir {
1628cdf0e10cSrcweir     // LONG_MAX == nBottom means we have to calculate all
1629cdf0e10cSrcweir     sal_Bool bAll = LONG_MAX == nBottom;
1630cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1631cdf0e10cSrcweir     const SwFrm* pOldUp = pFrm->GetUpper();
1632cdf0e10cSrcweir     SWRECTFN( pFrm )
1633cdf0e10cSrcweir 	do
1634cdf0e10cSrcweir 	{
1635cdf0e10cSrcweir         // --> OD 2004-10-15 #i26945# - parameter <_bOnlyRowsAndCells> controls,
1636cdf0e10cSrcweir         // if only row and cell frames are formatted.
1637cdf0e10cSrcweir         if ( pFrm->IsLayoutFrm() &&
1638cdf0e10cSrcweir              ( !_bOnlyRowsAndCells || pFrm->IsRowFrm() || pFrm->IsCellFrm() ) )
1639cdf0e10cSrcweir         // <--
1640cdf0e10cSrcweir 		{
1641cdf0e10cSrcweir             // --> FME 2006-02-23 #130744# An invalid locked table frame will
1642cdf0e10cSrcweir             // not be calculated => It will not become valid =>
1643cdf0e10cSrcweir             // Loop in lcl_RecalcRow(). Therefore we do not consider them for bRet.
1644cdf0e10cSrcweir             bRet |= !pFrm->IsValid() && ( !pFrm->IsTabFrm() || !static_cast<SwTabFrm*>(pFrm)->IsJoinLocked() );
1645cdf0e10cSrcweir             // <--
1646cdf0e10cSrcweir             pFrm->Calc();
1647cdf0e10cSrcweir             if( static_cast<SwLayoutFrm*>(pFrm)->Lower() )
1648cdf0e10cSrcweir                 bRet |= lcl_InnerCalcLayout( static_cast<SwLayoutFrm*>(pFrm)->Lower(), nBottom);
1649cdf0e10cSrcweir 
1650cdf0e10cSrcweir             // NEW TABLES
1651cdf0e10cSrcweir             SwCellFrm* pThisCell = dynamic_cast<SwCellFrm*>(pFrm);
1652cdf0e10cSrcweir             if ( pThisCell && pThisCell->GetTabBox()->getRowSpan() < 1 )
1653cdf0e10cSrcweir             {
1654cdf0e10cSrcweir                 SwCellFrm& rToCalc = const_cast<SwCellFrm&>(pThisCell->FindStartEndOfRowSpanCell( true, true ));
1655cdf0e10cSrcweir                 bRet |= !rToCalc.IsValid();
1656cdf0e10cSrcweir                 rToCalc.Calc();
1657cdf0e10cSrcweir                 if ( rToCalc.Lower() )
1658cdf0e10cSrcweir                     bRet |= lcl_InnerCalcLayout( rToCalc.Lower(), nBottom);
1659cdf0e10cSrcweir             }
1660cdf0e10cSrcweir 		}
1661cdf0e10cSrcweir 		pFrm = pFrm->GetNext();
1662cdf0e10cSrcweir     } while( pFrm &&
1663cdf0e10cSrcweir             ( bAll ||
1664cdf0e10cSrcweir               (*fnRect->fnYDiff)((pFrm->Frm().*fnRect->fnGetTop)(), nBottom) < 0 )
1665cdf0e10cSrcweir             && pFrm->GetUpper() == pOldUp );
1666cdf0e10cSrcweir 	return bRet;
1667cdf0e10cSrcweir }
1668cdf0e10cSrcweir 
lcl_RecalcRow(SwRowFrm & rRow,long nBottom)1669cdf0e10cSrcweir void MA_FASTCALL lcl_RecalcRow( SwRowFrm& rRow, long nBottom )
1670cdf0e10cSrcweir {
1671cdf0e10cSrcweir     // --> OD 2004-10-05 #i26945# - For correct appliance of the 'straightforward
1672cdf0e10cSrcweir     // object positioning process, it's needed to notify that the page frame,
1673cdf0e10cSrcweir     // on which the given layout frame is in, is in its layout process.
1674cdf0e10cSrcweir     SwPageFrm* pPageFrm = rRow.FindPageFrm();
1675cdf0e10cSrcweir     if ( pPageFrm && !pPageFrm->IsLayoutInProgress() )
1676cdf0e10cSrcweir         pPageFrm->SetLayoutInProgress( true );
1677cdf0e10cSrcweir     else
1678cdf0e10cSrcweir         pPageFrm = 0L;
1679cdf0e10cSrcweir     // <--
1680cdf0e10cSrcweir 
1681cdf0e10cSrcweir     // FME 2007-08-30 #i81146# new loop control
1682cdf0e10cSrcweir     sal_uInt16 nLoopControlRuns_1 = 0;
1683cdf0e10cSrcweir     sal_uInt16 nLoopControlStage_1 = 0;
1684cdf0e10cSrcweir     const sal_uInt16 nLoopControlMax = 10;
1685cdf0e10cSrcweir 
1686cdf0e10cSrcweir     bool bCheck = true;
1687cdf0e10cSrcweir     do
1688cdf0e10cSrcweir     {
1689cdf0e10cSrcweir         // FME 2007-08-30 #i81146# new loop control
1690cdf0e10cSrcweir         sal_uInt16 nLoopControlRuns_2 = 0;
1691cdf0e10cSrcweir         sal_uInt16 nLoopControlStage_2 = 0;
1692cdf0e10cSrcweir 
1693cdf0e10cSrcweir         while( lcl_InnerCalcLayout( &rRow, nBottom ) )
1694cdf0e10cSrcweir         {
1695cdf0e10cSrcweir             if ( ++nLoopControlRuns_2 > nLoopControlMax )
1696cdf0e10cSrcweir             {
1697cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1698cdf0e10cSrcweir                 ASSERT( 0 != nLoopControlStage_2, "LoopControl_2 in lcl_RecalcRow: Stage 1!" );
1699cdf0e10cSrcweir                 ASSERT( 1 != nLoopControlStage_2, "LoopControl_2 in lcl_RecalcRow: Stage 2!!" );
1700cdf0e10cSrcweir                 ASSERT( 2 >  nLoopControlStage_2, "LoopControl_2 in lcl_RecalcRow: Stage 3!!!" );
1701cdf0e10cSrcweir #endif
1702cdf0e10cSrcweir                 rRow.ValidateThisAndAllLowers( nLoopControlStage_2++ );
1703cdf0e10cSrcweir                 nLoopControlRuns_2 = 0;
1704cdf0e10cSrcweir                 if( nLoopControlStage_2 > 2 )
1705cdf0e10cSrcweir                     break;
1706cdf0e10cSrcweir             }
1707cdf0e10cSrcweir 
1708cdf0e10cSrcweir             bCheck = true;
1709cdf0e10cSrcweir         }
1710cdf0e10cSrcweir 
1711cdf0e10cSrcweir         if( bCheck )
1712cdf0e10cSrcweir         {
1713cdf0e10cSrcweir             // --> OD 2004-11-23 #115759# - force another format of the
1714cdf0e10cSrcweir             // lowers, if at least one of it was invalid.
1715cdf0e10cSrcweir             bCheck = SwCntntFrm::CalcLowers( &rRow, rRow.GetUpper(), nBottom, true );
1716cdf0e10cSrcweir             // <--
1717cdf0e10cSrcweir 
1718cdf0e10cSrcweir             // NEW TABLES
1719cdf0e10cSrcweir             // First we calculate the cells with row span of < 1, afterwards
1720cdf0e10cSrcweir             // all cells with row span of > 1:
1721cdf0e10cSrcweir             for ( int i = 0; i < 2; ++i )
1722cdf0e10cSrcweir             {
1723cdf0e10cSrcweir                 SwCellFrm* pCellFrm = static_cast<SwCellFrm*>(rRow.Lower());
1724cdf0e10cSrcweir                 while ( pCellFrm )
1725cdf0e10cSrcweir                 {
1726cdf0e10cSrcweir                     const bool bCalc = 0 == i ?
1727cdf0e10cSrcweir                                        pCellFrm->GetLayoutRowSpan() < 1 :
1728cdf0e10cSrcweir                                        pCellFrm->GetLayoutRowSpan() > 1;
1729cdf0e10cSrcweir 
1730cdf0e10cSrcweir                     if ( bCalc )
1731cdf0e10cSrcweir                     {
1732cdf0e10cSrcweir                         SwCellFrm& rToRecalc = 0 == i ?
1733cdf0e10cSrcweir                                                const_cast<SwCellFrm&>(pCellFrm->FindStartEndOfRowSpanCell( true, true )) :
1734cdf0e10cSrcweir                                                *pCellFrm;
1735cdf0e10cSrcweir                         bCheck  |= SwCntntFrm::CalcLowers( &rToRecalc, &rToRecalc, nBottom, false );
1736cdf0e10cSrcweir                     }
1737cdf0e10cSrcweir 
1738cdf0e10cSrcweir                     pCellFrm = static_cast<SwCellFrm*>(pCellFrm->GetNext());
1739cdf0e10cSrcweir                 }
1740cdf0e10cSrcweir             }
1741cdf0e10cSrcweir 
1742cdf0e10cSrcweir             if ( bCheck )
1743cdf0e10cSrcweir             {
1744cdf0e10cSrcweir                 if ( ++nLoopControlRuns_1 > nLoopControlMax )
1745cdf0e10cSrcweir                 {
1746cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1747cdf0e10cSrcweir                     ASSERT( 0 != nLoopControlStage_1, "LoopControl_1 in lcl_RecalcRow: Stage 1!" );
1748cdf0e10cSrcweir                     ASSERT( 1 != nLoopControlStage_1, "LoopControl_1 in lcl_RecalcRow: Stage 2!!" );
1749cdf0e10cSrcweir                     ASSERT( 2 >  nLoopControlStage_1, "LoopControl_1 in lcl_RecalcRow: Stage 3!!!" );
1750cdf0e10cSrcweir #endif
1751cdf0e10cSrcweir                     rRow.ValidateThisAndAllLowers( nLoopControlStage_1++ );
1752cdf0e10cSrcweir                     nLoopControlRuns_1 = 0;
1753cdf0e10cSrcweir                     if( nLoopControlStage_1 > 2 )
1754cdf0e10cSrcweir                         break;
1755cdf0e10cSrcweir                 }
1756cdf0e10cSrcweir 
1757cdf0e10cSrcweir                 continue;
1758cdf0e10cSrcweir             }
1759cdf0e10cSrcweir         }
1760cdf0e10cSrcweir         break;
1761cdf0e10cSrcweir     } while( true );
1762cdf0e10cSrcweir 
1763cdf0e10cSrcweir     // --> OD 2004-10-05 #i26945#
1764cdf0e10cSrcweir     if ( pPageFrm )
1765cdf0e10cSrcweir         pPageFrm->SetLayoutInProgress( false );
1766cdf0e10cSrcweir     // <--
1767cdf0e10cSrcweir }
1768cdf0e10cSrcweir 
lcl_RecalcTable(SwTabFrm & rTab,SwLayoutFrm * pFirstRow,SwLayNotify & rNotify)1769cdf0e10cSrcweir void MA_FASTCALL lcl_RecalcTable( SwTabFrm& rTab,
1770cdf0e10cSrcweir                                   SwLayoutFrm *pFirstRow,
1771cdf0e10cSrcweir                                   SwLayNotify &rNotify )
1772cdf0e10cSrcweir {
1773cdf0e10cSrcweir     if ( rTab.Lower() )
1774cdf0e10cSrcweir 	{
1775cdf0e10cSrcweir         if ( !pFirstRow )
1776cdf0e10cSrcweir 		{
1777cdf0e10cSrcweir             pFirstRow = (SwLayoutFrm*)rTab.Lower();
1778cdf0e10cSrcweir 			rNotify.SetLowersComplete( sal_True );
1779cdf0e10cSrcweir 		}
1780cdf0e10cSrcweir 		::SwInvalidatePositions( pFirstRow, LONG_MAX );
1781cdf0e10cSrcweir         lcl_RecalcRow( static_cast<SwRowFrm&>(*pFirstRow), LONG_MAX );
1782cdf0e10cSrcweir     }
1783cdf0e10cSrcweir }
1784cdf0e10cSrcweir 
1785cdf0e10cSrcweir // This is a new function to check the first condition whether
1786cdf0e10cSrcweir // a tab frame may move backward. It replaces the formerly used
1787cdf0e10cSrcweir // GetIndPrev(), which did not work correctly for #i5947#
lcl_NoPrev(const SwFrm & rFrm)1788cdf0e10cSrcweir bool lcl_NoPrev( const SwFrm& rFrm )
1789cdf0e10cSrcweir {
1790cdf0e10cSrcweir     // --> OD 2007-09-04 #i79774#, #b6596954#
1791cdf0e10cSrcweir     // skip empty sections on investigation of direct previous frame.
1792cdf0e10cSrcweir     // use information, that at least one empty section is skipped in the following code.
1793cdf0e10cSrcweir     bool bSkippedDirectPrevEmptySection( false );
1794cdf0e10cSrcweir     if ( rFrm.GetPrev() )
1795cdf0e10cSrcweir     {
1796cdf0e10cSrcweir         const SwFrm* pPrev( rFrm.GetPrev() );
1797cdf0e10cSrcweir         while ( pPrev &&
1798cdf0e10cSrcweir                 pPrev->IsSctFrm() &&
1799cdf0e10cSrcweir                 !dynamic_cast<const SwSectionFrm*>(pPrev)->GetSection() )
1800cdf0e10cSrcweir         {
1801cdf0e10cSrcweir             pPrev = pPrev->GetPrev();
1802cdf0e10cSrcweir             bSkippedDirectPrevEmptySection = true;
1803cdf0e10cSrcweir         }
1804cdf0e10cSrcweir         if ( pPrev )
1805cdf0e10cSrcweir         {
1806cdf0e10cSrcweir             return false;
1807cdf0e10cSrcweir         }
1808cdf0e10cSrcweir     }
1809cdf0e10cSrcweir 
1810cdf0e10cSrcweir     if ( ( !bSkippedDirectPrevEmptySection && !rFrm.GetIndPrev() ) ||
1811cdf0e10cSrcweir          ( bSkippedDirectPrevEmptySection &&
1812cdf0e10cSrcweir            ( !rFrm.IsInSct() || !rFrm._GetIndPrev() ) ) )
1813cdf0e10cSrcweir     {
1814cdf0e10cSrcweir         return true;
1815cdf0e10cSrcweir     }
1816cdf0e10cSrcweir     // <--
1817cdf0e10cSrcweir 
1818cdf0e10cSrcweir     // I do not have a direct prev, but I have an indirect prev.
1819cdf0e10cSrcweir     // In section frames I have to check if I'm located inside
1820cdf0e10cSrcweir     // the first column:
1821cdf0e10cSrcweir     if ( rFrm.IsInSct() )
1822cdf0e10cSrcweir     {
1823cdf0e10cSrcweir         const SwFrm* pSct = rFrm.GetUpper();
1824cdf0e10cSrcweir         if ( pSct && pSct->IsColBodyFrm() &&
1825cdf0e10cSrcweir             (pSct = pSct->GetUpper()->GetUpper())->IsSctFrm() )
1826cdf0e10cSrcweir         {
1827cdf0e10cSrcweir             const SwFrm* pPrevCol = rFrm.GetUpper()->GetUpper()->GetPrev();
1828cdf0e10cSrcweir             if ( pPrevCol )
1829cdf0e10cSrcweir                 // I'm not inside the first column and do not have a direct
1830cdf0e10cSrcweir                 // prev. I can try to go backward.
1831cdf0e10cSrcweir                 return true;
1832cdf0e10cSrcweir         }
1833cdf0e10cSrcweir     }
1834cdf0e10cSrcweir 
1835cdf0e10cSrcweir     return false;
1836cdf0e10cSrcweir }
1837cdf0e10cSrcweir 
1838cdf0e10cSrcweir #define KEEPTAB ( !GetFollow() && !IsFollow() )
1839cdf0e10cSrcweir 
1840cdf0e10cSrcweir // --> OD 2005-09-28 #b6329202# - helper method to find next content frame of
1841cdf0e10cSrcweir // a table frame and format it to assure keep attribute.
1842cdf0e10cSrcweir // method return true, if a next content frame is formatted.
1843cdf0e10cSrcweir // Precondition: The given table frame hasn't a follow and isn't a follow.
lcl_FormatNextCntntForKeep(SwTabFrm * pTabFrm)1844cdf0e10cSrcweir SwFrm* lcl_FormatNextCntntForKeep( SwTabFrm* pTabFrm )
1845cdf0e10cSrcweir {
1846cdf0e10cSrcweir     // find next content, table or section
1847cdf0e10cSrcweir     SwFrm* pNxt = pTabFrm->FindNext();
1848cdf0e10cSrcweir 
1849cdf0e10cSrcweir     // skip empty sections
1850cdf0e10cSrcweir     while ( pNxt && pNxt->IsSctFrm() &&
1851cdf0e10cSrcweir             !static_cast<SwSectionFrm*>(pNxt)->GetSection() )
1852cdf0e10cSrcweir     {
1853cdf0e10cSrcweir         pNxt = pNxt->FindNext();
1854cdf0e10cSrcweir     }
1855cdf0e10cSrcweir 
1856cdf0e10cSrcweir     // if found next frame is a section, get its first content.
1857cdf0e10cSrcweir     if ( pNxt && pNxt->IsSctFrm() )
1858cdf0e10cSrcweir     {
1859cdf0e10cSrcweir         pNxt = static_cast<SwSectionFrm*>(pNxt)->ContainsAny();
1860cdf0e10cSrcweir     }
1861cdf0e10cSrcweir 
1862cdf0e10cSrcweir     // format found next frame.
1863cdf0e10cSrcweir     // if table frame is inside another table, method <SwFrm::MakeAll()> is
1864cdf0e10cSrcweir     // called to avoid that the superior table frame is formatted.
1865cdf0e10cSrcweir     if ( pNxt )
1866cdf0e10cSrcweir     {
1867cdf0e10cSrcweir         if ( pTabFrm->GetUpper()->IsInTab() )
1868cdf0e10cSrcweir             pNxt->MakeAll();
1869cdf0e10cSrcweir         else
1870cdf0e10cSrcweir             pNxt->Calc();
1871cdf0e10cSrcweir     }
1872cdf0e10cSrcweir 
1873cdf0e10cSrcweir     return pNxt;
1874cdf0e10cSrcweir }
1875cdf0e10cSrcweir 
18769d3f73eaSOliver-Rainer Wittmann namespace {
AreAllRowsKeepWithNext(const SwRowFrm * pFirstRowFrm)18779d3f73eaSOliver-Rainer Wittmann     bool AreAllRowsKeepWithNext( const SwRowFrm* pFirstRowFrm )
18789d3f73eaSOliver-Rainer Wittmann     {
18799d3f73eaSOliver-Rainer Wittmann         bool bRet = pFirstRowFrm != 0 &&
18809d3f73eaSOliver-Rainer Wittmann                     pFirstRowFrm->ShouldRowKeepWithNext();
18819d3f73eaSOliver-Rainer Wittmann 
18829d3f73eaSOliver-Rainer Wittmann         while ( bRet && pFirstRowFrm->GetNext() != 0 )
18839d3f73eaSOliver-Rainer Wittmann         {
18849d3f73eaSOliver-Rainer Wittmann             pFirstRowFrm = dynamic_cast<const SwRowFrm*>(pFirstRowFrm->GetNext());
18859d3f73eaSOliver-Rainer Wittmann             bRet = pFirstRowFrm != 0 &&
18869d3f73eaSOliver-Rainer Wittmann                    pFirstRowFrm->ShouldRowKeepWithNext();
18879d3f73eaSOliver-Rainer Wittmann         }
18889d3f73eaSOliver-Rainer Wittmann 
18899d3f73eaSOliver-Rainer Wittmann         return bRet;
18909d3f73eaSOliver-Rainer Wittmann     }
18919d3f73eaSOliver-Rainer Wittmann }
MakeAll()1892cdf0e10cSrcweir void SwTabFrm::MakeAll()
1893cdf0e10cSrcweir {
1894cdf0e10cSrcweir 	if ( IsJoinLocked() || StackHack::IsLocked() || StackHack::Count() > 50 )
1895cdf0e10cSrcweir 		return;
1896cdf0e10cSrcweir 
1897cdf0e10cSrcweir     if ( HasFollow() )
1898cdf0e10cSrcweir     {
1899cdf0e10cSrcweir         SwTabFrm* pFollowFrm = (SwTabFrm*)GetFollow();
1900cdf0e10cSrcweir         ASSERT( !pFollowFrm->IsJoinLocked() || !pFollowFrm->IsRebuildLastLine(),
1901cdf0e10cSrcweir                 "SwTabFrm::MakeAll for master while follow is in RebuildLastLine()" )
1902cdf0e10cSrcweir         if ( pFollowFrm->IsJoinLocked() && pFollowFrm->IsRebuildLastLine() )
1903cdf0e10cSrcweir             return;
1904cdf0e10cSrcweir     }
1905cdf0e10cSrcweir 
1906cdf0e10cSrcweir     PROTOCOL_ENTER( this, PROT_MAKEALL, 0, 0 )
1907cdf0e10cSrcweir 
1908cdf0e10cSrcweir     LockJoin(); //Ich lass mich nicht unterwegs vernichten.
1909cdf0e10cSrcweir 	SwLayNotify aNotify( this );	//uebernimmt im DTor die Benachrichtigung
1910cdf0e10cSrcweir     // If pos is invalid, we have to call a SetInvaKeep at aNotify.
1911cdf0e10cSrcweir     // Otherwise the keep atribute would not work in front of a table.
1912cdf0e10cSrcweir     const sal_Bool bOldValidPos = GetValidPosFlag();
1913cdf0e10cSrcweir 
1914cdf0e10cSrcweir 	//Wenn mein direkter Nachbar gleichzeitig mein Follow ist
1915cdf0e10cSrcweir 	//verleibe ich mir das Teil ein.
1916cdf0e10cSrcweir     // OD 09.04.2003 #108698# - join all follows, which are placed on the
1917cdf0e10cSrcweir     // same page/column.
1918cdf0e10cSrcweir     // OD 29.04.2003 #109213# - join follow, only if join for the follow
1919cdf0e10cSrcweir     // is not locked. Otherwise, join will not be performed and this loop
1920cdf0e10cSrcweir     // will be endless.
1921cdf0e10cSrcweir     while ( GetNext() && GetNext() == GetFollow() &&
1922cdf0e10cSrcweir             !GetFollow()->IsJoinLocked()
1923cdf0e10cSrcweir           )
1924cdf0e10cSrcweir     {
1925cdf0e10cSrcweir         if ( HasFollowFlowLine() )
1926cdf0e10cSrcweir             RemoveFollowFlowLine();
1927cdf0e10cSrcweir         Join();
1928cdf0e10cSrcweir     }
1929cdf0e10cSrcweir 
1930cdf0e10cSrcweir     // The bRemoveFollowFlowLinePending is set if the split attribute of the
1931cdf0e10cSrcweir     // last line is set:
1932cdf0e10cSrcweir     if ( IsRemoveFollowFlowLinePending() && HasFollowFlowLine() )
1933cdf0e10cSrcweir     {
1934cdf0e10cSrcweir         if ( RemoveFollowFlowLine() )
1935cdf0e10cSrcweir             Join();
1936cdf0e10cSrcweir         SetRemoveFollowFlowLinePending( sal_False );
1937cdf0e10cSrcweir     }
1938cdf0e10cSrcweir 
1939cdf0e10cSrcweir 	if ( bResizeHTMLTable )	//Optimiertes Zusammenspiel mit Grow/Shrink des Inhaltes
1940cdf0e10cSrcweir 	{
1941cdf0e10cSrcweir 		bResizeHTMLTable = sal_False;
1942cdf0e10cSrcweir 		SwHTMLTableLayout *pLayout = GetTable()->GetHTMLTableLayout();
1943cdf0e10cSrcweir 		if ( pLayout )
1944cdf0e10cSrcweir 			bCalcLowers = pLayout->Resize(
1945cdf0e10cSrcweir 							pLayout->GetBrowseWidthByTabFrm( *this ), sal_False );
1946cdf0e10cSrcweir 	}
1947cdf0e10cSrcweir 
1948cdf0e10cSrcweir 
1949cdf0e10cSrcweir 	sal_Bool bMakePage	= sal_True;		//solange sal_True kann eine neue Seite
1950cdf0e10cSrcweir 								//angelegt werden (genau einmal)
1951cdf0e10cSrcweir 	sal_Bool bMovedBwd	= sal_False;	//Wird sal_True wenn der Frame zurueckfliesst
1952cdf0e10cSrcweir 	sal_Bool bMovedFwd	= sal_False;	//solange sal_False kann der Frm zurueck-
1953cdf0e10cSrcweir 								//fliessen (solange, bis er einmal
1954cdf0e10cSrcweir 								//vorwaerts ge'moved wurde).
1955cdf0e10cSrcweir 	sal_Bool bSplit		= sal_False;	//Wird sal_True wenn der Frm gesplittet wurde.
1956cdf0e10cSrcweir     const sal_Bool bFtnsInDoc = 0 != GetFmt()->GetDoc()->GetFtnIdxs().Count();
1957cdf0e10cSrcweir 	sal_Bool bMoveable;
1958cdf0e10cSrcweir 	const sal_Bool bFly		= IsInFly();
1959cdf0e10cSrcweir 
1960cdf0e10cSrcweir 	SwBorderAttrAccess  *pAccess= new SwBorderAttrAccess( SwFrm::GetCache(), this );
1961cdf0e10cSrcweir 	const SwBorderAttrs *pAttrs = pAccess->Get();
1962cdf0e10cSrcweir 
1963cdf0e10cSrcweir     // The beloved keep attribute
1964cdf0e10cSrcweir     const bool bKeep = IsKeep( pAttrs->GetAttrSet() );
1965cdf0e10cSrcweir 
1966cdf0e10cSrcweir     // All rows should keep together
1967cdf0e10cSrcweir     // OD 2004-05-25 #i21478# - don't split table, if it has to keep with next
1968cdf0e10cSrcweir     const bool bDontSplit = !IsFollow() &&
1969cdf0e10cSrcweir                             ( !GetFmt()->GetLayoutSplit().GetValue() || bKeep );
1970cdf0e10cSrcweir 
1971cdf0e10cSrcweir     // The number of repeated headlines
1972cdf0e10cSrcweir     const sal_uInt16 nRepeat = GetTable()->GetRowsToRepeat();
1973cdf0e10cSrcweir 
1974cdf0e10cSrcweir     // This flag indicates that we are allowed to try to split the
1975cdf0e10cSrcweir     // table rows.
1976cdf0e10cSrcweir     bool bTryToSplit = true;
1977cdf0e10cSrcweir 
1978cdf0e10cSrcweir     // --> FME 2006-02-16 #131283#
1979cdf0e10cSrcweir     // Indicates that two individual rows may keep together, based on the keep
1980cdf0e10cSrcweir     // attribute set at the first paragraph in the first cell.
1981cdf0e10cSrcweir     const bool bTableRowKeep = !bDontSplit && GetFmt()->GetDoc()->get(IDocumentSettingAccess::TABLE_ROW_KEEP);
1982cdf0e10cSrcweir 
1983cdf0e10cSrcweir     // The Magic Move: Used for the table row keep feature.
1984cdf0e10cSrcweir     // If only the last row of the table wants to keep (implicitely by setting
1985cdf0e10cSrcweir     // keep for the first paragraph in the first cell), and this table does
1986cdf0e10cSrcweir     // not have a next, the last line will be cut. Loop prevention: Only
1987cdf0e10cSrcweir     // one try.
1988cdf0e10cSrcweir     bool bLastRowHasToMoveToFollow = false;
1989cdf0e10cSrcweir     bool bLastRowMoveNoMoreTries = false;
1990cdf0e10cSrcweir 
1991cdf0e10cSrcweir     // Join follow table, if this table is not allowed to split:
1992cdf0e10cSrcweir 	if ( bDontSplit )
1993cdf0e10cSrcweir     {
1994cdf0e10cSrcweir 		while ( GetFollow() && !GetFollow()->IsJoinLocked() )
1995cdf0e10cSrcweir         {
1996cdf0e10cSrcweir             if ( HasFollowFlowLine() )
1997cdf0e10cSrcweir                 RemoveFollowFlowLine();
1998cdf0e10cSrcweir             Join();
1999cdf0e10cSrcweir         }
2000cdf0e10cSrcweir     }
2001cdf0e10cSrcweir 
2002cdf0e10cSrcweir     // Join follow table, if this does not have enough (repeated) lines:
2003cdf0e10cSrcweir     if ( nRepeat )
2004cdf0e10cSrcweir     {
2005cdf0e10cSrcweir         if( GetFollow() && !GetFollow()->IsJoinLocked() &&
2006cdf0e10cSrcweir             0 == GetFirstNonHeadlineRow() )
2007cdf0e10cSrcweir         {
2008cdf0e10cSrcweir             if ( HasFollowFlowLine() )
2009cdf0e10cSrcweir                 RemoveFollowFlowLine();
2010cdf0e10cSrcweir             Join();
2011cdf0e10cSrcweir         }
2012cdf0e10cSrcweir     }
2013cdf0e10cSrcweir 
2014cdf0e10cSrcweir     // Join follow table, if last row of this table should keep:
2015cdf0e10cSrcweir     if ( bTableRowKeep && GetFollow() && !GetFollow()->IsJoinLocked() )
2016cdf0e10cSrcweir     {
2017cdf0e10cSrcweir         const SwRowFrm* pTmpRow = static_cast<const SwRowFrm*>(GetLastLower());
2018cdf0e10cSrcweir         if ( pTmpRow && pTmpRow->ShouldRowKeepWithNext() )
2019cdf0e10cSrcweir         {
2020cdf0e10cSrcweir             if ( HasFollowFlowLine() )
2021cdf0e10cSrcweir                 RemoveFollowFlowLine();
2022cdf0e10cSrcweir             Join();
2023cdf0e10cSrcweir         }
2024cdf0e10cSrcweir     }
2025cdf0e10cSrcweir 
2026cdf0e10cSrcweir     //Einen Frischling moven wir gleich schon einmal vorwaerts...
2027cdf0e10cSrcweir 	if ( !Frm().Top() && IsFollow() )
2028cdf0e10cSrcweir 	{
2029cdf0e10cSrcweir 		SwFrm *pPre = GetPrev();
2030cdf0e10cSrcweir 		if ( pPre && pPre->IsTabFrm() && ((SwTabFrm*)pPre)->GetFollow() == this)
2031cdf0e10cSrcweir 		{
2032cdf0e10cSrcweir 			if ( !MoveFwd( bMakePage, sal_False ) )
2033cdf0e10cSrcweir 				bMakePage = sal_False;
2034cdf0e10cSrcweir 			bMovedFwd = sal_True;
2035cdf0e10cSrcweir 		}
2036cdf0e10cSrcweir 	}
2037cdf0e10cSrcweir 
2038cdf0e10cSrcweir 	int nUnSplitted = 5; // Just another loop control :-(
2039cdf0e10cSrcweir     SWRECTFN( this )
20400df44b11SOliver-Rainer Wittmann     while ( !bValidPos || !bValidSize || !bValidPrtArea )
20410df44b11SOliver-Rainer Wittmann     {
20420df44b11SOliver-Rainer Wittmann         if ( sal_True == (bMoveable = IsMoveable()) )
20430df44b11SOliver-Rainer Wittmann             if ( CheckMoveFwd( bMakePage, bKeep && KEEPTAB, bMovedBwd ) )
20440df44b11SOliver-Rainer Wittmann             {
20450df44b11SOliver-Rainer Wittmann                 bMovedFwd = sal_True;
20460df44b11SOliver-Rainer Wittmann                 bCalcLowers = sal_True;
2047cdf0e10cSrcweir                 // --> OD 2009-08-12 #i99267#
2048cdf0e10cSrcweir                 // reset <bSplit> after forward move to assure that follows
2049cdf0e10cSrcweir                 // can be joined, if further space is available.
2050cdf0e10cSrcweir                 bSplit = sal_False;
2051cdf0e10cSrcweir                 // <--
20520df44b11SOliver-Rainer Wittmann             }
2053cdf0e10cSrcweir 
2054cdf0e10cSrcweir         Point aOldPos( (Frm().*fnRect->fnGetPos)() );
20550df44b11SOliver-Rainer Wittmann         MakePos();
2056cdf0e10cSrcweir 
2057cdf0e10cSrcweir         if ( aOldPos != (Frm().*fnRect->fnGetPos)() )
20580df44b11SOliver-Rainer Wittmann         {
2059cdf0e10cSrcweir             if ( aOldPos.Y() != (Frm().*fnRect->fnGetTop)() )
20600df44b11SOliver-Rainer Wittmann             {
20610df44b11SOliver-Rainer Wittmann                 SwHTMLTableLayout *pLayout = GetTable()->GetHTMLTableLayout();
20620df44b11SOliver-Rainer Wittmann                 if( pLayout )
20630df44b11SOliver-Rainer Wittmann                 {
20640df44b11SOliver-Rainer Wittmann                     delete pAccess;
20650df44b11SOliver-Rainer Wittmann                     bCalcLowers |= pLayout->Resize(
20660df44b11SOliver-Rainer Wittmann                         pLayout->GetBrowseWidthByTabFrm( *this ), sal_False );
2067cdf0e10cSrcweir                     pAccess = new SwBorderAttrAccess( SwFrm::GetCache(), this );
20680df44b11SOliver-Rainer Wittmann                     pAttrs = pAccess->Get();
20690df44b11SOliver-Rainer Wittmann                 }
2070cdf0e10cSrcweir 
20710df44b11SOliver-Rainer Wittmann                 bValidPrtArea = sal_False;
20720df44b11SOliver-Rainer Wittmann                 aNotify.SetLowersComplete( sal_False );
20730df44b11SOliver-Rainer Wittmann             }
20740df44b11SOliver-Rainer Wittmann             SwFrm *pPre;
20750df44b11SOliver-Rainer Wittmann             if ( bKeep || (0 != (pPre = FindPrev()) &&
20760df44b11SOliver-Rainer Wittmann                 pPre->GetAttrSet()->GetKeep().GetValue()) )
20770df44b11SOliver-Rainer Wittmann             {
20780df44b11SOliver-Rainer Wittmann                 bCalcLowers = sal_True;
20790df44b11SOliver-Rainer Wittmann             }
20800df44b11SOliver-Rainer Wittmann         }
2081cdf0e10cSrcweir 
20820df44b11SOliver-Rainer Wittmann         //Wir muessen die Hoehe der ersten Zeile kennen, denn nur wenn diese
20830df44b11SOliver-Rainer Wittmann         //kleiner wird muss ggf. der Master angestossen werden um noetigenfalls
20840df44b11SOliver-Rainer Wittmann         //die Zeile aufzunehmen.
20850df44b11SOliver-Rainer Wittmann         long n1StLineHeight = 0;
20860df44b11SOliver-Rainer Wittmann         if ( IsFollow() )
20870df44b11SOliver-Rainer Wittmann         {
2088cdf0e10cSrcweir             SwFrm* pFrm = GetFirstNonHeadlineRow();
2089cdf0e10cSrcweir             if ( pFrm )
2090cdf0e10cSrcweir                 n1StLineHeight = (pFrm->Frm().*fnRect->fnGetHeight)();
20910df44b11SOliver-Rainer Wittmann         }
2092cdf0e10cSrcweir 
20930df44b11SOliver-Rainer Wittmann         if ( !bValidSize || !bValidPrtArea )
20940df44b11SOliver-Rainer Wittmann         {
2095cdf0e10cSrcweir             const long nOldPrtWidth = (Prt().*fnRect->fnGetWidth)();
2096cdf0e10cSrcweir             const long nOldFrmWidth = (Frm().*fnRect->fnGetWidth)();
2097cdf0e10cSrcweir             const Point aOldPrtPos  = (Prt().*fnRect->fnGetPos)();
20980df44b11SOliver-Rainer Wittmann             Format( pAttrs );
2099cdf0e10cSrcweir 
21000df44b11SOliver-Rainer Wittmann             SwHTMLTableLayout *pLayout = GetTable()->GetHTMLTableLayout();
21010df44b11SOliver-Rainer Wittmann             if ( pLayout &&
21020df44b11SOliver-Rainer Wittmann                 ((Prt().*fnRect->fnGetWidth)() != nOldPrtWidth ||
21030df44b11SOliver-Rainer Wittmann                 (Frm().*fnRect->fnGetWidth)() != nOldFrmWidth) )
2104cdf0e10cSrcweir             {
21050df44b11SOliver-Rainer Wittmann                 delete pAccess;
21060df44b11SOliver-Rainer Wittmann                 bCalcLowers |= pLayout->Resize(
21070df44b11SOliver-Rainer Wittmann                     pLayout->GetBrowseWidthByTabFrm( *this ), sal_False );
21080df44b11SOliver-Rainer Wittmann                 pAccess= new SwBorderAttrAccess( SwFrm::GetCache(), this );
21090df44b11SOliver-Rainer Wittmann                 pAttrs = pAccess->Get();
21100df44b11SOliver-Rainer Wittmann             }
2111cdf0e10cSrcweir             if ( aOldPrtPos != (Prt().*fnRect->fnGetPos)() )
21120df44b11SOliver-Rainer Wittmann                 aNotify.SetLowersComplete( sal_False );
21130df44b11SOliver-Rainer Wittmann         }
2114cdf0e10cSrcweir 
21150df44b11SOliver-Rainer Wittmann         //Wenn ich der erste einer Kette bin koennte ich mal sehen ob
21160df44b11SOliver-Rainer Wittmann         //ich zurueckfliessen kann (wenn ich mich ueberhaupt bewegen soll).
21170df44b11SOliver-Rainer Wittmann         //Damit es keine Oszillation gibt, darf ich nicht gerade vorwaerts
21180df44b11SOliver-Rainer Wittmann         //geflosssen sein.
2119cdf0e10cSrcweir         if ( !bMovedFwd && (bMoveable || bFly) && lcl_NoPrev( *this ) )
21200df44b11SOliver-Rainer Wittmann         {
21210df44b11SOliver-Rainer Wittmann             //Bei Follows muss der Master benachrichtigt
21220df44b11SOliver-Rainer Wittmann             //werden. Der Follow muss nur dann Moven, wenn er leere Blaetter
21230df44b11SOliver-Rainer Wittmann             //ueberspringen muss.
21240df44b11SOliver-Rainer Wittmann             if ( IsFollow() )
21250df44b11SOliver-Rainer Wittmann             {
21260df44b11SOliver-Rainer Wittmann                 //Nur wenn die Hoehe der ersten Zeile kleiner geworder ist.
2127cdf0e10cSrcweir                 SwFrm *pFrm = GetFirstNonHeadlineRow();
2128cdf0e10cSrcweir                 if( pFrm && n1StLineHeight >(pFrm->Frm().*fnRect->fnGetHeight )() )
21290df44b11SOliver-Rainer Wittmann                 {
21300df44b11SOliver-Rainer Wittmann                     SwTabFrm *pMaster = (SwTabFrm*)FindMaster();
21310df44b11SOliver-Rainer Wittmann                     sal_Bool bDummy;
21320df44b11SOliver-Rainer Wittmann                     if ( ShouldBwdMoved( pMaster->GetUpper(), sal_False, bDummy ) )
21330df44b11SOliver-Rainer Wittmann                         pMaster->InvalidatePos();
21340df44b11SOliver-Rainer Wittmann                 }
21350df44b11SOliver-Rainer Wittmann             }
21360df44b11SOliver-Rainer Wittmann             SwFtnBossFrm *pOldBoss = bFtnsInDoc ? FindFtnBossFrm( sal_True ) : 0;
21370df44b11SOliver-Rainer Wittmann             sal_Bool bReformat;
21380df44b11SOliver-Rainer Wittmann             if ( MoveBwd( bReformat ) )
21390df44b11SOliver-Rainer Wittmann             {
2140cdf0e10cSrcweir                 SWREFRESHFN( this )
21410df44b11SOliver-Rainer Wittmann                 bMovedBwd = sal_True;
21420df44b11SOliver-Rainer Wittmann                 aNotify.SetLowersComplete( sal_False );
21430df44b11SOliver-Rainer Wittmann                 if ( bFtnsInDoc )
21440df44b11SOliver-Rainer Wittmann                     MoveLowerFtns( 0, pOldBoss, 0, sal_True );
21450df44b11SOliver-Rainer Wittmann                 if ( bReformat || bKeep )
21460df44b11SOliver-Rainer Wittmann                 {
2147cdf0e10cSrcweir                     long nOldTop = (Frm().*fnRect->fnGetTop)();
2148cdf0e10cSrcweir                     MakePos();
2149cdf0e10cSrcweir                     if( nOldTop != (Frm().*fnRect->fnGetTop)() )
21500df44b11SOliver-Rainer Wittmann                     {
2151cdf0e10cSrcweir                         SwHTMLTableLayout *pHTMLLayout =
21520df44b11SOliver-Rainer Wittmann                             GetTable()->GetHTMLTableLayout();
2153cdf0e10cSrcweir                         if( pHTMLLayout )
21540df44b11SOliver-Rainer Wittmann                         {
21550df44b11SOliver-Rainer Wittmann                             delete pAccess;
2156cdf0e10cSrcweir                             bCalcLowers |= pHTMLLayout->Resize(
2157cdf0e10cSrcweir                                 pHTMLLayout->GetBrowseWidthByTabFrm( *this ),
21580df44b11SOliver-Rainer Wittmann                                 sal_False );
2159cdf0e10cSrcweir 
21600df44b11SOliver-Rainer Wittmann                             pAccess= new SwBorderAttrAccess( SwFrm::GetCache(), this );
21610df44b11SOliver-Rainer Wittmann                             pAttrs = pAccess->Get();
21620df44b11SOliver-Rainer Wittmann                         }
2163cdf0e10cSrcweir 
21640df44b11SOliver-Rainer Wittmann                         bValidPrtArea = sal_False;
21650df44b11SOliver-Rainer Wittmann                         Format( pAttrs );
21660df44b11SOliver-Rainer Wittmann                     }
2167cdf0e10cSrcweir                     lcl_RecalcTable( *this, 0, aNotify );
21680df44b11SOliver-Rainer Wittmann                     bLowersFormatted = sal_True;
21690df44b11SOliver-Rainer Wittmann                     if ( bKeep && KEEPTAB )
21700df44b11SOliver-Rainer Wittmann                     {
2171cdf0e10cSrcweir                         if ( 0 != lcl_FormatNextCntntForKeep( this ) && !GetNext() )
2172cdf0e10cSrcweir                         {
2173cdf0e10cSrcweir                             bValidPos = sal_False;
2174cdf0e10cSrcweir                         }
21750df44b11SOliver-Rainer Wittmann                     }
21760df44b11SOliver-Rainer Wittmann                 }
21770df44b11SOliver-Rainer Wittmann             }
21780df44b11SOliver-Rainer Wittmann         }
2179cdf0e10cSrcweir 
21800df44b11SOliver-Rainer Wittmann         //Wieder ein Wert ungueltig? - dann nochmal das ganze...
21810df44b11SOliver-Rainer Wittmann         if ( !bValidPos || !bValidSize || !bValidPrtArea )
21820df44b11SOliver-Rainer Wittmann             continue;
2183cdf0e10cSrcweir 
2184cdf0e10cSrcweir         // check, if calculation of table frame is ready.
2185cdf0e10cSrcweir 
21860df44b11SOliver-Rainer Wittmann         // Local variable <nDistanceToUpperPrtBottom>
21870df44b11SOliver-Rainer Wittmann         //     Introduce local variable and init it with the distance from the
21880df44b11SOliver-Rainer Wittmann         //     table frame bottom to the bottom of the upper printing area.
21890df44b11SOliver-Rainer Wittmann         // Note: negative values denotes the situation that table frame doesn't fit in its upper.
2190cdf0e10cSrcweir         SwTwips nDistanceToUpperPrtBottom =
2191cdf0e10cSrcweir                 (Frm().*fnRect->fnBottomDist)( (GetUpper()->*fnRect->fnGetPrtBottom)());
2192cdf0e10cSrcweir 
21930df44b11SOliver-Rainer Wittmann         // In online layout try to grow upper of table frame, if table frame doesn't fit in its upper.
2194cdf0e10cSrcweir         const ViewShell *pSh = getRootFrm()->GetCurrShell();
2195cdf0e10cSrcweir         const bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
2196cdf0e10cSrcweir         if ( nDistanceToUpperPrtBottom < 0 && bBrowseMode )
2197cdf0e10cSrcweir         {
2198cdf0e10cSrcweir             if ( GetUpper()->Grow( -nDistanceToUpperPrtBottom ) )
2199cdf0e10cSrcweir             {
2200cdf0e10cSrcweir                 // upper is grown --> recalculate <nDistanceToUpperPrtBottom>
22010df44b11SOliver-Rainer Wittmann                 nDistanceToUpperPrtBottom = (Frm().*fnRect->fnBottomDist)( (GetUpper()->*fnRect->fnGetPrtBottom)());
2202cdf0e10cSrcweir             }
2203cdf0e10cSrcweir         }
2204cdf0e10cSrcweir 
2205cdf0e10cSrcweir         // If there is still some space left in the upper, we check if we
2206cdf0e10cSrcweir         // can join some rows of the follow.
2207cdf0e10cSrcweir         // Setting bLastRowHasToMoveToFollow to true means we want to force
2208cdf0e10cSrcweir         // the table to be split! Only skip this if condition once.
2209cdf0e10cSrcweir         if( nDistanceToUpperPrtBottom >= 0 && !bLastRowHasToMoveToFollow )
2210cdf0e10cSrcweir         {
2211cdf0e10cSrcweir             // If there is space left in the upper printing area, join as for trial
2212cdf0e10cSrcweir             // at least one further row of an existing follow.
22130df44b11SOliver-Rainer Wittmann             if ( !bSplit && GetFollow() )
22140df44b11SOliver-Rainer Wittmann             {
22150df44b11SOliver-Rainer Wittmann                 sal_Bool bDummy;
22160df44b11SOliver-Rainer Wittmann                 if ( GetFollow()->ShouldBwdMoved( GetUpper(), sal_False, bDummy ) )
22170df44b11SOliver-Rainer Wittmann                 {
2218cdf0e10cSrcweir                     SwFrm *pTmp = GetUpper();
2219cdf0e10cSrcweir                     SwTwips nDeadLine = (pTmp->*fnRect->fnGetPrtBottom)();
2220cdf0e10cSrcweir                     if ( bBrowseMode )
2221cdf0e10cSrcweir                         nDeadLine += pTmp->Grow( LONG_MAX, sal_True );
2222cdf0e10cSrcweir                     if( (Frm().*fnRect->fnBottomDist)( nDeadLine ) > 0 )
22230df44b11SOliver-Rainer Wittmann                     {
2224cdf0e10cSrcweir                         //
2225cdf0e10cSrcweir                         // First, we remove an existing follow flow line.
2226cdf0e10cSrcweir                         //
2227cdf0e10cSrcweir                         if ( HasFollowFlowLine() )
2228cdf0e10cSrcweir                         {
2229cdf0e10cSrcweir                             SwFrm* pLastLine = const_cast<SwFrm*>(GetLastLower());
2230cdf0e10cSrcweir                             RemoveFollowFlowLine();
2231cdf0e10cSrcweir                             // invalidate and rebuild last row
2232cdf0e10cSrcweir                             if ( pLastLine )
2233cdf0e10cSrcweir                             {
2234cdf0e10cSrcweir                                 ::SwInvalidateAll( pLastLine, LONG_MAX );
2235cdf0e10cSrcweir                                 SetRebuildLastLine( sal_True );
2236cdf0e10cSrcweir                                 lcl_RecalcRow( static_cast<SwRowFrm&>(*pLastLine), LONG_MAX );
2237cdf0e10cSrcweir                                 SetRebuildLastLine( sal_False );
2238cdf0e10cSrcweir                             }
2239cdf0e10cSrcweir 
2240cdf0e10cSrcweir                             SwFrm* pRow = GetFollow()->GetFirstNonHeadlineRow();
2241cdf0e10cSrcweir 
2242cdf0e10cSrcweir                             if ( !pRow || !pRow->GetNext() )
22430df44b11SOliver-Rainer Wittmann                                 //Der Follow wird leer und damit ueberfluessig.
2244cdf0e10cSrcweir                                 Join();
2245cdf0e10cSrcweir 
2246cdf0e10cSrcweir                             continue;
2247cdf0e10cSrcweir                         }
2248cdf0e10cSrcweir 
2249cdf0e10cSrcweir                         //
2250cdf0e10cSrcweir                         // If there is no follow flow line, we move the first
2251cdf0e10cSrcweir                         // row in the follow table to the master table.
2252cdf0e10cSrcweir                         //
2253cdf0e10cSrcweir                         SwRowFrm *pRow = GetFollow()->GetFirstNonHeadlineRow();
2254cdf0e10cSrcweir 
22550df44b11SOliver-Rainer Wittmann                         //Der Follow wird leer und damit ueberfluessig.
22560df44b11SOliver-Rainer Wittmann                         if ( !pRow )
2257cdf0e10cSrcweir                         {
2258cdf0e10cSrcweir                             Join();
2259cdf0e10cSrcweir                             continue;
2260cdf0e10cSrcweir                         }
2261cdf0e10cSrcweir 
2262cdf0e10cSrcweir                         const SwTwips nOld = (Frm().*fnRect->fnGetHeight)();
2263cdf0e10cSrcweir                         long nRowsToMove = lcl_GetMaximumLayoutRowSpan( *pRow );
2264cdf0e10cSrcweir                         SwFrm* pRowToMove = pRow;
2265cdf0e10cSrcweir 
2266cdf0e10cSrcweir                         while ( pRowToMove && nRowsToMove-- > 0 )
2267cdf0e10cSrcweir                         {
22680df44b11SOliver-Rainer Wittmann                             const sal_Bool bMoveFtns = bFtnsInDoc && !GetFollow()->IsJoinLocked();
2269cdf0e10cSrcweir 
2270cdf0e10cSrcweir                             SwFtnBossFrm *pOldBoss = 0;
22710df44b11SOliver-Rainer Wittmann                             if ( bMoveFtns )
22720df44b11SOliver-Rainer Wittmann                                 pOldBoss = pRowToMove->FindFtnBossFrm( sal_True );
2273cdf0e10cSrcweir 
2274cdf0e10cSrcweir                             SwFrm* pNextRow = pRowToMove->GetNext();
2275cdf0e10cSrcweir 
22760df44b11SOliver-Rainer Wittmann                             if ( !pNextRow )
22770df44b11SOliver-Rainer Wittmann                             {
22780df44b11SOliver-Rainer Wittmann                                 //Der Follow wird leer und damit ueberfluessig.
2279cdf0e10cSrcweir                                 Join();
22800df44b11SOliver-Rainer Wittmann                             }
2281cdf0e10cSrcweir                             else
22820df44b11SOliver-Rainer Wittmann                             {
22830df44b11SOliver-Rainer Wittmann                                 pRowToMove->Cut();
22840df44b11SOliver-Rainer Wittmann                                 pRowToMove->Paste( this );
2285cdf0e10cSrcweir                             }
2286cdf0e10cSrcweir 
22870df44b11SOliver-Rainer Wittmann                             //Die Fussnoten verschieben!
22880df44b11SOliver-Rainer Wittmann                             if ( bMoveFtns )
22890df44b11SOliver-Rainer Wittmann                                 if ( ((SwLayoutFrm*)pRowToMove)->MoveLowerFtns( 0, pOldBoss, FindFtnBossFrm( sal_True ), sal_True ) )
22900df44b11SOliver-Rainer Wittmann                                     GetUpper()->Calc();
2291cdf0e10cSrcweir 
2292cdf0e10cSrcweir                             pRowToMove = pNextRow;
2293cdf0e10cSrcweir                         }
2294cdf0e10cSrcweir 
2295cdf0e10cSrcweir                         if ( nOld != (Frm().*fnRect->fnGetHeight)() )
2296cdf0e10cSrcweir                             lcl_RecalcTable( *this, (SwLayoutFrm*)pRow, aNotify );
2297cdf0e10cSrcweir 
2298cdf0e10cSrcweir                         continue;
22990df44b11SOliver-Rainer Wittmann                     }
23000df44b11SOliver-Rainer Wittmann                 }
23010df44b11SOliver-Rainer Wittmann             }
23020df44b11SOliver-Rainer Wittmann             else if ( KEEPTAB )
23030df44b11SOliver-Rainer Wittmann             {
2304cdf0e10cSrcweir                 bool bFormat = false;
2305cdf0e10cSrcweir                 if ( bKeep )
2306cdf0e10cSrcweir                     bFormat = true;
2307cdf0e10cSrcweir                 else if ( bTableRowKeep && !bLastRowMoveNoMoreTries )
2308cdf0e10cSrcweir                 {
2309cdf0e10cSrcweir                     // We only want to give the last row one chance to move
2310cdf0e10cSrcweir                     // to the follow table. Set the flag as early as possible:
2311cdf0e10cSrcweir                     bLastRowMoveNoMoreTries = true;
2312cdf0e10cSrcweir 
2313cdf0e10cSrcweir                     // The last line of the table has to be cut off if:
2314cdf0e10cSrcweir                     // 1. The table does not want to keep with its next
2315cdf0e10cSrcweir                     // 2. The compatibility option is set and the table is allowed to split
2316cdf0e10cSrcweir                     // 3. We did not already cut off the last row
2317cdf0e10cSrcweir                     // 4. There is not break after attribute set at the table
2318cdf0e10cSrcweir                     // 5. There is no break before attribute set behind the table
2319cdf0e10cSrcweir                     // 6. There is no section change behind the table (see IsKeep)
2320cdf0e10cSrcweir                     // 7. The last table row wants to keep with its next.
2321cdf0e10cSrcweir                     const SwRowFrm* pLastRow = static_cast<const SwRowFrm*>(GetLastLower());
2322cdf0e10cSrcweir                     if ( pLastRow && IsKeep( pAttrs->GetAttrSet(), true ) &&
2323cdf0e10cSrcweir                          pLastRow->ShouldRowKeepWithNext() )
2324cdf0e10cSrcweir                         bFormat = true;
2325cdf0e10cSrcweir                 }
2326cdf0e10cSrcweir 
2327cdf0e10cSrcweir                 if ( bFormat )
2328cdf0e10cSrcweir                 {
2329cdf0e10cSrcweir                     delete pAccess;
2330cdf0e10cSrcweir 
2331cdf0e10cSrcweir                     // --> OD 2005-09-28 #b6329202#
2332cdf0e10cSrcweir                     // Consider case that table is inside another table, because
2333cdf0e10cSrcweir                     // it has to be avoided, that superior table is formatted.
2334cdf0e10cSrcweir                     // Thus, find next content, table or section and, if a section
2335cdf0e10cSrcweir                     // is found, get its first content.
2336cdf0e10cSrcweir                     const SwFrm* pTmpNxt = lcl_FormatNextCntntForKeep( this );
2337cdf0e10cSrcweir                     // <--
2338cdf0e10cSrcweir 
2339cdf0e10cSrcweir                     pAccess= new SwBorderAttrAccess( SwFrm::GetCache(), this );
2340cdf0e10cSrcweir                     pAttrs = pAccess->Get();
2341cdf0e10cSrcweir 
2342cdf0e10cSrcweir                     // The last row wants to keep with the frame behind the table.
2343cdf0e10cSrcweir                     // Check if the next frame is on a different page and valid.
2344cdf0e10cSrcweir                     // In this case we do a magic trick:
2345cdf0e10cSrcweir                     if ( !bKeep && !GetNext() && pTmpNxt && pTmpNxt->IsValid() )
2346cdf0e10cSrcweir                     {
2347cdf0e10cSrcweir                         bValidPos = sal_False;
2348cdf0e10cSrcweir                         bLastRowHasToMoveToFollow = true;
2349cdf0e10cSrcweir                     }
2350cdf0e10cSrcweir                 }
23510df44b11SOliver-Rainer Wittmann             }
2352cdf0e10cSrcweir 
23530df44b11SOliver-Rainer Wittmann             if ( IsValid() )
23540df44b11SOliver-Rainer Wittmann             {
23550df44b11SOliver-Rainer Wittmann                 if ( bCalcLowers )
23560df44b11SOliver-Rainer Wittmann                 {
2357cdf0e10cSrcweir                     lcl_RecalcTable( *this, 0, aNotify );
23580df44b11SOliver-Rainer Wittmann                     bLowersFormatted = sal_True;
23590df44b11SOliver-Rainer Wittmann                     bCalcLowers = sal_False;
23600df44b11SOliver-Rainer Wittmann                 }
23610df44b11SOliver-Rainer Wittmann                 else if ( bONECalcLowers )
23620df44b11SOliver-Rainer Wittmann                 {
2363cdf0e10cSrcweir                     lcl_RecalcRow( static_cast<SwRowFrm&>(*Lower()), LONG_MAX );
23640df44b11SOliver-Rainer Wittmann                     bONECalcLowers = sal_False;
23650df44b11SOliver-Rainer Wittmann                 }
23660df44b11SOliver-Rainer Wittmann             }
23670df44b11SOliver-Rainer Wittmann             continue;
23680df44b11SOliver-Rainer Wittmann         }
2369cdf0e10cSrcweir 
2370cdf0e10cSrcweir         //Ich passe nicht mehr in meinen Uebergeordneten, also ist es jetzt
23710df44b11SOliver-Rainer Wittmann         //an der Zeit moeglichst konstruktive Veranderungen vorzunehmen
2372cdf0e10cSrcweir 
23730df44b11SOliver-Rainer Wittmann         //Wenn ich den uebergeordneten Frm nicht verlassen darf, habe
23740df44b11SOliver-Rainer Wittmann         //ich ein Problem; Frei nach Artur Dent tun wir das einzige das man
23750df44b11SOliver-Rainer Wittmann         //mit einen nicht loesbaren Problem tun kann: wir ignorieren es - und
23760df44b11SOliver-Rainer Wittmann         //zwar mit aller Kraft.
23770df44b11SOliver-Rainer Wittmann         if ( !bMoveable )
23780df44b11SOliver-Rainer Wittmann         {
23790df44b11SOliver-Rainer Wittmann             if ( bCalcLowers && IsValid() )
23800df44b11SOliver-Rainer Wittmann             {
2381cdf0e10cSrcweir                 lcl_RecalcTable( *this, 0, aNotify );
23820df44b11SOliver-Rainer Wittmann                 bLowersFormatted = sal_True;
23830df44b11SOliver-Rainer Wittmann                 bCalcLowers = sal_False;
23840df44b11SOliver-Rainer Wittmann             }
23850df44b11SOliver-Rainer Wittmann             else if ( bONECalcLowers )
23860df44b11SOliver-Rainer Wittmann             {
2387cdf0e10cSrcweir                 lcl_RecalcRow( static_cast<SwRowFrm&>(*Lower()), LONG_MAX );
23880df44b11SOliver-Rainer Wittmann                 bONECalcLowers = sal_False;
23890df44b11SOliver-Rainer Wittmann             }
2390cdf0e10cSrcweir 
2391cdf0e10cSrcweir             // It does not make sense to cut off the last line if we are
2392cdf0e10cSrcweir             // not moveable:
2393cdf0e10cSrcweir             bLastRowHasToMoveToFollow = false;
2394cdf0e10cSrcweir 
23950df44b11SOliver-Rainer Wittmann             continue;
23960df44b11SOliver-Rainer Wittmann         }
2397cdf0e10cSrcweir 
2398cdf0e10cSrcweir         if ( bCalcLowers && IsValid() )
23990df44b11SOliver-Rainer Wittmann         {
2400cdf0e10cSrcweir             lcl_RecalcTable( *this, 0, aNotify );
24010df44b11SOliver-Rainer Wittmann             bLowersFormatted = sal_True;
24020df44b11SOliver-Rainer Wittmann             bCalcLowers = sal_False;
2403cdf0e10cSrcweir             if( !IsValid() )
2404cdf0e10cSrcweir                 continue;
24050df44b11SOliver-Rainer Wittmann         }
2406cdf0e10cSrcweir 
2407cdf0e10cSrcweir         //
2408cdf0e10cSrcweir         // First try to split the table. Condition:
2409cdf0e10cSrcweir         // 1. We have at least one non headline row
2410cdf0e10cSrcweir         // 2. If this row wants to keep, we need an additional row
2411cdf0e10cSrcweir         // 3. The table is allowed to split or we do not have an pIndPrev:
2412cdf0e10cSrcweir         //
24139d3f73eaSOliver-Rainer Wittmann         SwFrm* pIndPrev = GetIndPrev();
2414cdf0e10cSrcweir         const SwRowFrm* pFirstNonHeadlineRow = GetFirstNonHeadlineRow();
24159d3f73eaSOliver-Rainer Wittmann         // #120016# if this row wants to keep, allow split in case that all rows want to keep with next,
24169d3f73eaSOliver-Rainer Wittmann         // the table can not move forward as it is the first one and a split is in general allowed.
24179d3f73eaSOliver-Rainer Wittmann         const bool bAllowSplitOfRow = ( bTableRowKeep &&
24189d3f73eaSOliver-Rainer Wittmann                                         AreAllRowsKeepWithNext( pFirstNonHeadlineRow ) ) &&
24199d3f73eaSOliver-Rainer Wittmann                                       !pIndPrev &&
24209d3f73eaSOliver-Rainer Wittmann                                       !bDontSplit;
2421cdf0e10cSrcweir 
2422cdf0e10cSrcweir         if ( pFirstNonHeadlineRow && nUnSplitted > 0 &&
24239d3f73eaSOliver-Rainer Wittmann              ( !bTableRowKeep || pFirstNonHeadlineRow->GetNext() || !pFirstNonHeadlineRow->ShouldRowKeepWithNext() || bAllowSplitOfRow ) &&
2424cdf0e10cSrcweir              ( !bDontSplit || !pIndPrev ) )
2425cdf0e10cSrcweir         {
2426cdf0e10cSrcweir             // --> FME 2004-06-03 #i29438#
2427cdf0e10cSrcweir             // Special DoNotSplit case:
2428cdf0e10cSrcweir             // We better avoid splitting of a row frame if we are inside a columned
2429cdf0e10cSrcweir             // section which has a height of 0, because this is not growable and thus
2430cdf0e10cSrcweir             // all kinds of unexpected things could happen.
2431cdf0e10cSrcweir             const SwSectionFrm* pTmpSct = 0;
2432cdf0e10cSrcweir             if ( IsInSct() &&
2433cdf0e10cSrcweir                 (pTmpSct = FindSctFrm())->Lower()->IsColumnFrm() &&
2434cdf0e10cSrcweir                 0 == (GetUpper()->Frm().*fnRect->fnGetHeight)()  )
2435cdf0e10cSrcweir             {
2436cdf0e10cSrcweir                 bTryToSplit = false;
2437cdf0e10cSrcweir             }
2438cdf0e10cSrcweir             // <--
2439cdf0e10cSrcweir 
2440cdf0e10cSrcweir             // 1. Try: bTryToSplit = true  => Try to split the row.
2441cdf0e10cSrcweir             // 2. Try: bTryToSplit = false => Split the table between the rows.
24429d3f73eaSOliver-Rainer Wittmann             if ( pFirstNonHeadlineRow->GetNext() || bTryToSplit )
2443cdf0e10cSrcweir             {
2444cdf0e10cSrcweir                 SwTwips nDeadLine = (GetUpper()->*fnRect->fnGetPrtBottom)();
2445cdf0e10cSrcweir                 if( IsInSct() || GetUpper()->IsInTab() ) // TABLE IN TABLE)
2446cdf0e10cSrcweir                     nDeadLine = (*fnRect->fnYInc)( nDeadLine,
2447cdf0e10cSrcweir                                         GetUpper()->Grow( LONG_MAX, sal_True ) );
2448cdf0e10cSrcweir 
24490df44b11SOliver-Rainer Wittmann                 {
24500df44b11SOliver-Rainer Wittmann                     SetInRecalcLowerRow( true );
24510df44b11SOliver-Rainer Wittmann                     ::lcl_RecalcRow( static_cast<SwRowFrm&>(*Lower()), nDeadLine );
24520df44b11SOliver-Rainer Wittmann                     SetInRecalcLowerRow( false );
24530df44b11SOliver-Rainer Wittmann                 }
2454cdf0e10cSrcweir                 bLowersFormatted = sal_True;
2455cdf0e10cSrcweir                 aNotify.SetLowersComplete( sal_True );
2456cdf0e10cSrcweir 
2457cdf0e10cSrcweir                 // One more check if its really necessary to split the table.
2458cdf0e10cSrcweir                 // 1. The table either has to exceed the deadline or
2459cdf0e10cSrcweir                 // 2. We explicitly want to cut off the last row.
2460cdf0e10cSrcweir                 if( (Frm().*fnRect->fnBottomDist)( nDeadLine ) > 0 && !bLastRowHasToMoveToFollow )
2461cdf0e10cSrcweir                 {
2462cdf0e10cSrcweir                     continue;
2463cdf0e10cSrcweir                 }
2464cdf0e10cSrcweir 
2465cdf0e10cSrcweir                 // Set to false again as early as possible.
2466cdf0e10cSrcweir                 bLastRowHasToMoveToFollow = false;
2467cdf0e10cSrcweir 
2468cdf0e10cSrcweir                 // --> FME 2005-08-03 #i52781#
2469cdf0e10cSrcweir                 // YaSC - Yet another special case:
2470cdf0e10cSrcweir                 // If our upper is inside a table cell which is not allowed
2471cdf0e10cSrcweir                 // to split, we do not try to split:
2472cdf0e10cSrcweir                 if ( GetUpper()->IsInTab() )
2473cdf0e10cSrcweir                 {
2474cdf0e10cSrcweir                     const SwFrm* pTmpRow = GetUpper();
2475cdf0e10cSrcweir                     while ( pTmpRow && !pTmpRow->IsRowFrm() )
2476cdf0e10cSrcweir                        pTmpRow = pTmpRow->GetUpper();
2477cdf0e10cSrcweir                     if ( pTmpRow && !static_cast<const SwRowFrm*>(pTmpRow)->IsRowSplitAllowed() )
2478cdf0e10cSrcweir                         continue;
2479cdf0e10cSrcweir                 }
2480cdf0e10cSrcweir                 // <--
2481cdf0e10cSrcweir 
2482cdf0e10cSrcweir                 sal_uInt16 nMinNumOfLines = nRepeat;
2483cdf0e10cSrcweir 
2484cdf0e10cSrcweir                 if ( bTableRowKeep )
2485cdf0e10cSrcweir                 {
2486cdf0e10cSrcweir                     const SwRowFrm* pTmpRow = pFirstNonHeadlineRow;
2487cdf0e10cSrcweir                     while ( pTmpRow && pTmpRow->ShouldRowKeepWithNext() )
2488cdf0e10cSrcweir                     {
2489cdf0e10cSrcweir                         ++nMinNumOfLines;
2490cdf0e10cSrcweir                         pTmpRow = static_cast<const SwRowFrm*>(pTmpRow->GetNext());
2491cdf0e10cSrcweir                     }
2492cdf0e10cSrcweir                     // Check if all lines want to keep together and we
2493cdf0e10cSrcweir                     // have a pIndPrev. In this case we set nDeadLine
2494cdf0e10cSrcweir                     // to 0, forcing the table to move forward.
2495cdf0e10cSrcweir                     if ( !pTmpRow && pIndPrev )
2496cdf0e10cSrcweir                         nDeadLine = 0;
2497cdf0e10cSrcweir                 }
2498cdf0e10cSrcweir 
2499cdf0e10cSrcweir                 if ( !bTryToSplit )
2500cdf0e10cSrcweir                     ++nMinNumOfLines;
2501cdf0e10cSrcweir 
2502cdf0e10cSrcweir                 const SwTwips nBreakLine = (*fnRect->fnYInc)(
2503cdf0e10cSrcweir                         (Frm().*fnRect->fnGetTop)(),
2504cdf0e10cSrcweir                         (this->*fnRect->fnGetTopMargin)() +
2505cdf0e10cSrcweir                          lcl_GetHeightOfRows( GetLower(), nMinNumOfLines ) );
2506cdf0e10cSrcweir 
2507cdf0e10cSrcweir                 // Some more checks if we want to call the split algorithm or not:
2508cdf0e10cSrcweir                 // The repeating lines / keeping lines still fit into the upper or
2509cdf0e10cSrcweir                 // if we do not have an (in)direkt Prev, we split anyway.
2510cdf0e10cSrcweir                 if( (*fnRect->fnYDiff)(nDeadLine, nBreakLine) >=0 || !pIndPrev )
2511cdf0e10cSrcweir                 {
2512cdf0e10cSrcweir                     aNotify.SetLowersComplete( sal_False );
2513cdf0e10cSrcweir                     bSplit = sal_True;
2514cdf0e10cSrcweir 
2515cdf0e10cSrcweir                     //
2516cdf0e10cSrcweir                     // An existing follow flow line has to be removed.
2517cdf0e10cSrcweir                     //
2518cdf0e10cSrcweir                     if ( HasFollowFlowLine() )
25199d3f73eaSOliver-Rainer Wittmann                     {
25209d3f73eaSOliver-Rainer Wittmann                         RemoveFollowFlowLine();
25219d3f73eaSOliver-Rainer Wittmann                     }
2522cdf0e10cSrcweir 
25239d3f73eaSOliver-Rainer Wittmann                     const bool bSplitError = !Split( nDeadLine, bTryToSplit, ( bTableRowKeep && !bAllowSplitOfRow ) );
25249d3f73eaSOliver-Rainer Wittmann                     if( !bTryToSplit && !bSplitError && nUnSplitted > 0 )
25259d3f73eaSOliver-Rainer Wittmann                     {
25269d3f73eaSOliver-Rainer Wittmann                         --nUnSplitted;
25279d3f73eaSOliver-Rainer Wittmann                     }
2528cdf0e10cSrcweir 
2529cdf0e10cSrcweir                     // --> FME 2004-06-09 #i29771# Two tries to split the table:
2530cdf0e10cSrcweir                     // If an error occured during splitting. We start a second
2531cdf0e10cSrcweir                     // try, this time without splitting of table rows.
2532cdf0e10cSrcweir                     if ( bSplitError )
2533cdf0e10cSrcweir                     {
2534cdf0e10cSrcweir                         if ( HasFollowFlowLine() )
2535cdf0e10cSrcweir                             RemoveFollowFlowLine();
2536cdf0e10cSrcweir                     }
2537cdf0e10cSrcweir 
2538cdf0e10cSrcweir                     // --> FME 2005-02-10 #119477#
2539cdf0e10cSrcweir                     // If splitting the table was successfull or not,
2540cdf0e10cSrcweir                     // we do not want to have 'empty' follow tables.
2541cdf0e10cSrcweir                     if ( GetFollow() && !GetFollow()->GetFirstNonHeadlineRow() )
2542cdf0e10cSrcweir                         Join();
2543cdf0e10cSrcweir                     // <--
2544cdf0e10cSrcweir 
2545cdf0e10cSrcweir 
2546cdf0e10cSrcweir                     // We want to restore the situation before the failed
2547cdf0e10cSrcweir                     // split operation as good as possible. Therefore we
2548cdf0e10cSrcweir                     // do some more calculations. Note: Restricting this
2549cdf0e10cSrcweir                     // to nDeadLine may not be enough.
2550cdf0e10cSrcweir                     if ( bSplitError && bTryToSplit ) // no restart if we did not try to split: i72847, i79426
2551cdf0e10cSrcweir                     {
2552cdf0e10cSrcweir                         lcl_RecalcRow( static_cast<SwRowFrm&>(*Lower()), LONG_MAX );
2553cdf0e10cSrcweir                         bValidPos = sal_False;
25549d3f73eaSOliver-Rainer Wittmann                         bTryToSplit = false;
2555cdf0e10cSrcweir                         continue;
2556cdf0e10cSrcweir                     }
2557cdf0e10cSrcweir                     // <--
2558cdf0e10cSrcweir 
25599d3f73eaSOliver-Rainer Wittmann                     bTryToSplit = !bSplitError;
2560cdf0e10cSrcweir 
2561cdf0e10cSrcweir                     //Damit es nicht zu Oszillationen kommt, muss der
2562cdf0e10cSrcweir                     //Follow gleich gueltig gemacht werden.
2563cdf0e10cSrcweir                     if ( GetFollow() )
2564cdf0e10cSrcweir                     {
2565cdf0e10cSrcweir                         // --> OD 2007-11-30 #i80924#
2566cdf0e10cSrcweir                         // After a successful split assure that the first row
2567cdf0e10cSrcweir                         // is invalid. When graphics are present, this isn't hold.
2568cdf0e10cSrcweir                         // Note: defect i80924 could also be fixed, if it is
2569cdf0e10cSrcweir                         // assured, that <SwLayNotify::bLowersComplete> is only
2570cdf0e10cSrcweir                         // set, if all lower are valid *and* are correct laid out.
2571cdf0e10cSrcweir                         if ( !bSplitError && GetFollow()->GetLower() )
2572cdf0e10cSrcweir                         {
2573cdf0e10cSrcweir                             GetFollow()->GetLower()->InvalidatePos();
2574cdf0e10cSrcweir                         }
2575cdf0e10cSrcweir                         // <--
2576cdf0e10cSrcweir                         SWRECTFNX( GetFollow() )
2577cdf0e10cSrcweir 
2578cdf0e10cSrcweir                         static sal_uInt8 nStack = 0;
2579cdf0e10cSrcweir                         if ( !StackHack::IsLocked() && nStack < 4 )
2580cdf0e10cSrcweir                         {
2581cdf0e10cSrcweir                             ++nStack;
2582cdf0e10cSrcweir                             StackHack aHack;
2583cdf0e10cSrcweir                             delete pAccess;
2584cdf0e10cSrcweir 
2585cdf0e10cSrcweir                             GetFollow()->MakeAll();
2586cdf0e10cSrcweir 
2587cdf0e10cSrcweir                             pAccess= new SwBorderAttrAccess( SwFrm::GetCache(), this );
2588cdf0e10cSrcweir                             pAttrs = pAccess->Get();
2589cdf0e10cSrcweir 
2590cdf0e10cSrcweir                             ((SwTabFrm*)GetFollow())->SetLowersFormatted(sal_False);
2591cdf0e10cSrcweir                             // --> OD 2005-03-30 #i43913# - lock follow table
2592cdf0e10cSrcweir                             // to avoid its formatting during the format of
2593cdf0e10cSrcweir                             // its content.
2594cdf0e10cSrcweir                             const bool bOldJoinLock =  GetFollow()->IsJoinLocked();
2595cdf0e10cSrcweir                             GetFollow()->LockJoin();
2596cdf0e10cSrcweir                             // <--
2597cdf0e10cSrcweir                             ::lcl_RecalcRow( static_cast<SwRowFrm&>(*GetFollow()->Lower()),
2598cdf0e10cSrcweir                                              (GetFollow()->GetUpper()->Frm().*fnRectX->fnGetBottom)() );
2599cdf0e10cSrcweir                             // --> OD 2005-03-30 #i43913#
2600cdf0e10cSrcweir                             // --> FME 2006-04-05 #i63632# Do not unlock the
2601cdf0e10cSrcweir                             // follow if it wasn't locked before.
2602cdf0e10cSrcweir                             if ( !bOldJoinLock )
2603cdf0e10cSrcweir                                 GetFollow()->UnlockJoin();
2604cdf0e10cSrcweir                             // <--
2605cdf0e10cSrcweir 
2606cdf0e10cSrcweir                             if ( !GetFollow()->GetFollow() )
2607cdf0e10cSrcweir                             {
2608cdf0e10cSrcweir                                 SwFrm* pNxt = ((SwFrm*)GetFollow())->FindNext();
2609cdf0e10cSrcweir                                 if ( pNxt )
2610cdf0e10cSrcweir                                 {
26110df44b11SOliver-Rainer Wittmann                                     // no formatting of found next frame, if its a follow
26120df44b11SOliver-Rainer Wittmann                                     // section of the 'ColLocked' section, the follow table is in.
2613cdf0e10cSrcweir                                     bool bCalcNxt = true;
2614cdf0e10cSrcweir                                     if ( GetFollow()->IsInSct() && pNxt->IsSctFrm() )
2615cdf0e10cSrcweir                                     {
2616cdf0e10cSrcweir                                         SwSectionFrm* pSct = GetFollow()->FindSctFrm();
2617cdf0e10cSrcweir                                         if ( pSct->IsColLocked() &&
2618cdf0e10cSrcweir                                              pSct->GetFollow() == pNxt )
2619cdf0e10cSrcweir                                         {
2620cdf0e10cSrcweir                                             bCalcNxt = false;
2621cdf0e10cSrcweir                                         }
2622cdf0e10cSrcweir                                     }
2623cdf0e10cSrcweir                                     if ( bCalcNxt )
2624cdf0e10cSrcweir                                     {
2625cdf0e10cSrcweir                                         pNxt->Calc();
2626cdf0e10cSrcweir                                     }
2627cdf0e10cSrcweir                                 }
2628cdf0e10cSrcweir                             }
2629cdf0e10cSrcweir                             --nStack;
2630cdf0e10cSrcweir                         }
2631cdf0e10cSrcweir                         else if ( GetFollow() == GetNext() )
2632cdf0e10cSrcweir                             ((SwTabFrm*)GetFollow())->MoveFwd( sal_True, sal_False );
2633cdf0e10cSrcweir                     }
2634cdf0e10cSrcweir                     continue;
2635cdf0e10cSrcweir                 }
2636cdf0e10cSrcweir             }
2637cdf0e10cSrcweir         }
2638cdf0e10cSrcweir 
2639cdf0e10cSrcweir         // Set to false again as early as possible.
2640cdf0e10cSrcweir         bLastRowHasToMoveToFollow = false;
2641cdf0e10cSrcweir 
26429d3f73eaSOliver-Rainer Wittmann         if( IsInSct() && bMovedFwd && bMakePage && GetUpper()->IsColBodyFrm() &&
26439d3f73eaSOliver-Rainer Wittmann             GetUpper()->GetUpper()->GetUpper()->IsSctFrm() &&
26449d3f73eaSOliver-Rainer Wittmann             ( GetUpper()->GetUpper()->GetPrev() || GetIndPrev() ) &&
26459d3f73eaSOliver-Rainer Wittmann             ((SwSectionFrm*)GetUpper()->GetUpper()->GetUpper())->MoveAllowed(this) )
26469d3f73eaSOliver-Rainer Wittmann         {
26479d3f73eaSOliver-Rainer Wittmann             bMovedFwd = sal_False;
26489d3f73eaSOliver-Rainer Wittmann         }
2649cdf0e10cSrcweir 
2650cdf0e10cSrcweir         // --> FME 2004-06-09 #i29771# Reset bTryToSplit flag on change of upper
2651cdf0e10cSrcweir         const SwFrm* pOldUpper = GetUpper();
2652cdf0e10cSrcweir         // <--
2653cdf0e10cSrcweir 
2654cdf0e10cSrcweir         //Mal sehen ob ich irgenwo Platz finde...
2655cdf0e10cSrcweir         if ( !bMovedFwd && !MoveFwd( bMakePage, sal_False ) )
2656cdf0e10cSrcweir             bMakePage = sal_False;
2657cdf0e10cSrcweir 
26580df44b11SOliver-Rainer Wittmann         // Reset bSplitError flag on change of upper
2659cdf0e10cSrcweir         if ( GetUpper() != pOldUpper )
26600df44b11SOliver-Rainer Wittmann         {
2661cdf0e10cSrcweir             bTryToSplit = true;
26620df44b11SOliver-Rainer Wittmann             nUnSplitted = 5;
26630df44b11SOliver-Rainer Wittmann         }
2664cdf0e10cSrcweir 
2665cdf0e10cSrcweir         SWREFRESHFN( this )
2666cdf0e10cSrcweir         bMovedFwd = bCalcLowers = sal_True;
2667cdf0e10cSrcweir         aNotify.SetLowersComplete( sal_False );
26680df44b11SOliver-Rainer Wittmann         if ( IsFollow() )
26690df44b11SOliver-Rainer Wittmann         {
26700df44b11SOliver-Rainer Wittmann             //Um Oszillationen zu vermeiden sollte kein ungueltiger Master
26710df44b11SOliver-Rainer Wittmann             //zurueckbleiben.
26720df44b11SOliver-Rainer Wittmann             SwTabFrm *pTab = FindMaster();
26730df44b11SOliver-Rainer Wittmann             if ( pTab->GetUpper() )
26740df44b11SOliver-Rainer Wittmann                 pTab->GetUpper()->Calc();
26750df44b11SOliver-Rainer Wittmann             pTab->Calc();
26760df44b11SOliver-Rainer Wittmann             pTab->SetLowersFormatted( sal_False );
26770df44b11SOliver-Rainer Wittmann         }
2678cdf0e10cSrcweir 
26790df44b11SOliver-Rainer Wittmann         //Wenn mein direkter Nachbar jetzt gleichzeitig mein Follow ist
26800df44b11SOliver-Rainer Wittmann         //verleibe ich mir das Teil ein.
26810df44b11SOliver-Rainer Wittmann         if ( ( GetNext() && GetNext() == GetFollow() ) || !GetLower() )
2682cdf0e10cSrcweir         {
2683cdf0e10cSrcweir             if ( HasFollowFlowLine() )
2684cdf0e10cSrcweir                 RemoveFollowFlowLine();
2685cdf0e10cSrcweir             if ( GetFollow() )
2686cdf0e10cSrcweir                 Join();
2687cdf0e10cSrcweir         }
2688cdf0e10cSrcweir 
26890df44b11SOliver-Rainer Wittmann         if ( bMovedBwd && GetUpper() )
26900df44b11SOliver-Rainer Wittmann         {
26910df44b11SOliver-Rainer Wittmann             //Beim zurueckfliessen wurde der Upper angeregt sich vollstaendig
26920df44b11SOliver-Rainer Wittmann             //zu Painten, dass koennen wir uns jetzt nach dem hin und her
26930df44b11SOliver-Rainer Wittmann             //fliessen sparen.
26940df44b11SOliver-Rainer Wittmann             GetUpper()->ResetCompletePaint();
26950df44b11SOliver-Rainer Wittmann         }
2696cdf0e10cSrcweir 
2697cdf0e10cSrcweir         if ( bCalcLowers && IsValid() )
26980df44b11SOliver-Rainer Wittmann         {
26990df44b11SOliver-Rainer Wittmann             // format of lower frames unnecessary and can cause layout loops,
27000df44b11SOliver-Rainer Wittmann             // if table doesn't fit and isn't  allowed to split.
2701cdf0e10cSrcweir             SwTwips nDistToUpperPrtBottom =
2702cdf0e10cSrcweir                 (Frm().*fnRect->fnBottomDist)( (GetUpper()->*fnRect->fnGetPrtBottom)());
2703cdf0e10cSrcweir             if ( nDistToUpperPrtBottom >= 0 || bTryToSplit )
2704cdf0e10cSrcweir             {
2705cdf0e10cSrcweir                 lcl_RecalcTable( *this, 0, aNotify );
2706cdf0e10cSrcweir                 bLowersFormatted = sal_True;
2707cdf0e10cSrcweir                 bCalcLowers = sal_False;
2708cdf0e10cSrcweir             }
2709cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
2710cdf0e10cSrcweir             else
2711cdf0e10cSrcweir             {
2712cdf0e10cSrcweir                 ASSERT( false, "debug assertion: <SwTabFrm::MakeAll()> - format of table lowers suppressed by fix i44910" );
2713cdf0e10cSrcweir             }
2714cdf0e10cSrcweir #endif
27150df44b11SOliver-Rainer Wittmann         }
2716cdf0e10cSrcweir 
27170df44b11SOliver-Rainer Wittmann     } //while ( !bValidPos || !bValidSize || !bValidPrtArea )
2718cdf0e10cSrcweir 
27190df44b11SOliver-Rainer Wittmann     //Wenn mein direkter Vorgaenger jetzt mein Master ist, so kann er mich
27200df44b11SOliver-Rainer Wittmann     //bei der nachstbesten Gelegenheit vernichten.
27210df44b11SOliver-Rainer Wittmann     if ( IsFollow() )
27220df44b11SOliver-Rainer Wittmann     {
27230df44b11SOliver-Rainer Wittmann         SwFrm *pPre = GetPrev();
27240df44b11SOliver-Rainer Wittmann         if ( pPre && pPre->IsTabFrm() && ((SwTabFrm*)pPre)->GetFollow() == this)
27250df44b11SOliver-Rainer Wittmann             pPre->InvalidatePos();
27260df44b11SOliver-Rainer Wittmann     }
2727cdf0e10cSrcweir 
27280df44b11SOliver-Rainer Wittmann     bCalcLowers = bONECalcLowers = sal_False;
27290df44b11SOliver-Rainer Wittmann     delete pAccess;
27300df44b11SOliver-Rainer Wittmann     UnlockJoin();
2731cdf0e10cSrcweir     if ( bMovedFwd || bMovedBwd || !bOldValidPos )
27320df44b11SOliver-Rainer Wittmann         aNotify.SetInvaKeep();
2733cdf0e10cSrcweir }
2734cdf0e10cSrcweir 
2735cdf0e10cSrcweir /*************************************************************************
2736cdf0e10cSrcweir |*
2737cdf0e10cSrcweir |*	SwTabFrm::CalcFlyOffsets()
2738cdf0e10cSrcweir |*
2739cdf0e10cSrcweir |*	Beschreibung:		Berechnet die Offsets, die durch FlyFrames
2740cdf0e10cSrcweir |*						entstehen.
2741cdf0e10cSrcweir |*	Ersterstellung		MA/MIB 14. Apr. 99
2742cdf0e10cSrcweir |*	Letzte Aenderung
2743cdf0e10cSrcweir |*
2744cdf0e10cSrcweir |*************************************************************************/
CalcFlyOffsets(SwTwips & rUpper,long & rLeftOffset,long & rRightOffset) const2745cdf0e10cSrcweir sal_Bool SwTabFrm::CalcFlyOffsets( SwTwips& rUpper,
2746cdf0e10cSrcweir 							   long& rLeftOffset,
2747cdf0e10cSrcweir 							   long& rRightOffset ) const
2748cdf0e10cSrcweir {
2749cdf0e10cSrcweir 	sal_Bool bInvalidatePrtArea = sal_False;
2750cdf0e10cSrcweir 	const SwPageFrm *pPage = FindPageFrm();
2751cdf0e10cSrcweir 	const SwFlyFrm* pMyFly = FindFlyFrm();
2752cdf0e10cSrcweir 
2753cdf0e10cSrcweir     // --> #108724# Page header/footer content doesn't have to wrap around
2754cdf0e10cSrcweir     //              floating screen objects
2755cdf0e10cSrcweir 
2756cdf0e10cSrcweir     const IDocumentSettingAccess* pIDSA = GetFmt()->getIDocumentSettingAccess();
2757cdf0e10cSrcweir     const bool bWrapAllowed = pIDSA->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING) ||
2758cdf0e10cSrcweir                                 ( !IsInFtn() && 0 == FindFooterOrHeader() );
2759cdf0e10cSrcweir     // <--
2760cdf0e10cSrcweir 
2761cdf0e10cSrcweir 	if ( pPage->GetSortedObjs() && bWrapAllowed )
2762cdf0e10cSrcweir 	{
2763cdf0e10cSrcweir         SWRECTFN( this )
2764cdf0e10cSrcweir         const bool bConsiderWrapOnObjPos = pIDSA->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION);
2765cdf0e10cSrcweir         long nPrtPos = (Frm().*fnRect->fnGetTop)();
2766cdf0e10cSrcweir         nPrtPos = (*fnRect->fnYInc)( nPrtPos, rUpper );
2767cdf0e10cSrcweir 		SwRect aRect( Frm() );
2768cdf0e10cSrcweir         long nYDiff = (*fnRect->fnYDiff)( (Prt().*fnRect->fnGetTop)(), rUpper );
2769cdf0e10cSrcweir         if( nYDiff > 0 )
2770cdf0e10cSrcweir             (aRect.*fnRect->fnAddBottom)( -nYDiff );
2771cdf0e10cSrcweir 		for ( sal_uInt16 i = 0; i < pPage->GetSortedObjs()->Count(); ++i )
2772cdf0e10cSrcweir 		{
2773cdf0e10cSrcweir             SwAnchoredObject* pAnchoredObj = (*pPage->GetSortedObjs())[i];
2774cdf0e10cSrcweir             if ( pAnchoredObj->ISA(SwFlyFrm) )
2775cdf0e10cSrcweir 			{
2776cdf0e10cSrcweir                 SwFlyFrm *pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
2777cdf0e10cSrcweir                 const SwRect aFlyRect = pFly->GetObjRectWithSpaces();
2778cdf0e10cSrcweir                 // --> OD 2004-10-07 #i26945# - correction of conditions,
2779cdf0e10cSrcweir                 // if Writer fly frame has to be considered:
2780cdf0e10cSrcweir                 // - no need to check, if top of Writer fly frame differs
2781cdf0e10cSrcweir                 //   from WEIT_WECH, because its also check, if the Writer
2782cdf0e10cSrcweir                 //   fly frame rectangle overlaps with <aRect>
2783cdf0e10cSrcweir                 // - no check, if bottom of anchor frame is prior the top of
2784cdf0e10cSrcweir                 //   the table, because Writer fly frames can be negative positioned.
2785cdf0e10cSrcweir                 // - correct check, if the Writer fly frame is an lower of the
2786cdf0e10cSrcweir                 //   table, because table lines/rows can split and a at-character
2787cdf0e10cSrcweir                 //   anchored Writer fly frame could be positioned in the follow
2788cdf0e10cSrcweir                 //   flow line.
2789cdf0e10cSrcweir                 // - add condition, that an existing anchor character text frame
2790cdf0e10cSrcweir                 //   has to be on the same page as the table.
2791cdf0e10cSrcweir                 //   E.g., it could happen, that the fly frame is still registered
2792cdf0e10cSrcweir                 //   at the page frame, the table is on, but it's anchor character
2793cdf0e10cSrcweir                 //   text frame has already changed its page.
2794cdf0e10cSrcweir                 //if ( WEIT_WECH != (pFly->Frm().*fnRect->fnGetTop)() &&
2795cdf0e10cSrcweir                 //     pFly->IsFlyAtCntFrm() && aFlyRect.IsOver( aRect ) &&
2796cdf0e10cSrcweir                 //     // OD 25.02.2003 #i9040# - use '<=' instead of '<'
2797cdf0e10cSrcweir                 //     (*fnRect->fnYDiff)(
2798cdf0e10cSrcweir                 //            (pFly->GetAnchorFrm()->Frm().*fnRect->fnGetBottom)(),
2799cdf0e10cSrcweir                 //            (Frm().*fnRect->fnGetTop)() ) <= 0 &&
2800cdf0e10cSrcweir                 //     !IsAnLower( pFly ) && !pFly->IsAnLower( this ) &&
2801cdf0e10cSrcweir                 //     ( !pMyFly || pMyFly->IsAnLower( pFly ) ) &&
2802cdf0e10cSrcweir                 //     pPage->GetPhyPageNum() >=
2803cdf0e10cSrcweir                 //     pFly->GetAnchorFrm()->FindPageFrm()->GetPhyPageNum() &&
2804cdf0e10cSrcweir                 //     // anchor should be in same page body/header/footer
2805cdf0e10cSrcweir                 //     ( pFly->GetAnchorFrm()->FindFooterOrHeader() ==
2806cdf0e10cSrcweir                 //       FindFooterOrHeader() ) )
2807cdf0e10cSrcweir                 const SwTxtFrm* pAnchorCharFrm = pFly->FindAnchorCharFrm();
2808cdf0e10cSrcweir                 bool bConsiderFly =
2809cdf0e10cSrcweir                     // --> OD 2005-04-06 #i46807# - do not consider invalid
2810cdf0e10cSrcweir                     // Writer fly frames.
2811cdf0e10cSrcweir                     pFly->IsValid() &&
2812cdf0e10cSrcweir                     // <--
2813cdf0e10cSrcweir                     // fly anchored at character
2814cdf0e10cSrcweir                     pFly->IsFlyAtCntFrm() &&
2815cdf0e10cSrcweir                     // fly overlaps with corresponding table rectangle
2816cdf0e10cSrcweir                     aFlyRect.IsOver( aRect ) &&
2817cdf0e10cSrcweir                     // fly isn't lower of table and
2818cdf0e10cSrcweir                     // anchor character frame of fly isn't lower of table
2819cdf0e10cSrcweir                     ( !IsAnLower( pFly ) &&
2820cdf0e10cSrcweir                       ( !pAnchorCharFrm || !IsAnLower( pAnchorCharFrm ) ) ) &&
2821cdf0e10cSrcweir                     // table isn't lower of fly
2822cdf0e10cSrcweir                     !pFly->IsAnLower( this ) &&
2823cdf0e10cSrcweir                     // fly is lower of fly, the table is in
2824cdf0e10cSrcweir                     // --> OD 2005-05-31 #123274# - correction:
2825cdf0e10cSrcweir                     // assure that fly isn't a lower of a fly, the table isn't in.
2826cdf0e10cSrcweir                     // E.g., a table in the body doesn't wrap around a graphic,
2827cdf0e10cSrcweir                     // which is inside a frame.
2828cdf0e10cSrcweir                     ( ( !pMyFly ||
2829cdf0e10cSrcweir                         pMyFly->IsAnLower( pFly ) ) &&
2830cdf0e10cSrcweir                       pMyFly == pFly->GetAnchorFrmContainingAnchPos()->FindFlyFrm() ) &&
2831cdf0e10cSrcweir                     // <--
2832cdf0e10cSrcweir                     // anchor frame not on following page
2833cdf0e10cSrcweir                     pPage->GetPhyPageNum() >=
2834cdf0e10cSrcweir                       pFly->GetAnchorFrm()->FindPageFrm()->GetPhyPageNum() &&
2835cdf0e10cSrcweir                     // anchor character text frame on same page
2836cdf0e10cSrcweir                     ( !pAnchorCharFrm ||
2837cdf0e10cSrcweir                       pAnchorCharFrm->FindPageFrm()->GetPhyPageNum() ==
2838cdf0e10cSrcweir                         pPage->GetPhyPageNum() );
2839cdf0e10cSrcweir 
2840cdf0e10cSrcweir                 if ( bConsiderFly )
2841cdf0e10cSrcweir                 {
2842cdf0e10cSrcweir                     const SwFrm* pFlyHeaderFooterFrm = pFly->GetAnchorFrm()->FindFooterOrHeader();
2843cdf0e10cSrcweir                     const SwFrm* pThisHeaderFooterFrm = FindFooterOrHeader();
2844cdf0e10cSrcweir 
2845cdf0e10cSrcweir                     if ( pFlyHeaderFooterFrm != pThisHeaderFooterFrm &&
2846cdf0e10cSrcweir                         // --> FME 2007-07-02 #148493# If bConsiderWrapOnObjPos is set,
2847cdf0e10cSrcweir                         // we want to consider the fly if it is located in the header and
2848cdf0e10cSrcweir                         // the table is located in the body:
2849cdf0e10cSrcweir                          ( !bConsiderWrapOnObjPos || 0 != pThisHeaderFooterFrm || !pFlyHeaderFooterFrm->IsHeaderFrm() ) )
2850cdf0e10cSrcweir                         bConsiderFly = false;
2851cdf0e10cSrcweir                         // <--
2852cdf0e10cSrcweir                 }
2853cdf0e10cSrcweir 
2854cdf0e10cSrcweir                 if ( bConsiderFly )
2855cdf0e10cSrcweir                 // <--
2856cdf0e10cSrcweir 				{
2857cdf0e10cSrcweir 					const SwFmtSurround   &rSur = pFly->GetFmt()->GetSurround();
2858cdf0e10cSrcweir 					const SwFmtHoriOrient &rHori= pFly->GetFmt()->GetHoriOrient();
2859cdf0e10cSrcweir 					if ( SURROUND_NONE == rSur.GetSurround() )
2860cdf0e10cSrcweir 					{
2861cdf0e10cSrcweir                         long nBottom = (aFlyRect.*fnRect->fnGetBottom)();
2862cdf0e10cSrcweir                         if( (*fnRect->fnYDiff)( nPrtPos, nBottom ) < 0 )
2863cdf0e10cSrcweir                             nPrtPos = nBottom;
2864cdf0e10cSrcweir 						bInvalidatePrtArea = sal_True;
2865cdf0e10cSrcweir 					}
2866cdf0e10cSrcweir 					if ( (SURROUND_RIGHT	== rSur.GetSurround() ||
2867cdf0e10cSrcweir 						  SURROUND_PARALLEL == rSur.GetSurround())&&
2868cdf0e10cSrcweir                          text::HoriOrientation::LEFT == rHori.GetHoriOrient() )
2869cdf0e10cSrcweir 					{
2870cdf0e10cSrcweir                         const long nWidth = (*fnRect->fnXDiff)(
2871cdf0e10cSrcweir                             (aFlyRect.*fnRect->fnGetRight)(),
2872cdf0e10cSrcweir                             (pFly->GetAnchorFrm()->Frm().*fnRect->fnGetLeft)() );
2873cdf0e10cSrcweir 						rLeftOffset = Max( rLeftOffset, nWidth );
2874cdf0e10cSrcweir 						bInvalidatePrtArea = sal_True;
2875cdf0e10cSrcweir 					}
2876cdf0e10cSrcweir 					if ( (SURROUND_LEFT		== rSur.GetSurround() ||
2877cdf0e10cSrcweir 						  SURROUND_PARALLEL == rSur.GetSurround())&&
2878cdf0e10cSrcweir                          text::HoriOrientation::RIGHT == rHori.GetHoriOrient() )
2879cdf0e10cSrcweir 					{
2880cdf0e10cSrcweir                         const long nWidth = (*fnRect->fnXDiff)(
2881cdf0e10cSrcweir                             (pFly->GetAnchorFrm()->Frm().*fnRect->fnGetRight)(),
2882cdf0e10cSrcweir                             (aFlyRect.*fnRect->fnGetLeft)() );
2883cdf0e10cSrcweir 						rRightOffset = Max( rRightOffset, nWidth );
2884cdf0e10cSrcweir 						bInvalidatePrtArea = sal_True;
2885cdf0e10cSrcweir 					}
2886cdf0e10cSrcweir 				}
2887cdf0e10cSrcweir 			}
2888cdf0e10cSrcweir 		}
2889cdf0e10cSrcweir         rUpper = (*fnRect->fnYDiff)( nPrtPos, (Frm().*fnRect->fnGetTop)() );
2890cdf0e10cSrcweir 	}
2891cdf0e10cSrcweir 
2892cdf0e10cSrcweir 	return bInvalidatePrtArea;
2893cdf0e10cSrcweir }
2894cdf0e10cSrcweir 
2895cdf0e10cSrcweir /*************************************************************************
2896cdf0e10cSrcweir |*
2897cdf0e10cSrcweir |*	SwTabFrm::Format()
2898cdf0e10cSrcweir |*
2899cdf0e10cSrcweir |*	Beschreibung:		"Formatiert" den Frame; Frm und PrtArea
2900cdf0e10cSrcweir |*						Die Fixsize wird hier nicht eingestellt.
2901cdf0e10cSrcweir |*	Ersterstellung		MA 09. Mar. 93
2902cdf0e10cSrcweir |*	Letzte Aenderung	MA 18. Jun. 97
2903cdf0e10cSrcweir |*
2904cdf0e10cSrcweir |*************************************************************************/
Format(const SwBorderAttrs * pAttrs)2905cdf0e10cSrcweir void SwTabFrm::Format( const SwBorderAttrs *pAttrs )
2906cdf0e10cSrcweir {
2907cdf0e10cSrcweir 	ASSERT( pAttrs, "TabFrm::Format, pAttrs ist 0." );
2908cdf0e10cSrcweir 
2909cdf0e10cSrcweir     SWRECTFN( this )
2910cdf0e10cSrcweir 	if ( !bValidSize )
2911cdf0e10cSrcweir     {
2912cdf0e10cSrcweir         long nDiff = (GetUpper()->Prt().*fnRect->fnGetWidth)() -
2913cdf0e10cSrcweir                      (Frm().*fnRect->fnGetWidth)();
2914cdf0e10cSrcweir         if( nDiff )
2915cdf0e10cSrcweir             (aFrm.*fnRect->fnAddRight)( nDiff );
2916cdf0e10cSrcweir     }
2917cdf0e10cSrcweir 
2918cdf0e10cSrcweir 	//VarSize ist immer die Hoehe.
2919cdf0e10cSrcweir 	//Fuer den oberen/unteren Rand gelten die selben Regeln wie fuer
2920cdf0e10cSrcweir 	//cntfrms (sie MakePrtArea() von diesen).
2921cdf0e10cSrcweir 
2922cdf0e10cSrcweir 	SwTwips nUpper = CalcUpperSpace( pAttrs );
2923cdf0e10cSrcweir 
2924cdf0e10cSrcweir 	//Wir wollen Rahmen ausweichen. Zwei Moeglichkeiten:
2925cdf0e10cSrcweir 	//1. Es gibt Rahmen mit SurroundNone, diesen wird vollsaendig ausgewichen
2926cdf0e10cSrcweir 	//2. Es gibt Rahmen mit Umlauf nur rechts bzw. nur links und diese sind
2927cdf0e10cSrcweir 	//   rechts bzw. links ausgerichtet, diese geben ein Minimum fuer die
2928cdf0e10cSrcweir 	//	 Raender vor.
2929cdf0e10cSrcweir 	long nTmpRight = -1000000,
2930cdf0e10cSrcweir 		 nLeftOffset  = 0;
2931cdf0e10cSrcweir 	if( CalcFlyOffsets( nUpper, nLeftOffset, nTmpRight ) )
2932cdf0e10cSrcweir 		bValidPrtArea = sal_False;
2933cdf0e10cSrcweir 	long nRightOffset = Max( 0L, nTmpRight );
2934cdf0e10cSrcweir 
2935cdf0e10cSrcweir 	SwTwips nLower = pAttrs->CalcBottomLine();
2936cdf0e10cSrcweir     // --> collapsing borders FME 2005-05-27 #i29550#
2937cdf0e10cSrcweir     if ( IsCollapsingBorders() )
2938cdf0e10cSrcweir         nLower += GetBottomLineSize();
2939cdf0e10cSrcweir     // <-- collapsing
2940cdf0e10cSrcweir 
2941cdf0e10cSrcweir     if ( !bValidPrtArea )
2942cdf0e10cSrcweir 	{	bValidPrtArea = sal_True;
2943cdf0e10cSrcweir 
2944cdf0e10cSrcweir 		//Die Breite der PrtArea wird vom FrmFmt vorgegeben, die Raender
2945cdf0e10cSrcweir 		//sind entsprechend einzustellen.
2946cdf0e10cSrcweir 		//Mindestraender werden von Umrandung und Schatten vorgegeben.
2947cdf0e10cSrcweir 		//Die Rander werden so eingestellt, dass die PrtArea nach dem
2948cdf0e10cSrcweir 		//angegebenen Adjustment im Frm ausgerichtet wird.
2949cdf0e10cSrcweir 		//Wenn das Adjustment 0 ist, so werden die Rander anhand des
2950cdf0e10cSrcweir 		//Randattributes eingestellt.
2951cdf0e10cSrcweir 
2952cdf0e10cSrcweir         const SwTwips nOldHeight = (Prt().*fnRect->fnGetHeight)();
2953cdf0e10cSrcweir         const SwTwips nMax = (aFrm.*fnRect->fnGetWidth)();
2954cdf0e10cSrcweir 
2955cdf0e10cSrcweir         // OD 14.03.2003 #i9040# - adjust variable names.
2956cdf0e10cSrcweir         const SwTwips nLeftLine  = pAttrs->CalcLeftLine();
2957cdf0e10cSrcweir         const SwTwips nRightLine = pAttrs->CalcRightLine();
2958cdf0e10cSrcweir 
2959cdf0e10cSrcweir 		//Die Breite ist evtl. eine Prozentangabe. Wenn die Tabelle irgendwo
2960cdf0e10cSrcweir 		//'drinsteckt bezieht sie sich auf die Umgebung. Ist es der Body, so
2961cdf0e10cSrcweir 		//bezieht sie sich in der BrowseView auf die Bildschirmbreite.
2962cdf0e10cSrcweir 		const SwFmtFrmSize &rSz = GetFmt()->GetFrmSize();
2963cdf0e10cSrcweir         // OD 14.03.2003 #i9040# - adjust variable name.
2964cdf0e10cSrcweir         const SwTwips nWishedTableWidth = CalcRel( rSz, sal_True );
2965cdf0e10cSrcweir 
2966cdf0e10cSrcweir 		sal_Bool bCheckBrowseWidth = sal_False;
2967cdf0e10cSrcweir 
2968cdf0e10cSrcweir         // OD 14.03.2003 #i9040# - insert new variables for left/right spacing.
2969cdf0e10cSrcweir         SwTwips nLeftSpacing  = 0;
2970cdf0e10cSrcweir         SwTwips nRightSpacing = 0;
2971cdf0e10cSrcweir         switch ( GetFmt()->GetHoriOrient().GetHoriOrient() )
2972cdf0e10cSrcweir 		{
2973cdf0e10cSrcweir             case text::HoriOrientation::LEFT:
2974cdf0e10cSrcweir 				{
2975cdf0e10cSrcweir                     // left indent:
2976cdf0e10cSrcweir                     nLeftSpacing = nLeftLine + nLeftOffset;
2977cdf0e10cSrcweir                     // OD 06.03.2003 #i9040# - correct calculation of right indent:
2978cdf0e10cSrcweir                     // - Consider right indent given by right line attributes.
2979cdf0e10cSrcweir                     // - Consider negative right indent.
2980cdf0e10cSrcweir                     // wished right indent determined by wished table width and
2981cdf0e10cSrcweir                     // left offset given by surround fly frames on the left:
2982cdf0e10cSrcweir                     const SwTwips nWishRight = nMax - nWishedTableWidth - nLeftOffset;
2983cdf0e10cSrcweir                     if ( nRightOffset > 0 )
2984cdf0e10cSrcweir                     {
2985cdf0e10cSrcweir                         // surrounding fly frames on the right
2986cdf0e10cSrcweir                         // -> right indent is maximun of given right offset
2987cdf0e10cSrcweir                         //    and wished right offset.
2988cdf0e10cSrcweir                         nRightSpacing = nRightLine + Max( nRightOffset, nWishRight );
2989cdf0e10cSrcweir                     }
2990cdf0e10cSrcweir                     else
2991cdf0e10cSrcweir                     {
2992cdf0e10cSrcweir                         // no surrounding fly frames on the right
2993cdf0e10cSrcweir                         // If intrinsic right indent (intrinsic means not considering
2994cdf0e10cSrcweir                         // determined left indent) is negative,
2995cdf0e10cSrcweir                         //      then hold this intrinsic indent,
2996cdf0e10cSrcweir                         //      otherwise non negative wished right indent is hold.
2997cdf0e10cSrcweir                         nRightSpacing = nRightLine +
2998cdf0e10cSrcweir                                         ( ( (nWishRight+nLeftOffset) < 0 ) ?
2999cdf0e10cSrcweir                                             (nWishRight+nLeftOffset) :
3000cdf0e10cSrcweir                                             Max( 0L, nWishRight ) );
3001cdf0e10cSrcweir                     }
3002cdf0e10cSrcweir 				}
3003cdf0e10cSrcweir 				break;
3004cdf0e10cSrcweir             case text::HoriOrientation::RIGHT:
3005cdf0e10cSrcweir 				{
3006cdf0e10cSrcweir                     // right indent:
3007cdf0e10cSrcweir                     nRightSpacing = nRightLine + nRightOffset;
3008cdf0e10cSrcweir                     // OD 06.03.2003 #i9040# - correct calculation of left indent:
3009cdf0e10cSrcweir                     // - Consider left indent given by left line attributes.
3010cdf0e10cSrcweir                     // - Consider negative left indent.
3011cdf0e10cSrcweir                     // wished left indent determined by wished table width and
3012cdf0e10cSrcweir                     // right offset given by surrounding fyl frames on the right:
3013cdf0e10cSrcweir                     const SwTwips nWishLeft = nMax - nWishedTableWidth - nRightOffset;
3014cdf0e10cSrcweir                     if ( nLeftOffset > 0 )
3015cdf0e10cSrcweir                     {
3016cdf0e10cSrcweir                         // surrounding fly frames on the left
3017cdf0e10cSrcweir                         // -> right indent is maximun of given left offset
3018cdf0e10cSrcweir                         //    and wished left offset.
3019cdf0e10cSrcweir                         nLeftSpacing = nLeftLine + Max( nLeftOffset, nWishLeft );
3020cdf0e10cSrcweir                     }
3021cdf0e10cSrcweir                     else
3022cdf0e10cSrcweir                     {
3023cdf0e10cSrcweir                         // no surrounding fly frames on the left
3024cdf0e10cSrcweir                         // If intrinsic left indent (intrinsic = not considering
3025cdf0e10cSrcweir                         // determined right indent) is negative,
3026cdf0e10cSrcweir                         //      then hold this intrinsic indent,
3027cdf0e10cSrcweir                         //      otherwise non negative wished left indent is hold.
3028cdf0e10cSrcweir                         nLeftSpacing = nLeftLine +
3029cdf0e10cSrcweir                                        ( ( (nWishLeft+nRightOffset) < 0 ) ?
3030cdf0e10cSrcweir                                            (nWishLeft+nRightOffset) :
3031cdf0e10cSrcweir                                            Max( 0L, nWishLeft ) );
3032cdf0e10cSrcweir                     }
3033cdf0e10cSrcweir 				}
3034cdf0e10cSrcweir 				break;
3035cdf0e10cSrcweir             case text::HoriOrientation::CENTER:
3036cdf0e10cSrcweir 				{
3037cdf0e10cSrcweir                     // OD 07.03.2003 #i9040# - consider left/right line attribute.
3038cdf0e10cSrcweir                     // OD 10.03.2003 #i9040# -
3039cdf0e10cSrcweir                     const SwTwips nCenterSpacing = ( nMax - nWishedTableWidth ) / 2;
3040cdf0e10cSrcweir                     nLeftSpacing = nLeftLine +
3041cdf0e10cSrcweir                                    ( (nLeftOffset > 0) ?
3042cdf0e10cSrcweir                                      Max( nCenterSpacing, nLeftOffset ) :
3043cdf0e10cSrcweir                                      nCenterSpacing );
3044cdf0e10cSrcweir                     nRightSpacing = nRightLine +
3045cdf0e10cSrcweir                                     ( (nRightOffset > 0) ?
3046cdf0e10cSrcweir                                       Max( nCenterSpacing, nRightOffset ) :
3047cdf0e10cSrcweir                                       nCenterSpacing );
3048cdf0e10cSrcweir 				}
3049cdf0e10cSrcweir 				break;
3050cdf0e10cSrcweir             case text::HoriOrientation::FULL:
3051cdf0e10cSrcweir 					//Das Teil dehnt sich ueber die gesamte Breite aus.
3052cdf0e10cSrcweir 					//Nur die fuer die Umrandung benoetigten Freiraeume
3053cdf0e10cSrcweir 					//werden beruecksichtigt.
3054cdf0e10cSrcweir 					//Die Attributwerte von LRSpace werden bewusst missachtet!
3055cdf0e10cSrcweir 					bCheckBrowseWidth = sal_True;
3056cdf0e10cSrcweir                     nLeftSpacing  = nLeftLine + nLeftOffset;
3057cdf0e10cSrcweir                     nRightSpacing = nRightLine + nRightOffset;
3058cdf0e10cSrcweir 				break;
3059cdf0e10cSrcweir             case text::HoriOrientation::NONE:
3060cdf0e10cSrcweir 				{
3061cdf0e10cSrcweir 					//Die Raender werden vom Randattribut bestimmt.
3062cdf0e10cSrcweir                     nLeftSpacing = pAttrs->CalcLeft( this );
3063cdf0e10cSrcweir 					if( nLeftOffset )
3064cdf0e10cSrcweir 					{
3065cdf0e10cSrcweir                         // OD 07.03.2003 #i9040# - surround fly frames only, if
3066cdf0e10cSrcweir                         // they overlap with the table.
3067cdf0e10cSrcweir                         // Thus, take maximun of left spacing and left offset.
3068cdf0e10cSrcweir                         // OD 10.03.2003 #i9040# - consider left line attribute.
3069cdf0e10cSrcweir                         nLeftSpacing = Max( nLeftSpacing, ( nLeftOffset + nLeftLine ) );
3070cdf0e10cSrcweir 					}
3071cdf0e10cSrcweir                     // OD 23.01.2003 #106895# - add 1st param to <SwBorderAttrs::CalcRight(..)>
3072cdf0e10cSrcweir                     nRightSpacing = pAttrs->CalcRight( this );
3073cdf0e10cSrcweir 					if( nRightOffset )
3074cdf0e10cSrcweir 					{
3075cdf0e10cSrcweir                         // OD 07.03.2003 #i9040# - surround fly frames only, if
3076cdf0e10cSrcweir                         // they overlap with the table.
3077cdf0e10cSrcweir                         // Thus, take maximun of right spacing and right offset.
3078cdf0e10cSrcweir                         // OD 10.03.2003 #i9040# - consider right line attribute.
3079cdf0e10cSrcweir                         nRightSpacing = Max( nRightSpacing, ( nRightOffset + nRightLine ) );
3080cdf0e10cSrcweir 					}
3081cdf0e10cSrcweir                     // OD 10.03.2003 #i9040# - do not hold wished table width.
3082cdf0e10cSrcweir                     /*
3083cdf0e10cSrcweir                     if ( !pAttrs->GetLRSpace().GetRight() )
3084cdf0e10cSrcweir 						nRight = Max( nRight, nMax - (nWish + nLeft + nRight));
3085cdf0e10cSrcweir                     */
3086cdf0e10cSrcweir 				}
3087cdf0e10cSrcweir 				break;
3088cdf0e10cSrcweir             case text::HoriOrientation::LEFT_AND_WIDTH:
3089cdf0e10cSrcweir                 {
3090cdf0e10cSrcweir 					//Linker Rand und die Breite zaehlen (Word-Spezialitaet)
3091cdf0e10cSrcweir                     // OD 10.03.2003 #i9040# - no width alignment in online mode.
3092cdf0e10cSrcweir                     //bCheckBrowseWidth = sal_True;
3093cdf0e10cSrcweir                     nLeftSpacing = pAttrs->CalcLeft( this );
3094cdf0e10cSrcweir 					if( nLeftOffset )
3095cdf0e10cSrcweir 					{
3096cdf0e10cSrcweir                         // OD 10.03.2003 #i9040# - surround fly frames only, if
3097cdf0e10cSrcweir                         // they overlap with the table.
3098cdf0e10cSrcweir                         // Thus, take maximun of right spacing and right offset.
3099cdf0e10cSrcweir                         // OD 10.03.2003 #i9040# - consider left line attribute.
3100cdf0e10cSrcweir                         nLeftSpacing = Max( nLeftSpacing, ( pAttrs->CalcLeftLine() + nLeftOffset ) );
3101cdf0e10cSrcweir 					}
3102cdf0e10cSrcweir                     // OD 10.03.2003 #i9040# - consider right and left line attribute.
3103cdf0e10cSrcweir                     const SwTwips nWishRight =
3104cdf0e10cSrcweir                             nMax - (nLeftSpacing-pAttrs->CalcLeftLine()) - nWishedTableWidth;
3105cdf0e10cSrcweir                     nRightSpacing = nRightLine +
3106cdf0e10cSrcweir                                     ( (nRightOffset > 0) ?
3107cdf0e10cSrcweir                                       Max( nWishRight, nRightOffset ) :
3108cdf0e10cSrcweir                                       nWishRight );
3109cdf0e10cSrcweir                 }
3110cdf0e10cSrcweir 				break;
3111cdf0e10cSrcweir 			default:
3112cdf0e10cSrcweir 				ASSERT( sal_False, "Ungueltige orientation fuer Table." );
3113cdf0e10cSrcweir 		}
3114cdf0e10cSrcweir 
3115cdf0e10cSrcweir         // --> OD 2004-07-15 #i26250# - extend bottom printing area, if table
3116cdf0e10cSrcweir         // is last content inside a table cell.
3117cdf0e10cSrcweir         if ( GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS) &&
3118cdf0e10cSrcweir              GetUpper()->IsInTab() && !GetIndNext() )
3119cdf0e10cSrcweir         {
3120cdf0e10cSrcweir             nLower += pAttrs->GetULSpace().GetLower();
3121cdf0e10cSrcweir         }
3122cdf0e10cSrcweir         // <--
3123cdf0e10cSrcweir         (this->*fnRect->fnSetYMargins)( nUpper, nLower );
3124cdf0e10cSrcweir         if( (nMax - MINLAY) < (nLeftSpacing + nRightSpacing) )
3125cdf0e10cSrcweir             (this->*fnRect->fnSetXMargins)( 0, 0 );
3126cdf0e10cSrcweir 		else
3127cdf0e10cSrcweir             (this->*fnRect->fnSetXMargins)( nLeftSpacing, nRightSpacing );
3128cdf0e10cSrcweir 
3129cdf0e10cSrcweir         ViewShell *pSh = getRootFrm()->GetCurrShell();
3130cdf0e10cSrcweir         if ( bCheckBrowseWidth &&
3131cdf0e10cSrcweir              pSh && pSh->GetViewOptions()->getBrowseMode() &&
3132cdf0e10cSrcweir 			 GetUpper()->IsPageBodyFrm() &&  // nur PageBodyFrms, nicht etwa ColBodyFrms
3133cdf0e10cSrcweir 			 pSh->VisArea().Width() )
3134cdf0e10cSrcweir 		{
3135cdf0e10cSrcweir 			//Nicht ueber die Kante des sichbaren Bereiches hinausragen.
3136cdf0e10cSrcweir 			//Die Seite kann breiter sein, weil es Objekte mit "ueberbreite"
3137cdf0e10cSrcweir 			//geben kann (RootFrm::ImplCalcBrowseWidth())
3138cdf0e10cSrcweir 			long nWidth = pSh->GetBrowseWidth();
3139cdf0e10cSrcweir 			nWidth -= Prt().Left();
3140cdf0e10cSrcweir 			nWidth -= pAttrs->CalcRightLine();
3141cdf0e10cSrcweir 			Prt().Width( Min( nWidth, Prt().Width() ) );
3142cdf0e10cSrcweir 		}
3143cdf0e10cSrcweir 
3144cdf0e10cSrcweir         if ( nOldHeight != (Prt().*fnRect->fnGetHeight)() )
3145cdf0e10cSrcweir 			bValidSize = sal_False;
3146cdf0e10cSrcweir 	}
3147cdf0e10cSrcweir 
3148cdf0e10cSrcweir 	if ( !bValidSize )
3149cdf0e10cSrcweir 	{
3150cdf0e10cSrcweir 		bValidSize = sal_True;
3151cdf0e10cSrcweir 
3152cdf0e10cSrcweir 		//Die Groesse wird durch den Inhalt plus den Raendern bestimmt.
3153cdf0e10cSrcweir 		SwTwips nRemaining = 0, nDiff;
3154cdf0e10cSrcweir 		SwFrm *pFrm = pLower;
3155cdf0e10cSrcweir 		while ( pFrm )
3156cdf0e10cSrcweir         {
3157cdf0e10cSrcweir             nRemaining += (pFrm->Frm().*fnRect->fnGetHeight)();
3158cdf0e10cSrcweir             pFrm = pFrm->GetNext();
3159cdf0e10cSrcweir 		}
3160cdf0e10cSrcweir 		//Jetzt noch die Raender addieren
3161cdf0e10cSrcweir 		nRemaining += nUpper + nLower;
3162cdf0e10cSrcweir 
3163cdf0e10cSrcweir         nDiff = (Frm().*fnRect->fnGetHeight)() - nRemaining;
3164cdf0e10cSrcweir         if ( nDiff > 0 )
3165cdf0e10cSrcweir             Shrink( nDiff );
3166cdf0e10cSrcweir 		else if ( nDiff < 0 )
3167cdf0e10cSrcweir             Grow( -nDiff );
3168cdf0e10cSrcweir 	}
3169cdf0e10cSrcweir }
3170cdf0e10cSrcweir /*************************************************************************
3171cdf0e10cSrcweir |*
3172cdf0e10cSrcweir |*	SwTabFrm::GrowFrm()
3173cdf0e10cSrcweir |*
3174cdf0e10cSrcweir |*	Ersterstellung		MA 12. Mar. 93
3175cdf0e10cSrcweir |*	Letzte Aenderung	MA 23. Sep. 96
3176cdf0e10cSrcweir |*
3177cdf0e10cSrcweir |*************************************************************************/
GrowFrm(SwTwips nDist,sal_Bool bTst,sal_Bool bInfo)3178cdf0e10cSrcweir SwTwips SwTabFrm::GrowFrm( SwTwips nDist, sal_Bool bTst, sal_Bool bInfo )
3179cdf0e10cSrcweir {
3180cdf0e10cSrcweir     SWRECTFN( this )
3181cdf0e10cSrcweir     SwTwips nHeight =(Frm().*fnRect->fnGetHeight)();
3182cdf0e10cSrcweir     if( nHeight > 0 && nDist > ( LONG_MAX - nHeight ) )
3183cdf0e10cSrcweir         nDist = LONG_MAX - nHeight;
3184cdf0e10cSrcweir 
3185cdf0e10cSrcweir     if ( bTst && !IsRestrictTableGrowth() )
3186cdf0e10cSrcweir         return nDist;
3187cdf0e10cSrcweir 
3188cdf0e10cSrcweir     if ( GetUpper() )
3189cdf0e10cSrcweir     {
3190cdf0e10cSrcweir         SwRect aOldFrm( Frm() );
3191cdf0e10cSrcweir 
3192cdf0e10cSrcweir         //Der Upper wird nur soweit wie notwendig gegrowed. In nReal wird erstmal
3193cdf0e10cSrcweir         //die bereits zur Verfuegung stehende Strecke bereitgestellt.
3194cdf0e10cSrcweir         SwTwips nReal = (GetUpper()->Prt().*fnRect->fnGetHeight)();
3195cdf0e10cSrcweir         SwFrm *pFrm = GetUpper()->Lower();
3196cdf0e10cSrcweir         while ( pFrm && GetFollow() != pFrm )
3197cdf0e10cSrcweir         {
3198cdf0e10cSrcweir             nReal -= (pFrm->Frm().*fnRect->fnGetHeight)();
3199cdf0e10cSrcweir             pFrm = pFrm->GetNext();
3200cdf0e10cSrcweir         }
3201cdf0e10cSrcweir 
3202cdf0e10cSrcweir         long nTmp = 0;
3203cdf0e10cSrcweir         if ( nReal < nDist )
3204cdf0e10cSrcweir         {
3205cdf0e10cSrcweir             nTmp = GetUpper()->Grow( nDist - ( nReal > 0 ? nReal : 0), bTst, bInfo );
3206cdf0e10cSrcweir 
3207cdf0e10cSrcweir             if ( IsRestrictTableGrowth() )
3208cdf0e10cSrcweir             {
3209cdf0e10cSrcweir                 nTmp = Min( nDist, nReal + nTmp );
3210cdf0e10cSrcweir                 nDist = nTmp < 0 ? 0 : nTmp;
3211cdf0e10cSrcweir             }
3212cdf0e10cSrcweir         }
3213cdf0e10cSrcweir 
3214cdf0e10cSrcweir         if ( !bTst )
3215cdf0e10cSrcweir         {
3216cdf0e10cSrcweir             (Frm().*fnRect->fnAddBottom)( nDist );
3217cdf0e10cSrcweir 
3218cdf0e10cSrcweir             SwRootFrm *pRootFrm = getRootFrm();
3219cdf0e10cSrcweir             if( pRootFrm && pRootFrm->IsAnyShellAccessible() &&
3220cdf0e10cSrcweir                 pRootFrm->GetCurrShell() )
3221cdf0e10cSrcweir             {
3222cdf0e10cSrcweir                 pRootFrm->GetCurrShell()->Imp()->MoveAccessibleFrm( this, aOldFrm );
3223cdf0e10cSrcweir             }
3224cdf0e10cSrcweir         }
3225cdf0e10cSrcweir     }
3226cdf0e10cSrcweir 
3227cdf0e10cSrcweir     if ( !bTst && ( nDist || IsRestrictTableGrowth() ) )
3228cdf0e10cSrcweir     {
3229cdf0e10cSrcweir         SwPageFrm *pPage = FindPageFrm();
3230cdf0e10cSrcweir         if ( GetNext() )
3231cdf0e10cSrcweir         {
3232cdf0e10cSrcweir             GetNext()->_InvalidatePos();
3233cdf0e10cSrcweir             if ( GetNext()->IsCntntFrm() )
3234cdf0e10cSrcweir                 GetNext()->InvalidatePage( pPage );
3235cdf0e10cSrcweir         }
3236cdf0e10cSrcweir         // --> OD 2004-07-05 #i28701# - Due to the new object positioning the
3237cdf0e10cSrcweir         // frame on the next page/column can flow backward (e.g. it was moved
3238cdf0e10cSrcweir         // forward due to the positioning of its objects ). Thus, invalivate this
3239cdf0e10cSrcweir         // next frame, if document compatibility option 'Consider wrapping style
3240cdf0e10cSrcweir         // influence on object positioning' is ON.
3241cdf0e10cSrcweir         else if ( GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) )
3242cdf0e10cSrcweir         {
3243cdf0e10cSrcweir             InvalidateNextPos();
3244cdf0e10cSrcweir         }
3245cdf0e10cSrcweir         // <--
3246cdf0e10cSrcweir         _InvalidateAll();
3247cdf0e10cSrcweir         InvalidatePage( pPage );
3248cdf0e10cSrcweir         SetComplete();
3249cdf0e10cSrcweir 
3250cdf0e10cSrcweir         const SvxGraphicPosition ePos = GetFmt()->GetBackground().GetGraphicPos();
3251cdf0e10cSrcweir         if ( GPOS_NONE != ePos && GPOS_TILED != ePos )
3252cdf0e10cSrcweir             SetCompletePaint();
3253cdf0e10cSrcweir     }
3254cdf0e10cSrcweir 
3255cdf0e10cSrcweir     return nDist;
3256cdf0e10cSrcweir }
3257cdf0e10cSrcweir /*************************************************************************
3258cdf0e10cSrcweir |*
3259cdf0e10cSrcweir |*	  SwTabFrm::Modify()
3260cdf0e10cSrcweir |*
3261cdf0e10cSrcweir |*	  Ersterstellung	MA 14. Mar. 93
3262cdf0e10cSrcweir |*	  Letzte Aenderung	MA 06. Dec. 96
3263cdf0e10cSrcweir |*
3264cdf0e10cSrcweir |*************************************************************************/
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)3265cdf0e10cSrcweir void SwTabFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
3266cdf0e10cSrcweir {
3267cdf0e10cSrcweir 	sal_uInt8 nInvFlags = 0;
3268cdf0e10cSrcweir 	sal_Bool bAttrSetChg = pNew && RES_ATTRSET_CHG == pNew->Which();
3269cdf0e10cSrcweir 
3270cdf0e10cSrcweir 	if( bAttrSetChg )
3271cdf0e10cSrcweir 	{
3272cdf0e10cSrcweir 		SfxItemIter aNIter( *((SwAttrSetChg*)pNew)->GetChgSet() );
3273cdf0e10cSrcweir 		SfxItemIter aOIter( *((SwAttrSetChg*)pOld)->GetChgSet() );
3274cdf0e10cSrcweir 		SwAttrSetChg aOldSet( *(SwAttrSetChg*)pOld );
3275cdf0e10cSrcweir 		SwAttrSetChg aNewSet( *(SwAttrSetChg*)pNew );
3276cdf0e10cSrcweir 		while( sal_True )
3277cdf0e10cSrcweir 		{
3278cdf0e10cSrcweir 			_UpdateAttr( (SfxPoolItem*)aOIter.GetCurItem(),
3279cdf0e10cSrcweir 						 (SfxPoolItem*)aNIter.GetCurItem(), nInvFlags,
3280cdf0e10cSrcweir 						 &aOldSet, &aNewSet );
3281cdf0e10cSrcweir 			if( aNIter.IsAtEnd() )
3282cdf0e10cSrcweir 				break;
3283cdf0e10cSrcweir 			aNIter.NextItem();
3284cdf0e10cSrcweir 			aOIter.NextItem();
3285cdf0e10cSrcweir 		}
3286cdf0e10cSrcweir 		if ( aOldSet.Count() || aNewSet.Count() )
3287cdf0e10cSrcweir 			SwLayoutFrm::Modify( &aOldSet, &aNewSet );
3288cdf0e10cSrcweir 	}
3289cdf0e10cSrcweir 	else
3290cdf0e10cSrcweir 		_UpdateAttr( pOld, pNew, nInvFlags );
3291cdf0e10cSrcweir 
3292cdf0e10cSrcweir 	if ( nInvFlags != 0 )
3293cdf0e10cSrcweir 	{
3294cdf0e10cSrcweir 		SwPageFrm *pPage = FindPageFrm();
3295cdf0e10cSrcweir 		InvalidatePage( pPage );
3296cdf0e10cSrcweir //		if ( nInvFlags & 0x01 )
3297cdf0e10cSrcweir //			SetCompletePaint();
3298cdf0e10cSrcweir 		if ( nInvFlags & 0x02 )
3299cdf0e10cSrcweir 			_InvalidatePrt();
3300cdf0e10cSrcweir 		if ( nInvFlags & 0x40 )
3301cdf0e10cSrcweir 			_InvalidatePos();
3302cdf0e10cSrcweir 		SwFrm *pTmp;
3303cdf0e10cSrcweir 		if ( 0 != (pTmp = GetIndNext()) )
3304cdf0e10cSrcweir 		{
3305cdf0e10cSrcweir 			if ( nInvFlags & 0x04 )
3306cdf0e10cSrcweir 			{
3307cdf0e10cSrcweir 				pTmp->_InvalidatePrt();
3308cdf0e10cSrcweir 				if ( pTmp->IsCntntFrm() )
3309cdf0e10cSrcweir 					pTmp->InvalidatePage( pPage );
3310cdf0e10cSrcweir 			}
3311cdf0e10cSrcweir 			if ( nInvFlags & 0x10 )
3312cdf0e10cSrcweir 				pTmp->SetCompletePaint();
3313cdf0e10cSrcweir 		}
3314cdf0e10cSrcweir 		if ( nInvFlags & 0x08 && 0 != (pTmp = GetPrev()) )
3315cdf0e10cSrcweir 		{
3316cdf0e10cSrcweir 			pTmp->_InvalidatePrt();
3317cdf0e10cSrcweir 			if ( pTmp->IsCntntFrm() )
3318cdf0e10cSrcweir 				pTmp->InvalidatePage( pPage );
3319cdf0e10cSrcweir 		}
3320cdf0e10cSrcweir 		if ( nInvFlags & 0x20  )
3321cdf0e10cSrcweir 		{
3322cdf0e10cSrcweir 			if ( pPage && pPage->GetUpper() && !IsFollow() )
3323cdf0e10cSrcweir 				((SwRootFrm*)pPage->GetUpper())->InvalidateBrowseWidth();
3324cdf0e10cSrcweir 		}
3325cdf0e10cSrcweir 		if ( nInvFlags & 0x80 )
3326cdf0e10cSrcweir 			InvalidateNextPos();
3327cdf0e10cSrcweir 	}
3328cdf0e10cSrcweir }
3329cdf0e10cSrcweir 
_UpdateAttr(const SfxPoolItem * pOld,const SfxPoolItem * pNew,sal_uInt8 & rInvFlags,SwAttrSetChg * pOldSet,SwAttrSetChg * pNewSet)3330cdf0e10cSrcweir void SwTabFrm::_UpdateAttr( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
3331cdf0e10cSrcweir 							sal_uInt8 &rInvFlags,
3332cdf0e10cSrcweir 							SwAttrSetChg *pOldSet, SwAttrSetChg *pNewSet )
3333cdf0e10cSrcweir {
3334cdf0e10cSrcweir 	sal_Bool bClear = sal_True;
3335cdf0e10cSrcweir 	const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
3336cdf0e10cSrcweir 	switch( nWhich )
3337cdf0e10cSrcweir 	{
3338cdf0e10cSrcweir 		case RES_TBLHEADLINECHG:
3339cdf0e10cSrcweir 			if ( IsFollow() )
3340cdf0e10cSrcweir 			{
3341cdf0e10cSrcweir                 // Delete remaining headlines:
3342cdf0e10cSrcweir                 SwRowFrm* pLowerRow = 0;
3343cdf0e10cSrcweir                 while ( 0 != ( pLowerRow = (SwRowFrm*)Lower() ) && pLowerRow->IsRepeatedHeadline() )
3344cdf0e10cSrcweir                 {
3345cdf0e10cSrcweir                     pLowerRow->Cut();
3346cdf0e10cSrcweir                     delete pLowerRow;
3347cdf0e10cSrcweir                 }
3348cdf0e10cSrcweir 
3349cdf0e10cSrcweir                 // insert new headlines
3350cdf0e10cSrcweir                 const sal_uInt16 nNewRepeat = GetTable()->GetRowsToRepeat();
3351cdf0e10cSrcweir                 for ( sal_uInt16 nIdx = 0; nIdx < nNewRepeat; ++nIdx )
3352cdf0e10cSrcweir                 {
3353cdf0e10cSrcweir                     bDontCreateObjects = sal_True;          //frmtool
3354cdf0e10cSrcweir                     SwRowFrm* pHeadline = new SwRowFrm( *GetTable()->GetTabLines()[ nIdx ], this );
3355cdf0e10cSrcweir                     pHeadline->SetRepeatedHeadline( true );
3356cdf0e10cSrcweir                     bDontCreateObjects = sal_False;
3357cdf0e10cSrcweir                     pHeadline->Paste( this, pLowerRow );
3358cdf0e10cSrcweir                 }
3359cdf0e10cSrcweir             }
3360cdf0e10cSrcweir             rInvFlags |= 0x02;
3361cdf0e10cSrcweir 			break;
3362cdf0e10cSrcweir 
3363cdf0e10cSrcweir 		case RES_FRM_SIZE:
3364cdf0e10cSrcweir 		case RES_HORI_ORIENT:
3365cdf0e10cSrcweir 			rInvFlags |= 0x22;
3366cdf0e10cSrcweir 			break;
3367cdf0e10cSrcweir 
3368cdf0e10cSrcweir 		case RES_PAGEDESC:						//Attributaenderung (an/aus)
3369cdf0e10cSrcweir 			if ( IsInDocBody() )
3370cdf0e10cSrcweir 			{
3371cdf0e10cSrcweir 				rInvFlags |= 0x40;
3372cdf0e10cSrcweir 				SwPageFrm *pPage = FindPageFrm();
3373cdf0e10cSrcweir 				if ( !GetPrev() )
3374cdf0e10cSrcweir 					CheckPageDescs( pPage );
3375cdf0e10cSrcweir 				if ( pPage && GetFmt()->GetPageDesc().GetNumOffset() )
3376cdf0e10cSrcweir 					((SwRootFrm*)pPage->GetUpper())->SetVirtPageNum( sal_True );
3377cdf0e10cSrcweir 				SwDocPosUpdate aMsgHnt( pPage->Frm().Top() );
3378cdf0e10cSrcweir 				GetFmt()->GetDoc()->UpdatePageFlds( &aMsgHnt );
3379cdf0e10cSrcweir 			}
3380cdf0e10cSrcweir 			break;
3381cdf0e10cSrcweir 
3382cdf0e10cSrcweir 		case RES_BREAK:
3383cdf0e10cSrcweir 			rInvFlags |= 0xC0;
3384cdf0e10cSrcweir 			break;
3385cdf0e10cSrcweir 
3386cdf0e10cSrcweir 		case RES_LAYOUT_SPLIT:
3387cdf0e10cSrcweir 			if ( !IsFollow() )
3388cdf0e10cSrcweir 				rInvFlags |= 0x40;
3389cdf0e10cSrcweir 			break;
3390cdf0e10cSrcweir         case RES_FRAMEDIR :
3391cdf0e10cSrcweir             SetDerivedR2L( sal_False );
3392cdf0e10cSrcweir             CheckDirChange();
3393cdf0e10cSrcweir             break;
3394cdf0e10cSrcweir         case RES_COLLAPSING_BORDERS :
3395cdf0e10cSrcweir     		rInvFlags |= 0x02;
3396cdf0e10cSrcweir             lcl_InvalidateAllLowersPrt( this );
3397cdf0e10cSrcweir             break;
3398cdf0e10cSrcweir 		case RES_UL_SPACE:
3399cdf0e10cSrcweir 			rInvFlags |= 0x1C;
3400cdf0e10cSrcweir 			/* kein Break hier */
3401cdf0e10cSrcweir 
3402cdf0e10cSrcweir 		default:
3403cdf0e10cSrcweir 			bClear = sal_False;
3404cdf0e10cSrcweir 	}
3405cdf0e10cSrcweir 	if ( bClear )
3406cdf0e10cSrcweir 	{
3407cdf0e10cSrcweir 		if ( pOldSet || pNewSet )
3408cdf0e10cSrcweir 		{
3409cdf0e10cSrcweir 			if ( pOldSet )
3410cdf0e10cSrcweir 				pOldSet->ClearItem( nWhich );
3411cdf0e10cSrcweir 			if ( pNewSet )
3412cdf0e10cSrcweir 				pNewSet->ClearItem( nWhich );
3413cdf0e10cSrcweir 		}
3414cdf0e10cSrcweir 		else
3415cdf0e10cSrcweir 			SwLayoutFrm::Modify( pOld, pNew );
3416cdf0e10cSrcweir 	}
3417cdf0e10cSrcweir }
3418cdf0e10cSrcweir 
3419cdf0e10cSrcweir /*************************************************************************
3420cdf0e10cSrcweir |*
3421cdf0e10cSrcweir |*	  SwTabFrm::GetInfo()
3422cdf0e10cSrcweir |*
3423cdf0e10cSrcweir |*	  Ersterstellung	MA 06. Dec. 96
3424cdf0e10cSrcweir |*	  Letzte Aenderung	MA 26. Jun. 98
3425cdf0e10cSrcweir |*
3426cdf0e10cSrcweir |*************************************************************************/
GetInfo(SfxPoolItem & rHnt) const3427cdf0e10cSrcweir sal_Bool SwTabFrm::GetInfo( SfxPoolItem &rHnt ) const
3428cdf0e10cSrcweir {
3429cdf0e10cSrcweir 	if ( RES_VIRTPAGENUM_INFO == rHnt.Which() && IsInDocBody() && !IsFollow() )
3430cdf0e10cSrcweir 	{
3431cdf0e10cSrcweir 		SwVirtPageNumInfo &rInfo = (SwVirtPageNumInfo&)rHnt;
3432cdf0e10cSrcweir 		const SwPageFrm *pPage = FindPageFrm();
3433cdf0e10cSrcweir 		if ( pPage  )
3434cdf0e10cSrcweir 		{
3435cdf0e10cSrcweir 			if ( pPage == rInfo.GetOrigPage() && !GetPrev() )
3436cdf0e10cSrcweir 			{
3437cdf0e10cSrcweir 				//Das sollte er sein (kann allenfalls temporaer anders sein,
3438cdf0e10cSrcweir 				//					  sollte uns das beunruhigen?)
3439cdf0e10cSrcweir 				rInfo.SetInfo( pPage, this );
3440cdf0e10cSrcweir 				return sal_False;
3441cdf0e10cSrcweir 			}
3442cdf0e10cSrcweir 			if ( pPage->GetPhyPageNum() < rInfo.GetOrigPage()->GetPhyPageNum() &&
3443cdf0e10cSrcweir 				 (!rInfo.GetPage() || pPage->GetPhyPageNum() > rInfo.GetPage()->GetPhyPageNum()))
3444cdf0e10cSrcweir 			{
3445cdf0e10cSrcweir 				//Das koennte er sein.
3446cdf0e10cSrcweir 				rInfo.SetInfo( pPage, this );
3447cdf0e10cSrcweir 			}
3448cdf0e10cSrcweir 		}
3449cdf0e10cSrcweir 	}
3450cdf0e10cSrcweir 	return sal_True;
3451cdf0e10cSrcweir }
3452cdf0e10cSrcweir 
3453cdf0e10cSrcweir /*************************************************************************
3454cdf0e10cSrcweir |*
3455cdf0e10cSrcweir |*	  SwTabFrm::FindLastCntnt()
3456cdf0e10cSrcweir |*
3457cdf0e10cSrcweir |*	  Ersterstellung	MA 13. Apr. 93
3458cdf0e10cSrcweir |*	  Letzte Aenderung	MA 15. May. 98
3459cdf0e10cSrcweir |*
3460cdf0e10cSrcweir |*************************************************************************/
FindLastCntnt()3461cdf0e10cSrcweir SwCntntFrm *SwTabFrm::FindLastCntnt()
3462cdf0e10cSrcweir {
3463cdf0e10cSrcweir 	SwFrm *pRet = pLower;
3464cdf0e10cSrcweir 
3465cdf0e10cSrcweir 	while ( pRet && !pRet->IsCntntFrm() )
3466cdf0e10cSrcweir 	{
3467cdf0e10cSrcweir 		SwFrm *pOld = pRet;
3468cdf0e10cSrcweir 
3469cdf0e10cSrcweir         SwFrm *pTmp = pRet;             // To skip empty section frames
3470cdf0e10cSrcweir 		while ( pRet->GetNext() )
3471cdf0e10cSrcweir         {
3472cdf0e10cSrcweir 			pRet = pRet->GetNext();
3473cdf0e10cSrcweir             if( !pRet->IsSctFrm() || ((SwSectionFrm*)pRet)->GetSection() )
3474cdf0e10cSrcweir                 pTmp = pRet;
3475cdf0e10cSrcweir         }
3476cdf0e10cSrcweir         pRet = pTmp;
3477cdf0e10cSrcweir 
3478cdf0e10cSrcweir 		if ( pRet->GetLower() )
3479cdf0e10cSrcweir 			pRet = pRet->GetLower();
3480cdf0e10cSrcweir 		if ( pRet == pOld )
3481cdf0e10cSrcweir         {
3482cdf0e10cSrcweir             // Wenn am Ende der letzten Zelle ein spaltiger Bereich steht,
3483cdf0e10cSrcweir 			// der eine leere letzte Spalte hat, muessen wir noch die anderen
3484cdf0e10cSrcweir 			// Spalten abklappern, dies erledigt SwSectionFrm::FindLastCntnt
3485cdf0e10cSrcweir 			if( pRet->IsColBodyFrm() )
3486cdf0e10cSrcweir 			{
3487cdf0e10cSrcweir #ifdef DBG_UTIL
3488cdf0e10cSrcweir 				SwSectionFrm* pSect = pRet->FindSctFrm();
3489cdf0e10cSrcweir 				ASSERT( pSect, "Wo kommt denn die Spalte her?")
3490cdf0e10cSrcweir 				ASSERT( IsAnLower( pSect ), "Gespaltene Zelle?" );
3491cdf0e10cSrcweir #endif
3492cdf0e10cSrcweir 				return pRet->FindSctFrm()->FindLastCntnt();
3493cdf0e10cSrcweir 			}
3494cdf0e10cSrcweir 
3495cdf0e10cSrcweir             //
3496cdf0e10cSrcweir             // pRet may be a cell frame without a lower (cell has been split).
3497cdf0e10cSrcweir             // We have to find the last content the hard way:
3498cdf0e10cSrcweir             //
3499cdf0e10cSrcweir             ASSERT( pRet->IsCellFrm(), "SwTabFrm::FindLastCntnt failed" )
3500cdf0e10cSrcweir             const SwFrm* pRow = pRet->GetUpper();
3501cdf0e10cSrcweir             while ( pRow && !pRow->GetUpper()->IsTabFrm() )
3502cdf0e10cSrcweir                 pRow = pRow->GetUpper();
3503cdf0e10cSrcweir             SwCntntFrm* pCntntFrm = ((SwLayoutFrm*)pRow)->ContainsCntnt();
3504cdf0e10cSrcweir             pRet = 0;
3505cdf0e10cSrcweir 
3506cdf0e10cSrcweir             while ( pCntntFrm && ((SwLayoutFrm*)pRow)->IsAnLower( pCntntFrm ) )
3507cdf0e10cSrcweir             {
3508cdf0e10cSrcweir                 pRet = pCntntFrm;
3509cdf0e10cSrcweir                 pCntntFrm = pCntntFrm->GetNextCntntFrm();
3510cdf0e10cSrcweir             }
3511cdf0e10cSrcweir         }
3512cdf0e10cSrcweir     }
3513cdf0e10cSrcweir 
3514cdf0e10cSrcweir     // #112929# There actually is a situation, which results in pRet = 0:
3515cdf0e10cSrcweir     // Insert frame, insert table via text <-> table. This gives you a frame
3516cdf0e10cSrcweir     // containing a table without any other content frames. Split the table
3517cdf0e10cSrcweir     // and undo the splitting. This operation gives us a table frame without
3518cdf0e10cSrcweir     // a lower.
3519cdf0e10cSrcweir     if ( pRet )
3520cdf0e10cSrcweir     {
3521cdf0e10cSrcweir         while ( pRet->GetNext() )
3522cdf0e10cSrcweir 			pRet = pRet->GetNext();
3523cdf0e10cSrcweir 
3524cdf0e10cSrcweir         if( pRet->IsSctFrm() )
3525cdf0e10cSrcweir 		    pRet = ((SwSectionFrm*)pRet)->FindLastCntnt();
3526cdf0e10cSrcweir     }
3527cdf0e10cSrcweir 
3528cdf0e10cSrcweir     return (SwCntntFrm*)pRet;
3529cdf0e10cSrcweir }
3530cdf0e10cSrcweir 
3531cdf0e10cSrcweir /*************************************************************************
3532cdf0e10cSrcweir |*
3533cdf0e10cSrcweir |*	SwTabFrm::GetLeaf()
3534cdf0e10cSrcweir |*
3535cdf0e10cSrcweir |*	Ersterstellung		MA 19. Mar. 93
3536cdf0e10cSrcweir |*	Letzte Aenderung	MA 25. Apr. 95
3537cdf0e10cSrcweir |*
3538cdf0e10cSrcweir |*************************************************************************/
GetLeaf(MakePageType eMakePage,sal_Bool bFwd)3539cdf0e10cSrcweir SwLayoutFrm *SwTabFrm::GetLeaf( MakePageType eMakePage, sal_Bool bFwd )
3540cdf0e10cSrcweir {
3541cdf0e10cSrcweir 	SwLayoutFrm *pRet;
3542cdf0e10cSrcweir 	if ( bFwd )
3543cdf0e10cSrcweir 	{
3544cdf0e10cSrcweir 		pRet = GetNextLeaf( eMakePage );
3545cdf0e10cSrcweir 		while ( IsAnLower( pRet ) )
3546cdf0e10cSrcweir 			pRet = pRet->GetNextLeaf( eMakePage );
3547cdf0e10cSrcweir 	}
3548cdf0e10cSrcweir 	else
3549cdf0e10cSrcweir 		pRet = GetPrevLeaf();
3550cdf0e10cSrcweir 	if ( pRet )
3551cdf0e10cSrcweir 		pRet->Calc();
3552cdf0e10cSrcweir 	return pRet;
3553cdf0e10cSrcweir }
3554cdf0e10cSrcweir 
3555cdf0e10cSrcweir /*************************************************************************
3556cdf0e10cSrcweir |*
3557cdf0e10cSrcweir |*	SwTabFrm::ShouldBwdMoved()
3558cdf0e10cSrcweir |*
3559cdf0e10cSrcweir |* 	Beschreibung		Returnwert sagt ob der Frm verschoben werden sollte
3560cdf0e10cSrcweir |*	Ersterstellung		MA 10. Jul. 95
3561cdf0e10cSrcweir |*	Letzte Aenderung	MA 04. Mar. 97
3562cdf0e10cSrcweir |*
3563cdf0e10cSrcweir |*************************************************************************/
ShouldBwdMoved(SwLayoutFrm * pNewUpper,sal_Bool,sal_Bool & rReformat)3564cdf0e10cSrcweir sal_Bool SwTabFrm::ShouldBwdMoved( SwLayoutFrm *pNewUpper, sal_Bool, sal_Bool &rReformat )
3565cdf0e10cSrcweir {
3566cdf0e10cSrcweir 	rReformat = sal_False;
3567cdf0e10cSrcweir 	if ( (SwFlowFrm::IsMoveBwdJump() || !IsPrevObjMove()) )
3568cdf0e10cSrcweir 	{
3569cdf0e10cSrcweir 		//Das zurueckfliessen von Frm's ist leider etwas Zeitintensiv.
3570cdf0e10cSrcweir 		//Der haufigste Fall ist der, dass dort wo der Frm hinfliessen
3571cdf0e10cSrcweir 		//moechte die FixSize die gleiche ist, die der Frm selbst hat.
3572cdf0e10cSrcweir 		//In diesem Fall kann einfach geprueft werden, ob der Frm genug
3573cdf0e10cSrcweir 		//Platz fuer seine VarSize findet, ist dies nicht der Fall kann
3574cdf0e10cSrcweir 		//gleich auf das Verschieben verzichtet werden.
3575cdf0e10cSrcweir 		//Die Pruefung, ob der Frm genug Platz findet fuehrt er selbst
3576cdf0e10cSrcweir 		//durch, dabei wird beruecksichtigt, dass er sich moeglicherweise
3577cdf0e10cSrcweir 		//aufspalten kann.
3578cdf0e10cSrcweir 		//Wenn jedoch die FixSize eine andere ist oder Flys im Spiel sind
3579cdf0e10cSrcweir 		//(an der alten oder neuen Position) hat alle Prueferei keinen Sinn
3580cdf0e10cSrcweir 		//der Frm muss dann halt Probehalber verschoben werden (Wenn ueberhaupt
3581cdf0e10cSrcweir 		//etwas Platz zur Verfuegung steht).
3582cdf0e10cSrcweir 
3583cdf0e10cSrcweir 		//Die FixSize der Umgebungen in denen Tabellen herumlungern ist immer
3584cdf0e10cSrcweir 		//Die Breite.
3585cdf0e10cSrcweir 
3586cdf0e10cSrcweir 		SwPageFrm *pOldPage = FindPageFrm(),
3587cdf0e10cSrcweir 				  *pNewPage = pNewUpper->FindPageFrm();
3588cdf0e10cSrcweir 		sal_Bool bMoveAnyway = sal_False;
3589cdf0e10cSrcweir 		SwTwips nSpace = 0;
3590cdf0e10cSrcweir 
3591cdf0e10cSrcweir         SWRECTFN( this )
3592cdf0e10cSrcweir         if ( !SwFlowFrm::IsMoveBwdJump() )
3593cdf0e10cSrcweir         {
3594cdf0e10cSrcweir 
3595cdf0e10cSrcweir             long nOldWidth = (GetUpper()->Prt().*fnRect->fnGetWidth)();
3596cdf0e10cSrcweir             SWRECTFNX( pNewUpper );
3597cdf0e10cSrcweir             long nNewWidth = (pNewUpper->Prt().*fnRectX->fnGetWidth)();
3598cdf0e10cSrcweir             if( Abs( nNewWidth - nOldWidth ) < 2 )
3599cdf0e10cSrcweir             {
3600cdf0e10cSrcweir                 if( sal_False ==
3601cdf0e10cSrcweir                     ( bMoveAnyway = BwdMoveNecessary( pOldPage, Frm() ) > 1 ) )
3602cdf0e10cSrcweir                 {
3603cdf0e10cSrcweir                     SwRect aRect( pNewUpper->Prt() );
3604cdf0e10cSrcweir                     aRect.Pos() += pNewUpper->Frm().Pos();
3605cdf0e10cSrcweir                     const SwFrm *pPrevFrm = pNewUpper->Lower();
3606cdf0e10cSrcweir                     while ( pPrevFrm && pPrevFrm != this )
3607cdf0e10cSrcweir                     {
3608cdf0e10cSrcweir                         (aRect.*fnRectX->fnSetTop)( (pPrevFrm->Frm().*fnRectX->
3609cdf0e10cSrcweir                                                     fnGetBottom)() );
3610cdf0e10cSrcweir                         pPrevFrm = pPrevFrm->GetNext();
3611cdf0e10cSrcweir                     }
3612cdf0e10cSrcweir                     bMoveAnyway = BwdMoveNecessary( pNewPage, aRect) > 1;
3613cdf0e10cSrcweir 
3614cdf0e10cSrcweir                     // --> FME 2006-01-20 #i54861# Due to changes made in PrepareMake,
3615cdf0e10cSrcweir                     // the tabfrm may not have a correct position. Therefore
3616cdf0e10cSrcweir                     // it is possible that pNewUpper->Prt().Height == 0. In this
3617cdf0e10cSrcweir                     // case the above calculation of nSpace might give wrong
3618cdf0e10cSrcweir                     // results and we really do not want to MoveBackwrd into a
3619cdf0e10cSrcweir                     // 0 height frame. If nTmpSpace is already <= 0, we take this
3620cdf0e10cSrcweir                     // value:
3621cdf0e10cSrcweir                     const SwTwips nTmpSpace = (aRect.*fnRectX->fnGetHeight)();
3622cdf0e10cSrcweir                     if ( (pNewUpper->Prt().*fnRectX->fnGetHeight)() > 0 || nTmpSpace <= 0 )
3623cdf0e10cSrcweir                         nSpace = nTmpSpace;
3624cdf0e10cSrcweir                     // <--
3625cdf0e10cSrcweir 
3626cdf0e10cSrcweir                     const ViewShell *pSh = getRootFrm()->GetCurrShell();
3627cdf0e10cSrcweir                     if( pSh && pSh->GetViewOptions()->getBrowseMode() )
3628cdf0e10cSrcweir                         nSpace += pNewUpper->Grow( LONG_MAX, sal_True );
3629cdf0e10cSrcweir                 }
3630cdf0e10cSrcweir             }
3631cdf0e10cSrcweir             else if( !bLockBackMove )
3632cdf0e10cSrcweir                 bMoveAnyway = sal_True;
3633cdf0e10cSrcweir 		}
3634cdf0e10cSrcweir         else if( !bLockBackMove )
3635cdf0e10cSrcweir 			bMoveAnyway = sal_True;
3636cdf0e10cSrcweir 
3637cdf0e10cSrcweir 		if ( bMoveAnyway )
3638cdf0e10cSrcweir 			return rReformat = sal_True;
3639cdf0e10cSrcweir 		else if ( !bLockBackMove && nSpace > 0 )
3640cdf0e10cSrcweir 		{
3641cdf0e10cSrcweir             // --> OD 2004-10-05 #i26945# - check, if follow flow line
3642cdf0e10cSrcweir             // contains frame, which are moved forward due to its object
3643cdf0e10cSrcweir             // positioning.
3644cdf0e10cSrcweir             SwRowFrm* pFirstRow = GetFirstNonHeadlineRow();
3645cdf0e10cSrcweir             if ( pFirstRow && pFirstRow->IsInFollowFlowRow() &&
3646cdf0e10cSrcweir                  SwLayouter::DoesRowContainMovedFwdFrm(
3647cdf0e10cSrcweir                                             *(pFirstRow->GetFmt()->GetDoc()),
3648cdf0e10cSrcweir                                             *(pFirstRow) ) )
3649cdf0e10cSrcweir             {
3650cdf0e10cSrcweir                 return sal_False;
3651cdf0e10cSrcweir             }
3652cdf0e10cSrcweir             // <--
3653cdf0e10cSrcweir             SwTwips nTmpHeight = CalcHeightOfFirstContentLine();
3654cdf0e10cSrcweir 
3655cdf0e10cSrcweir             // --> FME 2005-01-17 #118840#
3656cdf0e10cSrcweir             // For some mysterious reason, I changed the good old
3657cdf0e10cSrcweir             // 'return nHeight <= nSpace' to 'return nTmpHeight < nSpace'.
3658cdf0e10cSrcweir             // This obviously results in problems with table frames in
3659cdf0e10cSrcweir             // sections. Remember: Every twip is sacred.
3660cdf0e10cSrcweir             return nTmpHeight <= nSpace;
3661cdf0e10cSrcweir             // <--
3662cdf0e10cSrcweir         }
3663cdf0e10cSrcweir 	}
3664cdf0e10cSrcweir 	return sal_False;
3665cdf0e10cSrcweir }
3666cdf0e10cSrcweir 
3667cdf0e10cSrcweir /*************************************************************************
3668cdf0e10cSrcweir |*
3669cdf0e10cSrcweir |*	SwTabFrm::Cut()
3670cdf0e10cSrcweir |*
3671cdf0e10cSrcweir |*	Ersterstellung		MA 23. Feb. 94
3672cdf0e10cSrcweir |*	Letzte Aenderung	MA 09. Sep. 98
3673cdf0e10cSrcweir |*
3674cdf0e10cSrcweir |*************************************************************************/
Cut()3675cdf0e10cSrcweir void SwTabFrm::Cut()
3676cdf0e10cSrcweir {
3677cdf0e10cSrcweir 	ASSERT( GetUpper(), "Cut ohne Upper()." );
3678cdf0e10cSrcweir 
3679cdf0e10cSrcweir 	SwPageFrm *pPage = FindPageFrm();
3680cdf0e10cSrcweir 	InvalidatePage( pPage );
3681cdf0e10cSrcweir 	SwFrm *pFrm = GetNext();
3682cdf0e10cSrcweir 	if( pFrm )
3683cdf0e10cSrcweir 	{	//Der alte Nachfolger hat evtl. einen Abstand zum Vorgaenger
3684cdf0e10cSrcweir 		//berechnet der ist jetzt wo er der erste wird obsolete
3685cdf0e10cSrcweir 		pFrm->_InvalidatePrt();
3686cdf0e10cSrcweir 		pFrm->_InvalidatePos();
3687cdf0e10cSrcweir 		if ( pFrm->IsCntntFrm() )
3688cdf0e10cSrcweir 			pFrm->InvalidatePage( pPage );
3689cdf0e10cSrcweir 		if( IsInSct() && !GetPrev() )
3690cdf0e10cSrcweir 		{
3691cdf0e10cSrcweir 			SwSectionFrm* pSct = FindSctFrm();
3692cdf0e10cSrcweir 			if( !pSct->IsFollow() )
3693cdf0e10cSrcweir 			{
3694cdf0e10cSrcweir 				pSct->_InvalidatePrt();
3695cdf0e10cSrcweir 				pSct->InvalidatePage( pPage );
3696cdf0e10cSrcweir 			}
3697cdf0e10cSrcweir 		}
3698cdf0e10cSrcweir 	}
3699cdf0e10cSrcweir 	else
3700cdf0e10cSrcweir 	{
3701cdf0e10cSrcweir 		InvalidateNextPos();
3702cdf0e10cSrcweir 		//Einer muss die Retusche uebernehmen: Vorgaenger oder Upper
3703cdf0e10cSrcweir 		if ( 0 != (pFrm = GetPrev()) )
3704cdf0e10cSrcweir 		{	pFrm->SetRetouche();
3705cdf0e10cSrcweir 			pFrm->Prepare( PREP_WIDOWS_ORPHANS );
3706cdf0e10cSrcweir 			pFrm->_InvalidatePos();
3707cdf0e10cSrcweir 			if ( pFrm->IsCntntFrm() )
3708cdf0e10cSrcweir 				pFrm->InvalidatePage( pPage );
3709cdf0e10cSrcweir 		}
3710cdf0e10cSrcweir 		//Wenn ich der einzige FlowFrm in meinem Upper bin (war), so muss
3711cdf0e10cSrcweir 		//er die Retouche uebernehmen.
3712cdf0e10cSrcweir 		//Ausserdem kann eine Leerseite entstanden sein.
3713cdf0e10cSrcweir 		else
3714cdf0e10cSrcweir 		{	SwRootFrm *pRoot = (SwRootFrm*)pPage->GetUpper();
3715cdf0e10cSrcweir 			pRoot->SetSuperfluous();
3716cdf0e10cSrcweir 			GetUpper()->SetCompletePaint();
3717cdf0e10cSrcweir 			if( IsInSct() )
3718cdf0e10cSrcweir 			{
3719cdf0e10cSrcweir 				SwSectionFrm* pSct = FindSctFrm();
3720cdf0e10cSrcweir 				if( !pSct->IsFollow() )
3721cdf0e10cSrcweir 				{
3722cdf0e10cSrcweir 					pSct->_InvalidatePrt();
3723cdf0e10cSrcweir 					pSct->InvalidatePage( pPage );
3724cdf0e10cSrcweir 				}
3725cdf0e10cSrcweir 			}
3726cdf0e10cSrcweir 		}
3727cdf0e10cSrcweir 	}
3728cdf0e10cSrcweir 
3729cdf0e10cSrcweir 	//Erst removen, dann Upper Shrinken.
3730cdf0e10cSrcweir 	SwLayoutFrm *pUp = GetUpper();
3731cdf0e10cSrcweir     SWRECTFN( this )
3732cdf0e10cSrcweir 	Remove();
3733cdf0e10cSrcweir 	if ( pUp )
3734cdf0e10cSrcweir 	{
3735cdf0e10cSrcweir 		ASSERT( !pUp->IsFtnFrm(), "Tabelle in Fussnote." );
3736cdf0e10cSrcweir 		SwSectionFrm *pSct = 0;
3737cdf0e10cSrcweir         // --> OD 2006-01-04 #126020# - adjust check for empty section
3738cdf0e10cSrcweir         // --> OD 2006-02-01 #130797# - correct fix #126020#
3739cdf0e10cSrcweir         if ( !pUp->Lower() && pUp->IsInSct() &&
3740cdf0e10cSrcweir              !(pSct = pUp->FindSctFrm())->ContainsCntnt() &&
3741cdf0e10cSrcweir              !pSct->ContainsAny( true ) )
3742cdf0e10cSrcweir         // <--
3743cdf0e10cSrcweir 		{
3744cdf0e10cSrcweir 			if ( pUp->GetUpper() )
3745cdf0e10cSrcweir 			{
3746cdf0e10cSrcweir 				pSct->DelEmpty( sal_False );
3747cdf0e10cSrcweir 				pSct->_InvalidateSize();
3748cdf0e10cSrcweir 			}
3749cdf0e10cSrcweir 		}
3750cdf0e10cSrcweir         else if( (Frm().*fnRect->fnGetHeight)() )
3751cdf0e10cSrcweir         {
3752cdf0e10cSrcweir             // OD 26.08.2003 #i18103# - *no* 'ColUnlock' of section -
3753cdf0e10cSrcweir             // undo changes of fix for #104992#
3754cdf0e10cSrcweir             pUp->Shrink( Frm().Height() );
3755cdf0e10cSrcweir         }
3756cdf0e10cSrcweir 	}
3757cdf0e10cSrcweir 
3758cdf0e10cSrcweir 	if ( pPage && !IsFollow() && pPage->GetUpper() )
3759cdf0e10cSrcweir 		((SwRootFrm*)pPage->GetUpper())->InvalidateBrowseWidth();
3760cdf0e10cSrcweir }
3761cdf0e10cSrcweir 
3762cdf0e10cSrcweir /*************************************************************************
3763cdf0e10cSrcweir |*
3764cdf0e10cSrcweir |*	SwTabFrm::Paste()
3765cdf0e10cSrcweir |*
3766cdf0e10cSrcweir |*	Ersterstellung		MA 23. Feb. 94
3767cdf0e10cSrcweir |*	Letzte Aenderung	MA 09. Sep. 98
3768cdf0e10cSrcweir |*
3769cdf0e10cSrcweir |*************************************************************************/
Paste(SwFrm * pParent,SwFrm * pSibling)3770cdf0e10cSrcweir void SwTabFrm::Paste( SwFrm* pParent, SwFrm* pSibling )
3771cdf0e10cSrcweir {
3772cdf0e10cSrcweir 	ASSERT( pParent, "Kein Parent fuer Paste." );
3773cdf0e10cSrcweir 	ASSERT( pParent->IsLayoutFrm(), "Parent ist CntntFrm." );
3774cdf0e10cSrcweir 	ASSERT( pParent != this, "Bin selbst der Parent." );
3775cdf0e10cSrcweir 	ASSERT( pSibling != this, "Bin mein eigener Nachbar." );
3776cdf0e10cSrcweir 	ASSERT( !GetPrev() && !GetNext() && !GetUpper(),
3777cdf0e10cSrcweir 			"Bin noch irgendwo angemeldet." );
3778cdf0e10cSrcweir 
3779cdf0e10cSrcweir 	//In den Baum einhaengen.
3780cdf0e10cSrcweir 	InsertBefore( (SwLayoutFrm*)pParent, pSibling );
3781cdf0e10cSrcweir 
3782cdf0e10cSrcweir 	_InvalidateAll();
3783cdf0e10cSrcweir 	SwPageFrm *pPage = FindPageFrm();
3784cdf0e10cSrcweir 	InvalidatePage( pPage );
3785cdf0e10cSrcweir 
3786cdf0e10cSrcweir 	if ( GetNext() )
3787cdf0e10cSrcweir 	{
3788cdf0e10cSrcweir 		GetNext()->_InvalidatePos();
3789cdf0e10cSrcweir 		GetNext()->_InvalidatePrt();
3790cdf0e10cSrcweir 		if ( GetNext()->IsCntntFrm() )
3791cdf0e10cSrcweir 			GetNext()->InvalidatePage( pPage );
3792cdf0e10cSrcweir 	}
3793cdf0e10cSrcweir 
3794cdf0e10cSrcweir     SWRECTFN( this )
3795cdf0e10cSrcweir     if( (Frm().*fnRect->fnGetHeight)() )
3796cdf0e10cSrcweir         pParent->Grow( (Frm().*fnRect->fnGetHeight)() );
3797cdf0e10cSrcweir 
3798cdf0e10cSrcweir     if( (Frm().*fnRect->fnGetWidth)() != (pParent->Prt().*fnRect->fnGetWidth)() )
3799cdf0e10cSrcweir 		Prepare( PREP_FIXSIZE_CHG );
3800cdf0e10cSrcweir 	if ( GetPrev() )
3801cdf0e10cSrcweir 	{
3802cdf0e10cSrcweir 		if ( !IsFollow() )
3803cdf0e10cSrcweir 		{
3804cdf0e10cSrcweir 			GetPrev()->InvalidateSize();
3805cdf0e10cSrcweir 			if ( GetPrev()->IsCntntFrm() )
3806cdf0e10cSrcweir 				GetPrev()->InvalidatePage( pPage );
3807cdf0e10cSrcweir 		}
3808cdf0e10cSrcweir 	}
3809cdf0e10cSrcweir 	else if ( GetNext() )
3810cdf0e10cSrcweir 		//Bei CntntFrm's gilt es den Abstand zum Vorgaenger/Nachfolger
3811cdf0e10cSrcweir 		//zu beachten. Faelle (beide treten immer gleichzeitig auf):
3812cdf0e10cSrcweir 		//a) Der Cntnt wird der erste einer Kette
3813cdf0e10cSrcweir 		//b) Der neue Nachfolger war vorher der erste einer Kette
3814cdf0e10cSrcweir 		GetNext()->_InvalidatePrt();
3815cdf0e10cSrcweir 
3816cdf0e10cSrcweir 	if ( pPage && !IsFollow() )
3817cdf0e10cSrcweir 	{
3818cdf0e10cSrcweir 		if ( pPage->GetUpper() )
3819cdf0e10cSrcweir 			((SwRootFrm*)pPage->GetUpper())->InvalidateBrowseWidth();
3820cdf0e10cSrcweir 
3821cdf0e10cSrcweir 		if ( !GetPrev() )//Mindestens fuer HTML mit Tabelle am Anfang notwendig.
3822cdf0e10cSrcweir 		{
3823cdf0e10cSrcweir 			const SwPageDesc *pDesc = GetFmt()->GetPageDesc().GetPageDesc();
3824cdf0e10cSrcweir 			if ( (pDesc && pDesc != pPage->GetPageDesc()) ||
3825cdf0e10cSrcweir 				 (!pDesc && pPage->GetPageDesc() !=
3826cdf0e10cSrcweir                   &(const_cast<const SwDoc *>(GetFmt()->GetDoc())
3827cdf0e10cSrcweir                     ->GetPageDesc(0))) )
3828cdf0e10cSrcweir 				CheckPageDescs( pPage, sal_True );
3829cdf0e10cSrcweir 		}
3830cdf0e10cSrcweir 	}
3831cdf0e10cSrcweir }
3832cdf0e10cSrcweir 
3833cdf0e10cSrcweir /*************************************************************************
3834cdf0e10cSrcweir |*
3835cdf0e10cSrcweir |*  SwTabFrm::Prepare()
3836cdf0e10cSrcweir |*
3837cdf0e10cSrcweir |*  Created        AMA 01/10/02
3838cdf0e10cSrcweir |*  Last Change    AMA 01/10/02
3839cdf0e10cSrcweir |*
3840cdf0e10cSrcweir |*************************************************************************/
Prepare(const PrepareHint eHint,const void *,sal_Bool)3841cdf0e10cSrcweir void SwTabFrm::Prepare( const PrepareHint eHint, const void *, sal_Bool )
3842cdf0e10cSrcweir {
3843cdf0e10cSrcweir     if( PREP_BOSS_CHGD == eHint )
3844cdf0e10cSrcweir         CheckDirChange();
3845cdf0e10cSrcweir }
3846cdf0e10cSrcweir 
3847cdf0e10cSrcweir /*************************************************************************
3848cdf0e10cSrcweir |*
3849cdf0e10cSrcweir |*	SwRowFrm::SwRowFrm(), ~SwRowFrm()
3850cdf0e10cSrcweir |*
3851cdf0e10cSrcweir |*	Ersterstellung		MA 09. Mar. 93
3852cdf0e10cSrcweir |*	Letzte Aenderung	MA 30. May. 96
3853cdf0e10cSrcweir |*
3854cdf0e10cSrcweir |*************************************************************************/
SwRowFrm(const SwTableLine & rLine,SwFrm * pSib,bool bInsertContent)3855cdf0e10cSrcweir SwRowFrm::SwRowFrm( const SwTableLine &rLine, SwFrm* pSib, bool bInsertContent ):
3856cdf0e10cSrcweir 	SwLayoutFrm( rLine.GetFrmFmt(), pSib ),
3857cdf0e10cSrcweir     pTabLine( &rLine ),
3858cdf0e10cSrcweir     pFollowRow( 0 ),
3859cdf0e10cSrcweir     // --> collapsing borders FME 2005-05-27 #i29550#
3860cdf0e10cSrcweir     mnTopMarginForLowers( 0 ),
3861cdf0e10cSrcweir     mnBottomMarginForLowers( 0 ),
3862cdf0e10cSrcweir     mnBottomLineSize( 0 ),
3863cdf0e10cSrcweir     // <-- collapsing
3864cdf0e10cSrcweir     // --> split table rows
3865cdf0e10cSrcweir     bIsFollowFlowRow( false ),
3866cdf0e10cSrcweir     // <-- split table rows
3867cdf0e10cSrcweir     bIsRepeatedHeadline( false ),
3868cdf0e10cSrcweir     mbIsRowSpanLine( false )
3869cdf0e10cSrcweir {
3870cdf0e10cSrcweir     nType = FRMC_ROW;
3871cdf0e10cSrcweir 
3872cdf0e10cSrcweir 	//Gleich die Boxen erzeugen und einfuegen.
3873cdf0e10cSrcweir    	const SwTableBoxes &rBoxes = rLine.GetTabBoxes();
3874cdf0e10cSrcweir     SwFrm *pTmpPrev = 0;
3875cdf0e10cSrcweir   	for ( sal_uInt16 i = 0; i < rBoxes.Count(); ++i )
3876cdf0e10cSrcweir    	{
3877cdf0e10cSrcweir         SwCellFrm *pNew = new SwCellFrm( *rBoxes[i], this, bInsertContent );
3878cdf0e10cSrcweir         pNew->InsertBehind( this, pTmpPrev );
3879cdf0e10cSrcweir         pTmpPrev = pNew;
3880cdf0e10cSrcweir     }
3881cdf0e10cSrcweir }
3882cdf0e10cSrcweir 
~SwRowFrm()3883cdf0e10cSrcweir SwRowFrm::~SwRowFrm()
3884cdf0e10cSrcweir {
3885cdf0e10cSrcweir 	SwModify* pMod = GetFmt();
3886cdf0e10cSrcweir 	if( pMod )
3887cdf0e10cSrcweir 	{
3888cdf0e10cSrcweir 		pMod->Remove( this );			// austragen,
3889cdf0e10cSrcweir 		if( !pMod->GetDepends() )
3890cdf0e10cSrcweir 			delete pMod;				// und loeschen
3891cdf0e10cSrcweir 	}
3892cdf0e10cSrcweir }
3893cdf0e10cSrcweir 
3894cdf0e10cSrcweir /*************************************************************************
3895cdf0e10cSrcweir |*
3896cdf0e10cSrcweir |*	SwRowFrm::RegistFlys()
3897cdf0e10cSrcweir |*
3898cdf0e10cSrcweir |*	Ersterstellung		MA 08. Jul. 93
3899cdf0e10cSrcweir |*	Letzte Aenderung	MA 08. Jul. 93
3900cdf0e10cSrcweir |*
3901cdf0e10cSrcweir |*************************************************************************/
RegistFlys(SwPageFrm * pPage)3902cdf0e10cSrcweir void SwRowFrm::RegistFlys( SwPageFrm *pPage )
3903cdf0e10cSrcweir {
3904cdf0e10cSrcweir 	::RegistFlys( pPage ? pPage : FindPageFrm(), this );
3905cdf0e10cSrcweir }
3906cdf0e10cSrcweir 
3907cdf0e10cSrcweir /*************************************************************************
3908cdf0e10cSrcweir |*
3909cdf0e10cSrcweir |*	  SwRowFrm::Modify()
3910cdf0e10cSrcweir |*
3911cdf0e10cSrcweir |*	  Ersterstellung	MA 12. Nov. 97
3912cdf0e10cSrcweir |*	  Letzte Aenderung	MA 12. Nov. 97
3913cdf0e10cSrcweir |*
3914cdf0e10cSrcweir |*************************************************************************/
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)3915cdf0e10cSrcweir void SwRowFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
3916cdf0e10cSrcweir {
3917cdf0e10cSrcweir 	sal_Bool bAttrSetChg = pNew && RES_ATTRSET_CHG == pNew->Which();
3918cdf0e10cSrcweir 	const SfxPoolItem *pItem = 0;
3919cdf0e10cSrcweir 
3920cdf0e10cSrcweir 	if( bAttrSetChg )
3921cdf0e10cSrcweir     {
3922cdf0e10cSrcweir         const SwAttrSet* pChgSet = ((SwAttrSetChg*)pNew)->GetChgSet();
3923cdf0e10cSrcweir 		pChgSet->GetItemState( RES_FRM_SIZE, sal_False, &pItem);
3924cdf0e10cSrcweir         if ( !pItem )
3925cdf0e10cSrcweir             pChgSet->GetItemState( RES_ROW_SPLIT, sal_False, &pItem);
3926cdf0e10cSrcweir     }
3927cdf0e10cSrcweir     else if ( RES_FRM_SIZE == pNew->Which() || RES_ROW_SPLIT == pNew->Which() )
3928cdf0e10cSrcweir 		pItem = pNew;
3929cdf0e10cSrcweir 
3930cdf0e10cSrcweir 	if ( pItem )
3931cdf0e10cSrcweir 	{
3932cdf0e10cSrcweir 		SwTabFrm *pTab = FindTabFrm();
3933cdf0e10cSrcweir         if ( pTab )
3934cdf0e10cSrcweir         {
3935cdf0e10cSrcweir             const bool bInFirstNonHeadlineRow = pTab->IsFollow() &&
3936cdf0e10cSrcweir                                                 this == pTab->GetFirstNonHeadlineRow();
3937cdf0e10cSrcweir             // --> FME 2004-10-27 #i35063#
3938cdf0e10cSrcweir             // Invalidation required is pRow is last row
3939cdf0e10cSrcweir             if ( bInFirstNonHeadlineRow || !GetNext() )
3940cdf0e10cSrcweir             // <--
3941cdf0e10cSrcweir             {
3942cdf0e10cSrcweir                 if ( bInFirstNonHeadlineRow )
3943cdf0e10cSrcweir                     pTab = pTab->FindMaster();
3944cdf0e10cSrcweir                 pTab->InvalidatePos();
3945cdf0e10cSrcweir             }
3946cdf0e10cSrcweir         }
3947cdf0e10cSrcweir 	}
3948cdf0e10cSrcweir 
3949cdf0e10cSrcweir 	SwLayoutFrm::Modify( pOld, pNew );
3950cdf0e10cSrcweir }
3951cdf0e10cSrcweir 
3952cdf0e10cSrcweir 
3953cdf0e10cSrcweir 
3954cdf0e10cSrcweir /*************************************************************************
3955cdf0e10cSrcweir |*
3956cdf0e10cSrcweir |*	SwRowFrm::MakeAll()
3957cdf0e10cSrcweir |*
3958cdf0e10cSrcweir |*	Ersterstellung		MA 01. Mar. 94
3959cdf0e10cSrcweir |*	Letzte Aenderung	MA 01. Mar. 94
3960cdf0e10cSrcweir |*
3961cdf0e10cSrcweir |*************************************************************************/
MakeAll()3962cdf0e10cSrcweir void SwRowFrm::MakeAll()
3963cdf0e10cSrcweir {
3964cdf0e10cSrcweir 	if ( !GetNext() )
3965cdf0e10cSrcweir 		bValidSize = sal_False;
3966cdf0e10cSrcweir 	SwLayoutFrm::MakeAll();
3967cdf0e10cSrcweir }
3968cdf0e10cSrcweir 
3969cdf0e10cSrcweir /*************************************************************************
3970cdf0e10cSrcweir |*
3971cdf0e10cSrcweir |*	SwRowFrm::Format()
3972cdf0e10cSrcweir |*
3973cdf0e10cSrcweir |*	Ersterstellung		MA 13. Mar. 93
3974cdf0e10cSrcweir |*	Letzte Aenderung	MA 20. Jun. 96
3975cdf0e10cSrcweir |*
3976cdf0e10cSrcweir |*************************************************************************/
CalcHeightWidthFlys(const SwFrm * pFrm)3977cdf0e10cSrcweir long MA_FASTCALL CalcHeightWidthFlys( const SwFrm *pFrm )
3978cdf0e10cSrcweir {
3979cdf0e10cSrcweir     SWRECTFN( pFrm )
3980cdf0e10cSrcweir 	long nHeight = 0;
3981cdf0e10cSrcweir 	const SwFrm* pTmp = pFrm->IsSctFrm() ?
3982cdf0e10cSrcweir 			((SwSectionFrm*)pFrm)->ContainsCntnt() : pFrm;
3983cdf0e10cSrcweir 	while( pTmp )
3984cdf0e10cSrcweir 	{
3985cdf0e10cSrcweir         // --> OD 2004-10-08 #i26945# - consider follow text frames
3986cdf0e10cSrcweir         const SwSortedObjs* pObjs( 0L );
3987cdf0e10cSrcweir         bool bIsFollow( false );
3988cdf0e10cSrcweir         if ( pTmp->IsTxtFrm() && static_cast<const SwTxtFrm*>(pTmp)->IsFollow() )
3989cdf0e10cSrcweir         {
3990cdf0e10cSrcweir             const SwFrm* pMaster;
3991cdf0e10cSrcweir             // --> FME 2005-04-01 #i46450# Master does not necessarily have
3992cdf0e10cSrcweir             // to exist if this function is called from JoinFrm() ->
3993cdf0e10cSrcweir             // Cut() -> Shrink()
3994cdf0e10cSrcweir             const SwTxtFrm* pTmpFrm = static_cast<const SwTxtFrm*>(pTmp);
3995cdf0e10cSrcweir             if ( pTmpFrm->GetPrev() && pTmpFrm->GetPrev()->IsTxtFrm() &&
3996cdf0e10cSrcweir                  static_cast<const SwTxtFrm*>(pTmpFrm->GetPrev())->GetFollow() &&
3997cdf0e10cSrcweir                  static_cast<const SwTxtFrm*>(pTmpFrm->GetPrev())->GetFollow() != pTmp )
3998cdf0e10cSrcweir                  pMaster = 0;
3999cdf0e10cSrcweir             else
4000cdf0e10cSrcweir                  pMaster = pTmpFrm->FindMaster();
4001cdf0e10cSrcweir 
4002cdf0e10cSrcweir             if ( pMaster )
4003cdf0e10cSrcweir             {
4004cdf0e10cSrcweir                  pObjs = static_cast<const SwTxtFrm*>(pTmp)->FindMaster()->GetDrawObjs();
4005cdf0e10cSrcweir                 bIsFollow = true;
4006cdf0e10cSrcweir             }
4007cdf0e10cSrcweir         }
4008cdf0e10cSrcweir         else
4009cdf0e10cSrcweir         {
4010cdf0e10cSrcweir             pObjs = pTmp->GetDrawObjs();
4011cdf0e10cSrcweir         }
4012cdf0e10cSrcweir         if ( pObjs )
4013cdf0e10cSrcweir         // <--
4014cdf0e10cSrcweir 		{
4015cdf0e10cSrcweir             for ( sal_uInt16 i = 0; i < pObjs->Count(); ++i )
4016cdf0e10cSrcweir 			{
4017cdf0e10cSrcweir                 const SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
4018cdf0e10cSrcweir                 // --> OD 2004-10-08 #i26945# - if <pTmp> is follow, the
4019cdf0e10cSrcweir                 // anchor character frame has to be <pTmp>.
4020cdf0e10cSrcweir                 if ( bIsFollow &&
4021cdf0e10cSrcweir                      const_cast<SwAnchoredObject*>(pAnchoredObj)->FindAnchorCharFrm() != pTmp )
4022cdf0e10cSrcweir                 {
4023cdf0e10cSrcweir                     continue;
4024cdf0e10cSrcweir                 }
4025cdf0e10cSrcweir                 // <--
4026cdf0e10cSrcweir                 // --> OD 2004-10-04 #i26945# - consider also drawing objects
4027cdf0e10cSrcweir 				{
4028cdf0e10cSrcweir                     // OD 30.09.2003 #i18732# - only objects, which follow
4029cdf0e10cSrcweir                     // the text flow have to be considered.
4030cdf0e10cSrcweir                     const SwFrmFmt& rFrmFmt = pAnchoredObj->GetFrmFmt();
4031cdf0e10cSrcweir                     const bool bConsiderObj =
4032cdf0e10cSrcweir                         (rFrmFmt.GetAnchor().GetAnchorId() != FLY_AS_CHAR) &&
4033cdf0e10cSrcweir                             pAnchoredObj->GetObjRect().Top() != WEIT_WECH &&
4034cdf0e10cSrcweir                             rFrmFmt.GetFollowTextFlow().GetValue() &&
4035cdf0e10cSrcweir                             pAnchoredObj->GetPageFrm() == pTmp->FindPageFrm();
4036cdf0e10cSrcweir                     if ( bConsiderObj )
4037cdf0e10cSrcweir 					{
4038cdf0e10cSrcweir                         const SwFmtFrmSize &rSz = rFrmFmt.GetFrmSize();
4039cdf0e10cSrcweir 						if( !rSz.GetHeightPercent() )
4040cdf0e10cSrcweir                         {
4041cdf0e10cSrcweir                             const SwTwips nDistOfFlyBottomToAnchorTop =
4042cdf0e10cSrcweir                                 (pAnchoredObj->GetObjRect().*fnRect->fnGetHeight)() +
4043cdf0e10cSrcweir                                     ( bVert ?
4044cdf0e10cSrcweir                                       pAnchoredObj->GetCurrRelPos().X() :
4045cdf0e10cSrcweir                                       pAnchoredObj->GetCurrRelPos().Y() );
4046cdf0e10cSrcweir 
4047cdf0e10cSrcweir                             const SwTwips nFrmDiff =
4048cdf0e10cSrcweir                                 (*fnRect->fnYDiff)(
4049cdf0e10cSrcweir                                     (pTmp->Frm().*fnRect->fnGetTop)(),
4050cdf0e10cSrcweir                                     (pFrm->Frm().*fnRect->fnGetTop)() );
4051cdf0e10cSrcweir 
4052cdf0e10cSrcweir                             nHeight = Max( nHeight, nDistOfFlyBottomToAnchorTop + nFrmDiff -
4053cdf0e10cSrcweir                                             (pFrm->Frm().*fnRect->fnGetHeight)() );
4054cdf0e10cSrcweir 
4055cdf0e10cSrcweir                             // --> FME 2006-01-24 #i56115# The first height calculation
4056cdf0e10cSrcweir                             // gives wrong results if pFrm->Prt().Y() > 0. We do
4057cdf0e10cSrcweir                             // a second calculation based on the actual rectangles of
4058cdf0e10cSrcweir                             // pFrm and pAnchoredObj, and use the maximum of the results.
4059cdf0e10cSrcweir                             // I do not want to remove the first calculation because
4060cdf0e10cSrcweir                             // if clipping has been applied, using the GetCurrRelPos
4061cdf0e10cSrcweir                             // might be the better option to calculate nHeight.
4062cdf0e10cSrcweir                             const SwTwips nDistOfFlyBottomToAnchorTop2 = (*fnRect->fnYDiff)(
4063cdf0e10cSrcweir                                                                             (pAnchoredObj->GetObjRect().*fnRect->fnGetBottom)(),
4064cdf0e10cSrcweir                                                                             (pFrm->Frm().*fnRect->fnGetBottom)() );
4065cdf0e10cSrcweir 
4066cdf0e10cSrcweir                             nHeight = Max( nHeight, nDistOfFlyBottomToAnchorTop2 );
4067cdf0e10cSrcweir                             // <--
4068cdf0e10cSrcweir                         }
4069cdf0e10cSrcweir 					}
4070cdf0e10cSrcweir 				}
4071cdf0e10cSrcweir                 // <--
4072cdf0e10cSrcweir 			}
4073cdf0e10cSrcweir 		}
4074cdf0e10cSrcweir 		if( !pFrm->IsSctFrm() )
4075cdf0e10cSrcweir 			break;
4076cdf0e10cSrcweir 		pTmp = pTmp->FindNextCnt();
4077cdf0e10cSrcweir 		if( !((SwSectionFrm*)pFrm)->IsAnLower( pTmp ) )
4078cdf0e10cSrcweir 			break;
4079cdf0e10cSrcweir 	}
4080cdf0e10cSrcweir 	return nHeight;
4081cdf0e10cSrcweir }
4082cdf0e10cSrcweir 
lcl_CalcTopAndBottomMargin(const SwLayoutFrm & rCell,const SwBorderAttrs & rAttrs)4083cdf0e10cSrcweir SwTwips lcl_CalcTopAndBottomMargin( const SwLayoutFrm& rCell, const SwBorderAttrs& rAttrs )
4084cdf0e10cSrcweir {
4085cdf0e10cSrcweir     const SwTabFrm* pTab = rCell.FindTabFrm();
4086cdf0e10cSrcweir     SwTwips nTopSpace = 0;
4087cdf0e10cSrcweir     SwTwips nBottomSpace = 0;
4088cdf0e10cSrcweir 
4089cdf0e10cSrcweir     // --> collapsing borders FME 2005-05-27 #i29550#
4090cdf0e10cSrcweir     if ( pTab->IsCollapsingBorders() && rCell.Lower() && !rCell.Lower()->IsRowFrm() )
4091cdf0e10cSrcweir     {
4092cdf0e10cSrcweir         nTopSpace    = ((SwRowFrm*)rCell.GetUpper())->GetTopMarginForLowers();
4093cdf0e10cSrcweir         nBottomSpace = ((SwRowFrm*)rCell.GetUpper())->GetBottomMarginForLowers();
4094cdf0e10cSrcweir     }
4095cdf0e10cSrcweir     // <-- collapsing
4096cdf0e10cSrcweir     else
4097cdf0e10cSrcweir     {
4098cdf0e10cSrcweir         if ( pTab->IsVertical() != rCell.IsVertical() )
4099cdf0e10cSrcweir         {
4100cdf0e10cSrcweir             nTopSpace    = rAttrs.CalcLeft( &rCell );
4101cdf0e10cSrcweir             nBottomSpace = rAttrs.CalcRight( &rCell );
4102cdf0e10cSrcweir         }
4103cdf0e10cSrcweir         else
4104cdf0e10cSrcweir         {
4105cdf0e10cSrcweir             nTopSpace    = rAttrs.CalcTop();
4106cdf0e10cSrcweir             nBottomSpace = rAttrs.CalcBottom();
4107cdf0e10cSrcweir         }
4108cdf0e10cSrcweir     }
4109cdf0e10cSrcweir 
4110cdf0e10cSrcweir     return nTopSpace + nBottomSpace;
4111cdf0e10cSrcweir }
4112cdf0e10cSrcweir 
4113cdf0e10cSrcweir 
4114cdf0e10cSrcweir // --> OD 2004-10-04 #i26945# - add parameter <_bConsiderObjs> in order to
4115cdf0e10cSrcweir // control, if floating screen objects have to be considered for the minimal
4116cdf0e10cSrcweir // cell height.
lcl_CalcMinCellHeight(const SwLayoutFrm * _pCell,const sal_Bool _bConsiderObjs,const SwBorderAttrs * pAttrs=0)4117cdf0e10cSrcweir SwTwips MA_FASTCALL lcl_CalcMinCellHeight( const SwLayoutFrm *_pCell,
4118cdf0e10cSrcweir                                            const sal_Bool _bConsiderObjs,
4119cdf0e10cSrcweir                                            const SwBorderAttrs *pAttrs = 0 )
4120cdf0e10cSrcweir {
4121cdf0e10cSrcweir     SWRECTFN( _pCell )
4122cdf0e10cSrcweir 	SwTwips nHeight = 0;
4123cdf0e10cSrcweir     const SwFrm* pLow = _pCell->Lower();
4124cdf0e10cSrcweir 	if ( pLow )
4125cdf0e10cSrcweir 	{
4126cdf0e10cSrcweir 		long nFlyAdd = 0;
4127cdf0e10cSrcweir 		while ( pLow )
4128cdf0e10cSrcweir 		{
4129cdf0e10cSrcweir             // OD 2004-02-18 #106629# - change condition and switch then-body
4130cdf0e10cSrcweir             // and else-body
4131cdf0e10cSrcweir             if ( pLow->IsRowFrm() )
4132cdf0e10cSrcweir             {
4133cdf0e10cSrcweir                 // --> OD 2004-10-04 #i26945#
4134cdf0e10cSrcweir                 nHeight += ::lcl_CalcMinRowHeight( static_cast<const SwRowFrm*>(pLow),
4135cdf0e10cSrcweir                                                    _bConsiderObjs );
4136cdf0e10cSrcweir                 // <--
4137cdf0e10cSrcweir             }
4138cdf0e10cSrcweir             else
4139cdf0e10cSrcweir             {
4140cdf0e10cSrcweir                 long nLowHeight = (pLow->Frm().*fnRect->fnGetHeight)();
4141cdf0e10cSrcweir                 nHeight += nLowHeight;
4142cdf0e10cSrcweir                 // --> OD 2004-10-04 #i26945#
4143cdf0e10cSrcweir                 if ( _bConsiderObjs )
4144cdf0e10cSrcweir                 {
4145cdf0e10cSrcweir                     nFlyAdd = Max( 0L, nFlyAdd - nLowHeight );
4146cdf0e10cSrcweir                     nFlyAdd = Max( nFlyAdd, ::CalcHeightWidthFlys( pLow ) );
4147cdf0e10cSrcweir                 }
4148cdf0e10cSrcweir                 // <--
4149cdf0e10cSrcweir 			}
4150cdf0e10cSrcweir 
4151cdf0e10cSrcweir 			pLow = pLow->GetNext();
4152cdf0e10cSrcweir 		}
4153cdf0e10cSrcweir 		if ( nFlyAdd )
4154cdf0e10cSrcweir 			nHeight += nFlyAdd;
4155cdf0e10cSrcweir 	}
4156cdf0e10cSrcweir 	//Der Border will natuerlich auch mitspielen, er kann leider nicht
4157cdf0e10cSrcweir 	//aus PrtArea und Frm errechnet werden, da diese in beliebiger
4158cdf0e10cSrcweir 	//Kombination ungueltig sein koennen.
4159cdf0e10cSrcweir     if ( _pCell->Lower() )
4160cdf0e10cSrcweir     {
4161cdf0e10cSrcweir         if ( pAttrs )
4162cdf0e10cSrcweir             nHeight += lcl_CalcTopAndBottomMargin( *_pCell, *pAttrs );
4163cdf0e10cSrcweir         else
4164cdf0e10cSrcweir         {
4165cdf0e10cSrcweir             SwBorderAttrAccess aAccess( SwFrm::GetCache(), _pCell );
4166cdf0e10cSrcweir             const SwBorderAttrs &rAttrs = *aAccess.Get();
4167cdf0e10cSrcweir             nHeight += lcl_CalcTopAndBottomMargin( *_pCell, rAttrs );
4168cdf0e10cSrcweir         }
4169cdf0e10cSrcweir     }
4170cdf0e10cSrcweir     return nHeight;
4171cdf0e10cSrcweir }
4172cdf0e10cSrcweir 
4173cdf0e10cSrcweir // OD 2004-02-18 #106629# - correct type of 1st parameter
4174cdf0e10cSrcweir // --> OD 2004-10-04 #i26945# - add parameter <_bConsiderObjs> in order to control,
4175cdf0e10cSrcweir // if floating screen objects have to be considered for the minimal cell height
lcl_CalcMinRowHeight(const SwRowFrm * _pRow,const sal_Bool _bConsiderObjs)4176cdf0e10cSrcweir SwTwips MA_FASTCALL lcl_CalcMinRowHeight( const SwRowFrm* _pRow,
4177cdf0e10cSrcweir                                           const sal_Bool _bConsiderObjs )
4178cdf0e10cSrcweir {
4179cdf0e10cSrcweir     SWRECTFN( _pRow )
4180cdf0e10cSrcweir 
4181cdf0e10cSrcweir     const SwFmtFrmSize &rSz = _pRow->GetFmt()->GetFrmSize();
4182cdf0e10cSrcweir 
4183cdf0e10cSrcweir     if ( _pRow->HasFixSize() && !_pRow->IsRowSpanLine() )
4184cdf0e10cSrcweir     {
4185cdf0e10cSrcweir         ASSERT( ATT_FIX_SIZE == rSz.GetHeightSizeType(), "pRow claims to have fixed size" )
4186cdf0e10cSrcweir         return rSz.GetHeight();
4187cdf0e10cSrcweir     }
4188cdf0e10cSrcweir 
4189cdf0e10cSrcweir 	SwTwips nHeight = 0;
4190cdf0e10cSrcweir     const SwCellFrm* pLow = static_cast<const SwCellFrm*>(_pRow->Lower());
4191cdf0e10cSrcweir 	while ( pLow )
4192cdf0e10cSrcweir 	{
4193cdf0e10cSrcweir         SwTwips nTmp = 0;
4194cdf0e10cSrcweir         const long nRowSpan = pLow->GetLayoutRowSpan();
4195cdf0e10cSrcweir         // --> NEW TABLES
4196cdf0e10cSrcweir         // Consider height of
4197cdf0e10cSrcweir         // 1. current cell if RowSpan == 1
4198cdf0e10cSrcweir         // 2. current cell if cell is "follow" cell of a cell with RowSpan == -1
4199cdf0e10cSrcweir         // 3. master cell if RowSpan == -1
4200cdf0e10cSrcweir         if ( 1 == nRowSpan )
4201cdf0e10cSrcweir         {
4202cdf0e10cSrcweir             nTmp = ::lcl_CalcMinCellHeight( pLow, _bConsiderObjs );
4203cdf0e10cSrcweir         }
4204cdf0e10cSrcweir         else if ( -1 == nRowSpan )
4205cdf0e10cSrcweir         {
4206cdf0e10cSrcweir             // Height of the last cell of a row span is height of master cell
4207cdf0e10cSrcweir             // minus the height of the other rows which are covered by the master
4208cdf0e10cSrcweir             // cell:
4209cdf0e10cSrcweir             const SwCellFrm& rMaster = pLow->FindStartEndOfRowSpanCell( true, true );
4210cdf0e10cSrcweir             nTmp = ::lcl_CalcMinCellHeight( &rMaster, _bConsiderObjs );
4211cdf0e10cSrcweir             const SwFrm* pMasterRow = rMaster.GetUpper();
4212cdf0e10cSrcweir             while ( pMasterRow && pMasterRow != _pRow )
4213cdf0e10cSrcweir             {
4214cdf0e10cSrcweir                 nTmp -= (pMasterRow->Frm().*fnRect->fnGetHeight)();
4215cdf0e10cSrcweir                 pMasterRow = pMasterRow->GetNext();
4216cdf0e10cSrcweir             }
4217cdf0e10cSrcweir         }
4218cdf0e10cSrcweir         // <-- NEW TABLES
4219cdf0e10cSrcweir 
4220cdf0e10cSrcweir         // Do not consider rotated cells:
4221cdf0e10cSrcweir         if ( ( 0 != pLow->IsVertical() ) == ( 0 != bVert ) && nTmp > nHeight )
4222cdf0e10cSrcweir             nHeight = nTmp;
4223cdf0e10cSrcweir 
4224cdf0e10cSrcweir         pLow = static_cast<const SwCellFrm*>(pLow->GetNext());
4225cdf0e10cSrcweir 	}
4226cdf0e10cSrcweir     if ( rSz.GetHeightSizeType() == ATT_MIN_SIZE && !_pRow->IsRowSpanLine() )
4227cdf0e10cSrcweir 		nHeight = Max( nHeight, rSz.GetHeight() );
4228cdf0e10cSrcweir 	return nHeight;
4229cdf0e10cSrcweir }
4230cdf0e10cSrcweir 
4231cdf0e10cSrcweir // --> collapsing borders FME 2005-05-27 #i29550#
4232cdf0e10cSrcweir 
4233cdf0e10cSrcweir // Calculate the maximum of (TopLineSize + TopLineDist) over all lowers:
lcl_GetTopSpace(const SwRowFrm & rRow)4234cdf0e10cSrcweir sal_uInt16 lcl_GetTopSpace( const SwRowFrm& rRow )
4235cdf0e10cSrcweir {
4236cdf0e10cSrcweir     sal_uInt16 nTopSpace = 0;
4237cdf0e10cSrcweir     for ( SwCellFrm* pCurrLower = (SwCellFrm*)rRow.Lower(); pCurrLower;
4238cdf0e10cSrcweir           pCurrLower = (SwCellFrm*)pCurrLower->GetNext() )
4239cdf0e10cSrcweir     {
4240cdf0e10cSrcweir         sal_uInt16 nTmpTopSpace = 0;
4241cdf0e10cSrcweir         if ( pCurrLower->Lower() && pCurrLower->Lower()->IsRowFrm() )
4242cdf0e10cSrcweir             nTmpTopSpace = lcl_GetTopSpace( *(SwRowFrm*)pCurrLower->Lower() );
4243cdf0e10cSrcweir         else
4244cdf0e10cSrcweir         {
4245cdf0e10cSrcweir             const SwAttrSet& rSet = ((SwCellFrm*)pCurrLower)->GetFmt()->GetAttrSet();
4246cdf0e10cSrcweir             const SvxBoxItem& rBoxItem = rSet.GetBox();
4247cdf0e10cSrcweir             nTmpTopSpace = rBoxItem.CalcLineSpace( BOX_LINE_TOP, sal_True );
4248cdf0e10cSrcweir         }
4249cdf0e10cSrcweir         nTopSpace  = Max( nTopSpace, nTmpTopSpace );
4250cdf0e10cSrcweir     }
4251cdf0e10cSrcweir     return nTopSpace;
4252cdf0e10cSrcweir }
4253cdf0e10cSrcweir 
4254cdf0e10cSrcweir // Calculate the maximum of TopLineDist over all lowers:
lcl_GetTopLineDist(const SwRowFrm & rRow)4255cdf0e10cSrcweir sal_uInt16 lcl_GetTopLineDist( const SwRowFrm& rRow )
4256cdf0e10cSrcweir {
4257cdf0e10cSrcweir     sal_uInt16 nTopLineDist = 0;
4258cdf0e10cSrcweir     for ( SwCellFrm* pCurrLower = (SwCellFrm*)rRow.Lower(); pCurrLower;
4259cdf0e10cSrcweir           pCurrLower = (SwCellFrm*)pCurrLower->GetNext() )
4260cdf0e10cSrcweir     {
4261cdf0e10cSrcweir         sal_uInt16 nTmpTopLineDist = 0;
4262cdf0e10cSrcweir         if ( pCurrLower->Lower() && pCurrLower->Lower()->IsRowFrm() )
4263cdf0e10cSrcweir             nTmpTopLineDist = lcl_GetTopLineDist( *(SwRowFrm*)pCurrLower->Lower() );
4264cdf0e10cSrcweir         else
4265cdf0e10cSrcweir         {
4266cdf0e10cSrcweir             const SwAttrSet& rSet = ((SwCellFrm*)pCurrLower)->GetFmt()->GetAttrSet();
4267cdf0e10cSrcweir             const SvxBoxItem& rBoxItem = rSet.GetBox();
4268cdf0e10cSrcweir             nTmpTopLineDist = rBoxItem.GetDistance( BOX_LINE_TOP );
4269cdf0e10cSrcweir         }
4270cdf0e10cSrcweir         nTopLineDist = Max( nTopLineDist, nTmpTopLineDist );
4271cdf0e10cSrcweir     }
4272cdf0e10cSrcweir     return nTopLineDist;
4273cdf0e10cSrcweir }
4274cdf0e10cSrcweir 
4275cdf0e10cSrcweir // Calculate the maximum of BottomLineSize over all lowers:
lcl_GetBottomLineSize(const SwRowFrm & rRow)4276cdf0e10cSrcweir sal_uInt16 lcl_GetBottomLineSize( const SwRowFrm& rRow )
4277cdf0e10cSrcweir {
4278cdf0e10cSrcweir     sal_uInt16 nBottomLineSize = 0;
4279cdf0e10cSrcweir     for ( SwCellFrm* pCurrLower = (SwCellFrm*)rRow.Lower(); pCurrLower;
4280cdf0e10cSrcweir           pCurrLower = (SwCellFrm*)pCurrLower->GetNext() )
4281cdf0e10cSrcweir     {
4282cdf0e10cSrcweir         sal_uInt16 nTmpBottomLineSize = 0;
4283cdf0e10cSrcweir         if ( pCurrLower->Lower() && pCurrLower->Lower()->IsRowFrm() )
4284cdf0e10cSrcweir         {
4285cdf0e10cSrcweir             const SwFrm* pRow = pCurrLower->GetLastLower();
4286cdf0e10cSrcweir             nTmpBottomLineSize = lcl_GetBottomLineSize( *(SwRowFrm*)pRow );
4287cdf0e10cSrcweir         }
4288cdf0e10cSrcweir         else
4289cdf0e10cSrcweir         {
4290cdf0e10cSrcweir             const SwAttrSet& rSet = ((SwCellFrm*)pCurrLower)->GetFmt()->GetAttrSet();
4291cdf0e10cSrcweir             const SvxBoxItem& rBoxItem = rSet.GetBox();
4292cdf0e10cSrcweir             nTmpBottomLineSize = rBoxItem.CalcLineSpace( BOX_LINE_BOTTOM, sal_True ) -
4293cdf0e10cSrcweir                                  rBoxItem.GetDistance( BOX_LINE_BOTTOM );
4294cdf0e10cSrcweir         }
4295cdf0e10cSrcweir         nBottomLineSize = Max( nBottomLineSize, nTmpBottomLineSize );
4296cdf0e10cSrcweir     }
4297cdf0e10cSrcweir     return nBottomLineSize;
4298cdf0e10cSrcweir }
4299cdf0e10cSrcweir 
4300cdf0e10cSrcweir // Calculate the maximum of BottomLineDist over all lowers:
lcl_GetBottomLineDist(const SwRowFrm & rRow)4301cdf0e10cSrcweir sal_uInt16 lcl_GetBottomLineDist( const SwRowFrm& rRow )
4302cdf0e10cSrcweir {
4303cdf0e10cSrcweir     sal_uInt16 nBottomLineDist = 0;
4304cdf0e10cSrcweir     for ( SwCellFrm* pCurrLower = (SwCellFrm*)rRow.Lower(); pCurrLower;
4305cdf0e10cSrcweir           pCurrLower = (SwCellFrm*)pCurrLower->GetNext() )
4306cdf0e10cSrcweir     {
4307cdf0e10cSrcweir         sal_uInt16 nTmpBottomLineDist = 0;
4308cdf0e10cSrcweir         if ( pCurrLower->Lower() && pCurrLower->Lower()->IsRowFrm() )
4309cdf0e10cSrcweir         {
4310cdf0e10cSrcweir             const SwFrm* pRow = pCurrLower->GetLastLower();
4311cdf0e10cSrcweir             nTmpBottomLineDist = lcl_GetBottomLineDist( *(SwRowFrm*)pRow );
4312cdf0e10cSrcweir         }
4313cdf0e10cSrcweir         else
4314cdf0e10cSrcweir         {
4315cdf0e10cSrcweir             const SwAttrSet& rSet = ((SwCellFrm*)pCurrLower)->GetFmt()->GetAttrSet();
4316cdf0e10cSrcweir             const SvxBoxItem& rBoxItem = rSet.GetBox();
4317cdf0e10cSrcweir             nTmpBottomLineDist = rBoxItem.GetDistance( BOX_LINE_BOTTOM );
4318cdf0e10cSrcweir         }
4319cdf0e10cSrcweir         nBottomLineDist = Max( nBottomLineDist, nTmpBottomLineDist );
4320cdf0e10cSrcweir     }
4321cdf0e10cSrcweir     return nBottomLineDist;
4322cdf0e10cSrcweir }
4323cdf0e10cSrcweir 
4324cdf0e10cSrcweir // <-- collapsing
4325cdf0e10cSrcweir 
Format(const SwBorderAttrs * pAttrs)4326cdf0e10cSrcweir void SwRowFrm::Format( const SwBorderAttrs *pAttrs )
4327cdf0e10cSrcweir {
4328cdf0e10cSrcweir     SWRECTFN( this )
4329cdf0e10cSrcweir 	ASSERT( pAttrs, "SwRowFrm::Format ohne Attrs." );
4330cdf0e10cSrcweir 
4331cdf0e10cSrcweir     const sal_Bool bFix = bFixSize;
4332cdf0e10cSrcweir 
4333cdf0e10cSrcweir 	if ( !bValidPrtArea )
4334cdf0e10cSrcweir 	{
4335cdf0e10cSrcweir 		//RowFrms haben keine Umrandung usw. also entspricht die PrtArea immer
4336cdf0e10cSrcweir 		//dem Frm.
4337cdf0e10cSrcweir 		bValidPrtArea = sal_True;
4338cdf0e10cSrcweir 		aPrt.Left( 0 );
4339cdf0e10cSrcweir 		aPrt.Top( 0 );
4340cdf0e10cSrcweir 		aPrt.Width ( aFrm.Width() );
4341cdf0e10cSrcweir 		aPrt.Height( aFrm.Height() );
4342cdf0e10cSrcweir 
4343cdf0e10cSrcweir         // --> collapsing borders FME 2005-05-27 #i29550#
4344cdf0e10cSrcweir         // Here we calculate the top-printing area for the lower cell frames
4345cdf0e10cSrcweir         SwTabFrm* pTabFrm = FindTabFrm();
4346cdf0e10cSrcweir         if ( pTabFrm->IsCollapsingBorders() )
4347cdf0e10cSrcweir         {
4348cdf0e10cSrcweir             const sal_uInt16 nTopSpace        = lcl_GetTopSpace(       *this );
4349cdf0e10cSrcweir             const sal_uInt16 nTopLineDist     = lcl_GetTopLineDist(    *this );
4350cdf0e10cSrcweir             const sal_uInt16 nBottomLineSize  = lcl_GetBottomLineSize( *this );
4351cdf0e10cSrcweir             const sal_uInt16 nBottomLineDist  = lcl_GetBottomLineDist( *this );
4352cdf0e10cSrcweir 
4353cdf0e10cSrcweir 
4354cdf0e10cSrcweir             const SwRowFrm* pPreviousRow = 0;
4355cdf0e10cSrcweir 
4356cdf0e10cSrcweir             // --> FME 2004-09-14 #i32456#
4357cdf0e10cSrcweir             // In order to calculate the top printing area for the lower cell
4358cdf0e10cSrcweir             // frames, we have to find the 'previous' row frame and compare
4359cdf0e10cSrcweir             // the bottom values of the 'previous' row with the 'top' values
4360cdf0e10cSrcweir             // of this row. The best way to find the 'previous' row is to
4361cdf0e10cSrcweir             // use the table structure:
4362cdf0e10cSrcweir             const SwTable* pTable = pTabFrm->GetTable();
4363cdf0e10cSrcweir             const SwTableLine* pPrevTabLine = 0;
4364cdf0e10cSrcweir             const SwRowFrm* pTmpRow = this;
4365cdf0e10cSrcweir 
4366cdf0e10cSrcweir             while ( pTmpRow && !pPrevTabLine )
4367cdf0e10cSrcweir             {
4368cdf0e10cSrcweir                 sal_uInt16 nIdx = 0;
4369cdf0e10cSrcweir                 const SwTableLines& rLines = pTmpRow->GetTabLine()->GetUpper() ?
4370cdf0e10cSrcweir                                              pTmpRow->GetTabLine()->GetUpper()->GetTabLines() :
4371cdf0e10cSrcweir                                              pTable->GetTabLines();
4372cdf0e10cSrcweir 
4373cdf0e10cSrcweir                 while ( rLines[ nIdx ] != pTmpRow->GetTabLine() )
4374cdf0e10cSrcweir                     ++nIdx;
4375cdf0e10cSrcweir 
4376cdf0e10cSrcweir                 if ( nIdx > 0 )
4377cdf0e10cSrcweir                 {
4378cdf0e10cSrcweir                     // pTmpRow has a 'previous' row in the table structure:
4379cdf0e10cSrcweir                     pPrevTabLine = rLines[ nIdx - 1 ];
4380cdf0e10cSrcweir                 }
4381cdf0e10cSrcweir                 else
4382cdf0e10cSrcweir                 {
4383cdf0e10cSrcweir                     // pTmpRow is a first row in the table structue.
4384cdf0e10cSrcweir                     // We go up in the table structure:
4385cdf0e10cSrcweir                     pTmpRow = pTmpRow->GetUpper()->GetUpper() &&
4386cdf0e10cSrcweir                               pTmpRow->GetUpper()->GetUpper()->IsRowFrm() ?
4387cdf0e10cSrcweir                               static_cast<const SwRowFrm*>( pTmpRow->GetUpper()->GetUpper() ) :
4388cdf0e10cSrcweir                               0;
4389cdf0e10cSrcweir                 }
4390cdf0e10cSrcweir             }
4391cdf0e10cSrcweir 
4392cdf0e10cSrcweir             // If we found a 'previous' row, we look for the appropriate row frame:
4393cdf0e10cSrcweir             if ( pPrevTabLine )
4394cdf0e10cSrcweir             {
4395cdf0e10cSrcweir                 SwIterator<SwRowFrm,SwFmt> aIter( *pPrevTabLine->GetFrmFmt() );
4396cdf0e10cSrcweir                 for ( SwRowFrm* pRow = aIter.First(); pRow; pRow = aIter.Next() )
4397cdf0e10cSrcweir                 {
4398cdf0e10cSrcweir                     // --> OD 2004-11-23 #115759# - do *not* take repeated
4399cdf0e10cSrcweir                     // headlines, because during split of table it can be
4400cdf0e10cSrcweir                     // invalid and thus can't provide correct border values.
4401cdf0e10cSrcweir                     if ( pRow->GetTabLine() == pPrevTabLine &&
4402cdf0e10cSrcweir                          !pRow->IsRepeatedHeadline() )
4403cdf0e10cSrcweir                     // <--
4404cdf0e10cSrcweir                     {
4405cdf0e10cSrcweir                         pPreviousRow = pRow;
4406cdf0e10cSrcweir                         break;
4407cdf0e10cSrcweir                     }
4408cdf0e10cSrcweir                 }
4409cdf0e10cSrcweir             }
4410cdf0e10cSrcweir             // <--
4411cdf0e10cSrcweir 
4412cdf0e10cSrcweir             sal_uInt16 nTopPrtMargin = nTopSpace;
4413cdf0e10cSrcweir             if ( pPreviousRow )
4414cdf0e10cSrcweir             {
4415cdf0e10cSrcweir                 const sal_uInt16 nTmpPrtMargin = pPreviousRow->GetBottomLineSize() + nTopLineDist;
4416cdf0e10cSrcweir                 if ( nTmpPrtMargin > nTopPrtMargin )
4417cdf0e10cSrcweir                     nTopPrtMargin = nTmpPrtMargin;
4418cdf0e10cSrcweir             }
4419cdf0e10cSrcweir 
4420cdf0e10cSrcweir             // table has to be notified if it has to change its lower
4421cdf0e10cSrcweir             // margin due to changes of nBottomLineSize:
4422cdf0e10cSrcweir             if ( !GetNext() && nBottomLineSize != GetBottomLineSize() )
4423cdf0e10cSrcweir                  pTabFrm->_InvalidatePrt();
4424cdf0e10cSrcweir 
4425cdf0e10cSrcweir             // If there are rows nested inside this row, the nested rows
4426cdf0e10cSrcweir             // may not have been calculated yet. Therefore the
4427cdf0e10cSrcweir             // ::lcl_CalcMinRowHeight( this ) operation later in this
4428cdf0e10cSrcweir             // function cannot consider the correct border values. We
4429cdf0e10cSrcweir             // have to trigger the invalidation of the outer row frame
4430cdf0e10cSrcweir             // manually:
4431cdf0e10cSrcweir             // Note: If any further invalidations should be necessary, we
4432cdf0e10cSrcweir             // should consider moving the invalidation stuff to the
4433cdf0e10cSrcweir             // appropriate SwNotify object.
4434cdf0e10cSrcweir             if ( GetUpper()->GetUpper()->IsRowFrm() &&
4435cdf0e10cSrcweir                  ( nBottomLineDist != GetBottomMarginForLowers() ||
4436cdf0e10cSrcweir                    nTopPrtMargin   != GetTopMarginForLowers() ) )
4437cdf0e10cSrcweir                 GetUpper()->GetUpper()->_InvalidateSize();
4438cdf0e10cSrcweir 
4439cdf0e10cSrcweir             SetBottomMarginForLowers( nBottomLineDist );    //  3.
4440cdf0e10cSrcweir             SetBottomLineSize( nBottomLineSize );           //  4.
4441cdf0e10cSrcweir             SetTopMarginForLowers( nTopPrtMargin );         //  5.
4442cdf0e10cSrcweir 
4443cdf0e10cSrcweir         }
4444cdf0e10cSrcweir // <-- collapsing
4445cdf0e10cSrcweir 	}
4446cdf0e10cSrcweir 
4447cdf0e10cSrcweir 	while ( !bValidSize )
4448cdf0e10cSrcweir 	{
4449cdf0e10cSrcweir 		bValidSize = sal_True;
4450cdf0e10cSrcweir 
4451cdf0e10cSrcweir #ifdef DBG_UTIL
4452cdf0e10cSrcweir         if ( HasFixSize() )
4453cdf0e10cSrcweir 		{
4454cdf0e10cSrcweir 			const SwFmtFrmSize &rFrmSize = GetFmt()->GetFrmSize();
4455cdf0e10cSrcweir 			ASSERT( rFrmSize.GetSize().Height() > 0, "Hat ihn" );
4456cdf0e10cSrcweir 		}
4457cdf0e10cSrcweir #endif
4458cdf0e10cSrcweir         const SwTwips nDiff = (Frm().*fnRect->fnGetHeight)() -
4459cdf0e10cSrcweir                               ( HasFixSize() && !IsRowSpanLine()
4460cdf0e10cSrcweir                                 ? pAttrs->GetSize().Height()
4461cdf0e10cSrcweir                                 // --> OD 2004-10-04 #i26945#
4462cdf0e10cSrcweir                                 : ::lcl_CalcMinRowHeight( this,
4463cdf0e10cSrcweir                                     FindTabFrm()->IsConsiderObjsForMinCellHeight() ) );
4464cdf0e10cSrcweir                                 // <--
4465cdf0e10cSrcweir         if ( nDiff )
4466cdf0e10cSrcweir 		{
4467cdf0e10cSrcweir             bFixSize = sal_False;
4468cdf0e10cSrcweir 			if ( nDiff > 0 )
4469cdf0e10cSrcweir                 Shrink( nDiff, sal_False, sal_True );
4470cdf0e10cSrcweir 			else if ( nDiff < 0 )
4471cdf0e10cSrcweir                 Grow( -nDiff );
4472cdf0e10cSrcweir             bFixSize = bFix;
4473cdf0e10cSrcweir 		}
4474cdf0e10cSrcweir 	}
4475cdf0e10cSrcweir 
4476cdf0e10cSrcweir     // last row will fill the space in its upper.
4477cdf0e10cSrcweir     if ( !GetNext() )
4478cdf0e10cSrcweir 	{
4479cdf0e10cSrcweir 		//Der letzte fuellt den verbleibenden Raum im Upper aus.
4480cdf0e10cSrcweir         SwTwips nDiff = (GetUpper()->Prt().*fnRect->fnGetHeight)();
4481cdf0e10cSrcweir 		SwFrm *pSibling = GetUpper()->Lower();
4482cdf0e10cSrcweir 		do
4483cdf0e10cSrcweir         {   nDiff -= (pSibling->Frm().*fnRect->fnGetHeight)();
4484cdf0e10cSrcweir 			pSibling = pSibling->GetNext();
4485cdf0e10cSrcweir 		} while ( pSibling );
4486cdf0e10cSrcweir 		if ( nDiff > 0 )
4487cdf0e10cSrcweir 		{
4488cdf0e10cSrcweir             bFixSize = sal_False;
4489cdf0e10cSrcweir             Grow( nDiff );
4490cdf0e10cSrcweir             bFixSize = bFix;
4491cdf0e10cSrcweir 			bValidSize = sal_True;
4492cdf0e10cSrcweir 		}
4493cdf0e10cSrcweir 	}
4494cdf0e10cSrcweir }
4495cdf0e10cSrcweir 
4496cdf0e10cSrcweir /*************************************************************************
4497cdf0e10cSrcweir |*
4498cdf0e10cSrcweir |*	SwRowFrm::AdjustCells()
4499cdf0e10cSrcweir |*
4500cdf0e10cSrcweir |*	Ersterstellung		MA 10. Aug. 93
4501cdf0e10cSrcweir |*	Letzte Aenderung	MA 16. Dec. 96
4502cdf0e10cSrcweir |*
4503cdf0e10cSrcweir |*************************************************************************/
AdjustCells(const SwTwips nHeight,const sal_Bool bHeight)4504cdf0e10cSrcweir void SwRowFrm::AdjustCells( const SwTwips nHeight, const sal_Bool bHeight )
4505cdf0e10cSrcweir {
4506cdf0e10cSrcweir 	SwFrm *pFrm = Lower();
4507cdf0e10cSrcweir 	if ( bHeight )
4508cdf0e10cSrcweir 	{
4509cdf0e10cSrcweir 		SwRootFrm *pRootFrm = getRootFrm();
4510cdf0e10cSrcweir         SWRECTFN( this )
4511cdf0e10cSrcweir         SwRect aOldFrm;
4512cdf0e10cSrcweir 
4513cdf0e10cSrcweir         while ( pFrm )
4514cdf0e10cSrcweir         {
4515cdf0e10cSrcweir             SwFrm* pNotify = 0;
4516cdf0e10cSrcweir 
4517cdf0e10cSrcweir             SwCellFrm* pCellFrm = static_cast<SwCellFrm*>(pFrm);
4518cdf0e10cSrcweir 
4519cdf0e10cSrcweir             // NEW TABLES
4520cdf0e10cSrcweir             // Which cells need to be adjusted if the current row changes
4521cdf0e10cSrcweir             // its height?
4522cdf0e10cSrcweir 
4523cdf0e10cSrcweir             // Current frame is a covered frame:
4524cdf0e10cSrcweir             // Set new height for covered cell and adjust master cell:
4525cdf0e10cSrcweir             if ( pCellFrm->GetTabBox()->getRowSpan() < 1 )
4526cdf0e10cSrcweir             {
4527cdf0e10cSrcweir                 // Set height of current (covered) cell to new line height.
4528cdf0e10cSrcweir                 const long nDiff = nHeight - (pCellFrm->Frm().*fnRect->fnGetHeight)();
4529cdf0e10cSrcweir                 if ( nDiff )
4530cdf0e10cSrcweir                 {
4531cdf0e10cSrcweir                     (pCellFrm->Frm().*fnRect->fnAddBottom)( nDiff );
4532cdf0e10cSrcweir                     pCellFrm->_InvalidatePrt();
4533cdf0e10cSrcweir                 }
4534cdf0e10cSrcweir             }
4535cdf0e10cSrcweir 
4536cdf0e10cSrcweir             SwCellFrm* pToAdjust = 0;
4537cdf0e10cSrcweir             SwFrm* pToAdjustRow = 0;
4538cdf0e10cSrcweir 
4539cdf0e10cSrcweir             // If current frame is covered frame, we still want to adjust the
4540cdf0e10cSrcweir             // height of the cell starting the row span
4541cdf0e10cSrcweir             if ( pCellFrm->GetLayoutRowSpan() < 1 )
4542cdf0e10cSrcweir             {
4543cdf0e10cSrcweir                 pToAdjust = const_cast< SwCellFrm*>(&pCellFrm->FindStartEndOfRowSpanCell( true, true ));
4544cdf0e10cSrcweir                 pToAdjustRow = pToAdjust->GetUpper();
4545cdf0e10cSrcweir             }
4546cdf0e10cSrcweir             else
4547cdf0e10cSrcweir             {
4548cdf0e10cSrcweir                 pToAdjust = pCellFrm;
4549cdf0e10cSrcweir                 pToAdjustRow = this;
4550cdf0e10cSrcweir             }
4551cdf0e10cSrcweir 
4552cdf0e10cSrcweir             // Set height of master cell to height of all lines spanned by this line.
4553cdf0e10cSrcweir             long nRowSpan = pToAdjust->GetLayoutRowSpan();
4554cdf0e10cSrcweir             SwTwips nSumRowHeight = 0;
4555cdf0e10cSrcweir             while ( pToAdjustRow )
4556cdf0e10cSrcweir             {
4557cdf0e10cSrcweir                 // Use new height for the current row:
4558cdf0e10cSrcweir                 nSumRowHeight += pToAdjustRow == this ?
4559cdf0e10cSrcweir                                  nHeight :
4560cdf0e10cSrcweir                                  (pToAdjustRow->Frm().*fnRect->fnGetHeight)();
4561cdf0e10cSrcweir 
4562cdf0e10cSrcweir                 if ( nRowSpan-- == 1 )
4563cdf0e10cSrcweir                     break;
4564cdf0e10cSrcweir 
4565cdf0e10cSrcweir                 pToAdjustRow = pToAdjustRow->GetNext();
4566cdf0e10cSrcweir             }
4567cdf0e10cSrcweir 
4568cdf0e10cSrcweir             if ( pToAdjustRow && pToAdjustRow != this )
4569cdf0e10cSrcweir                 pToAdjustRow->_InvalidateSize();
4570cdf0e10cSrcweir 
4571cdf0e10cSrcweir             const long nDiff = nSumRowHeight - (pToAdjust->Frm().*fnRect->fnGetHeight)();
4572cdf0e10cSrcweir             if ( nDiff )
4573cdf0e10cSrcweir             {
4574cdf0e10cSrcweir                 aOldFrm = pToAdjust->Frm();
4575cdf0e10cSrcweir                 (pToAdjust->Frm().*fnRect->fnAddBottom)( nDiff );
4576cdf0e10cSrcweir                 pNotify = pToAdjust;
4577cdf0e10cSrcweir             }
4578cdf0e10cSrcweir 
4579cdf0e10cSrcweir             if ( pNotify )
4580cdf0e10cSrcweir             {
4581cdf0e10cSrcweir                 if( pRootFrm && pRootFrm->IsAnyShellAccessible() && pRootFrm->GetCurrShell() )
4582cdf0e10cSrcweir                     pRootFrm->GetCurrShell()->Imp()->MoveAccessibleFrm( pNotify, aOldFrm );
4583cdf0e10cSrcweir 
4584cdf0e10cSrcweir                 pNotify->_InvalidatePrt();
4585cdf0e10cSrcweir             }
4586cdf0e10cSrcweir 
4587cdf0e10cSrcweir 			pFrm = pFrm->GetNext();
4588cdf0e10cSrcweir 		}
4589cdf0e10cSrcweir 	}
4590cdf0e10cSrcweir 	else
4591cdf0e10cSrcweir 	{	while ( pFrm )
4592cdf0e10cSrcweir 		{
4593cdf0e10cSrcweir 			pFrm->_InvalidateAll();
4594cdf0e10cSrcweir 			pFrm = pFrm->GetNext();
4595cdf0e10cSrcweir 		}
4596cdf0e10cSrcweir 	}
4597cdf0e10cSrcweir 	InvalidatePage();
4598cdf0e10cSrcweir }
4599cdf0e10cSrcweir 
4600cdf0e10cSrcweir /*************************************************************************
4601cdf0e10cSrcweir |*
4602cdf0e10cSrcweir |*	SwRowFrm::Cut()
4603cdf0e10cSrcweir |*
4604cdf0e10cSrcweir |*	Ersterstellung		MA 12. Nov. 97
4605cdf0e10cSrcweir |*	Letzte Aenderung	MA 12. Nov. 97
4606cdf0e10cSrcweir |*
4607cdf0e10cSrcweir |*************************************************************************/
Cut()4608cdf0e10cSrcweir void SwRowFrm::Cut()
4609cdf0e10cSrcweir {
4610cdf0e10cSrcweir 	SwTabFrm *pTab = FindTabFrm();
4611cdf0e10cSrcweir     if ( pTab && pTab->IsFollow() && this == pTab->GetFirstNonHeadlineRow() )
4612cdf0e10cSrcweir     {
4613cdf0e10cSrcweir 		pTab->FindMaster()->InvalidatePos();
4614cdf0e10cSrcweir 	}
4615cdf0e10cSrcweir 
4616cdf0e10cSrcweir     // --> OD 2010-02-17 #i103961#
4617cdf0e10cSrcweir     // notification for accessibility
4618cdf0e10cSrcweir     {
4619cdf0e10cSrcweir         SwRootFrm *pRootFrm = getRootFrm();
4620cdf0e10cSrcweir         if( pRootFrm && pRootFrm->IsAnyShellAccessible() )
4621cdf0e10cSrcweir         {
4622cdf0e10cSrcweir             ViewShell* pVSh = pRootFrm->GetCurrShell();
4623cdf0e10cSrcweir             if ( pVSh && pVSh->Imp() )
4624cdf0e10cSrcweir             {
4625cdf0e10cSrcweir                 SwFrm* pCellFrm( GetLower() );
4626cdf0e10cSrcweir                 while ( pCellFrm )
4627cdf0e10cSrcweir                 {
4628cdf0e10cSrcweir                     ASSERT( pCellFrm->IsCellFrm(),
4629cdf0e10cSrcweir                             "<SwRowFrm::Cut()> - unexpected type of SwRowFrm lower." );
4630cdf0e10cSrcweir                     pVSh->Imp()->DisposeAccessibleFrm( pCellFrm );
4631cdf0e10cSrcweir 
4632cdf0e10cSrcweir                     pCellFrm = pCellFrm->GetNext();
4633cdf0e10cSrcweir                 }
4634cdf0e10cSrcweir             }
4635cdf0e10cSrcweir         }
4636cdf0e10cSrcweir     }
4637cdf0e10cSrcweir     // <--
4638cdf0e10cSrcweir 
4639cdf0e10cSrcweir 	SwLayoutFrm::Cut();
4640cdf0e10cSrcweir }
4641cdf0e10cSrcweir 
4642cdf0e10cSrcweir /*************************************************************************
4643cdf0e10cSrcweir |*
4644cdf0e10cSrcweir |*	SwRowFrm::GrowFrm()
4645cdf0e10cSrcweir |*
4646cdf0e10cSrcweir |*	Ersterstellung		MA 15. Mar. 93
4647cdf0e10cSrcweir |*	Letzte Aenderung	MA 05. May. 94
4648cdf0e10cSrcweir |*
4649cdf0e10cSrcweir |*************************************************************************/
4650cdf0e10cSrcweir 
4651cdf0e10cSrcweir 
GrowFrm(SwTwips nDist,sal_Bool bTst,sal_Bool bInfo)4652cdf0e10cSrcweir SwTwips SwRowFrm::GrowFrm( SwTwips nDist, sal_Bool bTst, sal_Bool bInfo )
4653cdf0e10cSrcweir {
4654cdf0e10cSrcweir     SwTwips nReal = 0;
4655cdf0e10cSrcweir 
4656cdf0e10cSrcweir     SwTabFrm* pTab = FindTabFrm();
4657cdf0e10cSrcweir     SWRECTFN( pTab )
4658cdf0e10cSrcweir 
4659cdf0e10cSrcweir     bool bRestrictTableGrowth;
4660cdf0e10cSrcweir     bool bHasFollowFlowLine = pTab->HasFollowFlowLine();
4661cdf0e10cSrcweir 
4662cdf0e10cSrcweir     if ( GetUpper()->IsTabFrm() )
4663cdf0e10cSrcweir     {
4664cdf0e10cSrcweir         const SwRowFrm* pFollowFlowRow = IsInSplitTableRow();
4665cdf0e10cSrcweir         bRestrictTableGrowth = pFollowFlowRow && !pFollowFlowRow->IsRowSpanLine();
4666cdf0e10cSrcweir     }
4667cdf0e10cSrcweir     else
4668cdf0e10cSrcweir     {
4669cdf0e10cSrcweir         ASSERT( GetUpper()->IsCellFrm(), "RowFrm->GetUpper neither table nor cell" )
4670cdf0e10cSrcweir         bRestrictTableGrowth = GetFollowRow() && bHasFollowFlowLine;
4671cdf0e10cSrcweir         ASSERT( !bRestrictTableGrowth || !GetNext(),
4672cdf0e10cSrcweir                 "GetFollowRow for row frame that has a Next" )
4673cdf0e10cSrcweir 
4674cdf0e10cSrcweir         //
4675cdf0e10cSrcweir         // There may still be some space left in my direct upper:
4676cdf0e10cSrcweir         //
4677cdf0e10cSrcweir         const SwTwips nAdditionalSpace =
4678cdf0e10cSrcweir                 (Frm().*fnRect->fnBottomDist)( (GetUpper()->GetUpper()->*fnRect->fnGetPrtBottom)() );
4679cdf0e10cSrcweir         if ( bRestrictTableGrowth && nAdditionalSpace > 0 )
4680cdf0e10cSrcweir         {
4681cdf0e10cSrcweir             nReal = Min( nAdditionalSpace, nDist );
4682cdf0e10cSrcweir             nDist -= nReal;
4683cdf0e10cSrcweir             if ( !bTst )
4684cdf0e10cSrcweir                 (Frm().*fnRect->fnAddBottom)( nReal );
4685cdf0e10cSrcweir         }
4686cdf0e10cSrcweir     }
4687cdf0e10cSrcweir 
4688cdf0e10cSrcweir     if ( bRestrictTableGrowth )
4689cdf0e10cSrcweir         pTab->SetRestrictTableGrowth( sal_True );
4690cdf0e10cSrcweir     else
4691cdf0e10cSrcweir     {
4692cdf0e10cSrcweir         // Ok, this looks like a hack, indeed, it is a hack.
4693cdf0e10cSrcweir         // If the current row frame is inside another cell frame,
4694cdf0e10cSrcweir         // and the current row frame has no follow, it should not
4695cdf0e10cSrcweir         // be allowed to grow. In fact, setting bRestrictTableGrowth
4696cdf0e10cSrcweir         // to 'false' does not work, because the surrounding RowFrm
4697cdf0e10cSrcweir         // would set this to 'true'.
4698cdf0e10cSrcweir         pTab->SetFollowFlowLine( sal_False );
4699cdf0e10cSrcweir     }
4700cdf0e10cSrcweir 
4701cdf0e10cSrcweir     nReal += SwLayoutFrm::GrowFrm( nDist, bTst, bInfo);
4702cdf0e10cSrcweir 
4703cdf0e10cSrcweir     pTab->SetRestrictTableGrowth( sal_False );
4704cdf0e10cSrcweir     pTab->SetFollowFlowLine( bHasFollowFlowLine );
4705cdf0e10cSrcweir 
4706cdf0e10cSrcweir 	//Hoehe der Zellen auf den neuesten Stand bringen.
4707cdf0e10cSrcweir 	if ( !bTst )
4708cdf0e10cSrcweir 	{
4709cdf0e10cSrcweir         SWRECTFNX( this )
4710cdf0e10cSrcweir         AdjustCells( (Prt().*fnRectX->fnGetHeight)() + nReal, sal_True );
4711cdf0e10cSrcweir 		if ( nReal )
4712cdf0e10cSrcweir 			SetCompletePaint();
4713cdf0e10cSrcweir 	}
4714cdf0e10cSrcweir 
4715cdf0e10cSrcweir     return nReal;
4716cdf0e10cSrcweir }
4717cdf0e10cSrcweir 
4718cdf0e10cSrcweir /*************************************************************************
4719cdf0e10cSrcweir |*
4720cdf0e10cSrcweir |*	SwRowFrm::ShrinkFrm()
4721cdf0e10cSrcweir |*
4722cdf0e10cSrcweir |*	Ersterstellung		MA 15. Mar. 93
4723cdf0e10cSrcweir |*	Letzte Aenderung	MA 20. Jun. 96
4724cdf0e10cSrcweir |*
4725cdf0e10cSrcweir |*************************************************************************/
ShrinkFrm(SwTwips nDist,sal_Bool bTst,sal_Bool bInfo)4726cdf0e10cSrcweir SwTwips SwRowFrm::ShrinkFrm( SwTwips nDist, sal_Bool bTst, sal_Bool bInfo )
4727cdf0e10cSrcweir {
4728cdf0e10cSrcweir     SWRECTFN( this )
4729cdf0e10cSrcweir     if( HasFixSize() )
4730cdf0e10cSrcweir 	{
4731cdf0e10cSrcweir         AdjustCells( (Prt().*fnRect->fnGetHeight)(), sal_True );
4732cdf0e10cSrcweir 		return 0L;
4733cdf0e10cSrcweir 	}
4734cdf0e10cSrcweir 
4735cdf0e10cSrcweir 	//bInfo wird ggf. vom SwRowFrm::Format auf sal_True gesetzt, hier muss dann
4736cdf0e10cSrcweir 	//entsprechend reagiert werden
4737cdf0e10cSrcweir 	const sal_Bool bShrinkAnyway = bInfo;
4738cdf0e10cSrcweir 
4739cdf0e10cSrcweir 	//Nur soweit Shrinken, wie es der Inhalt der groessten Zelle zulaesst.
4740cdf0e10cSrcweir 	SwTwips nRealDist = nDist;
4741cdf0e10cSrcweir 	{
4742cdf0e10cSrcweir 		const SwFmtFrmSize &rSz = GetFmt()->GetFrmSize();
4743cdf0e10cSrcweir         SwTwips nMinHeight = rSz.GetHeightSizeType() == ATT_MIN_SIZE ?
4744cdf0e10cSrcweir                              rSz.GetHeight() :
4745cdf0e10cSrcweir                              0;
4746cdf0e10cSrcweir 
4747cdf0e10cSrcweir         // Only necessary to calculate minimal row height if height
4748cdf0e10cSrcweir         // of pRow is at least nMinHeight. Otherwise nMinHeight is the
4749cdf0e10cSrcweir         // minimum height.
4750cdf0e10cSrcweir         if( nMinHeight < (Frm().*fnRect->fnGetHeight)() )
4751cdf0e10cSrcweir 		{
4752cdf0e10cSrcweir             // --> OD 2004-10-04 #i26945#
4753cdf0e10cSrcweir             ASSERT( FindTabFrm(), "<SwRowFrm::ShrinkFrm(..)> - no table frame -> crash." );
4754cdf0e10cSrcweir             const bool bConsiderObjs( FindTabFrm()->IsConsiderObjsForMinCellHeight() );
4755cdf0e10cSrcweir             // <--
4756cdf0e10cSrcweir             nMinHeight = lcl_CalcMinRowHeight( this, bConsiderObjs );
4757cdf0e10cSrcweir         }
4758cdf0e10cSrcweir 
4759cdf0e10cSrcweir         if ( ((Frm().*fnRect->fnGetHeight)() - nRealDist) < nMinHeight )
4760cdf0e10cSrcweir             nRealDist = (Frm().*fnRect->fnGetHeight)() - nMinHeight;
4761cdf0e10cSrcweir 	}
4762cdf0e10cSrcweir 	if ( nRealDist < 0 )
4763cdf0e10cSrcweir 		nRealDist = 0;
4764cdf0e10cSrcweir 
4765cdf0e10cSrcweir 	SwTwips nReal = nRealDist;
4766cdf0e10cSrcweir 	if ( nReal )
4767cdf0e10cSrcweir 	{
4768cdf0e10cSrcweir 		if ( !bTst )
4769cdf0e10cSrcweir         {
4770cdf0e10cSrcweir             SwTwips nHeight = (Frm().*fnRect->fnGetHeight)();
4771cdf0e10cSrcweir             (Frm().*fnRect->fnSetHeight)( nHeight - nReal );
4772cdf0e10cSrcweir             //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
4773cdf0e10cSrcweir             if( IsVertical() && !IsVertLR() && !bRev )
4774cdf0e10cSrcweir                 Frm().Pos().X() += nReal;
4775cdf0e10cSrcweir         }
4776cdf0e10cSrcweir 
4777cdf0e10cSrcweir         SwTwips nTmp = GetUpper()->Shrink( nReal, bTst );
4778cdf0e10cSrcweir 		if ( !bShrinkAnyway && !GetNext() && nTmp != nReal )
4779cdf0e10cSrcweir 		{
4780cdf0e10cSrcweir 			//Der letzte bekommt den Rest im Upper und nimmt deshalb
4781cdf0e10cSrcweir 			//ggf. Ruecksichten (sonst: Endlosschleife)
4782cdf0e10cSrcweir 			if ( !bTst )
4783cdf0e10cSrcweir             {
4784cdf0e10cSrcweir                 nReal -= nTmp;
4785cdf0e10cSrcweir                 SwTwips nHeight = (Frm().*fnRect->fnGetHeight)();
4786cdf0e10cSrcweir                 (Frm().*fnRect->fnSetHeight)( nHeight + nReal );
4787cdf0e10cSrcweir                 //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
4788cdf0e10cSrcweir                 if( IsVertical() && !IsVertLR() && !bRev )
4789cdf0e10cSrcweir                     Frm().Pos().X() -= nReal;
4790cdf0e10cSrcweir             }
4791cdf0e10cSrcweir 			nReal = nTmp;
4792cdf0e10cSrcweir 		}
4793cdf0e10cSrcweir 	}
4794cdf0e10cSrcweir 
47950df44b11SOliver-Rainer Wittmann     //Geeignet invalidieren und die Hoehe der Zellen auf den neuesten
47960df44b11SOliver-Rainer Wittmann     //Stand bringen.
47970df44b11SOliver-Rainer Wittmann     if ( !bTst )
47980df44b11SOliver-Rainer Wittmann     {
47990df44b11SOliver-Rainer Wittmann         if ( nReal )
48000df44b11SOliver-Rainer Wittmann         {
48010df44b11SOliver-Rainer Wittmann             if ( GetNext() )
48020df44b11SOliver-Rainer Wittmann                 GetNext()->_InvalidatePos();
48030df44b11SOliver-Rainer Wittmann             _InvalidateAll();
48040df44b11SOliver-Rainer Wittmann             SetCompletePaint();
4805cdf0e10cSrcweir 
48060df44b11SOliver-Rainer Wittmann             SwTabFrm *pTab = FindTabFrm();
48070df44b11SOliver-Rainer Wittmann             if ( !pTab->IsRebuildLastLine()
48080df44b11SOliver-Rainer Wittmann                  && pTab->IsFollow()
48090df44b11SOliver-Rainer Wittmann                  && this == pTab->GetFirstNonHeadlineRow()
48100df44b11SOliver-Rainer Wittmann                  && !pTab->IsInRecalcLowerRow() )
4811cdf0e10cSrcweir             {
4812cdf0e10cSrcweir                 SwTabFrm* pMasterTab = const_cast< SwTabFrm* >( pTab->FindMaster() );
4813cdf0e10cSrcweir                 pMasterTab->InvalidatePos();
4814cdf0e10cSrcweir             }
4815cdf0e10cSrcweir         }
4816cdf0e10cSrcweir         AdjustCells( (Prt().*fnRect->fnGetHeight)() - nReal, sal_True );
48170df44b11SOliver-Rainer Wittmann     }
48180df44b11SOliver-Rainer Wittmann     return nReal;
4819cdf0e10cSrcweir }
4820cdf0e10cSrcweir 
4821cdf0e10cSrcweir /*************************************************************************
4822cdf0e10cSrcweir |*
4823cdf0e10cSrcweir |*  SwRowFrm::IsRowSplitAllowed()
4824cdf0e10cSrcweir |*
4825cdf0e10cSrcweir |*************************************************************************/
IsRowSplitAllowed() const4826cdf0e10cSrcweir bool SwRowFrm::IsRowSplitAllowed() const
4827cdf0e10cSrcweir {
4828cdf0e10cSrcweir     // Fixed size rows are never allowed to split:
4829cdf0e10cSrcweir     if ( HasFixSize() )
4830cdf0e10cSrcweir     {
4831cdf0e10cSrcweir         ASSERT( ATT_FIX_SIZE == GetFmt()->GetFrmSize().GetHeightSizeType(), "pRow claims to have fixed size" )
4832cdf0e10cSrcweir         return false;
4833cdf0e10cSrcweir     }
4834cdf0e10cSrcweir 
4835cdf0e10cSrcweir     // Repeated headlines are never allowed to split:
4836cdf0e10cSrcweir     const SwTabFrm* pTabFrm = FindTabFrm();
4837cdf0e10cSrcweir     if ( pTabFrm->GetTable()->GetRowsToRepeat() > 0 &&
4838cdf0e10cSrcweir          pTabFrm->IsInHeadline( *this ) )
4839cdf0e10cSrcweir         return false;
4840cdf0e10cSrcweir 
4841cdf0e10cSrcweir     const SwTableLineFmt* pFrmFmt = (SwTableLineFmt*)GetTabLine()->GetFrmFmt();
4842cdf0e10cSrcweir     const SwFmtRowSplit& rLP = pFrmFmt->GetRowSplit();
4843cdf0e10cSrcweir     return 0 != rLP.GetValue();
4844cdf0e10cSrcweir }
4845cdf0e10cSrcweir 
4846cdf0e10cSrcweir /*************************************************************************
4847cdf0e10cSrcweir |*
4848cdf0e10cSrcweir |*  SwRowFrm::ShouldRowKeepWithNext()
4849cdf0e10cSrcweir |*
4850cdf0e10cSrcweir |*************************************************************************/
ShouldRowKeepWithNext() const4851cdf0e10cSrcweir bool SwRowFrm::ShouldRowKeepWithNext() const
4852cdf0e10cSrcweir {
4853cdf0e10cSrcweir     bool bRet = false;
4854cdf0e10cSrcweir 
4855cdf0e10cSrcweir     const SwCellFrm* pCell = static_cast<const SwCellFrm*>(Lower());
4856cdf0e10cSrcweir     const SwFrm* pTxt = pCell->Lower();
4857cdf0e10cSrcweir 
4858cdf0e10cSrcweir     if ( pTxt && pTxt->IsTxtFrm() )
4859cdf0e10cSrcweir     {
4860cdf0e10cSrcweir         bRet = static_cast<const SwTxtFrm*>(pTxt)->GetTxtNode()->GetSwAttrSet().GetKeep().GetValue();
4861cdf0e10cSrcweir     }
4862cdf0e10cSrcweir     return bRet;
4863cdf0e10cSrcweir }
4864cdf0e10cSrcweir 
4865cdf0e10cSrcweir /*************************************************************************
4866cdf0e10cSrcweir |*
4867cdf0e10cSrcweir |*	SwCellFrm::SwCellFrm(), ~SwCellFrm()
4868cdf0e10cSrcweir |*
4869cdf0e10cSrcweir |*	Ersterstellung		MA 09. Mar. 93
4870cdf0e10cSrcweir |*	Letzte Aenderung	MA 30. May. 96
4871cdf0e10cSrcweir |*
4872cdf0e10cSrcweir |*************************************************************************/
SwCellFrm(const SwTableBox & rBox,SwFrm * pSib,bool bInsertContent)4873cdf0e10cSrcweir SwCellFrm::SwCellFrm( const SwTableBox &rBox, SwFrm* pSib, bool bInsertContent ) :
4874cdf0e10cSrcweir 	SwLayoutFrm( rBox.GetFrmFmt(), pSib ),
4875cdf0e10cSrcweir     pTabBox( &rBox )
4876cdf0e10cSrcweir {
4877cdf0e10cSrcweir     nType = FRMC_CELL;
4878cdf0e10cSrcweir 
4879cdf0e10cSrcweir     if ( !bInsertContent )
4880cdf0e10cSrcweir         return;
4881cdf0e10cSrcweir 
4882cdf0e10cSrcweir 	//Wenn ein StartIdx vorhanden ist, so werden CntntFrms in der Zelle
4883cdf0e10cSrcweir 	//angelegt, andernfalls muessen Rows vorhanden sein und diese werden
4884cdf0e10cSrcweir 	//angelegt.
4885cdf0e10cSrcweir 	if ( rBox.GetSttIdx() )
4886cdf0e10cSrcweir 	{
4887cdf0e10cSrcweir         sal_uLong nIndex = rBox.GetSttIdx();
4888cdf0e10cSrcweir         ::_InsertCnt( this, rBox.GetFrmFmt()->GetDoc(), ++nIndex );
4889cdf0e10cSrcweir 	}
4890cdf0e10cSrcweir 	else
4891cdf0e10cSrcweir 	{
4892cdf0e10cSrcweir 	    const SwTableLines &rLines = rBox.GetTabLines();
4893cdf0e10cSrcweir         SwFrm *pTmpPrev = 0;
4894cdf0e10cSrcweir 		for ( sal_uInt16 i = 0; i < rLines.Count(); ++i )
4895cdf0e10cSrcweir 		{
4896cdf0e10cSrcweir 			SwRowFrm *pNew = new SwRowFrm( *rLines[i], this, bInsertContent );
4897cdf0e10cSrcweir             pNew->InsertBehind( this, pTmpPrev );
4898cdf0e10cSrcweir             pTmpPrev = pNew;
4899cdf0e10cSrcweir 		}
4900cdf0e10cSrcweir 	}
4901cdf0e10cSrcweir }
4902cdf0e10cSrcweir 
~SwCellFrm()4903cdf0e10cSrcweir SwCellFrm::~SwCellFrm()
4904cdf0e10cSrcweir {
4905cdf0e10cSrcweir 	SwModify* pMod = GetFmt();
4906cdf0e10cSrcweir 	if( pMod )
4907cdf0e10cSrcweir 	{
4908cdf0e10cSrcweir 		// At this stage the lower frames aren't destroyed already,
4909cdf0e10cSrcweir 		// therfor we have to do a recursive dispose.
4910cdf0e10cSrcweir 		SwRootFrm *pRootFrm = getRootFrm();
4911cdf0e10cSrcweir 		if( pRootFrm && pRootFrm->IsAnyShellAccessible() &&
4912cdf0e10cSrcweir 			pRootFrm->GetCurrShell() )
4913cdf0e10cSrcweir 		{
4914cdf0e10cSrcweir 			pRootFrm->GetCurrShell()->Imp()->DisposeAccessibleFrm( this, sal_True );
4915cdf0e10cSrcweir 		}
4916cdf0e10cSrcweir 
4917cdf0e10cSrcweir         pMod->Remove( this );           // austragen,
4918cdf0e10cSrcweir 		if( !pMod->GetDepends() )
4919cdf0e10cSrcweir 			delete pMod;				// und loeschen
4920cdf0e10cSrcweir 	}
4921cdf0e10cSrcweir }
4922cdf0e10cSrcweir 
4923cdf0e10cSrcweir /*************************************************************************
4924cdf0e10cSrcweir |*
4925cdf0e10cSrcweir |*	SwCellFrm::Format()
4926cdf0e10cSrcweir |*
4927cdf0e10cSrcweir |*	Ersterstellung		MA 09. Mar. 93
4928cdf0e10cSrcweir |*	Letzte Aenderung	MA 29. Jan. 98
4929cdf0e10cSrcweir |*
4930cdf0e10cSrcweir |*************************************************************************/
lcl_ArrangeLowers(SwLayoutFrm * pLay,long lYStart,sal_Bool bInva)4931cdf0e10cSrcweir sal_Bool lcl_ArrangeLowers( SwLayoutFrm *pLay, long lYStart, sal_Bool bInva )
4932cdf0e10cSrcweir {
4933cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
4934cdf0e10cSrcweir 	SwFrm *pFrm = pLay->Lower();
4935cdf0e10cSrcweir     SWRECTFN( pLay )
4936cdf0e10cSrcweir 	while ( pFrm )
4937cdf0e10cSrcweir 	{
4938cdf0e10cSrcweir         long nFrmTop = (pFrm->Frm().*fnRect->fnGetTop)();
4939cdf0e10cSrcweir         if( nFrmTop != lYStart )
4940cdf0e10cSrcweir 		{
4941cdf0e10cSrcweir 			bRet = sal_True;
4942cdf0e10cSrcweir             const long lDiff = (*fnRect->fnYDiff)( lYStart, nFrmTop );
4943cdf0e10cSrcweir             const long lDiffX = lYStart - nFrmTop;
4944cdf0e10cSrcweir             (pFrm->Frm().*fnRect->fnSubTop)( -lDiff );
4945cdf0e10cSrcweir             (pFrm->Frm().*fnRect->fnAddBottom)( lDiff );
4946cdf0e10cSrcweir 			pFrm->SetCompletePaint();
4947cdf0e10cSrcweir 			if ( !pFrm->GetNext() )
4948cdf0e10cSrcweir 				pFrm->SetRetouche();
4949cdf0e10cSrcweir 			if( bInva )
4950cdf0e10cSrcweir 				pFrm->Prepare( PREP_POS_CHGD );
4951cdf0e10cSrcweir 			if ( pFrm->IsLayoutFrm() && ((SwLayoutFrm*)pFrm)->Lower() )
4952cdf0e10cSrcweir 				lcl_ArrangeLowers( (SwLayoutFrm*)pFrm,
4953cdf0e10cSrcweir                     (((SwLayoutFrm*)pFrm)->Lower()->Frm().*fnRect->fnGetTop)()
4954cdf0e10cSrcweir                     + lDiffX, bInva );
4955cdf0e10cSrcweir 			if ( pFrm->GetDrawObjs() )
4956cdf0e10cSrcweir 			{
4957cdf0e10cSrcweir 				for ( sal_uInt16 i = 0; i < pFrm->GetDrawObjs()->Count(); ++i )
4958cdf0e10cSrcweir 				{
4959cdf0e10cSrcweir                     SwAnchoredObject* pAnchoredObj = (*pFrm->GetDrawObjs())[i];
4960cdf0e10cSrcweir                     // --> OD 2004-10-08 #i26945# - check, if anchored object
4961cdf0e10cSrcweir                     // is lower of layout frame by checking, if the anchor
4962cdf0e10cSrcweir                     // frame, which contains the anchor position, is a lower
4963cdf0e10cSrcweir                     // of the layout frame.
4964cdf0e10cSrcweir                     if ( !pLay->IsAnLower( pAnchoredObj->GetAnchorFrmContainingAnchPos() ) )
4965cdf0e10cSrcweir                     {
4966cdf0e10cSrcweir                         continue;
4967cdf0e10cSrcweir                     }
4968cdf0e10cSrcweir                     // <--
4969cdf0e10cSrcweir                     // --> OD 2005-08-08 #i52904# - distinguish between anchored
4970cdf0e10cSrcweir                     // objects, whose vertical position depends on its anchor
4971cdf0e10cSrcweir                     // frame and whose vertical position is independent
4972cdf0e10cSrcweir                     // from its anchor frame.
4973cdf0e10cSrcweir                     bool bVertPosDepOnAnchor( true );
4974cdf0e10cSrcweir                     {
4975cdf0e10cSrcweir                         SwFmtVertOrient aVert( pAnchoredObj->GetFrmFmt().GetVertOrient() );
4976cdf0e10cSrcweir                         switch ( aVert.GetRelationOrient() )
4977cdf0e10cSrcweir                         {
4978cdf0e10cSrcweir                             case text::RelOrientation::PAGE_FRAME:
4979cdf0e10cSrcweir                             case text::RelOrientation::PAGE_PRINT_AREA:
4980cdf0e10cSrcweir                                 bVertPosDepOnAnchor = false;
4981cdf0e10cSrcweir                                 break;
4982cdf0e10cSrcweir                             default: break;
4983cdf0e10cSrcweir                         }
4984cdf0e10cSrcweir                     }
4985cdf0e10cSrcweir                     if ( pAnchoredObj->ISA(SwFlyFrm) )
4986cdf0e10cSrcweir 					{
4987cdf0e10cSrcweir                         SwFlyFrm *pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
4988cdf0e10cSrcweir 
4989cdf0e10cSrcweir                         // OD 2004-05-18 #i28701# - no direct move of objects,
4990cdf0e10cSrcweir                         // which are anchored to-paragraph/to-character, if
4991cdf0e10cSrcweir                         // the wrapping style influence has to be considered
4992cdf0e10cSrcweir                         // on the object positioning.
4993cdf0e10cSrcweir                         // --> OD 2005-08-08 #i52904# - no direct move of objects,
4994cdf0e10cSrcweir                         // whose vertical position doesn't depend on anchor frame.
4995cdf0e10cSrcweir                         const bool bDirectMove =
4996cdf0e10cSrcweir                                 WEIT_WECH != pFly->Frm().Top() &&
4997cdf0e10cSrcweir                                 bVertPosDepOnAnchor &&
4998cdf0e10cSrcweir                                 !pFly->ConsiderObjWrapInfluenceOnObjPos();
4999cdf0e10cSrcweir                         // <--
5000cdf0e10cSrcweir                         if ( bDirectMove )
5001cdf0e10cSrcweir                         {
5002cdf0e10cSrcweir                             (pFly->Frm().*fnRect->fnSubTop)( -lDiff );
5003cdf0e10cSrcweir                             (pFly->Frm().*fnRect->fnAddBottom)( lDiff );
5004cdf0e10cSrcweir                             pFly->GetVirtDrawObj()->SetRectsDirty();
5005cdf0e10cSrcweir                             // --> OD 2004-08-17 - also notify view of <SdrObject>
5006cdf0e10cSrcweir                             // instance, which represents the Writer fly frame in
5007cdf0e10cSrcweir                             // the drawing layer
5008cdf0e10cSrcweir                             pFly->GetVirtDrawObj()->SetChanged();
5009cdf0e10cSrcweir                             // <--
5010cdf0e10cSrcweir                             // --> OD 2006-10-13 #i58280#
5011cdf0e10cSrcweir                             pFly->InvalidateObjRectWithSpaces();
5012cdf0e10cSrcweir                             // <--
5013cdf0e10cSrcweir                         }
5014cdf0e10cSrcweir 
5015cdf0e10cSrcweir                         if ( pFly->IsFlyInCntFrm() )
5016cdf0e10cSrcweir                         {
5017cdf0e10cSrcweir                             static_cast<SwFlyInCntFrm*>(pFly)->AddRefOfst( lDiff );
5018cdf0e10cSrcweir                             // --> OD 2004-12-02 #115759# - reset current relative
5019cdf0e10cSrcweir                             // position to get re-positioned, if not directly moved.
5020cdf0e10cSrcweir                             if ( !bDirectMove )
5021cdf0e10cSrcweir                             {
5022cdf0e10cSrcweir                                 pAnchoredObj->SetCurrRelPos( Point( 0, 0 ) );
5023cdf0e10cSrcweir                             }
5024cdf0e10cSrcweir                             // <--
5025cdf0e10cSrcweir                         }
5026cdf0e10cSrcweir                         else if( pFly->IsAutoPos() )
5027cdf0e10cSrcweir                         {
5028cdf0e10cSrcweir                             pFly->AddLastCharY( lDiff );
5029cdf0e10cSrcweir                             // OD 2004-05-18 #i28701# - follow-up of #i22341#
5030cdf0e10cSrcweir                             // <mnLastTopOfLine> has also been adjusted.
5031cdf0e10cSrcweir                             pFly->AddLastTopOfLineY( lDiff );
5032cdf0e10cSrcweir                         }
5033cdf0e10cSrcweir                         // --> OD 2004-11-05 #i26945# - re-registration at
5034cdf0e10cSrcweir                         // page frame of anchor frame, if table frame isn't
5035cdf0e10cSrcweir                         // a follow table and table frame isn't in its
5036cdf0e10cSrcweir                         // rebuild of last line.
5037cdf0e10cSrcweir                         const SwTabFrm* pTabFrm = pLay->FindTabFrm();
5038cdf0e10cSrcweir                         // --> OD 2004-11-23 #115759#
5039cdf0e10cSrcweir                         // - save: check, if table frame is found.
5040cdf0e10cSrcweir                         if ( pTabFrm &&
5041cdf0e10cSrcweir                              !( pTabFrm->IsFollow() &&
5042cdf0e10cSrcweir                                 pTabFrm->FindMaster()->IsRebuildLastLine() ) &&
5043cdf0e10cSrcweir                              pFly->IsFlyFreeFrm() )
5044cdf0e10cSrcweir                         // <--
5045cdf0e10cSrcweir                         {
5046cdf0e10cSrcweir                             SwPageFrm* pPageFrm = pFly->GetPageFrm();
5047cdf0e10cSrcweir                             SwPageFrm* pPageOfAnchor = pFrm->FindPageFrm();
5048cdf0e10cSrcweir                             if ( pPageFrm != pPageOfAnchor )
5049cdf0e10cSrcweir                             {
5050cdf0e10cSrcweir                                 pFly->InvalidatePos();
5051cdf0e10cSrcweir                                 if ( pPageFrm )
5052cdf0e10cSrcweir                                     pPageFrm->MoveFly( pFly, pPageOfAnchor );
5053cdf0e10cSrcweir                                 else
5054cdf0e10cSrcweir                                     pPageOfAnchor->AppendFlyToPage( pFly );
5055cdf0e10cSrcweir                             }
5056cdf0e10cSrcweir                         }
5057cdf0e10cSrcweir                         // <--
5058cdf0e10cSrcweir                         // OD 2004-05-11 #i28701# - Because of the introduction
5059cdf0e10cSrcweir                         // of new positionings and alignments (e.g. aligned at
5060cdf0e10cSrcweir                         // page area, but anchored at-character), the position
5061cdf0e10cSrcweir                         // of the Writer fly frame has to be invalidated.
5062cdf0e10cSrcweir                         pFly->InvalidatePos();
5063cdf0e10cSrcweir 
5064cdf0e10cSrcweir                         // --> OD 2004-11-04 #i26945# - follow-up of #i3317#
5065cdf0e10cSrcweir                         // No arrangement of lowers, if Writer fly frame isn't
5066cdf0e10cSrcweir                         // moved
5067cdf0e10cSrcweir                         if ( bDirectMove &&
5068cdf0e10cSrcweir                              ::lcl_ArrangeLowers( pFly,
5069cdf0e10cSrcweir                                                   (pFly->*fnRect->fnGetPrtTop)(),
5070cdf0e10cSrcweir                                                   bInva ) )
5071cdf0e10cSrcweir                         // <--
5072cdf0e10cSrcweir                         {
5073cdf0e10cSrcweir 							pFly->SetCompletePaint();
5074cdf0e10cSrcweir                         }
5075cdf0e10cSrcweir 					}
5076cdf0e10cSrcweir                     else if ( pAnchoredObj->ISA(SwAnchoredDrawObject) )
5077cdf0e10cSrcweir                     {
5078cdf0e10cSrcweir                         // --> OD 2004-11-05 #i26945#
5079cdf0e10cSrcweir                         const SwTabFrm* pTabFrm = pLay->FindTabFrm();
5080cdf0e10cSrcweir                         if ( pTabFrm &&
5081cdf0e10cSrcweir                              !( pTabFrm->IsFollow() &&
5082cdf0e10cSrcweir                                 pTabFrm->FindMaster()->IsRebuildLastLine() ) &&
5083cdf0e10cSrcweir                              !pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId()
5084cdf0e10cSrcweir                                                             == FLY_AS_CHAR )
5085cdf0e10cSrcweir                         {
5086cdf0e10cSrcweir                             SwPageFrm* pPageFrm = pAnchoredObj->GetPageFrm();
5087cdf0e10cSrcweir                             SwPageFrm* pPageOfAnchor = pFrm->FindPageFrm();
5088cdf0e10cSrcweir                             if ( pPageFrm != pPageOfAnchor )
5089cdf0e10cSrcweir                             {
5090cdf0e10cSrcweir                                 pAnchoredObj->InvalidateObjPos();
5091cdf0e10cSrcweir                                 if ( pPageFrm )
5092cdf0e10cSrcweir                                 {
5093cdf0e10cSrcweir                                     pPageFrm->RemoveDrawObjFromPage( *pAnchoredObj );
5094cdf0e10cSrcweir                                 }
5095cdf0e10cSrcweir                                 pPageOfAnchor->AppendDrawObjToPage( *pAnchoredObj );
5096cdf0e10cSrcweir                             }
5097cdf0e10cSrcweir                         }
5098cdf0e10cSrcweir                         // --> OD 2004-07-01 #i28701# - adjust last character
5099cdf0e10cSrcweir                         // rectangle and last top of line.
5100cdf0e10cSrcweir                         pAnchoredObj->AddLastCharY( lDiff );
5101cdf0e10cSrcweir                         pAnchoredObj->AddLastTopOfLineY( lDiff );
5102cdf0e10cSrcweir                         // --> OD 2005-08-08 #i52904# - re-introduce direct move
5103cdf0e10cSrcweir                         // of drawing objects
5104cdf0e10cSrcweir                         const bool bDirectMove =
5105cdf0e10cSrcweir                                 static_cast<const SwDrawFrmFmt&>(pAnchoredObj->GetFrmFmt()).IsPosAttrSet() &&
5106cdf0e10cSrcweir                                 bVertPosDepOnAnchor &&
5107cdf0e10cSrcweir                                 !pAnchoredObj->ConsiderObjWrapInfluenceOnObjPos();
5108cdf0e10cSrcweir                         if ( bDirectMove )
5109cdf0e10cSrcweir                         {
5110cdf0e10cSrcweir                             SwObjPositioningInProgress aObjPosInProgress( *pAnchoredObj );
5111cdf0e10cSrcweir                             if ( bVert )
5112cdf0e10cSrcweir                             {
5113cdf0e10cSrcweir                                 pAnchoredObj->DrawObj()->Move( Size( lDiff, 0 ) );
5114cdf0e10cSrcweir                             }
5115cdf0e10cSrcweir                             else
5116cdf0e10cSrcweir                             {
5117cdf0e10cSrcweir                                 pAnchoredObj->DrawObj()->Move( Size( 0, lDiff ) );
5118cdf0e10cSrcweir                             }
5119cdf0e10cSrcweir                             // --> OD 2006-10-13 #i58280#
5120cdf0e10cSrcweir                             pAnchoredObj->InvalidateObjRectWithSpaces();
5121cdf0e10cSrcweir                             // <--
5122cdf0e10cSrcweir                         }
5123cdf0e10cSrcweir                         // <--
5124cdf0e10cSrcweir                         pAnchoredObj->InvalidateObjPos();
5125cdf0e10cSrcweir                     }
5126cdf0e10cSrcweir                     else
5127cdf0e10cSrcweir                     {
5128cdf0e10cSrcweir                         ASSERT( false,
5129cdf0e10cSrcweir                                 "<lcl_ArrangeLowers(..)> - unknown type of anchored object!" );
5130cdf0e10cSrcweir                     }
5131cdf0e10cSrcweir 				}
5132cdf0e10cSrcweir 			}
5133cdf0e10cSrcweir 		}
5134cdf0e10cSrcweir         // Columns and cells are ordered horizontal, not vertical
5135cdf0e10cSrcweir         if( !pFrm->IsColumnFrm() && !pFrm->IsCellFrm() )
5136cdf0e10cSrcweir             lYStart = (*fnRect->fnYInc)( lYStart,
5137cdf0e10cSrcweir                                         (pFrm->Frm().*fnRect->fnGetHeight)() );
5138cdf0e10cSrcweir 
5139cdf0e10cSrcweir         // Nowadays, the content inside a cell can flow into the follow table.
5140cdf0e10cSrcweir         // Thus, the cell may only grow up to the end of the environment.
5141cdf0e10cSrcweir         // So the content may have grown, but the cell could not grow.
5142cdf0e10cSrcweir         // Therefore we have to trigger a formatting for the frames, which do
5143cdf0e10cSrcweir         // not fit into the cell anymore:
5144cdf0e10cSrcweir         SwTwips nDistanceToUpperPrtBottom =
5145cdf0e10cSrcweir             (pFrm->Frm().*fnRect->fnBottomDist)( (pLay->*fnRect->fnGetPrtBottom)());
5146cdf0e10cSrcweir         // --> OD 2006-01-19 #i56146# - Revise fix of issue #i26945#
5147cdf0e10cSrcweir         // do *not* consider content inside fly frames, if it's an undersized paragraph.
5148cdf0e10cSrcweir         // --> OD 2004-10-08 #i26945# - consider content inside fly frames
5149cdf0e10cSrcweir         if ( nDistanceToUpperPrtBottom < 0 &&
5150cdf0e10cSrcweir              ( ( pFrm->IsInFly() &&
5151cdf0e10cSrcweir                  ( !pFrm->IsTxtFrm() ||
5152cdf0e10cSrcweir                    !static_cast<SwTxtFrm*>(pFrm)->IsUndersized() ) ) ||
5153cdf0e10cSrcweir                pFrm->IsInSplitTableRow() ) )
5154cdf0e10cSrcweir         // <--
5155cdf0e10cSrcweir         {
5156cdf0e10cSrcweir             pFrm->InvalidatePos();
5157cdf0e10cSrcweir         }
5158cdf0e10cSrcweir 
5159cdf0e10cSrcweir 		pFrm = pFrm->GetNext();
5160cdf0e10cSrcweir 	}
5161cdf0e10cSrcweir 	return bRet;
5162cdf0e10cSrcweir }
5163cdf0e10cSrcweir 
Format(const SwBorderAttrs * pAttrs)5164cdf0e10cSrcweir void SwCellFrm::Format( const SwBorderAttrs *pAttrs )
5165cdf0e10cSrcweir {
5166cdf0e10cSrcweir     ASSERT( pAttrs, "CellFrm::Format, pAttrs ist 0." );
5167cdf0e10cSrcweir     const SwTabFrm* pTab = FindTabFrm();
5168cdf0e10cSrcweir     SWRECTFN( pTab )
5169cdf0e10cSrcweir 
5170cdf0e10cSrcweir     if ( !bValidPrtArea )
5171cdf0e10cSrcweir 	{
5172cdf0e10cSrcweir 		bValidPrtArea = sal_True;
5173cdf0e10cSrcweir 
5174cdf0e10cSrcweir         //Position einstellen.
5175cdf0e10cSrcweir         if ( Lower() )
5176cdf0e10cSrcweir         {
5177cdf0e10cSrcweir             SwTwips nTopSpace, nBottomSpace, nLeftSpace, nRightSpace;
5178cdf0e10cSrcweir             // --> collapsing borders FME 2005-05-27 #i29550#
5179cdf0e10cSrcweir             if ( pTab->IsCollapsingBorders() && !Lower()->IsRowFrm()  )
5180cdf0e10cSrcweir             {
5181cdf0e10cSrcweir                 const SvxBoxItem& rBoxItem = pAttrs->GetBox();
5182cdf0e10cSrcweir                 nLeftSpace   = rBoxItem.GetDistance( BOX_LINE_LEFT );
5183cdf0e10cSrcweir                 nRightSpace  = rBoxItem.GetDistance( BOX_LINE_RIGHT );
5184cdf0e10cSrcweir                 nTopSpace    =  ((SwRowFrm*)GetUpper())->GetTopMarginForLowers();
5185cdf0e10cSrcweir                 nBottomSpace =  ((SwRowFrm*)GetUpper())->GetBottomMarginForLowers();
5186cdf0e10cSrcweir             }
5187cdf0e10cSrcweir             else
5188cdf0e10cSrcweir             {
5189cdf0e10cSrcweir             // <-- collapsing
5190cdf0e10cSrcweir                 // OD 23.01.2003 #106895# - add 1st param to <SwBorderAttrs::CalcRight(..)>
5191cdf0e10cSrcweir                 nLeftSpace   = pAttrs->CalcLeft( this );
5192cdf0e10cSrcweir                 nRightSpace  = pAttrs->CalcRight( this );
5193cdf0e10cSrcweir                 nTopSpace    = pAttrs->CalcTop();
5194cdf0e10cSrcweir                 nBottomSpace = pAttrs->CalcBottom();
5195cdf0e10cSrcweir             }
5196cdf0e10cSrcweir             (this->*fnRect->fnSetXMargins)( nLeftSpace, nRightSpace );
5197cdf0e10cSrcweir             (this->*fnRect->fnSetYMargins)( nTopSpace, nBottomSpace );
5198cdf0e10cSrcweir         }
5199cdf0e10cSrcweir     }
5200cdf0e10cSrcweir     // --> OD 2004-10-04 #i26945#
5201cdf0e10cSrcweir     long nRemaining = GetTabBox()->getRowSpan() >= 1 ?
5202cdf0e10cSrcweir                       ::lcl_CalcMinCellHeight( this, pTab->IsConsiderObjsForMinCellHeight(), pAttrs ) :
5203cdf0e10cSrcweir                       0;
5204cdf0e10cSrcweir     // <--
5205cdf0e10cSrcweir 	if ( !bValidSize )
5206cdf0e10cSrcweir 	{
5207cdf0e10cSrcweir 		bValidSize = sal_True;
5208cdf0e10cSrcweir 
5209cdf0e10cSrcweir 		//Die VarSize der CellFrms ist immer die Breite.
5210cdf0e10cSrcweir 		//Tatsaechlich ist die Breite jedoch nicht Variabel, sie wird durch das
5211cdf0e10cSrcweir 		//Format vorgegeben. Dieser Vorgegebene Wert muss aber nun wiederum
5212cdf0e10cSrcweir 		//nicht der tatsaechlichen Breite entsprechen. Die Breite wird auf
5213cdf0e10cSrcweir 		//Basis des Attributes errechnet, der Wert im Attribut passt zu dem
5214cdf0e10cSrcweir 		//gewuenschten Wert des TabFrms. Anpassungen die dort vorgenommen
5215cdf0e10cSrcweir 		//wurden werden hier Proportional beruecksichtigt.
5216cdf0e10cSrcweir 		//Wenn die Celle keinen Nachbarn mehr hat beruecksichtigt sie nicht
5217cdf0e10cSrcweir 		//die Attribute, sonder greift sich einfach den Rest des
5218cdf0e10cSrcweir         //Uppers
5219cdf0e10cSrcweir 		SwTwips nWidth;
5220cdf0e10cSrcweir         if ( GetNext() )
5221cdf0e10cSrcweir 		{
5222cdf0e10cSrcweir             const SwTwips nWish = pTab->GetFmt()->GetFrmSize().GetWidth();
5223cdf0e10cSrcweir 			nWidth = pAttrs->GetSize().Width();
5224cdf0e10cSrcweir 
5225cdf0e10cSrcweir 			ASSERT( nWish, "Tabelle ohne Breite?" );
5226cdf0e10cSrcweir 			ASSERT( nWidth <= nWish, "Zelle breiter als Tabelle." );
5227cdf0e10cSrcweir 			ASSERT( nWidth > 0, "Box without width" );
5228cdf0e10cSrcweir 
5229cdf0e10cSrcweir             const long nPrtWidth = (pTab->Prt().*fnRect->fnGetWidth)();
5230cdf0e10cSrcweir             if ( nWish != nPrtWidth )
5231cdf0e10cSrcweir 			{
5232cdf0e10cSrcweir                 // Avoid rounding problems, at least for the new table model
5233cdf0e10cSrcweir                 if ( pTab->GetTable()->IsNewModel() )
5234cdf0e10cSrcweir                 {
5235cdf0e10cSrcweir                     // 1. sum of widths of cells up to this cell (in model)
5236cdf0e10cSrcweir                     const SwTableLine* pTabLine = GetTabBox()->GetUpper();
5237cdf0e10cSrcweir                     const SwTableBoxes& rBoxes = pTabLine->GetTabBoxes();
5238cdf0e10cSrcweir                     const SwTableBox* pTmpBox = 0;
5239cdf0e10cSrcweir 
5240cdf0e10cSrcweir                     SwTwips nSumWidth = 0;
5241cdf0e10cSrcweir                     sal_uInt16 i = 0;
5242cdf0e10cSrcweir                     do
5243cdf0e10cSrcweir                     {
5244cdf0e10cSrcweir                         pTmpBox = rBoxes[ i++ ];
5245cdf0e10cSrcweir                         nSumWidth += pTmpBox->GetFrmFmt()->GetFrmSize().GetWidth();
5246cdf0e10cSrcweir                     }
5247cdf0e10cSrcweir                     while ( pTmpBox != GetTabBox() );
5248cdf0e10cSrcweir 
5249cdf0e10cSrcweir                     // 2. calculate actual width of cells up to this one
5250cdf0e10cSrcweir                     double nTmpWidth = nSumWidth;
5251cdf0e10cSrcweir                     nTmpWidth *= nPrtWidth;
5252cdf0e10cSrcweir                     nTmpWidth /= nWish;
5253cdf0e10cSrcweir                     nWidth = (SwTwips)nTmpWidth;
5254cdf0e10cSrcweir 
5255cdf0e10cSrcweir                     // 3. calculate frame widths of cells up to this one:
5256cdf0e10cSrcweir                     const SwFrm* pTmpCell = static_cast<const SwLayoutFrm*>(GetUpper())->Lower();
5257cdf0e10cSrcweir                     SwTwips nSumFrameWidths = 0;
5258cdf0e10cSrcweir                     while ( pTmpCell != this )
5259cdf0e10cSrcweir                     {
5260cdf0e10cSrcweir                         nSumFrameWidths += (pTmpCell->Frm().*fnRect->fnGetWidth)();
5261cdf0e10cSrcweir                         pTmpCell = pTmpCell->GetNext();
5262cdf0e10cSrcweir                     }
5263cdf0e10cSrcweir 
5264cdf0e10cSrcweir                     nWidth = nWidth - nSumFrameWidths;
5265cdf0e10cSrcweir                 }
5266cdf0e10cSrcweir                 else
5267cdf0e10cSrcweir                 {
5268cdf0e10cSrcweir                     // #i12092# use double instead of long,
5269cdf0e10cSrcweir                     // otherwise this could lead to overflows
5270cdf0e10cSrcweir                     double nTmpWidth = nWidth;
5271cdf0e10cSrcweir                     nTmpWidth *= nPrtWidth;
5272cdf0e10cSrcweir                     nTmpWidth /= nWish;
5273cdf0e10cSrcweir                     nWidth = (SwTwips)nTmpWidth;
5274cdf0e10cSrcweir                 }
5275cdf0e10cSrcweir             }
5276cdf0e10cSrcweir 		}
5277cdf0e10cSrcweir 		else
5278cdf0e10cSrcweir 		{
5279cdf0e10cSrcweir 			ASSERT( pAttrs->GetSize().Width() > 0, "Box without width" );
5280cdf0e10cSrcweir             nWidth = (GetUpper()->Prt().*fnRect->fnGetWidth)();
5281cdf0e10cSrcweir 			SwFrm *pPre = GetUpper()->Lower();
5282cdf0e10cSrcweir 			while ( pPre != this )
5283cdf0e10cSrcweir             {
5284cdf0e10cSrcweir                 nWidth -= (pPre->Frm().*fnRect->fnGetWidth)();
5285cdf0e10cSrcweir 				pPre = pPre->GetNext();
5286cdf0e10cSrcweir 			}
5287cdf0e10cSrcweir 		}
5288cdf0e10cSrcweir         const long nDiff = nWidth - (Frm().*fnRect->fnGetWidth)();
5289cdf0e10cSrcweir         if( IsNeighbourFrm() && IsRightToLeft() )
5290cdf0e10cSrcweir             (Frm().*fnRect->fnSubLeft)( nDiff );
5291cdf0e10cSrcweir         else
5292cdf0e10cSrcweir             (Frm().*fnRect->fnAddRight)( nDiff );
5293cdf0e10cSrcweir         (Prt().*fnRect->fnAddRight)( nDiff );
5294cdf0e10cSrcweir 
5295cdf0e10cSrcweir 		//Jetzt die Hoehe einstellen, sie wird vom Inhalt und den Raendern
5296cdf0e10cSrcweir 		//bestimmt.
5297cdf0e10cSrcweir         const long nDiffHeight = nRemaining - (Frm().*fnRect->fnGetHeight)();
5298cdf0e10cSrcweir 		if ( nDiffHeight )
5299cdf0e10cSrcweir 		{
5300cdf0e10cSrcweir 			if ( nDiffHeight > 0 )
5301cdf0e10cSrcweir 			{
5302cdf0e10cSrcweir 				//Wieder validieren wenn kein Wachstum stattgefunden hat.
5303cdf0e10cSrcweir 				//Invalidiert wird durch AdjustCells von der Row.
5304cdf0e10cSrcweir                 if ( !Grow( nDiffHeight ) )
5305cdf0e10cSrcweir 					bValidSize = bValidPrtArea = sal_True;
5306cdf0e10cSrcweir 			}
5307cdf0e10cSrcweir 			else
5308cdf0e10cSrcweir 			{
5309cdf0e10cSrcweir 				//Nur dann invalidiert lassen, wenn tatsaechlich
5310cdf0e10cSrcweir 				//geshrinkt wurde; das kann abgelehnt werden, weil alle
5311cdf0e10cSrcweir 				//nebeneinanderliegenden Zellen gleichgross sein muessen.
5312cdf0e10cSrcweir                 if ( !Shrink( -nDiffHeight ) )
5313cdf0e10cSrcweir 					bValidSize = bValidPrtArea = sal_True;
5314cdf0e10cSrcweir 			}
5315cdf0e10cSrcweir 		}
5316cdf0e10cSrcweir 	}
5317cdf0e10cSrcweir 	const SwFmtVertOrient &rOri = pAttrs->GetAttrSet().GetVertOrient();
5318cdf0e10cSrcweir 
5319cdf0e10cSrcweir     if ( !Lower() )
5320cdf0e10cSrcweir         return;
5321cdf0e10cSrcweir 
5322cdf0e10cSrcweir     // From now on, all operations are related to the table cell.
5323cdf0e10cSrcweir     SWREFRESHFN( this )
5324cdf0e10cSrcweir 
5325cdf0e10cSrcweir     SwPageFrm* pPg = 0;
5326cdf0e10cSrcweir     if ( !FindTabFrm()->IsRebuildLastLine() && text::VertOrientation::NONE != rOri.GetVertOrient() &&
5327cdf0e10cSrcweir     // --> OD 2008-07-16 #158225# no vertical alignment of covered cells
5328cdf0e10cSrcweir          !IsCoveredCell() &&
5329cdf0e10cSrcweir     // <--
5330cdf0e10cSrcweir     // --> FME 2004-06-29 #116532# Do not consider vertical alignment in grid mode
5331cdf0e10cSrcweir          !(pPg = FindPageFrm())->HasGrid() )
5332cdf0e10cSrcweir     // <--
5333cdf0e10cSrcweir 	{
5334cdf0e10cSrcweir         if ( !Lower()->IsCntntFrm() && !Lower()->IsSctFrm() && !Lower()->IsTabFrm() )
5335cdf0e10cSrcweir 		{
5336cdf0e10cSrcweir 			//ASSERT fuer HTML-Import!
5337cdf0e10cSrcweir 			ASSERT( !this, "VAlign an Zelle ohne Inhalt" );
5338cdf0e10cSrcweir 			return;
5339cdf0e10cSrcweir 		}
5340cdf0e10cSrcweir 		sal_Bool bVertDir = sal_True;
5341cdf0e10cSrcweir         // --> OD 2005-03-30 #i43913# - no vertical alignment, if wrapping
5342cdf0e10cSrcweir         // style influence is considered on object positioning and
5343cdf0e10cSrcweir         // an object is anchored inside the cell.
5344cdf0e10cSrcweir         const bool bConsiderWrapOnObjPos( GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) );
5345cdf0e10cSrcweir         // <--
5346cdf0e10cSrcweir         //Keine Ausrichtung wenn Rahmen mit Umlauf in die Zelle ragen.
5347cdf0e10cSrcweir 		if ( pPg->GetSortedObjs() )
5348cdf0e10cSrcweir 		{
5349cdf0e10cSrcweir 			SwRect aRect( Prt() ); aRect += Frm().Pos();
5350cdf0e10cSrcweir 			for ( sal_uInt16 i = 0; i < pPg->GetSortedObjs()->Count(); ++i )
5351cdf0e10cSrcweir 			{
5352cdf0e10cSrcweir                 const SwAnchoredObject* pAnchoredObj = (*pPg->GetSortedObjs())[i];
5353cdf0e10cSrcweir                 SwRect aTmp( pAnchoredObj->GetObjRect() );
5354cdf0e10cSrcweir 				if ( aTmp.IsOver( aRect ) )
5355cdf0e10cSrcweir 				{
5356cdf0e10cSrcweir                     const SwFrmFmt& rAnchoredObjFrmFmt = pAnchoredObj->GetFrmFmt();
5357cdf0e10cSrcweir                     const SwFmtSurround &rSur = rAnchoredObjFrmFmt.GetSurround();
5358cdf0e10cSrcweir 
5359cdf0e10cSrcweir                     if ( SURROUND_THROUGHT != rSur.GetSurround() )
5360cdf0e10cSrcweir 					{
5361cdf0e10cSrcweir                         // frames, which the cell is a lower of, aren't relevant
5362cdf0e10cSrcweir                         if ( pAnchoredObj->ISA(SwFlyFrm) )
5363cdf0e10cSrcweir 						{
5364cdf0e10cSrcweir                             const SwFlyFrm *pFly =
5365cdf0e10cSrcweir                                     static_cast<const SwFlyFrm*>(pAnchoredObj);
5366cdf0e10cSrcweir 							if ( pFly->IsAnLower( this ) )
5367cdf0e10cSrcweir 								continue;
5368cdf0e10cSrcweir 						}
5369cdf0e10cSrcweir 
5370cdf0e10cSrcweir                         const SwFrm* pAnch = pAnchoredObj->GetAnchorFrm();
5371cdf0e10cSrcweir                         // --> OD 2005-03-30 #i43913#
5372cdf0e10cSrcweir                         // --> OD 2005-08-08 #i52904# - no vertical alignment,
5373cdf0e10cSrcweir                         // if object, anchored inside cell, has temporarly
5374cdf0e10cSrcweir                         // consider its wrapping style on object positioning.
5375cdf0e10cSrcweir                         // --> FME 2006-02-01 #i58806# - no vertical alignment
5376cdf0e10cSrcweir                         // if object does not follow the text flow.
5377cdf0e10cSrcweir                         if ( bConsiderWrapOnObjPos ||
5378cdf0e10cSrcweir                              !IsAnLower( pAnch ) ||
5379cdf0e10cSrcweir                              pAnchoredObj->IsTmpConsiderWrapInfluence() ||
5380cdf0e10cSrcweir                              !rAnchoredObjFrmFmt.GetFollowTextFlow().GetValue() )
5381cdf0e10cSrcweir                         // <--
5382cdf0e10cSrcweir 						{
5383cdf0e10cSrcweir 							bVertDir = sal_False;
5384cdf0e10cSrcweir 							break;
5385cdf0e10cSrcweir 						}
5386cdf0e10cSrcweir 					}
5387cdf0e10cSrcweir 				}
5388cdf0e10cSrcweir 			}
5389cdf0e10cSrcweir 		}
5390cdf0e10cSrcweir 
5391cdf0e10cSrcweir         long nPrtHeight = (Prt().*fnRect->fnGetHeight)();
5392cdf0e10cSrcweir         if( ( bVertDir && ( nRemaining -= lcl_CalcTopAndBottomMargin( *this, *pAttrs ) ) < nPrtHeight ) ||
5393cdf0e10cSrcweir             (Lower()->Frm().*fnRect->fnGetTop)() != (this->*fnRect->fnGetPrtTop)() )
5394cdf0e10cSrcweir 		{
5395cdf0e10cSrcweir 			long lTopOfst = 0,
5396cdf0e10cSrcweir                     nDiff = (Prt().*fnRect->fnGetHeight)() - nRemaining;
5397cdf0e10cSrcweir             if ( nDiff >= 0 )
5398cdf0e10cSrcweir 			{
5399cdf0e10cSrcweir 				if ( bVertDir )
5400cdf0e10cSrcweir 				{
5401cdf0e10cSrcweir 					switch ( rOri.GetVertOrient() )
5402cdf0e10cSrcweir 					{
5403cdf0e10cSrcweir                         case text::VertOrientation::CENTER:   lTopOfst = nDiff / 2; break;
5404cdf0e10cSrcweir                         case text::VertOrientation::BOTTOM:   lTopOfst = nDiff;     break;
5405cdf0e10cSrcweir                         default: break;
5406cdf0e10cSrcweir 					};
5407cdf0e10cSrcweir 				}
5408cdf0e10cSrcweir                 long nTmp = (*fnRect->fnYInc)(
5409cdf0e10cSrcweir                                     (this->*fnRect->fnGetPrtTop)(), lTopOfst );
5410cdf0e10cSrcweir                 if ( lcl_ArrangeLowers( this, nTmp, !bVertDir ) )
5411cdf0e10cSrcweir 					SetCompletePaint();
5412cdf0e10cSrcweir 			}
5413cdf0e10cSrcweir 		}
5414cdf0e10cSrcweir 	}
5415cdf0e10cSrcweir 	else
5416cdf0e10cSrcweir 	{
5417cdf0e10cSrcweir 		//Ist noch eine alte Ausrichtung beruecksichtigt worden?
5418cdf0e10cSrcweir 		if ( Lower()->IsCntntFrm() )
5419cdf0e10cSrcweir 		{
5420cdf0e10cSrcweir             const long lYStart = (this->*fnRect->fnGetPrtTop)();
5421cdf0e10cSrcweir 			lcl_ArrangeLowers( this, lYStart, sal_True );
5422cdf0e10cSrcweir 		}
5423cdf0e10cSrcweir 	}
5424cdf0e10cSrcweir }
5425cdf0e10cSrcweir 
5426cdf0e10cSrcweir /*************************************************************************
5427cdf0e10cSrcweir |*
5428cdf0e10cSrcweir |*	  SwCellFrm::Modify()
5429cdf0e10cSrcweir |*
5430cdf0e10cSrcweir |*	  Ersterstellung	MA 20. Dec. 96
5431cdf0e10cSrcweir |*	  Letzte Aenderung	MA 20. Dec. 96
5432cdf0e10cSrcweir |*
5433cdf0e10cSrcweir |*************************************************************************/
5434cdf0e10cSrcweir 
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)5435cdf0e10cSrcweir void SwCellFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
5436cdf0e10cSrcweir {
5437cdf0e10cSrcweir 	sal_Bool bAttrSetChg = pNew && RES_ATTRSET_CHG == pNew->Which();
5438cdf0e10cSrcweir 	const SfxPoolItem *pItem = 0;
5439cdf0e10cSrcweir 
5440cdf0e10cSrcweir 	if( bAttrSetChg )
5441cdf0e10cSrcweir 		((SwAttrSetChg*)pNew)->GetChgSet()->GetItemState( RES_VERT_ORIENT, sal_False, &pItem);
5442cdf0e10cSrcweir 	else if ( RES_VERT_ORIENT == pNew->Which() )
5443cdf0e10cSrcweir 		pItem = pNew;
5444cdf0e10cSrcweir 
5445cdf0e10cSrcweir 	if ( pItem )
5446cdf0e10cSrcweir 	{
5447cdf0e10cSrcweir 		sal_Bool bInva = sal_True;
5448cdf0e10cSrcweir         if ( text::VertOrientation::NONE == ((SwFmtVertOrient*)pItem)->GetVertOrient() &&
5449cdf0e10cSrcweir              // OD 04.11.2003 #112910#
5450cdf0e10cSrcweir              Lower() && Lower()->IsCntntFrm() )
5451cdf0e10cSrcweir 		{
5452cdf0e10cSrcweir             SWRECTFN( this )
5453cdf0e10cSrcweir             const long lYStart = (this->*fnRect->fnGetPrtTop)();
5454cdf0e10cSrcweir 			bInva = lcl_ArrangeLowers( this, lYStart, sal_False );
5455cdf0e10cSrcweir 		}
5456cdf0e10cSrcweir 		if ( bInva )
5457cdf0e10cSrcweir 		{
5458cdf0e10cSrcweir 			SetCompletePaint();
5459cdf0e10cSrcweir 			InvalidatePrt();
5460cdf0e10cSrcweir 		}
5461cdf0e10cSrcweir 	}
5462cdf0e10cSrcweir 
5463cdf0e10cSrcweir 	if ( ( bAttrSetChg &&
5464cdf0e10cSrcweir 	       SFX_ITEM_SET == ((SwAttrSetChg*)pNew)->GetChgSet()->GetItemState( RES_PROTECT, sal_False ) ) ||
5465cdf0e10cSrcweir 		 RES_PROTECT == pNew->Which() )
5466cdf0e10cSrcweir 	{
5467cdf0e10cSrcweir 		ViewShell *pSh = getRootFrm()->GetCurrShell();
5468cdf0e10cSrcweir 		if( pSh && pSh->GetLayout()->IsAnyShellAccessible() )
5469cdf0e10cSrcweir 			pSh->Imp()->InvalidateAccessibleEditableState( sal_True, this );
5470cdf0e10cSrcweir 	}
5471cdf0e10cSrcweir 
5472cdf0e10cSrcweir 	if ( bAttrSetChg &&
5473cdf0e10cSrcweir 	     SFX_ITEM_SET == ((SwAttrSetChg*)pNew)->GetChgSet()->GetItemState( RES_FRAMEDIR, sal_False, &pItem ) )
5474cdf0e10cSrcweir 	{
5475cdf0e10cSrcweir         SetDerivedVert( sal_False );
5476cdf0e10cSrcweir         CheckDirChange();
5477cdf0e10cSrcweir     }
5478cdf0e10cSrcweir 
5479cdf0e10cSrcweir     // --> collapsing borders FME 2005-05-27 #i29550#
5480cdf0e10cSrcweir     if ( bAttrSetChg &&
5481cdf0e10cSrcweir          SFX_ITEM_SET == ((SwAttrSetChg*)pNew)->GetChgSet()->GetItemState( RES_BOX, sal_False, &pItem ) )
5482cdf0e10cSrcweir 	{
5483cdf0e10cSrcweir         SwFrm* pTmpUpper = GetUpper();
5484cdf0e10cSrcweir         while ( pTmpUpper->GetUpper() && !pTmpUpper->GetUpper()->IsTabFrm() )
5485cdf0e10cSrcweir             pTmpUpper = pTmpUpper->GetUpper();
5486cdf0e10cSrcweir 
5487cdf0e10cSrcweir         SwTabFrm* pTabFrm = (SwTabFrm*)pTmpUpper->GetUpper();
5488cdf0e10cSrcweir         if ( pTabFrm->IsCollapsingBorders() )
5489cdf0e10cSrcweir         {
5490cdf0e10cSrcweir             // Invalidate lowers of this and next row:
5491cdf0e10cSrcweir             lcl_InvalidateAllLowersPrt( (SwRowFrm*)pTmpUpper );
5492cdf0e10cSrcweir             pTmpUpper = pTmpUpper->GetNext();
5493cdf0e10cSrcweir             if ( pTmpUpper )
5494cdf0e10cSrcweir                 lcl_InvalidateAllLowersPrt( (SwRowFrm*)pTmpUpper );
5495cdf0e10cSrcweir             else
5496cdf0e10cSrcweir                 pTabFrm->InvalidatePrt();
5497cdf0e10cSrcweir         }
5498cdf0e10cSrcweir     }
5499cdf0e10cSrcweir     // <-- collapsing
5500cdf0e10cSrcweir 
5501cdf0e10cSrcweir 	SwLayoutFrm::Modify( pOld, pNew );
5502cdf0e10cSrcweir }
5503cdf0e10cSrcweir 
5504cdf0e10cSrcweir /*************************************************************************
5505cdf0e10cSrcweir |*  SwCellFrm::GetLayoutRowSpan() const
5506cdf0e10cSrcweir |*************************************************************************/
5507cdf0e10cSrcweir 
GetLayoutRowSpan() const5508cdf0e10cSrcweir long SwCellFrm::GetLayoutRowSpan() const
5509cdf0e10cSrcweir {
5510cdf0e10cSrcweir     long nRet = GetTabBox()->getRowSpan();
5511cdf0e10cSrcweir     if ( nRet < 1 )
5512cdf0e10cSrcweir     {
5513cdf0e10cSrcweir         const SwFrm* pRow = GetUpper();
5514cdf0e10cSrcweir         const SwTabFrm* pTab = static_cast<const SwTabFrm*>(pRow->GetUpper());
5515cdf0e10cSrcweir 
5516cdf0e10cSrcweir         if ( pTab && pTab->IsFollow() && pRow == pTab->GetFirstNonHeadlineRow() )
5517cdf0e10cSrcweir             nRet = -nRet;
5518cdf0e10cSrcweir     }
5519cdf0e10cSrcweir     return  nRet;
5520cdf0e10cSrcweir }
5521cdf0e10cSrcweir 
5522cdf0e10cSrcweir // --> OD 2010-02-17 #i103961#
Cut()5523cdf0e10cSrcweir void SwCellFrm::Cut()
5524cdf0e10cSrcweir {
5525cdf0e10cSrcweir     // notification for accessibility
5526cdf0e10cSrcweir     {
5527cdf0e10cSrcweir         SwRootFrm *pRootFrm = getRootFrm();
5528cdf0e10cSrcweir         if( pRootFrm && pRootFrm->IsAnyShellAccessible() )
5529cdf0e10cSrcweir         {
5530cdf0e10cSrcweir             ViewShell* pVSh = pRootFrm->GetCurrShell();
5531cdf0e10cSrcweir             if ( pVSh && pVSh->Imp() )
5532cdf0e10cSrcweir             {
5533cdf0e10cSrcweir                 pVSh->Imp()->DisposeAccessibleFrm( this );
5534cdf0e10cSrcweir             }
5535cdf0e10cSrcweir         }
5536cdf0e10cSrcweir     }
5537cdf0e10cSrcweir 
5538cdf0e10cSrcweir     SwLayoutFrm::Cut();
5539cdf0e10cSrcweir }
5540cdf0e10cSrcweir // <--
5541cdf0e10cSrcweir 
5542cdf0e10cSrcweir //
5543cdf0e10cSrcweir // Helper functions for repeated headlines:
5544cdf0e10cSrcweir //
5545cdf0e10cSrcweir 
5546cdf0e10cSrcweir /*
5547cdf0e10cSrcweir  * SwTabFrm::IsInHeadline( const SwFrm& rFrm )
5548cdf0e10cSrcweir  */
IsInHeadline(const SwFrm & rFrm) const5549cdf0e10cSrcweir bool SwTabFrm::IsInHeadline( const SwFrm& rFrm ) const
5550cdf0e10cSrcweir {
5551cdf0e10cSrcweir     ASSERT( IsAnLower( &rFrm ) && rFrm.IsInTab(),
5552cdf0e10cSrcweir              "SwTabFrm::IsInHeadline called for frame not lower of table" )
5553cdf0e10cSrcweir 
5554cdf0e10cSrcweir     const SwFrm* pTmp = &rFrm;
5555cdf0e10cSrcweir     while ( !pTmp->GetUpper()->IsTabFrm() )
5556cdf0e10cSrcweir         pTmp = pTmp->GetUpper();
5557cdf0e10cSrcweir 
5558cdf0e10cSrcweir     return GetTable()->IsHeadline( *((SwRowFrm*)pTmp)->GetTabLine() );
5559cdf0e10cSrcweir }
5560cdf0e10cSrcweir 
5561cdf0e10cSrcweir /*
5562cdf0e10cSrcweir  * SwTabFrm::GetFirstNonHeadlineRow()
5563cdf0e10cSrcweir  *
5564cdf0e10cSrcweir  * If this is a master table, we can may assume, that there are at least
5565cdf0e10cSrcweir  * nRepeat lines in the table.
5566cdf0e10cSrcweir  * If this is a follow table, there are intermediate states for the table
5567cdf0e10cSrcweir  * layout, e.g., during deletion of rows, which makes it necessary to find
5568cdf0e10cSrcweir  * the first non-headline row by evaluating the headline flag at the row frame.
5569cdf0e10cSrcweir  */
GetFirstNonHeadlineRow() const5570cdf0e10cSrcweir SwRowFrm* SwTabFrm::GetFirstNonHeadlineRow() const
5571cdf0e10cSrcweir {
5572cdf0e10cSrcweir     SwRowFrm* pRet = (SwRowFrm*)Lower();
5573cdf0e10cSrcweir     if ( pRet )
5574cdf0e10cSrcweir     {
5575cdf0e10cSrcweir         if ( IsFollow() )
5576cdf0e10cSrcweir         {
5577cdf0e10cSrcweir             while ( pRet && pRet->IsRepeatedHeadline() )
5578cdf0e10cSrcweir                 pRet = (SwRowFrm*)pRet->GetNext();
5579cdf0e10cSrcweir         }
5580cdf0e10cSrcweir         else
5581cdf0e10cSrcweir         {
5582cdf0e10cSrcweir             sal_uInt16 nRepeat = GetTable()->GetRowsToRepeat();
5583cdf0e10cSrcweir             while ( pRet && nRepeat > 0 )
5584cdf0e10cSrcweir             {
5585cdf0e10cSrcweir                 pRet = (SwRowFrm*)pRet->GetNext();
5586cdf0e10cSrcweir                 --nRepeat;
5587cdf0e10cSrcweir             }
5588cdf0e10cSrcweir         }
5589cdf0e10cSrcweir     }
5590cdf0e10cSrcweir 
5591cdf0e10cSrcweir     return (SwRowFrm*)pRet;
5592cdf0e10cSrcweir }
5593cdf0e10cSrcweir 
5594cdf0e10cSrcweir /*
5595cdf0e10cSrcweir  * SwTable::IsHeadline()
5596cdf0e10cSrcweir  */
IsHeadline(const SwTableLine & rLine) const5597cdf0e10cSrcweir bool SwTable::IsHeadline( const SwTableLine& rLine ) const
5598cdf0e10cSrcweir {
5599cdf0e10cSrcweir     for ( sal_uInt16 i = 0; i < GetRowsToRepeat(); ++i )
5600cdf0e10cSrcweir         if ( GetTabLines()[ i ] == &rLine )
5601cdf0e10cSrcweir             return true;
5602cdf0e10cSrcweir 
5603cdf0e10cSrcweir     return false;
5604cdf0e10cSrcweir }
5605cdf0e10cSrcweir 
IsLayoutSplitAllowed() const5606cdf0e10cSrcweir bool SwTabFrm::IsLayoutSplitAllowed() const
5607cdf0e10cSrcweir {
5608cdf0e10cSrcweir     return GetFmt()->GetLayoutSplit().GetValue();
5609cdf0e10cSrcweir }
5610cdf0e10cSrcweir 
5611cdf0e10cSrcweir // --> collapsing borders FME 2005-05-27 #i29550#
5612cdf0e10cSrcweir 
GetBottomLineSize() const5613cdf0e10cSrcweir sal_uInt16 SwTabFrm::GetBottomLineSize() const
5614cdf0e10cSrcweir {
5615cdf0e10cSrcweir     ASSERT( IsCollapsingBorders(),
5616cdf0e10cSrcweir             "BottomLineSize only required for collapsing borders" )
5617cdf0e10cSrcweir 
5618cdf0e10cSrcweir     ASSERT( Lower(), "Warning! Trying to prevent a crash, please inform FME" )
5619cdf0e10cSrcweir 
5620cdf0e10cSrcweir     const SwFrm* pTmp = GetLastLower();
5621cdf0e10cSrcweir 
5622cdf0e10cSrcweir     // --> FME 2005-12-07 #124755# Try to make code robust:
5623cdf0e10cSrcweir     if ( !pTmp ) return 0;
5624cdf0e10cSrcweir     // <--
5625cdf0e10cSrcweir 
5626cdf0e10cSrcweir     return static_cast<const SwRowFrm*>(pTmp)->GetBottomLineSize();
5627cdf0e10cSrcweir }
5628cdf0e10cSrcweir 
IsCollapsingBorders() const5629cdf0e10cSrcweir bool SwTabFrm::IsCollapsingBorders() const
5630cdf0e10cSrcweir {
5631cdf0e10cSrcweir     return ((SfxBoolItem&)GetFmt()->GetAttrSet().Get( RES_COLLAPSING_BORDERS )).GetValue();
5632cdf0e10cSrcweir }
5633cdf0e10cSrcweir 
5634cdf0e10cSrcweir // <-- collapsing
5635cdf0e10cSrcweir 
5636cdf0e10cSrcweir 
5637cdf0e10cSrcweir //
5638cdf0e10cSrcweir // Local helper function to calculate height of first text row
5639cdf0e10cSrcweir //
lcl_CalcHeightOfFirstContentLine(const SwRowFrm & rSourceLine)5640cdf0e10cSrcweir SwTwips lcl_CalcHeightOfFirstContentLine( const SwRowFrm& rSourceLine )
5641cdf0e10cSrcweir {
5642cdf0e10cSrcweir     // Find corresponding split line in master table
5643cdf0e10cSrcweir     const SwTabFrm* pTab = rSourceLine.FindTabFrm();
5644cdf0e10cSrcweir     SWRECTFN( pTab )
5645cdf0e10cSrcweir     const SwCellFrm* pCurrSourceCell = (SwCellFrm*)rSourceLine.Lower();
5646cdf0e10cSrcweir 
5647cdf0e10cSrcweir     //
5648cdf0e10cSrcweir     // 1. Case: rSourceLine is a follow flow line.
5649cdf0e10cSrcweir     // In this case we have to return the minimum of the heights
5650cdf0e10cSrcweir     // of the first lines in rSourceLine.
5651cdf0e10cSrcweir     //
5652cdf0e10cSrcweir     // 2. Case: rSourceLine is not a follow flow line.
5653cdf0e10cSrcweir     // In this case we have to return the maximum of the heights
5654cdf0e10cSrcweir     // of the first lines in rSourceLine.
5655cdf0e10cSrcweir     //
5656cdf0e10cSrcweir     bool bIsInFollowFlowLine = rSourceLine.IsInFollowFlowRow();
5657cdf0e10cSrcweir     SwTwips nHeight = bIsInFollowFlowLine ? LONG_MAX : 0;
5658cdf0e10cSrcweir 
5659cdf0e10cSrcweir     while ( pCurrSourceCell )
5660cdf0e10cSrcweir     {
5661cdf0e10cSrcweir         // NEW TABLES
5662cdf0e10cSrcweir         // Skip cells which are not responsible for the height of
5663cdf0e10cSrcweir         // the follow flow line:
5664cdf0e10cSrcweir         if ( bIsInFollowFlowLine && pCurrSourceCell->GetLayoutRowSpan() > 1 )
5665cdf0e10cSrcweir         {
5666cdf0e10cSrcweir             pCurrSourceCell = (SwCellFrm*)pCurrSourceCell->GetNext();
5667cdf0e10cSrcweir             continue;
5668cdf0e10cSrcweir         }
5669cdf0e10cSrcweir 
5670cdf0e10cSrcweir         const SwFrm *pTmp = pCurrSourceCell->Lower();
5671cdf0e10cSrcweir         if ( pTmp )
5672cdf0e10cSrcweir         {
5673cdf0e10cSrcweir             SwTwips nTmpHeight = USHRT_MAX;
5674cdf0e10cSrcweir             // --> FME 2004-09-14 #i32456# Consider lower row frames
5675cdf0e10cSrcweir             if ( pTmp->IsRowFrm() )
5676cdf0e10cSrcweir             {
5677cdf0e10cSrcweir                 const SwRowFrm* pTmpSourceRow = (SwRowFrm*)pCurrSourceCell->Lower();
5678cdf0e10cSrcweir                 nTmpHeight = lcl_CalcHeightOfFirstContentLine( *pTmpSourceRow );
5679cdf0e10cSrcweir             }
5680cdf0e10cSrcweir             // <--
5681cdf0e10cSrcweir             if ( pTmp->IsTabFrm() )
5682cdf0e10cSrcweir             {
5683cdf0e10cSrcweir                 nTmpHeight = ((SwTabFrm*)pTmp)->CalcHeightOfFirstContentLine();
5684cdf0e10cSrcweir             }
5685cdf0e10cSrcweir             else if ( pTmp->IsTxtFrm() )
5686cdf0e10cSrcweir             {
5687cdf0e10cSrcweir                 SwTxtFrm* pTxtFrm = (SwTxtFrm*)pTmp;
5688cdf0e10cSrcweir                 pTxtFrm->GetFormatted();
5689cdf0e10cSrcweir                 nTmpHeight = pTxtFrm->FirstLineHeight();
5690cdf0e10cSrcweir             }
5691cdf0e10cSrcweir 
5692cdf0e10cSrcweir             if ( USHRT_MAX != nTmpHeight )
5693cdf0e10cSrcweir             {
5694cdf0e10cSrcweir                 const SwCellFrm* pPrevCell = pCurrSourceCell->GetPreviousCell();
5695cdf0e10cSrcweir                 if ( pPrevCell )
5696cdf0e10cSrcweir                 {
5697cdf0e10cSrcweir                     // If we are in a split row, there may be some space
5698cdf0e10cSrcweir                     // left in the cell frame of the master row.
5699cdf0e10cSrcweir                     // We look for the minimum of all first line heights;
5700cdf0e10cSrcweir                     SwTwips nReal = (pPrevCell->Prt().*fnRect->fnGetHeight)();
5701cdf0e10cSrcweir                     const SwFrm* pFrm = pPrevCell->Lower();
5702cdf0e10cSrcweir                     const SwFrm* pLast = pFrm;
5703cdf0e10cSrcweir                     while ( pFrm )
5704cdf0e10cSrcweir                     {
5705cdf0e10cSrcweir                         nReal -= (pFrm->Frm().*fnRect->fnGetHeight)();
5706cdf0e10cSrcweir                         pLast = pFrm;
5707cdf0e10cSrcweir                         pFrm = pFrm->GetNext();
5708cdf0e10cSrcweir                     }
5709cdf0e10cSrcweir 
5710cdf0e10cSrcweir                     // --> FME, OD 2004-07-15 #i26831#, #i26520#
5711cdf0e10cSrcweir                     // The additional lower space of the current last.
5712cdf0e10cSrcweir                     // --> OD 2004-11-25 #115759# - do *not* consider the
5713cdf0e10cSrcweir                     // additional lower space for 'master' text frames
5714cdf0e10cSrcweir                     if ( pLast && pLast->IsFlowFrm() &&
5715cdf0e10cSrcweir                          ( !pLast->IsTxtFrm() ||
5716cdf0e10cSrcweir                            !static_cast<const SwTxtFrm*>(pLast)->GetFollow() ) )
5717cdf0e10cSrcweir                     // <--
5718cdf0e10cSrcweir                     {
5719cdf0e10cSrcweir                         nReal += SwFlowFrm::CastFlowFrm(pLast)->CalcAddLowerSpaceAsLastInTableCell();
5720cdf0e10cSrcweir                     }
5721cdf0e10cSrcweir                     // Don't forget the upper space and lower space,
5722cdf0e10cSrcweir                     // --> OD 2004-11-25 #115759# - do *not* consider the upper
5723cdf0e10cSrcweir                     // and the lower space for follow text frames.
5724cdf0e10cSrcweir                     if ( pTmp->IsFlowFrm() &&
5725cdf0e10cSrcweir                          ( !pTmp->IsTxtFrm() ||
5726cdf0e10cSrcweir                            !static_cast<const SwTxtFrm*>(pTmp)->IsFollow() ) )
5727cdf0e10cSrcweir                     {
5728cdf0e10cSrcweir                         nTmpHeight += SwFlowFrm::CastFlowFrm(pTmp)->CalcUpperSpace( NULL, pLast);
5729cdf0e10cSrcweir                         nTmpHeight += SwFlowFrm::CastFlowFrm(pTmp)->CalcLowerSpace();
5730cdf0e10cSrcweir                     }
5731cdf0e10cSrcweir                     // <--
5732cdf0e10cSrcweir                     // --> OD 2004-11-25 #115759# - consider additional lower
5733cdf0e10cSrcweir                     // space of <pTmp>, if contains only one line.
5734cdf0e10cSrcweir                     // In this case it would be the new last text frame, which
5735cdf0e10cSrcweir                     // would have no follow and thus would add this space.
5736cdf0e10cSrcweir                     if ( pTmp->IsTxtFrm() &&
5737cdf0e10cSrcweir                          const_cast<SwTxtFrm*>(static_cast<const SwTxtFrm*>(pTmp))
5738cdf0e10cSrcweir                                             ->GetLineCount( STRING_LEN ) == 1 )
5739cdf0e10cSrcweir                     {
5740cdf0e10cSrcweir                         nTmpHeight += SwFlowFrm::CastFlowFrm(pTmp)
5741cdf0e10cSrcweir                                         ->CalcAddLowerSpaceAsLastInTableCell();
5742cdf0e10cSrcweir                     }
5743cdf0e10cSrcweir                     // <--
5744cdf0e10cSrcweir                     if ( nReal > 0 )
5745cdf0e10cSrcweir                         nTmpHeight -= nReal;
5746cdf0e10cSrcweir                 }
5747cdf0e10cSrcweir                 else
5748cdf0e10cSrcweir                 {
5749cdf0e10cSrcweir                     // pFirstRow is not a FollowFlowRow. In this case,
5750cdf0e10cSrcweir                     // we look for the maximum of all first line heights:
5751cdf0e10cSrcweir                     SwBorderAttrAccess aAccess( SwFrm::GetCache(), pCurrSourceCell );
5752cdf0e10cSrcweir                     const SwBorderAttrs &rAttrs = *aAccess.Get();
5753cdf0e10cSrcweir                     nTmpHeight += rAttrs.CalcTop() + rAttrs.CalcBottom();
5754cdf0e10cSrcweir                     // --> OD 2004-07-16 #i26250#
5755cdf0e10cSrcweir                     // Don't forget the upper space and lower space,
5756cdf0e10cSrcweir                     if ( pTmp->IsFlowFrm() )
5757cdf0e10cSrcweir                     {
5758cdf0e10cSrcweir                         nTmpHeight += SwFlowFrm::CastFlowFrm(pTmp)->CalcUpperSpace();
5759cdf0e10cSrcweir                         nTmpHeight += SwFlowFrm::CastFlowFrm(pTmp)->CalcLowerSpace();
5760cdf0e10cSrcweir                     }
5761cdf0e10cSrcweir                     // <--
5762cdf0e10cSrcweir                 }
5763cdf0e10cSrcweir             }
5764cdf0e10cSrcweir 
5765cdf0e10cSrcweir             if ( bIsInFollowFlowLine )
5766cdf0e10cSrcweir             {
5767cdf0e10cSrcweir                 // minimum
5768cdf0e10cSrcweir                 if ( nTmpHeight < nHeight )
5769cdf0e10cSrcweir                     nHeight = nTmpHeight;
5770cdf0e10cSrcweir             }
5771cdf0e10cSrcweir             else
5772cdf0e10cSrcweir             {
5773cdf0e10cSrcweir                 // maximum
5774cdf0e10cSrcweir                 if ( nTmpHeight > nHeight && USHRT_MAX != nTmpHeight )
5775cdf0e10cSrcweir                     nHeight = nTmpHeight;
5776cdf0e10cSrcweir             }
5777cdf0e10cSrcweir         }
5778cdf0e10cSrcweir 
5779cdf0e10cSrcweir         pCurrSourceCell = (SwCellFrm*)pCurrSourceCell->GetNext();
5780cdf0e10cSrcweir     }
5781cdf0e10cSrcweir 
5782cdf0e10cSrcweir     return ( LONG_MAX == nHeight ) ? 0 : nHeight;
5783cdf0e10cSrcweir }
5784cdf0e10cSrcweir 
5785cdf0e10cSrcweir //
5786cdf0e10cSrcweir // Function to calculate height of first text row
5787cdf0e10cSrcweir //
CalcHeightOfFirstContentLine() const5788cdf0e10cSrcweir SwTwips SwTabFrm::CalcHeightOfFirstContentLine() const
5789cdf0e10cSrcweir {
5790cdf0e10cSrcweir     SWRECTFN( this )
5791cdf0e10cSrcweir 
5792cdf0e10cSrcweir     const bool bDontSplit = !IsFollow() && !GetFmt()->GetLayoutSplit().GetValue();
5793cdf0e10cSrcweir 
5794cdf0e10cSrcweir     if ( bDontSplit )
5795cdf0e10cSrcweir     {
5796cdf0e10cSrcweir         // Table is not allowed to split: Take the whole height, that's all
5797cdf0e10cSrcweir         return (Frm().*fnRect->fnGetHeight)();
5798cdf0e10cSrcweir     }
5799cdf0e10cSrcweir 
5800cdf0e10cSrcweir     SwRowFrm* pFirstRow = 0;
5801cdf0e10cSrcweir     SwTwips nTmpHeight = 0;
5802cdf0e10cSrcweir 
5803cdf0e10cSrcweir     pFirstRow = GetFirstNonHeadlineRow();
5804cdf0e10cSrcweir     ASSERT( !IsFollow() || pFirstRow, "FollowTable without Lower" )
5805cdf0e10cSrcweir 
5806cdf0e10cSrcweir     // NEW TABLES
5807cdf0e10cSrcweir     if ( pFirstRow && pFirstRow->IsRowSpanLine() && pFirstRow->GetNext() )
5808cdf0e10cSrcweir         pFirstRow = static_cast<SwRowFrm*>(pFirstRow->GetNext());
5809cdf0e10cSrcweir 
5810cdf0e10cSrcweir     // Calculate the height of the headlines:
5811cdf0e10cSrcweir     const sal_uInt16 nRepeat = GetTable()->GetRowsToRepeat();
5812cdf0e10cSrcweir     SwTwips nRepeatHeight = nRepeat ? lcl_GetHeightOfRows( GetLower(), nRepeat ) : 0;
5813cdf0e10cSrcweir 
5814cdf0e10cSrcweir     // Calculate the height of the keeping lines
5815cdf0e10cSrcweir     // (headlines + following keeping lines):
5816cdf0e10cSrcweir     SwTwips nKeepHeight = nRepeatHeight;
5817cdf0e10cSrcweir     if ( GetFmt()->GetDoc()->get(IDocumentSettingAccess::TABLE_ROW_KEEP) )
5818cdf0e10cSrcweir     {
5819cdf0e10cSrcweir         sal_uInt16 nKeepRows = nRepeat;
5820cdf0e10cSrcweir 
5821cdf0e10cSrcweir         // Check how many rows want to keep together
5822cdf0e10cSrcweir         while ( pFirstRow && pFirstRow->ShouldRowKeepWithNext() )
5823cdf0e10cSrcweir         {
5824cdf0e10cSrcweir             ++nKeepRows;
5825cdf0e10cSrcweir             pFirstRow = static_cast<SwRowFrm*>(pFirstRow->GetNext());
5826cdf0e10cSrcweir         }
5827cdf0e10cSrcweir 
5828cdf0e10cSrcweir         if ( nKeepRows > nRepeat )
5829cdf0e10cSrcweir             nKeepHeight = lcl_GetHeightOfRows( GetLower(), nKeepRows );
5830cdf0e10cSrcweir     }
5831cdf0e10cSrcweir 
5832cdf0e10cSrcweir     // For master tables, the height of the headlines + the heigth of the
5833cdf0e10cSrcweir     // keeping lines (if any) has to be considered. For follow tables, we
5834cdf0e10cSrcweir     // only consider the height of the keeping rows without the repeated lines:
5835cdf0e10cSrcweir     if ( !IsFollow() )
5836cdf0e10cSrcweir     {
5837cdf0e10cSrcweir         nTmpHeight = nKeepHeight;
5838cdf0e10cSrcweir     }
5839cdf0e10cSrcweir     else
5840cdf0e10cSrcweir     {
5841cdf0e10cSrcweir         nTmpHeight = nKeepHeight - nRepeatHeight;
5842cdf0e10cSrcweir     }
5843cdf0e10cSrcweir 
5844cdf0e10cSrcweir     // pFirstRow row is the first non-heading row.
5845cdf0e10cSrcweir     // nTmpHeight is the height of the heading row if we are a follow.
5846cdf0e10cSrcweir     if ( pFirstRow )
5847cdf0e10cSrcweir     {
5848cdf0e10cSrcweir         const bool bSplittable = pFirstRow->IsRowSplitAllowed();
5849cdf0e10cSrcweir         const SwTwips nFirstLineHeight = (pFirstRow->Frm().*fnRect->fnGetHeight)();
5850cdf0e10cSrcweir 
5851cdf0e10cSrcweir         if ( !bSplittable )
5852cdf0e10cSrcweir         {
5853cdf0e10cSrcweir             // pFirstRow is not splittable, but it is still possible that the line height of pFirstRow
5854cdf0e10cSrcweir             // actually is determined by a lower cell with rowspan = -1. In this case we should not
5855cdf0e10cSrcweir             // just return the height of the first line. Basically we need to get the height of the
5856cdf0e10cSrcweir             // line as it would be on the last page. Since this is quite complicated to calculate,
5857cdf0e10cSrcweir             // we olny calculate the height of the first line.
5858cdf0e10cSrcweir             if ( pFirstRow->GetPrev() &&
5859cdf0e10cSrcweir                  static_cast<SwRowFrm*>(pFirstRow->GetPrev())->IsRowSpanLine() )
5860cdf0e10cSrcweir             {
5861cdf0e10cSrcweir                 // Calculate maximum height of all cells with rowspan = 1:
5862cdf0e10cSrcweir                 SwTwips nMaxHeight = 0;
5863cdf0e10cSrcweir                 const SwCellFrm* pLower2 = static_cast<const SwCellFrm*>(pFirstRow->Lower());
5864cdf0e10cSrcweir                 while ( pLower2 )
5865cdf0e10cSrcweir                 {
5866cdf0e10cSrcweir                     if ( 1 == pLower2->GetTabBox()->getRowSpan() )
5867cdf0e10cSrcweir                     {
5868cdf0e10cSrcweir                         const SwTwips nCellHeight = lcl_CalcMinCellHeight( pLower2, sal_True );
5869cdf0e10cSrcweir                         nMaxHeight = Max( nCellHeight, nMaxHeight );
5870cdf0e10cSrcweir                     }
5871cdf0e10cSrcweir                     pLower2 = static_cast<const SwCellFrm*>(pLower2->GetNext());
5872cdf0e10cSrcweir                 }
5873cdf0e10cSrcweir                 nTmpHeight += nMaxHeight;
5874cdf0e10cSrcweir             }
5875cdf0e10cSrcweir             else
5876cdf0e10cSrcweir             {
5877cdf0e10cSrcweir                 nTmpHeight += nFirstLineHeight;
5878cdf0e10cSrcweir             }
5879cdf0e10cSrcweir         }
5880cdf0e10cSrcweir 
5881cdf0e10cSrcweir         // --> FME 2004-11-18 #118411#
5882cdf0e10cSrcweir         // Optimization: lcl_CalcHeightOfFirstContentLine actually can trigger
5883cdf0e10cSrcweir         // a formatting of the row frame (via the GetFormatted()). We don't
5884cdf0e10cSrcweir         // want this formatting if the row does not have a height.
5885cdf0e10cSrcweir         else if ( 0 != nFirstLineHeight )
5886cdf0e10cSrcweir         // <--
5887cdf0e10cSrcweir         {
5888cdf0e10cSrcweir             const bool bOldJoinLock = IsJoinLocked();
5889cdf0e10cSrcweir             ((SwTabFrm*)this)->LockJoin();
5890cdf0e10cSrcweir             const SwTwips nHeightOfFirstContentLine = lcl_CalcHeightOfFirstContentLine( *(SwRowFrm*)pFirstRow );
5891cdf0e10cSrcweir 
5892cdf0e10cSrcweir             // Consider minimum row height:
5893cdf0e10cSrcweir             const SwFmtFrmSize &rSz = static_cast<const SwRowFrm*>(pFirstRow)->GetFmt()->GetFrmSize();
5894cdf0e10cSrcweir             const SwTwips nMinRowHeight = rSz.GetHeightSizeType() == ATT_MIN_SIZE ?
5895cdf0e10cSrcweir                                           rSz.GetHeight() : 0;
5896cdf0e10cSrcweir 
5897cdf0e10cSrcweir             nTmpHeight += Max( nHeightOfFirstContentLine, nMinRowHeight );
5898cdf0e10cSrcweir 
5899cdf0e10cSrcweir             if ( !bOldJoinLock )
5900cdf0e10cSrcweir                 ((SwTabFrm*)this)->UnlockJoin();
5901cdf0e10cSrcweir         }
5902cdf0e10cSrcweir     }
5903cdf0e10cSrcweir 
5904cdf0e10cSrcweir     return nTmpHeight;
5905cdf0e10cSrcweir }
5906cdf0e10cSrcweir 
5907cdf0e10cSrcweir //
5908cdf0e10cSrcweir // Some more functions for covered/covering cells. This way inclusion of
5909cdf0e10cSrcweir // SwCellFrm can be avoided
5910cdf0e10cSrcweir //
5911cdf0e10cSrcweir 
IsLeaveUpperAllowed() const5912cdf0e10cSrcweir bool SwFrm::IsLeaveUpperAllowed() const
5913cdf0e10cSrcweir {
5914cdf0e10cSrcweir     const SwCellFrm* pThisCell = dynamic_cast<const SwCellFrm*>(this);
5915cdf0e10cSrcweir     return pThisCell && pThisCell->GetLayoutRowSpan() > 1;
5916cdf0e10cSrcweir }
5917cdf0e10cSrcweir 
IsCoveredCell() const5918cdf0e10cSrcweir bool SwFrm::IsCoveredCell() const
5919cdf0e10cSrcweir {
5920cdf0e10cSrcweir     const SwCellFrm* pThisCell = dynamic_cast<const SwCellFrm*>(this);
5921cdf0e10cSrcweir     return pThisCell && pThisCell->GetLayoutRowSpan() < 1;
5922cdf0e10cSrcweir }
5923cdf0e10cSrcweir 
IsInCoveredCell() const5924cdf0e10cSrcweir bool SwFrm::IsInCoveredCell() const
5925cdf0e10cSrcweir {
5926cdf0e10cSrcweir     bool bRet = false;
5927cdf0e10cSrcweir 
5928cdf0e10cSrcweir     const SwFrm* pThis = this;
5929cdf0e10cSrcweir     while ( pThis && !pThis->IsCellFrm() )
5930cdf0e10cSrcweir         pThis = pThis->GetUpper();
5931cdf0e10cSrcweir 
5932cdf0e10cSrcweir     if ( pThis )
5933cdf0e10cSrcweir         bRet = pThis->IsCoveredCell();
5934cdf0e10cSrcweir 
5935cdf0e10cSrcweir     return bRet;
5936cdf0e10cSrcweir }
5937cdf0e10cSrcweir 
5938