summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2019-01-24 06:51:46 -0500
committerAndras Timar <andras.timar@collabora.com>2019-03-04 15:20:32 +0100
commit4c9f230ef4bc4400b6722c6fccbe32ef8fb2d05f (patch)
treebcbd830a3af0f7994e0205540a66808a330f52fb /desktop
parentd5e8de3c1e4a8bf6fb9cf7676bca13a9cb348633 (diff)
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@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx3
-rw-r--r--desktop/source/lib/init.cxx22
2 files changed, 22 insertions, 3 deletions
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;