[Libreoffice-commits] core.git: 2 commits - basic/source cui/source framework/source unotools/source
Stephan Bergmann
sbergman at redhat.com
Wed Dec 3 11:30:53 PST 2014
basic/source/inc/namecont.hxx | 2
basic/source/uno/namecont.cxx | 33 -------
cui/source/options/treeopt.cxx | 28 ------
framework/source/fwe/classes/addonsoptions.cxx | 23 -----
framework/source/uielement/imagebuttontoolbarcontroller.cxx | 39 ---------
unotools/source/config/lingucfg.cxx | 51 +++---------
6 files changed, 26 insertions(+), 150 deletions(-)
New commits:
commit 179810cdf254177197a3108e970d9555468cd265
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Dec 3 20:29:58 2014 +0100
Further clean-up
Change-Id: I20049b482c831e4ac2221fddfe80deb9847e72c3
diff --git a/basic/source/inc/namecont.hxx b/basic/source/inc/namecont.hxx
index bcbd245..c1c90d3 100644
--- a/basic/source/inc/namecont.hxx
+++ b/basic/source/inc/namecont.hxx
@@ -34,7 +34,6 @@
#include <com/sun/star/ucb/XSimpleFileAccess3.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/io/XInputStream.hpp>
-#include <com/sun/star/util/XMacroExpander.hpp>
#include <com/sun/star/util/XStringSubstitution.hpp>
#include <com/sun/star/document/XStorageBasedDocument.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -231,7 +230,6 @@ class SfxLibraryContainer : public SfxLibraryContainer_BASE, public ::utl::OEven
protected:
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess3 > mxSFI;
- ::com::sun::star::uno::Reference< ::com::sun::star::util::XMacroExpander > mxMacroExpander;
::com::sun::star::uno::Reference< ::com::sun::star::util::XStringSubstitution > mxStringSubstitution;
::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > mxOwnerDocument;
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index 09fc0e6..d95596d 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -31,7 +31,6 @@
#include <osl/mutex.hxx>
#include <tools/errinf.hxx>
#include <rtl/ustring.hxx>
-#include <rtl/uri.hxx>
#include <rtl/strbuf.hxx>
#include <comphelper/getexpandeduri.hxx>
#include <comphelper/processfactory.hxx>
@@ -60,7 +59,6 @@
#include <com/sun/star/script/vba/VBAScriptEventId.hpp>
#include <com/sun/star/ucb/SimpleFileAccess.hpp>
#include <com/sun/star/util/PathSubstitution.hpp>
-#include <com/sun/star/util/theMacroExpander.hpp>
#include <com/sun/star/deployment/ExtensionManager.hpp>
#include <comphelper/storagehelper.hxx>
#include <cppuhelper/exc_hlp.hxx>
@@ -92,8 +90,6 @@ using namespace osl;
using com::sun::star::uno::Reference;
-using ::rtl::Uri;
-
// #i34411: Flag for error handling during migration
static bool GbMigrationSuppressErrors = false;
@@ -1384,10 +1380,6 @@ throw(WrappedTargetException, RuntimeException)
return true;
}
-
-
-#define EXPAND_PROTOCOL "vnd.sun.star.expand"
-
OUString SfxLibraryContainer::createAppLibraryFolder( SfxLibrary* pLib, const OUString& aName )
{
OUString aLibDirPath = pLib->maStorageURL;
@@ -2877,23 +2869,8 @@ void SAL_CALL SfxLibraryContainer::exportLibrary( const OUString& Name, const OU
OUString SfxLibraryContainer::expand_url( const OUString& url )
throw(::com::sun::star::uno::RuntimeException)
{
- if (url.startsWith( EXPAND_PROTOCOL ":" ))
+ if (url.startsWithIgnoreAsciiCase( "vnd.sun.star.expand:" ))
{
- if( !mxMacroExpander.is() )
- {
- Reference< util::XMacroExpander > xExpander = util::theMacroExpander::get(mxContext);
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !mxMacroExpander.is() )
- {
- mxMacroExpander = xExpander;
- }
- }
-
- if( !mxMacroExpander.is() )
- {
- return url;
- }
-
return comphelper::getExpandedUri(mxContext, url);
}
else if( mxStringSubstitution.is() )
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index dc0c169..05bb302 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -65,7 +65,6 @@
#include <com/sun/star/frame/ModuleManager.hpp>
#include <com/sun/star/loader/CannotActivateFactoryException.hpp>
#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>
@@ -77,7 +76,6 @@
#include <osl/module.hxx>
#include <osl/process.h>
#include <rtl/bootstrap.hxx>
-#include <rtl/uri.hxx>
#include <sfx2/app.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/module.hxx>
@@ -120,8 +118,6 @@ using namespace ::com::sun::star::linguistic2;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::util;
-#define EXPAND_PROTOCOL "vnd.sun.star.expand:"
-
LastPageSaver* OfaTreeOptionsDialog::pLastPageSaver = NULL;
// some stuff for easier changes for SvtViewOptions
@@ -823,7 +819,6 @@ void OfaTreeOptionsDialog::ActivateLastSelection()
SvTreeListEntry* pEntry = NULL;
if ( pLastPageSaver )
{
- OUString sExpand( EXPAND_PROTOCOL );
OUString sLastURL = bIsFromExtensionManager ? pLastPageSaver->m_sLastPageURL_ExtMgr
: pLastPageSaver->m_sLastPageURL_Tools;
if ( sLastURL.isEmpty() )
@@ -832,17 +827,8 @@ void OfaTreeOptionsDialog::ActivateLastSelection()
: pLastPageSaver->m_sLastPageURL_Tools;
}
- // MacroExpander to convert "expand"-URL to "file"-URL
- Reference< XMacroExpander > xMacroExpander;
bool bMustExpand = ( INetURLObject( sLastURL ).GetProtocol() == INET_PROT_FILE );
- if ( bMustExpand )
- {
- Reference< XComponentContext > xContext(
- comphelper::getProcessComponentContext() );
- xMacroExpander = theMacroExpander::get(xContext);
- }
-
SvTreeListEntry* pTemp = pTreeLB->First();
while( !pEntry && pTemp )
{
@@ -851,9 +837,7 @@ void OfaTreeOptionsDialog::ActivateLastSelection()
{
OptionsPageInfo* pPageInfo = (OptionsPageInfo*)pTemp->GetUserData();
OUString sPageURL = pPageInfo->m_sPageURL;
- if ( bMustExpand
- && !sPageURL.isEmpty()
- && sPageURL.startsWith( sExpand ) )
+ if ( bMustExpand )
{
sPageURL = comphelper::getExpandedUri(
comphelper::getProcessComponentContext(), sPageURL);
diff --git a/framework/source/fwe/classes/addonsoptions.cxx b/framework/source/fwe/classes/addonsoptions.cxx
index 45af778..a3e57c7 100644
--- a/framework/source/fwe/classes/addonsoptions.cxx
+++ b/framework/source/fwe/classes/addonsoptions.cxx
@@ -24,10 +24,7 @@
#include <tools/stream.hxx>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Sequence.hxx>
-#include <com/sun/star/util/theMacroExpander.hpp>
-#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>
@@ -339,7 +336,6 @@ class AddonsOptions_Impl : public ConfigItem
AddonToolBars m_aCachedToolBarPartProperties;
std::vector< OUString > m_aCachedToolBarPartResourceNames;
Sequence< Sequence< PropertyValue > > m_aCachedHelpMenuProperties;
- Reference< util::XMacroExpander > m_xMacroExpander;
ImageManager m_aImageManager;
Sequence< Sequence< PropertyValue > > m_aEmptyAddonToolBar;
MergeMenuInstructionContainer m_aCachedMergeMenuInsContainer;
@@ -410,10 +406,6 @@ AddonsOptions_Impl::AddonsOptions_Impl()
m_aPropMergeStatusbarNames[ OFFSET_MERGESTATUSBAR_MERGECONTEXT ] = PROPERTYNAME_MERGESTATUSBAR_MERGECONTEXT;
m_aPropMergeStatusbarNames[ OFFSET_MERGESTATUSBAR_STATUSBARITEMS ] = PROPERTYNAME_MERGESTATUSBAR_STATUSBARITEMS;
- Reference< XComponentContext > xContext(
- comphelper::getProcessComponentContext() );
- m_xMacroExpander = util::theMacroExpander::get(xContext);
-
ReadConfigurationData();
// Enable notification mechanism of our baseclass.
diff --git a/framework/source/uielement/imagebuttontoolbarcontroller.cxx b/framework/source/uielement/imagebuttontoolbarcontroller.cxx
index 43ebc34..820722b 100644
--- a/framework/source/uielement/imagebuttontoolbarcontroller.cxx
+++ b/framework/source/uielement/imagebuttontoolbarcontroller.cxx
@@ -27,7 +27,6 @@
#include <com/sun/star/frame/XControlNotificationListener.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <rtl/uri.hxx>
#include <osl/mutex.hxx>
#include <comphelper/getexpandeduri.hxx>
#include <comphelper/processfactory.hxx>
diff --git a/unotools/source/config/lingucfg.cxx b/unotools/source/config/lingucfg.cxx
index cd504ec..9194c83 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 <rtl/uri.hxx>
#include <rtl/instance.hxx>
#include <osl/mutex.hxx>
#include <i18nlangtag/mslangid.hxx>
@@ -43,8 +42,6 @@
using namespace com::sun::star;
-using ::rtl::Uri;
-
#define FILE_PROTOCOL "file:///"
namespace
@@ -927,33 +924,20 @@ static bool lcl_GetFileUrlFromOrigin(
OUString /*out*/ &rFileUrl,
const OUString &rOrigin )
{
- bool bSuccess = false;
- if (!rOrigin.isEmpty())
+ OUString aURL(
+ comphelper::getExpandedUri(
+ comphelper::getProcessComponentContext(), rOrigin));
+ if (aURL.startsWith( FILE_PROTOCOL ))
{
- OUString aURL( rOrigin );
- if ( aURL.startsWith( "vnd.sun.star.expand:" ) )
- {
- aURL = comphelper::getExpandedUri(
- comphelper::getProcessComponentContext(), aURL);
- bool bIsFileUrl = aURL.startsWith( FILE_PROTOCOL );
- if (bIsFileUrl)
- {
- rFileUrl = aURL;
- bSuccess = true;
- }
- else
- {
- SAL_WARN(
- "unotools.config", "not a file URL, <" << aURL << ">" );
- }
- }
- else
- {
- SAL_WARN(
- "unotools.config", "failed to get file URL, <" << aURL << ">" );
- }
+ rFileUrl = aURL;
+ return true;
+ }
+ else
+ {
+ SAL_WARN(
+ "unotools.config", "not a file URL, <" << aURL << ">" );
+ return false;
}
- return bSuccess;
}
bool SvtLinguConfig::GetDictionaryEntry(
commit 9de4fe985349401fda68e8384860b14ef6b071d2
Author: Vishv Brahmbhatt <vishvbrahmbhatt19 at gmail.com>
Date: Fri Sep 13 01:01:52 2013 +0530
Code clean-up/consolidation task.
Removing the duplicate code,and consolidating changes
by using method "getExpandedFilePath" of comphelper.
Signed-off-by: Stephan Bergmann <sbergman at 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
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index da1ec5a..09fc0e6 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 92ed59b..dc0c169 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 975a256..45af778 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 d41f8b8..43ebc34 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 24f9fc2..cd504ec 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)
{
More information about the Libreoffice-commits
mailing list