diff options
author | Mert Tumer <mert.tumer@collabora.com> | 2019-10-24 12:11:21 +0300 |
---|---|---|
committer | Ashod Nakashian <ashnakash@gmail.com> | 2019-11-11 02:36:40 +0100 |
commit | 1dd66357752b01fbf3f1aee9966a55d4a16038e4 (patch) | |
tree | 11508e9bb7b71e57d31a6f496221fa92e3deef3c /desktop | |
parent | cd78158694a2cd6ea482f86eed99204d4b669b92 (diff) |
Added Orientation argument to LOKIT renderFont
method for rendering watermarks with angle
Change-Id: Id422ed62e4f78390661e4e1efa45101af9ecfc23
Reviewed-on: https://gerrit.libreoffice.org/82404
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 4 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 33 |
2 files changed, 30 insertions, 7 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index dc390e72c825..1810df911b06 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -2786,11 +2786,11 @@ void DesktopLOKTest::testABI() CPPUNIT_ASSERT_EQUAL(documentClassOffset(54), offsetof(struct _LibreOfficeKitDocumentClass, getSelectionType)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(55), offsetof(struct _LibreOfficeKitDocumentClass, removeTextContext)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(56), offsetof(struct _LibreOfficeKitDocumentClass, sendDialogEvent)); - + CPPUNIT_ASSERT_EQUAL(documentClassOffset(57), offsetof(struct _LibreOfficeKitDocumentClass, renderFontOrientation)); // Extending is fine, update this, and add new assert for the offsetof the // new method - CPPUNIT_ASSERT_EQUAL(documentClassOffset(57), sizeof(struct _LibreOfficeKitDocumentClass)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(58), sizeof(struct _LibreOfficeKitDocumentClass)); } CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index ac5fca9f39db..062ceb3dcb45 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -879,6 +879,12 @@ static int doc_getView(LibreOfficeKitDocument* pThis); static int doc_getViewsCount(LibreOfficeKitDocument* pThis); static bool doc_getViewIds(LibreOfficeKitDocument* pThis, int* pArray, size_t nSize); static void doc_setViewLanguage(LibreOfficeKitDocument* pThis, int nId, const char* language); +static unsigned char* doc_renderFontOrientation(LibreOfficeKitDocument* pThis, + const char *pFontName, + const char *pChar, + int* pFontWidth, + int* pFontHeight, + int pOrientation); static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis, const char *pFontName, const char *pChar, @@ -895,7 +901,8 @@ static void doc_paintWindowDPI(LibreOfficeKitDocument* pThis, unsigned nLOKWindo const int nWidth, const int nHeight, const double fDPIScale); -static void doc_postWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nAction, const char* pData); +static void doc_postWindow(LibreOfficeKitDocument* pThis, unsigned + nLOKWindowId, int nAction, const char* pData); static char* doc_getPartInfo(LibreOfficeKitDocument* pThis, int nPart); @@ -1001,6 +1008,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone m_pDocumentClass->getViewIds = doc_getViewIds; m_pDocumentClass->renderFont = doc_renderFont; + m_pDocumentClass->renderFontOrientation = doc_renderFontOrientation; m_pDocumentClass->getPartHash = doc_getPartHash; m_pDocumentClass->paintWindow = doc_paintWindow; @@ -4668,12 +4676,24 @@ static void doc_setViewLanguage(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*p SfxLokHelper::setViewLanguage(nId, OStringToOUString(language, RTL_TEXTENCODING_UTF8)); } -unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/, + + +unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis, const char* pFontName, const char* pChar, int* pFontWidth, int* pFontHeight) { + return doc_renderFontOrientation(pThis, pFontName, pChar, pFontWidth, pFontHeight, 0); +} + +unsigned char* doc_renderFontOrientation(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/, + const char* pFontName, + const char* pChar, + int* pFontWidth, + int* pFontHeight, + int pOrientation) +{ comphelper::ProfileZone aZone("doc_renderFont"); SolarMutexGuard aGuard; @@ -4707,6 +4727,7 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh ::tools::Rectangle aRect; vcl::Font aFont(rFontMetric); aFont.SetFontSize(Size(0, nDefaultFontSize)); + aFont.SetOrientation(pOrientation); aDevice->SetFont(aFont); aDevice->GetTextBoundRect(aRect, aText); if (aRect.IsEmpty()) @@ -4720,8 +4741,8 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh if (*pFontWidth > 0 && *pFontHeight > 0) { - double fScaleX = *pFontWidth / static_cast<double>(nFontWidth); - double fScaleY = *pFontHeight / static_cast<double>(nFontHeight); + double fScaleX = *pFontWidth / static_cast<double>(nFontWidth) / 1.5; + double fScaleY = *pFontHeight / static_cast<double>(nFontHeight) / 1.5; double fScale = std::min(fScaleX, fScaleY); @@ -4754,8 +4775,9 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh DrawTextFlags const nStyle = DrawTextFlags::Center | DrawTextFlags::VCenter + | DrawTextFlags::Bottom | DrawTextFlags::MultiLine - | DrawTextFlags::WordBreakHyphenation;// | DrawTextFlags::WordBreak ; + | DrawTextFlags::WordBreak;// | DrawTextFlags::WordBreakHyphenation ; aDevice->DrawText(aRect, aText, nStyle); } @@ -4774,6 +4796,7 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh return nullptr; } + static void doc_paintWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, unsigned char* pBuffer, const int nX, const int nY, |