summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVishv Brahmbhatt <vishvbrahmbhatt19@gmail.com>2013-09-13 01:01:52 +0530
committerStephan Bergmann <sbergman@redhat.com>2014-12-03 20:30:18 +0100
commit9de4fe985349401fda68e8384860b14ef6b071d2 (patch)
tree2e8618c1881635aa19262e292a8b6c6e69d1fba8
parent5d8001c801efeed3dced312862d667d650b5dbfa (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
-rw-r--r--basic/source/uno/namecont.cxx10
-rw-r--r--cui/source/options/treeopt.cxx10
-rw-r--r--framework/source/fwe/classes/addonsoptions.cxx15
-rw-r--r--framework/source/uielement/imagebuttontoolbarcontroller.cxx38
-rw-r--r--unotools/source/config/lingucfg.cxx17
5 files changed, 16 insertions, 74 deletions
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index da1ec5a6506a..09fc0e63ec06 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -33,6 +33,7 @@
#include <rtl/ustring.hxx>
#include <rtl/uri.hxx>
#include <rtl/strbuf.hxx>
+#include <comphelper/getexpandeduri.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/anytostring.hxx>
@@ -2892,13 +2893,8 @@ OUString SfxLibraryContainer::expand_url( const OUString& url )
{
return url;
}
- // cut protocol
- OUString macro( url.copy( sizeof (EXPAND_PROTOCOL ":") -1 ) );
- // decode uric class chars
- macro = Uri::decode( macro, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
- // expand macro string
- OUString ret( mxMacroExpander->expandMacros( macro ) );
- return ret;
+
+ return comphelper::getExpandedUri(mxContext, url);
}
else if( mxStringSubstitution.is() )
{
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index 92ed59b1d052..dc0c16915a7e 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -67,6 +67,7 @@
#include <com/sun/star/linguistic2/LinguProperties.hpp>
#include <com/sun/star/util/theMacroExpander.hpp>
#include <com/sun/star/setup/UpdateCheck.hpp>
+#include <comphelper/getexpandeduri.hxx>
#include <comphelper/processfactory.hxx>
#include <editeng/langitem.hxx>
#include <editeng/optitems.hxx>
@@ -854,13 +855,8 @@ void OfaTreeOptionsDialog::ActivateLastSelection()
&& !sPageURL.isEmpty()
&& sPageURL.startsWith( sExpand ) )
{
- // cut protocol
- OUString sTemp( sPageURL.copy( sExpand.getLength() ) );
- // decode uri class chars
- sTemp = ::rtl::Uri::decode(
- sTemp, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
- // expand string
- sPageURL = xMacroExpander->expandMacros( sTemp );
+ sPageURL = comphelper::getExpandedUri(
+ comphelper::getProcessComponentContext(), sPageURL);
}
if ( ( !bIsFromExtensionManager
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(
diff --git a/unotools/source/config/lingucfg.cxx b/unotools/source/config/lingucfg.cxx
index 24f9fc2c488e..cd504ec4b4d2 100644
--- a/unotools/source/config/lingucfg.cxx
+++ b/unotools/source/config/lingucfg.cxx
@@ -27,7 +27,6 @@
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/container/XNameReplace.hpp>
-#include <com/sun/star/util/theMacroExpander.hpp>
#include <rtl/uri.hxx>
#include <rtl/instance.hxx>
#include <osl/mutex.hxx>
@@ -37,7 +36,7 @@
#include <unotools/lingucfg.hxx>
#include <unotools/linguprops.hxx>
#include <sal/macros.h>
-
+#include <comphelper/getexpandeduri.hxx>
#include <comphelper/processfactory.hxx>
#include "itemholder1.hxx"
@@ -46,7 +45,6 @@ using namespace com::sun::star;
using ::rtl::Uri;
-#define EXPAND_PROTOCOL "vnd.sun.star.expand:"
#define FILE_PROTOCOL "file:///"
namespace
@@ -933,17 +931,10 @@ static bool lcl_GetFileUrlFromOrigin(
if (!rOrigin.isEmpty())
{
OUString aURL( rOrigin );
- if ( aURL.startsWith( EXPAND_PROTOCOL ) )
+ if ( aURL.startsWith( "vnd.sun.star.expand:" ) )
{
- // cut protocol
- OUString aMacro( aURL.copy( sizeof ( EXPAND_PROTOCOL ) -1 ) );
- // decode uric class chars
- aMacro = Uri::decode( aMacro, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
- // expand macro string
- aURL = util::theMacroExpander::get(
- comphelper::getProcessComponentContext() )->expandMacros(
- aMacro );
-
+ aURL = comphelper::getExpandedUri(
+ comphelper::getProcessComponentContext(), aURL);
bool bIsFileUrl = aURL.startsWith( FILE_PROTOCOL );
if (bIsFileUrl)
{