[Libreoffice-commits] core.git: Branch 'feature/calczoom' - 4 commits - comphelper/source desktop/qa desktop/source include/comphelper libreofficekit/qa sc/source
Michael Meeks (via logerrit)
logerrit at kemper.freedesktop.org
Fri Nov 1 17:04:14 UTC 2019
Rebased ref, commits from common ancestor:
commit f86283d41f55ea9d2659664e39ea4af0573a8679
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Fri Nov 1 15:40:43 2019 +0000
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Fri Nov 1 17:03:13 2019 +0000
sc lok: cope with non 100% zoom better.
Do the tile rendering and alignment ourselves. More work required
to get cleaner conversion between view and document twips (view
twips being rounded to produce nice round pixel sizes when
re-converted).
Change-Id: I51edb186cfd2dc434005cc074f4ed8de19c85cb3
diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
index 52da7fba5c5b..24dd5e69a275 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -161,13 +161,15 @@ class ScBoundsProvider
const bool bColumnHeader;
const index_type MAX_INDEX;
+ double mfPPTX;
+ double mfPPTY;
index_type nFirstIndex;
index_type nSecondIndex;
long nFirstPositionPx;
long nSecondPositionPx;
public:
- ScBoundsProvider(ScDocument* pD, SCTAB nT, bool bColumnHeader);
+ ScBoundsProvider(const ScViewData &rView, SCTAB nT, bool bColumnHeader);
void GetStartIndexAndPosition(SCCOL& nIndex, long& nPosition) const;
void GetEndIndexAndPosition(SCCOL& nIndex, long& nPosition) const;
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 9f924931b09b..3a54172c8760 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1098,7 +1098,7 @@ namespace
const auto& rStartNearest = rPositionHelper.getNearestByPosition(nTileStartPosPx);
const auto& rEndNearest = rPositionHelper.getNearestByPosition(nTileEndPosPx);
- ScBoundsProvider aBoundsProvider(pDoc, nTab, bColumnHeader);
+ ScBoundsProvider aBoundsProvider(*pViewData, nTab, bColumnHeader);
aBoundsProvider.Compute(rStartNearest, rEndNearest, nTileStartPosPx, nTileEndPosPx);
aBoundsProvider.GetStartIndexAndPosition(nStartIndex, nStartPosPx); ++nStartIndex;
aBoundsProvider.GetEndIndexAndPosition(nEndIndex, nEndPosPx);
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 807dc27d4993..8d84742368d4 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2495,13 +2495,13 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle)
{
SAL_INFO("sc.lok.header", "Row Header: compute start/end rows.");
long nEndHeightPx = 0;
- long nRectTopPx = rRectangle.Top() / TWIPS_PER_PIXEL;
- long nRectBottomPx = rRectangle.Bottom() / TWIPS_PER_PIXEL;
+ long nRectTopPx = rRectangle.Top() * aViewData.GetPPTX();
+ long nRectBottomPx = rRectangle.Bottom() * aViewData.GetPPTY();
const auto& rTopNearest = aViewData.GetLOKHeightHelper().getNearestByPosition(nRectTopPx);
const auto& rBottomNearest = aViewData.GetLOKHeightHelper().getNearestByPosition(nRectBottomPx);
- ScBoundsProvider aBoundingRowsProvider(pDoc, nTab, /*bColumnHeader: */ false);
+ ScBoundsProvider aBoundingRowsProvider(aViewData, nTab, /*bColumnHeader: */ false);
aBoundingRowsProvider.Compute(rTopNearest, rBottomNearest, nRectTopPx, nRectBottomPx);
aBoundingRowsProvider.EnlargeBy(2);
aBoundingRowsProvider.GetStartIndexAndPosition(nStartRow, nStartHeightPx);
@@ -2591,7 +2591,7 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle)
{
OUString aText = OUString::number(nStartRow + 1);
aBuffer.append("{ \"text\": \"").append(aText).append("\", ");
- aBuffer.append("\"size\": \"").append(OUString::number(nTotalPixels * TWIPS_PER_PIXEL)).append("\", ");
+ aBuffer.append("\"size\": \"").append(OUString::number(nTotalPixels / aViewData.GetPPTX())).append("\", ");
aBuffer.append("\"groupLevels\": \"").append(OUString::number(nRowGroupDepth)).append("\" }");
}
@@ -2603,7 +2603,7 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle)
// nSize will be 0 for hidden rows.
const long nSizePx = lcl_GetRowHeightPx(pDoc, nRow, nTab);
nTotalPixels += nSizePx;
- const long nTotalTwips = nTotalPixels * TWIPS_PER_PIXEL;
+ const long nTotalTwips = nTotalPixels / aViewData.GetPPTY();
if (bRangeHeaderSupport && nRowGroupDepth > 0)
{
@@ -2638,13 +2638,13 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle)
{
SAL_INFO("sc.lok.header", "Column Header: compute start/end columns.");
long nEndWidthPx = 0;
- long nRectLeftPx = rRectangle.Left() / TWIPS_PER_PIXEL;
- long nRectRightPx = rRectangle.Right() / TWIPS_PER_PIXEL;
+ long nRectLeftPx = rRectangle.Left() * aViewData.GetPPTX();
+ long nRectRightPx = rRectangle.Right() * aViewData.GetPPTY();
const auto& rLeftNearest = aViewData.GetLOKWidthHelper().getNearestByPosition(nRectLeftPx);
const auto& rRightNearest = aViewData.GetLOKWidthHelper().getNearestByPosition(nRectRightPx);
- ScBoundsProvider aBoundingColsProvider(pDoc, nTab, /*bColumnHeader: */ true);
+ ScBoundsProvider aBoundingColsProvider(aViewData, nTab, /*bColumnHeader: */ true);
aBoundingColsProvider.Compute(rLeftNearest, rRightNearest, nRectLeftPx, nRectRightPx);
aBoundingColsProvider.EnlargeBy(2);
aBoundingColsProvider.GetStartIndexAndPosition(nStartCol, nStartWidthPx);
@@ -2734,7 +2734,7 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle)
{
OUString aText = OUString::number(nStartCol + 1);
aBuffer.append("{ \"text\": \"").append(aText).append("\", ");
- aBuffer.append("\"size\": \"").append(OUString::number(nTotalPixels * TWIPS_PER_PIXEL)).append("\", ");
+ aBuffer.append("\"size\": \"").append(OUString::number(nTotalPixels / aViewData.GetPPTY())).append("\", ");
aBuffer.append("\"groupLevels\": \"").append(OUString::number(nColGroupDepth)).append("\" }");
}
@@ -2746,7 +2746,7 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle)
// nSize will be 0 for hidden columns.
const long nSizePx = lcl_GetColWidthPx(pDoc, nCol, nTab);
nTotalPixels += nSizePx;
- const long nTotalTwips = nTotalPixels * TWIPS_PER_PIXEL;
+ const long nTotalTwips = nTotalPixels / aViewData.GetPPTY();
if (bRangeHeaderSupport && nColGroupDepth > 0)
{
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 0eb317ff1eca..64b3daed8b39 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -280,11 +280,13 @@ long ScPositionHelper::computePosition(index_type nIndex, const std::function<lo
return nTotalPixels;
}
-ScBoundsProvider::ScBoundsProvider(ScDocument* pD, SCTAB nT, bool bColHeader)
- : pDoc(pD)
+ScBoundsProvider::ScBoundsProvider(const ScViewData &rView, SCTAB nT, bool bColHeader)
+ : pDoc(rView.GetDocument())
, nTab(nT)
, bColumnHeader(bColHeader)
- , MAX_INDEX(bColHeader ? pD->MaxCol() : MAXTILEDROW)
+ , MAX_INDEX(bColHeader ? pDoc->MaxCol() : MAXTILEDROW)
+ , mfPPTX(rView.GetPPTX())
+ , mfPPTY(rView.GetPPTY())
, nFirstIndex(-1)
, nSecondIndex(-1)
, nFirstPositionPx(-1)
@@ -322,7 +324,7 @@ void ScBoundsProvider::GetEndIndexAndPosition(SCROW& nIndex, long& nPosition) co
long ScBoundsProvider::GetSize(index_type nIndex) const
{
const sal_uInt16 nSize = bColumnHeader ? pDoc->GetColWidth(nIndex, nTab) : pDoc->GetRowHeight(nIndex, nTab);
- return ScViewData::ToPixel(nSize, 1.0 / TWIPS_PER_PIXEL);
+ return ScViewData::ToPixel(nSize, bColumnHeader ? mfPPTX : mfPPTY);
}
void ScBoundsProvider::GetIndexAndPos(index_type nNearestIndex, long nNearestPosition,
@@ -1372,10 +1374,9 @@ void ScViewData::SetMaxTiledCol( SCCOL nNewMaxCol )
nNewMaxCol = pDoc->MaxCol();
const SCTAB nTab = GetTabNo();
- ScDocument* pThisDoc = pDoc;
- auto GetColWidthPx = [pThisDoc, nTab](SCCOL nCol) {
- const sal_uInt16 nSize = pThisDoc->GetColWidth(nCol, nTab);
- const long nSizePx = ScViewData::ToPixel(nSize, 1.0 / TWIPS_PER_PIXEL);
+ auto GetColWidthPx = [this, nTab](SCCOL nCol) {
+ const sal_uInt16 nSize = this->pDoc->GetColWidth(nCol, nTab);
+ const long nSizePx = this->ToPixel(nSize, nPPTX);
return nSizePx;
};
@@ -1398,10 +1399,9 @@ void ScViewData::SetMaxTiledRow( SCROW nNewMaxRow )
nNewMaxRow = MAXTILEDROW;
const SCTAB nTab = GetTabNo();
- ScDocument* pThisDoc = pDoc;
- auto GetRowHeightPx = [pThisDoc, nTab](SCROW nRow) {
- const sal_uInt16 nSize = pThisDoc->GetRowHeight(nRow, nTab);
- const long nSizePx = ScViewData::ToPixel(nSize, 1.0 / TWIPS_PER_PIXEL);
+ auto GetRowHeightPx = [this, nTab](SCROW nRow) {
+ const sal_uInt16 nSize = this->pDoc->GetRowHeight(nRow, nTab);
+ const long nSizePx = this->ToPixel(nSize, nPPTY);
return nSizePx;
};
commit 01f29d7f5e81a28545be71626931ac2e5881aef8
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Fri Oct 25 21:16:42 2019 +0100
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Fri Nov 1 17:02:59 2019 +0000
lok: tilebench: implement zoom tests.
Change-Id: Ieffc89b8119c2baf56383ac8b5d3cb54dc9d0d2d
diff --git a/libreofficekit/qa/tilebench/tilebench.cxx b/libreofficekit/qa/tilebench/tilebench.cxx
index fef5271bdf27..f5dccf81affa 100644
--- a/libreofficekit/qa/tilebench/tilebench.cxx
+++ b/libreofficekit/qa/tilebench/tilebench.cxx
@@ -295,6 +295,21 @@ static int diffTiles( const std::vector<unsigned char> &vBase,
return nDifferent;
}
+static std::vector<unsigned char> paintTile( Document *pDocument,
+ long nX, long nY,
+ long const nTilePixelWidth,
+ long const nTilePixelHeight,
+ long const nTileTwipWidth,
+ long const nTileTwipHeight )
+{
+// long e = 0; // tweak if we suspect an overlap / visibility issue.
+// pDocument->setClientVisibleArea( nX - e, nY - e, nTileTwipWidth + e, nTileTwipHeight + e );
+ std::vector<unsigned char> vData( nTilePixelWidth * nTilePixelHeight * 4 );
+ pDocument->paintTile( vData.data(), nTilePixelWidth, nTilePixelHeight,
+ nX, nY, nTileTwipWidth, nTileTwipHeight );
+ return vData;
+}
+
static bool testJoinsAt( Document *pDocument, long nX, long nY,
long const nTilePixelSize,
long const nTileTwipSize )
@@ -306,12 +321,26 @@ static bool testJoinsAt( Document *pDocument, long nX, long nY,
long const nTileTwipWidth = nTileTwipSize;
long const nTileTwipHeight = nTileTwipSize;
- // Get a base image 4x the size
long initPosX = nX * nTileTwipWidth, initPosY = nY * nTileTwipHeight;
- std::vector<unsigned char> vBase( nTilePixelWidth * nTilePixelHeight * 4 * 4 );
- pDocument->paintTile( vBase.data(), nTilePixelWidth * 2, nTilePixelHeight * 2,
- initPosX, initPosY, nTileTwipWidth * 2, nTileTwipHeight * 2 );
+ // Calc has to do significant work on changing zoom ...
+ pDocument->setClientZoom( nTilePixelWidth, nTilePixelHeight,
+ nTileTwipWidth, nTileTwipHeight );
+
+ // Unfortunately without getting this nothing renders ...
+ std::stringstream aForceHeaders;
+ aForceHeaders << ".uno:ViewRowColumnHeaders?x=" << initPosX << "&y=" << initPosY <<
+ "&width=" << (nTileTwipWidth * 2) << "&height=" << (nTileTwipHeight * 2);
+ std::string cmd = aForceHeaders.str();
+ char* pJSON = pDocument->getCommandValues(cmd.c_str());
+ fprintf(stderr, "command: '%s' values '%s'\n", cmd.c_str(), pJSON);
+ free(pJSON);
+
+ // Get a base image 4x the size
+ std::vector<unsigned char> vBase(
+ paintTile(pDocument, initPosX, initPosY,
+ nTilePixelWidth * 2, nTilePixelHeight * 2,
+ nTileTwipWidth * 2, nTileTwipHeight * 2));
const struct {
long X;
@@ -326,11 +355,13 @@ static bool testJoinsAt( Document *pDocument, long nX, long nY,
// Compare each of the 4x tiles with a sub-tile of the larger image
for( auto &rPos : aCompare )
{
- std::vector<unsigned char> vCompare( nTilePixelWidth * nTilePixelHeight * 4 );
- pDocument->paintTile( vCompare.data(), nTilePixelWidth, nTilePixelHeight,
- initPosX + rPos.X * nTileTwipWidth,
- initPosY + rPos.Y * nTileTwipHeight,
- nTileTwipWidth, nTileTwipHeight );
+ std::vector<unsigned char> vCompare(
+ paintTile(pDocument,
+ initPosX + rPos.X * nTileTwipWidth,
+ initPosY + rPos.Y * nTileTwipHeight,
+ nTilePixelWidth, nTilePixelHeight,
+ nTileTwipWidth, nTileTwipHeight));
+
std::vector<unsigned char> vDiff( nTilePixelWidth * 3 * nTilePixelHeight * 4 );
int nDifferences = diffTiles( vBase, nTilePixelWidth * 2,
vCompare, nTilePixelWidth,
@@ -339,8 +370,9 @@ static bool testJoinsAt( Document *pDocument, long nX, long nY,
vDiff );
if ( nDifferences > 0 )
{
- fprintf( stderr, " %d differences in sub-tile pixel mismatch at %ld, %ld at offset %ld, %ld (twips)\n",
- nDifferences, rPos.X, rPos.Y, initPosX, initPosY );
+ fprintf( stderr, " %d differences in sub-tile pixel mismatch at %ld, %ld at offset %ld, %ld (twips) size %ld\n",
+ nDifferences, rPos.X, rPos.Y, initPosX, initPosY,
+ nTileTwipWidth);
dumpTile("_base", nTilePixelWidth * 2, nTilePixelHeight * 2,
mode, vBase.data());
/* dumpTile("_sub", nTilePixelWidth, nTilePixelHeight,
@@ -367,16 +399,31 @@ static int testJoin( Document *pDocument)
// Use realistic dimensions, similar to the Online client.
long const nTilePixelSize = 256;
- long const nTileTwipSize = 1852;
+ long const nTileTwipSize = 3840;
+ double fZooms[] = {
+ 0.5,
+ 0.6, 0.7, 0.85,
+ 1.0,
+ 1.2, 1.5, 1.75,
+ 2.0
+ };
long nFails = 0;
+ std::stringstream results;
- for( long y = 0; y < 5; ++y )
+ for( auto z : fZooms )
{
- for( long x = 0; x < 5; ++x )
+ long nBad = 0;
+ for( long y = 0; y < 5; ++y )
{
- if ( !testJoinsAt( pDocument, x, y, nTilePixelSize, nTileTwipSize ) )
- nFails++;
+ for( long x = 0; x < 5; ++x )
+ {
+ if ( !testJoinsAt( pDocument, x, y, nTilePixelSize, nTileTwipSize * z ) )
+ nBad++;
+ }
}
+ if (nBad > 0)
+ results << "\tZoom " << z << " bad tiles: " << nBad << "\n";
+ nFails += nBad;
}
if (nFails > 0)
@@ -384,6 +431,8 @@ static int testJoin( Document *pDocument)
else
fprintf( stderr, "All joins compared correctly\n" );
+ fprintf(stderr, "%s\n", results.str().c_str());
+
return nFails;
}
commit ff8e2fa46041b9addf8a8679fb0702477ef494f7
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Mon Oct 28 21:39:14 2019 +0000
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Fri Nov 1 17:02:35 2019 +0000
Revert "lok: sc: make hi-dpi/zoom compatible with retrieving cell cursor"
This reverts commit e3ff84aed5be8e0d2780d80b178fa8fc0e388859.
Change-Id: I174dd54cf7b44f12c90c61882814b6dee9be9b7c
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 49a26253b388..5097f4b0dbc8 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -813,7 +813,9 @@ void DesktopLOKTest::testCellCursor()
OString aRectangle(aTree.get<std::string>("commandValues").c_str());
// cell cursor geometry + col + row
- CPPUNIT_ASSERT_EQUAL(OString("0, 0, 1274, 254, 0, 0"), aRectangle);
+ CPPUNIT_ASSERT_EQUAL(OString("0, 0, 1279, 255, 0, 0"), aRectangle);
+
+ comphelper::LibreOfficeKit::setActive(false);
}
void DesktopLOKTest::testCommandResult()
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 8f5324a7cd00..0f72c2954a1b 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5675,7 +5675,7 @@ OString ScGridWindow::getCellCursor( int nOutputWidth, int nOutputHeight,
return getCellCursor(zoomX, zoomY);
}
-OString ScGridWindow::getCellCursor(const Fraction& /*rZoomX*/, const Fraction& /*rZoomY*/) const
+OString ScGridWindow::getCellCursor(const Fraction& rZoomX, const Fraction& rZoomY) const
{
// GridWindow stores a shown cell cursor in mpOOCursors, hence
// we can use that to determine whether we would want to be showing
@@ -5691,10 +5691,7 @@ OString ScGridWindow::getCellCursor(const Fraction& /*rZoomX*/, const Fraction&
Fraction defaultZoomX = pViewData->GetZoomX();
Fraction defaultZoomY = pViewData->GetZoomY();
- // hardcode to what we mean as 100% (256px tiles meaning 3840 twips)
- Fraction aFracX(long(256 * TWIPS_PER_PIXEL), 3840);
- Fraction aFracY(long(256 * TWIPS_PER_PIXEL), 3840);
- pViewData->SetZoom(aFracX, aFracY, true);
+ pViewData->SetZoom(rZoomX, rZoomY, true);
Point aScrPos = pViewData->GetScrPos( nX, nY, eWhich, true );
long nSizeXPix;
commit a4757272df03989ae7113e322d05c4f76ae27e8f
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Mon Oct 28 20:43:46 2019 +0000
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Fri Nov 1 17:02:30 2019 +0000
Revert "sc lok: Implement hi-dpi and zoom for spreadsheets."
This reverts commit 498dceb43f870bf9e380f1f87e99c6ccadf1963c.
Change-Id: Iadb9da47cf8c9a57385530ab888d55169db7639a
diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx
index b18314d155e5..4c1337dd927e 100644
--- a/comphelper/source/misc/lok.cxx
+++ b/comphelper/source/misc/lok.cxx
@@ -40,7 +40,7 @@ static Compat g_eCompatFlags(Compat::none);
static LanguageTag g_aLanguageTag("en-US", true);
-/// Scaling of the cairo or CoreGraphics canvas painting for HiDPI or zooming in Calc.
+/// Scaling of the cairo canvas painting for hi-dpi
static double g_fDPIScale(1.0);
/// List of <viewid, bMobile> pairs
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index b00638eaa127..e46d11dee080 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2730,15 +2730,9 @@ static void doc_paintTile(LibreOfficeKitDocument* pThis,
// would do - because that one is trying to fit the lines between cells to integer multiples of
// pixels.
comphelper::ScopeGuard dpiScaleGuard([]() { comphelper::LibreOfficeKit::setDPIScale(1.0); });
- double fDPIScaleX = 1.0;
- if (doc_getDocumentType(pThis) == LOK_DOCTYPE_SPREADSHEET)
- {
- fDPIScaleX = (nCanvasWidth * 3840.0) / (256.0 * nTileWidth);
- assert(fabs(fDPIScaleX - ((nCanvasHeight * 3840.0) / (256.0 * nTileHeight))) < 0.0001);
- comphelper::LibreOfficeKit::setDPIScale(fDPIScaleX);
- }
#if defined(IOS)
+ double fDPIScaleX = 1.0;
paintTileIOS(pThis, pBuffer, nCanvasWidth, nCanvasHeight, fDPIScaleX, nTilePosX, nTilePosY, nTileWidth, nTileHeight);
#else
ScopedVclPtrInstance< VirtualDevice > pDevice(DeviceFormat::DEFAULT);
diff --git a/include/comphelper/lok.hxx b/include/comphelper/lok.hxx
index 22d2c6931ab3..b4658913f0d1 100644
--- a/include/comphelper/lok.hxx
+++ b/include/comphelper/lok.hxx
@@ -65,9 +65,9 @@ COMPHELPER_DLLPUBLIC void setTiledPainting(bool bTiledPainting);
COMPHELPER_DLLPUBLIC bool isDialogPainting();
/// Set if we are painting the dialog.
COMPHELPER_DLLPUBLIC void setDialogPainting(bool bDialogPainting);
-/// Set the DPI scale for rendering for HiDPI displays. Used also for zoom in Calc.
+/// Set the DPI scale for rendering for HiDPI displays.
COMPHELPER_DLLPUBLIC void setDPIScale(double fDPIScale);
-/// Get the DPI scale for rendering for HiDPI displays. Used also for zoom in Calc.
+/// Get the DPI scale for rendering for HiDPI displays.
COMPHELPER_DLLPUBLIC double getDPIScale();
/// Set if we want no annotations rendering
COMPHELPER_DLLPUBLIC void setTiledAnnotations(bool bTiledAnnotations);
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 689b785ab982..9b0ae9763001 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -888,12 +888,12 @@ bool ScModelObj::isMimeTypeSupported()
return EditEngine::HasValidData(aDataHelper.GetTransferable());
}
-void ScModelObj::setClientZoom(int /*nTilePixelWidth_*/, int /*nTilePixelHeight_*/, int /*nTileTwipWidth_*/, int /*nTileTwipHeight_*/)
+void ScModelObj::setClientZoom(int nTilePixelWidth_, int nTilePixelHeight_, int nTileTwipWidth_, int nTileTwipHeight_)
{
- mnTilePixelWidth = 256;
- mnTilePixelHeight = 256;
- mnTileTwipWidth = mnTilePixelWidth * TWIPS_PER_PIXEL;
- mnTileTwipHeight = mnTilePixelHeight * TWIPS_PER_PIXEL;
+ mnTilePixelWidth = nTilePixelWidth_;
+ mnTilePixelHeight = nTilePixelHeight_;
+ mnTileTwipWidth = nTileTwipWidth_;
+ mnTileTwipHeight = nTileTwipHeight_;
}
OUString ScModelObj::getRowColumnHeaders(const tools::Rectangle& rRectangle)
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 76041fdc5b7a..9f924931b09b 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1129,30 +1129,17 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
// coords only, and avoid all the SetMapMode()'s.
// Similarly to Writer, we should set the mapmode once on the rDevice, and
// not care about any zoom settings.
- //
- // But until that happens, we actually draw everything at 100%, and only
- // set cairo's or CoreGraphic's scale factor accordingly, so that everything
- // is painted bigger or smaller. This is different to what Calc's internal
- // scaling would do - because that one is trying to fit the lines between
- // cells to integer multiples of pixels.
- //
- // See also desktop/source/lib/init.cxx for details, where we have to set
- // the stuff accordingly for the VirtualDevice creation.
-
- // page break zoom, and aLogicMode in ScViewData - hardcode that to what
- // we mean as 100% (256px tiles meaning 3840 twips)
- Fraction aFracX(long(256 * TWIPS_PER_PIXEL), 3840);
- Fraction aFracY(long(256 * TWIPS_PER_PIXEL), 3840);
- pViewData->SetZoom(aFracX, aFracY, true);
- // Cairo or CoreGraphics scales for us, we have to compensate for that,
- // otherwise we are painting too far away
- const double fDPIScale = comphelper::LibreOfficeKit::getDPIScale();
+ Fraction aFracX(long(nOutputWidth * TWIPS_PER_PIXEL), nTileWidth);
+ Fraction aFracY(long(nOutputHeight * TWIPS_PER_PIXEL), nTileHeight);
+
+ // page break zoom, and aLogicMode in ScViewData
+ pViewData->SetZoom(aFracX, aFracY, true);
- const double fTilePosXPixel = static_cast<double>(nTilePosX) * nOutputWidth / (nTileWidth * fDPIScale);
- const double fTilePosYPixel = static_cast<double>(nTilePosY) * nOutputHeight / (nTileHeight * fDPIScale);
- const double fTileBottomPixel = static_cast<double>(nTilePosY + nTileHeight) * nOutputHeight / (nTileHeight * fDPIScale);
- const double fTileRightPixel = static_cast<double>(nTilePosX + nTileWidth) * nOutputWidth / (nTileWidth * fDPIScale);
+ const double fTilePosXPixel = static_cast<double>(nTilePosX) * nOutputWidth / nTileWidth;
+ const double fTilePosYPixel = static_cast<double>(nTilePosY) * nOutputHeight / nTileHeight;
+ const double fTileBottomPixel = static_cast<double>(nTilePosY + nTileHeight) * nOutputHeight / nTileHeight;
+ const double fTileRightPixel = static_cast<double>(nTilePosX + nTileWidth) * nOutputWidth / nTileWidth;
SCTAB nTab = pViewData->GetTabNo();
ScDocument* pDoc = pViewData->GetDocument();
More information about the Libreoffice-commits
mailing list