summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej.hunt@collabora.com>2014-08-27 14:48:47 +0200
committerAndrzej Hunt <andrzej.hunt@collabora.com>2014-08-30 21:37:13 +0200
commit88c39c1fed1928bcd5ebed34c6c02dea352b9612 (patch)
treefcd1a6453f4204e618059e24a4e4c40eab74e42b
parent7e2080df792b1734268aa623f32dd33b2606800c (diff)
Replace AddPixelsWhile with Twips equivalent.
Change-Id: I7bd2125ac839278406133c116201a0474d84d4d4
-rw-r--r--sc/source/ui/inc/viewdata.hxx10
-rw-r--r--sc/source/ui/view/gridwin4.cxx8
-rw-r--r--sc/source/ui/view/viewdata.cxx59
3 files changed, 41 insertions, 36 deletions
diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
index 7c583b3bad0a..d1fae7dad75b 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -495,18 +495,16 @@ public:
segments. Upon return rPosY is the last row evaluated <= nEndRow, rScrY
may be > nEndPixels!
*/
- static void AddPixelsWhile( long & rScrY, long nEndPixels,
- SCROW & rPosY, SCROW nEndRow, double nPPTY,
- const ScDocument * pDoc, SCTAB nTabNo );
+ void AddTwipsWhile( long & rScrYTwips, long nEndPixels,
+ SCROW & rPosY, SCROW nEndRow ) const;
/** while (rScrY <= nEndPixels && rPosY >= nStartRow) add pixels of row
heights converted with nPPTY to rScrY, optimized for row height
segments. Upon return rPosY is the last row evaluated >= nStartRow,
rScrY may be > nEndPixels!
*/
- static void AddPixelsWhileBackward( long & rScrY, long nEndPixels,
- SCROW & rPosY, SCROW nStartRow, double nPPTY,
- const ScDocument * pDoc, SCTAB nTabNo );
+ void AddTwipsWhileBackward( long & rScrYTwips, long nEndPixels,
+ SCROW & rPosY, SCROW nStartRow ) const;
};
inline long ScViewData::ToPixel( sal_uInt16 nTwips, double nFactor )
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index b446ffef02b5..413aec376394 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -369,12 +369,16 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
}
long nScrY = 0;
- ScViewData::AddPixelsWhile( nScrY, aPixRect.Top(), nY1, MAXROW, nPPTY, pDoc, nTab);
+ pViewData->AddTwipsWhile( nScrY,
+ pViewData->LogicToPixelVertical( aLogicRect.Top() ),
+ nY1, MAXROW );
SCROW nY2 = nY1;
if (nScrY <= aPixRect.Bottom() && nY2 < MAXROW)
{
++nY2;
- ScViewData::AddPixelsWhile( nScrY, aPixRect.Bottom(), nY2, MAXROW, nPPTY, pDoc, nTab);
+ pViewData->AddTwipsWhile( nScrY,
+ pViewData->LogicToPixelVertical( aLogicRect.Bottom() ),
+ nY2, MAXROW );
}
// We specifically need to set the visible range here -- by default it is
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 672dbc45d33f..623c8fe55f84 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -1677,7 +1677,7 @@ SCROW ScViewData::CellsAtY( SCsROW nPosY, SCsROW nDir, ScVSplitPos eWhichY, sal_
// forward
nY = nPosY;
long nScrPosY = 0;
- AddPixelsWhile( nScrPosY, nScrSizeY, nY, MAXROW, nPPTY, pDoc, nTabNo);
+ AddTwipsWhile( nScrPosY, nScrSizeY, nY, MAXROW );
// Original loop ended on last evaluated +1 or if that was MAXROW even
// on MAXROW+2.
nY += (nY == MAXROW ? 2 : 1);
@@ -1688,7 +1688,7 @@ SCROW ScViewData::CellsAtY( SCsROW nPosY, SCsROW nDir, ScVSplitPos eWhichY, sal_
// backward
nY = nPosY-1;
long nScrPosY = 0;
- AddPixelsWhileBackward( nScrPosY, nScrSizeY, nY, 0, nPPTY, pDoc, nTabNo);
+ AddTwipsWhileBackward( nScrPosY, nScrSizeY, nY, 0 );
// Original loop ended on last evaluated -1 or if that was 0 even on
// -2.
nY -= (nY == 0 ? 2 : 1);
@@ -1799,7 +1799,9 @@ bool ScViewData::GetPosFromPixel( long nClickX, long nClickY, ScSplitPos eWhich,
}
if (nClickY > 0)
- AddPixelsWhile( nScrY, nClickY, rPosY, MAXROW, nPPTY, pDoc, nTabNo );
+ {
+ AddTwipsWhile( aScrPosTwips.Y(), nClickY, rPosY, MAXROW );
+ }
else
{
/* TODO: could need some "SubPixelsWhileBackward" method */
@@ -3024,11 +3026,13 @@ void ScViewData::SetRefEnd( SCCOL nNewX, SCROW nNewY, SCTAB nNewZ )
nRefEndX = nNewX; nRefEndY = nNewY; nRefEndZ = nNewZ;
}
-void ScViewData::AddPixelsWhile( long & rScrY, long nEndPixels, SCROW & rPosY,
- SCROW nEndRow, double nPPTY, const ScDocument * pDoc, SCTAB nTabNo )
+void ScViewData::AddTwipsWhile( long & rScrYTwips, long nEndPix,
+ SCROW & rPosY, SCROW nEndRow ) const
{
SCROW nRow = rPosY;
- while (rScrY <= nEndPixels && nRow <= nEndRow)
+ const long nEndTwips = PixelToLogicVertical( nEndPix );
+
+ while ( rScrYTwips <= nEndTwips && nRow <= nEndRow )
{
SCROW nHeightEndRow;
sal_uInt16 nHeight = pDoc->GetRowHeight( nRow, nTabNo, NULL, &nHeightEndRow);
@@ -3039,21 +3043,20 @@ void ScViewData::AddPixelsWhile( long & rScrY, long nEndPixels, SCROW & rPosY,
else
{
SCROW nRows = nHeightEndRow - nRow + 1;
- sal_Int64 nPixel = ToPixel( nHeight, nPPTY);
- sal_Int64 nAdd = nPixel * nRows;
- if (nAdd + rScrY > nEndPixels)
+ sal_Int64 nAdd = nHeight * nRows;
+ if ( nAdd + rScrYTwips > nEndTwips )
{
- sal_Int64 nDiff = rScrY + nAdd - nEndPixels;
- nRows -= static_cast<SCROW>(nDiff / nPixel);
- nAdd = nPixel * nRows;
+ sal_Int64 nDiff = rScrYTwips + nAdd - nEndTwips;
+ nRows -= static_cast<SCROW>( nDiff / nHeight );
+ nAdd = nHeight * nRows;
// We're looking for a value that satisfies loop condition.
- if (nAdd + rScrY <= nEndPixels)
+ if ( nAdd + rScrYTwips <= nEndTwips )
{
++nRows;
- nAdd += nPixel;
+ nAdd += nHeight;
}
}
- rScrY += static_cast<long>(nAdd);
+ rScrYTwips += static_cast<long>(nAdd);
nRow += nRows;
}
}
@@ -3062,12 +3065,13 @@ void ScViewData::AddPixelsWhile( long & rScrY, long nEndPixels, SCROW & rPosY,
rPosY = nRow;
}
-void ScViewData::AddPixelsWhileBackward( long & rScrY, long nEndPixels,
- SCROW & rPosY, SCROW nStartRow, double nPPTY, const ScDocument * pDoc,
- SCTAB nTabNo )
+void ScViewData::AddTwipsWhileBackward( long & rScrYTwips, long nEndPixels,
+ SCROW & rPosY, SCROW nStartRow ) const
{
+ // TODO: update this function to reality
SCROW nRow = rPosY;
- while (rScrY <= nEndPixels && nRow >= nStartRow)
+ long nEndTwips = PixelToLogicVertical( nEndPixels );
+ while ( rScrYTwips <= nEndTwips && nRow >= nStartRow )
{
SCROW nHeightStartRow;
sal_uInt16 nHeight = pDoc->GetRowHeight( nRow, nTabNo, &nHeightStartRow, NULL);
@@ -3078,21 +3082,20 @@ void ScViewData::AddPixelsWhileBackward( long & rScrY, long nEndPixels,
else
{
SCROW nRows = nRow - nHeightStartRow + 1;
- sal_Int64 nPixel = ToPixel( nHeight, nPPTY);
- sal_Int64 nAdd = nPixel * nRows;
- if (nAdd + rScrY > nEndPixels)
+ sal_Int64 nAdd = nHeight * nRows;
+ if ( nAdd + rScrYTwips > nEndTwips )
{
- sal_Int64 nDiff = nAdd + rScrY - nEndPixels;
- nRows -= static_cast<SCROW>(nDiff / nPixel);
- nAdd = nPixel * nRows;
+ sal_Int64 nDiff = nAdd + rScrYTwips - nEndPixels;
+ nRows -= static_cast<SCROW>( nDiff / nHeight );
+ nAdd = nHeight * nRows;
// We're looking for a value that satisfies loop condition.
- if (nAdd + rScrY <= nEndPixels)
+ if ( nAdd + rScrYTwips <= nEndTwips )
{
++nRows;
- nAdd += nPixel;
+ nAdd += nHeight;
}
}
- rScrY += static_cast<long>(nAdd);
+ rScrYTwips += static_cast<long>(nAdd);
nRow -= nRows;
}
}