sc/source/ui/view/gridwin4.cxx | 50 +++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 17 deletions(-)
New commits: commit 432473cb1697bda298d7edab0a5ec4f7abf2733c Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Thu Jul 3 14:47:15 2014 +0200 Iterate from origin to tile area to ensure correct positioning. Change-Id: I29e881f9e67b84e208a198d2aad06db382d14698 diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 34e085b..028c114 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -341,8 +341,16 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev ) bIsInPaint = true; - SCCOL nX1 = pViewData->GetPosX(eHWhich); - SCROW nY1 = pViewData->GetPosY(eVWhich); + // If we're doing tiled rendering we'll have a different output device here, + // and we could really be at a completely random position, hence we + // iterate from 0. + SCCOL nX1 = 0; + SCROW nY1 = 0; + if ( pOutDev == this ) + { + nX1 = pViewData->GetPosX(eHWhich); + nY1 = pViewData->GetPosY(eVWhich); + } SCTAB nTab = pViewData->GetTabNo(); @@ -381,6 +389,14 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev ) nScrY += pDoc->GetRowHeight( nY2, nTab ); } + // Bit hacky -- but Draw starts drawing with nX1/nY1 being at + // the output devices origin, so we make sure we start drawing + // with cell A1 at the origin etc. + if ( pOutDev != this ) + { + nX1 = 0; + nY1 = 0; + } // We specifically need to set the visible range here -- by default it is // set in UpdateVisibleRange which however uses the viewdata, which is // completely irrelevant for tiled rendering. commit b7a71cc225cd229e2bce98046b0aa6a342f10cb3 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Thu Jul 3 14:46:32 2014 +0200 Use logic units for visible-cells determination. This eliminates a bunch of LogicToPixel conversions, and also means that tiles starting other than the origin are correctly processed (as LogicToPixel run on a rectangle will also move that rectangle depending on the origin set in the output device). Change-Id: I42903fe23ad5f6baa1d5276d5dcc7ee038bd27cf diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index e752559..34e085b 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -341,46 +341,44 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev ) bIsInPaint = true; - Rectangle aPixRect = pOutDev->LogicToPixel( rRect ); - SCCOL nX1 = pViewData->GetPosX(eHWhich); SCROW nY1 = pViewData->GetPosY(eVWhich); SCTAB nTab = pViewData->GetTabNo(); - Rectangle aMirroredPixel = aPixRect; + Rectangle aMirroredRect = rRect; 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 = PixelToLogic(GetSizePixel()).Width(); + aMirroredRect.Left() = nWidth - 1 - rRect.Right(); + aMirroredRect.Right() = nWidth - 1 - rRect.Left(); } - long nScrX = pOutDev->LogicToPixel( Point( pDoc->GetColWidth( nX1, nTab ), 0 ) ).getX();/*ScViewData::ToPixel( pDoc->GetColWidth( nX1, nTab ), nPPTX );*/ - while ( nScrX <= aMirroredPixel.Left() && nX1 < MAXCOL ) + long nScrX = pDoc->GetColWidth( nX1, nTab ); + while ( nScrX <= aMirroredRect.Left() && nX1 < MAXCOL ) { ++nX1; - nScrX += pOutDev->LogicToPixel( Point( pDoc->GetColWidth( nX1, nTab ), 0 ) ).getX(); + nScrX += pDoc->GetColWidth( nX1, nTab ); } SCCOL nX2 = nX1; - while ( nScrX <= aMirroredPixel.Right() && nX2 < MAXCOL ) + while ( nScrX <= aMirroredRect.Right() && nX2 < MAXCOL ) { ++nX2; - nScrX += pOutDev->LogicToPixel( Point( pDoc->GetColWidth( nX2, nTab ), 0 ) ).getX(); + nScrX += pDoc->GetColWidth( nX2, nTab ); } long nScrY = 0; - while ( nScrY < aPixRect.Top() && nY1 < MAXROW ) + while ( nScrY < rRect.Top() && nY1 < MAXROW ) { ++nY1; - nScrY += pOutDev->LogicToPixel( Point( 0, pDoc->GetRowHeight( nY1, nTab ) ) ).getY(); + nScrY += pDoc->GetRowHeight( nY1, nTab ); } SCROW nY2 = nY1; - while ( nScrY <= aPixRect.Bottom() && nY2 < MAXROW ) + while ( nScrY <= rRect.Bottom() && nY2 < MAXROW ) { ++nY2; - nScrY += pOutDev->LogicToPixel( Point( 0, pDoc->GetRowHeight( nY2, nTab ) ) ).getY(); + nScrY += pDoc->GetRowHeight( nY2, nTab ); } // We specifically need to set the visible range here -- by default it is commit df080a9ca216696219f3f88f8f5430e51d139f25 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Thu Jul 3 14:43:28 2014 +0200 Scale the origin for the Draw Layer (Calc Tiled Rendering). Since we're changing units, we also need to scale the origin by the correct amount. Change-Id: Ie0563376e8fa56f20c30da4fe3cc50546f18e84f diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index a0ba523..e752559 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -623,7 +623,9 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod // define drawing layer map mode and paint rectangle MapMode aDrawMode = pOutDev->GetMapMode(); + Point aOrigin = aDrawMode.GetOrigin(); aDrawMode.SetMapUnit( MAP_100TH_MM ); + aDrawMode.SetOrigin( (aOrigin * 2540l) / 1440l ); Rectangle aDrawingRectLogic; { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits