summaryrefslogtreecommitdiff
path: root/sc/source/core/data/table2.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/core/data/table2.cxx')
-rw-r--r--sc/source/core/data/table2.cxx11
1 files changed, 7 insertions, 4 deletions
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index d54e16b8cbd7..4223c05c4f83 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -3100,10 +3100,13 @@ void ScTable::SetDrawPageSize(bool bResetStreamValid, bool bUpdateNoteCaptionPos
ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer();
if( pDrawLayer )
{
- long x = GetColOffset( MAXCOL + 1 );
- long y = GetRowOffset( MAXROW + 1 );
- x = (long) ((double) x * HMM_PER_TWIPS);
- y = (long) ((double) y * HMM_PER_TWIPS);
+ double fValX = GetColOffset( MAXCOL + 1 ) * HMM_PER_TWIPS;
+ double fValY = GetRowOffset( MAXROW + 1 ) * HMM_PER_TWIPS;
+ const long nMax = ::std::numeric_limits<long>::max();
+ // #i113884# Avoid int32 overflow with possible negative results than can cause bad effects.
+ // If the draw page size is smaller than all rows, only the bottom of the sheet is affected.
+ long x = ( fValX > (double)nMax ) ? nMax : (long) fValX;
+ long y = ( fValY > (double)nMax ) ? nMax : (long) fValY;
if ( IsLayoutRTL() ) // IsNegativePage
x = -x;