Blame SOURCES/0114-LOK-Avoid-crash-when-the-command-is-not-available-in.patch

135360
From a673fc9e4b1d04c26a486caa8babf7bd003d5b38 Mon Sep 17 00:00:00 2001
135360
From: Jan Holesovsky <kendy@collabora.com>
135360
Date: Tue, 15 Sep 2015 17:04:58 +0200
135360
Subject: [PATCH 114/398] LOK: Avoid crash when the command is not available in
135360
 the given component.
135360
135360
In that case we get a NULL pSlot.
135360
135360
Change-Id: I38783ed198b1ab9860398f59ef872a295cbae6f8
135360
(cherry picked from commit a191076e3b4063a074ebf1a4ef4cded25cebdb8c)
135360
---
135360
 desktop/source/lib/init.cxx | 23 +++++++++--------------
135360
 1 file changed, 9 insertions(+), 14 deletions(-)
135360
135360
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
135360
index e56284cdb7cb..87471454b5d2 100644
135360
--- a/desktop/source/lib/init.cxx
135360
+++ b/desktop/source/lib/init.cxx
135360
@@ -555,7 +555,7 @@ static void doc_iniUnoCommands ()
135360
     util::URL aCommandURL;
135360
     const SfxSlot* pSlot = NULL;
135360
     SfxViewShell* pViewShell = SfxViewShell::Current();
135360
-    SfxViewFrame* pViewFrame = (pViewShell ? pViewShell->GetViewFrame() : NULL);
135360
+    SfxViewFrame* pViewFrame = pViewShell? pViewShell->GetViewFrame(): NULL;
135360
 
135360
     // check if Frame-Controller were created.
135360
     if (!pViewShell && !pViewFrame)
135360
@@ -564,26 +564,21 @@ static void doc_iniUnoCommands ()
135360
         return;
135360
     }
135360
 
135360
-    SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool( pViewFrame );
135360
-    uno::Reference<util::XURLTransformer> xParser =
135360
-        util::URLTransformer::create(xContext);
135360
+    SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool(pViewFrame);
135360
+    uno::Reference<util::XURLTransformer> xParser(util::URLTransformer::create(xContext));
135360
 
135360
-    for (
135360
-        sal_uInt32 nIterator = 0;
135360
-        nIterator < SAL_N_ELEMENTS(sUnoCommands);
135360
-        nIterator++
135360
-        )
135360
+    for (sal_uInt32 nIterator = 0; nIterator < SAL_N_ELEMENTS(sUnoCommands); nIterator++)
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
+        // when null, this command is not supported by the given component
135360
+        // (like eg. Calc does not have ".uno:DefaultBullet" etc.)
135360
+        if (pSlot)
135360
         {
135360
-            SAL_WARN("lok", "iniUnoCommands: No XDispatch interface : " + aCommandURL.Complete);
135360
+            // Initialize slot to dispatch .uno: Command.
135360
+            pViewFrame->GetBindings().GetDispatch(pSlot, aCommandURL, false);
135360
         }
135360
     }
135360
 }
135360
-- 
135360
2.12.0
135360