diff options
author | Jan Holesovsky <kendy@collabora.com> | 2015-09-15 17:04:58 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2015-09-15 17:07:52 +0200 |
commit | a191076e3b4063a074ebf1a4ef4cded25cebdb8c (patch) | |
tree | b9744d0c162c95e103f5bb4e4963285556d33eb7 /desktop | |
parent | 0561298b793f065728611cbba7a216514224a9cf (diff) |
LOK: Avoid crash when the command is not available in the given component.
In that case we get a NULL pSlot.
Change-Id: I38783ed198b1ab9860398f59ef872a295cbae6f8
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index e56284cdb7cb..87471454b5d2 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -555,7 +555,7 @@ static void doc_iniUnoCommands () util::URL aCommandURL; const SfxSlot* pSlot = NULL; SfxViewShell* pViewShell = SfxViewShell::Current(); - SfxViewFrame* pViewFrame = (pViewShell ? pViewShell->GetViewFrame() : NULL); + SfxViewFrame* pViewFrame = pViewShell? pViewShell->GetViewFrame(): NULL; // check if Frame-Controller were created. if (!pViewShell && !pViewFrame) @@ -564,26 +564,21 @@ static void doc_iniUnoCommands () return; } - SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool( pViewFrame ); - uno::Reference<util::XURLTransformer> xParser = - util::URLTransformer::create(xContext); + 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++ - ) + 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()) + // when null, this command is not supported by the given component + // (like eg. Calc does not have ".uno:DefaultBullet" etc.) + if (pSlot) { - SAL_WARN("lok", "iniUnoCommands: No XDispatch interface : " + aCommandURL.Complete); + // Initialize slot to dispatch .uno: Command. + pViewFrame->GetBindings().GetDispatch(pSlot, aCommandURL, false); } } } |