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

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