[Libreoffice-commits] core.git: desktop/source sfx2/source
Henry Castro
hcastro at collabora.com
Sun Oct 1 23:34:11 UTC 2017
desktop/source/lib/init.cxx | 47 ++++++++++++++++++++++++++++++++++-----
sfx2/source/control/unoctitm.cxx | 8 ++++++
2 files changed, 50 insertions(+), 5 deletions(-)
New commits:
commit b3de468de84289f06a5eec858ba6493b2c9f408d
Author: Henry Castro <hcastro at collabora.com>
Date: Sun Oct 1 11:11:18 2017 -0400
lok: handle .uno:LanguageStatus command
Change-Id: I3828113bce3b7d32e90e461a299986e363115a83
Reviewed-on: https://gerrit.libreoffice.org/43002
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Henry Castro <hcastro at collabora.com>
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index e195ae5a0430..4566a01dac37 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -59,6 +59,7 @@
#include <editeng/fontitem.hxx>
#include <editeng/flstitem.hxx>
+#include <editeng/unolingu.hxx>
#include <sfx2/objsh.hxx>
#include <sfx2/viewsh.hxx>
#include <sfx2/viewfrm.hxx>
@@ -74,7 +75,9 @@
#include <vcl/svapp.hxx>
#include <unotools/resmgr.hxx>
#include <tools/fract.hxx>
+#include <linguistic/misc.hxx>
#include <svtools/ctrltool.hxx>
+#include <svtools/langtab.hxx>
#include <vcl/fontcharmap.hxx>
#include <vcl/graphicfilter.hxx>
#include <vcl/ptrstyle.hxx>
@@ -1492,7 +1495,36 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha
return false;
}
-static void doc_iniUnoCommands ()
+static void doc_iniUnoCommand(const SfxViewShell* pViewShell, const OUString& aUnoCommand)
+{
+ OUStringBuffer aBuffer;
+
+ if (aUnoCommand.endsWith("LanguageStatus"))
+ {
+ uno::Reference< css::linguistic2::XLinguServiceManager2 > xLangSrv = css::linguistic2::LinguServiceManager::create(xContext);
+ uno::Reference< css::linguistic2::XSpellChecker > xSpell(xLangSrv.is() ? xLangSrv->getSpellChecker() : nullptr, uno::UNO_QUERY);
+ uno::Reference< css::linguistic2::XSupportedLocales > xLocales(xSpell, uno::UNO_QUERY);
+ uno::Sequence< css::lang::Locale > aLocales(xLocales.is() ? xLocales->getLocales() : uno::Sequence< css::lang::Locale >());
+
+ aBuffer.append(aUnoCommand);
+ aBuffer.append("?[");
+ for ( sal_Int32 itLocale = 0; itLocale < aLocales.getLength(); itLocale++ )
+ {
+ aBuffer.append("\"" + SvtLanguageTable::GetLanguageString(LanguageTag::convertToLanguageType(aLocales[itLocale])) + "\"");
+ if (itLocale + 1 != aLocales.getLength())
+ aBuffer.append(",");
+ }
+ aBuffer.append("]");
+ }
+
+ if (pViewShell && !aBuffer.isEmpty())
+ {
+ OUString payload = aBuffer.makeStringAndClear();
+ pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, payload.toUtf8().getStr());
+ }
+}
+
+static void doc_iniUnoCommands (const SfxViewShell* pViewShell)
{
SolarMutexGuard aGuard;
@@ -1520,6 +1552,7 @@ static void doc_iniUnoCommands ()
OUString(".uno:JustifyPara"),
OUString(".uno:OutlineFont"),
OUString(".uno:LeftPara"),
+ OUString(".uno:LanguageStatus"),
OUString(".uno:RightPara"),
OUString(".uno:Shadowed"),
OUString(".uno:SubScript"),
@@ -1580,7 +1613,6 @@ static void doc_iniUnoCommands ()
};
util::URL aCommandURL;
- SfxViewShell* pViewShell = SfxViewShell::Current();
SfxViewFrame* pViewFrame = pViewShell? pViewShell->GetViewFrame(): nullptr;
// check if Frame-Controller were created.
@@ -1614,7 +1646,11 @@ static void doc_iniUnoCommands ()
if (pSlot)
{
// Initialize slot to dispatch .uno: Command.
- pViewFrame->GetBindings().GetDispatch(pSlot, aCommandURL, false);
+ uno::Reference<frame::XDispatch> xDispatch(pViewFrame->GetBindings().GetDispatch(pSlot, aCommandURL, false));
+ if (xDispatch.is())
+ {
+ doc_iniUnoCommand(pViewShell, sUnoCommand);
+ }
}
}
}
@@ -1964,8 +2000,6 @@ static void doc_initializeForRendering(LibreOfficeKitDocument* pThis,
ITiledRenderable* pDoc = getTiledRenderable(pThis);
if (pDoc)
{
- doc_iniUnoCommands();
-
pDoc->initializeForTiledRendering(
comphelper::containerToSequence(jsonToPropertyValuesVector(pArguments)));
}
@@ -2021,7 +2055,10 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis,
}
if (SfxViewShell* pViewShell = SfxViewShell::Current())
+ {
pViewShell->registerLibreOfficeKitViewCallback(CallbackFlushHandler::callback, pDocument->mpCallbackFlushHandlers[nView].get());
+ doc_iniUnoCommands(pViewShell);
+ }
}
/// Returns the JSON representation of all the comments in the document
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 3556a9c4acb2..c609bf21bbd5 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -1159,6 +1159,14 @@ static void InterceptLOKStateChangeEvent(const SfxViewFrame* pViewFrame, const c
aBuffer.append(OUString::number(aSize.Width) + " x " + OUString::number(aSize.Height));
}
}
+ else if (aEvent.FeatureURL.Path == "LanguageStatus")
+ {
+ css::uno::Sequence< OUString > aSeq;
+ if (aEvent.IsEnabled && (aEvent.State >>= aSeq))
+ {
+ aBuffer.append(aSeq[0]);
+ }
+ }
else
{
return;
More information about the Libreoffice-commits
mailing list