diff options
author | Henry Castro <hcastro@collabora.com> | 2015-09-14 20:14:34 -0400 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-09-15 09:28:57 +0200 |
commit | d3a2c0f60365d6092e5061b1d061d6e3e53eb9cf (patch) | |
tree | fdc0fe75852249263f11d0a279711f8c2ee9f68e /desktop | |
parent | 2ba8a592ca6f3035a2e3d5fe85c14122d8d0049c (diff) |
lok: initialize UNO url command dispatch
In the tiled rendering case, the desktop is headless, so the toolbar
is not created. The toolbar usually initializes all UNO url commands
for each tool item attached.
This causes that SfxControllerItem that monitor a state, it is not
intercepted by InterceptLOKStateChangeEvent so no callback status changes.
Change-Id: I5937cda66ef24d31dd92a1edd8c1440081c4b1a4
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index fb8ec3ea361a..f17493761529 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -44,10 +44,15 @@ #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/ucb/XContentProvider.hpp> #include <com/sun/star/ucb/XUniversalContentBroker.hpp> +#include <com/sun/star/util/URLTransformer.hpp> #include <editeng/fontitem.hxx> #include <editeng/flstitem.hxx> #include <sfx2/objsh.hxx> +#include <sfx2/viewsh.hxx> +#include <sfx2/viewfrm.hxx> +#include <sfx2/msgpool.hxx> +#include <sfx2/dispatch.hxx> #include <svx/svxids.hrc> #include <vcl/svapp.hxx> #include <vcl/svpforlokit.hxx> @@ -526,6 +531,58 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha return false; } +static void doc_iniUnoCommands () +{ + OUString sUnoCommands[] = + { + OUString(".uno:Bold"), + OUString(".uno:Italic"), + OUString(".uno:Underline"), + OUString(".uno:Strikeout"), + OUString(".uno:LeftPara"), + OUString(".uno:CenterPara"), + OUString(".uno:RightPara"), + OUString(".uno:JustifyPara"), + OUString(".uno:IncrementIndent"), + OUString(".uno:DecrementIndent") + }; + + util::URL aCommandURL; + const SfxSlot* pSlot = NULL; + SfxViewShell* pViewShell = SfxViewShell::Current(); + SfxViewFrame* pViewFrame = (pViewShell ? pViewShell->GetViewFrame() : NULL); + + // check if Frame-Controller were created. + if (!pViewShell && !pViewFrame) + { + SAL_WARN("lok", "iniUnoCommands: No Frame-Controller created."); + return; + } + + SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool( pViewFrame ); + uno::Reference<util::XURLTransformer> xParser = + util::URLTransformer::create(xContext); + + for ( + sal_uInt32 nIterator = 0; + nIterator < SAL_N_ELEMENTS(sUnoCommands); + nIterator++ + ) + { + aCommandURL.Complete = sUnoCommands[nIterator]; + xParser->parseStrict(aCommandURL); + pSlot = rSlotPool.GetUnoSlot(aCommandURL.Path); + + // Initialize slot to dispatch Uno Command. + uno::Reference<frame::XDispatch> xDispatch = + pViewFrame->GetBindings().GetDispatch( pSlot, aCommandURL, false ); + if (!xDispatch.is()) + { + SAL_WARN("lok", "iniUnoCommands: No XDispatch interface : " + aCommandURL.Complete); + } + } +} + static int doc_getDocumentType (LibreOfficeKitDocument* pThis) { LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis); @@ -739,6 +796,7 @@ static void doc_initializeForRendering(LibreOfficeKitDocument* pThis) ITiledRenderable* pDoc = getTiledRenderable(pThis); if (pDoc) { + doc_iniUnoCommands(); pDoc->initializeForTiledRendering(); } } |