diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-01-27 09:51:58 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-02-06 12:03:25 +0100 |
commit | 094f92bb789ecd24793c5843bfae13e79122fc5a (patch) | |
tree | e0bcb505f942a7f323cdbc9419eede5723165f5c | |
parent | a315454f349469923490e4116806ee19263849b8 (diff) |
Introduce com.sun.star.util.thePathSettings singleton.
To replace single-instance com.sun.star.util.PathSettings service,
incorrectly converted in 89b0017b22889af6a8afe28b94c06e7095dc8c6f
Keeping util::PathSettings::create in
sc/source/ui/vba/vbaapplication.cxx because for some reason
util::thePathSettings::get does not work in sc_macros_test
while testing sc/qa/extras/testdocuments/Ranges.xls.
Change-Id: I75b68ae56ac5b58f72416070dba100ab3ab70fe8
21 files changed, 173 insertions, 147 deletions
diff --git a/cui/inc/pch/precompiled_cui.hxx b/cui/inc/pch/precompiled_cui.hxx index 42a15602e84a..f04babaa0d56 100644 --- a/cui/inc/pch/precompiled_cui.hxx +++ b/cui/inc/pch/precompiled_cui.hxx @@ -242,7 +242,7 @@ #include <com/sun/star/uno/Sequence.h> #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/util/PathSettings.hpp> +#include <com/sun/star/util/thePathSettings.hpp> #include <com/sun/star/util/URLTransformer.hpp> #include <com/sun/star/util/XChangesBatch.hpp> #include <com/sun/star/util/XFlushable.hpp> diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index d4f5361285aa..1d5349db7e27 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -90,7 +90,7 @@ #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> #include "com/sun/star/ui/dialogs/TemplateDescription.hpp" #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> -#include <com/sun/star/util/PathSettings.hpp> +#include <com/sun/star/util/thePathSettings.hpp> #include "dlgname.hxx" @@ -4927,7 +4927,7 @@ SvxIconSelectorDialog::SvxIconSelectorDialog( Window *pWindow, graphic::GraphicProvider::create( xComponentContext ) ); uno::Reference< css::util::XPathSettings > xPathSettings = - css::util::PathSettings::create( xComponentContext ); + css::util::thePathSettings::get( xComponentContext ); OUString aDirectory = xPathSettings->getUserConfig(); diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx index af138e308674..5aa07b462a18 100644 --- a/cui/source/options/optpath.cxx +++ b/cui/source/options/optpath.cxx @@ -47,7 +47,7 @@ #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp> #include <com/sun/star/ui/dialogs/FolderPicker.hpp> -#include <com/sun/star/util/PathSettings.hpp> +#include <com/sun/star/util/thePathSettings.hpp> #include <officecfg/Office/Common.hxx> #include "optHeaderTabListbox.hxx" #include <vcl/help.hxx> @@ -722,7 +722,7 @@ void SvxPathTabPage::GetPathList( if ( !pImpl->m_xPathSettings.is() ) { Reference< XComponentContext > xContext = comphelper::getProcessComponentContext(); - pImpl->m_xPathSettings = css::util::PathSettings::create( xContext ); + pImpl->m_xPathSettings = css::util::thePathSettings::get( xContext ); } // load internal paths @@ -791,7 +791,7 @@ void SvxPathTabPage::SetPathList( if ( !pImpl->m_xPathSettings.is() ) { Reference< XComponentContext > xContext = comphelper::getProcessComponentContext(); - pImpl->m_xPathSettings = css::util::PathSettings::create( xContext ); + pImpl->m_xPathSettings = css::util::thePathSettings::get( xContext ); } // save user paths diff --git a/framework/inc/pch/precompiled_fwk.hxx b/framework/inc/pch/precompiled_fwk.hxx index 32b8d6dc7f6a..2452b626b87c 100644 --- a/framework/inc/pch/precompiled_fwk.hxx +++ b/framework/inc/pch/precompiled_fwk.hxx @@ -225,7 +225,7 @@ #include <com/sun/star/uri/XUriReference.hpp> #include <com/sun/star/uri/XUriReferenceFactory.hpp> #include <com/sun/star/util/Color.hpp> -#include <com/sun/star/util/PathSettings.hpp> +#include <com/sun/star/util/thePathSettings.hpp> #include <com/sun/star/util/PathSubstitution.hpp> #include <com/sun/star/util/URL.hpp> #include <com/sun/star/util/URLTransformer.hpp> diff --git a/framework/qa/complex/path_settings/PathSettingsTest.java b/framework/qa/complex/path_settings/PathSettingsTest.java index a36c75366744..599b76d46b12 100644 --- a/framework/qa/complex/path_settings/PathSettingsTest.java +++ b/framework/qa/complex/path_settings/PathSettingsTest.java @@ -25,9 +25,9 @@ import com.sun.star.beans.XPropertiesChangeListener; import com.sun.star.beans.XPropertyChangeListener; import com.sun.star.beans.XVetoableChangeListener; import com.sun.star.lang.WrappedTargetException; -import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.AnyConverter; +import com.sun.star.util.thePathSettings; // ---------- junit imports ----------------- import java.util.ArrayList; @@ -43,7 +43,6 @@ import static org.junit.Assert.*; public class PathSettingsTest { - private static XMultiServiceFactory xMSF; // the test object: an instance of the tested service private static Object aPathSettings = null; // the properties of the service @@ -111,9 +110,8 @@ public class PathSettingsTest { try { - xMSF = getMSF(); - aPathSettings = xMSF.createInstance("com.sun.star.comp.framework.PathSettings"); - assertNotNull("Can't instantiate com.sun.star.util.PathSettings.", aPathSettings); + aPathSettings = thePathSettings.get(connection.getComponentContext()); + assertNotNull("Can't instantiate com.sun.star.util.thePathSettings.", aPathSettings); // System.out.println("Implementation: " + util.utils.getImplName(aPathSettings)); // System.out.println("Service: "); util.dbg.getSuppServices(aPathSettings); @@ -954,12 +952,6 @@ public class PathSettingsTest } } - private XMultiServiceFactory getMSF() - { - final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); - return xMSF1; - } - // setup and close connections @BeforeClass public static void setUpConnection() throws Exception diff --git a/framework/source/accelerators/presethandler.cxx b/framework/source/accelerators/presethandler.cxx index efde565eac25..25006679d1e8 100644 --- a/framework/source/accelerators/presethandler.cxx +++ b/framework/source/accelerators/presethandler.cxx @@ -34,7 +34,7 @@ #include <com/sun/star/embed/XTransactedObject.hpp> #include <com/sun/star/embed/FileSystemStorageFactory.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <com/sun/star/util/PathSettings.hpp> +#include <com/sun/star/util/thePathSettings.hpp> #include <vcl/svapp.hxx> #include <cppuhelper/exc_hlp.hxx> @@ -216,7 +216,7 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::getOrCreateRootStorag // <- SAFE ---------------------------------- css::uno::Reference< css::util::XPathSettings > xPathSettings = - css::util::PathSettings::create( xContext ); + css::util::thePathSettings::get( xContext ); OUString sShareLayer = xPathSettings->getBasePathShareLayer(); @@ -274,7 +274,7 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::getOrCreateRootStorag // <- SAFE ---------------------------------- css::uno::Reference< css::util::XPathSettings > xPathSettings = - css::util::PathSettings::create( xContext ); + css::util::thePathSettings::get( xContext ); OUString sUserLayer = xPathSettings->getBasePathUserLayer(); diff --git a/framework/source/services/pathsettings.cxx b/framework/source/services/pathsettings.cxx index 472fac3b189c..dad1a43746d3 100644 --- a/framework/source/services/pathsettings.cxx +++ b/framework/source/services/pathsettings.cxx @@ -17,18 +17,13 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <threadhelp/readguard.hxx> -#include <threadhelp/writeguard.hxx> -#include <threadhelp/threadhelpbase.hxx> #include <properties.h> #include <stdtypes.h> - -#include "helper/mischelper.hxx" +#include <helper/mischelper.hxx> #include <com/sun/star/beans/Property.hpp> #include <com/sun/star/beans/XProperty.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> -#include <com/sun/star/container/XContainer.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/util/XChangesNotifier.hpp> #include <com/sun/star/util/PathSubstitution.hpp> @@ -42,12 +37,10 @@ #include <rtl/ustrbuf.hxx> #include <cppuhelper/propshlp.hxx> -#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/compbase3.hxx> #include <cppuhelper/supportsservice.hxx> #include <comphelper/sequence.hxx> -#include <comphelper/sequenceasvector.hxx> #include <comphelper/configurationhelper.hxx> -#include <comphelper/processfactory.hxx> #include <unotools/configitem.hxx> #include <unotools/configpaths.hxx> @@ -85,18 +78,15 @@ sal_Int32 impl_getPropGroup(sal_Int32 nID) disable it in case only the new schema must be used. */ -typedef ::cppu::WeakImplHelper3< - css::lang::XServiceInfo, - css::util::XChangesListener, // => XEventListener - css::util::XPathSettings> // => XPropertySet - PathSettings_BASE; - -class PathSettings : // base classes - // Order is necessary for right initialization! - private ThreadHelpBase , - public ::cppu::OBroadcastHelper , - public ::cppu::OPropertySetHelper , // => XPropertySet / XFastPropertySet / XMultiPropertySet - public PathSettings_BASE +typedef ::cppu::WeakComponentImplHelper3< + css::lang::XServiceInfo, + css::util::XChangesListener, // => XEventListener + css::util::XPathSettings> // => XPropertySet + PathSettings_BASE; + +class PathSettings : private osl::Mutex + , public PathSettings_BASE + , public ::cppu::OPropertySetHelper { struct PathInfo { @@ -231,9 +221,6 @@ public: virtual void SAL_CALL disposing(const css::lang::EventObject& aSource) throw(css::uno::RuntimeException); - using ::cppu::OPropertySetHelper::disposing; - - /** * XPathSettings attribute methods */ @@ -342,8 +329,6 @@ public: virtual void SAL_CALL setBasePathUserLayer(const OUString& p1) throw (css::uno::RuntimeException) { setStringProperty("UserConfig", p1); } - - /** * overrides to resolve inheritance ambiguity */ @@ -365,11 +350,11 @@ public: virtual void SAL_CALL removeVetoableChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XVetoableChangeListener>& p2) throw (css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException) { ::cppu::OPropertySetHelper::removeVetoableChangeListener(p1, p2); } - /** read all configured paths and create all needed internal structures. */ void impl_readAll(); private: + virtual void SAL_CALL disposing() SAL_OVERRIDE; OUString getStringProperty(const OUString& p1) throw(css::uno::RuntimeException); @@ -450,17 +435,20 @@ private: // OPropertySetHelper - virtual sal_Bool SAL_CALL convertFastPropertyValue ( css::uno::Any& aConvertedValue , - css::uno::Any& aOldValue , - sal_Int32 nHandle , - const css::uno::Any& aValue ) throw(css::lang::IllegalArgumentException); - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle , - const css::uno::Any& aValue ) throw(css::uno::Exception); + virtual sal_Bool SAL_CALL convertFastPropertyValue( css::uno::Any& aConvertedValue, + css::uno::Any& aOldValue, + sal_Int32 nHandle, + const css::uno::Any& aValue ) throw(css::lang::IllegalArgumentException); + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, + const css::uno::Any& aValue ) throw(css::uno::Exception); + virtual void SAL_CALL getFastPropertyValue( css::uno::Any& aValue, + sal_Int32 nHandle ) const; + // Avoid: + // warning: ‘virtual com::sun::star::uno::Any cppu::OPropertySetHelper::getFastPropertyValue(sal_Int32)’ was hidden [-Woverloaded-virtual] + // warning: by ‘virtual void {anonymous}::PathSettings::getFastPropertyValue(com::sun::star::uno::Any&, sal_Int32) const’ [-Woverloaded-virtual] using cppu::OPropertySetHelper::getFastPropertyValue; - virtual void SAL_CALL getFastPropertyValue ( css::uno::Any& aValue , - sal_Int32 nHandle ) const; - virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper ( ); - virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo ( ) throw(::css::uno::RuntimeException); + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(::css::uno::RuntimeException); /** factory methods to guarantee right (but on demand) initialized members ... */ css::uno::Reference< css::util::XStringSubstitution > fa_getSubstitution(); @@ -470,14 +458,8 @@ private: //----------------------------------------------------------------------------- PathSettings::PathSettings( const css::uno::Reference< css::uno::XComponentContext >& xContext ) - // Init baseclasses first - // Attention: Don't change order of initialization! - // ThreadHelpBase is a struct with a lock as member. We can't use a lock as direct member! - // We must garant right initialization and a valid value of this to initialize other baseclasses! - : ThreadHelpBase() - , ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType >(m_aLock.getShareableOslMutex()) - , ::cppu::OPropertySetHelper(*(static_cast< ::cppu::OBroadcastHelper* >(this))) - // Init member + : PathSettings_BASE(*(static_cast<osl::Mutex *>(this))) + , ::cppu::OPropertySetHelper(cppu::WeakComponentImplHelperBase::rBHelper) , m_xContext (xContext) , m_pPropHelp(0 ) , m_bIgnoreEvents(sal_False) @@ -487,11 +469,25 @@ PathSettings::PathSettings( const css::uno::Reference< css::uno::XComponentConte //----------------------------------------------------------------------------- PathSettings::~PathSettings() { - css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfgNew, css::uno::UNO_QUERY); + disposing(); +} + +void SAL_CALL PathSettings::disposing() +{ + osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex); + + css::uno::Reference< css::util::XChangesNotifier > + xBroadcaster(m_xCfgNew, css::uno::UNO_QUERY); if (xBroadcaster.is()) xBroadcaster->removeChangesListener(m_xCfgNewListener); - if (m_pPropHelp) - delete m_pPropHelp; + + m_xSubstitution.clear(); + m_xCfgOld.clear(); + m_xCfgNew.clear(); + m_xCfgNewListener.clear(); + + delete m_pPropHelp; + m_pPropHelp = 0; } //------------------------------------------------------------------ @@ -500,11 +496,11 @@ css::uno::Any SAL_CALL PathSettings::queryInterface( const css::uno::Type& _rTyp { css::uno::Any aRet = PathSettings_BASE::queryInterface( _rType ); if ( !aRet.hasValue() ) - aRet = OPropertySetHelper::queryInterface( _rType ); + aRet = ::cppu::OPropertySetHelper::queryInterface( _rType ); return aRet; } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------ css::uno::Sequence< css::uno::Type > SAL_CALL PathSettings::getTypes( ) throw(css::uno::RuntimeException) { @@ -549,12 +545,10 @@ void SAL_CALL PathSettings::changesOccurred(const css::util::ChangesEvent& aEven void SAL_CALL PathSettings::disposing(const css::lang::EventObject& aSource) throw(css::uno::RuntimeException) { - WriteGuard aWriteLock(m_aLock); + osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex); if (aSource.Source == m_xCfgNew) m_xCfgNew.clear(); - - aWriteLock.unlock(); } //----------------------------------------------------------------------------- @@ -750,7 +744,7 @@ PathSettings::EChangeOp PathSettings::impl_updatePath(const OUString& sPath sal_Bool bNotifyListener) { // SAFE -> - WriteGuard aWriteLock(m_aLock); + osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex); PathSettings::PathInfo* pPathOld = 0; PathSettings::PathInfo* pPathNew = 0; @@ -1096,7 +1090,7 @@ void PathSettings::impl_purgeKnownPaths(const PathSettings::PathInfo& rPath, void PathSettings::impl_rebuildPropertyDescriptor() { // SAFE -> - WriteGuard aWriteLock(m_aLock); + osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex); sal_Int32 c = (sal_Int32)m_lPaths.size(); sal_Int32 i = 0; @@ -1146,11 +1140,9 @@ void PathSettings::impl_rebuildPropertyDescriptor() ++i; } - if (m_pPropHelp) - delete m_pPropHelp; + delete m_pPropHelp; m_pPropHelp = new ::cppu::OPropertyArrayHelper(m_lPropDesc, sal_False); // false => not sorted ... must be done inside helper - aWriteLock.unlock(); // <- SAFE } @@ -1349,7 +1341,7 @@ OUString impl_extractBaseFromPropName(const OUString& sPropName) PathSettings::PathInfo* PathSettings::impl_getPathAccess(sal_Int32 nHandle) { // SAFE -> - ReadGuard aReadLock(m_aLock); + osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex); if (nHandle > (m_lPropDesc.getLength()-1)) return 0; @@ -1369,7 +1361,7 @@ PathSettings::PathInfo* PathSettings::impl_getPathAccess(sal_Int32 nHandle) const PathSettings::PathInfo* PathSettings::impl_getPathAccessConst(sal_Int32 nHandle) const { // SAFE -> - ReadGuard aReadLock(m_aLock); + osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex); if (nHandle > (m_lPropDesc.getLength()-1)) return 0; @@ -1428,18 +1420,18 @@ void SAL_CALL PathSettings::getFastPropertyValue(css::uno::Any& aValue , css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL PathSettings::getPropertySetInfo() throw(css::uno::RuntimeException) { - return css::uno::Reference< css::beans::XPropertySetInfo >(createPropertySetInfo(getInfoHelper())); + return css::uno::Reference< css::beans::XPropertySetInfo >( + ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper())); } //----------------------------------------------------------------------------- css::uno::Reference< css::util::XStringSubstitution > PathSettings::fa_getSubstitution() { - // SAFE -> - ReadGuard aReadLock(m_aLock); - css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext; - css::uno::Reference< css::util::XStringSubstitution > xSubst = m_xSubstitution; - aReadLock.unlock(); - // <- SAFE + css::uno::Reference< css::util::XStringSubstitution > xSubst; + { // SAFE -> + osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex); + xSubst = m_xSubstitution; + } if (! xSubst.is()) { @@ -1447,12 +1439,12 @@ css::uno::Reference< css::util::XStringSubstitution > PathSettings::fa_getSubsti // We must replace all used variables inside readed path values. // In case we can't do so ... the whole office can't work really. // That's why it seams to be OK to throw a RuntimeException then. - xSubst = css::util::PathSubstitution::create(xContext); + xSubst = css::util::PathSubstitution::create(m_xContext); - // SAFE -> - WriteGuard aWriteLock(m_aLock); + { // SAFE -> + osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex); m_xSubstitution = xSubst; - aWriteLock.unlock(); + } } return xSubst; @@ -1463,26 +1455,25 @@ css::uno::Reference< css::container::XNameAccess > PathSettings::fa_getCfgOld() { const OUString CFG_NODE_OLD("org.openoffice.Office.Common/Path/Current"); - // SAFE -> - ReadGuard aReadLock(m_aLock); - css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext; - css::uno::Reference< css::container::XNameAccess > xCfg = m_xCfgOld; - aReadLock.unlock(); - // <- SAFE + css::uno::Reference< css::container::XNameAccess > xCfg; + { // SAFE -> + osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex); + xCfg = m_xCfgOld; + } // <- SAFE if (! xCfg.is()) { xCfg = css::uno::Reference< css::container::XNameAccess >( ::comphelper::ConfigurationHelper::openConfig( - xContext, + m_xContext, CFG_NODE_OLD, ::comphelper::ConfigurationHelper::E_STANDARD), // not readonly! Sometimes we need write access there !!! css::uno::UNO_QUERY_THROW); - // SAFE -> - WriteGuard aWriteLock(m_aLock); + { // SAFE -> + osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex); m_xCfgOld = xCfg; - aWriteLock.unlock(); + } } return xCfg; @@ -1493,29 +1484,26 @@ css::uno::Reference< css::container::XNameAccess > PathSettings::fa_getCfgNew() { const OUString CFG_NODE_NEW("org.openoffice.Office.Paths/Paths"); - // SAFE -> - ReadGuard aReadLock(m_aLock); - css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext; - css::uno::Reference< css::container::XNameAccess > xCfg = m_xCfgNew; - if (xCfg.is()) - return xCfg; - aReadLock.unlock(); - // <- SAFE + css::uno::Reference< css::container::XNameAccess > xCfg; + { // SAFE -> + osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex); + xCfg = m_xCfgNew; + } // <- SAFE if (! xCfg.is()) { xCfg = css::uno::Reference< css::container::XNameAccess >( ::comphelper::ConfigurationHelper::openConfig( - xContext, + m_xContext, CFG_NODE_NEW, ::comphelper::ConfigurationHelper::E_STANDARD), css::uno::UNO_QUERY_THROW); - // SAFE -> - WriteGuard aWriteLock(m_aLock); + { // SAFE -> + osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex); m_xCfgNew = xCfg; m_xCfgNewListener = new WeakChangesListener(this); - aWriteLock.unlock(); + } css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(xCfg, css::uno::UNO_QUERY_THROW); xBroadcaster->addChangesListener(m_xCfgNewListener); @@ -1550,9 +1538,8 @@ com_sun_star_comp_framework_PathSettings_get_implementation( css::uno::XComponentContext *context, css::uno::Sequence<css::uno::Any> const &) { - css::uno::XInterface *inst = Singleton::get(context).instance.get(); - inst->acquire(); - return inst; + return cppu::acquire(static_cast<cppu::OWeakObject *>( + Singleton::get(context).instance.get())); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/util/fwk.component b/framework/util/fwk.component index fc94a5eaaafd..3c931636337e 100644 --- a/framework/util/fwk.component +++ b/framework/util/fwk.component @@ -97,6 +97,7 @@ <implementation name="com.sun.star.comp.framework.PathSettings" constructor="com_sun_star_comp_framework_PathSettings_get_implementation"> <service name="com.sun.star.util.PathSettings"/> + <singleton name="com.sun.star.util.thePathSettings"/> </implementation> <implementation name="com.sun.star.comp.framework.PathSubstitution" constructor="com_sun_star_comp_framework_PathSubstitution_get_implementation"> diff --git a/linguistic/source/misc2.cxx b/linguistic/source/misc2.cxx index abb8e3b393b7..02421495a80e 100644 --- a/linguistic/source/misc2.cxx +++ b/linguistic/source/misc2.cxx @@ -30,7 +30,7 @@ #include <com/sun/star/beans/PropertyValues.hpp> #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/uno/Reference.h> -#include <com/sun/star/util/PathSettings.hpp> +#include <com/sun/star/util/thePathSettings.hpp> #include "linguistic/misc.hxx" @@ -77,7 +77,7 @@ static uno::Sequence< OUString > GetMultiPaths_Impl( OUString aWriteable( rPathPrefix + "_writable" ); uno::Reference< util::XPathSettings > xPathSettings = - util::PathSettings::create( xContext ); + util::thePathSettings::get( xContext ); xPathSettings->getPropertyValue( aInternal ) >>= aInternalPaths; xPathSettings->getPropertyValue( aUser ) >>= aUserPaths; xPathSettings->getPropertyValue( aWriteable ) >>= aWritablePath; diff --git a/odk/examples/DevelopersGuide/GUI/SystemDialog.java b/odk/examples/DevelopersGuide/GUI/SystemDialog.java index 1c1de4364cf8..453d9b99cd72 100644 --- a/odk/examples/DevelopersGuide/GUI/SystemDialog.java +++ b/odk/examples/DevelopersGuide/GUI/SystemDialog.java @@ -42,7 +42,7 @@ import com.sun.star.ui.dialogs.XFilterManager; import com.sun.star.ui.dialogs.XFolderPicker2; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; - +import com.sun.star.util.thePathSettings; public class SystemDialog { @@ -86,7 +86,7 @@ public class SystemDialog { xFilePicker.setDefaultName("MyExampleDocument"); // set the initial displaydirectory. In this example the user template directory is used - Object oPathSettings = m_xMCF.createInstanceWithContext("com.sun.star.util.PathSettings",m_xContext); + Object oPathSettings = thePathSettings.get(m_xContext); XPropertySet xPropertySet = com.sun.star.uno.UnoRuntime.queryInterface(XPropertySet.class, oPathSettings); String sTemplateUrl = (String) xPropertySet.getPropertyValue("Template_writable"); xFilePicker.setDisplayDirectory(sTemplateUrl); @@ -134,7 +134,7 @@ public class SystemDialog { String sWorkUrl = ""; try{ // retrieve the configured Work path... - Object oPathSettings = m_xMCF.createInstanceWithContext("com.sun.star.util.PathSettings",m_xContext); + Object oPathSettings = thePathSettings.get(m_xContext); XPropertySet xPropertySet = com.sun.star.uno.UnoRuntime.queryInterface(XPropertySet.class, oPathSettings); sWorkUrl = (String) xPropertySet.getPropertyValue("Work"); } catch (com.sun.star.uno.Exception exception) { diff --git a/odk/examples/DevelopersGuide/GUI/UnoDialogSample.java b/odk/examples/DevelopersGuide/GUI/UnoDialogSample.java index 851158f91d81..60eb85475dd5 100644 --- a/odk/examples/DevelopersGuide/GUI/UnoDialogSample.java +++ b/odk/examples/DevelopersGuide/GUI/UnoDialogSample.java @@ -98,6 +98,7 @@ import com.sun.star.util.XNumberFormats; import com.sun.star.util.XNumberFormatsSupplier; import com.sun.star.util.Date; import com.sun.star.util.Time; +import com.sun.star.util.thePathSettings; // Anregung von DV: @@ -1116,7 +1117,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis String sName = createUniqueName(m_xDlgModelNameContainer, "FileControl"); // retrieve the configured Work path... - Object oPathSettings = m_xMCF.createInstanceWithContext("com.sun.star.util.PathSettings",m_xContext); + Object oPathSettings = thePathSettings.get(m_xContext); XPropertySet xPropertySet = com.sun.star.uno.UnoRuntime.queryInterface(XPropertySet.class, oPathSettings); String sWorkUrl = (String) xPropertySet.getPropertyValue("Work"); diff --git a/odk/examples/DevelopersGuide/OfficeDev/PathSettings/PathSettingsTest.java b/odk/examples/DevelopersGuide/OfficeDev/PathSettings/PathSettingsTest.java index 5fff201ef552..903cc14a5738 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/PathSettings/PathSettingsTest.java +++ b/odk/examples/DevelopersGuide/OfficeDev/PathSettings/PathSettingsTest.java @@ -36,6 +36,7 @@ import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; import com.sun.star.lang.XMultiComponentFactory; import com.sun.star.beans.XPropertySet; +import com.sun.star.util.thePathSettings; /* * Provides example code how to access and use the @@ -80,7 +81,6 @@ public class PathSettingsTest extends java.lang.Object { public static void main(String[] args) { XComponentContext xRemoteContext = null; - XMultiComponentFactory xRemoteServiceManager = null; XPropertySet xPathSettingsService = null; try { @@ -88,10 +88,8 @@ public class PathSettingsTest extends java.lang.Object { // process is started xRemoteContext = com.sun.star.comp.helper.Bootstrap.bootstrap(); System.out.println("Connected to a running office ..."); - xRemoteServiceManager = xRemoteContext.getServiceManager(); - Object pathSubst = xRemoteServiceManager.createInstanceWithContext( - "com.sun.star.comp.framework.PathSettings", xRemoteContext ); + Object pathSubst = thePathSettings.get( xRemoteContext ); xPathSettingsService = UnoRuntime.queryInterface( XPropertySet.class, pathSubst); diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 936073c9068c..9aaf26b3810d 100755 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -446,6 +446,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/util,\ theOfficeInstallationDirectories \ UriAbbreviation \ URLTransformer \ + thePathSettings \ )) $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/xforms,\ Model \ diff --git a/offapi/com/sun/star/util/PathSettings.idl b/offapi/com/sun/star/util/PathSettings.idl index 14b0d3fba30a..00ab23d559f4 100644 --- a/offapi/com/sun/star/util/PathSettings.idl +++ b/offapi/com/sun/star/util/PathSettings.idl @@ -26,16 +26,10 @@ module com { module sun { module star { module util { -/** Supports read/write access and listener for the paths properties that - the Office uses. - <p> - The property names of the Office paths/directories are an exactly match - to the configuration entries found in the file - (org/openoffice/Office/Common.xml).<br> - This service supports the usage of path variables to define - paths that a relative to other office or system directories. - See PathSubstitution - </p> +/** + A legacy (single-instance) service-variant of thePathSettings singleton. + + @deprecated Use thePathSettings singleton instead. @since OOo 1.1.2 */ diff --git a/offapi/com/sun/star/util/thePathSettings.idl b/offapi/com/sun/star/util/thePathSettings.idl new file mode 100644 index 000000000000..ea3adb69105b --- /dev/null +++ b/offapi/com/sun/star/util/thePathSettings.idl @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef __com_sun_star_util_thePathSettings_idl__ +#define __com_sun_star_util_thePathSettings_idl__ + +#include <com/sun/star/util/XPathSettings.idl> + + +module com { module sun { module star { module util { + + +/** Supports read/write access and listener for the paths properties that + the Office uses. + <p> + The property names of the Office paths/directories are an exactly match + to the configuration entries found in the file + (org/openoffice/Office/Common.xml).<br> + This service supports the usage of path variables to define + paths that a relative to other office or system directories. + See PathSubstitution + </p> + + Prior to LibreOffice 4.3, this singleton was only available as a + (single-instance) PathSettings service. + + @since LibreOffice 4.3 + */ +published singleton thePathSettings : XPathSettings; + + +}; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/pch/precompiled_vbaobj.hxx b/sc/inc/pch/precompiled_vbaobj.hxx index c48f0150e2e3..af05020f2c3a 100644 --- a/sc/inc/pch/precompiled_vbaobj.hxx +++ b/sc/inc/pch/precompiled_vbaobj.hxx @@ -182,7 +182,7 @@ #include <com/sun/star/uri/XUriReferenceFactory.hpp> #include <com/sun/star/util/CellProtection.hpp> #include <com/sun/star/util/NumberFormat.hpp> -#include <com/sun/star/util/PathSettings.hpp> +#include <com/sun/star/util/thePathSettings.hpp> #include <com/sun/star/util/TriState.hpp> #include <com/sun/star/util/XChangesListener.hpp> #include <com/sun/star/util/XChangesNotifier.hpp> diff --git a/sw/inc/pch/precompiled_vbaswobj.hxx b/sw/inc/pch/precompiled_vbaswobj.hxx index aa952be731e0..bbddb69c7f62 100644 --- a/sw/inc/pch/precompiled_vbaswobj.hxx +++ b/sw/inc/pch/precompiled_vbaswobj.hxx @@ -100,7 +100,7 @@ #include <com/sun/star/ucb/SimpleFileAccess.hpp> #include <com/sun/star/uri/XUriReference.hpp> #include <com/sun/star/uri/XUriReferenceFactory.hpp> -#include <com/sun/star/util/PathSettings.hpp> +#include <com/sun/star/util/thePathSettings.hpp> #include <com/sun/star/util/XCloseable.hpp> #include <com/sun/star/util/XModifiable.hpp> #include <com/sun/star/util/XRefreshable.hpp> diff --git a/sw/source/ui/vba/vbaoptions.cxx b/sw/source/ui/vba/vbaoptions.cxx index 6969248f3088..16d127fbbda1 100644 --- a/sw/source/ui/vba/vbaoptions.cxx +++ b/sw/source/ui/vba/vbaoptions.cxx @@ -24,7 +24,7 @@ #include <ooo/vba/word/WdColorIndex.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/util/XStringSubstitution.hpp> -#include <com/sun/star/util/PathSettings.hpp> +#include <com/sun/star/util/thePathSettings.hpp> #include <osl/file.hxx> using namespace ::ooo::vba; @@ -95,7 +95,7 @@ void SwVbaOptions::setValueEvent( const uno::Any& value ) value >>= sNewPath; OUString sNewPathUrl; ::osl::File::getFileURLFromSystemPath( sNewPath, sNewPathUrl ); - uno::Reference< util::XPathSettings > xPathSettings = util::PathSettings::create( comphelper::getProcessComponentContext() ); + uno::Reference< util::XPathSettings > xPathSettings = util::thePathSettings::get( comphelper::getProcessComponentContext() ); OUString sOldPathUrl; xPathSettings->getPropertyValue( msDefaultFilePath ) >>= sOldPathUrl; // path could be a multipath, Microsoft doesn't support this feature in Word currently @@ -110,7 +110,7 @@ void SwVbaOptions::setValueEvent( const uno::Any& value ) uno::Any SwVbaOptions::getValueEvent() { - uno::Reference< util::XPathSettings > xPathSettings = util::PathSettings::create( comphelper::getProcessComponentContext() ); + uno::Reference< util::XPathSettings > xPathSettings = util::thePathSettings::get( comphelper::getProcessComponentContext() ); OUString sPathUrl; xPathSettings->getPropertyValue( msDefaultFilePath ) >>= sPathUrl; // path could be a multipath, Microsoft doesn't support this feature in Word currently diff --git a/unotools/source/config/pathoptions.cxx b/unotools/source/config/pathoptions.cxx index c7a1276133ad..c7beb4c7cba4 100644 --- a/unotools/source/config/pathoptions.cxx +++ b/unotools/source/config/pathoptions.cxx @@ -36,7 +36,7 @@ #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/XPropertySetInfo.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/util/PathSettings.hpp> +#include <com/sun/star/util/thePathSettings.hpp> #include <com/sun/star/util/PathSubstitution.hpp> #include <com/sun/star/util/XStringSubstitution.hpp> #include <com/sun/star/util/theMacroExpander.hpp> @@ -410,7 +410,7 @@ SvtPathOptions_Impl::SvtPathOptions_Impl() : Reference< XComponentContext > xContext = comphelper::getProcessComponentContext(); // Create necessary services - Reference< XPathSettings > xPathSettings = PathSettings::create(xContext); + Reference< XPathSettings > xPathSettings = thePathSettings::get(xContext); m_xPathSettings.set( xPathSettings, UNO_QUERY_THROW ); m_xSubstVariables.set( PathSubstitution::create(xContext) ); m_xMacroExpander = theMacroExpander::get(xContext); diff --git a/vcl/inc/pch/precompiled_vcl.hxx b/vcl/inc/pch/precompiled_vcl.hxx index 87234bf1501e..c952a6d04937 100644 --- a/vcl/inc/pch/precompiled_vcl.hxx +++ b/vcl/inc/pch/precompiled_vcl.hxx @@ -265,7 +265,7 @@ #include <com/sun/star/uno/XInterface.hpp> #include <com/sun/star/uno/XWeak.hpp> #include <com/sun/star/util/Endianness.hpp> -#include <com/sun/star/util/PathSettings.hpp> +#include <com/sun/star/util/thePathSettings.hpp> #include <com/sun/star/util/SearchFlags.hpp> #include <com/sun/star/util/SearchOptions.hpp> #include <com/sun/star/util/URL.hpp> diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 13a1da892dcd..3633699b9f4d 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -20,7 +20,7 @@ #include <config_features.h> #include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/util/PathSettings.hpp> +#include <com/sun/star/util/thePathSettings.hpp> #include <comphelper/processfactory.hxx> #include <osl/file.hxx> @@ -484,7 +484,7 @@ Dialog::Dialog( WindowType nType ) OUString VclBuilderContainer::getUIRootDir() { /*to-do, check if user config has an override before using shared one, etc*/ - css::uno::Reference< css::util::XPathSettings > xPathSettings = css::util::PathSettings::create( + css::uno::Reference< css::util::XPathSettings > xPathSettings = css::util::thePathSettings::get( ::comphelper::getProcessComponentContext() ); OUString sShareLayer = xPathSettings->getBasePathShareLayer(); |