summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej.hunt@collabora.com>2014-08-27 20:39:23 +0200
committerAndrzej Hunt <andrzej.hunt@collabora.com>2014-08-30 21:37:16 +0200
commitf71b7b21554fdbe4696f55f8236ac55ea842e318 (patch)
tree7660ecebb16d55a01f9ec162311221a9a8db95c6
parent0ca6bda9e743d4e5ec2c3d7425b4cda6b70e0545 (diff)
Use logic coordinates to determine cells in visible area.
Change-Id: I91268b0d32aa85ea2a63e05837dc8c3781ede018
-rw-r--r--sc/source/ui/view/gridwin4.cxx34
1 files changed, 20 insertions, 14 deletions
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index f50f7a161eeb..ec0a52f4ec72 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -336,36 +336,42 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
bIsInPaint = true;
- Rectangle aPixRect = pOutDev->LogicToPixel( rRect );
+ // We are handed a rectangle in the logic coordinates currently applying
+ // to the window. But we might be (probably will be) painting in different
+ // logic coordinates. Hence the multi-stage conversion.
+ // In fact most of the drawing in ScGridWin is done in Pixel coordinates, but
+ // we need logic coordinates for converting the cells to pixels and all
+ // related calculations.
+ const Rectangle aPixRect = pOutDev->LogicToPixel( rRect );
+ const Rectangle aLogicRect = pOutDev->PixelToLogic( aPixRect,
+ pViewData->GetPaintMapMode() );
SCCOL nX1 = pViewData->GetPosX(eHWhich);
SCROW nY1 = pViewData->GetPosY(eVWhich);
SCTAB nTab = pViewData->GetTabNo();
- double nPPTX = pViewData->GetPPTX();
- double nPPTY = pViewData->GetPPTY();
-
- Rectangle aMirroredPixel = aPixRect;
+ Rectangle aMirroredTwips = aLogicRect;
if ( pDoc->IsLayoutRTL( nTab ) )
{
// mirror and swap
- long nWidth = GetSizePixel().Width();
- aMirroredPixel.Left() = nWidth - 1 - aPixRect.Right();
- aMirroredPixel.Right() = nWidth - 1 - aPixRect.Left();
+ long nWidth = pOutDev->PixelToLogic( GetSizePixel(),
+ pViewData->GetPaintMapMode() ).Width();
+ aMirroredTwips.Left() = nWidth - 1 - aLogicRect.Right();
+ aMirroredTwips.Right() = nWidth - 1 - aLogicRect.Left();
}
- long nScrX = ScViewData::ToPixel( pDoc->GetColWidth( nX1, nTab ), nPPTX );
- while ( nScrX <= aMirroredPixel.Left() && nX1 < MAXCOL )
+ long nScrX = pDoc->GetColWidth( nX1, nTab );
+ while ( nScrX <= aMirroredTwips.Left() && nX1 < MAXCOL )
{
++nX1;
- nScrX += ScViewData::ToPixel( pDoc->GetColWidth( nX1, nTab ), nPPTX );
+ nScrX += pDoc->GetColWidth( nX1, nTab );
}
SCCOL nX2 = nX1;
- while ( nScrX <= aMirroredPixel.Right() && nX2 < MAXCOL )
+ while ( nScrX <= aMirroredTwips.Right() && nX2 < MAXCOL )
{
++nX2;
- nScrX += ScViewData::ToPixel( pDoc->GetColWidth( nX2, nTab ), nPPTX );
+ nScrX += pDoc->GetColWidth( nX2, nTab );
}
long nScrY = 0;
@@ -373,7 +379,7 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
pViewData->LogicToPixelVertical( aLogicRect.Top() ),
nY1, MAXROW );
SCROW nY2 = nY1;
- if (nScrY <= aPixRect.Bottom() && nY2 < MAXROW)
+ if (nScrY <= aLogicRect.Bottom() && nY2 < MAXROW)
{
++nY2;
pViewData->AddTwipsWhile( nScrY,