Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <hints.hxx>
21 : #include <svl/itemiter.hxx>
22 : #include <editeng/brushitem.hxx>
23 : #include <fmtornt.hxx>
24 : #include <pagefrm.hxx>
25 : #include <section.hxx>
26 : #include <rootfrm.hxx>
27 : #include <anchoreddrawobject.hxx>
28 : #include <fmtanchr.hxx>
29 : #include <viewimp.hxx>
30 : #include "viewopt.hxx"
31 : #include <IDocumentSettingAccess.hxx>
32 : #include <IDocumentFieldsAccess.hxx>
33 : #include <fesh.hxx>
34 : #include <docsh.hxx>
35 : #include <ftninfo.hxx>
36 : #include <fmtclbl.hxx>
37 : #include <fmtfsize.hxx>
38 : #include <fmtpdsc.hxx>
39 : #include <txtftn.hxx>
40 : #include <fmtftn.hxx>
41 : #include <fmtsrnd.hxx>
42 : #include <ftnfrm.hxx>
43 : #include <tabfrm.hxx>
44 : #include <flyfrms.hxx>
45 : #include <sectfrm.hxx>
46 : #include <fmtclds.hxx>
47 : #include <txtfrm.hxx>
48 : #include <bodyfrm.hxx>
49 : #include <cellfrm.hxx>
50 : #include <dbg_lay.hxx>
51 : #include <editeng/frmdiritem.hxx>
52 : #include <sortedobjs.hxx>
53 :
54 : using namespace ::com::sun::star;
55 :
56 124694 : SwFrm::SwFrm( SwModify *pMod, SwFrm* pSib ) :
57 : SwClient( pMod ),
58 : mbIfAccTableShouldDisposing( false ), //A member to identify if the acc table should dispose
59 : mbInDtor(false),
60 : mnFrmId( SwFrm::mnLastFrmId++ ),
61 : mpRoot( pSib ? pSib->getRootFrm() : 0 ),
62 : mpUpper( 0 ),
63 : mpNext( 0 ),
64 : mpPrev( 0 ),
65 : mpDrawObjs( 0 ),
66 : mnType(0),
67 : mbInfBody( false ),
68 : mbInfTab ( false ),
69 : mbInfFly ( false ),
70 : mbInfFtn ( false ),
71 124694 : mbInfSct ( false )
72 : {
73 : OSL_ENSURE( pMod, "No frame format given." );
74 124694 : mbInvalidR2L = mbInvalidVert = true;
75 124694 : mbDerivedR2L = mbDerivedVert = mbRightToLeft = mbVertical = mbReverse = mbVertLR = false;
76 :
77 : mbValidPos = mbValidPrtArea = mbValidSize = mbValidLineNum = mbRetouche =
78 124694 : mbFixSize = mbColLocked = false;
79 124694 : mbCompletePaint = mbInfInvalid = true;
80 124694 : }
81 :
82 544 : const IDocumentDrawModelAccess* SwFrm::getIDocumentDrawModelAccess()
83 : {
84 544 : return GetUpper()->GetFmt()->getIDocumentDrawModelAccess();
85 : }
86 :
87 80 : bool SwFrm::KnowsFormat( const SwFmt& rFmt ) const
88 : {
89 80 : return GetRegisteredIn() == &rFmt;
90 : }
91 :
92 114 : void SwFrm::RegisterToFormat( SwFmt& rFmt )
93 : {
94 114 : rFmt.Add( this );
95 114 : }
96 :
97 123800 : void SwFrm::CheckDir( sal_uInt16 nDir, bool bVert, bool bOnlyBiDi, bool bBrowse )
98 : {
99 123800 : if( FRMDIR_ENVIRONMENT == nDir || ( bVert && bOnlyBiDi ) )
100 : {
101 62136 : mbDerivedVert = true;
102 62136 : if( FRMDIR_ENVIRONMENT == nDir )
103 13188 : mbDerivedR2L = true;
104 62136 : SetDirFlags( bVert );
105 : }
106 61664 : else if( bVert )
107 : {
108 1138 : mbInvalidVert = false;
109 1138 : if( FRMDIR_HORI_LEFT_TOP == nDir || FRMDIR_HORI_RIGHT_TOP == nDir
110 2 : || bBrowse )
111 : {
112 1136 : mbVertical = false;
113 1136 : mbVertLR = false;
114 : }
115 : else
116 : {
117 2 : mbVertical = true;
118 2 : if(FRMDIR_VERT_TOP_RIGHT == nDir)
119 2 : mbVertLR = false;
120 0 : else if(FRMDIR_VERT_TOP_LEFT==nDir)
121 0 : mbVertLR = true;
122 : }
123 : }
124 : else
125 : {
126 60526 : mbInvalidR2L = false;
127 60526 : if( FRMDIR_HORI_RIGHT_TOP == nDir )
128 66 : mbRightToLeft = true;
129 : else
130 60460 : mbRightToLeft = false;
131 : }
132 123800 : }
133 :
134 1269314 : void SwFrm::CheckDirection( bool bVert )
135 : {
136 1269314 : if( bVert )
137 : {
138 1239822 : if( !IsHeaderFrm() && !IsFooterFrm() )
139 : {
140 35564 : mbDerivedVert = true;
141 35564 : SetDirFlags( bVert );
142 : }
143 : }
144 : else
145 : {
146 29492 : mbDerivedR2L = true;
147 29492 : SetDirFlags( bVert );
148 : }
149 1269314 : }
150 :
151 1200 : void SwSectionFrm::CheckDirection( bool bVert )
152 : {
153 1200 : const SwFrmFmt* pFmt = GetFmt();
154 1200 : if( pFmt )
155 : {
156 1200 : const SwViewShell *pSh = getRootFrm()->GetCurrShell();
157 1200 : const bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
158 1200 : CheckDir(((SvxFrameDirectionItem&)pFmt->GetFmtAttr(RES_FRAMEDIR)).GetValue(),
159 2400 : bVert, true, bBrowseMode );
160 : }
161 : else
162 0 : SwFrm::CheckDirection( bVert );
163 1200 : }
164 :
165 4 : void SwFlyFrm::CheckDirection( bool bVert )
166 : {
167 4 : const SwFrmFmt* pFmt = GetFmt();
168 4 : if( pFmt )
169 : {
170 4 : const SwViewShell *pSh = getRootFrm()->GetCurrShell();
171 4 : const bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
172 4 : CheckDir(((SvxFrameDirectionItem&)pFmt->GetFmtAttr(RES_FRAMEDIR)).GetValue(),
173 8 : bVert, false, bBrowseMode );
174 : }
175 : else
176 0 : SwFrm::CheckDirection( bVert );
177 4 : }
178 :
179 3220 : void SwTabFrm::CheckDirection( bool bVert )
180 : {
181 3220 : const SwFrmFmt* pFmt = GetFmt();
182 3220 : if( pFmt )
183 : {
184 3220 : const SwViewShell *pSh = getRootFrm()->GetCurrShell();
185 3220 : const bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
186 3220 : CheckDir(((SvxFrameDirectionItem&)pFmt->GetFmtAttr(RES_FRAMEDIR)).GetValue(),
187 6440 : bVert, true, bBrowseMode );
188 : }
189 : else
190 0 : SwFrm::CheckDirection( bVert );
191 3220 : }
192 :
193 33430 : void SwCellFrm::CheckDirection( bool bVert )
194 : {
195 33430 : const SwFrmFmt* pFmt = GetFmt();
196 : const SfxPoolItem* pItem;
197 : // Check if the item is set, before actually
198 : // using it. Otherwise the dynamic pool default is used, which may be set
199 : // to LTR in case of OOo 1.0 documents.
200 33430 : if( pFmt && SfxItemState::SET == pFmt->GetItemState( RES_FRAMEDIR, true, &pItem ) )
201 : {
202 2220 : const SvxFrameDirectionItem* pFrmDirItem = static_cast<const SvxFrameDirectionItem*>(pItem);
203 2220 : const SwViewShell *pSh = getRootFrm()->GetCurrShell();
204 2220 : const bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
205 2220 : CheckDir( pFrmDirItem->GetValue(), bVert, false, bBrowseMode );
206 : }
207 : else
208 31210 : SwFrm::CheckDirection( bVert );
209 33430 : }
210 :
211 117156 : void SwTxtFrm::CheckDirection( bool bVert )
212 : {
213 117156 : const SwViewShell *pSh = getRootFrm()->GetCurrShell();
214 117156 : const bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
215 117156 : CheckDir( GetTxtNode()->GetSwAttrSet().GetFrmDir().GetValue(), bVert,
216 234312 : true, bBrowseMode );
217 117156 : }
218 :
219 18028 : void SwFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
220 : {
221 18028 : sal_uInt8 nInvFlags = 0;
222 :
223 18028 : if( pOld && pNew && RES_ATTRSET_CHG == pNew->Which() )
224 : {
225 9964 : SfxItemIter aNIter( *((SwAttrSetChg*)pNew)->GetChgSet() );
226 19928 : SfxItemIter aOIter( *((SwAttrSetChg*)pOld)->GetChgSet() );
227 : while( true )
228 : {
229 : _UpdateAttrFrm( (SfxPoolItem*)aOIter.GetCurItem(),
230 21306 : (SfxPoolItem*)aNIter.GetCurItem(), nInvFlags );
231 21306 : if( aNIter.IsAtEnd() )
232 9964 : break;
233 11342 : aNIter.NextItem();
234 11342 : aOIter.NextItem();
235 9964 : }
236 : }
237 : else
238 8064 : _UpdateAttrFrm( pOld, pNew, nInvFlags );
239 :
240 18028 : if ( nInvFlags != 0 )
241 : {
242 9066 : SwPageFrm *pPage = FindPageFrm();
243 9066 : InvalidatePage( pPage );
244 9066 : if ( nInvFlags & 0x01 )
245 : {
246 8946 : _InvalidatePrt();
247 8946 : if( !GetPrev() && IsTabFrm() && IsInSct() )
248 0 : FindSctFrm()->_InvalidatePrt();
249 : }
250 9066 : if ( nInvFlags & 0x02 )
251 8946 : _InvalidateSize();
252 9066 : if ( nInvFlags & 0x04 )
253 6040 : _InvalidatePos();
254 9066 : if ( nInvFlags & 0x08 )
255 8848 : SetCompletePaint();
256 : SwFrm *pNxt;
257 9066 : if ( nInvFlags & 0x30 && 0 != (pNxt = GetNext()) )
258 : {
259 108 : pNxt->InvalidatePage( pPage );
260 108 : if ( nInvFlags & 0x10 )
261 20 : pNxt->_InvalidatePos();
262 108 : if ( nInvFlags & 0x20 )
263 88 : pNxt->SetCompletePaint();
264 : }
265 : }
266 18028 : }
267 :
268 29370 : void SwFrm::_UpdateAttrFrm( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
269 : sal_uInt8 &rInvFlags )
270 : {
271 29370 : sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
272 29370 : switch( nWhich )
273 : {
274 : case RES_BOX:
275 : case RES_SHADOW:
276 132 : Prepare( PREP_FIXSIZE_CHG );
277 : // no break here!
278 : case RES_LR_SPACE:
279 : case RES_UL_SPACE:
280 2696 : rInvFlags |= 0x0B;
281 2696 : break;
282 :
283 : case RES_HEADER_FOOTER_EAT_SPACING:
284 0 : rInvFlags |= 0x03;
285 0 : break;
286 :
287 : case RES_BACKGROUND:
288 102 : rInvFlags |= 0x28;
289 102 : break;
290 :
291 : case RES_KEEP:
292 2 : rInvFlags |= 0x04;
293 2 : break;
294 :
295 : case RES_FRM_SIZE:
296 246 : ReinitializeFrmSizeAttrFlags();
297 246 : rInvFlags |= 0x13;
298 246 : break;
299 :
300 : case RES_FMT_CHG:
301 6038 : rInvFlags |= 0x0F;
302 6038 : break;
303 :
304 : case RES_ROW_SPLIT:
305 : {
306 644 : if ( IsRowFrm() )
307 : {
308 32 : bool bInFollowFlowRow = 0 != IsInFollowFlowRow();
309 32 : if ( bInFollowFlowRow || 0 != IsInSplitTableRow() )
310 : {
311 0 : SwTabFrm* pTab = FindTabFrm();
312 0 : if ( bInFollowFlowRow )
313 0 : pTab = pTab->FindMaster();
314 0 : pTab->SetRemoveFollowFlowLinePending( true );
315 : }
316 : }
317 644 : break;
318 : }
319 : case RES_COL:
320 : OSL_FAIL( "Columns for new FrmTyp?" );
321 0 : break;
322 :
323 : default:
324 : //UUUU the new FillStyle has to do the same as previous RES_BACKGROUND
325 19642 : if(nWhich >= XATTR_FILL_FIRST && nWhich <= XATTR_FILL_LAST)
326 : {
327 36 : rInvFlags |= 0x28;
328 : }
329 : /* do Nothing */;
330 : }
331 29370 : }
332 :
333 2426 : void SwFrm::Prepare( const PrepareHint, const void *, bool )
334 : {
335 : /* Do nothing */
336 2426 : }
337 :
338 : /**
339 : * Invalidates the page in which the Frm is currently placed.
340 : * The page is invalidated depending on the type (Layout, Cntnt, FlyFrm)
341 : */
342 516323 : void SwFrm::InvalidatePage( const SwPageFrm *pPage ) const
343 : {
344 516323 : if ( !pPage )
345 : {
346 337248 : pPage = FindPageFrm();
347 : // #i28701# - for at-character and as-character
348 : // anchored Writer fly frames additionally invalidate also page frame
349 : // its 'anchor character' is on.
350 337248 : if ( pPage && pPage->GetUpper() && IsFlyFrm() )
351 : {
352 13121 : const SwFlyFrm* pFlyFrm = static_cast<const SwFlyFrm*>(this);
353 13121 : if ( pFlyFrm->IsAutoPos() || pFlyFrm->IsFlyInCntFrm() )
354 : {
355 : // #i33751#, #i34060# - method <GetPageFrmOfAnchor()>
356 : // is replaced by method <FindPageFrmOfAnchor()>. It's return value
357 : // have to be checked.
358 : SwPageFrm* pPageFrmOfAnchor =
359 5886 : const_cast<SwFlyFrm*>(pFlyFrm)->FindPageFrmOfAnchor();
360 5886 : if ( pPageFrmOfAnchor && pPageFrmOfAnchor != pPage )
361 : {
362 44 : InvalidatePage( pPageFrmOfAnchor );
363 : }
364 : }
365 : }
366 : }
367 :
368 516323 : if ( pPage && pPage->GetUpper() )
369 : {
370 479911 : if ( pPage->GetFmt()->GetDoc()->IsInDtor() )
371 516323 : return;
372 :
373 479911 : SwRootFrm *pRoot = (SwRootFrm*)pPage->GetUpper();
374 479911 : const SwFlyFrm *pFly = FindFlyFrm();
375 479911 : if ( IsCntntFrm() )
376 : {
377 286481 : if ( pRoot->IsTurboAllowed() )
378 : {
379 : // If a ContentFrame wants to register for a second time, make it a TurboAction.
380 12411 : if ( !pRoot->GetTurbo() || this == pRoot->GetTurbo() )
381 10913 : pRoot->SetTurbo( (const SwCntntFrm*)this );
382 : else
383 : {
384 1498 : pRoot->DisallowTurbo();
385 : //The page of the Turbo could be a different one then mine,
386 : //therefore we have to invalidate it.
387 1498 : const SwFrm *pTmp = pRoot->GetTurbo();
388 1498 : pRoot->ResetTurbo();
389 1498 : pTmp->InvalidatePage();
390 : }
391 : }
392 286481 : if ( !pRoot->GetTurbo() )
393 : {
394 275538 : if ( pFly )
395 17739 : { if( !pFly->IsLocked() )
396 : {
397 16815 : if ( pFly->IsFlyInCntFrm() )
398 3562 : { pPage->InvalidateFlyInCnt();
399 3562 : ((SwFlyInCntFrm*)pFly)->InvalidateCntnt();
400 3562 : pFly->GetAnchorFrm()->InvalidatePage();
401 : }
402 : else
403 13253 : pPage->InvalidateFlyCntnt();
404 : }
405 : }
406 : else
407 257799 : pPage->InvalidateCntnt();
408 : }
409 : }
410 : else
411 : {
412 193430 : pRoot->DisallowTurbo();
413 193430 : if ( pFly )
414 : {
415 22641 : if ( !pFly->IsLocked() )
416 : {
417 22373 : if ( pFly->IsFlyInCntFrm() )
418 : {
419 4812 : pPage->InvalidateFlyInCnt();
420 4812 : ((SwFlyInCntFrm*)pFly)->InvalidateLayout();
421 4812 : pFly->GetAnchorFrm()->InvalidatePage();
422 : }
423 : else
424 17561 : pPage->InvalidateFlyLayout();
425 : }
426 : }
427 : else
428 170789 : pPage->InvalidateLayout();
429 :
430 193430 : if ( pRoot->GetTurbo() )
431 145 : { const SwFrm *pTmp = pRoot->GetTurbo();
432 145 : pRoot->ResetTurbo();
433 145 : pTmp->InvalidatePage();
434 : }
435 : }
436 479911 : pRoot->SetIdleFlags();
437 :
438 479911 : const SwTxtFrm *pTxtFrm = dynamic_cast< const SwTxtFrm * >(this);
439 479911 : if (pTxtFrm)
440 : {
441 283025 : const SwTxtNode *pTxtNode = pTxtFrm->GetTxtNode();
442 283025 : if (pTxtNode && pTxtNode->IsGrammarCheckDirty())
443 282601 : pRoot->SetNeedGrammarCheck( true );
444 : }
445 : }
446 : }
447 :
448 12956 : Size SwFrm::ChgSize( const Size& aNewSize )
449 : {
450 12956 : mbFixSize = true;
451 12956 : const Size aOldSize( Frm().SSize() );
452 12956 : if ( aNewSize == aOldSize )
453 3678 : return aOldSize;
454 :
455 9278 : if ( GetUpper() )
456 : {
457 1802 : SWRECTFN2( this )
458 1802 : SwRect aNew( Point(0,0), aNewSize );
459 1802 : (maFrm.*fnRect->fnSetWidth)( (aNew.*fnRect->fnGetWidth)() );
460 1802 : long nNew = (aNew.*fnRect->fnGetHeight)();
461 1802 : long nDiff = nNew - (maFrm.*fnRect->fnGetHeight)();
462 1802 : if( nDiff )
463 : {
464 1668 : if ( GetUpper()->IsFtnBossFrm() && HasFixSize() &&
465 : NA_GROW_SHRINK !=
466 64 : ((SwFtnBossFrm*)GetUpper())->NeighbourhoodAdjustment( this ) )
467 : {
468 64 : (maFrm.*fnRect->fnSetHeight)( nNew );
469 64 : SwTwips nReal = ((SwLayoutFrm*)this)->AdjustNeighbourhood(nDiff);
470 64 : if ( nReal != nDiff )
471 56 : (maFrm.*fnRect->fnSetHeight)( nNew - nDiff + nReal );
472 : }
473 : else
474 : {
475 : // OD 24.10.2002 #97265# - grow/shrink not for neighbour frames
476 : // NOTE: neighbour frames are cell and column frames.
477 1540 : if ( !bNeighb )
478 : {
479 24 : if ( nDiff > 0 )
480 10 : Grow( nDiff );
481 : else
482 14 : Shrink( -nDiff );
483 :
484 24 : if ( GetUpper() && (maFrm.*fnRect->fnGetHeight)() != nNew )
485 24 : GetUpper()->_InvalidateSize();
486 : }
487 :
488 : // Even if grow/shrink did not yet set the desired width, for
489 : // example when called by ChgColumns to set the column width, we
490 : // set the right width now.
491 1540 : (maFrm.*fnRect->fnSetHeight)( nNew );
492 : }
493 : }
494 : }
495 : else
496 7476 : maFrm.SSize( aNewSize );
497 :
498 9278 : if ( Frm().SSize() != aOldSize )
499 : {
500 9278 : SwPageFrm *pPage = FindPageFrm();
501 9278 : if ( GetNext() )
502 : {
503 1072 : GetNext()->_InvalidatePos();
504 1072 : GetNext()->InvalidatePage( pPage );
505 : }
506 9278 : if( IsLayoutFrm() )
507 : {
508 9278 : if( IsRightToLeft() )
509 0 : _InvalidatePos();
510 9278 : if( ((SwLayoutFrm*)this)->Lower() )
511 1746 : ((SwLayoutFrm*)this)->Lower()->_InvalidateSize();
512 : }
513 9278 : _InvalidatePrt();
514 9278 : _InvalidateSize();
515 9278 : InvalidatePage( pPage );
516 : }
517 :
518 9278 : return maFrm.SSize();
519 : }
520 :
521 : /** Insert SwFrm into existing structure.
522 : *
523 : * Insertion is done below the parent either before pBehind or
524 : * at the end of the chain if pBehind is empty.
525 : */
526 41718 : void SwFrm::InsertBefore( SwLayoutFrm* pParent, SwFrm* pBehind )
527 : {
528 : OSL_ENSURE( pParent, "No parent for insert." );
529 : OSL_ENSURE( (!pBehind || (pBehind && pParent == pBehind->GetUpper())),
530 : "Frame tree is inconsistent." );
531 :
532 41718 : mpUpper = pParent;
533 41718 : mpNext = pBehind;
534 41718 : if( pBehind )
535 : { //Insert before pBehind.
536 6756 : if( 0 != (mpPrev = pBehind->mpPrev) )
537 3862 : mpPrev->mpNext = this;
538 : else
539 2894 : mpUpper->pLower = this;
540 6756 : pBehind->mpPrev = this;
541 : }
542 : else
543 : { //Insert at the end, or as first node in the sub tree
544 34962 : mpPrev = mpUpper->Lower();
545 34962 : if ( mpPrev )
546 : {
547 319470 : while( mpPrev->mpNext )
548 278234 : mpPrev = mpPrev->mpNext;
549 20618 : mpPrev->mpNext = this;
550 : }
551 : else
552 14344 : mpUpper->pLower = this;
553 : }
554 41718 : }
555 :
556 : /** Insert SwFrm into existing structure.
557 : *
558 : * Insertion is done below the parent either after pBehind or
559 : * at the beginning of the chain if pBehind is empty.
560 : */
561 100152 : void SwFrm::InsertBehind( SwLayoutFrm *pParent, SwFrm *pBefore )
562 : {
563 : OSL_ENSURE( pParent, "No Parent for Insert." );
564 : OSL_ENSURE( (!pBefore || (pBefore && pParent == pBefore->GetUpper())),
565 : "Frame tree is inconsistent." );
566 :
567 100152 : mpUpper = pParent;
568 100152 : mpPrev = pBefore;
569 100152 : if ( pBefore )
570 : {
571 : //Insert after pBefore
572 57538 : if ( 0 != (mpNext = pBefore->mpNext) )
573 130 : mpNext->mpPrev = this;
574 57538 : pBefore->mpNext = this;
575 : }
576 : else
577 : {
578 : //Insert at the beginning of the chain
579 42614 : mpNext = pParent->Lower();
580 42614 : if ( pParent->Lower() )
581 38 : pParent->Lower()->mpPrev = this;
582 42614 : pParent->pLower = this;
583 : }
584 100152 : }
585 :
586 : /** Insert a chain of SwFrms into an existing struction
587 : *
588 : * Currently, this method is used to insert a SectionFrame (which may have some siblings) into an
589 : * existing structure. If the third parameter is NULL, this method is (besides handling the
590 : * siblings) equal to SwFrm::InsertBefore(..).
591 : *
592 : * If the third parameter is passed, the following happens:
593 : * - this becomes mpNext of pParent
594 : * - pSct becomes mpNext of the last one in the this-chain
595 : * - pBehind is reconnected from pParent to pSct
596 : * The purpose is: a SectionFrm (this) won't become a child of another SectionFrm (pParent), but
597 : * pParent gets split into two siblings (pParent+pSect) and this is inserted between.
598 : */
599 0 : void SwFrm::InsertGroupBefore( SwFrm* pParent, SwFrm* pBehind, SwFrm* pSct )
600 : {
601 : OSL_ENSURE( pParent, "No parent for insert." );
602 : OSL_ENSURE( (!pBehind || ( (pBehind && (pParent == pBehind->GetUpper()))
603 : || ((pParent->IsSctFrm() && pBehind->GetUpper()->IsColBodyFrm())) ) ),
604 : "Frame tree inconsistent." );
605 0 : if( pSct )
606 : {
607 0 : mpUpper = pParent->GetUpper();
608 0 : SwFrm *pLast = this;
609 0 : while( pLast->GetNext() )
610 : {
611 0 : pLast = pLast->GetNext();
612 0 : pLast->mpUpper = GetUpper();
613 : }
614 0 : if( pBehind )
615 : {
616 0 : pLast->mpNext = pSct;
617 0 : pSct->mpPrev = pLast;
618 0 : pSct->mpNext = pParent->GetNext();
619 : }
620 : else
621 : {
622 0 : pLast->mpNext = pParent->GetNext();
623 0 : if( pLast->GetNext() )
624 0 : pLast->GetNext()->mpPrev = pLast;
625 : }
626 0 : pParent->mpNext = this;
627 0 : mpPrev = pParent;
628 0 : if( pSct->GetNext() )
629 0 : pSct->GetNext()->mpPrev = pSct;
630 0 : while( pLast->GetNext() )
631 : {
632 0 : pLast = pLast->GetNext();
633 0 : pLast->mpUpper = GetUpper();
634 : }
635 0 : if( pBehind )
636 : { // Insert before pBehind.
637 0 : if( pBehind->GetPrev() )
638 0 : pBehind->GetPrev()->mpNext = NULL;
639 : else
640 0 : pBehind->GetUpper()->pLower = NULL;
641 0 : pBehind->mpPrev = NULL;
642 0 : SwLayoutFrm* pTmp = (SwLayoutFrm*)pSct;
643 0 : if( pTmp->Lower() )
644 : {
645 : OSL_ENSURE( pTmp->Lower()->IsColumnFrm(), "InsertGrp: Used SectionFrm" );
646 0 : pTmp = (SwLayoutFrm*)((SwLayoutFrm*)pTmp->Lower())->Lower();
647 : OSL_ENSURE( pTmp, "InsertGrp: Missing ColBody" );
648 : }
649 0 : pBehind->mpUpper = pTmp;
650 0 : pBehind->GetUpper()->pLower = pBehind;
651 0 : pLast = pBehind->GetNext();
652 0 : while ( pLast )
653 : {
654 0 : pLast->mpUpper = pBehind->GetUpper();
655 0 : pLast = pLast->GetNext();
656 : }
657 : }
658 : else
659 : {
660 : OSL_ENSURE( pSct->IsSctFrm(), "InsertGroup: For SectionFrms only" );
661 0 : delete ((SwSectionFrm*)pSct);
662 : }
663 : }
664 : else
665 : {
666 0 : mpUpper = (SwLayoutFrm*)pParent;
667 0 : SwFrm *pLast = this;
668 0 : while( pLast->GetNext() )
669 : {
670 0 : pLast = pLast->GetNext();
671 0 : pLast->mpUpper = GetUpper();
672 : }
673 0 : pLast->mpNext = pBehind;
674 0 : if( pBehind )
675 : { // Insert before pBehind.
676 0 : if( 0 != (mpPrev = pBehind->mpPrev) )
677 0 : mpPrev->mpNext = this;
678 : else
679 0 : mpUpper->pLower = this;
680 0 : pBehind->mpPrev = pLast;
681 : }
682 : else
683 : {
684 : //Insert at the end, or ... the first node in the subtree
685 0 : mpPrev = mpUpper->Lower();
686 0 : if ( mpPrev )
687 : {
688 0 : while( mpPrev->mpNext )
689 0 : mpPrev = mpPrev->mpNext;
690 0 : mpPrev->mpNext = this;
691 : }
692 : else
693 0 : mpUpper->pLower = this;
694 : }
695 : }
696 0 : }
697 :
698 102850 : void SwFrm::Remove()
699 : {
700 : OSL_ENSURE( mpUpper, "Remove without upper?" );
701 :
702 102850 : if( mpPrev )
703 : // one out of the middle is removed
704 13553 : mpPrev->mpNext = mpNext;
705 : else
706 : { // the first in a list is removed //TODO
707 : OSL_ENSURE( mpUpper->pLower == this, "Layout is inconsistent." );
708 89297 : mpUpper->pLower = mpNext;
709 : }
710 102850 : if( mpNext )
711 66752 : mpNext->mpPrev = mpPrev;
712 :
713 : // Remove link
714 102850 : mpNext = mpPrev = 0;
715 102850 : mpUpper = 0;
716 102850 : }
717 :
718 18184 : void SwCntntFrm::Paste( SwFrm* pParent, SwFrm* pSibling)
719 : {
720 : OSL_ENSURE( pParent, "No parent for pasting." );
721 : OSL_ENSURE( pParent->IsLayoutFrm(), "Parent is CntntFrm." );
722 : OSL_ENSURE( pParent != this, "I'm the parent." );
723 : OSL_ENSURE( pSibling != this, "I'm my own neighbour." );
724 : OSL_ENSURE( !GetPrev() && !GetNext() && !GetUpper(),
725 : "I'm still registered somewhere" );
726 : OSL_ENSURE( !pSibling || pSibling->IsFlowFrm(),
727 : "<SwCntntFrm::Paste(..)> - sibling not of expected type." );
728 :
729 : //Insert in the tree.
730 18184 : InsertBefore( (SwLayoutFrm*)pParent, pSibling );
731 :
732 18184 : SwPageFrm *pPage = FindPageFrm();
733 18184 : _InvalidateAll();
734 18184 : InvalidatePage( pPage );
735 :
736 18184 : if( pPage )
737 : {
738 18184 : pPage->InvalidateSpelling();
739 18184 : pPage->InvalidateSmartTags();
740 18184 : pPage->InvalidateAutoCompleteWords();
741 18184 : pPage->InvalidateWordCount();
742 : }
743 :
744 18184 : if ( GetNext() )
745 : {
746 4068 : SwFrm* pNxt = GetNext();
747 4068 : pNxt->_InvalidatePrt();
748 4068 : pNxt->_InvalidatePos();
749 4068 : pNxt->InvalidatePage( pPage );
750 4068 : if( pNxt->IsSctFrm() )
751 6 : pNxt = ((SwSectionFrm*)pNxt)->ContainsCntnt();
752 4068 : if( pNxt && pNxt->IsTxtFrm() && pNxt->IsInFtn() )
753 10 : pNxt->Prepare( PREP_FTN, 0, false );
754 : }
755 :
756 18184 : if ( Frm().Height() )
757 12258 : pParent->Grow( Frm().Height() );
758 :
759 18184 : if ( Frm().Width() != pParent->Prt().Width() )
760 5602 : Prepare( PREP_FIXSIZE_CHG );
761 :
762 18184 : if ( GetPrev() )
763 : {
764 17340 : if ( IsFollow() )
765 : //I'm a direct follower of my master now
766 1238 : ((SwCntntFrm*)GetPrev())->Prepare( PREP_FOLLOW_FOLLOWS );
767 : else
768 : {
769 32204 : if ( GetPrev()->Frm().Height() !=
770 16102 : GetPrev()->Prt().Height() + GetPrev()->Prt().Top() )
771 : {
772 : // Take the border into account?
773 72 : GetPrev()->_InvalidatePrt();
774 : }
775 : // OD 18.02.2003 #104989# - force complete paint of previous frame,
776 : // if frame is inserted at the end of a section frame, in order to
777 : // get subsidiary lines repainted for the section.
778 16102 : if ( pParent->IsSctFrm() && !GetNext() )
779 : {
780 : // force complete paint of previous frame, if new inserted frame
781 : // in the section is the last one.
782 358 : GetPrev()->SetCompletePaint();
783 : }
784 16102 : GetPrev()->InvalidatePage( pPage );
785 : }
786 : }
787 18184 : if ( IsInFtn() )
788 : {
789 14 : SwFrm* pFrm = GetIndPrev();
790 14 : if( pFrm && pFrm->IsSctFrm() )
791 2 : pFrm = ((SwSectionFrm*)pFrm)->ContainsAny();
792 14 : if( pFrm )
793 6 : pFrm->Prepare( PREP_QUOVADIS, 0, false );
794 14 : if( !GetNext() )
795 : {
796 4 : pFrm = FindFtnFrm()->GetNext();
797 4 : if( pFrm && 0 != (pFrm=((SwLayoutFrm*)pFrm)->ContainsAny()) )
798 0 : pFrm->_InvalidatePrt();
799 : }
800 : }
801 :
802 18184 : _InvalidateLineNum();
803 18184 : SwFrm *pNxt = FindNextCnt();
804 18184 : if ( pNxt )
805 : {
806 35870 : while ( pNxt && pNxt->IsInTab() )
807 : {
808 722 : if( 0 != (pNxt = pNxt->FindTabFrm()) )
809 722 : pNxt = pNxt->FindNextCnt();
810 : }
811 17574 : if ( pNxt )
812 : {
813 17574 : pNxt->_InvalidateLineNum();
814 17574 : if ( pNxt != GetNext() )
815 13534 : pNxt->InvalidatePage();
816 : }
817 : }
818 18184 : }
819 :
820 14322 : void SwCntntFrm::Cut()
821 : {
822 : OSL_ENSURE( GetUpper(), "Cut without Upper()." );
823 :
824 14322 : SwPageFrm *pPage = FindPageFrm();
825 14322 : InvalidatePage( pPage );
826 14322 : SwFrm *pFrm = GetIndPrev();
827 14322 : if( pFrm )
828 : {
829 1070 : if( pFrm->IsSctFrm() )
830 96 : pFrm = ((SwSectionFrm*)pFrm)->ContainsAny();
831 1070 : if ( pFrm && pFrm->IsCntntFrm() )
832 : {
833 1010 : pFrm->_InvalidatePrt();
834 1010 : if( IsInFtn() )
835 6 : pFrm->Prepare( PREP_QUOVADIS, 0, false );
836 : }
837 : // #i26250# - invalidate printing area of previous
838 : // table frame.
839 60 : else if ( pFrm && pFrm->IsTabFrm() )
840 : {
841 12 : pFrm->InvalidatePrt();
842 : }
843 : }
844 :
845 14322 : SwFrm *pNxt = FindNextCnt();
846 14322 : if ( pNxt )
847 : {
848 28652 : while ( pNxt && pNxt->IsInTab() )
849 : {
850 620 : if( 0 != (pNxt = pNxt->FindTabFrm()) )
851 620 : pNxt = pNxt->FindNextCnt();
852 : }
853 14016 : if ( pNxt )
854 : {
855 14016 : pNxt->_InvalidateLineNum();
856 14016 : if ( pNxt != GetNext() )
857 2212 : pNxt->InvalidatePage();
858 : }
859 : }
860 :
861 14322 : if( 0 != (pFrm = GetIndNext()) )
862 : {
863 : // The old follow may have calculated a gap to the predecessor which
864 : // now becomes obsolete or different as it becomes the first one itself
865 12464 : pFrm->_InvalidatePrt();
866 12464 : pFrm->_InvalidatePos();
867 12464 : pFrm->InvalidatePage( pPage );
868 12464 : if( pFrm->IsSctFrm() )
869 : {
870 542 : pFrm = ((SwSectionFrm*)pFrm)->ContainsAny();
871 542 : if( pFrm )
872 : {
873 90 : pFrm->_InvalidatePrt();
874 90 : pFrm->_InvalidatePos();
875 90 : pFrm->InvalidatePage( pPage );
876 : }
877 : }
878 12464 : if( pFrm && IsInFtn() )
879 4 : pFrm->Prepare( PREP_ERGOSUM, 0, false );
880 12464 : if( IsInSct() && !GetPrev() )
881 : {
882 1456 : SwSectionFrm* pSct = FindSctFrm();
883 1456 : if( !pSct->IsFollow() )
884 : {
885 114 : pSct->_InvalidatePrt();
886 114 : pSct->InvalidatePage( pPage );
887 : }
888 : }
889 : }
890 : else
891 : {
892 1858 : InvalidateNextPos();
893 : //Someone needs to do the retouching: predecessor or upper
894 1858 : if ( 0 != (pFrm = GetPrev()) )
895 418 : { pFrm->SetRetouche();
896 418 : pFrm->Prepare( PREP_WIDOWS_ORPHANS );
897 418 : pFrm->_InvalidatePos();
898 418 : pFrm->InvalidatePage( pPage );
899 : }
900 : // If I'm (was) the only CntntFrm in my upper, it has to do the
901 : // retouching. Also, perhaps a page became empty.
902 : else
903 1440 : { SwRootFrm *pRoot = getRootFrm();
904 1440 : if ( pRoot )
905 : {
906 1440 : pRoot->SetSuperfluous();
907 1440 : GetUpper()->SetCompletePaint();
908 1440 : GetUpper()->InvalidatePage( pPage );
909 : }
910 1440 : if( IsInSct() )
911 : {
912 686 : SwSectionFrm* pSct = FindSctFrm();
913 686 : if( !pSct->IsFollow() )
914 : {
915 458 : pSct->_InvalidatePrt();
916 458 : pSct->InvalidatePage( pPage );
917 : }
918 : }
919 : // #i52253# The master table should take care
920 : // of removing the follow flow line.
921 1440 : if ( IsInTab() )
922 : {
923 6 : SwTabFrm* pThisTab = FindTabFrm();
924 6 : SwTabFrm* pMasterTab = pThisTab && pThisTab->IsFollow() ? pThisTab->FindMaster() : 0;
925 6 : if ( pMasterTab )
926 : {
927 6 : pMasterTab->_InvalidatePos();
928 6 : pMasterTab->SetRemoveFollowFlowLinePending( true );
929 : }
930 : }
931 : }
932 : }
933 : //Remove first, then shrink the upper.
934 14322 : SwLayoutFrm *pUp = GetUpper();
935 14322 : Remove();
936 14322 : if ( pUp )
937 : {
938 14322 : SwSectionFrm *pSct = 0;
939 16724 : if ( !pUp->Lower() &&
940 3920 : ( ( pUp->IsFtnFrm() && !pUp->IsColLocked() ) ||
941 3166 : ( pUp->IsInSct() &&
942 : // #i29438#
943 : // We have to consider the case that the section may be "empty"
944 : // except from a temporary empty table frame.
945 : // This can happen due to the new cell split feature.
946 3618 : !pUp->IsCellFrm() &&
947 : // #126020# - adjust check for empty section
948 : // #130797# - correct fix #126020#
949 2854 : !(pSct = pUp->FindSctFrm())->ContainsCntnt() &&
950 442 : !pSct->ContainsAny( true ) ) ) )
951 : {
952 442 : if ( pUp->GetUpper() )
953 : {
954 :
955 : // prevent delete of <ColLocked> footnote frame
956 442 : if ( pUp->IsFtnFrm() && !pUp->IsColLocked())
957 : {
958 0 : if( pUp->GetNext() && !pUp->GetPrev() )
959 : {
960 0 : SwFrm* pTmp = ((SwLayoutFrm*)pUp->GetNext())->ContainsAny();
961 0 : if( pTmp )
962 0 : pTmp->_InvalidatePrt();
963 : }
964 0 : pUp->Cut();
965 0 : delete pUp;
966 : }
967 : else
968 : {
969 :
970 884 : if ( pSct->IsColLocked() || !pSct->IsInFtn() ||
971 0 : ( pUp->IsFtnFrm() && pUp->IsColLocked() ) )
972 : {
973 442 : pSct->DelEmpty( false );
974 : // If a locked section may not be deleted then at least
975 : // its size became invalid after removing its last
976 : // content.
977 442 : pSct->_InvalidateSize();
978 : }
979 : else
980 : {
981 0 : pSct->DelEmpty( true );
982 0 : delete pSct;
983 : }
984 : }
985 : }
986 : }
987 : else
988 : {
989 13880 : SWRECTFN( this )
990 13880 : long nFrmHeight = (Frm().*fnRect->fnGetHeight)();
991 13880 : if( nFrmHeight )
992 12688 : pUp->Shrink( nFrmHeight );
993 : }
994 : }
995 14322 : }
996 :
997 13170 : void SwLayoutFrm::Paste( SwFrm* pParent, SwFrm* pSibling)
998 : {
999 : OSL_ENSURE( pParent, "No parent for pasting." );
1000 : OSL_ENSURE( pParent->IsLayoutFrm(), "Parent is CntntFrm." );
1001 : OSL_ENSURE( pParent != this, "I'm the parent oneself." );
1002 : OSL_ENSURE( pSibling != this, "I'm my own neighbour." );
1003 : OSL_ENSURE( !GetPrev() && !GetNext() && !GetUpper(),
1004 : "I'm still registered somewhere." );
1005 :
1006 : //Insert in the tree.
1007 13170 : InsertBefore( (SwLayoutFrm*)pParent, pSibling );
1008 :
1009 : // OD 24.10.2002 #103517# - correct setting of variable <fnRect>
1010 : // <fnRect> is used for the following:
1011 : // (1) To invalidate the frame's size, if its size, which has to be the
1012 : // same as its upper/parent, differs from its upper's/parent's.
1013 : // (2) To adjust/grow the frame's upper/parent, if it has a dimension in its
1014 : // size, which is not determined by its upper/parent.
1015 : // Which size is which depends on the frame type and the layout direction
1016 : // (vertical or horizontal).
1017 : // There are the following cases:
1018 : // (A) Header and footer frames both in vertical and in horizontal layout
1019 : // have to size the width to the upper/parent. A dimension in the height
1020 : // has to cause a adjustment/grow of the upper/parent.
1021 : // --> <fnRect> = fnRectHori
1022 : // (B) Cell and column frames in vertical layout, the width has to be the
1023 : // same as upper/parent and a dimension in height causes adjustment/grow
1024 : // of the upper/parent.
1025 : // --> <fnRect> = fnRectHori
1026 : // in horizontal layout the other way around
1027 : // --> <fnRect> = fnRectVert
1028 : // (C) Other frames in vertical layout, the height has to be the
1029 : // same as upper/parent and a dimension in width causes adjustment/grow
1030 : // of the upper/parent.
1031 : // --> <fnRect> = fnRectVert
1032 : // in horizontal layout the other way around
1033 : // --> <fnRect> = fnRectHori
1034 : //SwRectFn fnRect = IsVertical() ? fnRectHori : fnRectVert;
1035 : SwRectFn fnRect;
1036 13170 : if ( IsHeaderFrm() || IsFooterFrm() )
1037 3664 : fnRect = fnRectHori;
1038 9506 : else if ( IsCellFrm() || IsColumnFrm() )
1039 374 : fnRect = GetUpper()->IsVertical() ? fnRectHori : ( GetUpper()->IsVertLR() ? fnRectVertL2R : fnRectVert );
1040 : else
1041 9132 : fnRect = GetUpper()->IsVertical() ? ( GetUpper()->IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
1042 :
1043 13170 : if( (Frm().*fnRect->fnGetWidth)() != (pParent->Prt().*fnRect->fnGetWidth)())
1044 5182 : _InvalidateSize();
1045 13170 : _InvalidatePos();
1046 13170 : const SwPageFrm *pPage = FindPageFrm();
1047 13170 : InvalidatePage( pPage );
1048 : SwFrm *pFrm;
1049 13170 : if( !IsColumnFrm() )
1050 : {
1051 12796 : if( 0 != ( pFrm = GetIndNext() ) )
1052 : {
1053 1924 : pFrm->_InvalidatePos();
1054 1924 : if( IsInFtn() )
1055 : {
1056 20 : if( pFrm->IsSctFrm() )
1057 0 : pFrm = ((SwSectionFrm*)pFrm)->ContainsAny();
1058 20 : if( pFrm )
1059 20 : pFrm->Prepare( PREP_ERGOSUM, 0, false );
1060 : }
1061 : }
1062 12796 : if ( IsInFtn() && 0 != ( pFrm = GetIndPrev() ) )
1063 : {
1064 126 : if( pFrm->IsSctFrm() )
1065 0 : pFrm = ((SwSectionFrm*)pFrm)->ContainsAny();
1066 126 : if( pFrm )
1067 126 : pFrm->Prepare( PREP_QUOVADIS, 0, false );
1068 : }
1069 : }
1070 :
1071 13170 : if( (Frm().*fnRect->fnGetHeight)() )
1072 : {
1073 : // AdjustNeighbourhood is now also called in columns which are not
1074 : // placed inside a frame
1075 7670 : sal_uInt8 nAdjust = GetUpper()->IsFtnBossFrm() ?
1076 7470 : ((SwFtnBossFrm*)GetUpper())->NeighbourhoodAdjustment( this )
1077 15140 : : NA_GROW_SHRINK;
1078 7670 : SwTwips nGrow = (Frm().*fnRect->fnGetHeight)();
1079 7670 : if( NA_ONLY_ADJUST == nAdjust )
1080 7470 : AdjustNeighbourhood( nGrow );
1081 : else
1082 : {
1083 200 : SwTwips nReal = 0;
1084 200 : if( NA_ADJUST_GROW == nAdjust )
1085 0 : nReal = AdjustNeighbourhood( nGrow );
1086 200 : if( nReal < nGrow )
1087 200 : nReal += pParent->Grow( nGrow - nReal );
1088 200 : if( NA_GROW_ADJUST == nAdjust && nReal < nGrow )
1089 0 : AdjustNeighbourhood( nGrow - nReal );
1090 : }
1091 : }
1092 13170 : }
1093 :
1094 1722 : void SwLayoutFrm::Cut()
1095 : {
1096 1722 : if ( GetNext() )
1097 1564 : GetNext()->_InvalidatePos();
1098 :
1099 1722 : SWRECTFN( this )
1100 1722 : SwTwips nShrink = (Frm().*fnRect->fnGetHeight)();
1101 :
1102 : //Remove first, then shrink upper.
1103 1722 : SwLayoutFrm *pUp = GetUpper();
1104 :
1105 : // AdjustNeighbourhood is now also called in columns which are not
1106 : // placed inside a frame
1107 :
1108 : // Remove must not be called before a AdjustNeighbourhood, but it has to
1109 : // be called before the upper-shrink-call, if the upper-shrink takes care
1110 : // of his content
1111 1722 : if ( pUp && nShrink )
1112 : {
1113 370 : if( pUp->IsFtnBossFrm() )
1114 : {
1115 136 : sal_uInt8 nAdjust= ((SwFtnBossFrm*)pUp)->NeighbourhoodAdjustment( this );
1116 136 : if( NA_ONLY_ADJUST == nAdjust )
1117 132 : AdjustNeighbourhood( -nShrink );
1118 : else
1119 : {
1120 4 : SwTwips nReal = 0;
1121 4 : if( NA_ADJUST_GROW == nAdjust )
1122 4 : nReal = -AdjustNeighbourhood( -nShrink );
1123 4 : if( nReal < nShrink )
1124 : {
1125 0 : SwTwips nOldHeight = (Frm().*fnRect->fnGetHeight)();
1126 0 : (Frm().*fnRect->fnSetHeight)( 0 );
1127 0 : nReal += pUp->Shrink( nShrink - nReal );
1128 0 : (Frm().*fnRect->fnSetHeight)( nOldHeight );
1129 : }
1130 4 : if( NA_GROW_ADJUST == nAdjust && nReal < nShrink )
1131 0 : AdjustNeighbourhood( nReal - nShrink );
1132 : }
1133 136 : Remove();
1134 : }
1135 : else
1136 : {
1137 234 : Remove();
1138 234 : pUp->Shrink( nShrink );
1139 370 : }
1140 : }
1141 : else
1142 1352 : Remove();
1143 :
1144 1722 : if( pUp && !pUp->Lower() )
1145 : {
1146 30 : pUp->SetCompletePaint();
1147 30 : pUp->InvalidatePage();
1148 : }
1149 1722 : }
1150 :
1151 240162 : SwTwips SwFrm::Grow( SwTwips nDist, bool bTst, bool bInfo )
1152 : {
1153 : OSL_ENSURE( nDist >= 0, "Negative growth?" );
1154 :
1155 : PROTOCOL_ENTER( this, bTst ? PROT_GROW_TST : PROT_GROW, 0, &nDist )
1156 :
1157 240162 : if ( nDist )
1158 : {
1159 240024 : SWRECTFN( this )
1160 :
1161 240024 : SwTwips nPrtHeight = (Prt().*fnRect->fnGetHeight)();
1162 240024 : if( nPrtHeight > 0 && nDist > (LONG_MAX - nPrtHeight) )
1163 16833 : nDist = LONG_MAX - nPrtHeight;
1164 :
1165 240024 : if ( IsFlyFrm() )
1166 1816 : return ((SwFlyFrm*)this)->_Grow( nDist, bTst );
1167 238208 : else if( IsSctFrm() )
1168 18222 : return ((SwSectionFrm*)this)->_Grow( nDist, bTst );
1169 : else
1170 : {
1171 219986 : const SwCellFrm* pThisCell = dynamic_cast<const SwCellFrm*>(this);
1172 219986 : if ( pThisCell )
1173 : {
1174 18160 : const SwTabFrm* pTab = FindTabFrm();
1175 :
1176 : // NEW TABLES
1177 36316 : if ( pTab->IsVertical() != IsVertical() ||
1178 18156 : pThisCell->GetLayoutRowSpan() < 1 )
1179 76 : return 0;
1180 : }
1181 :
1182 219910 : const SwTwips nReal = GrowFrm( nDist, bTst, bInfo );
1183 219910 : if( !bTst )
1184 : {
1185 183241 : nPrtHeight = (Prt().*fnRect->fnGetHeight)();
1186 183241 : (Prt().*fnRect->fnSetHeight)( nPrtHeight +
1187 183241 : ( IsCntntFrm() ? nDist : nReal ) );
1188 : }
1189 219910 : return nReal;
1190 : }
1191 : }
1192 138 : return 0L;
1193 : }
1194 :
1195 81382 : SwTwips SwFrm::Shrink( SwTwips nDist, bool bTst, bool bInfo )
1196 : {
1197 : OSL_ENSURE( nDist >= 0, "Negative reduction?" );
1198 :
1199 : PROTOCOL_ENTER( this, bTst ? PROT_SHRINK_TST : PROT_SHRINK, 0, &nDist )
1200 :
1201 81382 : if ( nDist )
1202 : {
1203 80896 : if ( IsFlyFrm() )
1204 24 : return ((SwFlyFrm*)this)->_Shrink( nDist, bTst );
1205 80872 : else if( IsSctFrm() )
1206 2668 : return ((SwSectionFrm*)this)->_Shrink( nDist, bTst );
1207 : else
1208 : {
1209 78204 : const SwCellFrm* pThisCell = dynamic_cast<const SwCellFrm*>(this);
1210 78204 : if ( pThisCell )
1211 : {
1212 18128 : const SwTabFrm* pTab = FindTabFrm();
1213 :
1214 : // NEW TABLES
1215 36254 : if ( pTab->IsVertical() != IsVertical() ||
1216 18126 : pThisCell->GetLayoutRowSpan() < 1 )
1217 68 : return 0;
1218 : }
1219 :
1220 78136 : SWRECTFN( this )
1221 78136 : SwTwips nReal = (Frm().*fnRect->fnGetHeight)();
1222 78136 : ShrinkFrm( nDist, bTst, bInfo );
1223 78136 : nReal -= (Frm().*fnRect->fnGetHeight)();
1224 78136 : if( !bTst )
1225 : {
1226 78136 : const SwTwips nPrtHeight = (Prt().*fnRect->fnGetHeight)();
1227 78136 : (Prt().*fnRect->fnSetHeight)( nPrtHeight -
1228 78136 : ( IsCntntFrm() ? nDist : nReal ) );
1229 : }
1230 78136 : return nReal;
1231 : }
1232 : }
1233 486 : return 0L;
1234 : }
1235 :
1236 : /** Adjust surrounding neighbourhood after insertion
1237 : *
1238 : * A Frm needs "normalization" if it is directly placed below a footnote boss (page/column) and its
1239 : * size changes. There is always a frame that takes the maximum possible space (the frame that
1240 : * contains the Body text) and zero or more frames which only take the space needed (header/footer
1241 : * area, footnote container). If one of these frames changes, the body-text-frame has to grow or
1242 : * shrink accordingly, even tough it's fixed.
1243 : *
1244 : * !! Is it possible to do this in a generic way and not restrict it to the page and a distinct
1245 : * frame which takes the maximum space (controlled using the FrmSize attribute)?
1246 : * Problems:
1247 : * - What if multiple frames taking the maximum space are placed next to each other?
1248 : * - How is the maximum space calculated?
1249 : * - How small can those frames become?
1250 : *
1251 : * In any case, only a certain amount of space is allowed, so we never go below a minimum value for
1252 : * the height of the body.
1253 : *
1254 : * @param nDiff the value around which the space has to be allocated
1255 : */
1256 13882 : SwTwips SwFrm::AdjustNeighbourhood( SwTwips nDiff, bool bTst )
1257 : {
1258 : PROTOCOL_ENTER( this, PROT_ADJUSTN, 0, &nDiff );
1259 :
1260 13882 : if ( !nDiff || !GetUpper()->IsFtnBossFrm() ) // only inside pages/columns
1261 0 : return 0L;
1262 :
1263 13882 : const SwViewShell *pSh = getRootFrm()->GetCurrShell();
1264 13882 : const bool bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode();
1265 :
1266 : //The (Page-)Body only changes in BrowseMode, but only if it does not
1267 : //contain columns.
1268 21478 : if ( IsPageBodyFrm() && (!bBrowse ||
1269 252 : (((SwLayoutFrm*)this)->Lower() &&
1270 126 : ((SwLayoutFrm*)this)->Lower()->IsColumnFrm())) )
1271 7470 : return 0L;
1272 :
1273 : //In BrowseView mode the PageFrm can handle some of the requests.
1274 6412 : long nBrowseAdd = 0;
1275 6412 : if ( bBrowse && GetUpper()->IsPageFrm() ) // only (Page-)BodyFrms
1276 : {
1277 126 : SwViewShell *pViewShell = getRootFrm()->GetCurrShell();
1278 126 : SwLayoutFrm *pUp = GetUpper();
1279 : long nChg;
1280 252 : const long nUpPrtBottom = pUp->Frm().Height() -
1281 252 : pUp->Prt().Height() - pUp->Prt().Top();
1282 126 : SwRect aInva( pUp->Frm() );
1283 126 : if ( pViewShell )
1284 : {
1285 126 : aInva.Pos().X() = pViewShell->VisArea().Left();
1286 126 : aInva.Width( pViewShell->VisArea().Width() );
1287 : }
1288 126 : if ( nDiff > 0 )
1289 : {
1290 118 : nChg = BROWSE_HEIGHT - pUp->Frm().Height();
1291 118 : nChg = std::min( nDiff, nChg );
1292 :
1293 118 : if ( !IsBodyFrm() )
1294 : {
1295 0 : SetCompletePaint();
1296 0 : if ( !pViewShell || pViewShell->VisArea().Height() >= pUp->Frm().Height() )
1297 : {
1298 : //First minimize Body, it will grow again later.
1299 0 : SwFrm *pBody = ((SwFtnBossFrm*)pUp)->FindBodyCont();
1300 0 : const long nTmp = nChg - pBody->Prt().Height();
1301 0 : if ( !bTst )
1302 : {
1303 0 : pBody->Frm().Height(std::max( 0L, pBody->Frm().Height() - nChg ));
1304 0 : pBody->_InvalidatePrt();
1305 0 : pBody->_InvalidateSize();
1306 0 : if ( pBody->GetNext() )
1307 0 : pBody->GetNext()->_InvalidatePos();
1308 0 : if ( !IsHeaderFrm() )
1309 0 : pBody->SetCompletePaint();
1310 : }
1311 0 : nChg = nTmp <= 0 ? 0 : nTmp;
1312 : }
1313 : }
1314 :
1315 118 : const long nTmp = nUpPrtBottom + 20;
1316 118 : aInva.Top( aInva.Bottom() - nTmp );
1317 118 : aInva.Height( nChg + nTmp );
1318 : }
1319 : else
1320 : {
1321 : //The page can shrink to 0. The fist page keeps the same size like
1322 : //VisArea.
1323 8 : nChg = nDiff;
1324 8 : long nInvaAdd = 0;
1325 16 : if ( pViewShell && !pUp->GetPrev() &&
1326 8 : pUp->Frm().Height() + nDiff < pViewShell->VisArea().Height() )
1327 : {
1328 : // This means that we have to invalidate adequately.
1329 8 : nChg = pViewShell->VisArea().Height() - pUp->Frm().Height();
1330 8 : nInvaAdd = -(nDiff - nChg);
1331 : }
1332 :
1333 : //Invalidate including bottom border.
1334 8 : long nBorder = nUpPrtBottom + 20;
1335 8 : nBorder -= nChg;
1336 8 : aInva.Top( aInva.Bottom() - (nBorder+nInvaAdd) );
1337 8 : if ( !IsBodyFrm() )
1338 : {
1339 0 : SetCompletePaint();
1340 0 : if ( !IsHeaderFrm() )
1341 0 : ((SwFtnBossFrm*)pUp)->FindBodyCont()->SetCompletePaint();
1342 : }
1343 : //Invalidate the page because of the frames. Thereby the page becomes
1344 : //the right size again if a frame didn't fit. This only works
1345 : //randomly for paragraph bound frames otherwise (NotifyFlys).
1346 8 : pUp->InvalidateSize();
1347 : }
1348 126 : if ( !bTst )
1349 : {
1350 : //Independent from nChg
1351 30 : if ( pViewShell && aInva.HasArea() && pUp->GetUpper() )
1352 26 : pViewShell->InvalidateWindows( aInva );
1353 : }
1354 126 : if ( !bTst && nChg )
1355 : {
1356 22 : pUp->Frm().SSize().Height() += nChg;
1357 22 : pUp->Prt().SSize().Height() += nChg;
1358 22 : if ( pViewShell )
1359 22 : pViewShell->Imp()->SetFirstVisPageInvalid();
1360 :
1361 22 : if ( GetNext() )
1362 0 : GetNext()->_InvalidatePos();
1363 :
1364 : //Trigger a repaint if necessary.
1365 22 : SvxBrushItem aBack(pUp->GetFmt()->makeBackgroundBrushItem());
1366 22 : const SvxGraphicPosition ePos = aBack.GetGraphicPos();
1367 22 : if ( ePos != GPOS_NONE && ePos != GPOS_TILED )
1368 0 : pViewShell->InvalidateWindows( pUp->Frm() );
1369 :
1370 22 : if ( pUp->GetUpper() )
1371 : {
1372 22 : if ( pUp->GetNext() )
1373 0 : pUp->GetNext()->InvalidatePos();
1374 :
1375 : //Sad but true: during notify on ViewImp a Calc on the page and
1376 : //its Lower may be called. The values should not be changed
1377 : //because the caller takes care of the adjustment of Frm and
1378 : //Prt.
1379 22 : const long nOldFrmHeight = Frm().Height();
1380 22 : const long nOldPrtHeight = Prt().Height();
1381 22 : const bool bOldComplete = IsCompletePaint();
1382 22 : if ( IsBodyFrm() )
1383 22 : Prt().SSize().Height() = nOldFrmHeight;
1384 :
1385 22 : if ( pUp->GetUpper() )
1386 22 : static_cast<SwRootFrm*>(pUp->GetUpper())->CheckViewLayout( 0, 0 );
1387 : //((SwPageFrm*)pUp)->AdjustRootSize( CHG_CHGPAGE, &aOldRect );
1388 :
1389 22 : Frm().SSize().Height() = nOldFrmHeight;
1390 22 : Prt().SSize().Height() = nOldPrtHeight;
1391 22 : mbCompletePaint = bOldComplete;
1392 : }
1393 22 : if ( !IsBodyFrm() )
1394 0 : pUp->_InvalidateSize();
1395 22 : InvalidatePage( (SwPageFrm*)pUp );
1396 : }
1397 126 : nDiff -= nChg;
1398 126 : if ( !nDiff )
1399 22 : return nChg;
1400 : else
1401 104 : nBrowseAdd = nChg;
1402 : }
1403 :
1404 6390 : const SwFtnBossFrm *pBoss = (SwFtnBossFrm*)GetUpper();
1405 :
1406 6390 : SwTwips nReal = 0,
1407 6390 : nAdd = 0;
1408 6390 : SwFrm *pFrm = 0;
1409 6390 : SWRECTFN( this )
1410 :
1411 6390 : if( IsBodyFrm() )
1412 : {
1413 166 : if( IsInSct() )
1414 : {
1415 6 : SwSectionFrm *pSect = FindSctFrm();
1416 6 : if( nDiff > 0 && pSect->IsEndnAtEnd() && GetNext() &&
1417 0 : GetNext()->IsFtnContFrm() )
1418 : {
1419 0 : SwFtnContFrm* pCont = (SwFtnContFrm*)GetNext();
1420 0 : SwTwips nMinH = 0;
1421 0 : SwFtnFrm* pFtn = (SwFtnFrm*)pCont->Lower();
1422 0 : bool bFtn = false;
1423 0 : while( pFtn )
1424 : {
1425 0 : if( !pFtn->GetAttr()->GetFtn().IsEndNote() )
1426 : {
1427 0 : nMinH += (pFtn->Frm().*fnRect->fnGetHeight)();
1428 0 : bFtn = true;
1429 : }
1430 0 : pFtn = (SwFtnFrm*)pFtn->GetNext();
1431 : }
1432 0 : if( bFtn )
1433 0 : nMinH += (pCont->Prt().*fnRect->fnGetTop)();
1434 0 : nReal = (pCont->Frm().*fnRect->fnGetHeight)() - nMinH;
1435 0 : if( nReal > nDiff )
1436 0 : nReal = nDiff;
1437 0 : if( nReal > 0 )
1438 0 : pFrm = GetNext();
1439 : else
1440 0 : nReal = 0;
1441 : }
1442 6 : if( !bTst && !pSect->IsColLocked() )
1443 0 : pSect->InvalidateSize();
1444 : }
1445 166 : if( !pFrm )
1446 166 : return nBrowseAdd;
1447 : }
1448 : else
1449 : {
1450 6224 : const bool bFtnPage = pBoss->IsPageFrm() && ((SwPageFrm*)pBoss)->IsFtnPage();
1451 6224 : if ( bFtnPage && !IsFtnContFrm() )
1452 0 : pFrm = (SwFrm*)pBoss->FindFtnCont();
1453 6224 : if ( !pFrm )
1454 6224 : pFrm = (SwFrm*)pBoss->FindBodyCont();
1455 :
1456 6224 : if ( !pFrm )
1457 0 : return 0;
1458 :
1459 : //If not one is found, everything else is solved.
1460 6224 : nReal = (pFrm->Frm().*fnRect->fnGetHeight)();
1461 6224 : if( nReal > nDiff )
1462 6200 : nReal = nDiff;
1463 6224 : if( !bFtnPage )
1464 : {
1465 : //Respect the minimal boundary!
1466 6176 : if( nReal )
1467 : {
1468 6176 : const SwTwips nMax = pBoss->GetVarSpace();
1469 6176 : if ( nReal > nMax )
1470 0 : nReal = nMax;
1471 : }
1472 17444 : if( !IsFtnContFrm() && nDiff > nReal &&
1473 0 : pFrm->GetNext() && pFrm->GetNext()->IsFtnContFrm()
1474 6176 : && ( pFrm->GetNext()->IsVertical() == IsVertical() )
1475 : )
1476 : {
1477 : //If the Body doesn't return enough, we look for a footnote, if
1478 : //there is one, we steal there accordingly.
1479 0 : const SwTwips nAddMax = (pFrm->GetNext()->Frm().*fnRect->
1480 0 : fnGetHeight)();
1481 0 : nAdd = nDiff - nReal;
1482 0 : if ( nAdd > nAddMax )
1483 0 : nAdd = nAddMax;
1484 0 : if ( !bTst )
1485 : {
1486 0 : (pFrm->GetNext()->Frm().*fnRect->fnSetHeight)(nAddMax-nAdd);
1487 0 : if( bVert && !bVertL2R && !bRev )
1488 0 : pFrm->GetNext()->Frm().Pos().X() += nAdd;
1489 0 : pFrm->GetNext()->InvalidatePrt();
1490 0 : if ( pFrm->GetNext()->GetNext() )
1491 0 : pFrm->GetNext()->GetNext()->_InvalidatePos();
1492 : }
1493 : }
1494 : }
1495 : }
1496 :
1497 6224 : if ( !bTst && nReal )
1498 : {
1499 5602 : SwTwips nTmp = (pFrm->Frm().*fnRect->fnGetHeight)();
1500 5602 : (pFrm->Frm().*fnRect->fnSetHeight)( nTmp - nReal );
1501 5602 : if( bVert && !bVertL2R && !bRev )
1502 0 : pFrm->Frm().Pos().X() += nReal;
1503 5602 : pFrm->InvalidatePrt();
1504 5602 : if ( pFrm->GetNext() )
1505 5354 : pFrm->GetNext()->_InvalidatePos();
1506 5602 : if( nReal < 0 && pFrm->IsInSct() )
1507 : {
1508 6 : SwLayoutFrm* pUp = pFrm->GetUpper();
1509 12 : if( pUp && 0 != ( pUp = pUp->GetUpper() ) && pUp->IsSctFrm() &&
1510 6 : !pUp->IsColLocked() )
1511 6 : pUp->InvalidateSize();
1512 : }
1513 5602 : if( ( IsHeaderFrm() || IsFooterFrm() ) && pBoss->GetDrawObjs() )
1514 : {
1515 10 : const SwSortedObjs &rObjs = *pBoss->GetDrawObjs();
1516 : OSL_ENSURE( pBoss->IsPageFrm(), "Header/Footer out of page?" );
1517 62 : for ( size_t i = 0; i < rObjs.size(); ++i )
1518 : {
1519 52 : SwAnchoredObject* pAnchoredObj = rObjs[i];
1520 52 : if ( pAnchoredObj->ISA(SwFlyFrm) )
1521 : {
1522 22 : SwFlyFrm* pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
1523 : OSL_ENSURE( !pFly->IsFlyInCntFrm(), "FlyInCnt at Page?" );
1524 : const SwFmtVertOrient &rVert =
1525 22 : pFly->GetFmt()->GetVertOrient();
1526 : // When do we have to invalidate?
1527 : // If a frame is aligned on a PageTextArea and the header
1528 : // changes a TOP, MIDDLE or NONE aligned frame needs to
1529 : // recalculate it's position; if the footer changes a BOTTOM
1530 : // or MIDDLE aligned frame needs to recalculate it's
1531 : // position.
1532 66 : if( ( rVert.GetRelationOrient() == text::RelOrientation::PRINT_AREA ||
1533 22 : rVert.GetRelationOrient() == text::RelOrientation::PAGE_PRINT_AREA ) &&
1534 0 : ((IsHeaderFrm() && rVert.GetVertOrient()!=text::VertOrientation::BOTTOM) ||
1535 0 : (IsFooterFrm() && rVert.GetVertOrient()!=text::VertOrientation::NONE &&
1536 0 : rVert.GetVertOrient() != text::VertOrientation::TOP)) )
1537 : {
1538 0 : pFly->_InvalidatePos();
1539 0 : pFly->_Invalidate();
1540 : }
1541 : }
1542 : }
1543 : }
1544 : }
1545 6224 : return (nBrowseAdd + nReal + nAdd);
1546 : }
1547 :
1548 : /** method to perform additional actions on an invalidation (2004-05-19 #i28701#) */
1549 401680 : void SwFrm::_ActionOnInvalidation( const InvalidationType )
1550 : {
1551 : // default behaviour is to perform no additional action
1552 401680 : }
1553 :
1554 : /** method to determine, if an invalidation is allowed (2004-05-19 #i28701#) */
1555 403899 : bool SwFrm::_InvalidationAllowed( const InvalidationType ) const
1556 : {
1557 : // default behaviour is to allow invalidation
1558 403899 : return true;
1559 : }
1560 :
1561 46605 : void SwFrm::ImplInvalidateSize()
1562 : {
1563 46605 : if ( _InvalidationAllowed( INVALID_SIZE ) )
1564 : {
1565 46605 : mbValidSize = false;
1566 46605 : if ( IsFlyFrm() )
1567 210 : ((SwFlyFrm*)this)->_Invalidate();
1568 : else
1569 46395 : InvalidatePage();
1570 :
1571 : // OD 2004-05-19 #i28701#
1572 46605 : _ActionOnInvalidation( INVALID_SIZE );
1573 : }
1574 46605 : }
1575 :
1576 69707 : void SwFrm::ImplInvalidatePrt()
1577 : {
1578 69707 : if ( _InvalidationAllowed( INVALID_PRTAREA ) )
1579 : {
1580 69707 : mbValidPrtArea = false;
1581 69707 : if ( IsFlyFrm() )
1582 0 : ((SwFlyFrm*)this)->_Invalidate();
1583 : else
1584 69707 : InvalidatePage();
1585 :
1586 : // OD 2004-05-19 #i28701#
1587 69707 : _ActionOnInvalidation( INVALID_PRTAREA );
1588 : }
1589 69707 : }
1590 :
1591 74532 : void SwFrm::ImplInvalidatePos()
1592 : {
1593 74532 : if ( _InvalidationAllowed( INVALID_POS ) )
1594 : {
1595 74504 : mbValidPos = false;
1596 74504 : if ( IsFlyFrm() )
1597 : {
1598 1786 : ((SwFlyFrm*)this)->_Invalidate();
1599 : }
1600 : else
1601 : {
1602 72718 : InvalidatePage();
1603 : }
1604 :
1605 : // OD 2004-05-19 #i28701#
1606 74504 : _ActionOnInvalidation( INVALID_POS );
1607 : }
1608 74532 : }
1609 :
1610 4086 : void SwFrm::ImplInvalidateLineNum()
1611 : {
1612 4086 : if ( _InvalidationAllowed( INVALID_LINENUM ) )
1613 : {
1614 4086 : mbValidLineNum = false;
1615 : OSL_ENSURE( IsTxtFrm(), "line numbers are implemented for text only" );
1616 4086 : InvalidatePage();
1617 :
1618 : // OD 2004-05-19 #i28701#
1619 4086 : _ActionOnInvalidation( INVALID_LINENUM );
1620 : }
1621 4086 : }
1622 :
1623 246 : void SwFrm::ReinitializeFrmSizeAttrFlags()
1624 : {
1625 246 : const SwFmtFrmSize &rFmtSize = GetAttrSet()->GetFrmSize();
1626 278 : if ( ATT_VAR_SIZE == rFmtSize.GetHeightSizeType() ||
1627 32 : ATT_MIN_SIZE == rFmtSize.GetHeightSizeType())
1628 : {
1629 222 : mbFixSize = false;
1630 222 : if ( GetType() & (FRM_HEADER | FRM_FOOTER | FRM_ROW) )
1631 : {
1632 156 : SwFrm *pFrm = ((SwLayoutFrm*)this)->Lower();
1633 524 : while ( pFrm )
1634 212 : { pFrm->_InvalidateSize();
1635 212 : pFrm->_InvalidatePrt();
1636 212 : pFrm = pFrm->GetNext();
1637 : }
1638 156 : SwCntntFrm *pCnt = ((SwLayoutFrm*)this)->ContainsCntnt();
1639 : // #i36991# - be save.
1640 : // E.g., a row can contain *no* content.
1641 156 : if ( pCnt )
1642 : {
1643 156 : pCnt->InvalidatePage();
1644 10684 : do
1645 : {
1646 10684 : pCnt->Prepare( PREP_ADJUST_FRM );
1647 10684 : pCnt->_InvalidateSize();
1648 10684 : pCnt = pCnt->GetNextCntntFrm();
1649 : } while ( ((SwLayoutFrm*)this)->IsAnLower( pCnt ) );
1650 : }
1651 : }
1652 : }
1653 24 : else if ( rFmtSize.GetHeightSizeType() == ATT_FIX_SIZE )
1654 : {
1655 24 : if( IsVertical() )
1656 0 : ChgSize( Size( rFmtSize.GetWidth(), Frm().Height()));
1657 : else
1658 24 : ChgSize( Size( Frm().Width(), rFmtSize.GetHeight()));
1659 : }
1660 246 : }
1661 :
1662 0 : void SwFrm::ValidateThisAndAllLowers( const sal_uInt16 nStage )
1663 : {
1664 : // Stage 0: Only validate frames. Do not process any objects.
1665 : // Stage 1: Only validate fly frames and all of their contents.
1666 : // Stage 2: Validate all.
1667 :
1668 0 : const bool bOnlyObject = 1 == nStage;
1669 0 : const bool bIncludeObjects = 1 <= nStage;
1670 :
1671 0 : if ( !bOnlyObject || ISA(SwFlyFrm) )
1672 : {
1673 0 : mbValidSize = true;
1674 0 : mbValidPrtArea = true;
1675 0 : mbValidPos = true;
1676 : }
1677 :
1678 0 : if ( bIncludeObjects )
1679 : {
1680 0 : const SwSortedObjs* pObjs = GetDrawObjs();
1681 0 : if ( pObjs )
1682 : {
1683 0 : const size_t nCnt = pObjs->size();
1684 0 : for ( size_t i = 0; i < nCnt; ++i )
1685 : {
1686 0 : SwAnchoredObject* pAnchObj = (*pObjs)[i];
1687 0 : if ( pAnchObj->ISA(SwFlyFrm) )
1688 0 : static_cast<SwFlyFrm*>(pAnchObj)->ValidateThisAndAllLowers( 2 );
1689 0 : else if ( pAnchObj->ISA(SwAnchoredDrawObject) )
1690 0 : static_cast<SwAnchoredDrawObject*>(pAnchObj)->ValidateThis();
1691 : }
1692 : }
1693 : }
1694 :
1695 0 : if ( IsLayoutFrm() )
1696 : {
1697 0 : SwFrm* pLower = static_cast<SwLayoutFrm*>(this)->Lower();
1698 0 : while ( pLower )
1699 : {
1700 0 : pLower->ValidateThisAndAllLowers( nStage );
1701 0 : pLower = pLower->GetNext();
1702 : }
1703 : }
1704 0 : }
1705 :
1706 104498 : SwTwips SwCntntFrm::GrowFrm( SwTwips nDist, bool bTst, bool bInfo )
1707 : {
1708 104498 : SWRECTFN( this )
1709 :
1710 104498 : SwTwips nFrmHeight = (Frm().*fnRect->fnGetHeight)();
1711 138159 : if( nFrmHeight > 0 &&
1712 33661 : nDist > (LONG_MAX - nFrmHeight ) )
1713 2530 : nDist = LONG_MAX - nFrmHeight;
1714 :
1715 104498 : const SwViewShell *pSh = getRootFrm()->GetCurrShell();
1716 104498 : const bool bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode();
1717 104498 : const sal_uInt16 nTmpType = bBrowse ? 0x2084: 0x2004; //Row+Cell, Browse with Body
1718 104498 : if( !(GetUpper()->GetType() & nTmpType) && GetUpper()->HasFixSize() )
1719 : {
1720 51096 : if ( !bTst )
1721 : {
1722 47627 : (Frm().*fnRect->fnSetHeight)( nFrmHeight + nDist );
1723 47627 : if( IsVertical() && !IsVertLR() && !IsReverse() )
1724 0 : Frm().Pos().X() -= nDist;
1725 47627 : if ( GetNext() )
1726 : {
1727 29302 : GetNext()->InvalidatePos();
1728 : }
1729 : // #i28701# - Due to the new object positioning the
1730 : // frame on the next page/column can flow backward (e.g. it was moved forward
1731 : // due to the positioning of its objects ). Thus, invalivate this next frame,
1732 : // if document compatibility option 'Consider wrapping style influence on
1733 : // object positioning' is ON.
1734 18325 : else if ( GetUpper()->GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) )
1735 : {
1736 14244 : InvalidateNextPos();
1737 : }
1738 : }
1739 51096 : return 0;
1740 : }
1741 :
1742 53402 : SwTwips nReal = (GetUpper()->Prt().*fnRect->fnGetHeight)();
1743 53402 : SwFrm *pFrm = GetUpper()->Lower();
1744 265742 : while( pFrm && nReal > 0 )
1745 158938 : { nReal -= (pFrm->Frm().*fnRect->fnGetHeight)();
1746 158938 : pFrm = pFrm->GetNext();
1747 : }
1748 :
1749 53402 : if ( !bTst )
1750 : {
1751 : //Cntnts are always resized to the wished value.
1752 45242 : long nOld = (Frm().*fnRect->fnGetHeight)();
1753 45242 : (Frm().*fnRect->fnSetHeight)( nOld + nDist );
1754 45242 : if( IsVertical()&& !IsVertLR() && !IsReverse() )
1755 6 : Frm().Pos().X() -= nDist;
1756 45242 : if ( nOld && IsInTab() )
1757 : {
1758 3602 : SwTabFrm *pTab = FindTabFrm();
1759 7736 : if ( pTab->GetTable()->GetHTMLTableLayout() &&
1760 3824 : !pTab->IsJoinLocked() &&
1761 222 : !pTab->GetFmt()->GetDoc()->GetDocShell()->IsReadOnly() )
1762 : {
1763 222 : pTab->InvalidatePos();
1764 222 : pTab->SetResizeHTMLTable();
1765 : }
1766 : }
1767 : }
1768 :
1769 : //Only grow Upper if necessary.
1770 53402 : if ( nReal < nDist )
1771 : {
1772 30068 : if( GetUpper() )
1773 : {
1774 30068 : if( bTst || !GetUpper()->IsFooterFrm() )
1775 26508 : nReal = GetUpper()->Grow( nDist - (nReal > 0 ? nReal : 0),
1776 53016 : bTst, bInfo );
1777 : else
1778 : {
1779 3560 : nReal = 0;
1780 3560 : GetUpper()->InvalidateSize();
1781 : }
1782 : }
1783 : else
1784 0 : nReal = 0;
1785 : }
1786 : else
1787 23334 : nReal = nDist;
1788 :
1789 : // #i28701# - Due to the new object positioning the
1790 : // frame on the next page/column can flow backward (e.g. it was moved forward
1791 : // due to the positioning of its objects ). Thus, invalivate this next frame,
1792 : // if document compatibility option 'Consider wrapping style influence on
1793 : // object positioning' is ON.
1794 53402 : if ( !bTst )
1795 : {
1796 45242 : if ( GetNext() )
1797 : {
1798 14458 : GetNext()->InvalidatePos();
1799 : }
1800 30784 : else if ( GetUpper()->GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) )
1801 : {
1802 26316 : InvalidateNextPos();
1803 : }
1804 : }
1805 :
1806 53402 : return nReal;
1807 : }
1808 :
1809 17654 : SwTwips SwCntntFrm::ShrinkFrm( SwTwips nDist, bool bTst, bool bInfo )
1810 : {
1811 17654 : SWRECTFN( this )
1812 : OSL_ENSURE( nDist >= 0, "nDist < 0" );
1813 : OSL_ENSURE( nDist <= (Frm().*fnRect->fnGetHeight)(),
1814 : "nDist > than current size." );
1815 :
1816 17654 : if ( !bTst )
1817 : {
1818 : SwTwips nRstHeight;
1819 17654 : if( GetUpper() )
1820 17654 : nRstHeight = (Frm().*fnRect->fnBottomDist)
1821 17654 : ( (GetUpper()->*fnRect->fnGetPrtBottom)() );
1822 : else
1823 0 : nRstHeight = 0;
1824 17654 : if( nRstHeight < 0 )
1825 : {
1826 12865 : SwTwips nNextHeight = 0;
1827 12865 : if( GetUpper()->IsSctFrm() && nDist > LONG_MAX/2 )
1828 : {
1829 0 : SwFrm *pNxt = GetNext();
1830 0 : while( pNxt )
1831 : {
1832 0 : nNextHeight += (pNxt->Frm().*fnRect->fnGetHeight)();
1833 0 : pNxt = pNxt->GetNext();
1834 : }
1835 : }
1836 12865 : nRstHeight = nDist + nRstHeight - nNextHeight;
1837 : }
1838 : else
1839 4789 : nRstHeight = nDist;
1840 17654 : (Frm().*fnRect->fnSetHeight)( (Frm().*fnRect->fnGetHeight)() - nDist );
1841 17654 : if( IsVertical() && !IsVertLR() )
1842 2 : Frm().Pos().X() += nDist;
1843 17654 : nDist = nRstHeight;
1844 17654 : if ( IsInTab() )
1845 : {
1846 3454 : SwTabFrm *pTab = FindTabFrm();
1847 6920 : if ( pTab->GetTable()->GetHTMLTableLayout() &&
1848 3454 : !pTab->IsJoinLocked() &&
1849 0 : !pTab->GetFmt()->GetDoc()->GetDocShell()->IsReadOnly() )
1850 : {
1851 0 : pTab->InvalidatePos();
1852 0 : pTab->SetResizeHTMLTable();
1853 : }
1854 : }
1855 : }
1856 :
1857 : SwTwips nReal;
1858 17654 : if( GetUpper() && nDist > 0 )
1859 : {
1860 5682 : if( bTst || !GetUpper()->IsFooterFrm() )
1861 5682 : nReal = GetUpper()->Shrink( nDist, bTst, bInfo );
1862 : else
1863 : {
1864 0 : nReal = 0;
1865 :
1866 : // #108745# Sorry, dear old footer friend, I'm not gonna invalidate you,
1867 : // if there are any objects anchored inside your content, which
1868 : // overlap with the shrinking frame.
1869 : // This may lead to a footer frame that is too big, but this is better
1870 : // than looping.
1871 : // #109722# : The fix for #108745# was too strict.
1872 :
1873 0 : bool bInvalidate = true;
1874 0 : const SwRect aRect( Frm() );
1875 0 : const SwPageFrm* pPage = FindPageFrm();
1876 0 : const SwSortedObjs* pSorted = pPage ? pPage->GetSortedObjs() : 0;
1877 0 : if( pSorted )
1878 : {
1879 0 : for ( size_t i = 0; i < pSorted->size(); ++i )
1880 : {
1881 0 : const SwAnchoredObject* pAnchoredObj = (*pSorted)[i];
1882 0 : const SwRect aBound( pAnchoredObj->GetObjRectWithSpaces() );
1883 :
1884 0 : if( aBound.Left() > aRect.Right() )
1885 0 : continue;
1886 :
1887 0 : if( aBound.IsOver( aRect ) )
1888 : {
1889 0 : const SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt();
1890 0 : if( SURROUND_THROUGHT != rFmt.GetSurround().GetSurround() )
1891 : {
1892 0 : const SwFrm* pAnchor = pAnchoredObj->GetAnchorFrm();
1893 0 : if ( pAnchor && pAnchor->FindFooterOrHeader() == GetUpper() )
1894 : {
1895 0 : bInvalidate = false;
1896 0 : break;
1897 : }
1898 : }
1899 : }
1900 : }
1901 : }
1902 :
1903 0 : if ( bInvalidate )
1904 0 : GetUpper()->InvalidateSize();
1905 : }
1906 : }
1907 : else
1908 11972 : nReal = 0;
1909 :
1910 17654 : if ( !bTst )
1911 : {
1912 : //The position of the next Frm changes for sure.
1913 17654 : InvalidateNextPos();
1914 :
1915 : //If I don't have a successor I have to do the retouch by myself.
1916 17654 : if ( !GetNext() )
1917 10354 : SetRetouche();
1918 : }
1919 17654 : return nReal;
1920 : }
1921 :
1922 9852 : void SwCntntFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
1923 : {
1924 9852 : sal_uInt8 nInvFlags = 0;
1925 :
1926 9852 : if( pNew && RES_ATTRSET_CHG == pNew->Which() && pOld )
1927 : {
1928 8528 : SfxItemIter aNIter( *((SwAttrSetChg*)pNew)->GetChgSet() );
1929 17056 : SfxItemIter aOIter( *((SwAttrSetChg*)pOld)->GetChgSet() );
1930 17056 : SwAttrSetChg aOldSet( *(SwAttrSetChg*)pOld );
1931 17056 : SwAttrSetChg aNewSet( *(SwAttrSetChg*)pNew );
1932 : while( true )
1933 : {
1934 : _UpdateAttr( (SfxPoolItem*)aOIter.GetCurItem(),
1935 : (SfxPoolItem*)aNIter.GetCurItem(), nInvFlags,
1936 25284 : &aOldSet, &aNewSet );
1937 25284 : if( aNIter.IsAtEnd() )
1938 8528 : break;
1939 16756 : aNIter.NextItem();
1940 16756 : aOIter.NextItem();
1941 : }
1942 8528 : if ( aOldSet.Count() || aNewSet.Count() )
1943 16098 : SwFrm::Modify( &aOldSet, &aNewSet );
1944 : }
1945 : else
1946 1324 : _UpdateAttr( pOld, pNew, nInvFlags );
1947 :
1948 9852 : if ( nInvFlags != 0 )
1949 : {
1950 4922 : SwPageFrm *pPage = FindPageFrm();
1951 4922 : InvalidatePage( pPage );
1952 4922 : if ( nInvFlags & 0x01 )
1953 3968 : SetCompletePaint();
1954 4922 : if ( nInvFlags & 0x02 )
1955 812 : _InvalidatePos();
1956 4922 : if ( nInvFlags & 0x04 )
1957 550 : _InvalidateSize();
1958 4922 : if ( nInvFlags & 0x88 )
1959 : {
1960 696 : if( IsInSct() && !GetPrev() )
1961 : {
1962 34 : SwSectionFrm *pSect = FindSctFrm();
1963 34 : if( pSect->ContainsAny() == this )
1964 : {
1965 6 : pSect->_InvalidatePrt();
1966 6 : pSect->InvalidatePage( pPage );
1967 : }
1968 : }
1969 696 : _InvalidatePrt();
1970 : }
1971 4922 : SwFrm* mpNextFrm = GetIndNext();
1972 4922 : if ( mpNextFrm && nInvFlags & 0x10)
1973 : {
1974 1038 : mpNextFrm->_InvalidatePrt();
1975 1038 : mpNextFrm->InvalidatePage( pPage );
1976 : }
1977 4922 : if ( mpNextFrm && nInvFlags & 0x80 )
1978 : {
1979 390 : mpNextFrm->SetCompletePaint();
1980 : }
1981 4922 : if ( nInvFlags & 0x20 )
1982 : {
1983 1458 : SwFrm* pPrevFrm = GetPrev();
1984 1458 : if ( pPrevFrm )
1985 : {
1986 980 : pPrevFrm->_InvalidatePrt();
1987 980 : pPrevFrm->InvalidatePage( pPage );
1988 : }
1989 : }
1990 4922 : if ( nInvFlags & 0x40 )
1991 574 : InvalidateNextPos();
1992 : }
1993 9852 : }
1994 :
1995 26608 : void SwCntntFrm::_UpdateAttr( const SfxPoolItem* pOld, const SfxPoolItem* pNew,
1996 : sal_uInt8 &rInvFlags,
1997 : SwAttrSetChg *pOldSet, SwAttrSetChg *pNewSet )
1998 : {
1999 26608 : bool bClear = true;
2000 26608 : sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
2001 26608 : switch ( nWhich )
2002 : {
2003 : case RES_FMT_CHG:
2004 550 : rInvFlags = 0xFF;
2005 : /* no break here */
2006 :
2007 : case RES_PAGEDESC: //attribute changes (on/off)
2008 796 : if ( IsInDocBody() && !IsInTab() )
2009 : {
2010 650 : rInvFlags |= 0x02;
2011 650 : SwPageFrm *pPage = FindPageFrm();
2012 650 : if ( !GetPrev() )
2013 284 : CheckPageDescs( pPage );
2014 650 : if ( GetAttrSet()->GetPageDesc().GetNumOffset() )
2015 20 : ((SwRootFrm*)pPage->GetUpper())->SetVirtPageNum( true );
2016 650 : SwDocPosUpdate aMsgHnt( pPage->Frm().Top() );
2017 650 : pPage->GetFmt()->GetDoc()->getIDocumentFieldsAccess().UpdatePageFlds( &aMsgHnt );
2018 : }
2019 796 : break;
2020 :
2021 : case RES_UL_SPACE:
2022 : {
2023 : // OD 2004-02-18 #106629# - correction
2024 : // Invalidation of the printing area of next frame, not only
2025 : // for footnote content.
2026 146 : if ( !GetIndNext() )
2027 : {
2028 80 : SwFrm* pNxt = FindNext();
2029 80 : if ( pNxt )
2030 : {
2031 8 : SwPageFrm* pPg = pNxt->FindPageFrm();
2032 8 : pNxt->InvalidatePage( pPg );
2033 8 : pNxt->_InvalidatePrt();
2034 8 : if( pNxt->IsSctFrm() )
2035 : {
2036 0 : SwFrm* pCnt = ((SwSectionFrm*)pNxt)->ContainsAny();
2037 0 : if( pCnt )
2038 : {
2039 0 : pCnt->_InvalidatePrt();
2040 0 : pCnt->InvalidatePage( pPg );
2041 : }
2042 : }
2043 8 : pNxt->SetCompletePaint();
2044 : }
2045 : }
2046 : // OD 2004-03-17 #i11860#
2047 212 : if ( GetIndNext() &&
2048 66 : !GetUpper()->GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::USE_FORMER_OBJECT_POS) )
2049 : {
2050 : // OD 2004-07-01 #i28701# - use new method <InvalidateObjs(..)>
2051 66 : GetIndNext()->InvalidateObjs( true );
2052 : }
2053 146 : Prepare( PREP_UL_SPACE ); //TxtFrm has to correct line spacing.
2054 146 : rInvFlags |= 0x80;
2055 : /* no break here */
2056 : }
2057 : case RES_LR_SPACE:
2058 : case RES_BOX:
2059 : case RES_SHADOW:
2060 1040 : Prepare( PREP_FIXSIZE_CHG );
2061 1040 : SwFrm::Modify( pOld, pNew );
2062 1040 : rInvFlags |= 0x30;
2063 1040 : break;
2064 :
2065 : case RES_BREAK:
2066 : {
2067 24 : rInvFlags |= 0x42;
2068 24 : const IDocumentSettingAccess* pIDSA = GetUpper()->GetFmt()->getIDocumentSettingAccess();
2069 24 : if( pIDSA->get(IDocumentSettingAccess::PARA_SPACE_MAX) ||
2070 0 : pIDSA->get(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES) )
2071 : {
2072 24 : rInvFlags |= 0x1;
2073 24 : SwFrm* pNxt = FindNext();
2074 24 : if( pNxt )
2075 : {
2076 0 : SwPageFrm* pPg = pNxt->FindPageFrm();
2077 0 : pNxt->InvalidatePage( pPg );
2078 0 : pNxt->_InvalidatePrt();
2079 0 : if( pNxt->IsSctFrm() )
2080 : {
2081 0 : SwFrm* pCnt = ((SwSectionFrm*)pNxt)->ContainsAny();
2082 0 : if( pCnt )
2083 : {
2084 0 : pCnt->_InvalidatePrt();
2085 0 : pCnt->InvalidatePage( pPg );
2086 : }
2087 : }
2088 0 : pNxt->SetCompletePaint();
2089 : }
2090 : }
2091 : }
2092 24 : break;
2093 :
2094 : // OD 2004-02-26 #i25029#
2095 : case RES_PARATR_CONNECT_BORDER:
2096 : {
2097 0 : rInvFlags |= 0x01;
2098 0 : if ( IsTxtFrm() )
2099 : {
2100 0 : InvalidateNextPrtArea();
2101 : }
2102 0 : if ( !GetIndNext() && IsInTab() && IsInSplitTableRow() )
2103 : {
2104 0 : FindTabFrm()->InvalidateSize();
2105 : }
2106 : }
2107 0 : break;
2108 :
2109 : case RES_PARATR_TABSTOP:
2110 : case RES_CHRATR_PROPORTIONALFONTSIZE:
2111 : case RES_CHRATR_SHADOWED:
2112 : case RES_CHRATR_AUTOKERN:
2113 : case RES_CHRATR_UNDERLINE:
2114 : case RES_CHRATR_OVERLINE:
2115 : case RES_CHRATR_KERNING:
2116 : case RES_CHRATR_FONT:
2117 : case RES_CHRATR_FONTSIZE:
2118 : case RES_CHRATR_ESCAPEMENT:
2119 : case RES_CHRATR_CONTOUR:
2120 : case RES_PARATR_NUMRULE:
2121 6122 : rInvFlags |= 0x01;
2122 6122 : break;
2123 :
2124 : case RES_FRM_SIZE:
2125 0 : rInvFlags |= 0x01;
2126 : /* no break here */
2127 :
2128 : default:
2129 18626 : bClear = false;
2130 : }
2131 26608 : if ( bClear )
2132 : {
2133 7982 : if ( pOldSet || pNewSet )
2134 : {
2135 6680 : if ( pOldSet )
2136 6680 : pOldSet->ClearItem( nWhich );
2137 13360 : if ( pNewSet )
2138 6680 : pNewSet->ClearItem( nWhich );
2139 : }
2140 : else
2141 1302 : SwFrm::Modify( pOld, pNew );
2142 : }
2143 26608 : }
2144 :
2145 58852 : SwLayoutFrm::SwLayoutFrm( SwFrmFmt* pFmt, SwFrm* pSib ):
2146 : SwFrm( pFmt, pSib ),
2147 58852 : pLower( 0 )
2148 : {
2149 58852 : const SwFmtFrmSize &rFmtSize = pFmt->GetFrmSize();
2150 58852 : if ( rFmtSize.GetHeightSizeType() == ATT_FIX_SIZE )
2151 10402 : mbFixSize = true;
2152 58852 : }
2153 :
2154 : // #i28701#
2155 951786 : TYPEINIT1(SwLayoutFrm,SwFrm);
2156 :
2157 4832 : SwTwips SwLayoutFrm::InnerHeight() const
2158 : {
2159 4832 : if( !Lower() )
2160 142 : return 0;
2161 4690 : SwTwips nRet = 0;
2162 4690 : const SwFrm* pCnt = Lower();
2163 4690 : SWRECTFN( this )
2164 4690 : if( pCnt->IsColumnFrm() || pCnt->IsCellFrm() )
2165 : {
2166 414 : do
2167 : {
2168 414 : SwTwips nTmp = ((SwLayoutFrm*)pCnt)->InnerHeight();
2169 414 : if( pCnt->GetValidPrtAreaFlag() )
2170 414 : nTmp += (pCnt->Frm().*fnRect->fnGetHeight)() -
2171 414 : (pCnt->Prt().*fnRect->fnGetHeight)();
2172 414 : if( nRet < nTmp )
2173 200 : nRet = nTmp;
2174 414 : pCnt = pCnt->GetNext();
2175 : } while ( pCnt );
2176 : }
2177 : else
2178 : {
2179 11298 : do
2180 : {
2181 11298 : nRet += (pCnt->Frm().*fnRect->fnGetHeight)();
2182 11298 : if( pCnt->IsCntntFrm() && ((SwTxtFrm*)pCnt)->IsUndersized() )
2183 0 : nRet += ((SwTxtFrm*)pCnt)->GetParHeight() -
2184 0 : (pCnt->Prt().*fnRect->fnGetHeight)();
2185 11298 : if( pCnt->IsLayoutFrm() && !pCnt->IsTabFrm() )
2186 420 : nRet += ((SwLayoutFrm*)pCnt)->InnerHeight() -
2187 420 : (pCnt->Prt().*fnRect->fnGetHeight)();
2188 11298 : pCnt = pCnt->GetNext();
2189 : } while( pCnt );
2190 :
2191 : }
2192 4690 : return nRet;
2193 : }
2194 :
2195 91340 : SwTwips SwLayoutFrm::GrowFrm( SwTwips nDist, bool bTst, bool bInfo )
2196 : {
2197 91340 : const SwViewShell *pSh = getRootFrm()->GetCurrShell();
2198 91340 : const bool bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode();
2199 91340 : const sal_uInt16 nTmpType = bBrowse ? 0x2084: 0x2004; //Row+Cell, Browse with Body
2200 91340 : if( !(GetType() & nTmpType) && HasFixSize() )
2201 22580 : return 0;
2202 :
2203 68760 : SWRECTFN( this )
2204 68760 : const SwTwips nFrmHeight = (Frm().*fnRect->fnGetHeight)();
2205 68760 : const SwTwips nFrmPos = Frm().Pos().X();
2206 :
2207 68760 : if ( nFrmHeight > 0 && nDist > (LONG_MAX - nFrmHeight) )
2208 2454 : nDist = LONG_MAX - nFrmHeight;
2209 :
2210 68760 : SwTwips nMin = 0;
2211 68760 : if ( GetUpper() && !IsCellFrm() )
2212 : {
2213 50676 : SwFrm *pFrm = GetUpper()->Lower();
2214 728858 : while( pFrm )
2215 627506 : { nMin += (pFrm->Frm().*fnRect->fnGetHeight)();
2216 627506 : pFrm = pFrm->GetNext();
2217 : }
2218 50676 : nMin = (GetUpper()->Prt().*fnRect->fnGetHeight)() - nMin;
2219 50676 : if ( nMin < 0 )
2220 5362 : nMin = 0;
2221 : }
2222 :
2223 68760 : SwRect aOldFrm( Frm() );
2224 68760 : bool bMoveAccFrm = false;
2225 :
2226 68760 : bool bChgPos = IsVertical() && !IsReverse();
2227 68760 : if ( !bTst )
2228 : {
2229 52704 : (Frm().*fnRect->fnSetHeight)( nFrmHeight + nDist );
2230 52704 : if( bChgPos && !IsVertLR() )
2231 0 : Frm().Pos().X() -= nDist;
2232 52704 : bMoveAccFrm = true;
2233 : }
2234 :
2235 68760 : SwTwips nReal = nDist - nMin;
2236 68760 : if ( nReal > 0 )
2237 : {
2238 68678 : if ( GetUpper() )
2239 : { // AdjustNeighbourhood now only for the columns (but not in frames)
2240 68678 : sal_uInt8 nAdjust = GetUpper()->IsFtnBossFrm() ?
2241 16576 : ((SwFtnBossFrm*)GetUpper())->NeighbourhoodAdjustment( this )
2242 85254 : : NA_GROW_SHRINK;
2243 68678 : if( NA_ONLY_ADJUST == nAdjust )
2244 5186 : nReal = AdjustNeighbourhood( nReal, bTst );
2245 : else
2246 : {
2247 63492 : if( NA_ADJUST_GROW == nAdjust )
2248 0 : nReal += AdjustNeighbourhood( nReal, bTst );
2249 :
2250 63492 : SwTwips nGrow = 0;
2251 63492 : if( 0 < nReal )
2252 : {
2253 63492 : SwFrm* pToGrow = GetUpper();
2254 : // NEW TABLES
2255 : // A cell with a row span of > 1 is allowed to grow the
2256 : // line containing the end of the row span if it is
2257 : // located in the same table frame:
2258 63492 : const SwCellFrm* pThisCell = dynamic_cast<const SwCellFrm*>(this);
2259 63492 : if ( pThisCell && pThisCell->GetLayoutRowSpan() > 1 )
2260 : {
2261 44 : SwCellFrm& rEndCell = const_cast<SwCellFrm&>(pThisCell->FindStartEndOfRowSpanCell( false, true ));
2262 44 : if ( -1 == rEndCell.GetTabBox()->getRowSpan() )
2263 44 : pToGrow = rEndCell.GetUpper();
2264 : else
2265 0 : pToGrow = 0;
2266 : }
2267 :
2268 63492 : nGrow = pToGrow ? pToGrow->Grow( nReal, bTst, bInfo ) : 0;
2269 : }
2270 :
2271 63492 : if( NA_GROW_ADJUST == nAdjust && nGrow < nReal )
2272 0 : nReal += AdjustNeighbourhood( nReal - nGrow, bTst );
2273 :
2274 63492 : if ( IsFtnFrm() && (nGrow != nReal) && GetNext() )
2275 : {
2276 : //Footnotes can replace their successor.
2277 0 : SwTwips nSpace = bTst ? 0 : -nDist;
2278 0 : const SwFrm *pFrm = GetUpper()->Lower();
2279 0 : do
2280 0 : { nSpace += (pFrm->Frm().*fnRect->fnGetHeight)();
2281 0 : pFrm = pFrm->GetNext();
2282 0 : } while ( pFrm != GetNext() );
2283 0 : nSpace = (GetUpper()->Prt().*fnRect->fnGetHeight)() -nSpace;
2284 0 : if ( nSpace < 0 )
2285 0 : nSpace = 0;
2286 0 : nSpace += nGrow;
2287 0 : if ( nReal > nSpace )
2288 0 : nReal = nSpace;
2289 0 : if ( nReal && !bTst )
2290 0 : ((SwFtnFrm*)this)->InvalidateNxtFtnCnts( FindPageFrm() );
2291 : }
2292 : else
2293 63492 : nReal = nGrow;
2294 : }
2295 : }
2296 : else
2297 0 : nReal = 0;
2298 :
2299 68678 : nReal += nMin;
2300 : }
2301 : else
2302 82 : nReal = nDist;
2303 :
2304 68760 : if ( !bTst )
2305 : {
2306 88184 : if( nReal != nDist &&
2307 : // NEW TABLES
2308 21840 : ( !IsCellFrm() || static_cast<SwCellFrm*>(this)->GetLayoutRowSpan() > 1 ) )
2309 : {
2310 16376 : (Frm().*fnRect->fnSetHeight)( nFrmHeight + nReal );
2311 16376 : if( bChgPos && !IsVertLR() )
2312 0 : Frm().Pos().X() = nFrmPos - nReal;
2313 16376 : bMoveAccFrm = true;
2314 : }
2315 :
2316 52704 : if ( nReal )
2317 : {
2318 33900 : SwPageFrm *pPage = FindPageFrm();
2319 33900 : if ( GetNext() )
2320 : {
2321 17658 : GetNext()->_InvalidatePos();
2322 17658 : if ( GetNext()->IsCntntFrm() )
2323 0 : GetNext()->InvalidatePage( pPage );
2324 : }
2325 33900 : if ( !IsPageBodyFrm() )
2326 : {
2327 33878 : _InvalidateAll();
2328 33878 : InvalidatePage( pPage );
2329 : }
2330 33900 : if ( !(GetType() & 0x1823) ) //Tab, Row, FtnCont, Root, Page
2331 17156 : NotifyLowerObjs();
2332 :
2333 33900 : if( IsCellFrm() )
2334 11588 : InvaPercentLowers( nReal );
2335 :
2336 33900 : SvxBrushItem aBack(GetFmt()->makeBackgroundBrushItem());
2337 33900 : const SvxGraphicPosition ePos = aBack.GetGraphicPos();
2338 33900 : if ( GPOS_NONE != ePos && GPOS_TILED != ePos )
2339 2 : SetCompletePaint();
2340 : }
2341 : }
2342 :
2343 68760 : if( bMoveAccFrm && IsAccessibleFrm() )
2344 : {
2345 19500 : SwRootFrm *pRootFrm = getRootFrm();
2346 19500 : if( pRootFrm && pRootFrm->IsAnyShellAccessible() &&
2347 0 : pRootFrm->GetCurrShell() )
2348 : {
2349 0 : pRootFrm->GetCurrShell()->Imp()->MoveAccessibleFrm( this, aOldFrm );
2350 : }
2351 : }
2352 68760 : return nReal;
2353 : }
2354 :
2355 44826 : SwTwips SwLayoutFrm::ShrinkFrm( SwTwips nDist, bool bTst, bool bInfo )
2356 : {
2357 44826 : const SwViewShell *pSh = getRootFrm()->GetCurrShell();
2358 44826 : const bool bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode();
2359 44826 : const sal_uInt16 nTmpType = bBrowse ? 0x2084: 0x2004; //Row+Cell, Browse mit Body
2360 44826 : if( !(GetType() & nTmpType) && HasFixSize() )
2361 16908 : return 0;
2362 :
2363 : OSL_ENSURE( nDist >= 0, "nDist < 0" );
2364 27918 : SWRECTFN( this )
2365 27918 : SwTwips nFrmHeight = (Frm().*fnRect->fnGetHeight)();
2366 27918 : if ( nDist > nFrmHeight )
2367 1470 : nDist = nFrmHeight;
2368 :
2369 27918 : SwTwips nMin = 0;
2370 27918 : bool bChgPos = IsVertical() && !IsReverse();
2371 27918 : if ( Lower() )
2372 : {
2373 26618 : if( !Lower()->IsNeighbourFrm() )
2374 26618 : { const SwFrm *pFrm = Lower();
2375 26618 : const long nTmp = (Prt().*fnRect->fnGetHeight)();
2376 173110 : while( pFrm && nMin < nTmp )
2377 119874 : { nMin += (pFrm->Frm().*fnRect->fnGetHeight)();
2378 119874 : pFrm = pFrm->GetNext();
2379 : }
2380 : }
2381 : }
2382 27918 : SwTwips nReal = nDist;
2383 27918 : SwTwips nMinDiff = (Prt().*fnRect->fnGetHeight)() - nMin;
2384 27918 : if( nReal > nMinDiff )
2385 2016 : nReal = nMinDiff;
2386 27918 : if( nReal <= 0 )
2387 1724 : return nDist;
2388 :
2389 26194 : SwRect aOldFrm( Frm() );
2390 26194 : bool bMoveAccFrm = false;
2391 :
2392 26194 : SwTwips nRealDist = nReal;
2393 26194 : if ( !bTst )
2394 : {
2395 26194 : (Frm().*fnRect->fnSetHeight)( nFrmHeight - nReal );
2396 26194 : if( bChgPos && !IsVertLR() )
2397 0 : Frm().Pos().X() += nReal;
2398 26194 : bMoveAccFrm = true;
2399 : }
2400 :
2401 52388 : sal_uInt8 nAdjust = GetUpper() && GetUpper()->IsFtnBossFrm() ?
2402 2362 : ((SwFtnBossFrm*)GetUpper())->NeighbourhoodAdjustment( this )
2403 28556 : : NA_GROW_SHRINK;
2404 :
2405 : // AdjustNeighbourhood also in columns (but not in frames)
2406 26194 : if( NA_ONLY_ADJUST == nAdjust )
2407 : {
2408 64 : if ( IsPageBodyFrm() && !bBrowse )
2409 0 : nReal = nDist;
2410 : else
2411 64 : { nReal = AdjustNeighbourhood( -nReal, bTst );
2412 64 : nReal *= -1;
2413 64 : if ( !bTst && IsBodyFrm() && nReal < nRealDist )
2414 : {
2415 20 : (Frm().*fnRect->fnSetHeight)( (Frm().*fnRect->fnGetHeight)()
2416 20 : + nRealDist - nReal );
2417 10 : if( bChgPos && !IsVertLR() )
2418 0 : Frm().Pos().X() += nRealDist - nReal;
2419 : OSL_ENSURE( !IsAccessibleFrm(), "bMoveAccFrm has to be set!" );
2420 : }
2421 : }
2422 : }
2423 26130 : else if( IsColumnFrm() || IsColBodyFrm() )
2424 : {
2425 4594 : SwTwips nTmp = GetUpper()->Shrink( nReal, bTst, bInfo );
2426 4594 : if ( nTmp != nReal )
2427 : {
2428 9076 : (Frm().*fnRect->fnSetHeight)( (Frm().*fnRect->fnGetHeight)()
2429 9076 : + nReal - nTmp );
2430 4538 : if( bChgPos && !IsVertLR() )
2431 0 : Frm().Pos().X() += nTmp - nReal;
2432 : OSL_ENSURE( !IsAccessibleFrm(), "bMoveAccFrm has to be set!" );
2433 4538 : nReal = nTmp;
2434 : }
2435 : }
2436 : else
2437 : {
2438 21536 : SwTwips nShrink = nReal;
2439 21536 : SwFrm* pToShrink = GetUpper();
2440 21536 : const SwCellFrm* pThisCell = dynamic_cast<const SwCellFrm*>(this);
2441 : // NEW TABLES
2442 21536 : if ( pThisCell && pThisCell->GetLayoutRowSpan() > 1 )
2443 : {
2444 112 : SwCellFrm& rEndCell = const_cast<SwCellFrm&>(pThisCell->FindStartEndOfRowSpanCell( false, true ));
2445 112 : pToShrink = rEndCell.GetUpper();
2446 : }
2447 :
2448 21536 : nReal = pToShrink ? pToShrink->Shrink( nShrink, bTst, bInfo ) : 0;
2449 21536 : if( ( NA_GROW_ADJUST == nAdjust || NA_ADJUST_GROW == nAdjust )
2450 2 : && nReal < nShrink )
2451 2 : AdjustNeighbourhood( nReal - nShrink );
2452 : }
2453 :
2454 26194 : if( bMoveAccFrm && IsAccessibleFrm() )
2455 : {
2456 21544 : SwRootFrm *pRootFrm = getRootFrm();
2457 21544 : if( pRootFrm && pRootFrm->IsAnyShellAccessible() &&
2458 0 : pRootFrm->GetCurrShell() )
2459 : {
2460 0 : pRootFrm->GetCurrShell()->Imp()->MoveAccessibleFrm( this, aOldFrm );
2461 : }
2462 : }
2463 26194 : if ( !bTst && (IsCellFrm() || IsColumnFrm() ? nReal : nRealDist) )
2464 : {
2465 9106 : SwPageFrm *pPage = FindPageFrm();
2466 9106 : if ( GetNext() )
2467 : {
2468 3706 : GetNext()->_InvalidatePos();
2469 3706 : if ( GetNext()->IsCntntFrm() )
2470 1464 : GetNext()->InvalidatePage( pPage );
2471 3706 : if ( IsTabFrm() )
2472 3054 : ((SwTabFrm*)this)->SetComplete();
2473 : }
2474 : else
2475 5400 : { if ( IsRetoucheFrm() )
2476 726 : SetRetouche();
2477 5400 : if ( IsTabFrm() )
2478 : {
2479 718 : if( IsTabFrm() )
2480 718 : ((SwTabFrm*)this)->SetComplete();
2481 718 : if ( Lower() ) // Can also be in the Join and be empty!
2482 712 : InvalidateNextPos();
2483 : }
2484 : }
2485 9106 : if ( !IsBodyFrm() )
2486 : {
2487 6800 : _InvalidateAll();
2488 6800 : InvalidatePage( pPage );
2489 6800 : bool bCompletePaint = true;
2490 6800 : const SwFrmFmt* pFmt = GetFmt();
2491 6800 : if (pFmt)
2492 : {
2493 6800 : SvxBrushItem aBack(pFmt->makeBackgroundBrushItem());
2494 6800 : const SvxGraphicPosition ePos = aBack.GetGraphicPos();
2495 6800 : if ( GPOS_NONE == ePos || GPOS_TILED == ePos )
2496 6800 : bCompletePaint = false;
2497 : }
2498 6800 : if (bCompletePaint)
2499 0 : SetCompletePaint();
2500 : }
2501 :
2502 9106 : if ( !(GetType() & 0x1823) ) //Tab, Row, FtnCont, Root, Page
2503 5288 : NotifyLowerObjs();
2504 :
2505 9106 : if( IsCellFrm() )
2506 2936 : InvaPercentLowers( nReal );
2507 :
2508 : SwCntntFrm *pCnt;
2509 18228 : if( IsFtnFrm() && !((SwFtnFrm*)this)->GetAttr()->GetFtn().IsEndNote() &&
2510 8 : ( GetFmt()->GetDoc()->GetFtnInfo().ePos != FTNPOS_CHAPTER ||
2511 9106 : ( IsInSct() && FindSctFrm()->IsFtnAtEnd() ) ) &&
2512 : 0 != (pCnt = ((SwFtnFrm*)this)->GetRefFromAttr() ) )
2513 : {
2514 8 : if ( pCnt->IsFollow() )
2515 : { // If we are in an other column/page than the frame with the
2516 : // reference, we don't need to invalidate its master.
2517 0 : SwFrm *pTmp = pCnt->FindFtnBossFrm(true) == FindFtnBossFrm(true)
2518 0 : ? &pCnt->FindMaster()->GetFrm() : pCnt;
2519 0 : pTmp->Prepare( PREP_ADJUST_FRM );
2520 0 : pTmp->InvalidateSize();
2521 : }
2522 : else
2523 8 : pCnt->InvalidatePos();
2524 : }
2525 : }
2526 26194 : return nReal;
2527 : }
2528 :
2529 : /**
2530 : * Changes the size of the directly subsidiary Frm's that have a fixed size, proportionally to the
2531 : * size change of the PrtArea of the Frm's.
2532 : *
2533 : * The variable Frms are also proportionally adapted; they will grow/shrink again by themselves.
2534 : */
2535 63398 : void SwLayoutFrm::ChgLowersProp( const Size& rOldSize )
2536 : {
2537 : // no change of lower properties for root frame or if no lower exists.
2538 63398 : if ( IsRootFrm() || !Lower() )
2539 20394 : return;
2540 :
2541 : // declare and init <SwFrm* pLowerFrm> with first lower
2542 43004 : SwFrm *pLowerFrm = Lower();
2543 :
2544 : // declare and init const booleans <bHeightChgd> and <bWidthChg>
2545 43004 : const bool bHeightChgd = rOldSize.Height() != Prt().Height();
2546 43004 : const bool bWidthChgd = rOldSize.Width() != Prt().Width();
2547 :
2548 : // declare and init variables <bVert>, <bRev> and <fnRect>
2549 43004 : SWRECTFN( this )
2550 :
2551 : // This shortcut basically tries to handle only lower frames that
2552 : // are affected by the size change. Otherwise much more lower frames
2553 : // are invalidated.
2554 102494 : if ( !( bVert ? bHeightChgd : bWidthChgd ) &&
2555 75446 : ! Lower()->IsColumnFrm() &&
2556 33078 : ( ( IsBodyFrm() && IsInDocBody() && ( !IsInSct() || !FindSctFrm()->IsColLocked() ) ) ||
2557 : // #i10826# Section frames without columns should not
2558 : // invalidate all lowers!
2559 14678 : IsSctFrm() ) )
2560 : {
2561 : // Determine page frame the body frame resp. the section frame belongs to.
2562 660 : SwPageFrm *pPage = FindPageFrm();
2563 : // Determine last lower by traveling through them using <GetNext()>.
2564 : // During travel check each section frame, if it will be sized to
2565 : // maximum. If Yes, invalidate size of section frame and set
2566 : // corresponding flags at the page.
2567 : do
2568 : {
2569 4480 : if( pLowerFrm->IsSctFrm() &&((SwSectionFrm*)pLowerFrm)->_ToMaximize() )
2570 : {
2571 4 : pLowerFrm->_InvalidateSize();
2572 4 : pLowerFrm->InvalidatePage( pPage );
2573 : }
2574 4480 : if( pLowerFrm->GetNext() )
2575 3820 : pLowerFrm = pLowerFrm->GetNext();
2576 : else
2577 660 : break;
2578 : } while( true );
2579 : // If found last lower is a section frame containing no section
2580 : // (section frame isn't valid and will be deleted in the future),
2581 : // travel backwards.
2582 1326 : while( pLowerFrm->IsSctFrm() && !((SwSectionFrm*)pLowerFrm)->GetSection() &&
2583 4 : pLowerFrm->GetPrev() )
2584 2 : pLowerFrm = pLowerFrm->GetPrev();
2585 : // If found last lower is a section frame, set <pLowerFrm> to its last
2586 : // content, if the section frame is valid and is not sized to maximum.
2587 : // Otherwise set <pLowerFrm> to NULL - In this case body frame only
2588 : // contains invalid section frames.
2589 660 : if( pLowerFrm->IsSctFrm() )
2590 78 : pLowerFrm = ((SwSectionFrm*)pLowerFrm)->GetSection() &&
2591 38 : !((SwSectionFrm*)pLowerFrm)->ToMaximize( false ) ?
2592 74 : ((SwSectionFrm*)pLowerFrm)->FindLastCntnt() : NULL;
2593 :
2594 : // continue with found last lower, probably the last content of a section
2595 660 : if ( pLowerFrm )
2596 : {
2597 : // If <pLowerFrm> is in a table frame, set <pLowerFrm> to this table
2598 : // frame and continue.
2599 654 : if ( pLowerFrm->IsInTab() )
2600 : {
2601 : // OD 28.10.2002 #97265# - safeguard for setting <pLowerFrm> to
2602 : // its table frame - check, if the table frame is also a lower
2603 : // of the body frame, in order to assure that <pLowerFrm> is not
2604 : // set to a frame, which is an *upper* of the body frame.
2605 82 : SwFrm* pTableFrm = pLowerFrm->FindTabFrm();
2606 82 : if ( IsAnLower( pTableFrm ) )
2607 : {
2608 82 : pLowerFrm = pTableFrm;
2609 : }
2610 : }
2611 : // Check, if variable size of body frame resp. section frame has grown
2612 : // OD 28.10.2002 #97265# - correct check, if variable size has grown.
2613 654 : SwTwips nOldHeight = bVert ? rOldSize.Width() : rOldSize.Height();
2614 654 : if( nOldHeight < (Prt().*fnRect->fnGetHeight)() )
2615 : {
2616 : // If variable size of body|section frame has grown, only found
2617 : // last lower and the position of the its next have to be invalidated.
2618 42 : pLowerFrm->_InvalidateAll();
2619 42 : pLowerFrm->InvalidatePage( pPage );
2620 84 : if( !pLowerFrm->IsFlowFrm() ||
2621 42 : !SwFlowFrm::CastFlowFrm( pLowerFrm )->HasFollow() )
2622 42 : pLowerFrm->InvalidateNextPos( true );
2623 42 : if ( pLowerFrm->IsTxtFrm() )
2624 40 : ((SwCntntFrm*)pLowerFrm)->Prepare( PREP_ADJUST_FRM );
2625 : }
2626 : else
2627 : {
2628 : // variable size of body|section frame has shrunk. Thus,
2629 : // invalidate all lowers not matching the new body|section size
2630 : // and the dedicated new last lower.
2631 612 : if( bVert )
2632 : {
2633 0 : SwTwips nBot = Frm().Left() + Prt().Left();
2634 0 : while ( pLowerFrm && pLowerFrm->GetPrev() && pLowerFrm->Frm().Left() < nBot )
2635 : {
2636 0 : pLowerFrm->_InvalidateAll();
2637 0 : pLowerFrm->InvalidatePage( pPage );
2638 0 : pLowerFrm = pLowerFrm->GetPrev();
2639 : }
2640 : }
2641 : else
2642 : {
2643 612 : SwTwips nBot = Frm().Top() + Prt().Bottom();
2644 1244 : while ( pLowerFrm && pLowerFrm->GetPrev() && pLowerFrm->Frm().Top() > nBot )
2645 : {
2646 20 : pLowerFrm->_InvalidateAll();
2647 20 : pLowerFrm->InvalidatePage( pPage );
2648 20 : pLowerFrm = pLowerFrm->GetPrev();
2649 : }
2650 : }
2651 612 : if ( pLowerFrm )
2652 : {
2653 612 : pLowerFrm->_InvalidateSize();
2654 612 : pLowerFrm->InvalidatePage( pPage );
2655 612 : if ( pLowerFrm->IsTxtFrm() )
2656 532 : ((SwCntntFrm*)pLowerFrm)->Prepare( PREP_ADJUST_FRM );
2657 : }
2658 : }
2659 : // #i41694# - improvement by removing duplicates
2660 654 : if ( pLowerFrm )
2661 : {
2662 654 : if ( pLowerFrm->IsInSct() )
2663 : {
2664 : // #i41694# - follow-up of issue #i10826#
2665 : // No invalidation of section frame, if it's the this.
2666 80 : SwFrm* pSectFrm = pLowerFrm->FindSctFrm();
2667 80 : if( pSectFrm != this && IsAnLower( pSectFrm ) )
2668 : {
2669 34 : pSectFrm->_InvalidateSize();
2670 34 : pSectFrm->InvalidatePage( pPage );
2671 : }
2672 : }
2673 : }
2674 : }
2675 4480 : return;
2676 : } // end of { special case }
2677 :
2678 : // Invalidate page for content only once.
2679 42344 : bool bInvaPageForCntnt = true;
2680 :
2681 : // Declare booleans <bFixChgd> and <bVarChgd>, indicating for text frame
2682 : // adjustment, if fixed/variable size has changed.
2683 : bool bFixChgd, bVarChgd;
2684 42344 : if( bVert == pLowerFrm->IsNeighbourFrm() )
2685 : {
2686 41146 : bFixChgd = bWidthChgd;
2687 41146 : bVarChgd = bHeightChgd;
2688 : }
2689 : else
2690 : {
2691 1198 : bFixChgd = bHeightChgd;
2692 1198 : bVarChgd = bWidthChgd;
2693 : }
2694 :
2695 : // Declare const unsigned short <nFixWidth> and init it this frame types
2696 : // which has fixed width in vertical respectively horizontal layout.
2697 : // In vertical layout these are neighbour frames (cell and column frames),
2698 : // header frames and footer frames.
2699 : // In horizontal layout these are all frames, which aren't neighbour frames.
2700 : const sal_uInt16 nFixWidth = bVert ? (FRM_NEIGHBOUR | FRM_HEADFOOT)
2701 42344 : : ~FRM_NEIGHBOUR;
2702 :
2703 : // Declare const unsigned short <nFixHeight> and init it this frame types
2704 : // which has fixed height in vertical respectively horizontal layout.
2705 : // In vertical layout these are all frames, which aren't neighbour frames,
2706 : // header frames, footer frames, body frames or foot note container frames.
2707 : // In horizontal layout these are neighbour frames.
2708 : const sal_uInt16 nFixHeight= bVert ? ~(FRM_NEIGHBOUR | FRM_HEADFOOT | FRM_BODYFTNC)
2709 42344 : : FRM_NEIGHBOUR;
2710 :
2711 : // Travel through all lowers using <GetNext()>
2712 152676 : while ( pLowerFrm )
2713 : {
2714 67988 : if ( pLowerFrm->IsTxtFrm() )
2715 : {
2716 : // Text frames will only be invalidated - prepare invalidation
2717 45472 : if ( bFixChgd )
2718 30920 : static_cast<SwCntntFrm*>(pLowerFrm)->Prepare( PREP_FIXSIZE_CHG );
2719 45472 : if ( bVarChgd )
2720 37156 : static_cast<SwCntntFrm*>(pLowerFrm)->Prepare( PREP_ADJUST_FRM );
2721 : }
2722 : else
2723 : {
2724 : // If lower isn't a table, row, cell or section frame, adjust its
2725 : // frame size.
2726 22516 : const sal_uInt16 nLowerType = pLowerFrm->GetType();
2727 22516 : if ( !(nLowerType & (FRM_TAB|FRM_ROW|FRM_CELL|FRM_SECTION)) )
2728 : {
2729 10696 : if ( bWidthChgd )
2730 : {
2731 3504 : if( nLowerType & nFixWidth )
2732 : {
2733 : // Considering previous conditions:
2734 : // In vertical layout set width of column, header and
2735 : // footer frames to its upper width.
2736 : // In horizontal layout set width of header, footer,
2737 : // foot note container, foot note, body and no-text
2738 : // frames to its upper width.
2739 3504 : pLowerFrm->Frm().Width( Prt().Width() );
2740 : }
2741 0 : else if( rOldSize.Width() && !pLowerFrm->IsFtnFrm() )
2742 : {
2743 : // Adjust frame width proportional, if lower isn't a
2744 : // foot note frame and condition <nLowerType & nFixWidth>
2745 : // isn't true.
2746 : // Considering previous conditions:
2747 : // In vertical layout these are foot note container,
2748 : // body and no-text frames.
2749 : // In horizontal layout these are column and no-text frames.
2750 : // OD 24.10.2002 #97265# - <double> calculation
2751 : // Perform <double> calculation of new width, if
2752 : // one of the coefficients is greater than 50000
2753 : SwTwips nNewWidth;
2754 0 : if ( (pLowerFrm->Frm().Width() > 50000) ||
2755 0 : (Prt().Width() > 50000) )
2756 : {
2757 : double nNewWidthTmp =
2758 0 : ( double(pLowerFrm->Frm().Width())
2759 0 : * double(Prt().Width()) )
2760 0 : / double(rOldSize.Width());
2761 0 : nNewWidth = SwTwips(nNewWidthTmp);
2762 : }
2763 : else
2764 : {
2765 : nNewWidth =
2766 0 : (pLowerFrm->Frm().Width() * Prt().Width()) / rOldSize.Width();
2767 : }
2768 0 : pLowerFrm->Frm().Width( nNewWidth );
2769 : }
2770 : }
2771 10696 : if ( bHeightChgd )
2772 : {
2773 9588 : if( nLowerType & nFixHeight )
2774 : {
2775 : // Considering previous conditions:
2776 : // In vertical layout set height of foot note and
2777 : // no-text frames to its upper height.
2778 : // In horizontal layout set height of column frames
2779 : // to its upper height.
2780 3614 : pLowerFrm->Frm().Height( Prt().Height() );
2781 : }
2782 : // OD 01.10.2002 #102211#
2783 : // add conditions <!pLowerFrm->IsHeaderFrm()> and
2784 : // <!pLowerFrm->IsFooterFrm()> in order to avoid that
2785 : // the <Grow> of header or footer are overwritten.
2786 : // NOTE: Height of header/footer frame is determined by contents.
2787 15642 : else if ( rOldSize.Height() &&
2788 7386 : !pLowerFrm->IsFtnFrm() &&
2789 13342 : !pLowerFrm->IsHeaderFrm() &&
2790 3676 : !pLowerFrm->IsFooterFrm()
2791 : )
2792 : {
2793 : // Adjust frame height proportional, if lower isn't a
2794 : // foot note, a header or a footer frame and
2795 : // condition <nLowerType & nFixHeight> isn't true.
2796 : // Considering previous conditions:
2797 : // In vertical layout these are column, foot note container,
2798 : // body and no-text frames.
2799 : // In horizontal layout these are column, foot note
2800 : // container, body and no-text frames.
2801 :
2802 : // OD 29.10.2002 #97265# - special case for page lowers
2803 : // The page lowers that have to be adjusted on page height
2804 : // change are the body frame and the foot note container
2805 : // frame.
2806 : // In vertical layout the height of both is directly
2807 : // adjusted to the page height change.
2808 : // In horizontal layout the height of the body frame is
2809 : // directly adjsuted to the page height change and the
2810 : // foot note frame height isn't touched, because its
2811 : // determined by its content.
2812 : // OD 31.03.2003 #108446# - apply special case for page
2813 : // lowers - see description above - also for section columns.
2814 10832 : if ( IsPageFrm() ||
2815 7080 : ( IsColumnFrm() && IsInSct() )
2816 : )
2817 : {
2818 : OSL_ENSURE( pLowerFrm->IsBodyFrm() || pLowerFrm->IsFtnContFrm(),
2819 : "ChgLowersProp - only for body or foot note container" );
2820 3632 : if ( pLowerFrm->IsBodyFrm() || pLowerFrm->IsFtnContFrm() )
2821 : {
2822 3632 : if ( IsVertical() || pLowerFrm->IsBodyFrm() )
2823 : {
2824 : SwTwips nNewHeight =
2825 3632 : pLowerFrm->Frm().Height() +
2826 3632 : ( Prt().Height() - rOldSize.Height() );
2827 3632 : if ( nNewHeight < 0)
2828 : {
2829 : // OD 01.04.2003 #108446# - adjust assertion condition and text
2830 : OSL_ENSURE( !( IsPageFrm() &&
2831 : (pLowerFrm->Frm().Height()>0) &&
2832 : (pLowerFrm->IsValid()) ),
2833 : "ChgLowersProg - negative height for lower.");
2834 0 : nNewHeight = 0;
2835 : }
2836 3632 : pLowerFrm->Frm().Height( nNewHeight );
2837 : }
2838 : }
2839 : }
2840 : else
2841 : {
2842 : SwTwips nNewHeight;
2843 : // OD 24.10.2002 #97265# - <double> calculation
2844 : // Perform <double> calculation of new height, if
2845 : // one of the coefficients is greater than 50000
2846 48 : if ( (pLowerFrm->Frm().Height() > 50000) ||
2847 24 : (Prt().Height() > 50000) )
2848 : {
2849 : double nNewHeightTmp =
2850 0 : ( double(pLowerFrm->Frm().Height())
2851 0 : * double(Prt().Height()) )
2852 0 : / double(rOldSize.Height());
2853 0 : nNewHeight = SwTwips(nNewHeightTmp);
2854 : }
2855 : else
2856 : {
2857 24 : nNewHeight = ( pLowerFrm->Frm().Height()
2858 24 : * Prt().Height() ) / rOldSize.Height();
2859 : }
2860 24 : if( !pLowerFrm->GetNext() )
2861 : {
2862 24 : SwTwips nSum = Prt().Height();
2863 24 : SwFrm* pTmp = Lower();
2864 48 : while( pTmp->GetNext() )
2865 : {
2866 0 : if( !pTmp->IsFtnContFrm() || !pTmp->IsVertical() )
2867 0 : nSum -= pTmp->Frm().Height();
2868 0 : pTmp = pTmp->GetNext();
2869 : }
2870 24 : if( nSum - nNewHeight == 1 &&
2871 0 : nSum == pLowerFrm->Frm().Height() )
2872 0 : nNewHeight = nSum;
2873 : }
2874 24 : pLowerFrm->Frm().Height( nNewHeight );
2875 : }
2876 : }
2877 : }
2878 : }
2879 : } // end of else { NOT text frame }
2880 :
2881 67988 : pLowerFrm->_InvalidateAll();
2882 67988 : if ( bInvaPageForCntnt && pLowerFrm->IsCntntFrm() )
2883 : {
2884 33844 : pLowerFrm->InvalidatePage();
2885 33844 : bInvaPageForCntnt = false;
2886 : }
2887 :
2888 67988 : if ( !pLowerFrm->GetNext() && pLowerFrm->IsRetoucheFrm() )
2889 : {
2890 : //If a growth took place and the subordinate elements can retouch
2891 : //itself (currently Tabs, Sections and Cntnt) we trigger it.
2892 44290 : if ( rOldSize.Height() < Prt().SSize().Height() ||
2893 9816 : rOldSize.Width() < Prt().SSize().Width() )
2894 30734 : pLowerFrm->SetRetouche();
2895 : }
2896 67988 : pLowerFrm = pLowerFrm->GetNext();
2897 : }
2898 :
2899 : // Finally adjust the columns if width is set to auto
2900 : // Possible optimization: execute this code earlier in this function and
2901 : // return???
2902 68862 : if ( ( (bVert && bHeightChgd) || (! bVert && bWidthChgd) ) &&
2903 26518 : Lower()->IsColumnFrm() )
2904 : {
2905 : // get column attribute
2906 0 : const SwFmtCol* pColAttr = NULL;
2907 0 : if ( IsPageBodyFrm() )
2908 : {
2909 : OSL_ENSURE( GetUpper()->IsPageFrm(), "Upper is not page frame" );
2910 0 : pColAttr = &GetUpper()->GetFmt()->GetCol();
2911 : }
2912 : else
2913 : {
2914 : OSL_ENSURE( IsFlyFrm() || IsSctFrm(), "Columns not in fly or section" );
2915 0 : pColAttr = &GetFmt()->GetCol();
2916 : }
2917 :
2918 0 : if ( pColAttr->IsOrtho() && pColAttr->GetNumCols() > 1 )
2919 0 : AdjustColumns( pColAttr, false );
2920 : }
2921 : }
2922 :
2923 : /** "Formats" the Frame; Frm and PrtArea.
2924 : *
2925 : * The Fixsize is not set here.
2926 : */
2927 18792 : void SwLayoutFrm::Format( const SwBorderAttrs *pAttrs )
2928 : {
2929 : OSL_ENSURE( pAttrs, "LayoutFrm::Format, pAttrs ist 0." );
2930 :
2931 18792 : if ( mbValidPrtArea && mbValidSize )
2932 18792 : return;
2933 :
2934 18792 : const sal_uInt16 nLeft = (sal_uInt16)pAttrs->CalcLeft( this );
2935 18792 : const sal_uInt16 nUpper = pAttrs->CalcTop();
2936 :
2937 18792 : const sal_uInt16 nRight = (sal_uInt16)((SwBorderAttrs*)pAttrs)->CalcRight( this );
2938 18792 : const sal_uInt16 nLower = pAttrs->CalcBottom();
2939 18792 : bool bVert = IsVertical() && !IsPageFrm();
2940 18792 : SwRectFn fnRect = bVert ? ( IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
2941 18792 : if ( !mbValidPrtArea )
2942 : {
2943 13440 : mbValidPrtArea = true;
2944 13440 : (this->*fnRect->fnSetXMargins)( nLeft, nRight );
2945 13440 : (this->*fnRect->fnSetYMargins)( nUpper, nLower );
2946 : }
2947 :
2948 18792 : if ( !mbValidSize )
2949 : {
2950 18640 : if ( !HasFixSize() )
2951 : {
2952 616 : const SwTwips nBorder = nUpper + nLower;
2953 616 : const SwFmtFrmSize &rSz = GetFmt()->GetFrmSize();
2954 616 : SwTwips nMinHeight = rSz.GetHeightSizeType() == ATT_MIN_SIZE ? rSz.GetHeight() : 0;
2955 766 : do
2956 766 : { mbValidSize = true;
2957 :
2958 : //The size in VarSize is calculated using the content plus the
2959 : // borders.
2960 766 : SwTwips nRemaining = 0;
2961 766 : SwFrm *pFrm = Lower();
2962 2574 : while ( pFrm )
2963 1042 : { nRemaining += (pFrm->Frm().*fnRect->fnGetHeight)();
2964 1042 : if( pFrm->IsTxtFrm() && ((SwTxtFrm*)pFrm)->IsUndersized() )
2965 : // This TxtFrm would like to be a bit bigger
2966 0 : nRemaining += ((SwTxtFrm*)pFrm)->GetParHeight()
2967 0 : - (pFrm->Prt().*fnRect->fnGetHeight)();
2968 1042 : else if( pFrm->IsSctFrm() && ((SwSectionFrm*)pFrm)->IsUndersized() )
2969 0 : nRemaining += ((SwSectionFrm*)pFrm)->Undersize();
2970 1042 : pFrm = pFrm->GetNext();
2971 : }
2972 766 : nRemaining += nBorder;
2973 766 : nRemaining = std::max( nRemaining, nMinHeight );
2974 766 : const SwTwips nDiff = nRemaining-(Frm().*fnRect->fnGetHeight)();
2975 766 : const long nOldLeft = (Frm().*fnRect->fnGetLeft)();
2976 766 : const long nOldTop = (Frm().*fnRect->fnGetTop)();
2977 766 : if ( nDiff )
2978 : {
2979 150 : if ( nDiff > 0 )
2980 150 : Grow( nDiff );
2981 : else
2982 0 : Shrink( -nDiff );
2983 : //Updates the positions using the fast channel.
2984 150 : MakePos();
2985 : }
2986 : //Don't exceed the bottom edge of the Upper.
2987 766 : if ( GetUpper() && (Frm().*fnRect->fnGetHeight)() )
2988 : {
2989 616 : const SwTwips nLimit = (GetUpper()->*fnRect->fnGetPrtBottom)();
2990 1232 : if( (this->*fnRect->fnSetLimit)( nLimit ) &&
2991 616 : nOldLeft == (Frm().*fnRect->fnGetLeft)() &&
2992 0 : nOldTop == (Frm().*fnRect->fnGetTop)() )
2993 0 : mbValidSize = mbValidPrtArea = true;
2994 : }
2995 766 : } while ( !mbValidSize );
2996 : }
2997 18024 : else if ( GetType() & 0x0018 )
2998 : {
2999 2 : do
3000 2 : { if ( Frm().Height() != pAttrs->GetSize().Height() )
3001 2 : ChgSize( Size( Frm().Width(), pAttrs->GetSize().Height()));
3002 2 : mbValidSize = true;
3003 2 : MakePos();
3004 2 : } while ( !mbValidSize );
3005 : }
3006 : else
3007 18022 : mbValidSize = true;
3008 : }
3009 : }
3010 :
3011 5348 : static void InvaPercentFlys( SwFrm *pFrm, SwTwips nDiff )
3012 : {
3013 : OSL_ENSURE( pFrm->GetDrawObjs(), "Can't find any Objects" );
3014 11810 : for ( size_t i = 0; i < pFrm->GetDrawObjs()->size(); ++i )
3015 : {
3016 6462 : SwAnchoredObject* pAnchoredObj = (*pFrm->GetDrawObjs())[i];
3017 6462 : if ( pAnchoredObj->ISA(SwFlyFrm) )
3018 : {
3019 2756 : SwFlyFrm *pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
3020 2756 : const SwFmtFrmSize &rSz = pFly->GetFmt()->GetFrmSize();
3021 2756 : if ( rSz.GetWidthPercent() || rSz.GetHeightPercent() )
3022 : {
3023 2 : bool bNotify = true;
3024 : // If we've a fly with more than 90% relative height...
3025 8 : if( rSz.GetHeightPercent() > 90 && pFly->GetAnchorFrm() &&
3026 4 : rSz.GetHeightPercent() != 0xFF && nDiff )
3027 : {
3028 0 : const SwFrm *pRel = pFly->IsFlyLayFrm() ? pFly->GetAnchorFrm():
3029 0 : pFly->GetAnchorFrm()->GetUpper();
3030 : // ... and we have already more than 90% height and we
3031 : // not allow the text to go through...
3032 : // then a notifycation could cause an endless loop, e.g.
3033 : // 100% height and no text wrap inside a cell of a table.
3034 0 : if( pFly->Frm().Height()*10 >
3035 0 : ( nDiff + pRel->Prt().Height() )*9 &&
3036 0 : pFly->GetFmt()->GetSurround().GetSurround() !=
3037 : SURROUND_THROUGHT )
3038 0 : bNotify = false;
3039 : }
3040 2 : if( bNotify )
3041 2 : pFly->InvalidateSize();
3042 : }
3043 : }
3044 : }
3045 5348 : }
3046 :
3047 82972 : void SwLayoutFrm::InvaPercentLowers( SwTwips nDiff )
3048 : {
3049 82972 : if ( GetDrawObjs() )
3050 26 : ::InvaPercentFlys( this, nDiff );
3051 :
3052 82972 : SwFrm *pFrm = ContainsCntnt();
3053 82972 : if ( pFrm )
3054 215938 : do
3055 : {
3056 215938 : if ( pFrm->IsInTab() && !IsTabFrm() )
3057 : {
3058 149460 : SwFrm *pTmp = pFrm->FindTabFrm();
3059 : OSL_ENSURE( pTmp, "Where's my TabFrm?" );
3060 149460 : if( IsAnLower( pTmp ) )
3061 7382 : pFrm = pTmp;
3062 : }
3063 :
3064 215938 : if ( pFrm->IsTabFrm() )
3065 : {
3066 7382 : const SwFmtFrmSize &rSz = ((SwLayoutFrm*)pFrm)->GetFmt()->GetFrmSize();
3067 7382 : if ( rSz.GetWidthPercent() || rSz.GetHeightPercent() )
3068 3782 : pFrm->InvalidatePrt();
3069 : }
3070 208556 : else if ( pFrm->GetDrawObjs() )
3071 5322 : ::InvaPercentFlys( pFrm, nDiff );
3072 215938 : pFrm = pFrm->FindNextCnt();
3073 215938 : } while ( pFrm && IsAnLower( pFrm ) ) ;
3074 82972 : }
3075 :
3076 8488 : long SwLayoutFrm::CalcRel( const SwFmtFrmSize &rSz, bool ) const
3077 : {
3078 8488 : long nRet = rSz.GetWidth(),
3079 8488 : nPercent = rSz.GetWidthPercent();
3080 :
3081 8488 : if ( nPercent )
3082 : {
3083 1434 : const SwFrm *pRel = GetUpper();
3084 1434 : long nRel = LONG_MAX;
3085 1434 : const SwViewShell *pSh = getRootFrm()->GetCurrShell();
3086 1434 : const bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
3087 1434 : if( pRel->IsPageBodyFrm() && pSh && bBrowseMode && pSh->VisArea().Width() )
3088 : {
3089 0 : nRel = pSh->GetBrowseWidth();
3090 0 : long nDiff = nRel - pRel->Prt().Width();
3091 0 : if ( nDiff > 0 )
3092 0 : nRel -= nDiff;
3093 : }
3094 1434 : nRel = std::min( nRel, pRel->Prt().Width() );
3095 1434 : nRet = nRel * nPercent / 100;
3096 : }
3097 8488 : return nRet;
3098 : }
3099 :
3100 : // Local helpers for SwLayoutFrm::FormatWidthCols()
3101 :
3102 1258 : static long lcl_CalcMinColDiff( SwLayoutFrm *pLayFrm )
3103 : {
3104 1258 : long nDiff = 0, nFirstDiff = 0;
3105 1258 : SwLayoutFrm *pCol = (SwLayoutFrm*)pLayFrm->Lower();
3106 : OSL_ENSURE( pCol, "Where's the columnframe?" );
3107 1258 : SwFrm *pFrm = pCol->Lower();
3108 3772 : do
3109 : {
3110 3772 : if( pFrm && pFrm->IsBodyFrm() )
3111 3772 : pFrm = ((SwBodyFrm*)pFrm)->Lower();
3112 3772 : if ( pFrm && pFrm->IsTxtFrm() )
3113 : {
3114 2678 : const long nTmp = ((SwTxtFrm*)pFrm)->FirstLineHeight();
3115 2678 : if ( nTmp != USHRT_MAX )
3116 : {
3117 2676 : if ( pCol == pLayFrm->Lower() )
3118 1176 : nFirstDiff = nTmp;
3119 : else
3120 1500 : nDiff = nDiff ? std::min( nDiff, nTmp ) : nTmp;
3121 : }
3122 : }
3123 : //Skip empty columns!
3124 3772 : pCol = (SwLayoutFrm*)pCol->GetNext();
3125 7544 : while ( pCol && 0 == (pFrm = pCol->Lower()) )
3126 0 : pCol = (SwLayoutFrm*)pCol->GetNext();
3127 :
3128 3108 : } while ( pFrm && pCol );
3129 :
3130 1258 : return nDiff ? nDiff : nFirstDiff ? nFirstDiff : 240;
3131 : }
3132 :
3133 1184 : static bool lcl_IsFlyHeightClipped( SwLayoutFrm *pLay )
3134 : {
3135 1184 : SwFrm *pFrm = pLay->ContainsCntnt();
3136 16972 : while ( pFrm )
3137 : {
3138 14604 : if ( pFrm->IsInTab() )
3139 100 : pFrm = pFrm->FindTabFrm();
3140 :
3141 14604 : if ( pFrm->GetDrawObjs() )
3142 : {
3143 94 : const size_t nCnt = pFrm->GetDrawObjs()->size();
3144 188 : for ( size_t i = 0; i < nCnt; ++i )
3145 : {
3146 94 : SwAnchoredObject* pAnchoredObj = (*pFrm->GetDrawObjs())[i];
3147 94 : if ( pAnchoredObj->ISA(SwFlyFrm) )
3148 : {
3149 90 : SwFlyFrm* pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
3150 90 : if ( pFly->IsHeightClipped() &&
3151 0 : ( !pFly->IsFlyFreeFrm() || pFly->GetPageFrm() ) )
3152 0 : return true;
3153 : }
3154 : }
3155 : }
3156 14604 : pFrm = pFrm->FindNextCnt();
3157 : }
3158 1184 : return false;
3159 : }
3160 :
3161 154 : void SwLayoutFrm::FormatWidthCols( const SwBorderAttrs &rAttrs,
3162 : const SwTwips nBorder, const SwTwips nMinHeight )
3163 : {
3164 : //If there are columns involved, the size is adjusted using the last column.
3165 : //1. Format content.
3166 : //2. Calculate height of the last column: if it's too big, the Fly has to
3167 : // grow. The amount by which the Fly grows is not the amount of the
3168 : // overhang because we have to act on the assumption that some text flows
3169 : // back which will generate some more space.
3170 : // The amount which we grow by equals the overhang
3171 : // divided by the amount of columns or the overhang itself if it's smaller
3172 : // than the amount of columns.
3173 : //3. Go back to 1. until everything is stable.
3174 :
3175 154 : const SwFmtCol &rCol = rAttrs.GetAttrSet().GetCol();
3176 154 : const sal_uInt16 nNumCols = rCol.GetNumCols();
3177 :
3178 154 : bool bEnd = false;
3179 154 : bool bBackLock = false;
3180 154 : SwViewShell *pSh = getRootFrm()->GetCurrShell();
3181 154 : SwViewImp *pImp = pSh ? pSh->Imp() : 0;
3182 : {
3183 : // Underlying algorithm
3184 : // We try to find the optimal height for the column.
3185 : // nMinimum starts with the passed minimum height and is then remembered
3186 : // as the maximum height on which column content still juts out of a
3187 : // column.
3188 : // nMaximum starts with LONG_MAX and is then remembered as the minimum
3189 : // width on which the content fitted.
3190 : // In column based sections nMaximum starts at the maximum value which
3191 : // the surrounding defines, this can certainly be a value on which
3192 : // content still juts out.
3193 : // The columns are formatted. If content still juts out, nMinimum is
3194 : // adjusted accordingly, then we grow, at least by uMinDiff but not
3195 : // over a certain nMaximum. If no content juts out but there is still
3196 : // some space left in the column, shrinking is done accordingly, at
3197 : // least by nMindIff but not below the nMinimum.
3198 : // Cancel as soon as no content juts out and the difference from minimum
3199 : // to maximum is less than MinDiff or the maximum which was defined by
3200 : // the surrounding is reached even if some content still juts out.
3201 :
3202 : // Criticism of this implementation
3203 : // 1. Theoretically situations are possible in which the content fits in
3204 : // a lower height but not in a higher height. To ensure that the code
3205 : // handles such situations the code contains a few checks concerning
3206 : // minimum and maximum which probably are never triggered.
3207 : // 2. We use the same nMinDiff for shrinking and growing, but nMinDiff
3208 : // is more or less the smallest first line height and doesn't seem ideal
3209 : // as minimum value.
3210 :
3211 154 : long nMinimum = nMinHeight;
3212 : long nMaximum;
3213 154 : bool bNoBalance = false;
3214 154 : SWRECTFN( this )
3215 154 : if( IsSctFrm() )
3216 : {
3217 154 : nMaximum = (Frm().*fnRect->fnGetHeight)() - nBorder +
3218 154 : (Frm().*fnRect->fnBottomDist)(
3219 154 : (GetUpper()->*fnRect->fnGetPrtBottom)() );
3220 154 : nMaximum += GetUpper()->Grow( LONG_MAX, true );
3221 154 : if( nMaximum < nMinimum )
3222 : {
3223 0 : if( nMaximum < 0 )
3224 0 : nMinimum = nMaximum = 0;
3225 : else
3226 0 : nMinimum = nMaximum;
3227 : }
3228 154 : if( nMaximum > BROWSE_HEIGHT )
3229 0 : nMaximum = BROWSE_HEIGHT;
3230 :
3231 154 : bNoBalance = ((SwSectionFrm*)this)->GetSection()->GetFmt()->
3232 154 : GetBalancedColumns().GetValue();
3233 154 : SwFrm* pAny = ContainsAny();
3234 324 : if( bNoBalance ||
3235 88 : ( !(Frm().*fnRect->fnGetHeight)() && pAny ) )
3236 : {
3237 98 : long nTop = (this->*fnRect->fnGetTopMargin)();
3238 : // #i23129# - correction
3239 : // to the calculated maximum height.
3240 98 : (Frm().*fnRect->fnAddBottom)( nMaximum -
3241 98 : (Frm().*fnRect->fnGetHeight)() );
3242 98 : if( nTop > nMaximum )
3243 0 : nTop = nMaximum;
3244 98 : (this->*fnRect->fnSetYMargins)( nTop, 0 );
3245 : }
3246 154 : if( !pAny && !((SwSectionFrm*)this)->IsFtnLock() )
3247 : {
3248 10 : SwFtnContFrm* pFtnCont = ((SwSectionFrm*)this)->ContainsFtnCont();
3249 10 : if( pFtnCont )
3250 : {
3251 0 : SwFrm* pFtnAny = pFtnCont->ContainsAny();
3252 0 : if( pFtnAny && pFtnAny->IsValid() )
3253 : {
3254 0 : bBackLock = true;
3255 0 : ((SwSectionFrm*)this)->SetFtnLock( true );
3256 : }
3257 : }
3258 : }
3259 : }
3260 : else
3261 0 : nMaximum = LONG_MAX;
3262 :
3263 : // #i3317# - reset temporarly consideration
3264 : // of wrapping style influence
3265 154 : SwPageFrm* pPageFrm = FindPageFrm();
3266 154 : SwSortedObjs* pObjs = pPageFrm ? pPageFrm->GetSortedObjs() : 0L;
3267 154 : if ( pObjs )
3268 : {
3269 214 : for ( size_t i = 0; i < pObjs->size(); ++i )
3270 : {
3271 174 : SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
3272 :
3273 174 : if ( IsAnLower( pAnchoredObj->GetAnchorFrm() ) )
3274 : {
3275 10 : pAnchoredObj->SetTmpConsiderWrapInfluence( false );
3276 : }
3277 : }
3278 : }
3279 1292 : do
3280 : {
3281 : //Could take a while therefore check for Waitcrsr here.
3282 1292 : if ( pImp )
3283 1292 : pImp->CheckWaitCrsr();
3284 :
3285 1292 : mbValidSize = true;
3286 : //First format the column as this will relieve the stack a bit.
3287 : //Also set width and height of the column (if they are wrong)
3288 : //while we are at it.
3289 1292 : SwLayoutFrm *pCol = (SwLayoutFrm*)Lower();
3290 :
3291 : // #i27399#
3292 : // Simply setting the column width based on the values returned by
3293 : // CalcColWidth does not work for automatic column width.
3294 1292 : AdjustColumns( &rCol, false );
3295 :
3296 5144 : for ( sal_uInt16 i = 0; i < nNumCols; ++i )
3297 : {
3298 3852 : pCol->Calc();
3299 : // ColumnFrms have a BodyFrm now, which needs to be calculated
3300 3852 : pCol->Lower()->Calc();
3301 3852 : if( pCol->Lower()->GetNext() )
3302 0 : pCol->Lower()->GetNext()->Calc(); // SwFtnCont
3303 3852 : pCol = (SwLayoutFrm*)pCol->GetNext();
3304 : }
3305 :
3306 1292 : ::CalcCntnt( this );
3307 :
3308 1292 : pCol = (SwLayoutFrm*)Lower();
3309 : OSL_ENSURE( pCol && pCol->GetNext(), ":-( column making holidays?");
3310 : // set bMinDiff if no empty columns exist
3311 1292 : bool bMinDiff = true;
3312 : // OD 28.03.2003 #108446# - check for all column content and all columns
3313 5960 : while ( bMinDiff && pCol )
3314 : {
3315 3376 : bMinDiff = 0 != pCol->ContainsCntnt();
3316 3376 : pCol = (SwLayoutFrm*)pCol->GetNext();
3317 : }
3318 1292 : pCol = (SwLayoutFrm*)Lower();
3319 : // OD 28.03.2003 #108446# - initialize local variable
3320 1292 : SwFrm *pLow = NULL;
3321 1292 : SwTwips nDiff = 0;
3322 1292 : SwTwips nMaxFree = 0;
3323 1292 : SwTwips nAllFree = LONG_MAX;
3324 : // set bFoundLower if there is at least one non-empty column
3325 1292 : bool bFoundLower = false;
3326 6436 : while( pCol )
3327 : {
3328 3852 : SwLayoutFrm* pLay = (SwLayoutFrm*)pCol->Lower();
3329 3852 : SwTwips nInnerHeight = (pLay->Frm().*fnRect->fnGetHeight)() -
3330 3852 : (pLay->Prt().*fnRect->fnGetHeight)();
3331 3852 : if( pLay->Lower() )
3332 : {
3333 2678 : bFoundLower = true;
3334 2678 : nInnerHeight += pLay->InnerHeight();
3335 : }
3336 1174 : else if( nInnerHeight < 0 )
3337 0 : nInnerHeight = 0;
3338 :
3339 3852 : if( pLay->GetNext() )
3340 : {
3341 4 : bFoundLower = true;
3342 4 : pLay = (SwLayoutFrm*)pLay->GetNext();
3343 : OSL_ENSURE( pLay->IsFtnContFrm(),"FtnContainer expected" );
3344 4 : nInnerHeight += pLay->InnerHeight();
3345 4 : nInnerHeight += (pLay->Frm().*fnRect->fnGetHeight)() -
3346 4 : (pLay->Prt().*fnRect->fnGetHeight)();
3347 : }
3348 3852 : nInnerHeight -= (pCol->Prt().*fnRect->fnGetHeight)();
3349 3852 : if( nInnerHeight > nDiff )
3350 : {
3351 74 : nDiff = nInnerHeight;
3352 74 : nAllFree = 0;
3353 : }
3354 : else
3355 : {
3356 3778 : if( nMaxFree < -nInnerHeight )
3357 2056 : nMaxFree = -nInnerHeight;
3358 3778 : if( nAllFree > -nInnerHeight )
3359 1462 : nAllFree = -nInnerHeight;
3360 : }
3361 3852 : pCol = (SwLayoutFrm*)pCol->GetNext();
3362 : }
3363 :
3364 1292 : if ( bFoundLower || ( IsSctFrm() && ((SwSectionFrm*)this)->HasFollow() ) )
3365 : {
3366 1258 : SwTwips nMinDiff = ::lcl_CalcMinColDiff( this );
3367 : // Here we decide if growing is needed - this is the case, if
3368 : // column content (nDiff) or a Fly juts over.
3369 : // In sections with columns we take into account to set the size
3370 : // when having a non-empty Follow.
3371 2802 : if ( nDiff || ::lcl_IsFlyHeightClipped( this ) ||
3372 2368 : ( IsSctFrm() && ((SwSectionFrm*)this)->CalcMinDiff( nMinDiff ) ) )
3373 : {
3374 360 : long nPrtHeight = (Prt().*fnRect->fnGetHeight)();
3375 : // The minimum must not be smaller than our PrtHeight as
3376 : // long as something juts over.
3377 360 : if( nMinimum < nPrtHeight )
3378 360 : nMinimum = nPrtHeight;
3379 : // The maximum must not be smaller than PrtHeight if
3380 : // something still juts over.
3381 360 : if( nMaximum < nPrtHeight )
3382 0 : nMaximum = nPrtHeight; // Robust, but will this ever happen?
3383 360 : if( !nDiff ) // If only Flys jut over, we grow by nMinDiff
3384 286 : nDiff = nMinDiff;
3385 : // If we should grow more than by nMinDiff we split it over
3386 : // the columns
3387 360 : if ( std::abs(nDiff - nMinDiff) > nNumCols && nDiff > (long)nNumCols )
3388 64 : nDiff /= nNumCols;
3389 :
3390 360 : if ( bMinDiff )
3391 : { // If no empty column exists, we want to grow at least
3392 : // by nMinDiff. Special case: If we are smaller than the
3393 : // minimal FrmHeight and PrtHeight is smaller than
3394 : // nMindiff we grow in a way that PrtHeight is exactly
3395 : // nMinDiff afterwards.
3396 200 : long nFrmHeight = (Frm().*fnRect->fnGetHeight)();
3397 200 : if ( nFrmHeight > nMinHeight || nPrtHeight >= nMinDiff )
3398 200 : nDiff = std::max( nDiff, nMinDiff );
3399 0 : else if( nDiff < nMinDiff )
3400 0 : nDiff = nMinDiff - nPrtHeight + 1;
3401 : }
3402 : // nMaximum has a size which fits the content or the
3403 : // requested value from the surrounding therefore we don't
3404 : // need to exceed this value.
3405 360 : if( nDiff + nPrtHeight > nMaximum )
3406 276 : nDiff = nMaximum - nPrtHeight;
3407 : }
3408 898 : else if( nMaximum > nMinimum ) // We fit, do we still have some margin?
3409 : {
3410 898 : long nPrtHeight = (Prt().*fnRect->fnGetHeight)();
3411 898 : if ( nMaximum < nPrtHeight )
3412 0 : nDiff = nMaximum - nPrtHeight; // We grew over a working
3413 : // height and shrink back to it, but will this ever
3414 : // happen?
3415 : else
3416 : { // We have a new maximum, a size which fits for the content.
3417 898 : nMaximum = nPrtHeight;
3418 : // If the margin in the column is bigger than nMinDiff
3419 : // and we therefore drop under the minimum, we deflate
3420 : // a bit.
3421 898 : if ( !bNoBalance &&
3422 : // #i23129# - <nMinDiff> can be
3423 : // big, because of an object at the beginning of
3424 : // a column. Thus, decrease optimization here.
3425 : //nMaxFree >= nMinDiff &&
3426 752 : nMaxFree > 0 &&
3427 488 : ( !nAllFree ||
3428 488 : nMinimum < nPrtHeight - nMinDiff ) )
3429 : {
3430 702 : nMaxFree /= nNumCols; // disperse over the columns
3431 702 : nDiff = nMaxFree < nMinDiff ? -nMinDiff : -nMaxFree; // min nMinDiff
3432 1404 : if( nPrtHeight + nDiff <= nMinimum ) // below the minimum?
3433 274 : nDiff = ( nMinimum - nMaximum ) / 2; // Take the center
3434 : }
3435 196 : else if( nAllFree )
3436 : {
3437 112 : nDiff = -nAllFree;
3438 112 : if( nPrtHeight + nDiff <= nMinimum ) // Less than minimum?
3439 0 : nDiff = ( nMinimum - nMaximum ) / 2; // Take the center
3440 : }
3441 : }
3442 : }
3443 1258 : if( nDiff ) // now we shrink or grow...
3444 : {
3445 1126 : Size aOldSz( Prt().SSize() );
3446 1126 : long nTop = (this->*fnRect->fnGetTopMargin)();
3447 2252 : nDiff = (Prt().*fnRect->fnGetHeight)() + nDiff + nBorder -
3448 2252 : (Frm().*fnRect->fnGetHeight)();
3449 1126 : (Frm().*fnRect->fnAddBottom)( nDiff );
3450 : // #i68520#
3451 1126 : SwFlyFrm *pFlyFrm = dynamic_cast<SwFlyFrm*>(this);
3452 1126 : if (pFlyFrm)
3453 : {
3454 0 : pFlyFrm->InvalidateObjRectWithSpaces();
3455 : }
3456 1126 : (this->*fnRect->fnSetYMargins)( nTop, nBorder - nTop );
3457 1126 : ChgLowersProp( aOldSz );
3458 1126 : NotifyLowerObjs();
3459 :
3460 : // #i3317# - reset temporarly consideration
3461 : // of wrapping style influence
3462 1126 : SwPageFrm* pTmpPageFrm = FindPageFrm();
3463 1126 : SwSortedObjs* pTmpObjs = pTmpPageFrm ? pTmpPageFrm->GetSortedObjs() : 0L;
3464 1126 : if ( pTmpObjs )
3465 : {
3466 2266 : for ( size_t i = 0; i < pTmpObjs->size(); ++i )
3467 : {
3468 1944 : SwAnchoredObject* pAnchoredObj = (*pTmpObjs)[i];
3469 :
3470 1944 : if ( IsAnLower( pAnchoredObj->GetAnchorFrm() ) )
3471 : {
3472 36 : pAnchoredObj->SetTmpConsiderWrapInfluence( false );
3473 : }
3474 : }
3475 : }
3476 : //Invalidate suitable to nicely balance the Frms.
3477 : //- Every first one after the second column gets a
3478 : // InvalidatePos();
3479 1126 : pCol = (SwLayoutFrm*)Lower()->GetNext();
3480 4582 : while ( pCol )
3481 : {
3482 2330 : pLow = pCol->Lower();
3483 2330 : if ( pLow )
3484 2330 : pLow->_InvalidatePos();
3485 2330 : pCol = (SwLayoutFrm*)pCol->GetNext();
3486 : }
3487 1126 : if( IsSctFrm() && ((SwSectionFrm*)this)->HasFollow() )
3488 : {
3489 : // If we created a Follow, we need to give its content
3490 : // the opportunity to flow back inside the CalcCntnt
3491 : SwCntntFrm* pTmpCntnt =
3492 350 : ((SwSectionFrm*)this)->GetFollow()->ContainsCntnt();
3493 350 : if( pTmpCntnt )
3494 350 : pTmpCntnt->_InvalidatePos();
3495 : }
3496 : }
3497 : else
3498 132 : bEnd = true;
3499 : }
3500 : else
3501 34 : bEnd = true;
3502 :
3503 1458 : } while ( !bEnd || !mbValidSize );
3504 : }
3505 : // OD 01.04.2003 #108446# - Don't collect endnotes for sections. Thus, set
3506 : // 2nd parameter to <true>.
3507 154 : ::CalcCntnt( this, true );
3508 154 : if( IsSctFrm() )
3509 : {
3510 : // OD 14.03.2003 #i11760# - adjust 2nd parameter - sal_True --> true
3511 154 : ::CalcCntnt( this, true );
3512 154 : if( bBackLock )
3513 0 : ((SwSectionFrm*)this)->SetFtnLock( false );
3514 : }
3515 154 : }
3516 :
3517 0 : static SwCntntFrm* lcl_InvalidateSection( SwFrm *pCnt, sal_uInt8 nInv )
3518 : {
3519 0 : SwSectionFrm* pSect = pCnt->FindSctFrm();
3520 : // If our CntntFrm is placed inside a table or a footnote, only sections
3521 : // which are also placed inside are meant.
3522 : // Exception: If a table is directly passed.
3523 0 : if( ( ( pCnt->IsInTab() && !pSect->IsInTab() ) ||
3524 0 : ( pCnt->IsInFtn() && !pSect->IsInFtn() ) ) && !pCnt->IsTabFrm() )
3525 0 : return NULL;
3526 0 : if( nInv & INV_SIZE )
3527 0 : pSect->_InvalidateSize();
3528 0 : if( nInv & INV_POS )
3529 0 : pSect->_InvalidatePos();
3530 0 : if( nInv & INV_PRTAREA )
3531 0 : pSect->_InvalidatePrt();
3532 0 : SwFlowFrm *pFoll = pSect->GetFollow();
3533 : // Temporary separation from follow
3534 0 : pSect->SetFollow( NULL );
3535 0 : SwCntntFrm* pRet = pSect->FindLastCntnt();
3536 0 : pSect->SetFollow( pFoll );
3537 0 : return pRet;
3538 : }
3539 :
3540 0 : static SwCntntFrm* lcl_InvalidateTable( SwTabFrm *pTable, sal_uInt8 nInv )
3541 : {
3542 0 : if( ( nInv & INV_SECTION ) && pTable->IsInSct() )
3543 0 : lcl_InvalidateSection( pTable, nInv );
3544 0 : if( nInv & INV_SIZE )
3545 0 : pTable->_InvalidateSize();
3546 0 : if( nInv & INV_POS )
3547 0 : pTable->_InvalidatePos();
3548 0 : if( nInv & INV_PRTAREA )
3549 0 : pTable->_InvalidatePrt();
3550 0 : return pTable->FindLastCntnt();
3551 : }
3552 :
3553 : static void lcl_InvalidateAllCntnt( SwCntntFrm *pCnt, sal_uInt8 nInv );
3554 :
3555 83 : static void lcl_InvalidateCntnt( SwCntntFrm *pCnt, sal_uInt8 nInv )
3556 : {
3557 83 : SwCntntFrm *pLastTabCnt = NULL;
3558 83 : SwCntntFrm *pLastSctCnt = NULL;
3559 318 : while ( pCnt )
3560 : {
3561 152 : if( nInv & INV_SECTION )
3562 : {
3563 0 : if( pCnt->IsInSct() )
3564 : {
3565 : // See above at tables
3566 0 : if( !pLastSctCnt )
3567 0 : pLastSctCnt = lcl_InvalidateSection( pCnt, nInv );
3568 0 : if( pLastSctCnt == pCnt )
3569 0 : pLastSctCnt = NULL;
3570 : }
3571 : #if OSL_DEBUG_LEVEL > 0
3572 : else
3573 : OSL_ENSURE( !pLastSctCnt, "Where's the last SctCntnt?" );
3574 : #endif
3575 : }
3576 152 : if( nInv & INV_TABLE )
3577 : {
3578 26 : if( pCnt->IsInTab() )
3579 : {
3580 : // To not call FindTabFrm() for each CntntFrm of a table and
3581 : // then invalidate the table, we remember the last CntntFrm of
3582 : // the table and ignore IsInTab() until we are past it.
3583 : // When entering the table, LastSctCnt is set to null, so
3584 : // sections inside the table are correctly invalidated.
3585 : // If the table itself is in a section the
3586 : // invalidation is done three times, which is acceptable.
3587 0 : if( !pLastTabCnt )
3588 : {
3589 0 : pLastTabCnt = lcl_InvalidateTable( pCnt->FindTabFrm(), nInv );
3590 0 : pLastSctCnt = NULL;
3591 : }
3592 0 : if( pLastTabCnt == pCnt )
3593 : {
3594 0 : pLastTabCnt = NULL;
3595 0 : pLastSctCnt = NULL;
3596 : }
3597 : }
3598 : #if OSL_DEBUG_LEVEL > 0
3599 : else
3600 : OSL_ENSURE( !pLastTabCnt, "Where's the last TabCntnt?" );
3601 : #endif
3602 : }
3603 :
3604 152 : if( nInv & INV_SIZE )
3605 130 : pCnt->Prepare( PREP_CLEAR, 0, false );
3606 152 : if( nInv & INV_POS )
3607 54 : pCnt->_InvalidatePos();
3608 152 : if( nInv & INV_PRTAREA )
3609 54 : pCnt->_InvalidatePrt();
3610 152 : if ( nInv & INV_LINENUM )
3611 12 : pCnt->InvalidateLineNum();
3612 152 : if ( pCnt->GetDrawObjs() )
3613 4 : lcl_InvalidateAllCntnt( pCnt, nInv );
3614 152 : pCnt = pCnt->GetNextCntntFrm();
3615 : }
3616 83 : }
3617 :
3618 4 : static void lcl_InvalidateAllCntnt( SwCntntFrm *pCnt, sal_uInt8 nInv )
3619 : {
3620 4 : SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
3621 32 : for ( size_t i = 0; i < rObjs.size(); ++i )
3622 : {
3623 28 : SwAnchoredObject* pAnchoredObj = rObjs[i];
3624 28 : if ( pAnchoredObj->ISA(SwFlyFrm) )
3625 : {
3626 22 : SwFlyFrm *pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
3627 22 : if ( pFly->IsFlyInCntFrm() )
3628 : {
3629 0 : ::lcl_InvalidateCntnt( pFly->ContainsCntnt(), nInv );
3630 0 : if( nInv & INV_DIRECTION )
3631 0 : pFly->CheckDirChange();
3632 : }
3633 : }
3634 : }
3635 4 : }
3636 :
3637 59 : void SwRootFrm::InvalidateAllCntnt( sal_uInt8 nInv )
3638 : {
3639 : // First process all page bound FlyFrms.
3640 59 : SwPageFrm *pPage = (SwPageFrm*)Lower();
3641 177 : while( pPage )
3642 : {
3643 59 : pPage->InvalidateFlyLayout();
3644 59 : pPage->InvalidateFlyCntnt();
3645 59 : pPage->InvalidateFlyInCnt();
3646 59 : pPage->InvalidateLayout();
3647 59 : pPage->InvalidateCntnt();
3648 59 : pPage->InvalidatePage( pPage ); // So even the Turbo disappears if applicable
3649 :
3650 59 : if ( pPage->GetSortedObjs() )
3651 : {
3652 2 : const SwSortedObjs &rObjs = *pPage->GetSortedObjs();
3653 32 : for ( size_t i = 0; i < rObjs.size(); ++i )
3654 : {
3655 30 : SwAnchoredObject* pAnchoredObj = rObjs[i];
3656 30 : if ( pAnchoredObj->ISA(SwFlyFrm) )
3657 : {
3658 24 : SwFlyFrm* pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
3659 24 : ::lcl_InvalidateCntnt( pFly->ContainsCntnt(), nInv );
3660 24 : if ( nInv & INV_DIRECTION )
3661 0 : pFly->CheckDirChange();
3662 : }
3663 : }
3664 : }
3665 59 : if( nInv & INV_DIRECTION )
3666 4 : pPage->CheckDirChange();
3667 59 : pPage = (SwPageFrm*)(pPage->GetNext());
3668 : }
3669 :
3670 : //Invalidate the whole document content and the character bound Flys here.
3671 59 : ::lcl_InvalidateCntnt( ContainsCntnt(), nInv );
3672 :
3673 59 : if( nInv & INV_PRTAREA )
3674 : {
3675 53 : SwViewShell *pSh = getRootFrm()->GetCurrShell();
3676 53 : if( pSh )
3677 53 : pSh->InvalidateWindows( Frm() );
3678 : }
3679 59 : }
3680 :
3681 : /**
3682 : * Invalidate/re-calculate the position of all floating screen objects (Writer fly frames and
3683 : * drawing objects), that are anchored to paragraph or to character. (2004-03-16 #i11860#)
3684 : */
3685 0 : void SwRootFrm::InvalidateAllObjPos()
3686 : {
3687 0 : const SwPageFrm* pPageFrm = static_cast<const SwPageFrm*>(Lower());
3688 0 : while( pPageFrm )
3689 : {
3690 0 : pPageFrm->InvalidateFlyLayout();
3691 :
3692 0 : if ( pPageFrm->GetSortedObjs() )
3693 : {
3694 0 : const SwSortedObjs& rObjs = *(pPageFrm->GetSortedObjs());
3695 0 : for ( size_t i = 0; i < rObjs.size(); ++i )
3696 : {
3697 0 : SwAnchoredObject* pAnchoredObj = rObjs[i];
3698 0 : const SwFmtAnchor& rAnch = pAnchoredObj->GetFrmFmt().GetAnchor();
3699 0 : if ((rAnch.GetAnchorId() != FLY_AT_PARA) &&
3700 0 : (rAnch.GetAnchorId() != FLY_AT_CHAR))
3701 : {
3702 : // only to paragraph and to character anchored objects are considered.
3703 0 : continue;
3704 : }
3705 : // #i28701# - special invalidation for anchored
3706 : // objects, whose wrapping style influence has to be considered.
3707 0 : if ( pAnchoredObj->ConsiderObjWrapInfluenceOnObjPos() )
3708 0 : pAnchoredObj->InvalidateObjPosForConsiderWrapInfluence( true );
3709 : else
3710 0 : pAnchoredObj->InvalidateObjPos();
3711 : }
3712 : }
3713 :
3714 0 : pPageFrm = static_cast<const SwPageFrm*>(pPageFrm->GetNext());
3715 : }
3716 270 : }
3717 :
3718 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|