summaryrefslogtreecommitdiff
path: root/desktop/source/lib
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2017-03-23 21:27:18 +0100
committerJan Holesovsky <kendy@collabora.com>2017-03-24 19:01:53 +0100
commit5fefac660ae5d978843fd7abbc6db1fce0800566 (patch)
tree206f056a85470765a643458476ac7bf01d133253 /desktop/source/lib
parent125ca372c1d0821139b4c682a02494294b322473 (diff)
lok: Allow setting of the language during load.
Change-Id: I9dbb62950e639376c26122ceb9fcec2982b3ca82
Diffstat (limited to 'desktop/source/lib')
-rw-r--r--desktop/source/lib/init.cxx60
1 files changed, 59 insertions, 1 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 90c85b9de4ac..edbeb4a01975 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -472,6 +472,50 @@ int lcl_getViewId(const std::string& payload)
} // end anonymous namespace
+// Could be anonymous in principle, but for the unit testing purposes, we
+// declare it in init.hxx.
+OUString desktop::extractParameter(OUString& rOptions, const OUString& rName)
+{
+ OUString aValue;
+
+ OUString aNameEquals(rName + "=");
+ OUString aCommaNameEquals("," + rName + "=");
+
+ int nIndex = -1;
+ if (rOptions.startsWith(aNameEquals))
+ {
+ size_t nLen = aNameEquals.getLength();
+ int nComma = rOptions.indexOf(",", nLen);
+ if (nComma >= 0)
+ {
+ aValue = rOptions.copy(nLen, nComma - nLen);
+ rOptions = rOptions.copy(nComma + 1);
+ }
+ else
+ {
+ aValue = rOptions.copy(nLen);
+ rOptions.clear();
+ }
+ }
+ else if ((nIndex = rOptions.indexOf(aCommaNameEquals)) >= 0)
+ {
+ size_t nLen = aCommaNameEquals.getLength();
+ int nComma = rOptions.indexOf(",", nIndex + nLen);
+ if (nComma >= 0)
+ {
+ aValue = rOptions.copy(nIndex + nLen, nComma - nIndex - nLen);
+ rOptions = rOptions.copy(0, nIndex) + rOptions.copy(nComma);
+ }
+ else
+ {
+ aValue = rOptions.copy(nIndex + nLen);
+ rOptions = rOptions.copy(0, nIndex);
+ }
+ }
+
+ return aValue;
+}
+
extern "C"
{
@@ -1160,10 +1204,24 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis,
try
{
+ // '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");
+
+ if (!aLanguage.isEmpty())
+ {
+ // use with care - it sets it for the entire core, not just the
+ // document
+ SvtSysLocaleOptions aSysLocaleOptions;
+ aSysLocaleOptions.SetLocaleConfigString(aLanguage);
+ aSysLocaleOptions.SetUILocaleConfigString(aLanguage);
+ }
+
uno::Sequence<css::beans::PropertyValue> aFilterOptions(2);
aFilterOptions[0] = css::beans::PropertyValue( "FilterOptions",
0,
- uno::makeAny(OUString::createFromAscii(pOptions)),
+ uno::makeAny(aOptions),
beans::PropertyState_DIRECT_VALUE);
rtl::Reference<LOKInteractionHandler> const pInteraction(