diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-11-20 23:39:21 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-11-20 23:39:21 +0100 |
commit | 380007d64716fc93fa265133eaa264132a242768 (patch) | |
tree | b405a09114e0f9aa11f0b1d08973399cac36cde6 /unotools/source | |
parent | 2d81c8f01771585e5f6bac87722051e0582f8453 (diff) |
Elide utl::ConfigItem_Impl
...and utl::ConfigItem::IsValidConfigMgr is always true.
Change-Id: I37e295729c3d0ae12719f0ae6f5a5628c58d0b9f
Diffstat (limited to 'unotools/source')
-rw-r--r-- | unotools/source/config/configitem.cxx | 107 | ||||
-rw-r--r-- | unotools/source/config/syslocaleoptions.cxx | 165 |
2 files changed, 109 insertions, 163 deletions
diff --git a/unotools/source/config/configitem.cxx b/unotools/source/config/configitem.cxx index 4119983f8e68..d3127c873cae 100644 --- a/unotools/source/config/configitem.cxx +++ b/unotools/source/config/configitem.cxx @@ -91,23 +91,6 @@ namespace utl{ //XEventListener virtual void SAL_CALL disposing( const EventObject& Source ) throw(RuntimeException); }; - -struct ConfigItem_Impl -{ - utl::ConfigManager* pManager; - sal_Int16 nMode; - sal_Bool bIsModified; - sal_Bool bEnableInternalNotification; - - sal_Int16 nInValueChange; - ConfigItem_Impl() : - pManager(0), - nMode(0), - bIsModified(sal_False), - bEnableInternalNotification(sal_False), - nInValueChange(0) - {} -}; } class ValueCounter_Impl @@ -124,28 +107,6 @@ public: } }; -namespace -{ - // helper to achieve exception - safe handling of an Item under construction - template <class TYP> - class AutoDeleter // : Noncopyable - { - TYP* m_pItem; - public: - AutoDeleter(TYP * pItem) - : m_pItem(pItem) - { - } - - ~AutoDeleter() - { - delete m_pItem; - } - - void keep() { m_pItem = 0; } - }; -} - ConfigChangeListener_Impl::ConfigChangeListener_Impl( ConfigItem& rItem, const Sequence< OUString >& rNames) : pParent(&rItem), @@ -206,33 +167,21 @@ void ConfigChangeListener_Impl::disposing( const EventObject& /*rSource*/ ) thro ConfigItem::ConfigItem(const OUString &rSubTree, sal_Int16 nSetMode ) : sSubTree(rSubTree), - pImpl(new ConfigItem_Impl) + m_nMode(nSetMode), + m_bIsModified(false), + m_bEnableInternalNotification(false), + m_nInValueChange(0) { - AutoDeleter<ConfigItem_Impl> aNewImpl(pImpl); - - pImpl->pManager = &ConfigManager::getConfigManager(); - pImpl->nMode = nSetMode; if(0 != (nSetMode&CONFIG_MODE_RELEASE_TREE)) - pImpl->pManager->addConfigItem(*this); + ConfigManager::getConfigManager().addConfigItem(*this); else - m_xHierarchyAccess = pImpl->pManager->addConfigItem(*this); - - aNewImpl.keep(); -} - -sal_Bool ConfigItem::IsValidConfigMgr() const -{ - return pImpl->pManager != 0; + m_xHierarchyAccess = ConfigManager::getConfigManager().addConfigItem(*this); } ConfigItem::~ConfigItem() { - if(pImpl->pManager) - { - RemoveChangesListener(); - pImpl->pManager->removeConfigItem(*this); - } - delete pImpl; + RemoveChangesListener(); + ConfigManager::getConfigManager().removeConfigItem(*this); } void ConfigItem::CallNotify( const com::sun::star::uno::Sequence<OUString>& rPropertyNames ) @@ -240,7 +189,7 @@ void ConfigItem::CallNotify( const com::sun::star::uno::Sequence<OUString>& rPro // the call is forwarded to the virtual Notify() method // it is pure virtual, so all classes deriving from ConfigItem have to decide how they // want to notify listeners - if(!IsInValueChange() || pImpl->bEnableInternalNotification) + if(!IsInValueChange() || m_bEnableInternalNotification) Notify(rPropertyNames); } @@ -250,7 +199,7 @@ void ConfigItem::impl_packLocalizedProperties( const Sequence< OUString >& { // Safe impossible cases. // This method should be called for special ConfigItem-mode only! - OSL_ENSURE( ((pImpl->nMode & CONFIG_MODE_ALL_LOCALES ) == CONFIG_MODE_ALL_LOCALES), "ConfigItem::impl_packLocalizedProperties()\nWrong call of this method detected!\n" ); + OSL_ENSURE( ((m_nMode & CONFIG_MODE_ALL_LOCALES ) == CONFIG_MODE_ALL_LOCALES), "ConfigItem::impl_packLocalizedProperties()\nWrong call of this method detected!\n" ); sal_Int32 nSourceCounter ; // used to step during input lists sal_Int32 nSourceSize ; // marks end of loop over input lists @@ -323,7 +272,7 @@ void ConfigItem::impl_unpackLocalizedProperties( const Sequence< OUString > { // Safe impossible cases. // This method should be called for special ConfigItem-mode only! - OSL_ENSURE( ((pImpl->nMode & CONFIG_MODE_ALL_LOCALES ) == CONFIG_MODE_ALL_LOCALES), "ConfigItem::impl_unpackLocalizedProperties()\nWrong call of this method detected!\n" ); + OSL_ENSURE( ((m_nMode & CONFIG_MODE_ALL_LOCALES ) == CONFIG_MODE_ALL_LOCALES), "ConfigItem::impl_unpackLocalizedProperties()\nWrong call of this method detected!\n" ); sal_Int32 nSourceCounter ; // used to step during input lists sal_Int32 nSourceSize ; // marks end of loop over input lists @@ -496,7 +445,7 @@ Sequence< Any > ConfigItem::GetProperties(const Sequence< OUString >& rNames) } // In special mode "ALL_LOCALES" we must convert localized values to Sequence< PropertyValue >. - if((pImpl->nMode & CONFIG_MODE_ALL_LOCALES ) == CONFIG_MODE_ALL_LOCALES) + if((m_nMode & CONFIG_MODE_ALL_LOCALES ) == CONFIG_MODE_ALL_LOCALES) { Sequence< Any > lValues; impl_packLocalizedProperties( rNames, aRet, lValues ); @@ -509,7 +458,7 @@ Sequence< Any > ConfigItem::GetProperties(const Sequence< OUString >& rNames) sal_Bool ConfigItem::PutProperties( const Sequence< OUString >& rNames, const Sequence< Any>& rValues) { - ValueCounter_Impl aCounter(pImpl->nInValueChange); + ValueCounter_Impl aCounter(m_nInValueChange); Reference<XHierarchicalNameAccess> xHierarchyAccess = GetTree(); Reference<XNameReplace> xTopNodeReplace(xHierarchyAccess, UNO_QUERY); sal_Bool bRet = xHierarchyAccess.is() && xTopNodeReplace.is(); @@ -520,7 +469,7 @@ sal_Bool ConfigItem::PutProperties( const Sequence< OUString >& rNames, const OUString* pNames = NULL ; const Any* pValues = NULL ; sal_Int32 nNameCount ; - if(( pImpl->nMode & CONFIG_MODE_ALL_LOCALES ) == CONFIG_MODE_ALL_LOCALES ) + if(( m_nMode & CONFIG_MODE_ALL_LOCALES ) == CONFIG_MODE_ALL_LOCALES ) { // If ConfigItem works in "ALL_LOCALES"-mode ... we must support a Sequence< PropertyValue > // as value of an localized configuration entry! @@ -590,8 +539,8 @@ sal_Bool ConfigItem::EnableNotification(const Sequence< OUString >& rNames, sal_Bool bEnableInternalNotification ) { - OSL_ENSURE(0 == (pImpl->nMode&CONFIG_MODE_RELEASE_TREE), "notification in CONFIG_MODE_RELEASE_TREE mode not possible"); - pImpl->bEnableInternalNotification = bEnableInternalNotification; + OSL_ENSURE(0 == (m_nMode&CONFIG_MODE_RELEASE_TREE), "notification in CONFIG_MODE_RELEASE_TREE mode not possible"); + m_bEnableInternalNotification = bEnableInternalNotification; Reference<XHierarchicalNameAccess> xHierarchyAccess = GetTree(); Reference<XChangesNotifier> xChgNot(xHierarchyAccess, UNO_QUERY); if(!xChgNot.is()) @@ -743,7 +692,7 @@ Sequence< OUString > ConfigItem::GetNodeNames(const OUString& rNode, ConfigNameF sal_Bool ConfigItem::ClearNodeSet(const OUString& rNode) { - ValueCounter_Impl aCounter(pImpl->nInValueChange); + ValueCounter_Impl aCounter(m_nInValueChange); sal_Bool bRet = sal_False; Reference<XHierarchicalNameAccess> xHierarchyAccess = GetTree(); if(xHierarchyAccess.is()) @@ -781,7 +730,7 @@ sal_Bool ConfigItem::ClearNodeSet(const OUString& rNode) sal_Bool ConfigItem::ClearNodeElements(const OUString& rNode, Sequence< OUString >& rElements) { - ValueCounter_Impl aCounter(pImpl->nInValueChange); + ValueCounter_Impl aCounter(m_nInValueChange); sal_Bool bRet = sal_False; Reference<XHierarchicalNameAccess> xHierarchyAccess = GetTree(); if(xHierarchyAccess.is()) @@ -855,7 +804,7 @@ Sequence< OUString > lcl_extractSetPropertyNames( const Sequence< PropertyValue sal_Bool ConfigItem::SetSetProperties( const OUString& rNode, Sequence< PropertyValue > rValues) { - ValueCounter_Impl aCounter(pImpl->nInValueChange); + ValueCounter_Impl aCounter(m_nInValueChange); sal_Bool bRet = sal_True; Reference<XHierarchicalNameAccess> xHierarchyAccess = GetTree(); if(xHierarchyAccess.is()) @@ -954,7 +903,7 @@ sal_Bool ConfigItem::SetSetProperties( sal_Bool ConfigItem::ReplaceSetProperties( const OUString& rNode, Sequence< PropertyValue > rValues) { - ValueCounter_Impl aCounter(pImpl->nInValueChange); + ValueCounter_Impl aCounter(m_nInValueChange); sal_Bool bRet = sal_True; Reference<XHierarchicalNameAccess> xHierarchyAccess = GetTree(); if(xHierarchyAccess.is()) @@ -1091,7 +1040,7 @@ sal_Bool ConfigItem::ReplaceSetProperties( sal_Bool ConfigItem::AddNode(const OUString& rNode, const OUString& rNewNode) { - ValueCounter_Impl aCounter(pImpl->nInValueChange); + ValueCounter_Impl aCounter(m_nInValueChange); sal_Bool bRet = sal_True; Reference<XHierarchicalNameAccess> xHierarchyAccess = GetTree(); if(xHierarchyAccess.is()) @@ -1154,27 +1103,27 @@ sal_Bool ConfigItem::AddNode(const OUString& rNode, const OUString& rNewNode) sal_Int16 ConfigItem::GetMode() const { - return pImpl->nMode; + return m_nMode; } void ConfigItem::SetModified() { - pImpl->bIsModified = sal_True; + m_bIsModified = true; } void ConfigItem::ClearModified() { - pImpl->bIsModified = sal_False; + m_bIsModified = false; } -sal_Bool ConfigItem::IsModified() const +bool ConfigItem::IsModified() const { - return pImpl->bIsModified; + return m_bIsModified; } -sal_Bool ConfigItem::IsInValueChange() const +bool ConfigItem::IsInValueChange() const { - return pImpl->nInValueChange > 0; + return m_nInValueChange > 0; } Reference< XHierarchicalNameAccess> ConfigItem::GetTree() diff --git a/unotools/source/config/syslocaleoptions.cxx b/unotools/source/config/syslocaleoptions.cxx index 806d58e1eb03..67c7de50d0fb 100644 --- a/unotools/source/config/syslocaleoptions.cxx +++ b/unotools/source/config/syslocaleoptions.cxx @@ -152,103 +152,100 @@ SvtSysLocaleOptions_Impl::SvtSysLocaleOptions_Impl() , m_bROIgnoreLanguageChange(false) { - if ( IsValidConfigMgr() ) + const Sequence< OUString > aNames = GetPropertyNames(); + Sequence< Any > aValues = GetProperties( aNames ); + Sequence< sal_Bool > aROStates = GetReadOnlyStates( aNames ); + const Any* pValues = aValues.getConstArray(); + const sal_Bool* pROStates = aROStates.getConstArray(); + DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" ); + DBG_ASSERT( aROStates.getLength() == aNames.getLength(), "GetReadOnlyStates failed" ); + if ( aValues.getLength() == aNames.getLength() && aROStates.getLength() == aNames.getLength() ) { - const Sequence< OUString > aNames = GetPropertyNames(); - Sequence< Any > aValues = GetProperties( aNames ); - Sequence< sal_Bool > aROStates = GetReadOnlyStates( aNames ); - const Any* pValues = aValues.getConstArray(); - const sal_Bool* pROStates = aROStates.getConstArray(); - DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" ); - DBG_ASSERT( aROStates.getLength() == aNames.getLength(), "GetReadOnlyStates failed" ); - if ( aValues.getLength() == aNames.getLength() && aROStates.getLength() == aNames.getLength() ) + for ( sal_Int32 nProp = 0; nProp < aNames.getLength(); nProp++ ) { - for ( sal_Int32 nProp = 0; nProp < aNames.getLength(); nProp++ ) + if ( pValues[nProp].hasValue() ) { - if ( pValues[nProp].hasValue() ) + switch ( nProp ) { - switch ( nProp ) + case PROPERTYHANDLE_LOCALE : { - case PROPERTYHANDLE_LOCALE : - { - OUString aStr; - if ( pValues[nProp] >>= aStr ) - m_aLocaleString = aStr; - else - { - SAL_WARN( "unotools.config", "Wrong property type!" ); - } - m_bROLocale = pROStates[nProp]; - } - break; - case PROPERTYHANDLE_UILOCALE : - { - OUString aStr; - if ( pValues[nProp] >>= aStr ) - m_aUILocaleString = aStr; - else - { - SAL_WARN( "unotools.config", "Wrong property type!" ); - } - m_bROUILocale = pROStates[nProp]; - } - break; - case PROPERTYHANDLE_CURRENCY : - { - OUString aStr; - if ( pValues[nProp] >>= aStr ) - m_aCurrencyString = aStr; - else - { - SAL_WARN( "unotools.config", "Wrong property type!" ); - } - m_bROCurrency = pROStates[nProp]; - } - break; - case PROPERTYHANDLE_DECIMALSEPARATOR: + OUString aStr; + if ( pValues[nProp] >>= aStr ) + m_aLocaleString = aStr; + else { - bool bValue = false; - if ( pValues[nProp] >>= bValue ) - m_bDecimalSeparator = bValue; - else - { - SAL_WARN( "unotools.config", "Wrong property type!" ); - } - m_bRODecimalSeparator = pROStates[nProp]; + SAL_WARN( "unotools.config", "Wrong property type!" ); } - break; - case PROPERTYHANDLE_DATEPATTERNS : - { - OUString aStr; - if ( pValues[nProp] >>= aStr ) - m_aDatePatternsString = aStr; - else - { - SAL_WARN( "unotools.config", "Wrong property type!" ); - } - m_bRODatePatterns = pROStates[nProp]; - } - break; - case PROPERTYHANDLE_IGNORELANGCHANGE : - { - bool bValue = false; - if ( pValues[nProp] >>= bValue ) - m_bIgnoreLanguageChange = bValue; - else - { - SAL_WARN( "unotools.config", "Wrong property type!" ); - } - m_bROIgnoreLanguageChange = pROStates[nProp]; - } - break; - default: + m_bROLocale = pROStates[nProp]; + } + break; + case PROPERTYHANDLE_UILOCALE : + { + OUString aStr; + if ( pValues[nProp] >>= aStr ) + m_aUILocaleString = aStr; + else + { SAL_WARN( "unotools.config", "Wrong property type!" ); + } + m_bROUILocale = pROStates[nProp]; + } + break; + case PROPERTYHANDLE_CURRENCY : + { + OUString aStr; + if ( pValues[nProp] >>= aStr ) + m_aCurrencyString = aStr; + else + { + SAL_WARN( "unotools.config", "Wrong property type!" ); + } + m_bROCurrency = pROStates[nProp]; + } + break; + case PROPERTYHANDLE_DECIMALSEPARATOR: + { + bool bValue = false; + if ( pValues[nProp] >>= bValue ) + m_bDecimalSeparator = bValue; + else + { + SAL_WARN( "unotools.config", "Wrong property type!" ); + } + m_bRODecimalSeparator = pROStates[nProp]; + } + break; + case PROPERTYHANDLE_DATEPATTERNS : + { + OUString aStr; + if ( pValues[nProp] >>= aStr ) + m_aDatePatternsString = aStr; + else + { + SAL_WARN( "unotools.config", "Wrong property type!" ); + } + m_bRODatePatterns = pROStates[nProp]; + } + break; + case PROPERTYHANDLE_IGNORELANGCHANGE : + { + bool bValue = false; + if ( pValues[nProp] >>= bValue ) + m_bIgnoreLanguageChange = bValue; + else + { + SAL_WARN( "unotools.config", "Wrong property type!" ); + } + m_bROIgnoreLanguageChange = pROStates[nProp]; } + break; + default: + SAL_WARN( "unotools.config", "Wrong property type!" ); } } } - EnableNotification( aNames ); } + EnableNotification( aNames ); MakeRealLocale(); MakeRealUILocale(); |