summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2018-11-23 17:36:33 +0200
committerTor Lillqvist <tml@collabora.com>2018-11-23 17:48:20 +0200
commit3ace447b0fe1926945f739479a7be39276e81fb5 (patch)
tree27a32645bf4c4587e70e2f8f4676dcd60148f128 /desktop
parentc9b0766aee1f13c07c1f3decbc2e8b0388e5f8e5 (diff)
Use the correct DPI scaling factor in LibreOfficeKit for iOS, too
Fixes the rendering of spreadsheets in the iOS app. (The cell area was rendered at half the scale of the row and column headers.) Actual code change only in desktop/source/lib/init.cxx, but update related comments elsewhere to mention CoreGraphics, too, and not just cairo. Change-Id: Ife99c6a2d58e592cfea3b4ed1ab09c19fba77e72
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx23
1 files changed, 12 insertions, 11 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 3cb194b5ab38..a7ce8182ebd1 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2134,15 +2134,16 @@ static void doc_paintTile(LibreOfficeKitDocument* pThis,
#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.
+ // Painting of zoomed or hi-dpi spreadsheets is special, we actually draw everything at 100%,
+ // and only set cairo's (or CoreGraphic's, in the iOS case) 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); });
+ double fDPIScaleX = 1;
if (doc_getDocumentType(pThis) == LOK_DOCTYPE_SPREADSHEET)
{
- double fDPIScaleX = (nCanvasWidth * 3840.0) / (256.0 * nTileWidth);
+ fDPIScaleX = (nCanvasWidth * 3840.0) / (256.0 * nTileWidth);
assert(fabs(fDPIScaleX - ((nCanvasHeight * 3840.0) / (256.0 * nTileHeight))) < 0.0001);
comphelper::LibreOfficeKit::setDPIScale(fDPIScaleX);
}
@@ -2151,7 +2152,7 @@ static void doc_paintTile(LibreOfficeKitDocument* pThis,
CGContextRef cgc = CGBitmapContextCreate(pBuffer, nCanvasWidth, nCanvasHeight, 8, nCanvasWidth*4, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipFirst | kCGImageByteOrder32Little);
CGContextTranslateCTM(cgc, 0, nCanvasHeight);
- CGContextScaleCTM(cgc, 1, -1);
+ CGContextScaleCTM(cgc, fDPIScaleX, -fDPIScaleX);
doc_paintTileToCGContext(pThis, (void*) cgc, nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight);
@@ -3618,8 +3619,8 @@ static void doc_paintWindowDPI(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKW
return;
}
- // Setup cairo to draw with the changed DPI scale (and return back to 1.0
- // when the painting finishes)
+ // Setup cairo (or CoreGraphics, in the iOS case) to draw with the changed DPI scale (and return
+ // back to 1.0 when the painting finishes)
comphelper::ScopeGuard dpiScaleGuard([]() { comphelper::LibreOfficeKit::setDPIScale(1.0); });
comphelper::LibreOfficeKit::setDPIScale(fDPIScale);
@@ -3628,7 +3629,7 @@ static void doc_paintWindowDPI(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKW
CGContextRef cgc = CGBitmapContextCreate(pBuffer, nWidth, nHeight, 8, nWidth*4, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipFirst | kCGImageByteOrder32Little);
CGContextTranslateCTM(cgc, 0, nHeight);
- CGContextScaleCTM(cgc, 1, -1);
+ CGContextScaleCTM(cgc, fDPIScale, -fDPIScale);
SystemGraphicsData aData;
aData.rCGContext = cgc;
@@ -3639,7 +3640,7 @@ static void doc_paintWindowDPI(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKW
pDevice->SetOutputSizePixel(Size(nWidth, nHeight));
MapMode aMapMode(pDevice->GetMapMode());
- aMapMode.SetOrigin(Point(-nX, -nY));
+ aMapMode.SetOrigin(Point(-(nX / fDPIScale), -(nY / fDPIScale)));
pDevice->SetMapMode(aMapMode);
comphelper::LibreOfficeKit::setDialogPainting(true);