summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-02-08 11:02:37 +0200
committerNoel Grandin <noel@peralex.com>2013-02-11 08:02:13 +0200
commit591ef7844079e93ff627c7e194c04d520d2f1d55 (patch)
tree39c16f140ef2eae20f00a6c078d49519d4bd6bdc /unotools
parent81c967e06e4247dec7ecb9ffec695ba31cb4f057 (diff)
fdo#46808, Use singleton util::theMacroExpander new-style constructor
And deprecate the old-style service util::MacroExpander Change-Id: Ifcefe31a8f8c68c6d44d6ec19616727eb607e1cd
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/config/lingucfg.cxx15
-rw-r--r--unotools/source/config/moduleoptions.cxx16
-rw-r--r--unotools/source/config/pathoptions.cxx24
3 files changed, 17 insertions, 38 deletions
diff --git a/unotools/source/config/lingucfg.cxx b/unotools/source/config/lingucfg.cxx
index 45fc0a7ac0f7..6721821fe8ac 100644
--- a/unotools/source/config/lingucfg.cxx
+++ b/unotools/source/config/lingucfg.cxx
@@ -24,7 +24,7 @@
#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/XMacroExpander.hpp"
+#include <com/sun/star/util/theMacroExpander.hpp>
#include <rtl/uri.hxx>
#include <rtl/instance.hxx>
#include <osl/mutex.hxx>
@@ -937,15 +937,8 @@ static uno::Reference< util::XMacroExpander > lcl_GetMacroExpander()
uno::Reference< util::XMacroExpander > xMacroExpander( aG_xMacroExpander );
if ( !xMacroExpander.is() )
{
- if ( !xMacroExpander.is() )
- {
- uno::Reference< uno::XComponentContext > xContext(
- comphelper::getProcessComponentContext() );
- aG_xMacroExpander = uno::Reference< com::sun::star::util::XMacroExpander >( xContext->getValueByName(
- OUString(RTL_CONSTASCII_USTRINGPARAM("/singletons/com.sun.star.util.theMacroExpander"))),
- uno::UNO_QUERY );
- xMacroExpander = aG_xMacroExpander;
- }
+ aG_xMacroExpander = util::theMacroExpander::get( comphelper::getProcessComponentContext() );
+ xMacroExpander = aG_xMacroExpander;
}
return xMacroExpander;
@@ -958,7 +951,7 @@ static bool lcl_GetFileUrlFromOrigin(
uno::Reference< util::XMacroExpander > &rxMacroExpander )
{
bool bSuccess = false;
- if (!rOrigin.isEmpty() && rxMacroExpander.is())
+ if (!rOrigin.isEmpty())
{
rtl::OUString aURL( rOrigin );
if (( aURL.compareToAscii( RTL_CONSTASCII_STRINGPARAM( EXPAND_PROTOCOL )) == 0 ) &&
diff --git a/unotools/source/config/moduleoptions.cxx b/unotools/source/config/moduleoptions.cxx
index 4c03a2cd93dd..9023d8d700b6 100644
--- a/unotools/source/config/moduleoptions.cxx
+++ b/unotools/source/config/moduleoptions.cxx
@@ -98,8 +98,6 @@ struct FactoryInfo
FactoryInfo()
{
free();
- // @@@ should be supplied from outside!
- xSMgr = ::comphelper::getProcessServiceFactory();
}
//---------------------------------------------------------------------------------------------------------
@@ -262,10 +260,7 @@ struct FactoryInfo
{
if ( !xSubstVars.is() )
{
- css::uno::Reference< css::uno::XComponentContext > xContext( comphelper::getComponentContext(xSMgr) );
- xSubstVars
- = css::uno::Reference< css::util::XStringSubstitution >(
- css::util::PathSubstitution::create(xContext) );
+ xSubstVars.set( css::util::PathSubstitution::create(::comphelper::getProcessComponentContext()) );
}
return xSubstVars;
}
@@ -286,7 +281,6 @@ struct FactoryInfo
sal_Bool bChangedIcon :1 ;
sal_Bool bDefaultFilterReadonly :1 ;
- css::uno::Reference< css::lang::XMultiServiceFactory > xSMgr;
css::uno::Reference< css::util::XStringSubstitution > xSubstVars;
};
@@ -1271,18 +1265,16 @@ SvtModuleOptions::EFactory SvtModuleOptions::ClassifyFactoryByServiceName(const
SvtModuleOptions::EFactory SvtModuleOptions::ClassifyFactoryByURL(const ::rtl::OUString& sURL ,
const css::uno::Sequence< css::beans::PropertyValue >& lMediaDescriptor)
{
- css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
- if (!xSMGR.is())
- return E_UNKNOWN_FACTORY;
+ css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
css::uno::Reference< css::container::XNameAccess > xFilterCfg;
css::uno::Reference< css::container::XNameAccess > xTypeCfg ;
try
{
xFilterCfg = css::uno::Reference< css::container::XNameAccess >(
- xSMGR->createInstance(::rtl::OUString("com.sun.star.document.FilterFactory")), css::uno::UNO_QUERY);
+ xContext->getServiceManager()->createInstanceWithContext("com.sun.star.document.FilterFactory", xContext), css::uno::UNO_QUERY);
xTypeCfg = css::uno::Reference< css::container::XNameAccess >(
- xSMGR->createInstance(::rtl::OUString("com.sun.star.document.TypeDetection")), css::uno::UNO_QUERY);
+ xContext->getServiceManager()->createInstanceWithContext("com.sun.star.document.TypeDetection", xContext), css::uno::UNO_QUERY);
}
catch(const css::uno::RuntimeException&)
{ throw; }
diff --git a/unotools/source/config/pathoptions.cxx b/unotools/source/config/pathoptions.cxx
index a4fe929024ee..507c902df9e2 100644
--- a/unotools/source/config/pathoptions.cxx
+++ b/unotools/source/config/pathoptions.cxx
@@ -38,7 +38,7 @@
#include <com/sun/star/util/PathSubstitution.hpp>
#include <com/sun/star/util/XStringSubstitution.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/util/XMacroExpander.hpp>
+#include <com/sun/star/util/theMacroExpander.hpp>
#include <rtl/instance.hxx>
#include <itemholder1.hxx>
@@ -416,11 +416,11 @@ OUString SvtPathOptions_Impl::SubstVar( const OUString& rVar ) const
SvtPathOptions_Impl::SvtPathOptions_Impl() :
m_aPathArray( (sal_Int32)SvtPathOptions::PATH_COUNT )
{
- Reference< XMultiServiceFactory > xSMgr = comphelper::getProcessServiceFactory();
+ Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
// Create necessary services
- m_xPathSettings = Reference< XFastPropertySet >( xSMgr->createInstance(
- ::rtl::OUString( "com.sun.star.util.PathSettings" )),
+ m_xPathSettings = Reference< XFastPropertySet >( xContext->getServiceManager()->createInstanceWithContext(
+ "com.sun.star.util.PathSettings", xContext),
UNO_QUERY );
if ( !m_xPathSettings.is() )
{
@@ -431,9 +431,8 @@ SvtPathOptions_Impl::SvtPathOptions_Impl() :
Reference< XInterface >() );
}
- ::comphelper::ComponentContext aContext( xSMgr );
- m_xSubstVariables.set( PathSubstitution::create(aContext.getUNOContext()) );
- m_xMacroExpander.set( aContext.getSingleton( "com.sun.star.util.theMacroExpander" ), UNO_QUERY_THROW );
+ m_xSubstVariables.set( PathSubstitution::create(xContext) );
+ m_xMacroExpander = theMacroExpander::get(xContext);
// Create temporary hash map to have a mapping between property names and property handles
Reference< XPropertySet > xPropertySet = Reference< XPropertySet >( m_xPathSettings, UNO_QUERY );
@@ -944,14 +943,9 @@ sal_Bool SvtPathOptions::SearchFile( String& rIniFile, Paths ePath )
}
if ( aObj.GetProtocol() == INET_PROT_VND_SUN_STAR_EXPAND )
{
- ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
- Reference< XMacroExpander > xMacroExpander( aContext.getSingleton( "com.sun.star.util.theMacroExpander" ), UNO_QUERY );
- OSL_ENSURE( xMacroExpander.is(), "SvtPathOptions::SearchFile: unable to access the MacroExpander singleton!" );
- if ( xMacroExpander.is() )
- {
- const ::rtl::OUString sExpandedPath = xMacroExpander->expandMacros( aObj.GetURLPath( INetURLObject::DECODE_WITH_CHARSET ) );
- aObj.SetURL( sExpandedPath );
- }
+ Reference< XMacroExpander > xMacroExpander = theMacroExpander::get( ::comphelper::getProcessComponentContext() );
+ const ::rtl::OUString sExpandedPath = xMacroExpander->expandMacros( aObj.GetURLPath( INetURLObject::DECODE_WITH_CHARSET ) );
+ aObj.SetURL( sExpandedPath );
}
sal_Int32 nIniIndex = 0;