diff options
author | Vishv Brahmbhatt <vishvbrahmbhatt19@gmail.com> | 2013-09-13 01:01:52 +0530 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-12-03 20:30:18 +0100 |
commit | 9de4fe985349401fda68e8384860b14ef6b071d2 (patch) | |
tree | 2e8618c1881635aa19262e292a8b6c6e69d1fba8 /framework | |
parent | 5d8001c801efeed3dced312862d667d650b5dbfa (diff) |
Code clean-up/consolidation task.
Removing the duplicate code,and consolidating changes
by using method "getExpandedFilePath" of comphelper.
Signed-off-by: Stephan Bergmann <sbergman@redhat.com>: adapted to recent change
from comphelper::getExpandedFilePath to comphelper::getExpandedUri; fixed the
two changes in framework to actually modify the by--non-const--ref argument;
fixed a loplugin:unreffun. More clean-up to follow.
Change-Id: Ie8875bcb61b616385bd64151f0a915bf7cce04e5
Diffstat (limited to 'framework')
-rw-r--r-- | framework/source/fwe/classes/addonsoptions.cxx | 15 | ||||
-rw-r--r-- | framework/source/uielement/imagebuttontoolbarcontroller.cxx | 38 |
2 files changed, 6 insertions, 47 deletions
diff --git a/framework/source/fwe/classes/addonsoptions.cxx b/framework/source/fwe/classes/addonsoptions.cxx index 975a25642b04..45af778e3b78 100644 --- a/framework/source/fwe/classes/addonsoptions.cxx +++ b/framework/source/fwe/classes/addonsoptions.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <rtl/ustrbuf.hxx> #include <rtl/uri.hxx> +#include <comphelper/getexpandeduri.hxx> #include <comphelper/processfactory.hxx> #include <vcl/dibtools.hxx> #include <vcl/graph.hxx> @@ -186,8 +187,6 @@ using namespace ::com::sun::star; #define OFFSET_MERGESTATUSBAR_MERGECONTEXT 4 #define OFFSET_MERGESTATUSBAR_STATUSBARITEMS 5 -#define EXPAND_PROTOCOL "vnd.sun.star.expand:" - // private declarations! /*-**************************************************************************************************************** @@ -1340,16 +1339,8 @@ bool AddonsOptions_Impl::HasAssociatedImages( const OUString& aURL ) void AddonsOptions_Impl::SubstituteVariables( OUString& aURL ) { - if ( aURL.startsWith( EXPAND_PROTOCOL ) ) - { - // cut protocol - OUString macro( aURL.copy( sizeof ( EXPAND_PROTOCOL ) -1 ) ); - // decode uric class chars - macro = ::rtl::Uri::decode( - macro, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); - // expand macro string - aURL = m_xMacroExpander->expandMacros( macro ); - } + aURL = comphelper::getExpandedUri( + comphelper::getProcessComponentContext(), aURL); } Image AddonsOptions_Impl::ReadImageFromURL(const OUString& aImageURL) diff --git a/framework/source/uielement/imagebuttontoolbarcontroller.cxx b/framework/source/uielement/imagebuttontoolbarcontroller.cxx index d41f8b870f42..43ebc34c3817 100644 --- a/framework/source/uielement/imagebuttontoolbarcontroller.cxx +++ b/framework/source/uielement/imagebuttontoolbarcontroller.cxx @@ -25,11 +25,11 @@ #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/frame/XControlNotificationListener.hpp> -#include <com/sun/star/util/theMacroExpander.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <rtl/uri.hxx> #include <osl/mutex.hxx> +#include <comphelper/getexpandeduri.hxx> #include <comphelper/processfactory.hxx> #include <unotools/ucbstreamhelper.hxx> #include <vcl/svapp.hxx> @@ -50,48 +50,16 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::util; -#define EXPAND_PROTOCOL "vnd.sun.star.expand:" - const ::Size aImageSizeSmall( 16, 16 ); const ::Size aImageSizeBig( 26, 26 ); namespace framework { -static uno::WeakReference< util::XMacroExpander > m_xMacroExpander; - -uno::Reference< util::XMacroExpander > GetMacroExpander() -{ - uno::Reference< util::XMacroExpander > xMacroExpander( m_xMacroExpander ); - if ( !xMacroExpander.is() ) - { - SolarMutexGuard aSolarMutexGuard; - - if ( !xMacroExpander.is() ) - { - uno::Reference< uno::XComponentContext > xContext( - comphelper::getProcessComponentContext() ); - m_xMacroExpander = util::theMacroExpander::get(xContext); - xMacroExpander = m_xMacroExpander; - } - } - - return xMacroExpander; -} - static void SubstituteVariables( OUString& aURL ) { - if ( aURL.startsWith( EXPAND_PROTOCOL ) ) - { - uno::Reference< util::XMacroExpander > xMacroExpander = GetMacroExpander(); - - // cut protocol - OUString aMacro( aURL.copy( sizeof ( EXPAND_PROTOCOL ) -1 ) ); - // decode uric class chars - aMacro = ::rtl::Uri::decode( aMacro, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); - // expand macro string - aURL = xMacroExpander->expandMacros( aMacro ); - } + aURL = comphelper::getExpandedUri( + comphelper::getProcessComponentContext(), aURL); } ImageButtonToolbarController::ImageButtonToolbarController( |