From 2d6f56e4f7e492ba5394a86f13bc710bf6c68335 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sat, 16 Nov 2019 16:30:59 +0000 Subject: cid#1455212 Uncaught exception MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I75956bfc3dccdf3ef400c3b9dcea40606abb8504 Reviewed-on: https://gerrit.libreoffice.org/82987 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sfx2/source/control/request.cxx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'sfx2/source/control/request.cxx') diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx index fcdb5c036f32..ec3d36eb4467 100644 --- a/sfx2/source/control/request.cxx +++ b/sfx2/source/control/request.cxx @@ -74,7 +74,7 @@ struct SfxRequest_Impl: public SfxListener SfxViewFrame* pViewFrame; css::uno::Reference< css::frame::XDispatchRecorder > xRecorder; - css::uno::Reference< uno::XComponentContext > xContext; + css::uno::Reference< css::util::XURLTransformer > xTransform; explicit SfxRequest_Impl( SfxRequest *pOwner ) : pAnti( pOwner) @@ -88,7 +88,6 @@ struct SfxRequest_Impl: public SfxListener , nCallMode( SfxCallMode::SYNCHRON ) , bAllowRecording( false ) , pViewFrame(nullptr) - , xContext(comphelper::getProcessComponentContext()) { } @@ -167,6 +166,8 @@ SfxRequest::SfxRequest { pImpl->SetPool( &pImpl->pShell->GetPool() ); pImpl->xRecorder = SfxRequest::GetMacroRecorder(pImpl->pViewFrame); + if (pImpl->xRecorder) + pImpl->xTransform = util::URLTransformer::create(comphelper::getProcessComponentContext()); pImpl->aTarget = pImpl->pShell->GetName(); } else @@ -206,6 +207,8 @@ SfxRequest::SfxRequest { pImpl->SetPool( &pImpl->pShell->GetPool() ); pImpl->xRecorder = SfxRequest::GetMacroRecorder( pViewFrame ); + if (pImpl->xRecorder) + pImpl->xTransform = util::URLTransformer::create(comphelper::getProcessComponentContext()); pImpl->aTarget = pImpl->pShell->GetName(); } else @@ -333,10 +336,11 @@ void SfxRequest_Impl::Record */ { - OUString aCmd = ".uno:" + OUString::createFromAscii( pSlot->GetUnoName() ); if(!xRecorder.is()) return; + OUString aCmd = ".uno:" + OUString::createFromAscii( pSlot->GetUnoName() ); + uno::Reference< container::XIndexReplace > xReplace( xRecorder, uno::UNO_QUERY ); if ( xReplace.is() && aCmd == ".uno:InsertText" ) { @@ -360,8 +364,6 @@ void SfxRequest_Impl::Record } } - uno::Reference< util::XURLTransformer > xTransform = util::URLTransformer::create( xContext ); - css::util::URL aURL; aURL.Complete = aCmd; xTransform->parseStrict(aURL); @@ -392,6 +394,8 @@ void SfxRequest::Record_Impl pImpl->pShell = &rSh; pImpl->pSlot = &rSlot; pImpl->xRecorder = xRecorder; + if (!pImpl->xTransform) + pImpl->xTransform = util::URLTransformer::create(comphelper::getProcessComponentContext()); pImpl->aTarget = rSh.GetName(); pImpl->pViewFrame = pViewFrame; } -- cgit