diff options
author | Andrzej Hunt <andrzej.hunt@collabora.com> | 2014-08-15 09:48:52 +0200 |
---|---|---|
committer | Andrzej Hunt <andrzej.hunt@collabora.com> | 2014-08-30 21:37:07 +0200 |
commit | 1ad8138273be02a9f34d7d8379130e06c253762d (patch) | |
tree | 1dcc67a692491be377f0ce57f1ab0feeab9d8ac8 | |
parent | c4c39ab5b305b4f3feb54a0e65117ec2df365195 (diff) |
Fillinfo: don't scale data unnecessarily.
Previously we had multiple layers of scaling, with rounding
errors propagating, leading to up to 5% differences in expected
and rendered sheet widths -- for tiled rendering dimensions have
to scale accurately as we may paint the same tile at multiple zoom
levels, by eliminating multiple scaling and letting the output
device instead deal with the scaling once we can eliminate these
errors.
Change-Id: I0a725fd5c030f3c089c2bbd25947088c321eb2d4
-rw-r--r-- | sc/source/core/data/fillinfo.cxx | 12 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin4.cxx | 20 |
2 files changed, 15 insertions, 17 deletions
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index a6b7b90f62a0..4313856c6349 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -278,7 +278,7 @@ void ScDocument::FillInfo( RowInfo* pThisRowInfo = &pRowInfo[nArrRow]; pThisRowInfo->pCellInfo = NULL; // wird unten belegt - sal_uInt16 nHeight = (sal_uInt16) ( nDocHeight * fRowScale ); + sal_uInt16 nHeight = nDocHeight; if (!nHeight) nHeight = 1; @@ -393,11 +393,7 @@ void ScDocument::FillInfo( { if (!ColHidden(nX, nTab)) { - sal_uInt16 nThisWidth = (sal_uInt16) (GetColWidth( nX, nTab ) * fColScale); - if (!nThisWidth) - nThisWidth = 1; - - pRowInfo[0].pCellInfo[nArrCol].nWidth = nThisWidth; + pRowInfo[0].pCellInfo[nArrCol].nWidth = GetColWidth( nX, nTab ); } } } @@ -418,9 +414,7 @@ void ScDocument::FillInfo( // TODO: Optimize this loop. if (!ColHidden(nX, nTab)) { - sal_uInt16 nThisWidth = (sal_uInt16) (GetColWidth( nX, nTab ) * fColScale); - if (!nThisWidth) - nThisWidth = 1; + int nThisWidth = GetColWidth( nX, nTab ); pRowInfo[0].pCellInfo[nArrCol].nWidth = nThisWidth; //! dies sollte reichen diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 7422258fd331..961370a6de99 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -940,21 +940,25 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice, int nTilePosX, int nTilePosY, long nTileWidth, long nTileHeight ) { + // Scaling. Must convert from pixels to TWIPs. We know + // that VirtualDevices use a DPI of 96. We might as well do this + // calculation now, rather than after another dimension conversion, + // to minimise errors. + Fraction scaleX = Fraction( nOutputWidth, 96 ) * Fraction(1440L) / + Fraction( nTileWidth); + Fraction scaleY = Fraction( nOutputHeight, 96 ) * Fraction(1440L) / + Fraction( nTileHeight); + rDevice.SetOutputSizePixel( Size( nOutputWidth, nOutputHeight ) ); - // setup the output device to draw the tile MapMode aMapMode( rDevice.GetMapMode() ); aMapMode.SetMapUnit( MAP_TWIP ); aMapMode.SetOrigin( Point( -nTilePosX, -nTilePosY ) ); - // Scaling. Must convert from pixels to twips. We know - // that VirtualDevises use a DPI of 96. - Fraction scaleX = Fraction( nOutputWidth, 96 ) * Fraction(1440L) / - Fraction( nTileWidth); - Fraction scaleY = Fraction( nOutputHeight, 96 ) * Fraction(1440L) / - Fraction( nTileHeight); aMapMode.SetScaleX( scaleX ); aMapMode.SetScaleY( scaleY ); - rDevice.SetMapMode( aMapMode ); + + maPaintMapMode = aMapMode; +// rDevice.SetMapMode( aMapMode ); ScTabViewShell* pTabViewSh = pViewData->GetViewShell(); SdrView* pDrawView = pTabViewSh->GetScDrawView(); |