summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2011-11-11 22:48:37 +0100
committerStephan Bergmann <sbergman@redhat.com>2011-11-11 22:49:21 +0100
commitc1758889cbd5e8e4afb1044425c908715eb3e1cd (patch)
treeff58b017da12c009f0b17c067787d1dbbd52eb7a /unotools
parent4ffcc73fa25f174c2d1e161f02cce2d7afc15e3b (diff)
Heavily simplified utl::ConfigManager.
Diffstat (limited to 'unotools')
-rw-r--r--unotools/inc/unotools/configitem.hxx2
-rw-r--r--unotools/inc/unotools/configmgr.hxx152
-rw-r--r--unotools/source/config/configitem.cxx102
-rw-r--r--unotools/source/config/configmgr.cxx786
-rw-r--r--unotools/source/config/defaultoptions.cxx1
-rw-r--r--unotools/source/config/docinfohelper.cxx18
-rw-r--r--unotools/source/config/itemholder1.cxx1
-rw-r--r--unotools/source/config/pathoptions.cxx21
-rw-r--r--unotools/source/config/useroptions.cxx14
9 files changed, 265 insertions, 832 deletions
diff --git a/unotools/inc/unotools/configitem.hxx b/unotools/inc/unotools/configitem.hxx
index 1b1558d024b4..fe3a0e991ad4 100644
--- a/unotools/inc/unotools/configitem.hxx
+++ b/unotools/inc/unotools/configitem.hxx
@@ -58,8 +58,6 @@ namespace utl
#define CONFIG_MODE_DELAYED_UPDATE 0x01
#define CONFIG_MODE_ALL_LOCALES 0x02
#define CONFIG_MODE_RELEASE_TREE 0x04
-#define CONFIG_MODE_IGNORE_ERRORS 0x08 // prevent assertions, if creation fails
-#define CONFIG_MODE_PROPAGATE_ERRORS 0x10 // throw exceptions, if creation fails
enum ConfigNameFormat
{
diff --git a/unotools/inc/unotools/configmgr.hxx b/unotools/inc/unotools/configmgr.hxx
index 61bcac6b8737..1ac1868585d1 100644
--- a/unotools/inc/unotools/configmgr.hxx
+++ b/unotools/inc/unotools/configmgr.hxx
@@ -26,92 +26,76 @@
*
************************************************************************/
-#ifndef _UTL_CONFIGMGR_HXX_
-#define _UTL_CONFIGMGR_HXX_
+#ifndef INCLUDED_UNOTOOLS_CONFIGMGR_HXX
+#define INCLUDED_UNOTOOLS_CONFIGMGR_HXX
-#include <com/sun/star/uno/Reference.h>
-#include <com/sun/star/uno/Any.hxx>
-#include <rtl/ustring.hxx>
+#include "sal/config.h"
+
+#include <list>
+
+#include "boost/noncopyable.hpp"
+#include "com/sun/star/uno/Reference.hxx"
+#include "sal/types.h"
#include "unotools/unotoolsdllapi.h"
-//-----------------------------------------------------------------------------
-namespace com{ namespace sun{ namespace star{
- namespace lang{
- class XMultiServiceFactory;
- }
- namespace container{
- class XHierarchicalNameAccess;
- }
-}}}
-
-//-----------------------------------------------------------------------------
-namespace utl
-{
- struct ConfigMgr_Impl;
- class ConfigItem;
- class UNOTOOLS_DLLPUBLIC ConfigManager
- {
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
- xConfigurationProvider;
- ConfigMgr_Impl* pMgrImpl;
-
- static void getBasisAboutBoxProductVersion( rtl::OUString& rVersion );
-
- public:
- ConfigManager();
- ConfigManager(com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xConfigProvider);
- ~ConfigManager();
-
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
- GetConfigurationProvider();
-
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
- GetLocalConfigurationProvider();
-
- com::sun::star::uno::Reference< com::sun::star::container::XHierarchicalNameAccess>
- AddConfigItem(utl::ConfigItem& rCfgItem);
-
- void RegisterConfigItem(utl::ConfigItem& rCfgItem);
- com::sun::star::uno::Reference< com::sun::star::container::XHierarchicalNameAccess>
- AcquireTree(utl::ConfigItem& rCfgItem);
-
-
- void RemoveConfigItem(utl::ConfigItem& rCfgItem);
-
- void StoreConfigItems();
-
- static ConfigManager& GetConfigManager();
- static rtl::OUString GetConfigBaseURL();
-
- enum ConfigProperty
- {
- INSTALLPATH, // deprecated. don't use
- LOCALE,
- OFFICEINSTALL, // deprecated. don't use
- USERINSTALLURL, // deprecated. don't use
- OFFICEINSTALLURL, // deprecated. don't use
- PRODUCTNAME,
- PRODUCTVERSION,
- PRODUCTEXTENSION,
- DEFAULTCURRENCY,
- PRODUCTXMLFILEFORMATNAME,
- PRODUCTXMLFILEFORMATVERSION,
- WRITERCOMPATIBILITYVERSIONOOO11,
- OPENSOURCECONTEXT,
- ABOUTBOXPRODUCTVERSION,
- OOOVENDOR
- };
- //direct readonly access to some special configuration elements
- static com::sun::star::uno::Any GetDirectConfigProperty(ConfigProperty eProp);
-
- sal_Bool IsLocalConfigProvider();
- com::sun::star::uno::Reference< com::sun::star::container::XHierarchicalNameAccess>
- GetHierarchyAccess(const rtl::OUString& rFullPath);
- com::sun::star::uno::Any GetLocalProperty(const rtl::OUString& rProperty);
- void PutLocalProperty(const rtl::OUString& , const com::sun::star::uno::Any& rValue);
-
- };
-}//namespace utl
-#endif //_UTL_CONFIGMGR_HXX_
+namespace com { namespace sun { namespace star {
+ namespace container{ class XHierarchicalNameAccess; }
+} } }
+namespace rtl { class OUString; }
+namespace utl { class ConfigItem; }
+
+namespace utl {
+
+class UNOTOOLS_DLLPUBLIC ConfigManager: private boost::noncopyable {
+public:
+ static rtl::OUString getAboutBoxProductVersion();
+
+ static rtl::OUString getDefaultCurrency();
+
+ static rtl::OUString getLocale();
+
+ static rtl::OUString getProductExtension();
+
+ static rtl::OUString getProductName();
+
+ static rtl::OUString getProductXmlFileFormat();
+
+ static rtl::OUString getProductXmlFileFormatVersion();
+
+ static rtl::OUString getProductVersion();
+
+ static rtl::OUString getVendor();
+
+ static rtl::OUString getWriterCompatibilityVersionOOo_1_1();
+
+ static void storeConfigItems();
+
+ SAL_DLLPRIVATE static ConfigManager & getConfigManager();
+
+ SAL_DLLPRIVATE static com::sun::star::uno::Reference<
+ com::sun::star::container::XHierarchicalNameAccess>
+ acquireTree(utl::ConfigItem & item);
+
+ SAL_DLLPRIVATE ConfigManager();
+
+ SAL_DLLPRIVATE ~ConfigManager();
+
+ SAL_DLLPRIVATE com::sun::star::uno::Reference<
+ com::sun::star::container::XHierarchicalNameAccess >
+ addConfigItem(utl::ConfigItem & item);
+
+ SAL_DLLPRIVATE void removeConfigItem(utl::ConfigItem & item);
+
+ SAL_DLLPRIVATE void registerConfigItem(utl::ConfigItem * item);
+
+private:
+ void doStoreConfigItems();
+
+ std::list< ConfigItem * > items_;
+};
+
+}
+
+#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/config/configitem.cxx b/unotools/source/config/configitem.cxx
index d0b29214f108..a0200e6b4d09 100644
--- a/unotools/source/config/configitem.cxx
+++ b/unotools/source/config/configitem.cxx
@@ -225,21 +225,19 @@ ConfigItem::ConfigItem(const OUString &rSubTree, sal_Int16 nSetMode ) :
{
AutoDeleter<ConfigItem_Impl> aNewImpl(pImpl);
- pImpl->pManager = &ConfigManager::GetConfigManager();
+ pImpl->pManager = &ConfigManager::getConfigManager();
pImpl->nMode = nSetMode;
if(0 != (nSetMode&CONFIG_MODE_RELEASE_TREE))
- pImpl->pManager->AddConfigItem(*this);
+ pImpl->pManager->addConfigItem(*this);
else
- m_xHierarchyAccess = pImpl->pManager->AddConfigItem(*this);
+ m_xHierarchyAccess = pImpl->pManager->addConfigItem(*this);
- // no more exceptions after c'tor has finished
aNewImpl.keep();
- pImpl->nMode &= ~CONFIG_MODE_PROPAGATE_ERRORS;
}
sal_Bool ConfigItem::IsValidConfigMgr() const
{
- return ( pImpl->pManager && pImpl->pManager->GetConfigurationProvider().is() );
+ return pImpl->pManager != 0;
}
ConfigItem::~ConfigItem()
@@ -247,7 +245,7 @@ ConfigItem::~ConfigItem()
if(pImpl->pManager)
{
RemoveChangesListener();
- pImpl->pManager->RemoveConfigItem(*this);
+ pImpl->pManager->removeConfigItem(*this);
}
delete pImpl;
}
@@ -278,29 +276,6 @@ void ConfigItem::CallNotify( const com::sun::star::uno::Sequence<OUString>& rPro
Notify(rPropertyNames);
}
-sal_Bool lcl_IsLocalProperty(const OUString& rSubTree, const OUString& rProperty)
-{
- static const sal_Char* aLocalProperties[] =
- {
- "Office.Common/Path/Current/Storage",
- "Office.Common/Path/Current/Temp"
- };
- static const int aLocalPropLen[] =
- {
- 34,
- 31
- };
- OUString sProperty(rSubTree);
- sProperty += C2U("/");
- sProperty += rProperty;
-
- if(sProperty.equalsAsciiL( aLocalProperties[0], aLocalPropLen[0]) ||
- sProperty.equalsAsciiL( aLocalProperties[1], aLocalPropLen[1]))
- return sal_True;
-
- return sal_False;
-}
-
void ConfigItem::impl_packLocalizedProperties( const Sequence< OUString >& lInNames ,
const Sequence< Any >& lInValues ,
Sequence< Any >& lOutValues )
@@ -471,12 +446,6 @@ Sequence< sal_Bool > ConfigItem::GetReadOnlyStates(const com::sun::star::uno::Se
{
try
{
- if(pImpl->pManager->IsLocalConfigProvider() && lcl_IsLocalProperty(sSubTree, rNames[i]))
- {
- OSL_FAIL("ConfigItem::IsReadonly()\nlocal mode seams to be used!?\n");
- continue;
- }
-
OUString sName = rNames[i];
OUString sPath;
OUString sProperty;
@@ -546,15 +515,7 @@ Sequence< Any > ConfigItem::GetProperties(const Sequence< OUString >& rNames)
{
try
{
- if(pImpl->pManager->IsLocalConfigProvider() && lcl_IsLocalProperty(sSubTree, pNames[i]))
- {
- OUString sProperty(sSubTree);
- sProperty += C2U("/");
- sProperty += pNames[i];
- pRet[i] = pImpl->pManager->GetLocalProperty(sProperty);
- }
- else
- pRet[i] = xHierarchyAccess->getByHierarchicalName(pNames[i]);
+ pRet[i] = xHierarchyAccess->getByHierarchicalName(pNames[i]);
}
catch (const Exception& rEx)
{
@@ -563,10 +524,7 @@ Sequence< Any > ConfigItem::GetProperties(const Sequence< OUString >& rNames)
sMsg += OString(rEx.Message.getStr(),
rEx.Message.getLength(),
RTL_TEXTENCODING_ASCII_US);
- sMsg += OString("\n");
- sMsg += OString(ConfigManager::GetConfigBaseURL().getStr(),
- ConfigManager::GetConfigBaseURL().getLength(),
- RTL_TEXTENCODING_ASCII_US);
+ sMsg += OString("\n/org.openoffice.");
sMsg += OString(sSubTree.getStr(),
sSubTree.getLength(),
RTL_TEXTENCODING_ASCII_US);
@@ -627,43 +585,33 @@ sal_Bool ConfigItem::PutProperties( const Sequence< OUString >& rNames,
}
for(int i = 0; i < nNameCount; i++)
{
- if(pImpl->pManager->IsLocalConfigProvider() && lcl_IsLocalProperty(sSubTree, pNames[i]))
- {
- OUString sProperty(sSubTree);
- sProperty += C2U("/");
- sProperty += pNames[i];
- pImpl->pManager->PutLocalProperty(sProperty, pValues[i]);
- }
- else
+ try
{
- try
+ OUString sNode, sProperty;
+ if (splitLastFromConfigurationPath(pNames[i],sNode, sProperty))
{
- OUString sNode, sProperty;
- if (splitLastFromConfigurationPath(pNames[i],sNode, sProperty))
- {
- Any aNode = xHierarchyAccess->getByHierarchicalName(sNode);
+ Any aNode = xHierarchyAccess->getByHierarchicalName(sNode);
- Reference<XNameAccess> xNodeAcc;
- aNode >>= xNodeAcc;
- Reference<XNameReplace> xNodeReplace(xNodeAcc, UNO_QUERY);
- Reference<XNameContainer> xNodeCont (xNodeAcc, UNO_QUERY);
+ Reference<XNameAccess> xNodeAcc;
+ aNode >>= xNodeAcc;
+ Reference<XNameReplace> xNodeReplace(xNodeAcc, UNO_QUERY);
+ Reference<XNameContainer> xNodeCont (xNodeAcc, UNO_QUERY);
- sal_Bool bExist = (xNodeAcc.is() && xNodeAcc->hasByName(sProperty));
- if (bExist && xNodeReplace.is())
- xNodeReplace->replaceByName(sProperty, pValues[i]);
- else
+ sal_Bool bExist = (xNodeAcc.is() && xNodeAcc->hasByName(sProperty));
+ if (bExist && xNodeReplace.is())
+ xNodeReplace->replaceByName(sProperty, pValues[i]);
+ else
if (!bExist && xNodeCont.is())
xNodeCont->insertByName(sProperty, pValues[i]);
else
bRet = sal_False;
- }
- else //direct value
- {
- xTopNodeReplace->replaceByName(sProperty, pValues[i]);
- }
}
- CATCH_INFO("Exception from PutProperties: ");
+ else //direct value
+ {
+ xTopNodeReplace->replaceByName(sProperty, pValues[i]);
+ }
}
+ CATCH_INFO("Exception from PutProperties: ");
}
try
{
@@ -1314,7 +1262,7 @@ Reference< XHierarchicalNameAccess> ConfigItem::GetTree()
{
Reference< XHierarchicalNameAccess> xRet;
if(!m_xHierarchyAccess.is())
- xRet = pImpl->pManager->AcquireTree(*this);
+ xRet = ConfigManager::acquireTree(*this);
else
xRet = m_xHierarchyAccess;
return xRet;
diff --git a/unotools/source/config/configmgr.cxx b/unotools/source/config/configmgr.cxx
index 00e46145e360..e11b99dc4d6a 100644
--- a/unotools/source/config/configmgr.cxx
+++ b/unotools/source/config/configmgr.cxx
@@ -26,693 +26,225 @@
*
************************************************************************/
-// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_unotools.hxx"
-#include "unotools/configmgr.hxx"
-#include "unotools/configitem.hxx"
-#include "unotools/configpathes.hxx"
-#include <unotools/processfactory.hxx>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/container/XNameAccess.hpp>
-#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
-#include <com/sun/star/container/XNameContainer.hpp>
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <osl/diagnose.h>
-#include <rtl/bootstrap.hxx>
-#include <rtl/instance.hxx>
-#if OSL_DEBUG_LEVEL > 0
-#include <rtl/strbuf.hxx>
-#endif
+#include "sal/config.h"
#include <list>
-#include <stdio.h>
-
-//-----------------------------------------------------------------------------
-
-using namespace utl;
-using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
-using namespace com::sun::star::beans;
-using namespace com::sun::star::container;
-
-using ::rtl::OUString;
-#if OSL_DEBUG_LEVEL > 0
-using ::rtl::OString;
-#endif
+#include "boost/noncopyable.hpp"
+#include "com/sun/star/beans/NamedValue.hpp"
+#include "com/sun/star/container/XHierarchicalNameAccess.hpp"
+#include "com/sun/star/lang/XMultiServiceFactory.hpp"
+#include "com/sun/star/uno/Any.hxx"
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/Sequence.hxx"
+#include "osl/diagnose.h"
+#include "rtl/instance.hxx"
+#include "rtl/ustring.h"
+#include "rtl/ustring.hxx"
+#include "unotools/configitem.hxx"
+#include "unotools/configmgr.hxx"
+#include "unotools/processfactory.hxx"
-#define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
+namespace {
-//-----------------------------------------------------------------------------
-const char aConfigBaseURL[] = "/org.openoffice.";
-const char aAccessSrvc[] = "com.sun.star.configuration.ConfigurationUpdateAccess";
+namespace css = com::sun::star;
-namespace
-{
- struct BrandName
- : public rtl::Static< ::rtl::OUString, BrandName > {};
- struct ProductVersion
- : public rtl::Static< ::rtl::OUString, ProductVersion > {};
- struct AboutBoxProductVersion
- : public rtl::Static< ::rtl::OUString, AboutBoxProductVersion > {};
- struct OOOVendor
- : public rtl::Static< ::rtl::OUString, OOOVendor > {};
- struct ProductExtension
- : public rtl::Static< ::rtl::OUString, ProductExtension > {};
- struct XMLFileFormatName
- : public rtl::Static< ::rtl::OUString, XMLFileFormatName > {};
- struct XMLFileFormatVersion
- : public rtl::Static< ::rtl::OUString, XMLFileFormatVersion > {};
- struct WriterCompatibilityVersionOOo11
- : public rtl::Static< ::rtl::OUString, WriterCompatibilityVersionOOo11 > {};
- struct OpenSourceContext : public rtl::StaticWithInit< sal_Int32, OpenSourceContext >
+class RegisterConfigItemHelper: private boost::noncopyable {
+public:
+ RegisterConfigItemHelper(
+ utl::ConfigManager & manager, utl::ConfigItem & item):
+ manager_(manager), item_(&item)
{
- sal_Int32 operator() () { return sal_Int32( -1 ); }
- };
+ manager.registerConfigItem(item_);
+ }
-}
+ ~RegisterConfigItemHelper() {
+ if (item_ != 0) {
+ manager_.removeConfigItem(*item_);
+ }
+ }
-//-----------------------------------------------------------------------------
-struct ConfigItemListEntry_Impl
-{
- ConfigItem* pConfigItem;
+ void keep() { item_ = 0; }
- ConfigItemListEntry_Impl(ConfigItem* pItem ) :
- pConfigItem(pItem){}
-};
-typedef std::list<ConfigItemListEntry_Impl> ConfigItemList;
-struct utl::ConfigMgr_Impl
-{
- ConfigItemList aItemList;
+private:
+ utl::ConfigManager & manager_;
+ utl::ConfigItem * item_;
};
-ConfigManager::ConfigManager() :
- pMgrImpl(new utl::ConfigMgr_Impl)
-{
- GetConfigurationProvider(); // attempt to create the provider early
+css::uno::Reference< css::lang::XMultiServiceFactory >
+getConfigurationProvider() {
+ return css::uno::Reference< css::lang::XMultiServiceFactory >(
+ (css::uno::Reference< css::lang::XMultiServiceFactory >(
+ utl::getProcessServiceFactory(), css::uno::UNO_SET_THROW)->
+ createInstance(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.configuration.ConfigurationProvider")))),
+ css::uno::UNO_QUERY_THROW);
}
-ConfigManager::ConfigManager(Reference< XMultiServiceFactory > xConfigProv) :
- xConfigurationProvider(xConfigProv),
- pMgrImpl(new utl::ConfigMgr_Impl)
+rtl::OUString getConfigurationString(
+ rtl::OUString const & module, rtl::OUString const & path)
{
+ css::uno::Sequence< css::uno::Any > args(1);
+ args[0] <<= css::beans::NamedValue(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")),
+ css::uno::makeAny(module));
+ return
+ css::uno::Reference< css::container::XHierarchicalNameAccess >(
+ getConfigurationProvider()->createInstanceWithArguments(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.configuration.ConfigurationAccess")),
+ args),
+ css::uno::UNO_QUERY_THROW)->
+ getByHierarchicalName(path).get< rtl::OUString >();
}
-ConfigManager::~ConfigManager()
-{
- //check list content -> should be empty!
-#if OSL_DEBUG_LEVEL > 0
- if(!pMgrImpl->aItemList.empty())
- {
- ConfigItemList::iterator aListIter;
- for (aListIter = pMgrImpl->aItemList.begin(); aListIter != pMgrImpl->aItemList.end(); ++aListIter)
- {
- ConfigItemListEntry_Impl& rEntry = *aListIter;
- fprintf(stderr, "Dangling config item of %s\n", rtl::OUStringToOString(rEntry.pConfigItem->GetSubTreeName(), RTL_TEXTENCODING_UTF8).getStr());
- }
- }
-#endif
- OSL_ENSURE(pMgrImpl->aItemList.empty(), "some ConfigItems are still alive");
- if(!pMgrImpl->aItemList.empty())
- {
- ConfigItemList::iterator aListIter;
- for(aListIter = pMgrImpl->aItemList.begin(); aListIter != pMgrImpl->aItemList.end(); ++aListIter)
- {
- ConfigItemListEntry_Impl& rEntry = *aListIter;
- rEntry.pConfigItem->ReleaseConfigMgr();
- }
- pMgrImpl->aItemList.erase(pMgrImpl->aItemList.begin(), pMgrImpl->aItemList.end());
- }
- delete pMgrImpl;
+struct theConfigManager:
+ public rtl::Static< utl::ConfigManager, theConfigManager >
+{};
}
-Reference< XMultiServiceFactory > ConfigManager::GetConfigurationProvider()
-{
- if(!xConfigurationProvider.is())
- {
- Reference< XMultiServiceFactory > xMSF = ::utl::getProcessServiceFactory();
- if ( xMSF.is() )
- {
- try
- {
- xConfigurationProvider = Reference< XMultiServiceFactory >
- (xMSF->createInstance(
- UNISTRING("com.sun.star.configuration.ConfigurationProvider")),
- UNO_QUERY);
- }
-#if OSL_DEBUG_LEVEL > 1
- catch (const Exception& rEx)
- {
- static sal_Bool bMessage = sal_True;
- if(bMessage)
- {
- bMessage = sal_False;
- OString sMsg("CreateInstance with arguments exception: ");
- sMsg += OString(rEx.Message.getStr(),
- rEx.Message.getLength(),
- RTL_TEXTENCODING_ASCII_US);
- OSL_FAIL(sMsg.getStr());
- }
- }
-#else
- catch (const Exception&)
- {
- }
-#endif
- }
- }
- return xConfigurationProvider;
+rtl::OUString utl::ConfigManager::getAboutBoxProductVersion() {
+ return getConfigurationString(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Product/ooSetupVersionAboutBox")));
}
-namespace
-{
- // helper to achieve exception - safe registration of a ConfigItem under construction
- class RegisterConfigItemHelper // : Noncopyable
- {
- utl::ConfigManager & rCfgMgr;
- utl::ConfigItem* pCfgItem;
- public:
- RegisterConfigItemHelper(utl::ConfigManager & rMgr, utl::ConfigItem& rCfgItem)
- : rCfgMgr(rMgr)
- , pCfgItem(&rCfgItem)
- {
- rCfgMgr.RegisterConfigItem(rCfgItem);
- }
-
- ~RegisterConfigItemHelper()
- {
- if (pCfgItem) rCfgMgr.RemoveConfigItem(*pCfgItem);
- }
-
- void keep() { pCfgItem = 0; }
- };
+rtl::OUString utl::ConfigManager::getDefaultCurrency() {
+ return getConfigurationString(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("L10N/ooSetupCurrency")));
}
-Reference< XMultiServiceFactory > ConfigManager::GetLocalConfigurationProvider()
-{
- return GetConfigurationProvider();
+rtl::OUString utl::ConfigManager::getLocale() {
+ return getConfigurationString(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("L10N/ooLocale")));
}
-Reference< XHierarchicalNameAccess > ConfigManager::AddConfigItem(utl::ConfigItem& rCfgItem)
-{
- RegisterConfigItemHelper registeredItem(*this,rCfgItem);
- Reference< XHierarchicalNameAccess > xTree = AcquireTree(rCfgItem);
- registeredItem.keep();
- return xTree;
+rtl::OUString utl::ConfigManager::getProductExtension() {
+ return getConfigurationString(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Product/ooSetupExtension")));
}
-void ConfigManager::RegisterConfigItem(utl::ConfigItem& rCfgItem)
-{
- ConfigItemList::iterator aListIter = pMgrImpl->aItemList.begin();
-#if OSL_DEBUG_LEVEL > 1
- for(aListIter = pMgrImpl->aItemList.begin(); aListIter != pMgrImpl->aItemList.end(); ++aListIter)
- {
- ConfigItemListEntry_Impl& rEntry = *aListIter;
- if(rEntry.pConfigItem == &rCfgItem)
- OSL_FAIL("RegisterConfigItem: already inserted!");
- }
-#endif
- pMgrImpl->aItemList.insert(aListIter, ConfigItemListEntry_Impl(&rCfgItem));
+rtl::OUString utl::ConfigManager::getProductName() {
+ return getConfigurationString(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Product/ooName")));
}
-Reference< XHierarchicalNameAccess> ConfigManager::AcquireTree(utl::ConfigItem& rCfgItem)
-{
-#if OSL_DEBUG_LEVEL > 1
- sal_Bool bFound = sal_False;
- ConfigItemList::iterator aListIter = pMgrImpl->aItemList.begin();
- for(aListIter = pMgrImpl->aItemList.begin(); aListIter != pMgrImpl->aItemList.end(); ++aListIter)
- {
- ConfigItemListEntry_Impl& rEntry = *aListIter;
- if(rEntry.pConfigItem == &rCfgItem)
- {
- bFound = sal_True;
- break;
- }
- }
- OSL_ENSURE(bFound, "AcquireTree: ConfigItem unknown!");
-#endif
- OUString sPath(RTL_CONSTASCII_USTRINGPARAM(aConfigBaseURL));
- sPath += rCfgItem.GetSubTreeName();
- Sequence< Any > aArgs(2);
- Any* pArgs = aArgs.getArray();
- PropertyValue aPath;
- aPath.Name = UNISTRING("nodepath");
- aPath.Value <<= sPath;
- pArgs[0] <<= aPath;
- sal_Bool bLazy = 0 != (rCfgItem.GetMode()&CONFIG_MODE_DELAYED_UPDATE);
- PropertyValue aUpdate;
- aUpdate.Name = UNISTRING("lazywrite");
- aUpdate.Value.setValue(&bLazy, ::getBooleanCppuType());
- pArgs[1] <<= aUpdate;
-
- // Initialize item with support for reading/writing more then one locales at same time!
- // It's neccessary for creation of a complete configuration entry without changing office locale
- // at runtime.
- if((rCfgItem.GetMode() & CONFIG_MODE_ALL_LOCALES) == CONFIG_MODE_ALL_LOCALES)
- {
- sal_Int32 nCount = aArgs.getLength();
- aArgs.realloc(nCount+1);
-
- PropertyValue aAllLocale;
- aAllLocale.Name = UNISTRING("locale");
- aAllLocale.Value <<= UNISTRING("*" );
- aArgs[nCount] <<= aAllLocale;
- }
-
- Reference< XMultiServiceFactory > xCfgProvider = GetConfigurationProvider();
- Reference< XInterface > xIFace;
- if(xCfgProvider.is())
- {
- try
- {
- xIFace = xCfgProvider->createInstanceWithArguments(
- OUString(RTL_CONSTASCII_USTRINGPARAM(aAccessSrvc)),
- aArgs);
- }
- catch (const Exception& rEx)
- {
- if (CONFIG_MODE_PROPAGATE_ERRORS & rCfgItem.GetMode())
- {
- OSL_TRACE("ConfigItem: Propagating creation error: %s\n",
- OUStringToOString(rEx.Message,RTL_TEXTENCODING_ASCII_US).getStr());
-
- throw;
- }
-#if OSL_DEBUG_LEVEL > 1
- if(0 == (CONFIG_MODE_IGNORE_ERRORS & rCfgItem.GetMode()))
- {
- OString sMsg("CreateInstance exception: ");
- sMsg += OString(rEx.Message.getStr(),
- rEx.Message.getLength(),
- RTL_TEXTENCODING_ASCII_US);
- OSL_FAIL(sMsg.getStr());
- }
-#endif
- }
- }
- return Reference<XHierarchicalNameAccess>(xIFace, UNO_QUERY);
+rtl::OUString utl::ConfigManager::getProductVersion() {
+ return getConfigurationString(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Product/ooSetupVersion")));
}
-void ConfigManager::RemoveConfigItem(utl::ConfigItem& rCfgItem)
-{
- if( !pMgrImpl->aItemList.empty() )
- {
- ConfigItemList::iterator aListIter = pMgrImpl->aItemList.begin();
- for(aListIter = pMgrImpl->aItemList.begin(); aListIter != pMgrImpl->aItemList.end(); ++aListIter)
- {
- ConfigItemListEntry_Impl& rEntry = *aListIter;
- if(rEntry.pConfigItem == &rCfgItem)
- {
- pMgrImpl->aItemList.erase(aListIter);
- break;
- }
- }
- }
+rtl::OUString utl::ConfigManager::getProductXmlFileFormat() {
+ return getConfigurationString(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Product/ooXMLFileFormatName")));
}
-void ConfigManager::StoreConfigItems()
-{
- if(!pMgrImpl->aItemList.empty())
- {
- ConfigItemList::iterator aListIter = pMgrImpl->aItemList.begin();
- for(aListIter = pMgrImpl->aItemList.begin(); aListIter != pMgrImpl->aItemList.end(); ++aListIter)
- {
- ConfigItemListEntry_Impl& rEntry = *aListIter;
- if(rEntry.pConfigItem->IsModified())
- {
- rEntry.pConfigItem->Commit();
- rEntry.pConfigItem->ClearModified();
- }
- }
- }
+rtl::OUString utl::ConfigManager::getProductXmlFileFormatVersion() {
+ return getConfigurationString(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Product/ooXMLFileFormatVersion")));
}
-struct theConfigManager : public rtl::Static<ConfigManager, theConfigManager> {};
-
-ConfigManager& ConfigManager::GetConfigManager()
-{
- return theConfigManager::get();
+rtl::OUString utl::ConfigManager::getVendor() {
+ return getConfigurationString(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Product/ooVendor")));
}
-rtl::OUString ConfigManager::GetConfigBaseURL()
-{
- return OUString(RTL_CONSTASCII_USTRINGPARAM(aConfigBaseURL));
+rtl::OUString utl::ConfigManager::getWriterCompatibilityVersionOOo_1_1() {
+ return getConfigurationString(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "/org.openoffice.Office.Compatibility")),
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("WriterCompatibilityVersion/OOo11")));
}
-Any ConfigManager::GetDirectConfigProperty(ConfigProperty eProp)
-{
- switch(eProp)
- {
- case INSTALLPATH:
- OSL_FAIL( "ConfigManager::GetDirectConfigProperty: "
- "INSTALLPATH no longer supported." );
- return Any();
- case USERINSTALLURL:
- OSL_FAIL( "ConfigManager::GetDirectConfigProperty: "
- "USERINSTALLURL no longer supported." );
- return Any();
- case OFFICEINSTALL:
- OSL_FAIL( "ConfigManager::GetDirectConfigProperty: "
- "OFFICEINSTALL no longer supported." );
- return Any();
- case OFFICEINSTALLURL:
- OSL_FAIL( "ConfigManager::GetDirectConfigProperty: "
- "OFFICEINSTALLURL no longer supported." );
- return Any();
- default:
- break;
- }
-
- Any aRet;
-
- ::rtl::OUString &rBrandName = BrandName::get();
- if ( eProp == PRODUCTNAME && rBrandName.getLength() )
- {
- aRet <<= rBrandName;
- return aRet;
- }
-
- rtl::OUString &rProductVersion = ProductVersion::get();
- if ( eProp == PRODUCTVERSION && rProductVersion.getLength() )
- {
- aRet <<= rProductVersion;
- return aRet;
- }
-
- rtl::OUString &rAboutBoxProductVersion = AboutBoxProductVersion::get();
- if ( eProp == ABOUTBOXPRODUCTVERSION && rAboutBoxProductVersion.getLength() )
- {
- aRet <<= rAboutBoxProductVersion;
- return aRet;
- }
-
- rtl::OUString &rOOOVendor = OOOVendor::get();
- if ( eProp == OOOVENDOR && rOOOVendor.getLength() )
- {
- aRet <<= rOOOVendor;
- return aRet;
- }
-
-
- rtl::OUString &rProductExtension = ProductExtension::get();
- if ( eProp == PRODUCTEXTENSION && rProductExtension.getLength() )
- {
- aRet <<= rProductExtension;
- return aRet;
- }
-
- rtl::OUString &rXMLFileFormatName = XMLFileFormatName::get();
- if ( eProp == PRODUCTXMLFILEFORMATNAME && rXMLFileFormatName.getLength() )
- {
- aRet <<= rXMLFileFormatName;
- return aRet;
- }
-
- rtl::OUString &rXMLFileFormatVersion = XMLFileFormatVersion::get();
- if ( eProp == PRODUCTXMLFILEFORMATVERSION && rXMLFileFormatVersion.getLength() )
- {
- aRet <<= rXMLFileFormatVersion;
- return aRet;
- }
-
- sal_Int32 &rOpenSourceContext = OpenSourceContext::get();
- if ( eProp == OPENSOURCECONTEXT && ( rOpenSourceContext >= 0 ) )
- {
- aRet <<= rOpenSourceContext;
- return aRet;
- }
+void utl::ConfigManager::storeConfigItems() {
+ getConfigManager().doStoreConfigItems();
+}
- rtl::OUString &rWriterCompatibilityVersionOOo11 = WriterCompatibilityVersionOOo11::get();
- if ( eProp == WRITERCOMPATIBILITYVERSIONOOO11 && rWriterCompatibilityVersionOOo11.getLength() )
- {
- aRet <<= rWriterCompatibilityVersionOOo11;
- return aRet;
- }
+utl::ConfigManager & utl::ConfigManager::getConfigManager() {
+ return theConfigManager::get();
+}
- if (eProp == PRODUCTEXTENSION) {
- rtl::OUString name(
+css::uno::Reference< css::container::XHierarchicalNameAccess >
+utl::ConfigManager::acquireTree(utl::ConfigItem & item) {
+ css::uno::Sequence< css::uno::Any > args(1);
+ args[0] <<= css::beans::NamedValue(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")),
+ css::uno::makeAny(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.")) +
+ item.GetSubTreeName()));
+ if ((item.GetMode() & CONFIG_MODE_ALL_LOCALES) != 0) {
+ args.realloc(2);
+ args[1] <<= css::beans::NamedValue(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("locale")),
+ css::uno::makeAny(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("*"))));
+ }
+ return css::uno::Reference< css::container::XHierarchicalNameAccess >(
+ getConfigurationProvider()->createInstanceWithArguments(
+ rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
- "${BRAND_BASE_DIR}/program/edition/edition.ini"));
- rtl::Bootstrap::expandMacros(name);
- if (rtl::Bootstrap(name).getFrom(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EDITIONNAME")),
- rProductExtension))
- {
- return com::sun::star::uno::Any(rProductExtension);
- }
- }
-
- OUString sPath(RTL_CONSTASCII_USTRINGPARAM(aConfigBaseURL));
- switch(eProp)
- {
- case LOCALE: sPath += UNISTRING("Setup/L10N"); break;
-
- case PRODUCTNAME:
- case PRODUCTVERSION:
- case PRODUCTEXTENSION:
- case PRODUCTXMLFILEFORMATNAME :
- case PRODUCTXMLFILEFORMATVERSION:
- case OPENSOURCECONTEXT:
- case OOOVENDOR:
- case ABOUTBOXPRODUCTVERSION: sPath += UNISTRING("Setup/Product"); break;
-
- case DEFAULTCURRENCY: sPath += UNISTRING("Setup/L10N"); break;
-
- case WRITERCOMPATIBILITYVERSIONOOO11:
- sPath += UNISTRING("Office.Compatibility/WriterCompatibilityVersion"); break;
- default:
- break;
- }
- Sequence< Any > aArgs(1);
- aArgs[0] <<= sPath;
- Reference< XMultiServiceFactory > xCfgProvider = GetConfigManager().GetConfigurationProvider();
- if(!xCfgProvider.is())
- return aRet;
- Reference< XInterface > xIFace;
- try
- {
- xIFace = xCfgProvider->createInstanceWithArguments(
- OUString(RTL_CONSTASCII_USTRINGPARAM(aAccessSrvc)),
- aArgs);
-
- }
- catch (const Exception&)
- {
- }
- Reference<XNameAccess> xDirectAccess(xIFace, UNO_QUERY);
- if(xDirectAccess.is())
- {
- OUString sProperty;
- switch(eProp)
- {
- case LOCALE: sProperty = UNISTRING("ooLocale"); break;
- case PRODUCTNAME: sProperty = UNISTRING("ooName"); break;
- case PRODUCTVERSION: sProperty = UNISTRING("ooSetupVersion"); break;
- case ABOUTBOXPRODUCTVERSION: sProperty = UNISTRING("ooSetupVersionAboutBox"); break;
- case OOOVENDOR: sProperty = UNISTRING("ooVendor"); break;
- case PRODUCTEXTENSION: sProperty = UNISTRING("ooSetupExtension"); break;
- case PRODUCTXMLFILEFORMATNAME: sProperty = UNISTRING("ooXMLFileFormatName"); break;
- case PRODUCTXMLFILEFORMATVERSION: sProperty = UNISTRING("ooXMLFileFormatVersion"); break;
- case OPENSOURCECONTEXT: sProperty = UNISTRING("ooOpenSourceContext"); break;
- case DEFAULTCURRENCY: sProperty = UNISTRING("ooSetupCurrency"); break;
- case WRITERCOMPATIBILITYVERSIONOOO11: sProperty = UNISTRING("OOo11"); break;
- default:
- break;
- }
- try
- {
- aRet = xDirectAccess->getByName(sProperty);
- }
- catch (const Exception&)
- {
- #if OSL_DEBUG_LEVEL > 0
- rtl::OStringBuffer aBuf(256);
- aBuf.append( "ConfigManager::GetDirectConfigProperty: could not retrieve the property \"" );
- aBuf.append( rtl::OUStringToOString( sProperty, RTL_TEXTENCODING_ASCII_US ) );
- aBuf.append( "\" under \"" );
- aBuf.append( rtl::OUStringToOString( sPath, RTL_TEXTENCODING_ASCII_US ) );
- aBuf.append( "\" (caught an exception)!" );
- OSL_FAIL( aBuf.getStr() );
- #endif
- }
- }
-
- if ( eProp == PRODUCTNAME )
- aRet >>= rBrandName;
-
- if ( eProp == PRODUCTXMLFILEFORMATNAME )
- aRet >>= rXMLFileFormatName;
-
- if ( eProp == PRODUCTXMLFILEFORMATVERSION )
- aRet >>= rXMLFileFormatVersion;
-
- if ( eProp == PRODUCTVERSION )
- aRet >>= rProductVersion;
-
- if( eProp == OOOVENDOR )
- aRet >>= rOOOVendor;
-
- if ( eProp == ABOUTBOXPRODUCTVERSION )
- {
- aRet >>= rAboutBoxProductVersion;
- getBasisAboutBoxProductVersion( rAboutBoxProductVersion );
- aRet <<= rAboutBoxProductVersion;
- }
-
- if ( eProp == PRODUCTEXTENSION )
- aRet >>= rProductExtension;
-
- if ( eProp == WRITERCOMPATIBILITYVERSIONOOO11 )
- aRet >>= rWriterCompatibilityVersionOOo11;
+ "com.sun.star.configuration.ConfigurationUpdateAccess")),
+ args),
+ css::uno::UNO_QUERY_THROW);
+}
- if ( eProp == OPENSOURCECONTEXT )
- aRet >>= rOpenSourceContext;
+utl::ConfigManager::ConfigManager() {}
- return aRet;
+utl::ConfigManager::~ConfigManager() {
+ OSL_ASSERT(items_.empty());
}
-/*---------------------------------------------------------------------------*/
-void ConfigManager::getBasisAboutBoxProductVersion( OUString& rVersion )
-{
- rtl::OUString aPackageVersion = UNISTRING( "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("version") ":OOOPackageVersion}" );
- rtl::Bootstrap::expandMacros( aPackageVersion );
-
- if ( aPackageVersion.getLength() )
- {
- sal_Int32 nTokIndex = 0;
- rtl::OUString aVersionMinor = aPackageVersion.getToken( 1, '.', nTokIndex );
- rtl::OUString aVersionMicro;
-
- if ( nTokIndex > 0 )
- aVersionMicro = aPackageVersion.getToken( 0, '.', nTokIndex );
-
- if ( aVersionMinor.getLength() == 0 )
- aVersionMinor = UNISTRING( "0" );
- if ( aVersionMicro.getLength() == 0 )
- aVersionMicro = UNISTRING( "0" );
-
- sal_Int32 nIndex = rVersion.indexOf( '.' );
- if ( nIndex == -1 )
- {
- rVersion += UNISTRING( "." );
- rVersion += aVersionMinor;
- }
- else
- {
- nIndex = rVersion.indexOf( '.', nIndex+1 );
- }
- if ( nIndex == -1 )
- {
- rVersion += UNISTRING( "." );
- rVersion += aVersionMicro;
- }
- else
- {
- rVersion = rVersion.replaceAt( nIndex+1, rVersion.getLength()-nIndex-1, aVersionMicro );
- }
- }
+css::uno::Reference< css::container::XHierarchicalNameAccess >
+utl::ConfigManager::addConfigItem(utl::ConfigItem & item) {
+ RegisterConfigItemHelper reg(*this, item);
+ css::uno::Reference< css::container::XHierarchicalNameAccess > tree(
+ acquireTree(item));
+ reg.keep();
+ return tree;
}
-Reference< XHierarchicalNameAccess> ConfigManager::GetHierarchyAccess(const OUString& rFullPath)
-{
- Sequence< Any > aArgs(1);
- aArgs[0] <<= rFullPath;
- Reference< XMultiServiceFactory > xCfgProvider = GetLocalConfigurationProvider();
- Reference< XInterface > xIFace;
- if(xCfgProvider.is())
+void utl::ConfigManager::removeConfigItem(utl::ConfigItem & item) {
+ for (std::list< ConfigItem * >::iterator i(items_.begin());
+ i != items_.end(); ++i)
{
- try
- {
- xIFace = xCfgProvider->createInstanceWithArguments(
- OUString(RTL_CONSTASCII_USTRINGPARAM(aAccessSrvc)),
- aArgs);
- }
-#if OSL_DEBUG_LEVEL > 1
- catch (const Exception& rEx)
- {
- OString sMsg("CreateInstance exception: ");
- sMsg += OString(rEx.Message.getStr(),
- rEx.Message.getLength(),
- RTL_TEXTENCODING_ASCII_US);
- OSL_FAIL(sMsg.getStr());
- }
-#else
- catch (const Exception&)
- {
+ if (*i == &item) {
+ items_.erase(i);
+ break;
}
-#endif
}
- return Reference<XHierarchicalNameAccess>(xIFace, UNO_QUERY);
}
-Any ConfigManager::GetLocalProperty(const OUString& rProperty)
-{
- OUString sPath(RTL_CONSTASCII_USTRINGPARAM(aConfigBaseURL));
- sPath += rProperty;
-
- OUString sNode, sProperty;
- OSL_VERIFY( splitLastFromConfigurationPath(sPath, sNode, sProperty) );
-
- Reference< XNameAccess> xAccess( GetHierarchyAccess(sNode), UNO_QUERY );
- Any aRet;
- try
- {
- if(xAccess.is())
- aRet = xAccess->getByName(sProperty);
- }
-#if OSL_DEBUG_LEVEL > 1
- catch (const Exception& rEx)
- {
- OString sMsg("GetLocalProperty: ");
- sMsg += OString(rEx.Message.getStr(),
- rEx.Message.getLength(),
- RTL_TEXTENCODING_ASCII_US);
- OSL_FAIL(sMsg.getStr());
- }
-#else
- catch (const Exception&)
- {
- }
-#endif
- return aRet;
+void utl::ConfigManager::registerConfigItem(utl::ConfigItem * item) {
+ OSL_ASSERT(item != 0);
+ items_.push_back(item);
}
-void ConfigManager::PutLocalProperty(const OUString& rProperty, const Any& rValue)
-{
- OUString sPath(RTL_CONSTASCII_USTRINGPARAM(aConfigBaseURL));
- sPath += rProperty;
-
- OUString sNode, sProperty;
- OSL_VERIFY( splitLastFromConfigurationPath(sPath, sNode, sProperty) );
-
- Reference<XNameReplace> xNodeReplace(GetHierarchyAccess(sNode), UNO_QUERY);
- if(xNodeReplace.is())
+void utl::ConfigManager::doStoreConfigItems() {
+ for (std::list< ConfigItem * >::iterator i(items_.begin());
+ i != items_.end(); ++i)
{
- try
- {
- xNodeReplace->replaceByName(sProperty, rValue);
- }
-#if OSL_DEBUG_LEVEL > 1
- catch (const Exception& rEx)
- {
- OString sMsg("PutLocalProperty: ");
- sMsg += OString(rEx.Message.getStr(),
- rEx.Message.getLength(),
- RTL_TEXTENCODING_ASCII_US);
- OSL_FAIL(sMsg.getStr());
+ if ((*i)->IsModified()) {
+ (*i)->Commit();
+ (*i)->ClearModified();
}
-#else
- catch (const Exception&)
- {
- }
-#endif
}
}
-sal_Bool ConfigManager::IsLocalConfigProvider()
-{
- return false;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/config/defaultoptions.cxx b/unotools/source/config/defaultoptions.cxx
index 0b9f1331b261..b068646341ae 100644
--- a/unotools/source/config/defaultoptions.cxx
+++ b/unotools/source/config/defaultoptions.cxx
@@ -234,7 +234,6 @@ String SvtDefaultOptions_Impl::GetDefaultPath( sal_uInt16 nId ) const
SvtDefaultOptions_Impl::SvtDefaultOptions_Impl() : ConfigItem( ASCII_STR("Office.Common/Path/Default") )
{
- /*ConfigManager* pCfgMgr =*/ ConfigManager::GetConfigManager();
Sequence< OUString > aNames = GetDefaultPropertyNames();
Sequence< Any > aValues = GetProperties( aNames );
EnableNotification( aNames );
diff --git a/unotools/source/config/docinfohelper.cxx b/unotools/source/config/docinfohelper.cxx
index 462ab33ca162..537102a9eff7 100644
--- a/unotools/source/config/docinfohelper.cxx
+++ b/unotools/source/config/docinfohelper.cxx
@@ -47,25 +47,21 @@ namespace utl
// First product: branded name + version
// version is <product_versions>_<product_extension>$<platform>
- utl::ConfigManager& rMgr = utl::ConfigManager::GetConfigManager();
+
// plain product name
- rtl::OUString aValue;
- uno::Any aAny = rMgr.GetDirectConfigProperty(
- utl::ConfigManager::PRODUCTNAME);
- if ( (aAny >>= aValue) && aValue.getLength() )
+ rtl::OUString aValue( utl::ConfigManager::getProductName() );
+ if ( !aValue.isEmpty() )
{
aResult.append( aValue.replace( ' ', '_' ) );
aResult.append( (sal_Unicode)'/' );
- aAny = rMgr.GetDirectConfigProperty(
- utl::ConfigManager::PRODUCTVERSION);
- if ( (aAny >>= aValue) && aValue.getLength() )
+ aValue = utl::ConfigManager::getProductVersion();
+ if ( !aValue.isEmpty() )
{
aResult.append( aValue.replace( ' ', '_' ) );
- aAny = rMgr.GetDirectConfigProperty(
- utl::ConfigManager::PRODUCTEXTENSION);
- if ( (aAny >>= aValue) && aValue.getLength() )
+ aValue = utl::ConfigManager::getProductExtension();
+ if ( !aValue.isEmpty() )
{
aResult.append( (sal_Unicode)'_' );
aResult.append( aValue.replace( ' ', '_' ) );
diff --git a/unotools/source/config/itemholder1.cxx b/unotools/source/config/itemholder1.cxx
index ee96bc83e322..92d3971a5365 100644
--- a/unotools/source/config/itemholder1.cxx
+++ b/unotools/source/config/itemholder1.cxx
@@ -90,7 +90,6 @@ ItemHolder1::ItemHolder1()
if (xCfg.is())
xCfg->addEventListener(static_cast< css::lang::XEventListener* >(this));
}
-// #i37892 got errorhandling from ConfigManager::GetConfigurationProvider()
#ifdef DBG_UTIL
catch(css::uno::Exception& rEx)
{
diff --git a/unotools/source/config/pathoptions.cxx b/unotools/source/config/pathoptions.cxx
index b760576c47a1..327401059d5d 100644
--- a/unotools/source/config/pathoptions.cxx
+++ b/unotools/source/config/pathoptions.cxx
@@ -510,22 +510,11 @@ SvtPathOptions_Impl::SvtPathOptions_Impl() :
}
// Set language type!
- Any aLocale = ConfigManager::GetConfigManager().GetDirectConfigProperty( ConfigManager::LOCALE );
- OUString aLocaleStr;
- if ( aLocale >>= aLocaleStr )
- {
- sal_Int32 nIndex = 0;
- m_aLocale.Language = aLocaleStr.getToken(0, '-', nIndex );
- m_aLocale.Country = aLocaleStr.getToken(0, '-', nIndex );
- m_aLocale.Variant = aLocaleStr.getToken(0, '-', nIndex );
- }
- else
- {
- DBG_ASSERT(!aLocale.hasValue(), "wrong any type");
- m_aLocale.Language = OStringToOUString(OString("en"), RTL_TEXTENCODING_UTF8);
- m_aLocale.Country = OStringToOUString(OString("US"), RTL_TEXTENCODING_UTF8);
- m_aLocale.Variant = OStringToOUString(OString(""), RTL_TEXTENCODING_UTF8);
- }
+ OUString aLocaleStr( ConfigManager::getLocale() );
+ sal_Int32 nIndex = 0;
+ m_aLocale.Language = aLocaleStr.getToken(0, '-', nIndex );
+ m_aLocale.Country = aLocaleStr.getToken(0, '-', nIndex );
+ m_aLocale.Variant = aLocaleStr.getToken(0, '-', nIndex );
}
// -----------------------------------------------------------------------
diff --git a/unotools/source/config/useroptions.cxx b/unotools/source/config/useroptions.cxx
index 11a781213b4c..dc5599437b24 100644
--- a/unotools/source/config/useroptions.cxx
+++ b/unotools/source/config/useroptions.cxx
@@ -106,7 +106,6 @@ public:
::rtl::OUString GetApartment() const;
::rtl::OUString GetFullName() const;
- ::rtl::OUString GetLocale() const { return m_aLocale; }
// set the address token
void SetCompany( const ::rtl::OUString& rNewToken );
@@ -136,7 +135,6 @@ private:
uno::Reference< util::XChangesListener > m_xChangeListener;
css::uno::Reference< css::container::XNameAccess > m_xCfg;
css::uno::Reference< css::beans::XPropertySet > m_xData;
- ::rtl::OUString m_aLocale;
};
// global ----------------------------------------------------------------
@@ -203,15 +201,6 @@ SvtUserOptions_Impl::SvtUserOptions_Impl() :
m_xCfg.clear();
LogHelper::logIt(ex);
}
-
- Any aAny = ConfigManager::GetConfigManager().GetDirectConfigProperty( ConfigManager::LOCALE );
- ::rtl::OUString aLocale;
- if ( aAny >>= aLocale )
- m_aLocale = aLocale;
- else
- {
- DBG_ERRORFILE( "SvtUserOptions_Impl::SvtUserOptions_Impl(): no locale found" );
- }
}
// -----------------------------------------------------------------------
@@ -1150,8 +1139,7 @@ namespace
::rtl::OUString SvtUserOptions::GetLocale() const
{
- ::osl::MutexGuard aGuard( GetInitMutex() );
- return pImp->GetLocale();
+ return utl::ConfigManager::getLocale();
}
// -----------------------------------------------------------------------