[Libreoffice-commits] core.git: desktop/qa desktop/source include/LibreOfficeKit
Ashod Nakashian (via logerrit)
logerrit at kemper.freedesktop.org
Tue Apr 23 09:59:37 UTC 2019
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 6a2382c64f65d433d44ce74f936e42f744f04e21
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Thu Jan 24 06:51:46 2019 -0500
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Tue Apr 23 11:58:54 2019 +0200
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 <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/71111
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index a688350cb386..a08d476a8bac 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2699,9 +2699,10 @@ void DesktopLOKTest::testABI()
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, postWindowGestureEvent));
+ CPPUNIT_ASSERT_EQUAL(documentClassOffset(48), offsetof(struct _LibreOfficeKitDocumentClass, createViewWithOptions));
// Extending is fine, update this, and add new assert for the offsetof the
// new method
- CPPUNIT_ASSERT_EQUAL(documentClassOffset(48), sizeof(struct _LibreOfficeKitDocumentClass));
+ CPPUNIT_ASSERT_EQUAL(documentClassOffset(49), sizeof(struct _LibreOfficeKitDocumentClass));
}
CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 0853678a0008..7fcf018813d4 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -783,6 +783,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);
@@ -891,6 +892,8 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->renderShapeSelection = doc_renderShapeSelection;
m_pDocumentClass->postWindowGestureEvent = doc_postWindowGestureEvent;
+ m_pDocumentClass->createViewWithOptions = doc_createViewWithOptions;
+
gDocumentClass = m_pDocumentClass;
}
pClass = m_pDocumentClass.get();
@@ -1615,7 +1618,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())
{
@@ -3866,7 +3869,8 @@ 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)
{
comphelper::ProfileZone aZone("doc_createView");
@@ -3874,9 +3878,23 @@ static int doc_createView(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/
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)
{
comphelper::ProfileZone aZone("doc_destroyView");
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index f2c8dd40f1b3..62bd3c429fa1 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -375,6 +375,9 @@ struct _LibreOfficeKitDocumentClass
int nY,
int nOffset);
+ /// @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 6bebf36611dd..7027298a1481 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);
}
/**
More information about the Libreoffice-commits
mailing list