[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sc/source
Marco Cecchetti
marco.cecchetti at collabora.com
Tue Apr 18 10:20:20 UTC 2017
sc/source/ui/view/viewdata.cxx | 133 +++++++++++++++++++++++------------------
1 file changed, 76 insertions(+), 57 deletions(-)
New commits:
commit 3526b7c0db27cb8e333d30813b79982873aa4501
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date: Sat Apr 15 11:37:51 2017 +0200
LOK - Calc: Selecting cells to the left/top does not work properly
This patch fix a regression of commit
4b39183c5740067cc31c006214cb24b81ee0f98c "LOK - Calc: make computation
of cell cursor position faster"
The problem occurs when bAllowNeg is false.
At present should be safe, in the LOK case, to assume that
GetPosX(eWhichX) and GetPosY(eWhichX) are always 0.
In the end we could always find the screen position for the left-top
cell position and subtract it from the final screen position values.
Change-Id: I7d4bf24cb57757e7ac05fcde48ade9feec56aba7
Reviewed-on: https://gerrit.libreoffice.org/36562
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index e1e24280e8b9..87a77ad4692d 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -1879,90 +1879,109 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich,
sal_uInt16 nTSize;
bool bIsTiledRendering = comphelper::LibreOfficeKit::isActive();
- SCCOL nPosX = GetPosX(eWhichX);
- SCCOL nX;
- long nScrPosX=0;
- if (bIsTiledRendering)
+ SCCOL nPosX = GetPosX(eWhichX);
+ long nScrPosX = 0;
+
+ if (bAllowNeg || nWhereX >= nPosX)
{
- const auto& rNearest = pThisTab->aWidthHelper.getNearestByIndex(nWhereX - 1);
- nPosX = rNearest.first + 1;
- nScrPosX = rNearest.second;
- }
+ SCROW nStartPosX = nPosX;
+ if (bIsTiledRendering)
+ {
+ OSL_ENSURE(nPosX == 0, "Unsupported case.");
+ const auto& rNearest = pThisTab->aWidthHelper.getNearestByIndex(nWhereX - 1);
+ nStartPosX = rNearest.first + 1;
+ nScrPosX = rNearest.second;
+ }
- if (nWhereX >= nPosX)
- for (nX = nPosX; nX < nWhereX && (bAllowNeg || bIsTiledRendering || nScrPosX <= aScrSize.Width()); nX++)
+ if (nWhereX >= nStartPosX)
{
- if ( nX > MAXCOL )
- nScrPosX = 0x7FFFFFFF;
- else
+ for (SCCOL nX = nStartPosX; nX < nWhereX && (bAllowNeg || bIsTiledRendering || nScrPosX <= aScrSize.Width()); nX++)
{
- nTSize = pDoc->GetColWidth( nX, nTabNo );
- if (nTSize)
+ if ( nX > MAXCOL )
+ nScrPosX = 0x7FFFFFFF;
+ else
{
- long nSizeXPix = ToPixel( nTSize, nPPTX );
- nScrPosX += nSizeXPix;
+ nTSize = pDoc->GetColWidth( nX, nTabNo );
+ if (nTSize)
+ {
+ long nSizeXPix = ToPixel( nTSize, nPPTX );
+ nScrPosX += nSizeXPix;
+ }
}
}
}
- else if (bAllowNeg)
- for (nX=nPosX; nX>nWhereX;)
+ else
{
- --nX;
- nTSize = pDoc->GetColWidth( nX, nTabNo );
- if (nTSize)
+ for (SCCOL nX = nStartPosX; nX > nWhereX;)
{
- long nSizeXPix = ToPixel( nTSize, nPPTX );
- nScrPosX -= nSizeXPix;
+ --nX;
+ nTSize = pDoc->GetColWidth( nX, nTabNo );
+ if (nTSize)
+ {
+ long nSizeXPix = ToPixel( nTSize, nPPTX );
+ nScrPosX -= nSizeXPix;
+ }
}
}
- SCROW nPosY = GetPosY(eWhichY);
- SCROW nY;
+ }
+
+
+ SCROW nPosY = GetPosY(eWhichY);
+ long nScrPosY = 0;
- long nScrPosY=0;
- if (bIsTiledRendering)
+ if (bAllowNeg || nWhereY >= nPosY)
{
- const auto& rNearest = pThisTab->aHeightHelper.getNearestByIndex(nWhereY - 1);
- nPosY = rNearest.first + 1;
- nScrPosY = rNearest.second;
- }
+ SCROW nStartPosY = nPosY;
+ if (bIsTiledRendering)
+ {
+ OSL_ENSURE(nPosY == 0, "Unsupported case.");
+ const auto& rNearest = pThisTab->aHeightHelper.getNearestByIndex(nWhereY - 1);
+ nStartPosY = rNearest.first + 1;
+ nScrPosY = rNearest.second;
+ }
- if (nWhereY >= nPosY)
- for (nY = nPosY; nY < nWhereY && (bAllowNeg || bIsTiledRendering || nScrPosY <= aScrSize.Height()); nY++)
+ if (nWhereY >= nStartPosY)
{
- if ( nY > MAXROW )
- nScrPosY = 0x7FFFFFFF;
- else
+ for (SCROW nY = nStartPosY; nY < nWhereY && (bAllowNeg || bIsTiledRendering || nScrPosY <= aScrSize.Height()); nY++)
{
- nTSize = pDoc->GetRowHeight( nY, nTabNo );
- if (nTSize)
- {
- long nSizeYPix = ToPixel( nTSize, nPPTY );
- nScrPosY += nSizeYPix;
- }
- else if ( nY < MAXROW )
+ if ( nY > MAXROW )
+ nScrPosY = 0x7FFFFFFF;
+ else
{
- // skip multiple hidden rows (forward only for now)
- SCROW nNext = pDoc->FirstVisibleRow(nY + 1, MAXROW, nTabNo);
- if ( nNext > MAXROW )
- nY = MAXROW;
- else
- nY = nNext - 1; // +=nDir advances to next visible row
+ nTSize = pDoc->GetRowHeight( nY, nTabNo );
+ if (nTSize)
+ {
+ long nSizeYPix = ToPixel( nTSize, nPPTY );
+ nScrPosY += nSizeYPix;
+ }
+ else if ( nY < MAXROW )
+ {
+ // skip multiple hidden rows (forward only for now)
+ SCROW nNext = pDoc->FirstVisibleRow(nY + 1, MAXROW, nTabNo);
+ if ( nNext > MAXROW )
+ nY = MAXROW;
+ else
+ nY = nNext - 1; // +=nDir advances to next visible row
+ }
}
}
}
- else if (bAllowNeg)
- for (nY=nPosY; nY>nWhereY;)
+ else
{
- --nY;
- nTSize = pDoc->GetRowHeight( nY, nTabNo );
- if (nTSize)
+ for (SCROW nY = nStartPosY; nY > nWhereY;)
{
- long nSizeYPix = ToPixel( nTSize, nPPTY );
- nScrPosY -= nSizeYPix;
+ --nY;
+ nTSize = pDoc->GetRowHeight( nY, nTabNo );
+ if (nTSize)
+ {
+ long nSizeYPix = ToPixel( nTSize, nPPTY );
+ nScrPosY -= nSizeYPix;
+ }
}
}
+ }
if ( pDoc->IsLayoutRTL( nTabNo ) )
{
More information about the Libreoffice-commits
mailing list