[Libreoffice-commits] .: 2 commits - sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Dec 17 13:20:48 PST 2012


 sw/source/core/layout/colfrm.cxx |   46 ++++++++++++++++-----------------------
 1 file changed, 19 insertions(+), 27 deletions(-)

New commits:
commit 6560cae1b5f81cb753a7216cb22d4e7f9d175cd1
Author: Yong Lin Ma <mayongl at apache.org>
Date:   Sat Jun 16 06:47:30 2012 +0000

    118878: Writer crash after column number and width of frame are modified
    
    Patch by: Lin Yuan
    Review by: mayongl
    Reported by: Ji Yan

diff --git a/sw/source/core/layout/colfrm.cxx b/sw/source/core/layout/colfrm.cxx
index 654657a..f8522c1 100644
--- a/sw/source/core/layout/colfrm.cxx
+++ b/sw/source/core/layout/colfrm.cxx
@@ -349,7 +349,7 @@ void SwLayoutFrm::AdjustColumns( const SwFmtCol *pAttr, sal_Bool bAdjustAttribut
     const sal_Bool bOrtho = pAttr->IsOrtho() && pAttr->GetNumCols() > 0;
     long nGutter = 0;
 
-    for ( sal_uInt16 i = 0; i < pAttr->GetNumCols(); ++i )
+    for ( sal_uInt16 i = 0; i < pAttr->GetNumCols() && pCol; ++i ) //i118878, value returned by GetNumCols() can't be trusted
     {
         if( !bOrtho )
         {
@@ -426,7 +426,7 @@ void SwLayoutFrm::AdjustColumns( const SwFmtCol *pAttr, sal_Bool bAdjustAttribut
     {
         long nInnerWidth = ( nAvail - nGutter ) / pAttr->GetNumCols();
         pCol = Lower();
-        for( sal_uInt16 i = 0; i < pAttr->GetNumCols(); pCol = pCol->GetNext(), ++i )
+        for( sal_uInt16 i = 0; i < pAttr->GetNumCols() && pCol; pCol = pCol->GetNext(), ++i ) //i118878, value returned by GetNumCols() can't be trusted
         {
             SwTwips nWidth;
             if ( i == pAttr->GetNumCols() - 1 )
commit 092a4385c2616943baccc8ec43ca29c1dcfba9fa
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Mon Dec 17 21:14:21 2012 +0000

    fdo#53525 - Revert "writer:crash(i118878) when adding
    
    columns and chang. properties in a frame"
    
    This reverts commit de1c42d9f552bc57b28d50f4313bc982c63b84d4.

diff --git a/sw/source/core/layout/colfrm.cxx b/sw/source/core/layout/colfrm.cxx
index a47258b..654657a 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;
         }
     }


More information about the Libreoffice-commits mailing list