desktop/qa/desktop_lib/test_desktop_lib.cxx | 3 ++- desktop/source/lib/init.cxx | 22 ++++++++++++++++++++-- include/LibreOfficeKit/LibreOfficeKit.h | 3 +++ include/LibreOfficeKit/LibreOfficeKit.hxx | 10 +++++++--- 4 files changed, 32 insertions(+), 6 deletions(-)
New commits: commit 4c9f230ef4bc4400b6722c6fccbe32ef8fb2d05f Author: Ashod Nakashian <[email protected]> AuthorDate: Thu Jan 24 06:51:46 2019 -0500 Commit: Andras Timar <[email protected]> CommitDate: Mon Mar 4 15:20:32 2019 +0100 LOK: support creating view with options This adds a new API createViewWithOptions that make createView similar to documentLoad, which also has documentViewWithOptions version. This is primarily to support setting per-view language and similar settings. Change-Id: I0ae5a5b2410cf9e053aee8f7c8a6204af9038a31 Reviewed-on: https://gerrit.libreoffice.org/68261 Reviewed-by: Andras Timar <[email protected]> Tested-by: Andras Timar <[email protected]> diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 195cbbfd50d6..b3f6a7fb943d 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -2538,9 +2538,10 @@ void DesktopLOKTest::testABI() CPPUNIT_ASSERT_EQUAL(documentClassOffset(44), offsetof(struct _LibreOfficeKitDocumentClass, addCertificate)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(45), offsetof(struct _LibreOfficeKitDocumentClass, getSignatureState)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(46), offsetof(struct _LibreOfficeKitDocumentClass, renderShapeSelection)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(47), offsetof(struct _LibreOfficeKitDocumentClass, createViewWithOptions)); // Extending is fine, update this, and add new assert for the offsetof the // new method - CPPUNIT_ASSERT_EQUAL(documentClassOffset(47), sizeof(struct _LibreOfficeKitDocumentClass)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(48), sizeof(struct _LibreOfficeKitDocumentClass)); } CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 2fa9a3b7ce2b..c7dd54a0d7dc 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -716,6 +716,7 @@ static void doc_setClientZoom(LibreOfficeKitDocument* pThis, static void doc_setClientVisibleArea(LibreOfficeKitDocument* pThis, int nX, int nY, int nWidth, int nHeight); static void doc_setOutlineState(LibreOfficeKitDocument* pThis, bool bColumn, int nLevel, int nIndex, bool bHidden); static int doc_createView(LibreOfficeKitDocument* pThis); +static int doc_createViewWithOptions(LibreOfficeKitDocument* pThis, const char* pOptions); static void doc_destroyView(LibreOfficeKitDocument* pThis, int nId); static void doc_setView(LibreOfficeKitDocument* pThis, int nId); static int doc_getView(LibreOfficeKitDocument* pThis); @@ -820,6 +821,8 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone m_pDocumentClass->renderShapeSelection = doc_renderShapeSelection; + m_pDocumentClass->createViewWithOptions = doc_createViewWithOptions; + gDocumentClass = m_pDocumentClass; } pClass = m_pDocumentClass.get(); @@ -1525,7 +1528,7 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis, // 'Language=...' is an option that LOK consumes by itself, and does // not pass it as a parameter to the filter OUString aOptions = getUString(pOptions); - OUString aLanguage = extractParameter(aOptions, "Language"); + const OUString aLanguage = extractParameter(aOptions, "Language"); if (!aLanguage.isEmpty()) { @@ -3682,15 +3685,30 @@ static void doc_setOutlineState(LibreOfficeKitDocument* pThis, bool bColumn, int pDoc->setOutlineState(bColumn, nLevel, nIndex, bHidden); } -static int doc_createView(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/) +static int doc_createViewWithOptions(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/, + const char* pOptions) { SolarMutexGuard aGuard; if (gImpl) gImpl->maLastExceptionMsg.clear(); + OUString aOptions = getUString(pOptions); + const OUString aLanguage = extractParameter(aOptions, "Language"); + + if (!aLanguage.isEmpty()) + { + // Set the LOK language tag, used for dialog tunneling. + comphelper::LibreOfficeKit::setLanguageTag(LanguageTag(aLanguage)); + } + return SfxLokHelper::createView(); } +static int doc_createView(LibreOfficeKitDocument* pThis) +{ + return doc_createViewWithOptions(pThis, nullptr); // No options. +} + static void doc_destroyView(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/, int nId) { SolarMutexGuard aGuard; diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index 479344cfc971..0939cb661410 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -348,6 +348,9 @@ struct _LibreOfficeKitDocumentClass /// @see lok::Document::renderShapeSelection size_t (*renderShapeSelection)(LibreOfficeKitDocument* pThis, char** pOutput); + /// @see lok::Document::createViewWithOptions(). + int (*createViewWithOptions) (LibreOfficeKitDocument* pThis, const char* pOptions); + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index 8709f5418722..0440e8bae2f6 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -440,13 +440,17 @@ public: } /** - * Create a new view for an existing document. + * Create a new view for an existing document with + * options similar to documentLoadWithOptions. * By default a loaded document has 1 view. * @return the ID of the new view. */ - int createView() + int createView(const char* pOptions = nullptr) { - return mpDoc->pClass->createView(mpDoc); + if (LIBREOFFICEKIT_DOCUMENT_HAS(mpDoc, createViewWithOptions)) + return mpDoc->pClass->createViewWithOptions(mpDoc, pOptions); + else + return mpDoc->pClass->createView(mpDoc); } /** _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
