diff options
author | Jan Holesovsky <kendy@collabora.com> | 2018-10-23 17:20:38 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2018-11-08 14:38:27 +0100 |
commit | 498dceb43f870bf9e380f1f87e99c6ccadf1963c (patch) | |
tree | 1cfcb65dfc6b28c06bb4b4666a20218f74462585 /desktop | |
parent | d2c7b86be879fe33ce170727421a19370ba8884d (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
Reviewed-on: https://gerrit.libreoffice.org/63031
Tested-by: Jenkins
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 202bf279f153..7ea6316f9e26 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -2126,7 +2126,20 @@ static void doc_paintTile(LibreOfficeKitDocument* pThis, return; } -#if defined(UNX) && !defined(MACOSX) +#if defined(UNX) && !defined(MACOSX) && !defined(ENABLE_HEADLESS) + + // 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(IOS) CGContextRef cgc = CGBitmapContextCreate(pBuffer, nCanvasWidth, nCanvasHeight, 8, nCanvasWidth*4, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipFirst | kCGImageByteOrder32Little); |