summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2019-01-24 06:51:46 -0500
committerMichael Meeks <michael.meeks@collabora.com>2019-04-23 11:58:54 +0200
commit6a2382c64f65d433d44ce74f936e42f744f04e21 (patch)
tree81736b12ec7d3adc7ef3055b6399146dfc927d1d /desktop
parent053b1417137b0cdec4e4fed7ae0c57cf67ff2698 (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> Reviewed-on: https://gerrit.libreoffice.org/71111 Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.meeks@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 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");