Blame SOURCES/0112-lok-initialize-UNO-url-command-dispatch.patch

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