[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - sw/source

Michael Stahl mstahl at redhat.com
Sun Mar 9 09:51:45 PDT 2014


 sw/source/core/layout/atrfrm.cxx |   12 ++++++++++++
 1 file changed, 12 insertions(+)

New commits:
commit 6beed55f62dacf365b16fd64dc32682e5db30a8f
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Mar 7 15:56:37 2014 +0100

    rhbz#1043551: sw: avoid division-by-0 in Text Grid painting code
    
    Possible to trigger with a document containing:
        style:layout-grid-base-height="0cm"
    
    (cherry picked from commit 71b55cf57460aec3fec948676251448934ba31d1)
    
    got to love the sal_Int32 as long/int
    (cherry picked from commit 18c89ae6ff01f3d555a7cb030eb4572d504e8de7)
    
    Change-Id: Id3bd1f29157b39e8a577be0b87b86236dbe5a50c
    Reviewed-on: https://gerrit.libreoffice.org/8497
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index b06cea4..3c40518 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -2262,12 +2262,24 @@ bool SwTextGridItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
             bRet = (rVal >>= nTmp);
             nTmp = MM100_TO_TWIP( nTmp );
             if( bRet && (nTmp >= 0) && ( nTmp <= USHRT_MAX) )
+            {
+                // rhbz#1043551 round up to 5pt -- 0 causes divide-by-zero
+                // in layout; 1pt ties the painting code up in knots for
+                // minutes with bazillion lines...
+#define MIN_TEXTGRID_SIZE 100
                 if( (nMemberId & ~CONVERT_TWIPS) == MID_GRID_BASEHEIGHT )
+                {
+                    nTmp = std::max<sal_Int32>(nTmp, MIN_TEXTGRID_SIZE);
                     SetBaseHeight( (sal_uInt16)nTmp );
+                }
                 else if( (nMemberId & ~CONVERT_TWIPS) == MID_GRID_BASEWIDTH )
+                {
+                    nTmp = std::max<sal_Int32>(nTmp, MIN_TEXTGRID_SIZE);
                     SetBaseWidth( (sal_uInt16)nTmp );
+                }
                 else
                     SetRubyHeight( (sal_uInt16)nTmp );
+            }
             else
                 bRet = false;
         }


More information about the Libreoffice-commits mailing list