From bb949259f1ca2a384b68616b8c2ae953ea7eba17 Mon Sep 17 00:00:00 2001 From: Henry Castro Date: Mon, 14 Sep 2015 20:14:34 -0400 Subject: [PATCH 112/398] 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 (cherry picked from commit d3a2c0f60365d6092e5061b1d061d6e3e53eb9cf) --- desktop/source/lib/init.cxx | 58 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) 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 #include #include +#include #include #include #include +#include +#include +#include +#include #include #include #include @@ -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 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 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(pThis); @@ -739,6 +796,7 @@ static void doc_initializeForRendering(LibreOfficeKitDocument* pThis) ITiledRenderable* pDoc = getTiledRenderable(pThis); if (pDoc) { + doc_iniUnoCommands(); pDoc->initializeForTiledRendering(); } } -- 2.12.0