From 092a4385c2616943baccc8ec43ca29c1dcfba9fa Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Mon, 17 Dec 2012 21:14:21 +0000 Subject: fdo#53525 - Revert "writer:crash(i118878) when adding columns and chang. properties in a frame" This reverts commit de1c42d9f552bc57b28d50f4313bc982c63b84d4. --- sw/source/core/layout/colfrm.cxx | 46 +++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 27 deletions(-) (limited to 'sw') diff --git a/sw/source/core/layout/colfrm.cxx b/sw/source/core/layout/colfrm.cxx index a47258bb61b2..654657a26f62 100644 --- a/sw/source/core/layout/colfrm.cxx +++ b/sw/source/core/layout/colfrm.cxx @@ -340,26 +340,20 @@ void SwLayoutFrm::AdjustColumns( const SwFmtCol *pAttr, sal_Bool bAdjustAttribut const sal_Bool bLine = pAttr->GetLineAdj() != COLADJ_NONE; const sal_uInt16 nMin = bLine ? sal_uInt16( 20 + ( pAttr->GetLineWidth() / 2) ) : 0; + const sal_Bool bR2L = IsRightToLeft(); + SwFrm *pCol = bR2L ? GetLastLower() : Lower(); + // #i27399# // bOrtho means we have to adjust the column frames manually. Otherwise // we may use the values returned by CalcColWidth: const sal_Bool bOrtho = pAttr->IsOrtho() && pAttr->GetNumCols() > 0; long nGutter = 0; - sal_uInt16 real_nb_col = 0; - - SwFrm* pColHead = Lower();; - SwFrm* pColTail; - for ( pColTail = pColHead; pColTail; pColTail = pColTail->GetNext(), real_nb_col += 1 ); - - sal_uInt16 i = IsRightToLeft() ? real_nb_col : 0; - for ( SwFrm* pColCursor = IsRightToLeft() ? pColTail : pColHead; - pColCursor; - (pColCursor = IsRightToLeft() ? pColCursor->GetPrev() : pColCursor->GetNext()), (i += IsRightToLeft() ? -1 : +1) ) + for ( sal_uInt16 i = 0; i < pAttr->GetNumCols(); ++i ) { if( !bOrtho ) { - const SwTwips nWidth = (pColCursor == (IsRightToLeft() ? pColTail : pColHead) ) ? + const SwTwips nWidth = i == (pAttr->GetNumCols() - 1) ? nAvail : pAttr->CalcColWidth( i, sal_uInt16( (Prt().*fnRect->fnGetWidth)() ) ); @@ -367,14 +361,14 @@ void SwLayoutFrm::AdjustColumns( const SwFmtCol *pAttr, sal_Bool bAdjustAttribut Size( Prt().Width(), nWidth ) : Size( nWidth, Prt().Height() ); - pColCursor->ChgSize( aColSz ); + pCol->ChgSize( aColSz ); // With this, the ColumnBodyFrms from page columns gets adjusted and // their bFixHeight flag is set so they won't shrink/grow. // Don't use the flag with frame columns because BodyFrms in frame // columns can grow/shrink. if( IsBodyFrm() ) - ((SwLayoutFrm*)pColCursor)->Lower()->ChgSize( aColSz ); + ((SwLayoutFrm*)pCol)->Lower()->ChgSize( aColSz ); nAvail -= nWidth; } @@ -382,7 +376,7 @@ void SwLayoutFrm::AdjustColumns( const SwFmtCol *pAttr, sal_Bool bAdjustAttribut if ( bOrtho || bAdjustAttributes ) { const SwColumn *pC = &pAttr->GetColumns()[i]; - const SwAttrSet* pSet = pColCursor->GetAttrSet(); + const SwAttrSet* pSet = pCol->GetAttrSet(); SvxLRSpaceItem aLR( pSet->GetLRSpace() ); //In order to have enough space for the separation lines, we have to @@ -418,44 +412,42 @@ void SwLayoutFrm::AdjustColumns( const SwFmtCol *pAttr, sal_Bool bAdjustAttribut aUL.SetUpper( pC->GetUpper()); aUL.SetLower( pC->GetLower()); - ((SwLayoutFrm*)pColCursor)->GetFmt()->SetFmtAttr( aLR ); - ((SwLayoutFrm*)pColCursor)->GetFmt()->SetFmtAttr( aUL ); + ((SwLayoutFrm*)pCol)->GetFmt()->SetFmtAttr( aLR ); + ((SwLayoutFrm*)pCol)->GetFmt()->SetFmtAttr( aUL ); } nGutter += aLR.GetLeft() + aLR.GetRight(); } + + pCol = bR2L ? pCol->GetPrev() : pCol->GetNext(); } if( bOrtho ) { long nInnerWidth = ( nAvail - nGutter ) / pAttr->GetNumCols(); - i = 0; - for (SwFrm* pColCursor = pColHead; pColCursor; pColCursor = pColCursor->GetNext(), i++) + pCol = Lower(); + for( sal_uInt16 i = 0; i < pAttr->GetNumCols(); pCol = pCol->GetNext(), ++i ) { SwTwips nWidth; if ( i == pAttr->GetNumCols() - 1 ) - { nWidth = nAvail; - } else { - SvxLRSpaceItem aLR( pColCursor->GetAttrSet()->GetLRSpace() ); + SvxLRSpaceItem aLR( pCol->GetAttrSet()->GetLRSpace() ); nWidth = nInnerWidth + aLR.GetLeft() + aLR.GetRight(); } if( nWidth < 0 ) - { nWidth = 0; - } + const Size aColSz = bVert ? Size( Prt().Width(), nWidth ) : Size( nWidth, Prt().Height() ); - pColCursor->ChgSize( aColSz ); + pCol->ChgSize( aColSz ); if( IsBodyFrm() ) - { - ((SwLayoutFrm*)pColCursor)->Lower()->ChgSize( aColSz ); - } + ((SwLayoutFrm*)pCol)->Lower()->ChgSize( aColSz ); + nAvail -= nWidth; } } -- cgit