diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-03-07 15:56:37 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2014-03-07 17:04:08 +0100 |
commit | 71b55cf57460aec3fec948676251448934ba31d1 (patch) | |
tree | 2081b1b0dcd08dd9f26aba8d5af7782fe4740db6 /sw | |
parent | 04cc0939abcf55debd2b15efea9b310196259093 (diff) |
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"
Change-Id: Id3bd1f29157b39e8a577be0b87b86236dbe5a50c
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/layout/atrfrm.cxx | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 51a0d5373d1a..f80cf38e8a96 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -2268,12 +2268,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(nTmp, MIN_TEXTGRID_SIZE); SetBaseHeight( (sal_uInt16)nTmp ); + } else if( (nMemberId & ~CONVERT_TWIPS) == MID_GRID_BASEWIDTH ) + { + nTmp = std::max(nTmp, MIN_TEXTGRID_SIZE); SetBaseWidth( (sal_uInt16)nTmp ); + } else SetRubyHeight( (sal_uInt16)nTmp ); + } else bRet = false; } |