sc/inc/document.hxx | 5 - sc/source/core/data/fillinfo.cxx | 49 ++++++----- sc/source/ui/view/gridwin.cxx | 5 - sc/source/ui/view/gridwin4.cxx | 47 +++++++--- sc/source/ui/view/printfun.cxx | 12 ++ sc/source/ui/view/viewdata.cxx | 169 +++++++++++++++++++++++++-------------- 6 files changed, 191 insertions(+), 96 deletions(-)
New commits: commit 48df6684d55f1565cd107638ef9ccab96150ce72 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Tue Sep 30 15:28:36 2014 +0100 TODO: printfun needs fixing (see previous commit). We don't need this for tiled rendering for now though. Change-Id: Iac9ed2a4327840ac0af00eb1903484e127fac2c8 diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index e78545a..1d68535 100644 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -493,7 +493,9 @@ void ScPrintFunc::DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double /* nPr ScTableInfo aTabInfo; pDoc->FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab, - nScaleX, nScaleY, false, bFormula ); + nScaleX, nScaleY, + pDev, MapMode(), // TODO: fix this -- use pViewData if possible, otherwise? + false, bFormula ); lcl_HidePrint( aTabInfo, nX1, nX2 ); if (bEmbed) @@ -1337,7 +1339,9 @@ void ScPrintFunc::DrawBorder( long nScrX, long nScrY, long nScrW, long nScrH, ScTableInfo aTabInfo; pBorderDoc->FillInfo( aTabInfo, 0,0, 0,0, 0, - nScaleX, nScaleY, false, false ); + nScaleX, nScaleY, + pDev, MapMode(), // TODO: same as above + false, false ); OSL_ENSURE(aTabInfo.mnArrCount,"nArrCount == 0"); aTabInfo.mpRowInfo[1].nHeight = (sal_uInt16) nEffHeight; @@ -1553,7 +1557,9 @@ void ScPrintFunc::PrintArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScTableInfo aTabInfo; pDoc->FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nPrintTab, - nScaleX, nScaleY, true, aTableParam.bFormulas ); + nScaleX, nScaleY, + pDev, MapMode(), // TODO: same here + true, aTableParam.bFormulas ); lcl_HidePrint( aTabInfo, nX1, nX2 ); if (bEmbed) commit de11617acda45ec49562f7793e0b7b1dabc0b43c Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Tue Sep 30 15:28:03 2014 +0100 Use twips internally for FillInfo too. Otherwise errors sum up leading to tile-mismatches for tiled rendering. Change-Id: I5328771a2d7c284870bb028b53fe69a61e00ba6d diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 9c462d7..8fa9b35 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -20,6 +20,7 @@ #ifndef INCLUDED_SC_INC_DOCUMENT_HXX #define INCLUDED_SC_INC_DOCUMENT_HXX +#include <vcl/mapmod.hxx> #include <vcl/prntypes.hxx> #include <vcl/timer.hxx> #include <com/sun/star/uno/Reference.hxx> @@ -1668,7 +1669,9 @@ public: void FillInfo( ScTableInfo& rTabInfo, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, - SCTAB nTab, double fColScale, double fRowScale, bool bPageMode, bool bFormulaMode, + SCTAB nTab, double fColScale, double fRowScale, + const OutputDevice* pOutDev, const MapMode& rMapMode, + bool bPageMode, bool bFormulaMode, const ScMarkData* pMarkData = NULL ); SC_DLLPUBLIC SvNumberFormatter* GetFormatTable() const; diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index 3688412..b3b0a42 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -195,7 +195,9 @@ public: void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, - SCTAB nTab, double fColScale, double fRowScale, bool bPageMode, bool bFormulaMode, + SCTAB nTab, double fColScale, double fRowScale, + const OutputDevice* pOutDev, const MapMode& rMapMode, + bool bPageMode, bool bFormulaMode, const ScMarkData* pMarkData ) { OSL_ENSURE( maTabs[nTab], "Table does not exist" ); @@ -258,6 +260,7 @@ void ScDocument::FillInfo( SCROW nYExtra = nRow2+1; sal_uInt16 nDocHeight = ScGlobal::nStdRowHeight; SCROW nDocHeightEndRow = -1; + long nPosYTwips = 0; for (nSignedY=((SCsROW)nRow1)-1; nSignedY<=(SCsROW)nYExtra; nSignedY++) { if (nSignedY >= 0) @@ -278,7 +281,14 @@ void ScDocument::FillInfo( RowInfo* pThisRowInfo = &pRowInfo[nArrRow]; pThisRowInfo->pCellInfo = NULL; // wird unten belegt - sal_uInt16 nHeight = (sal_uInt16) ( nDocHeight * fRowScale ); + const long nPosStartTwips = nPosYTwips; + nPosYTwips += nDocHeight; + + sal_uInt16 nHeight = + pOutDev->LogicToPixel( Point( 0, nPosYTwips ), + rMapMode ).getY() - + pOutDev->LogicToPixel( Point( 0, nPosStartTwips ), + rMapMode ).getY(); if (!nHeight) nHeight = 1; @@ -386,27 +396,14 @@ void ScDocument::FillInfo( } } - for (nArrCol=nCol2+3; nArrCol<=nRotMax+2; nArrCol++) // restliche Breiten eintragen - { - nX = nArrCol-1; - if ( ValidCol(nX) ) - { - if (!ColHidden(nX, nTab)) - { - sal_uInt16 nThisWidth = (sal_uInt16) (GetColWidth( nX, nTab ) * fColScale); - if (!nThisWidth) - nThisWidth = 1; - - pRowInfo[0].pCellInfo[nArrCol].nWidth = nThisWidth; - } - } - } ScConditionalFormatList* pCondFormList = GetCondFormList(nTab); if(pCondFormList) pCondFormList->startRendering(); - for (nArrCol=0; nArrCol<=nCol2+2; nArrCol++) // links & rechts + 1 + long nPosXTwips = 0; + + for (nArrCol=0; nArrCol<=nRotMax+2; nArrCol++) // links & rechts + 1 { nX = (nArrCol>0) ? nArrCol-1 : MAXCOL+1; // negativ -> ungueltig @@ -418,11 +415,21 @@ void ScDocument::FillInfo( // TODO: Optimize this loop. if (!ColHidden(nX, nTab)) { - sal_uInt16 nThisWidth = (sal_uInt16) (GetColWidth( nX, nTab ) * fColScale); - if (!nThisWidth) + const long nPosStartTwips = nPosXTwips; + nPosXTwips += GetColWidth( nX, nTab ); + + sal_uInt16 nThisWidth = + pOutDev->LogicToPixel( Point( nPosXTwips, 0 ), + rMapMode ).getX() - + pOutDev->LogicToPixel( Point( nPosStartTwips, 0 ), + rMapMode ).getX(); + if ( nThisWidth == 0) nThisWidth = 1; - pRowInfo[0].pCellInfo[nArrCol].nWidth = nThisWidth; //! dies sollte reichen + pRowInfo[0].pCellInfo[nArrCol].nWidth = nThisWidth; + + if (nArrCol > nCol2+2) + break; // Remaining information isn't needed ScColumn* pThisCol = &maTabs[nTab]->aCol[nX]; // Spalten-Daten diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 4d5ad0a..275a10d 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -4623,7 +4623,10 @@ void ScGridWindow::UpdateFormulas() double nPPTY = pViewData->GetPPTY(); ScTableInfo aTabInfo; - rDoc.FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab, nPPTX, nPPTY, false, false ); + rDoc.FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab, + nPPTX, nPPTY, + this, pViewData->GetPaintMapMode(), + false, false ); Fraction aZoomX = pViewData->GetZoomX(); Fraction aZoomY = pViewData->GetZoomY(); diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index b8d36f9..302bcee 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -553,8 +553,10 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod ScTableInfo aTabInfo; rDoc.FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab, - nPPTX, nPPTY, false, bFormulaMode, - &pViewData->GetMarkData() ); + nPPTX, nPPTY, + this, pViewData->GetPaintMapMode(), + false, bFormulaMode, + &pViewData->GetMarkData() ); Fraction aZoomX = pViewData->GetZoomX(); Fraction aZoomY = pViewData->GetZoomY(); commit 50933a27ca77d753d80b1bf47e2adc30b0e655e5 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Tue Sep 30 15:24:25 2014 +0100 Adjust MapModes for gridwin tiled rendering. Change-Id: I8d31521d6b22f375c6de413f2070746f4758a431 diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 8816e64..b8d36f9 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -643,8 +643,21 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod bEditMode = false; } + // For tiled rendering we have already prepared the pixel map mode in PaintTile, and need + // to make sure that we don't overwrite the origin (however for normal rendering + // we specifically need to make sure that we do set this mode). + const MapMode aPixelMode = (pOutDev == this ) ? MapMode(MAP_PIXEL) : pOutDev->GetMapMode(); + + // define drawing layer map mode and paint rectangle - const MapMode aDrawMode = GetDrawMapMode(); + MapMode aDrawModeInitial = GetDrawMapMode(); + if ( pOutDev != this ) + { + aDrawModeInitial.SetOrigin( Point() ); + aDrawModeInitial.SetOrigin( pOutDev->PixelToLogic( aPixelMode.GetOrigin(), + aDrawModeInitial ) ); + } + const MapMode aDrawMode = aDrawModeInitial; Rectangle aDrawingRectLogic; { @@ -711,7 +724,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod { // save MapMode and set to pixel MapMode aCurrentMapMode(pContentDev->GetMapMode()); - pContentDev->SetMapMode(MAP_PIXEL); + pContentDev->SetMapMode(aPixelMode); Rectangle aPixRect = Rectangle( Point(), GetOutputSizePixel() ); pContentDev->SetFillColor( rColorCfg.GetColorValue(svtools::APPBACKGROUND).nColor ); @@ -748,7 +761,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod if ( rDoc.HasBackgroundDraw( nTab, aDrawingRectLogic ) ) { - pContentDev->SetMapMode(MAP_PIXEL); + pContentDev->SetMapMode(aPixelMode); aOutputData.DrawClear(); // Drawing Hintergrund @@ -759,7 +772,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod else aOutputData.SetSolidBackground(true); - pContentDev->SetMapMode(MAP_PIXEL); + pContentDev->SetMapMode(aPixelMode); aOutputData.DrawDocumentBackground(); if ( bGridFirst && ( bGrid || bPage ) ) @@ -792,7 +805,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod if ( bLogicText ) aOutputData.DrawStrings(true); // in logic MapMode if bTextWysiwyg is set aOutputData.DrawEdit(true); - pContentDev->SetMapMode(MAP_PIXEL); + pContentDev->SetMapMode(aPixelMode); // Autofilter- und Pivot-Buttons @@ -854,7 +867,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod } } - pContentDev->SetMapMode(MAP_PIXEL); + pContentDev->SetMapMode(aPixelMode); if ( pViewData->IsRefMode() && nTab >= pViewData->GetRefStartZ() && nTab <= pViewData->GetRefEndZ() ) { @@ -915,7 +928,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod if ( bEditMode && (pViewData->GetRefTabNo() == pViewData->GetTabNo()) ) { //! use pContentDev for EditView? - SetMapMode(MAP_PIXEL); + SetMapMode(aPixelMode); SCCOL nCol1 = pViewData->GetEditStartCol(); SCROW nRow1 = pViewData->GetEditStartRow(); SCCOL nCol2 = pViewData->GetEditEndCol(); @@ -931,7 +944,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod SetMapMode(pViewData->GetLogicMode()); pEditView->Paint( pOutDev->PixelToLogic( Rectangle( Point( nScrX, nScrY ), Size( aOutputData.GetScrW(), aOutputData.GetScrH() ) ) ) ); - SetMapMode(MAP_PIXEL); + SetMapMode(aPixelMode); } if (pViewData->HasEditView(eWhich)) commit c03104e7e62d8ec9cfe3ee05fa9824b46260f8d6 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Tue Sep 30 15:22:48 2014 +0100 Don't abort rendering if Android window 'minimized'. This simply has no relevance to tiled rendering. Change-Id: Iee348cf6792d83d364c33de81415a7cbe0be6a47 diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index dd4ea95..8816e64 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -456,7 +456,13 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod ScModule* pScMod = SC_MOD(); bool bTextWysiwyg = pScMod->GetInputOptions().GetTextWysiwyg(); - if (pViewData->IsMinimized()) + // For tiled rendering on Android (but NOT on desktop) IsMinimized returns + // false (for reasons I do not yet understand), hence for now we disable + // this check when we are doing tiled-rendering. However presumably VCL + // shouldn't be calling Paint (and thus Draw) in any case when the window + // isn't visible, so it's possible that this check is completely bogus + // anyway? + if ( (pOutDev == this) && ( pViewData->IsMinimized() ) ) return; PutInOrder( nX1, nX2 ); commit c08aed81936e338dc82558014328ab19f7361a0f Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Tue Sep 30 15:21:42 2014 +0100 We want to keep nPPTX/Y for our old scaling. Change-Id: Ia10baf8eebeb92c421066a392387a1ad71e56ce9 diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index c61b427..683bb6c 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -2179,6 +2179,43 @@ void ScViewData::CalcPPT() maPaintMapMode.SetScaleX( aScaleX ); maPaintMapMode.SetScaleY( GetZoomY()); + + nPPTX = ScGlobal::nScreenPPTX * (double) GetZoomX(); + if (pDocShell) + nPPTX = nPPTX / (double) pDocShell->GetOutputFactor(); // Faktor ist Drucker zu Bildschirm + nPPTY = ScGlobal::nScreenPPTY * (double) GetZoomY(); + + // if detective objects are present, + // try to adjust horizontal scale so the most common column width has minimal rounding errors, + // to avoid differences between cell and drawing layer output + + if ( pDoc && pDoc->HasDetectiveObjects(nTabNo) ) + { + SCCOL nEndCol = 0; + SCROW nDummy = 0; + pDoc->GetTableArea( nTabNo, nEndCol, nDummy ); + if (nEndCol<20) + nEndCol = 20; // same end position as when determining draw scale + + sal_uInt16 nTwips = pDoc->GetCommonWidth( nEndCol, nTabNo ); + if ( nTwips ) + { + double fOriginal = nTwips * nPPTX; + if ( fOriginal < static_cast<double>(nEndCol) ) + { + // if one column is smaller than the column count, + // rounding errors are likely to add up to a whole column. + + double fRounded = ::rtl::math::approxFloor( fOriginal + 0.5 ); + if ( fRounded > 0.0 ) + { + double fScale = fRounded / fOriginal + 1E-6; + if ( fScale >= 0.9 && fScale <= 1.1 ) + nPPTX *= fScale; + } + } + } + } } #define SC_OLD_TABSEP '/' commit b0b91ebb937d90fc6245dc6cd649674e01a83156 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Tue Sep 30 15:20:53 2014 +0100 Remove incorrect fudge factor. Change-Id: I3a8d2b2ca1f90a07bd9fffd9e33f59b23671569c diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 4281693..dd4ea95 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -965,13 +965,13 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice, // calculation now, rather than after another dimension conversion, // to minimise errors. // TODO: width wise we need the print scaling compensation stuff? - Fraction scaleX = Fraction( 100*nOutputWidth, 96*96 ) * Fraction(1440L) / + Fraction scaleX = Fraction( nOutputWidth, 96 ) * Fraction(1440L) / Fraction( nTileWidth); if ( pViewData->GetDocShell() ) { scaleX *= pViewData->GetDocShell()->GetOutputFactor(); } - Fraction scaleY = Fraction( 100*nOutputHeight, 96*96 ) * Fraction(1440L) / + Fraction scaleY = Fraction( nOutputHeight, 96 ) * Fraction(1440L) / Fraction( nTileHeight); rDevice.SetOutputSizePixel( Size( nOutputWidth, nOutputHeight ) ); diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index b86dc61..c61b427 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -2171,14 +2171,14 @@ void ScViewData::CalcPPT() { maPaintMapMode.SetMapUnit( MAP_TWIP ); - Fraction aScaleX = GetZoomX() * Fraction(0.96); + Fraction aScaleX = GetZoomX(); if ( pDocShell ) { aScaleX /= pDocShell->GetOutputFactor(); } maPaintMapMode.SetScaleX( aScaleX ); - maPaintMapMode.SetScaleY( GetZoomY() * Fraction(0.96) ); + maPaintMapMode.SetScaleY( GetZoomY()); } #define SC_OLD_TABSEP '/' commit 49092fbd2ecd4b8103d9893c25800511f85c573b Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Tue Sep 30 15:20:07 2014 +0100 ScreenPos calculations in twips too. Change-Id: Ibc45f414a56e3c4cdf6c7f384d561938382c1653 diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index c061ffb0..b86dc61 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -1974,17 +1974,22 @@ void ScViewData::RecalcPixPos() // after zoom changes { for (sal_uInt16 eWhich=0; eWhich<2; eWhich++) { - long nPixPosX = 0; + long nPosXTwips = 0; SCCOL nPosX = pThisTab->nPosX[eWhich]; for (SCCOL i=0; i<nPosX; i++) - nPixPosX -= ToPixel(pDoc->GetColWidth(i,nTabNo), nPPTX); - pThisTab->nPixPosX[eWhich] = nPixPosX; + nPosXTwips += pDoc->GetColWidth(i,nTabNo); - long nPixPosY = 0; - SCROW nPosY = pThisTab->nPosY[eWhich]; - for (SCROW j=0; j<nPosY; j++) - nPixPosY -= ToPixel(pDoc->GetRowHeight(j,nTabNo), nPPTY); - pThisTab->nPixPosY[eWhich] = nPixPosY; + long nPosYTwips = 0; + SCCOL nPosY = pThisTab->nPosY[eWhich]; + for (SCCOL i=0; i<nPosY; i++) + nPosYTwips += pDoc->GetRowHeight(i,nTabNo); + + Point aPosTwips = Point( nPosXTwips, nPosYTwips ); + Point aPosPix = + Application::GetDefaultDevice()->LogicToPixel( aPosTwips, + maPaintMapMode ); + pThisTab->nPixPosX[eWhich] = aPosPix.getX(); + pThisTab->nPixPosY[eWhich] = aPosPix.getY(); } } @@ -2005,10 +2010,8 @@ void ScViewData::SetScreen( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) { SCCOL nCol; SCROW nRow; - sal_uInt16 nTSize; - long nSizePix; - long nScrPosX = 0; - long nScrPosY = 0; + long nScrPosXTwips = 0; + long nScrPosYTwips = 0; SetActivePart( SC_SPLIT_BOTTOMLEFT ); SetPosX( SC_SPLIT_LEFT, nCol1 ); @@ -2016,25 +2019,20 @@ void ScViewData::SetScreen( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) for (nCol=nCol1; nCol<=nCol2; nCol++) { - nTSize = pDoc->GetColWidth( nCol, nTabNo ); - if (nTSize) - { - nSizePix = ToPixel( nTSize, nPPTX ); - nScrPosX += (sal_uInt16) nSizePix; - } + nScrPosXTwips += pDoc->GetColWidth( nCol, nTabNo ); } for (nRow=nRow1; nRow<=nRow2; nRow++) { - nTSize = pDoc->GetRowHeight( nRow, nTabNo ); - if (nTSize) - { - nSizePix = ToPixel( nTSize, nPPTY ); - nScrPosY += (sal_uInt16) nSizePix; - } + nScrPosYTwips = pDoc->GetRowHeight( nRow, nTabNo ); } - aScrSize = Size( nScrPosX, nScrPosY ); + Size aScrSizeTwips = Size( nScrPosXTwips, nScrPosYTwips ); + + aScrSize = + Application::GetDefaultDevice()->PixelToLogic( aScrSizeTwips, + maPaintMapMode ); + } void ScViewData::SetScreenPos( const Point& rVisAreaStart ) commit f4c916021bf2552bc9bb1165e5cc08672db27dbc Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Tue Sep 30 15:19:30 2014 +0100 Use twips internally for GetScrPos. Change-Id: I48c674815c95f73722a427fd2d8d9a3dca9b3a6c diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 6db5e56..c061ffb0 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -1532,55 +1532,56 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, aScrSize.Height() = pView->GetGridHeight(eWhichY); } + const Size aScrSizeTwips = + Application::GetDefaultDevice()->PixelToLogic( aScrSize, maPaintMapMode ); + sal_uInt16 nTSize; SCCOL nPosX = GetPosX(eWhichX); SCCOL nX; - long nScrPosX=0; + long nScrPosXTwips=0; if (nWhereX >= nPosX) - for (nX=nPosX; nX<nWhereX && (bAllowNeg || nScrPosX<=aScrSize.Width()); nX++) + { + for (nX=nPosX; nX<nWhereX && (bAllowNeg || nScrPosXTwips<=aScrSizeTwips.Width()); nX++) { if ( nX > MAXCOL ) - nScrPosX = 65535; + { + nScrPosXTwips = LONG_MAX; + } else { - nTSize = pDoc->GetColWidth( nX, nTabNo ); - if (nTSize) - { - long nSizeXPix = ToPixel( nTSize, nPPTX ); - nScrPosX += nSizeXPix; - } + nScrPosXTwips += pDoc->GetColWidth( nX, nTabNo ); } } + } else if (bAllowNeg) + { for (nX=nPosX; nX>nWhereX;) { --nX; - nTSize = pDoc->GetColWidth( nX, nTabNo ); - if (nTSize) - { - long nSizeXPix = ToPixel( nTSize, nPPTX ); - nScrPosX -= nSizeXPix; - } + nScrPosXTwips -= pDoc->GetColWidth( nX, nTabNo ); } + } SCROW nPosY = GetPosY(eWhichY); SCROW nY; - long nScrPosY=0; + long nScrPosYTwips=0; if (nWhereY >= nPosY) - for (nY=nPosY; nY<nWhereY && (bAllowNeg || nScrPosY<=aScrSize.Height()); nY++) + { + for (nY=nPosY; nY<nWhereY && (bAllowNeg || nScrPosYTwips<=aScrSizeTwips.Height()); nY++) { if ( nY > MAXROW ) - nScrPosY = 65535; + { + nScrPosYTwips = LONG_MAX; + } else { nTSize = pDoc->GetRowHeight( nY, nTabNo ); if (nTSize) { - long nSizeYPix = ToPixel( nTSize, nPPTY ); - nScrPosY += nSizeYPix; + nScrPosYTwips += nTSize; } else if ( nY < MAXROW ) { @@ -1593,27 +1594,46 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, } } } + } else if (bAllowNeg) + { for (nY=nPosY; nY>nWhereY;) { --nY; - nTSize = pDoc->GetRowHeight( nY, nTabNo ); - if (nTSize) - { - long nSizeYPix = ToPixel( nTSize, nPPTY ); - nScrPosY -= nSizeYPix; - } + nScrPosYTwips -= pDoc->GetRowHeight( nY, nTabNo ); } + } + + Point aScreenStartTwips = Point( maTabData[ nTabNo ]->nTPosX[ eWhichX ], + maTabData[ nTabNo ]->nTPosY[ eWhichY ] ); + + Point aPosScrRelative = Point( nScrPosXTwips, nScrPosYTwips ); + Point aPosScrAbsolute = aScreenStartTwips + aPosScrRelative; + + Point aScrPosPix = + Application::GetDefaultDevice()->LogicToPixel( aPosScrAbsolute, maPaintMapMode ) - + Application::GetDefaultDevice()->LogicToPixel( aScreenStartTwips, maPaintMapMode ); + + // Point aScrPosPix = + // Application::GetDefaultDevice()->LogicToPixel( aPosScrRelative, maPaintMapMode ); if ( pDoc->IsLayoutRTL( nTabNo ) ) { // mirror horizontal position - nScrPosX = aScrSize.Width() - 1 - nScrPosX; + aScrPosPix.X() = aScrSize.Width() - 1 - aScrPosPix.getX(); + } + + if ( nScrPosXTwips == LONG_MAX ) + { + aScrPosPix.X() = 32767; + } + if ( nScrPosYTwips == LONG_MAX ) + { + aScrPosPix.Y() = 32767; } - if (nScrPosX > 32767) nScrPosX=32767; - if (nScrPosY > 32767) nScrPosY=32767; - return Point( nScrPosX, nScrPosY ); + + return aScrPosPix; } // Number of cells on a screen _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits