summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2018-10-26 15:21:06 +0200
committerJan Holesovsky <kendy@collabora.com>2018-11-07 12:53:17 +0100
commite94ceb6eff0edd1699d21b8b860f6929236a90ef (patch)
tree0b61a594602e1f4c7bfd3b1c42d1516f7ebda2b5 /desktop
parent053d9247ce0818580658a7b6f5854f8b21754f7c (diff)
lokdialog: Implement hi-dpi support for the routed dialogs.
Change-Id: I770c605a049b7ac9c26c2773414eef8b6fc093a2
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx24
1 files changed, 22 insertions, 2 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 5b5381c002fa..a8d5e87eed08 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -678,6 +678,11 @@ static void doc_paintWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId
const int nX, const int nY,
const int nWidth, const int nHeight);
+static void doc_paintWindowDPI(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, unsigned char* pBuffer,
+ const int nX, const int nY,
+ const int nWidth, const int nHeight,
+ const double fDPIScale);
+
static void doc_postWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nAction);
static char* doc_getPartInfo(LibreOfficeKitDocument* pThis, int nPart);
@@ -733,6 +738,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->getPartHash = doc_getPartHash;
m_pDocumentClass->paintWindow = doc_paintWindow;
+ m_pDocumentClass->paintWindowDPI = doc_paintWindowDPI;
m_pDocumentClass->postWindow = doc_postWindow;
m_pDocumentClass->setViewLanguage = doc_setViewLanguage;
@@ -3566,11 +3572,20 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh
return nullptr;
}
-static void doc_paintWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId,
+static void doc_paintWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId,
unsigned char* pBuffer,
const int nX, const int nY,
const int nWidth, const int nHeight)
{
+ doc_paintWindowDPI(pThis, nLOKWindowId, pBuffer, nX, nY, nWidth, nHeight, 1.0);
+}
+
+static void doc_paintWindowDPI(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId,
+ unsigned char* pBuffer,
+ const int nX, const int nY,
+ const int nWidth, const int nHeight,
+ const double fDPIScale)
+{
SolarMutexGuard aGuard;
if (gImpl)
gImpl->maLastExceptionMsg.clear();
@@ -3582,6 +3597,11 @@ static void doc_paintWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWind
return;
}
+ // Setup cairo 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);
+
#if defined(IOS)
CGContextRef cgc = CGBitmapContextCreate(pBuffer, nWidth, nHeight, 8, nWidth*4, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipFirst | kCGImageByteOrder32Little);
@@ -3615,7 +3635,7 @@ static void doc_paintWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWind
pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nWidth, nHeight), Fraction(1.0), Point(), pBuffer);
MapMode aMapMode(pDevice->GetMapMode());
- aMapMode.SetOrigin(Point(-nX, -nY));
+ aMapMode.SetOrigin(Point(-(nX / fDPIScale), -(nY / fDPIScale)));
pDevice->SetMapMode(aMapMode);
comphelper::LibreOfficeKit::setDialogPainting(true);