summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej.hunt@collabora.com>2014-06-20 09:38:50 +0100
committerAndrzej Hunt <andrzej.hunt@collabora.com>2014-07-11 16:34:50 +0200
commitf77ef66c9c295a2cf2c50e4f180bfe69ec1d5759 (patch)
tree090584e7f9052b3c74351eed2abded7ddac69d99
parent6f079c4733fb1c61c0ecdf9f96afc4b2c1181bbd (diff)
Don't scale grid and cell dimensions multiple times.
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. (However currently rendering of text/images isn't quite right.) Change-Id: I0a725fd5c030f3c089c2bbd25947088c321eb2d4
-rw-r--r--sc/source/core/data/fillinfo.cxx12
-rw-r--r--sc/source/ui/view/gridwin4.cxx17
2 files changed, 12 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 c458f72a5c53..7068bb02c399 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -711,7 +711,6 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
else
aOutputData.SetSolidBackground(true);
- pContentDev->SetMapMode(MAP_PIXEL);
aOutputData.DrawDocumentBackground();
if ( bGridFirst && ( bGrid || bPage ) )
@@ -918,18 +917,20 @@ 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 );