diff options
-rw-r--r-- | comphelper/source/misc/lok.cxx | 2 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 23 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin4.cxx | 12 |
3 files changed, 19 insertions, 18 deletions
diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx index 5934ed58c297..e5f3573cb391 100644 --- a/comphelper/source/misc/lok.cxx +++ b/comphelper/source/misc/lok.cxx @@ -38,7 +38,7 @@ static bool g_bLocalRendering(false); static LanguageTag g_aLanguageTag("en-US", true); -/// Scaling of the cairo canvas painting for hi-dpi or zooming in Calc. +/// Scaling of the cairo or CoreGraphics canvas painting for hi-dpi or zooming in Calc. static double g_fDPIScale(1.0); void setActive(bool bActive) 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); diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 1ed36c4ed414..99329375b2c2 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -1112,10 +1112,10 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice, // not care about any zoom settings. // // But until that happens, 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. + // 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. @@ -1126,8 +1126,8 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice, Fraction aFracY(long(256 * TWIPS_PER_PIXEL), 3840); pViewData->SetZoom(aFracX, aFracY, true); - // Cairo scales for us, we have to compensate for that, otherwise we are - // painting too far away + // 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(); const double fTilePosXPixel = static_cast<double>(nTilePosX) * nOutputWidth / (nTileWidth * fDPIScale); |