diff options
-rw-r--r-- | filter/source/xsltfilter/XSLTFilter.cxx | 11 | ||||
-rw-r--r-- | forms/source/xforms/submission.cxx | 7 | ||||
-rw-r--r-- | framework/source/fwe/xml/xmlnamespaces.cxx | 19 | ||||
-rw-r--r-- | framework/source/fwi/uielement/constitemcontainer.cxx | 5 | ||||
-rw-r--r-- | framework/source/services/ContextChangeEventMultiplexer.cxx | 5 | ||||
-rw-r--r-- | framework/source/services/substitutepathvars.cxx | 9 | ||||
-rw-r--r-- | framework/source/uiconfiguration/graphicnameaccess.cxx | 5 | ||||
-rw-r--r-- | framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx | 301 | ||||
-rw-r--r-- | framework/source/uiconfiguration/uiconfigurationmanager.cxx | 112 | ||||
-rw-r--r-- | i18npool/source/breakiterator/breakiterator_unicode.cxx | 7 | ||||
-rw-r--r-- | i18npool/source/calendar/calendarImpl.cxx | 180 | ||||
-rw-r--r-- | i18npool/source/collator/collatorImpl.cxx | 5 | ||||
-rw-r--r-- | i18npool/source/indexentry/indexentrysupplier.cxx | 17 | ||||
-rw-r--r-- | i18npool/source/localedata/localedata.cxx | 5 |
14 files changed, 310 insertions, 378 deletions
diff --git a/filter/source/xsltfilter/XSLTFilter.cxx b/filter/source/xsltfilter/XSLTFilter.cxx index d4455f620a0a..5373db29aa73 100644 --- a/filter/source/xsltfilter/XSLTFilter.cxx +++ b/filter/source/xsltfilter/XSLTFilter.cxx @@ -527,15 +527,8 @@ namespace XSLT // wait for the transformer to finish m_cTransformed.wait(); m_tcontrol->terminate(); - if (!m_bError && !m_bTerminated) - { - return; - } - else - { - throw RuntimeException(); - } - + if (m_bError || m_bTerminated) + throw RuntimeException(); } diff --git a/forms/source/xforms/submission.cxx b/forms/source/xforms/submission.cxx index a0cd6e9fcdba..3757378c663d 100644 --- a/forms/source/xforms/submission.cxx +++ b/forms/source/xforms/submission.cxx @@ -477,16 +477,13 @@ void SAL_CALL Submission::submitWithInteraction( *this, makeAny( e ) ); } - if( bResult ) - { - mxModel->rebuild(); - } - else + if( !bResult ) { // other failure: throw wrapped target exception, too. throw WrappedTargetException( lcl_message( sID, OUString() ), *this, Any() ); } + mxModel->rebuild(); } void SAL_CALL Submission::submit( ) diff --git a/framework/source/fwe/xml/xmlnamespaces.cxx b/framework/source/fwe/xml/xmlnamespaces.cxx index c13c0bbbf163..a505a2101094 100644 --- a/framework/source/fwe/xml/xmlnamespaces.cxx +++ b/framework/source/fwe/xml/xmlnamespaces.cxx @@ -98,16 +98,13 @@ OUString XMLNamespaces::applyNSToAttributeName( const OUString& aName ) const int index; if (( index = aName.indexOf( ':' )) > 0 ) { - if ( aName.getLength() > index+1 ) - { - OUString aAttributeName = getNamespaceValue( aName.copy( 0, index )) + "^" + aName.copy( index+1); - return aAttributeName; - } - else + if ( aName.getLength() <= index+1 ) { // attribute with namespace but without name "namespace:" is not allowed!! throw SAXException( "Attribute has no name only preceding namespace!", Reference< XInterface >(), Any() ); } + OUString aAttributeName = getNamespaceValue( aName.copy( 0, index )) + "^" + aName.copy( index+1); + return aAttributeName; } return aName; @@ -135,13 +132,12 @@ OUString XMLNamespaces::applyNSToElementName( const OUString& aName ) const if ( index > 0 ) { - if ( aName.getLength() > index+1 ) - aElementName += aName.copy( index+1 ); - else + if ( aName.getLength() <= index+1 ) { // attribute with namespace but without a name is not allowed (e.g. "cfg:" ) throw SAXException( "Attribute has no name only preceding namespace!", Reference< XInterface >(), Any() ); } + aElementName += aName.copy( index+1 ); } else aElementName += aName; @@ -157,13 +153,12 @@ OUString XMLNamespaces::getNamespaceValue( const OUString& aNamespace ) const { NamespaceMap::const_iterator p; p = m_aNamespaceMap.find( aNamespace ); - if ( p != m_aNamespaceMap.end() ) - return p->second; - else + if ( p == m_aNamespaceMap.end() ) { // namespace not defined => throw exception! throw SAXException( "XML namespace used but not defined!", Reference< XInterface >(), Any() ); } + return p->second; } } diff --git a/framework/source/fwi/uielement/constitemcontainer.cxx b/framework/source/fwi/uielement/constitemcontainer.cxx index 811e33ba89cb..efe3167c81a9 100644 --- a/framework/source/fwi/uielement/constitemcontainer.cxx +++ b/framework/source/fwi/uielement/constitemcontainer.cxx @@ -204,10 +204,9 @@ sal_Int32 SAL_CALL ConstItemContainer::getCount() Any SAL_CALL ConstItemContainer::getByIndex( sal_Int32 Index ) { - if ( sal_Int32( m_aItemVector.size()) > Index ) - return makeAny( m_aItemVector[Index] ); - else + if ( sal_Int32( m_aItemVector.size()) <= Index ) throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); + return makeAny( m_aItemVector[Index] ); } // XPropertySet diff --git a/framework/source/services/ContextChangeEventMultiplexer.cxx b/framework/source/services/ContextChangeEventMultiplexer.cxx index ac579eeee802..59eca7c933a6 100644 --- a/framework/source/services/ContextChangeEventMultiplexer.cxx +++ b/framework/source/services/ContextChangeEventMultiplexer.cxx @@ -156,14 +156,13 @@ void SAL_CALL ContextChangeEventMultiplexer::addContextChangeEventListener ( if (pFocusDescriptor != nullptr) { ListenerContainer& rContainer (pFocusDescriptor->maListeners); - if (::std::find(rContainer.begin(), rContainer.end(), rxListener) == rContainer.end()) - rContainer.push_back(rxListener); - else + if (::std::find(rContainer.begin(), rContainer.end(), rxListener) != rContainer.end()) { // The listener was added for the same event focus // previously. That is an error. throw cssl::IllegalArgumentException("listener added twice", static_cast<XWeak*>(this), 0); } + rContainer.push_back(rxListener); } // Send out an initial event that informs the new listener about diff --git a/framework/source/services/substitutepathvars.cxx b/framework/source/services/substitutepathvars.cxx index 44a17f6ac6b7..7aea555232a6 100644 --- a/framework/source/services/substitutepathvars.cxx +++ b/framework/source/services/substitutepathvars.cxx @@ -590,15 +590,12 @@ OUString const & SubstitutePathVariables::impl_getSubstituteVariableValue( const VarNameToIndexMap::const_iterator pNTOIIter = m_aPreDefVarMap.find( ( nPos == -1 ) ? aVariable : rVariable ); // Fixed/Predefined variable - if ( pNTOIIter != m_aPreDefVarMap.end() ) - { - PreDefVariable nIndex = pNTOIIter->second; - return m_aPreDefVars.m_FixedVar[(sal_Int32)nIndex]; - } - else + if ( pNTOIIter == m_aPreDefVarMap.end() ) { throw NoSuchElementException("Unknown variable!", static_cast<cppu::OWeakObject *>(this)); } + PreDefVariable nIndex = pNTOIIter->second; + return m_aPreDefVars.m_FixedVar[(sal_Int32)nIndex]; } void SubstitutePathVariables::SetPredefinedPathVariables() diff --git a/framework/source/uiconfiguration/graphicnameaccess.cxx b/framework/source/uiconfiguration/graphicnameaccess.cxx index bdd4c1f2445c..fbc1d8ed43f2 100644 --- a/framework/source/uiconfiguration/graphicnameaccess.cxx +++ b/framework/source/uiconfiguration/graphicnameaccess.cxx @@ -43,10 +43,9 @@ void GraphicNameAccess::addElement( const OUString& rName, const uno::Reference< uno::Any SAL_CALL GraphicNameAccess::getByName( const OUString& aName ) { NameGraphicHashMap::const_iterator pIter = m_aNameToElementMap.find( aName ); - if ( pIter != m_aNameToElementMap.end() ) - return uno::makeAny( pIter->second ); - else + if ( pIter == m_aNameToElementMap.end() ) throw container::NoSuchElementException(); + return uno::makeAny( pIter->second ); } uno::Sequence< OUString > SAL_CALL GraphicNameAccess::getElementNames() diff --git a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx index 96299c2bd83b..403e045c99f8 100644 --- a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx +++ b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx @@ -1188,94 +1188,91 @@ void SAL_CALL ModuleUIConfigurationManager::replaceSettings( const OUString& Res throw DisposedException(); UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType ); - if ( pDataSettings ) + if ( !pDataSettings ) + throw NoSuchElementException(); + if ( !pDataSettings->bDefaultNode ) { - if ( !pDataSettings->bDefaultNode ) - { - // we have a settings entry in our user-defined layer - replace - Reference< XIndexAccess > xOldSettings = pDataSettings->xSettings; - - // Create a copy of the data if the container is not const - Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY ); - if ( xReplace.is() ) - pDataSettings->xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY ); - else - pDataSettings->xSettings = aNewData; - pDataSettings->bDefault = false; - pDataSettings->bModified = true; - m_bModified = true; - - // Modify type container - UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType]; - rElementType.bModified = true; - - Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); - Reference< XInterface > xIfac( xThis, UNO_QUERY ); + // we have a settings entry in our user-defined layer - replace + Reference< XIndexAccess > xOldSettings = pDataSettings->xSettings; - // Create event to notify listener about replaced element settings - ui::ConfigurationEvent aEvent; - aEvent.ResourceURL = ResourceURL; - aEvent.Accessor <<= xThis; - aEvent.Source = xIfac; - aEvent.ReplacedElement <<= xOldSettings; - aEvent.Element <<= pDataSettings->xSettings; + // Create a copy of the data if the container is not const + Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY ); + if ( xReplace.is() ) + pDataSettings->xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY ); + else + pDataSettings->xSettings = aNewData; + pDataSettings->bDefault = false; + pDataSettings->bModified = true; + m_bModified = true; - aGuard.clear(); + // Modify type container + UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType]; + rElementType.bModified = true; - implts_notifyContainerListener( aEvent, NotifyOp_Replace ); - } + Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); + Reference< XInterface > xIfac( xThis, UNO_QUERY ); + + // Create event to notify listener about replaced element settings + ui::ConfigurationEvent aEvent; + aEvent.ResourceURL = ResourceURL; + aEvent.Accessor <<= xThis; + aEvent.Source = xIfac; + aEvent.ReplacedElement <<= xOldSettings; + aEvent.Element <<= pDataSettings->xSettings; + + aGuard.clear(); + + implts_notifyContainerListener( aEvent, NotifyOp_Replace ); + } + else + { + // we have no settings in our user-defined layer - insert + UIElementData aUIElementData; + + aUIElementData.bDefault = false; + aUIElementData.bDefaultNode = false; + aUIElementData.bModified = true; + + // Create a copy of the data if the container is not const + Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY ); + if ( xReplace.is() ) + aUIElementData.xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY ); else - { - // we have no settings in our user-defined layer - insert - UIElementData aUIElementData; + aUIElementData.xSettings = aNewData; + aUIElementData.aName = RetrieveNameFromResourceURL( ResourceURL ) + m_aXMLPostfix; + aUIElementData.aResourceURL = ResourceURL; + m_bModified = true; - aUIElementData.bDefault = false; - aUIElementData.bDefaultNode = false; - aUIElementData.bModified = true; - - // Create a copy of the data if the container is not const - Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY ); - if ( xReplace.is() ) - aUIElementData.xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY ); - else - aUIElementData.xSettings = aNewData; - aUIElementData.aName = RetrieveNameFromResourceURL( ResourceURL ) + m_aXMLPostfix; - aUIElementData.aResourceURL = ResourceURL; - m_bModified = true; - - // Modify type container - UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType]; - rElementType.bModified = true; - - UIElementDataHashMap& rElements = rElementType.aElementsHashMap; - - // Check our user element settings hash map as it can already contain settings that have been set to default! - // If no node can be found, we have to insert it. - UIElementDataHashMap::iterator pIter = rElements.find( ResourceURL ); - if ( pIter != rElements.end() ) - pIter->second = aUIElementData; - else - rElements.emplace( ResourceURL, aUIElementData ); - - Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); - Reference< XInterface > xIfac( xThis, UNO_QUERY ); + // Modify type container + UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType]; + rElementType.bModified = true; - // Create event to notify listener about replaced element settings - ui::ConfigurationEvent aEvent; + UIElementDataHashMap& rElements = rElementType.aElementsHashMap; - aEvent.ResourceURL = ResourceURL; - aEvent.Accessor <<= xThis; - aEvent.Source = xIfac; - aEvent.ReplacedElement <<= pDataSettings->xSettings; - aEvent.Element <<= aUIElementData.xSettings; + // Check our user element settings hash map as it can already contain settings that have been set to default! + // If no node can be found, we have to insert it. + UIElementDataHashMap::iterator pIter = rElements.find( ResourceURL ); + if ( pIter != rElements.end() ) + pIter->second = aUIElementData; + else + rElements.emplace( ResourceURL, aUIElementData ); - aGuard.clear(); + Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); + Reference< XInterface > xIfac( xThis, UNO_QUERY ); - implts_notifyContainerListener( aEvent, NotifyOp_Replace ); - } + // Create event to notify listener about replaced element settings + ui::ConfigurationEvent aEvent; + + aEvent.ResourceURL = ResourceURL; + aEvent.Accessor <<= xThis; + aEvent.Source = xIfac; + aEvent.ReplacedElement <<= pDataSettings->xSettings; + aEvent.Element <<= aUIElementData.xSettings; + + aGuard.clear(); + + implts_notifyContainerListener( aEvent, NotifyOp_Replace ); } - else - throw NoSuchElementException(); } } @@ -1301,65 +1298,62 @@ void SAL_CALL ModuleUIConfigurationManager::removeSettings( const OUString& Reso "ResourceURL: " + ResourceURL, nullptr ); UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType ); - if ( pDataSettings ) + if ( !pDataSettings ) + throw NoSuchElementException( "The settings data cannot be found. " + "ResourceURL: " + ResourceURL, nullptr ); + // If element settings are default, we don't need to change anything! + if ( pDataSettings->bDefault ) + return; + else { - // If element settings are default, we don't need to change anything! - if ( pDataSettings->bDefault ) - return; - else - { - Reference< XIndexAccess > xRemovedSettings = pDataSettings->xSettings; - pDataSettings->bDefault = true; + Reference< XIndexAccess > xRemovedSettings = pDataSettings->xSettings; + pDataSettings->bDefault = true; - // check if this is a default layer node - if ( !pDataSettings->bDefaultNode ) - pDataSettings->bModified = true; // we have to remove this node from the user layer! - pDataSettings->xSettings.clear(); - m_bModified = true; // user layer must be written + // check if this is a default layer node + if ( !pDataSettings->bDefaultNode ) + pDataSettings->bModified = true; // we have to remove this node from the user layer! + pDataSettings->xSettings.clear(); + m_bModified = true; // user layer must be written - // Modify type container - UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType]; - rElementType.bModified = true; + // Modify type container + UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType]; + rElementType.bModified = true; - Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); - Reference< XInterface > xIfac( xThis, UNO_QUERY ); + Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); + Reference< XInterface > xIfac( xThis, UNO_QUERY ); - // Check if we have settings in the default layer which replaces the user-defined one! - UIElementData* pDefaultDataSettings = impl_findUIElementData( ResourceURL, nElementType ); - if ( pDefaultDataSettings ) - { - // Create event to notify listener about replaced element settings - ui::ConfigurationEvent aEvent; + // Check if we have settings in the default layer which replaces the user-defined one! + UIElementData* pDefaultDataSettings = impl_findUIElementData( ResourceURL, nElementType ); + if ( pDefaultDataSettings ) + { + // Create event to notify listener about replaced element settings + ui::ConfigurationEvent aEvent; - aEvent.ResourceURL = ResourceURL; - aEvent.Accessor <<= xThis; - aEvent.Source = xIfac; - aEvent.Element <<= xRemovedSettings; - aEvent.ReplacedElement <<= pDefaultDataSettings->xSettings; + aEvent.ResourceURL = ResourceURL; + aEvent.Accessor <<= xThis; + aEvent.Source = xIfac; + aEvent.Element <<= xRemovedSettings; + aEvent.ReplacedElement <<= pDefaultDataSettings->xSettings; - aGuard.clear(); + aGuard.clear(); - implts_notifyContainerListener( aEvent, NotifyOp_Replace ); - } - else - { - // Create event to notify listener about removed element settings - ui::ConfigurationEvent aEvent; + implts_notifyContainerListener( aEvent, NotifyOp_Replace ); + } + else + { + // Create event to notify listener about removed element settings + ui::ConfigurationEvent aEvent; - aEvent.ResourceURL = ResourceURL; - aEvent.Accessor <<= xThis; - aEvent.Source = xIfac; - aEvent.Element <<= xRemovedSettings; + aEvent.ResourceURL = ResourceURL; + aEvent.Accessor <<= xThis; + aEvent.Source = xIfac; + aEvent.Element <<= xRemovedSettings; - aGuard.clear(); + aGuard.clear(); - implts_notifyContainerListener( aEvent, NotifyOp_Remove ); - } + implts_notifyContainerListener( aEvent, NotifyOp_Remove ); } } - else - throw NoSuchElementException( "The settings data cannot be found. " - "ResourceURL: " + ResourceURL, nullptr ); } } @@ -1380,47 +1374,44 @@ void SAL_CALL ModuleUIConfigurationManager::insertSettings( const OUString& NewR throw DisposedException(); UIElementData* pDataSettings = impl_findUIElementData( NewResourceURL, nElementType ); - if ( !pDataSettings ) - { - UIElementData aUIElementData; + if ( !(!pDataSettings) ) + throw ElementExistException(); + UIElementData aUIElementData; - aUIElementData.bDefault = false; - aUIElementData.bDefaultNode = false; - aUIElementData.bModified = true; + aUIElementData.bDefault = false; + aUIElementData.bDefaultNode = false; + aUIElementData.bModified = true; - // Create a copy of the data if the container is not const - Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY ); - if ( xReplace.is() ) - aUIElementData.xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY ); - else - aUIElementData.xSettings = aNewData; - aUIElementData.aName = RetrieveNameFromResourceURL( NewResourceURL ) + m_aXMLPostfix; - aUIElementData.aResourceURL = NewResourceURL; - m_bModified = true; + // Create a copy of the data if the container is not const + Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY ); + if ( xReplace.is() ) + aUIElementData.xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY ); + else + aUIElementData.xSettings = aNewData; + aUIElementData.aName = RetrieveNameFromResourceURL( NewResourceURL ) + m_aXMLPostfix; + aUIElementData.aResourceURL = NewResourceURL; + m_bModified = true; - UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType]; - rElementType.bModified = true; + UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType]; + rElementType.bModified = true; - UIElementDataHashMap& rElements = rElementType.aElementsHashMap; - rElements.emplace( NewResourceURL, aUIElementData ); + UIElementDataHashMap& rElements = rElementType.aElementsHashMap; + rElements.emplace( NewResourceURL, aUIElementData ); - Reference< XIndexAccess > xInsertSettings( aUIElementData.xSettings ); - Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); + Reference< XIndexAccess > xInsertSettings( aUIElementData.xSettings ); + Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); - // Create event to notify listener about removed element settings - ui::ConfigurationEvent aEvent; + // Create event to notify listener about removed element settings + ui::ConfigurationEvent aEvent; - aEvent.ResourceURL = NewResourceURL; - aEvent.Accessor <<= xThis; - aEvent.Source = xThis; - aEvent.Element <<= xInsertSettings; + aEvent.ResourceURL = NewResourceURL; + aEvent.Accessor <<= xThis; + aEvent.Source = xThis; + aEvent.Element <<= xInsertSettings; - aGuard.clear(); + aGuard.clear(); - implts_notifyContainerListener( aEvent, NotifyOp_Insert ); - } - else - throw ElementExistException(); + implts_notifyContainerListener( aEvent, NotifyOp_Insert ); } } diff --git a/framework/source/uiconfiguration/uiconfigurationmanager.cxx b/framework/source/uiconfiguration/uiconfigurationmanager.cxx index dcfd7227bc98..06b267a48700 100644 --- a/framework/source/uiconfiguration/uiconfigurationmanager.cxx +++ b/framework/source/uiconfiguration/uiconfigurationmanager.cxx @@ -957,44 +957,41 @@ void SAL_CALL UIConfigurationManager::replaceSettings( const OUString& ResourceU throw DisposedException(); UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType ); - if ( pDataSettings && !pDataSettings->bDefault ) - { - // we have a settings entry in our user-defined layer - replace - Reference< XIndexAccess > xOldSettings = pDataSettings->xSettings; + if ( !pDataSettings || pDataSettings->bDefault ) + throw NoSuchElementException(); + // we have a settings entry in our user-defined layer - replace + Reference< XIndexAccess > xOldSettings = pDataSettings->xSettings; - // Create a copy of the data if the container is not const - Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY ); - if ( xReplace.is() ) - pDataSettings->xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY ); - else - pDataSettings->xSettings = aNewData; + // Create a copy of the data if the container is not const + Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY ); + if ( xReplace.is() ) + pDataSettings->xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY ); + else + pDataSettings->xSettings = aNewData; - pDataSettings->bDefault = false; - pDataSettings->bModified = true; - m_bModified = true; + pDataSettings->bDefault = false; + pDataSettings->bModified = true; + m_bModified = true; - // Modify type container - UIElementType& rElementType = m_aUIElements[nElementType]; - rElementType.bModified = true; + // Modify type container + UIElementType& rElementType = m_aUIElements[nElementType]; + rElementType.bModified = true; - Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); - Reference< XInterface > xIfac( xThis, UNO_QUERY ); + Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); + Reference< XInterface > xIfac( xThis, UNO_QUERY ); - // Create event to notify listener about replaced element settings - ConfigurationEvent aEvent; + // Create event to notify listener about replaced element settings + ConfigurationEvent aEvent; - aEvent.ResourceURL = ResourceURL; - aEvent.Accessor <<= xThis; - aEvent.Source = xIfac; - aEvent.ReplacedElement <<= xOldSettings; - aEvent.Element <<= pDataSettings->xSettings; + aEvent.ResourceURL = ResourceURL; + aEvent.Accessor <<= xThis; + aEvent.Source = xIfac; + aEvent.ReplacedElement <<= xOldSettings; + aEvent.Element <<= pDataSettings->xSettings; - aGuard.clear(); + aGuard.clear(); - implts_notifyContainerListener( aEvent, NotifyOp_Replace ); - } - else - throw NoSuchElementException(); + implts_notifyContainerListener( aEvent, NotifyOp_Replace ); } } @@ -1020,44 +1017,41 @@ void SAL_CALL UIConfigurationManager::removeSettings( const OUString& ResourceUR "ResourceURL: " + ResourceURL, nullptr ); UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType ); - if ( pDataSettings ) + if ( !pDataSettings ) + throw NoSuchElementException( "The settings data cannot be found. " + "ResourceURL: " + ResourceURL, nullptr); + // If element settings are default, we don't need to change anything! + if ( pDataSettings->bDefault ) + return; + else { - // If element settings are default, we don't need to change anything! - if ( pDataSettings->bDefault ) - return; - else - { - Reference< XIndexAccess > xRemovedSettings = pDataSettings->xSettings; - pDataSettings->bDefault = true; + Reference< XIndexAccess > xRemovedSettings = pDataSettings->xSettings; + pDataSettings->bDefault = true; - // check if this is a default layer node - pDataSettings->bModified = true; // we have to remove this node from the user layer! - pDataSettings->xSettings.clear(); - m_bModified = true; // user layer must be written + // check if this is a default layer node + pDataSettings->bModified = true; // we have to remove this node from the user layer! + pDataSettings->xSettings.clear(); + m_bModified = true; // user layer must be written - // Modify type container - UIElementType& rElementType = m_aUIElements[nElementType]; - rElementType.bModified = true; + // Modify type container + UIElementType& rElementType = m_aUIElements[nElementType]; + rElementType.bModified = true; - Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); - Reference< XInterface > xIfac( xThis, UNO_QUERY ); + Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); + Reference< XInterface > xIfac( xThis, UNO_QUERY ); - // Create event to notify listener about removed element settings - ConfigurationEvent aEvent; + // Create event to notify listener about removed element settings + ConfigurationEvent aEvent; - aEvent.ResourceURL = ResourceURL; - aEvent.Accessor <<= xThis; - aEvent.Source = xIfac; - aEvent.Element <<= xRemovedSettings; + aEvent.ResourceURL = ResourceURL; + aEvent.Accessor <<= xThis; + aEvent.Source = xIfac; + aEvent.Element <<= xRemovedSettings; - aGuard.clear(); + aGuard.clear(); - implts_notifyContainerListener( aEvent, NotifyOp_Remove ); - } + implts_notifyContainerListener( aEvent, NotifyOp_Remove ); } - else - throw NoSuchElementException( "The settings data cannot be found. " - "ResourceURL: " + ResourceURL, nullptr); } } diff --git a/i18npool/source/breakiterator/breakiterator_unicode.cxx b/i18npool/source/breakiterator/breakiterator_unicode.cxx index cf781eb414a0..5331b8366e4d 100644 --- a/i18npool/source/breakiterator/breakiterator_unicode.cxx +++ b/i18npool/source/breakiterator/breakiterator_unicode.cxx @@ -179,12 +179,11 @@ void SAL_CALL BreakIterator_Unicode::loadICUBreakIterator(const css::lang::Local throw uno::RuntimeException(); } } - if (icuBI->aBreakIterator) { - icuBI->maLocale=rLocale; - bNewBreak=true; - } else { + if (!icuBI->aBreakIterator) { throw uno::RuntimeException(); } + icuBI->maLocale=rLocale; + bNewBreak=true; } if (bNewBreak || icuBI->aICUText.pData != rText.pData) diff --git a/i18npool/source/calendar/calendarImpl.cxx b/i18npool/source/calendar/calendarImpl.cxx index 94b72e2bf70d..220a3a9fde78 100644 --- a/i18npool/source/calendar/calendarImpl.cxx +++ b/i18npool/source/calendar/calendarImpl.cxx @@ -83,10 +83,9 @@ CalendarImpl::loadCalendar(const OUString& uniqueID, const Locale& rLocale ) } } - if ( xI.is() ) - xCalendar.set(xI, UNO_QUERY); - else + if ( !xI.is() ) throw ERROR; + xCalendar.set(xI, UNO_QUERY); lookupTable.push_back( new lookupTableItem(uniqueID, xCalendar) ); } @@ -111,19 +110,17 @@ CalendarImpl::loadCalendar(const OUString& uniqueID, const Locale& rLocale ) Calendar2 SAL_CALL CalendarImpl::getLoadedCalendar2() { - if (xCalendar.is()) - return xCalendar->getLoadedCalendar2(); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + return xCalendar->getLoadedCalendar2(); } Calendar SAL_CALL CalendarImpl::getLoadedCalendar() { - if (xCalendar.is()) - return xCalendar->getLoadedCalendar(); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + return xCalendar->getLoadedCalendar(); } Sequence< OUString > SAL_CALL @@ -140,217 +137,194 @@ CalendarImpl::getAllCalendars( const Locale& rLocale ) void SAL_CALL CalendarImpl::setDateTime( double fTimeInDays ) { - if (xCalendar.is()) - xCalendar->setDateTime( fTimeInDays ); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + xCalendar->setDateTime( fTimeInDays ); } double SAL_CALL CalendarImpl::getDateTime() { - if (xCalendar.is()) - return xCalendar->getDateTime(); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + return xCalendar->getDateTime(); } void SAL_CALL CalendarImpl::setLocalDateTime( double fTimeInDays ) { - if (xCalendar.is()) - xCalendar->setLocalDateTime( fTimeInDays ); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + xCalendar->setLocalDateTime( fTimeInDays ); } double SAL_CALL CalendarImpl::getLocalDateTime() { - if (xCalendar.is()) - return xCalendar->getLocalDateTime(); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + return xCalendar->getLocalDateTime(); } OUString SAL_CALL CalendarImpl::getUniqueID() { - if (xCalendar.is()) - return xCalendar->getUniqueID(); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + return xCalendar->getUniqueID(); } void SAL_CALL CalendarImpl::setValue( sal_Int16 fieldIndex, sal_Int16 value ) { - if (xCalendar.is()) - xCalendar->setValue( fieldIndex, value ); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + xCalendar->setValue( fieldIndex, value ); } sal_Int16 SAL_CALL CalendarImpl::getValue( sal_Int16 fieldIndex ) { - if (xCalendar.is()) - return xCalendar->getValue( fieldIndex ); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + return xCalendar->getValue( fieldIndex ); } void SAL_CALL CalendarImpl::addValue( sal_Int16 fieldIndex, sal_Int32 amount ) { - if (xCalendar.is()) - xCalendar->addValue( fieldIndex, amount); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + xCalendar->addValue( fieldIndex, amount); } sal_Int16 SAL_CALL CalendarImpl::getFirstDayOfWeek() { - if (xCalendar.is()) - return xCalendar->getFirstDayOfWeek(); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + return xCalendar->getFirstDayOfWeek(); } void SAL_CALL CalendarImpl::setFirstDayOfWeek( sal_Int16 day ) { - if (xCalendar.is()) - xCalendar->setFirstDayOfWeek(day); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR ; xCalendar->setFirstDayOfWeek(day); + } void SAL_CALL CalendarImpl::setMinimumNumberOfDaysForFirstWeek( sal_Int16 days ) { - if (xCalendar.is()) - xCalendar->setMinimumNumberOfDaysForFirstWeek(days); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + xCalendar->setMinimumNumberOfDaysForFirstWeek(days); } sal_Int16 SAL_CALL CalendarImpl::getMinimumNumberOfDaysForFirstWeek() { - if (xCalendar.is()) - return xCalendar->getMinimumNumberOfDaysForFirstWeek(); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + return xCalendar->getMinimumNumberOfDaysForFirstWeek(); } OUString SAL_CALL CalendarImpl::getDisplayName( sal_Int16 displayIndex, sal_Int16 idx, sal_Int16 nameType ) { - if (xCalendar.is()) - return xCalendar->getDisplayName( displayIndex, idx, nameType ); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + return xCalendar->getDisplayName( displayIndex, idx, nameType ); } sal_Int16 SAL_CALL CalendarImpl::getNumberOfMonthsInYear() { - if (xCalendar.is()) - return xCalendar->getNumberOfMonthsInYear(); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR ; return xCalendar->getNumberOfMonthsInYear(); + } sal_Int16 SAL_CALL CalendarImpl::getNumberOfDaysInWeek() { - if (xCalendar.is()) - return xCalendar->getNumberOfDaysInWeek(); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + return xCalendar->getNumberOfDaysInWeek(); } Sequence< CalendarItem > SAL_CALL CalendarImpl::getDays() { - if (xCalendar.is()) - return xCalendar->getDays(); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + return xCalendar->getDays(); } Sequence< CalendarItem > SAL_CALL CalendarImpl::getMonths() { - if (xCalendar.is()) - return xCalendar->getMonths(); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR ; return xCalendar->getMonths(); + } Sequence< CalendarItem2 > SAL_CALL CalendarImpl::getDays2() { - if (xCalendar.is()) - return xCalendar->getDays2(); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + return xCalendar->getDays2(); } Sequence< CalendarItem2 > SAL_CALL CalendarImpl::getMonths2() { - if (xCalendar.is()) - return xCalendar->getMonths2(); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + return xCalendar->getMonths2(); } Sequence< CalendarItem2 > SAL_CALL CalendarImpl::getGenitiveMonths2() { - if (xCalendar.is()) - return xCalendar->getGenitiveMonths2(); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + return xCalendar->getGenitiveMonths2(); } Sequence< CalendarItem2 > SAL_CALL CalendarImpl::getPartitiveMonths2() { - if (xCalendar.is()) - return xCalendar->getPartitiveMonths2(); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + return xCalendar->getPartitiveMonths2(); } sal_Bool SAL_CALL CalendarImpl::isValid() { - if (xCalendar.is()) - return xCalendar->isValid(); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + return xCalendar->isValid(); } OUString SAL_CALL CalendarImpl::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) { - if (xCalendar.is()) - return xCalendar->getDisplayString(nCalendarDisplayCode, nNativeNumberMode); - else - throw ERROR ; + if (!xCalendar.is()) + throw ERROR; + return xCalendar->getDisplayString(nCalendarDisplayCode, nNativeNumberMode); } OUString SAL_CALL diff --git a/i18npool/source/collator/collatorImpl.cxx b/i18npool/source/collator/collatorImpl.cxx index 38bca648f27f..022071a9b904 100644 --- a/i18npool/source/collator/collatorImpl.cxx +++ b/i18npool/source/collator/collatorImpl.cxx @@ -88,10 +88,9 @@ CollatorImpl::loadCollatorAlgorithm(const OUString& impl, const lang::Locale& rL if (! cachedItem || ! cachedItem->equals(rLocale, impl)) loadCachedCollator(rLocale, impl); - if (cachedItem) - cachedItem->xC->loadCollatorAlgorithm(cachedItem->algorithm, nLocale = rLocale, collatorOptions); - else + if (!cachedItem) throw RuntimeException(); // impl could not be loaded + cachedItem->xC->loadCollatorAlgorithm(cachedItem->algorithm, nLocale = rLocale, collatorOptions); return 0; } diff --git a/i18npool/source/indexentry/indexentrysupplier.cxx b/i18npool/source/indexentry/indexentrysupplier.cxx index cf6b633414dc..9b6d938c987b 100644 --- a/i18npool/source/indexentry/indexentrysupplier.cxx +++ b/i18npool/source/indexentry/indexentrysupplier.cxx @@ -63,30 +63,27 @@ sal_Bool SAL_CALL IndexEntrySupplier::usePhoneticEntry( const Locale& rLocale ) OUString SAL_CALL IndexEntrySupplier::getPhoneticCandidate( const OUString& rIndexEntry, const Locale& rLocale ) { - if (getLocaleSpecificIndexEntrySupplier(rLocale, OUString()).is()) - return xIES->getPhoneticCandidate(rIndexEntry, rLocale); - else + if (!getLocaleSpecificIndexEntrySupplier(rLocale, OUString()).is()) throw RuntimeException(); + return xIES->getPhoneticCandidate(rIndexEntry, rLocale); } OUString SAL_CALL IndexEntrySupplier::getIndexKey( const OUString& rIndexEntry, const OUString& rPhoneticEntry, const Locale& rLocale ) { - if (xIES.is()) - return xIES->getIndexKey(rIndexEntry, rPhoneticEntry, rLocale); - else + if (!xIES.is()) throw RuntimeException(); + return xIES->getIndexKey(rIndexEntry, rPhoneticEntry, rLocale); } sal_Int16 SAL_CALL IndexEntrySupplier::compareIndexEntry( const OUString& rIndexEntry1, const OUString& rPhoneticEntry1, const Locale& rLocale1, const OUString& rIndexEntry2, const OUString& rPhoneticEntry2, const Locale& rLocale2 ) { - if (xIES.is()) - return xIES->compareIndexEntry(rIndexEntry1, rPhoneticEntry1, rLocale1, - rIndexEntry2, rPhoneticEntry2, rLocale2); - else + if (!xIES.is()) throw RuntimeException(); + return xIES->compareIndexEntry(rIndexEntry1, rPhoneticEntry1, rLocale1, + rIndexEntry2, rPhoneticEntry2, rLocale2); } OUString SAL_CALL IndexEntrySupplier::getIndexCharacter( const OUString& rIndexEntry, diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx index 78a37c15308a..2660f7fae5c1 100644 --- a/i18npool/source/localedata/localedata.cxx +++ b/i18npool/source/localedata/localedata.cxx @@ -633,10 +633,9 @@ Sequence< CalendarItem2 > &LocaleDataImpl::getCalendarItemByName(const OUString& // Referred locale not found, return name for en_US locale. if (index == cals.getLength()) { cals = getAllCalendars2( Locale("en", "US", OUString()) ); - if (cals.getLength() > 0) - ref_cal = cals[0]; - else + if (cals.getLength() <= 0) throw RuntimeException(); + ref_cal = cals[0]; } ref_name = name; } |