summaryrefslogtreecommitdiffstats
path: root/sc/source/ui/view/drawutil.cxx
diff options
context:
space:
mode:
authorNiklas Nebel <nn@openoffice.org>2001-10-16 13:43:14 +0000
committerNiklas Nebel <nn@openoffice.org>2001-10-16 13:43:14 +0000
commitc2da6f9155ca4d699a77d38f18db18571834ebaf (patch)
tree52b04be78254823a889b514ae683367da684a746 /sc/source/ui/view/drawutil.cxx
parent#65293# SO3 define removed (diff)
downloadcore-c2da6f9155ca4d699a77d38f18db18571834ebaf.tar.gz
core-c2da6f9155ca4d699a77d38f18db18571834ebaf.zip
#78486# calculate scale in double, reduce to 17 bits
Diffstat (limited to 'sc/source/ui/view/drawutil.cxx')
-rw-r--r--sc/source/ui/view/drawutil.cxx36
1 files changed, 27 insertions, 9 deletions
diff --git a/sc/source/ui/view/drawutil.cxx b/sc/source/ui/view/drawutil.cxx
index 17821f91afe2..b09beb9175b5 100644
--- a/sc/source/ui/view/drawutil.cxx
+++ b/sc/source/ui/view/drawutil.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: drawutil.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: nn $ $Date: 2001-04-18 10:42:14 $
+ * last change: $Author: nn $ $Date: 2001-10-16 14:43:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -113,13 +113,31 @@ void ScDrawUtil::CalcScale( ScDocument* pDoc, USHORT nTab,
MapMode aHMMMode( MAP_100TH_MM, Point(), rZoomX, rZoomY );
Point aPixelLog = pDev->PixelToLogic( Point( nPixelX,nPixelY ), aHMMMode );
- rScaleX = MakeFraction( aPixelLog.X() * rZoomX.GetNumerator(),
- (long) ( nTwipsX * HMM_PER_TWIPS * rZoomX.GetDenominator() ) );
- rScaleY = MakeFraction( aPixelLog.Y() * rZoomY.GetNumerator(),
- (long) ( nTwipsY * HMM_PER_TWIPS * rZoomY.GetDenominator() ) );
-
- rScaleX.ReduceInaccurate( 14 );
- rScaleY.ReduceInaccurate( 14 );
+ // Fraction(double) ctor can be used here (and avoid overflows of PixelLog * Zoom)
+ // because ReduceInaccurate is called later anyway.
+
+ if ( aPixelLog.X() && nTwipsX )
+ rScaleX = Fraction( ((double)aPixelLog.X()) *
+ ((double)rZoomX.GetNumerator()) /
+ ((double)nTwipsX) /
+ ((double)HMM_PER_TWIPS) /
+ ((double)rZoomX.GetDenominator()) );
+ else
+ rScaleX = Fraction( 1, 1 );
+
+ if ( aPixelLog.Y() && nTwipsY )
+ rScaleY = Fraction( ((double)aPixelLog.Y()) *
+ ((double)rZoomY.GetNumerator()) /
+ ((double)nTwipsY) /
+ ((double)HMM_PER_TWIPS) /
+ ((double)rZoomY.GetDenominator()) );
+ else
+ rScaleY = Fraction( 1, 1 );
+
+ // 17 bits of accuracy are needed to always hit the right part of
+ // cells in the last rows
+ rScaleX.ReduceInaccurate( 17 );
+ rScaleY.ReduceInaccurate( 17 );
}