summaryrefslogtreecommitdiffstats
path: root/sc
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej.hunt@collabora.com>2014-08-11 08:48:07 +0200
committerAndrzej Hunt <andrzej.hunt@collabora.com>2014-08-11 08:48:07 +0200
commitb72d20b165ee1610338cf23cc9cd2216280fc0e1 (patch)
tree2d90992813786e8b0146cf74f20126c902f1f89a /sc
parentImplement data area size retrieval. (diff)
downloadcore-b72d20b165ee1610338cf23cc9cd2216280fc0e1.tar.gz
core-b72d20b165ee1610338cf23cc9cd2216280fc0e1.zip
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
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/fillinfo.cxx12
-rw-r--r--sc/source/ui/inc/gridwin.hxx2
-rw-r--r--sc/source/ui/view/gridwin4.cxx59
3 files changed, 40 insertions, 33 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/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index dfb9b84c5f85..6e2ecaf86c71 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -129,6 +129,8 @@ class ScGridWindow : public Window, public DropTargetHelper, public DragSourceHe
VisibleRange maVisibleRange;
+ MapMode maPaintMapMode;
+
boost::scoped_ptr<sc::SpellCheckContext> mpSpellCheckCxt;
boost::ptr_vector<Window> maChildWindows;
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 6a6d3ef17512..bc3114c458f1 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -461,13 +461,14 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
rDoc.ExtendHidden( nX1, nY1, nX2, nY2, nTab );
- Point aScrPos = pViewData->GetScrPos( nX1, nY1, eWhich );
+ Point aScrPos = LogicToPixel(pViewData->GetScrPos( nX1, nY1, eWhich ), maPaintMapMode);
long nMirrorWidth = GetSizePixel().Width();
bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
long nLayoutSign = bLayoutRTL ? -1 : 1;
if ( bLayoutRTL )
{
- long nEndPixel = pViewData->GetScrPos( nX2+1, maVisibleRange.mnRow1, eWhich ).X();
+ long nEndPixel = LogicToPixel(pViewData->GetScrPos( nX2+1, maVisibleRange.mnRow1, eWhich ),
+ maPaintMapMode).X();
nMirrorWidth = aScrPos.X() - nEndPixel;
aScrPos.X() = nEndPixel + 1;
}
@@ -876,8 +877,8 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
SCROW nRow2 = pViewData->GetEditEndRow();
SetLineColor();
SetFillColor( pEditView->GetBackgroundColor() );
- Point aStart = pViewData->GetScrPos( nCol1, nRow1, eWhich );
- Point aEnd = pViewData->GetScrPos( nCol2+1, nRow2+1, eWhich );
+ Point aStart = LogicToPixel(pViewData->GetScrPos( nCol1, nRow1, eWhich ), maPaintMapMode);
+ Point aEnd = LogicToPixel(pViewData->GetScrPos( nCol2+1, nRow2+1, eWhich ), maPaintMapMode);
aEnd.X() -= 2 * nLayoutSign; // don't overwrite grid
aEnd.Y() -= 2;
DrawRect( Rectangle( aStart,aEnd ) );
@@ -920,21 +921,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();
@@ -1033,10 +1038,12 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
else
pContentDev->SetFillColor( aManual );
- Point aStart = pViewData->GetScrPos(
- aRange.aStart.Col(), aRange.aStart.Row(), eWhich, true );
- Point aEnd = pViewData->GetScrPos(
- aRange.aEnd.Col() + 1, aRange.aEnd.Row() + 1, eWhich, true );
+ Point aStart = LogicToPixel(pViewData->GetScrPos(
+ aRange.aStart.Col(), aRange.aStart.Row(), eWhich, true ),
+ maPaintMapMode);
+ Point aEnd = LogicToPixel(pViewData->GetScrPos(
+ aRange.aEnd.Col() + 1, aRange.aEnd.Row() + 1, eWhich, true ),
+ maPaintMapMode);
aStart.X() -= 2;
aStart.Y() -= 2;
@@ -1069,8 +1076,9 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
pContentDev->SetFillColor( aManual );
else
pContentDev->SetFillColor( aAutomatic );
- Point aBreak = pViewData->GetScrPos(
- nBreak, aRange.aStart.Row(), eWhich, true );
+ Point aBreak = LogicToPixel(pViewData->GetScrPos(
+ nBreak, aRange.aStart.Row(), eWhich, true ),
+ maPaintMapMode);
pContentDev->DrawRect( Rectangle( aBreak.X()-1, aStart.Y(), aBreak.X(), aEnd.Y() ) );
}
}
@@ -1088,8 +1096,9 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
pContentDev->SetFillColor( aManual );
else
pContentDev->SetFillColor( aAutomatic );
- Point aBreak = pViewData->GetScrPos(
- aRange.aStart.Col(), nBreak, eWhich, true );
+ Point aBreak = LogicToPixel(pViewData->GetScrPos(
+ aRange.aStart.Col(), nBreak, eWhich, true ),
+ maPaintMapMode);
pContentDev->DrawRect( Rectangle( aStart.X(), aBreak.Y()-1, aEnd.X(), aBreak.Y() ) );
}
}
@@ -1108,10 +1117,12 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
SCCOL nPrEndX = pColEnd[nColPos];
if ( nPrEndX >= nX1 && nPrStartX <= nX2 )
{
- Point aPageStart = pViewData->GetScrPos(
- nPrStartX, nPrStartY, eWhich, true );
- Point aPageEnd = pViewData->GetScrPos(
- nPrEndX+1,nPrEndY+1, eWhich, true );
+ Point aPageStart = LogicToPixel(pViewData->GetScrPos(
+ nPrStartX, nPrStartY, eWhich, true ),
+ maPaintMapMode);
+ Point aPageEnd = LogicToPixel(pViewData->GetScrPos(
+ nPrEndX+1,nPrEndY+1, eWhich, true ),
+ maPaintMapMode);
long nPageNo = rData.GetFirstPage();
if ( rData.IsTopDown() )