summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2018-10-23 17:20:38 +0200
committerJan Holesovsky <kendy@collabora.com>2018-11-07 12:51:03 +0100
commit053d9247ce0818580658a7b6f5854f8b21754f7c (patch)
tree74e8357d14920b7babe85b9287dff8e52e5bbefd /desktop
parentddd2790f3402abaa64ccc501b63826dd29b29b68 (diff)
sc lok: Implement hi-dpi and zoom for spreadsheets.
A bit different approach than trying to paint different zoom levels at the samet time, because it is terribly hard to achieve with Calc - things misalign, because Calc tries to fit the lines into the pixels etc. Instead, always paint the spreadsheet at 100%, but use cairo to scale the actual painting. Change-Id: I228a9dd41bf29862bdd188825d12e61e1c86cccc
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 7527c1b857d2..5b5381c002fa 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2104,6 +2104,19 @@ static void doc_paintTile(LibreOfficeKitDocument* pThis,
return;
}
+ // Painting of zoomed or hi-dpi spreadsheets is special, we actually draw
+ // everything at 100%, and only set cairo'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.
+ comphelper::ScopeGuard dpiScaleGuard([]() { comphelper::LibreOfficeKit::setDPIScale(1.0); });
+ if (doc_getDocumentType(pThis) == LOK_DOCTYPE_SPREADSHEET)
+ {
+ double fDPIScaleX = (nCanvasWidth * 3840.0) / (256.0 * nTileWidth);
+ assert(fabs(fDPIScaleX - ((nCanvasHeight * 3840.0) / (256.0 * nTileHeight))) < 0.0001);
+ comphelper::LibreOfficeKit::setDPIScale(fDPIScaleX);
+ }
+
#if defined(UNX) && !defined(MACOSX) && !defined(ENABLE_HEADLESS)
#if defined(IOS)