ucb/source/cacher/cachedcontentresultsetstub.cxx | 91 ++++---- ucb/source/cacher/contentresultsetwrapper.cxx | 140 ++++++------ ucb/source/core/ucb.cxx | 48 ++-- ucb/source/core/ucbcmds.cxx | 28 +- ucb/source/core/ucbstore.cxx | 20 - ucb/source/ucp/cmis/cmis_content.cxx | 250 +++++++++++------------ ucb/source/ucp/cmis/cmis_repo_content.cxx | 126 +++++------ ucb/source/ucp/ext/ucpext_content.cxx | 46 ++-- ucb/source/ucp/file/filtask.cxx | 58 ++--- ucb/source/ucp/file/prov.cxx | 30 +- ucb/source/ucp/gio/gio_content.cxx | 22 +- ucb/source/ucp/hierarchy/hierarchycontent.cxx | 40 +-- ucb/source/ucp/hierarchy/hierarchyuri.cxx | 220 ++++++++++---------- ucb/source/ucp/package/pkgcontent.cxx | 40 +-- ucb/source/ucp/tdoc/tdoc_content.cxx | 167 +++++++-------- ucb/source/ucp/tdoc/tdoc_stgelems.cxx | 172 +++++++-------- ucb/source/ucp/webdav-neon/DAVResourceAccess.cxx | 52 ++-- ucb/source/ucp/webdav-neon/DAVTypes.cxx | 22 +- ucb/source/ucp/webdav-neon/NeonSession.cxx | 66 +++--- ucb/source/ucp/webdav-neon/webdavcontent.cxx | 58 ++--- 20 files changed, 846 insertions(+), 850 deletions(-)
New commits: commit fb58fc19c0c6e3c00f94161276a4f5dbe9db9096 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Aug 3 16:00:30 2020 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Aug 3 21:54:58 2020 +0200 loplugin:flatten in ucb Change-Id: Ica7e5d3b5a5cec065f35f99d62b3b6604323601a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100009 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/ucb/source/cacher/cachedcontentresultsetstub.cxx b/ucb/source/cacher/cachedcontentresultsetstub.cxx index 9f8b94116504..cedd3d588dac 100644 --- a/ucb/source/cacher/cachedcontentresultsetstub.cxx +++ b/ucb/source/cacher/cachedcontentresultsetstub.cxx @@ -376,64 +376,63 @@ void CachedContentResultSetStub bLastDirection = m_bLastFetchDirection; bFirstPropagationDone = m_bFirstFetchSizePropagationDone; } - if( bNeedAction ) - { - if( nLastSize == nFetchSize - && bLastDirection == bFetchDirection - && bFirstPropagationDone ) - return; - - if(!bFirstPropagationDone) - { - //check whether the properties 'FetchSize' and 'FetchDirection' do exist + if( !bNeedAction ) + return; - Reference< XPropertySetInfo > xPropertySetInfo = getPropertySetInfo(); - bool bHasSize = xPropertySetInfo->hasPropertyByName( m_aPropertyNameForFetchSize ); - bool bHasDirection = xPropertySetInfo->hasPropertyByName( m_aPropertyNameForFetchDirection ); + if( nLastSize == nFetchSize + && bLastDirection == bFetchDirection + && bFirstPropagationDone ) + return; - if(!bHasSize || !bHasDirection) - { - osl::Guard< osl::Mutex > aGuard( m_aMutex ); - m_bNeedToPropagateFetchSize = false; - return; - } - } + if(!bFirstPropagationDone) + { + //check whether the properties 'FetchSize' and 'FetchDirection' do exist - bool bSetSize = ( nLastSize !=nFetchSize ) || !bFirstPropagationDone; - bool bSetDirection = ( bLastDirection !=bFetchDirection ) || !bFirstPropagationDone; + Reference< XPropertySetInfo > xPropertySetInfo = getPropertySetInfo(); + bool bHasSize = xPropertySetInfo->hasPropertyByName( m_aPropertyNameForFetchSize ); + bool bHasDirection = xPropertySetInfo->hasPropertyByName( m_aPropertyNameForFetchDirection ); + if(!bHasSize || !bHasDirection) { osl::Guard< osl::Mutex > aGuard( m_aMutex ); - m_bFirstFetchSizePropagationDone = true; - m_nLastFetchSize = nFetchSize; - m_bLastFetchDirection = bFetchDirection; + m_bNeedToPropagateFetchSize = false; + return; } + } - if( bSetSize ) - { - Any aValue; - aValue <<= nFetchSize; - try - { - setPropertyValue( m_aPropertyNameForFetchSize, aValue ); - } - catch( css::uno::Exception& ) {} - } - if( bSetDirection ) + bool bSetSize = ( nLastSize !=nFetchSize ) || !bFirstPropagationDone; + bool bSetDirection = ( bLastDirection !=bFetchDirection ) || !bFirstPropagationDone; + + { + osl::Guard< osl::Mutex > aGuard( m_aMutex ); + m_bFirstFetchSizePropagationDone = true; + m_nLastFetchSize = nFetchSize; + m_bLastFetchDirection = bFetchDirection; + } + + if( bSetSize ) + { + Any aValue; + aValue <<= nFetchSize; + try { - sal_Int32 nFetchDirection = FetchDirection::FORWARD; - if( !bFetchDirection ) - nFetchDirection = FetchDirection::REVERSE; - Any aValue; - aValue <<= nFetchDirection; - try - { - setPropertyValue( m_aPropertyNameForFetchDirection, aValue ); - } - catch( css::uno::Exception& ) {} + setPropertyValue( m_aPropertyNameForFetchSize, aValue ); } + catch( css::uno::Exception& ) {} + } + if( !bSetDirection ) + return; + sal_Int32 nFetchDirection = FetchDirection::FORWARD; + if( !bFetchDirection ) + nFetchDirection = FetchDirection::REVERSE; + Any aValue; + aValue <<= nFetchDirection; + try + { + setPropertyValue( m_aPropertyNameForFetchDirection, aValue ); } + catch( css::uno::Exception& ) {} } diff --git a/ucb/source/cacher/contentresultsetwrapper.cxx b/ucb/source/cacher/contentresultsetwrapper.cxx index d6a6cdf1727c..6699fc9df710 100644 --- a/ucb/source/cacher/contentresultsetwrapper.cxx +++ b/ucb/source/cacher/contentresultsetwrapper.cxx @@ -539,28 +539,28 @@ void SAL_CALL ContentResultSetWrapper::addPropertyChangeListener( const OUString bool bNeedRegister = !m_pPropertyChangeListeners-> getContainedTypes().hasElements(); m_pPropertyChangeListeners->addInterface( aPropertyName, xListener ); - if( bNeedRegister ) + if( !bNeedRegister ) + return; + + impl_init_xPropertySetOrigin(); { - impl_init_xPropertySetOrigin(); - { - osl::Guard< osl::Mutex > aGuard( m_aMutex ); - if( !m_xPropertySetOrigin.is() ) - { - OSL_FAIL( "broadcaster was disposed already" ); - return; - } - } - try - { - m_xPropertySetOrigin->addPropertyChangeListener( - OUString(), static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) ); - } - catch( Exception& ) + osl::Guard< osl::Mutex > aGuard( m_aMutex ); + if( !m_xPropertySetOrigin.is() ) { - m_pPropertyChangeListeners->removeInterface( aPropertyName, xListener ); - throw; + OSL_FAIL( "broadcaster was disposed already" ); + return; } } + try + { + m_xPropertySetOrigin->addPropertyChangeListener( + OUString(), static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) ); + } + catch( Exception& ) + { + m_pPropertyChangeListeners->removeInterface( aPropertyName, xListener ); + throw; + } } @@ -584,28 +584,28 @@ void SAL_CALL ContentResultSetWrapper::addVetoableChangeListener( const OUString bool bNeedRegister = !m_pVetoableChangeListeners-> getContainedTypes().hasElements(); m_pVetoableChangeListeners->addInterface( rPropertyName, xListener ); - if( bNeedRegister ) + if( !bNeedRegister ) + return; + + impl_init_xPropertySetOrigin(); { - impl_init_xPropertySetOrigin(); - { - osl::Guard< osl::Mutex > aGuard( m_aMutex ); - if( !m_xPropertySetOrigin.is() ) - { - OSL_FAIL( "broadcaster was disposed already" ); - return; - } - } - try - { - m_xPropertySetOrigin->addVetoableChangeListener( - OUString(), static_cast< XVetoableChangeListener * >( m_xMyListenerImpl.get() ) ); - } - catch( Exception& ) + osl::Guard< osl::Mutex > aGuard( m_aMutex ); + if( !m_xPropertySetOrigin.is() ) { - m_pVetoableChangeListeners->removeInterface( rPropertyName, xListener ); - throw; + OSL_FAIL( "broadcaster was disposed already" ); + return; } } + try + { + m_xPropertySetOrigin->addVetoableChangeListener( + OUString(), static_cast< XVetoableChangeListener * >( m_xMyListenerImpl.get() ) ); + } + catch( Exception& ) + { + m_pVetoableChangeListeners->removeInterface( rPropertyName, xListener ); + throw; + } } @@ -638,27 +638,27 @@ void SAL_CALL ContentResultSetWrapper::removePropertyChangeListener( const OUStr m_pPropertyChangeListeners->removeInterface( rPropertyName, xListener ); - if( !m_pPropertyChangeListeners->getContainedTypes().hasElements() ) + if( m_pPropertyChangeListeners->getContainedTypes().hasElements() ) + return; + + impl_init_xPropertySetOrigin(); { - impl_init_xPropertySetOrigin(); - { - osl::Guard< osl::Mutex > aGuard( m_aMutex ); - if( !m_xPropertySetOrigin.is() ) - { - OSL_FAIL( "broadcaster was disposed already" ); - return; - } - } - try - { - m_xPropertySetOrigin->removePropertyChangeListener( - OUString(), static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) ); - } - catch( Exception& ) + osl::Guard< osl::Mutex > aGuard( m_aMutex ); + if( !m_xPropertySetOrigin.is() ) { - OSL_FAIL( "could not remove PropertyChangeListener" ); + OSL_FAIL( "broadcaster was disposed already" ); + return; } } + try + { + m_xPropertySetOrigin->removePropertyChangeListener( + OUString(), static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) ); + } + catch( Exception& ) + { + OSL_FAIL( "could not remove PropertyChangeListener" ); + } } @@ -691,27 +691,27 @@ void SAL_CALL ContentResultSetWrapper::removeVetoableChangeListener( const OUStr m_pVetoableChangeListeners->removeInterface( rPropertyName, xListener ); - if( !m_pVetoableChangeListeners->getContainedTypes().hasElements() ) + if( m_pVetoableChangeListeners->getContainedTypes().hasElements() ) + return; + + impl_init_xPropertySetOrigin(); { - impl_init_xPropertySetOrigin(); - { - osl::Guard< osl::Mutex > aGuard( m_aMutex ); - if( !m_xPropertySetOrigin.is() ) - { - OSL_FAIL( "broadcaster was disposed already" ); - return; - } - } - try - { - m_xPropertySetOrigin->removeVetoableChangeListener( - OUString(), static_cast< XVetoableChangeListener * >( m_xMyListenerImpl.get() ) ); - } - catch( Exception& ) + osl::Guard< osl::Mutex > aGuard( m_aMutex ); + if( !m_xPropertySetOrigin.is() ) { - OSL_FAIL( "could not remove VetoableChangeListener" ); + OSL_FAIL( "broadcaster was disposed already" ); + return; } } + try + { + m_xPropertySetOrigin->removeVetoableChangeListener( + OUString(), static_cast< XVetoableChangeListener * >( m_xMyListenerImpl.get() ) ); + } + catch( Exception& ) + { + OSL_FAIL( "could not remove VetoableChangeListener" ); + } } diff --git a/ucb/source/core/ucb.cxx b/ucb/source/core/ucb.cxx index f97377e023a9..7d4a307ca334 100644 --- a/ucb/source/core/ucb.cxx +++ b/ucb/source/core/ucb.cxx @@ -665,37 +665,37 @@ void SAL_CALL UniversalContentBroker::abort( sal_Int32 ) // virtual void SAL_CALL UniversalContentBroker::changesOccurred( const util::ChangesEvent& Event ) { - if ( Event.Changes.hasElements() ) - { - uno::Reference< container::XHierarchicalNameAccess > xHierNameAccess; - Event.Base >>= xHierNameAccess; + if ( !Event.Changes.hasElements() ) + return; - OSL_ASSERT( xHierNameAccess.is() ); + uno::Reference< container::XHierarchicalNameAccess > xHierNameAccess; + Event.Base >>= xHierNameAccess; - ContentProviderDataList aData; - for ( const util::ElementChange& rElem : Event.Changes ) - { - OUString aKey; - rElem.Accessor >>= aKey; + OSL_ASSERT( xHierNameAccess.is() ); - ContentProviderData aInfo; + ContentProviderDataList aData; + for ( const util::ElementChange& rElem : Event.Changes ) + { + OUString aKey; + rElem.Accessor >>= aKey; - // Removal of UCPs from the configuration leads to changesOccurred - // notifications, too, but it is hard to tell for a given - // ElementChange whether it is an addition or a removal, so as a - // heuristic consider as removals those that cause a - // NoSuchElementException in createContentProviderData. + ContentProviderData aInfo; - // For now, removal of UCPs from the configuration is simply ignored - // (and not reflected in the UCB's data structures): - if (createContentProviderData(aKey, xHierNameAccess, aInfo)) - { - aData.push_back(aInfo); - } - } + // Removal of UCPs from the configuration leads to changesOccurred + // notifications, too, but it is hard to tell for a given + // ElementChange whether it is an addition or a removal, so as a + // heuristic consider as removals those that cause a + // NoSuchElementException in createContentProviderData. - prepareAndRegister(aData); + // For now, removal of UCPs from the configuration is simply ignored + // (and not reflected in the UCB's data structures): + if (createContentProviderData(aKey, xHierNameAccess, aInfo)) + { + aData.push_back(aInfo); + } } + + prepareAndRegister(aData); } diff --git a/ucb/source/core/ucbcmds.cxx b/ucb/source/core/ucbcmds.cxx index 41f79907a029..3eb032d2263c 100644 --- a/ucb/source/core/ucbcmds.cxx +++ b/ucb/source/core/ucbcmds.cxx @@ -1839,22 +1839,22 @@ void UniversalContentBroker::globalTransfer( // (3) Delete source, if operation is MOVE. - if ( rArg.Operation == ucb::TransferCommandOperation_MOVE ) + if ( rArg.Operation != ucb::TransferCommandOperation_MOVE ) + return; + + try { - try - { - ucb::Command aCommand( - "delete", // Name - -1, // Handle - uno::makeAny( true ) ); // Argument + ucb::Command aCommand( + "delete", // Name + -1, // Handle + uno::makeAny( true ) ); // Argument - xCommandProcessor->execute( aCommand, 0, xLocalEnv ); - } - catch ( uno::Exception const & ) - { - OSL_FAIL( "Cannot delete source object!" ); - throw; - } + xCommandProcessor->execute( aCommand, 0, xLocalEnv ); + } + catch ( uno::Exception const & ) + { + OSL_FAIL( "Cannot delete source object!" ); + throw; } } diff --git a/ucb/source/core/ucbstore.cxx b/ucb/source/core/ucbstore.cxx index 09b747879a8c..8720f3da10f6 100644 --- a/ucb/source/core/ucbstore.cxx +++ b/ucb/source/core/ucbstore.cxx @@ -568,18 +568,18 @@ void PropertySetRegistry::remove( PersistentPropertySet* pSet ) { OUString key( pSet->getKey() ); - if ( !key.isEmpty() ) - { - osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex ); + if ( key.isEmpty() ) + return; - PropertySetMap_Impl& rSets = m_pImpl->m_aPropSets; + osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex ); - PropertySetMap_Impl::iterator it = rSets.find( key ); - if ( it != rSets.end() ) - { - // Found. - rSets.erase( it ); - } + PropertySetMap_Impl& rSets = m_pImpl->m_aPropSets; + + PropertySetMap_Impl::iterator it = rSets.find( key ); + if ( it != rSets.end() ) + { + // Found. + rSets.erase( it ); } } diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx index 5a345e6fb17c..641c17f9d04c 100644 --- a/ucb/source/ucp/cmis/cmis_content.cxx +++ b/ucb/source/ucp/cmis/cmis_content.cxx @@ -1259,137 +1259,137 @@ namespace cmis } // For transient content, the URL is the one of the parent - if ( m_bTransient ) + if ( !m_bTransient ) + return; + + OUString sNewPath; + + // Try to get the object from the server if there is any + libcmis::FolderPtr pFolder; + try { - OUString sNewPath; + pFolder = boost::dynamic_pointer_cast< libcmis::Folder >( getObject( xEnv ) ); + } + catch ( const libcmis::Exception& ) + { + } - // Try to get the object from the server if there is any - libcmis::FolderPtr pFolder; - try - { - pFolder = boost::dynamic_pointer_cast< libcmis::Folder >( getObject( xEnv ) ); - } - catch ( const libcmis::Exception& ) + if ( pFolder == nullptr ) + return; + + libcmis::ObjectPtr object; + map< string, libcmis::PropertyPtr >::iterator it = m_pObjectProps.find( "cmis:name" ); + if ( it == m_pObjectProps.end( ) ) + { + ucbhelper::cancelCommandExecution( uno::makeAny + ( uno::RuntimeException( "Missing name property", + static_cast< cppu::OWeakObject * >( this ) ) ), + xEnv ); + } + string newName = it->second->getStrings( ).front( ); + string newPath = OUSTR_TO_STDSTR( m_sObjectPath ); + if ( !newPath.empty( ) && newPath[ newPath.size( ) - 1 ] != '/' ) + newPath += "/"; + newPath += newName; + try + { + if ( !m_sObjectId.isEmpty( ) ) + object = getSession( xEnv )->getObject( OUSTR_TO_STDSTR( m_sObjectId) ); + else + object = getSession( xEnv )->getObjectByPath( newPath ); + sNewPath = STD_TO_OUSTR( newPath ); + } + catch ( const libcmis::Exception& ) + { + // Nothing matched the path + } + + if ( nullptr != object.get( ) ) + { + // Are the base type matching? + if ( object->getBaseType( ) != m_pObjectType->getBaseType( )->getId() ) { + ucbhelper::cancelCommandExecution( uno::makeAny + ( uno::RuntimeException( "Can't change a folder into a document and vice-versa.", + static_cast< cppu::OWeakObject * >( this ) ) ), + xEnv ); } - if ( pFolder != nullptr ) + // Update the existing object if it's a document + libcmis::Document* document = dynamic_cast< libcmis::Document* >( object.get( ) ); + if ( nullptr != document ) { - libcmis::ObjectPtr object; - map< string, libcmis::PropertyPtr >::iterator it = m_pObjectProps.find( "cmis:name" ); - if ( it == m_pObjectProps.end( ) ) + boost::shared_ptr< ostream > pOut( new ostringstream ( ios_base::binary | ios_base::in | ios_base::out ) ); + uno::Reference < io::XOutputStream > xOutput = new StdOutputStream( pOut ); + copyData( xInputStream, xOutput ); + try + { + document->setContentStream( pOut, OUSTR_TO_STDSTR( rMimeType ), string( ), bReplaceExisting ); + } + catch ( const libcmis::Exception& ) { ucbhelper::cancelCommandExecution( uno::makeAny - ( uno::RuntimeException( "Missing name property", + ( uno::RuntimeException( "Error when setting document content", static_cast< cppu::OWeakObject * >( this ) ) ), xEnv ); } - string newName = it->second->getStrings( ).front( ); - string newPath = OUSTR_TO_STDSTR( m_sObjectPath ); - if ( !newPath.empty( ) && newPath[ newPath.size( ) - 1 ] != '/' ) - newPath += "/"; - newPath += newName; + } + } + else + { + // We need to create a brand new object... either folder or document + bool bIsFolder = getObjectType( xEnv )->getBaseType( )->getId( ) == "cmis:folder"; + setCmisProperty( "cmis:objectTypeId", getObjectType( xEnv )->getId( ), xEnv ); + + if ( bIsFolder ) + { try { - if ( !m_sObjectId.isEmpty( ) ) - object = getSession( xEnv )->getObject( OUSTR_TO_STDSTR( m_sObjectId) ); - else - object = getSession( xEnv )->getObjectByPath( newPath ); + pFolder->createFolder( m_pObjectProps ); sNewPath = STD_TO_OUSTR( newPath ); } catch ( const libcmis::Exception& ) { - // Nothing matched the path - } - - if ( nullptr != object.get( ) ) - { - // Are the base type matching? - if ( object->getBaseType( ) != m_pObjectType->getBaseType( )->getId() ) - { - ucbhelper::cancelCommandExecution( uno::makeAny - ( uno::RuntimeException( "Can't change a folder into a document and vice-versa.", - static_cast< cppu::OWeakObject * >( this ) ) ), - xEnv ); - } - - // Update the existing object if it's a document - libcmis::Document* document = dynamic_cast< libcmis::Document* >( object.get( ) ); - if ( nullptr != document ) - { - boost::shared_ptr< ostream > pOut( new ostringstream ( ios_base::binary | ios_base::in | ios_base::out ) ); - uno::Reference < io::XOutputStream > xOutput = new StdOutputStream( pOut ); - copyData( xInputStream, xOutput ); - try - { - document->setContentStream( pOut, OUSTR_TO_STDSTR( rMimeType ), string( ), bReplaceExisting ); - } - catch ( const libcmis::Exception& ) - { - ucbhelper::cancelCommandExecution( uno::makeAny - ( uno::RuntimeException( "Error when setting document content", - static_cast< cppu::OWeakObject * >( this ) ) ), - xEnv ); - } - } + ucbhelper::cancelCommandExecution( uno::makeAny + ( uno::RuntimeException( "Error when creating folder", + static_cast< cppu::OWeakObject * >( this ) ) ), + xEnv ); } - else + } + else + { + boost::shared_ptr< ostream > pOut( new ostringstream ( ios_base::binary | ios_base::in | ios_base::out ) ); + uno::Reference < io::XOutputStream > xOutput = new StdOutputStream( pOut ); + copyData( xInputStream, xOutput ); + try { - // We need to create a brand new object... either folder or document - bool bIsFolder = getObjectType( xEnv )->getBaseType( )->getId( ) == "cmis:folder"; - setCmisProperty( "cmis:objectTypeId", getObjectType( xEnv )->getId( ), xEnv ); - - if ( bIsFolder ) - { - try - { - pFolder->createFolder( m_pObjectProps ); - sNewPath = STD_TO_OUSTR( newPath ); - } - catch ( const libcmis::Exception& ) - { - ucbhelper::cancelCommandExecution( uno::makeAny - ( uno::RuntimeException( "Error when creating folder", - static_cast< cppu::OWeakObject * >( this ) ) ), - xEnv ); - } - } - else - { - boost::shared_ptr< ostream > pOut( new ostringstream ( ios_base::binary | ios_base::in | ios_base::out ) ); - uno::Reference < io::XOutputStream > xOutput = new StdOutputStream( pOut ); - copyData( xInputStream, xOutput ); - try - { - pFolder->createDocument( m_pObjectProps, pOut, OUSTR_TO_STDSTR( rMimeType ), string() ); - sNewPath = STD_TO_OUSTR( newPath ); - } - catch ( const libcmis::Exception& ) - { - ucbhelper::cancelCommandExecution( uno::makeAny - ( uno::RuntimeException( "Error when creating document", - static_cast< cppu::OWeakObject * >( this ) ) ), - xEnv ); - } - } + pFolder->createDocument( m_pObjectProps, pOut, OUSTR_TO_STDSTR( rMimeType ), string() ); + sNewPath = STD_TO_OUSTR( newPath ); } - - if ( !sNewPath.isEmpty( ) || !m_sObjectId.isEmpty( ) ) + catch ( const libcmis::Exception& ) { - // Update the current content: it's no longer transient - m_sObjectPath = sNewPath; - URL aUrl( m_sURL ); - aUrl.setObjectPath( m_sObjectPath ); - aUrl.setObjectId( m_sObjectId ); - m_sURL = aUrl.asString( ); - m_pObject.reset( ); - m_pObjectType.reset( ); - m_pObjectProps.clear( ); - m_bTransient = false; - inserted(); + ucbhelper::cancelCommandExecution( uno::makeAny + ( uno::RuntimeException( "Error when creating document", + static_cast< cppu::OWeakObject * >( this ) ) ), + xEnv ); } } } + + if ( sNewPath.isEmpty( ) && m_sObjectId.isEmpty( ) ) + return; + + // Update the current content: it's no longer transient + m_sObjectPath = sNewPath; + URL aUrl( m_sURL ); + aUrl.setObjectPath( m_sObjectPath ); + aUrl.setObjectId( m_sObjectId ); + m_sURL = aUrl.asString( ); + m_pObject.reset( ); + m_pObjectType.reset( ); + m_pObjectProps.clear( ); + m_bTransient = false; + inserted(); } const int TRANSFER_BUFFER_SIZE = 65536; @@ -2043,29 +2043,29 @@ namespace cmis void Content::setCmisProperty(const std::string& rName, const std::string& rValue, const uno::Reference< ucb::XCommandEnvironment >& xEnv ) { - if ( getObjectType( xEnv ).get( ) ) - { - map< string, libcmis::PropertyPtr >::iterator propIt = m_pObjectProps.find(rName); - vector< string > values; - values.push_back(rValue); + if ( !getObjectType( xEnv ).get( ) ) + return; - if ( propIt == m_pObjectProps.end( ) && getObjectType( xEnv ).get( ) ) - { - map< string, libcmis::PropertyTypePtr > propsTypes = getObjectType( xEnv )->getPropertiesTypes( ); - map< string, libcmis::PropertyTypePtr >::iterator typeIt = propsTypes.find(rName); + map< string, libcmis::PropertyPtr >::iterator propIt = m_pObjectProps.find(rName); + vector< string > values; + values.push_back(rValue); - if ( typeIt != propsTypes.end( ) ) - { - libcmis::PropertyTypePtr propType = typeIt->second; - libcmis::PropertyPtr property( new libcmis::Property( propType, values ) ); - m_pObjectProps.insert(pair< string, libcmis::PropertyPtr >(rName, property)); - } - } - else if ( propIt != m_pObjectProps.end( ) ) + if ( propIt == m_pObjectProps.end( ) && getObjectType( xEnv ).get( ) ) + { + map< string, libcmis::PropertyTypePtr > propsTypes = getObjectType( xEnv )->getPropertiesTypes( ); + map< string, libcmis::PropertyTypePtr >::iterator typeIt = propsTypes.find(rName); + + if ( typeIt != propsTypes.end( ) ) { - propIt->second->setValues( values ); + libcmis::PropertyTypePtr propType = typeIt->second; + libcmis::PropertyPtr property( new libcmis::Property( propType, values ) ); + m_pObjectProps.insert(pair< string, libcmis::PropertyPtr >(rName, property)); } } + else if ( propIt != m_pObjectProps.end( ) ) + { + propIt->second->setValues( values ); + } } } diff --git a/ucb/source/ucp/cmis/cmis_repo_content.cxx b/ucb/source/ucp/cmis/cmis_repo_content.cxx index ead15fb1e2f7..d98da53d5e2d 100644 --- a/ucb/source/ucp/cmis/cmis_repo_content.cxx +++ b/ucb/source/ucp/cmis/cmis_repo_content.cxx @@ -138,87 +138,87 @@ namespace cmis sProxy += ":" + OUString::number( rProxy.nPort ); libcmis::SessionFactory::setProxySettings( OUSTR_TO_STDSTR( sProxy ), std::string(), std::string(), std::string() ); - if ( m_aRepositories.empty() ) - { - // Set the SSL Validation handler - libcmis::CertValidationHandlerPtr certHandler( - new CertValidationHandler( xEnv, m_xContext, aBindingUrl.GetHost( ) ) ); - libcmis::SessionFactory::setCertificateValidationHandler( certHandler ); + if ( !m_aRepositories.empty() ) + return; + + // Set the SSL Validation handler + libcmis::CertValidationHandlerPtr certHandler( + new CertValidationHandler( xEnv, m_xContext, aBindingUrl.GetHost( ) ) ); + libcmis::SessionFactory::setCertificateValidationHandler( certHandler ); - // Get the auth credentials - AuthProvider authProvider( xEnv, m_xIdentifier->getContentIdentifier( ), m_aURL.getBindingUrl( ) ); - AuthProvider::setXEnv( xEnv ); + // Get the auth credentials + AuthProvider authProvider( xEnv, m_xIdentifier->getContentIdentifier( ), m_aURL.getBindingUrl( ) ); + AuthProvider::setXEnv( xEnv ); - std::string rUsername = OUSTR_TO_STDSTR( m_aURL.getUsername( ) ); - std::string rPassword = OUSTR_TO_STDSTR( m_aURL.getPassword( ) ); + std::string rUsername = OUSTR_TO_STDSTR( m_aURL.getUsername( ) ); + std::string rPassword = OUSTR_TO_STDSTR( m_aURL.getPassword( ) ); - bool bIsDone = false; + bool bIsDone = false; - while( !bIsDone ) + while( !bIsDone ) + { + if ( authProvider.authenticationQuery( rUsername, rPassword ) ) { - if ( authProvider.authenticationQuery( rUsername, rPassword ) ) + try { - try + // Create a session to get repositories + libcmis::OAuth2DataPtr oauth2Data; + if ( m_aURL.getBindingUrl( ) == GDRIVE_BASE_URL ) { - // Create a session to get repositories - libcmis::OAuth2DataPtr oauth2Data; - if ( m_aURL.getBindingUrl( ) == GDRIVE_BASE_URL ) - { - libcmis::SessionFactory::setOAuth2AuthCodeProvider( AuthProvider::gdriveAuthCodeFallback ); - oauth2Data.reset( new libcmis::OAuth2Data( - GDRIVE_AUTH_URL, GDRIVE_TOKEN_URL, - GDRIVE_SCOPE, GDRIVE_REDIRECT_URI, - GDRIVE_CLIENT_ID, GDRIVE_CLIENT_SECRET ) ); - } - if ( m_aURL.getBindingUrl().startsWith( ALFRESCO_CLOUD_BASE_URL ) ) - oauth2Data.reset( new libcmis::OAuth2Data( - ALFRESCO_CLOUD_AUTH_URL, ALFRESCO_CLOUD_TOKEN_URL, - ALFRESCO_CLOUD_SCOPE, ALFRESCO_CLOUD_REDIRECT_URI, - ALFRESCO_CLOUD_CLIENT_ID, ALFRESCO_CLOUD_CLIENT_SECRET ) ); - if ( m_aURL.getBindingUrl( ) == ONEDRIVE_BASE_URL ) - { - libcmis::SessionFactory::setOAuth2AuthCodeProvider( AuthProvider::onedriveAuthCodeFallback ); - oauth2Data.reset( new libcmis::OAuth2Data( - ONEDRIVE_AUTH_URL, ONEDRIVE_TOKEN_URL, - ONEDRIVE_SCOPE, ONEDRIVE_REDIRECT_URI, - ONEDRIVE_CLIENT_ID, ONEDRIVE_CLIENT_SECRET ) ); - } - - std::unique_ptr<libcmis::Session> session(libcmis::SessionFactory::createSession( - OUSTR_TO_STDSTR( m_aURL.getBindingUrl( ) ), - rUsername, rPassword, "", false, oauth2Data )); - if (!session) - ucbhelper::cancelCommandExecution( - ucb::IOErrorCode_INVALID_DEVICE, - uno::Sequence< uno::Any >( 0 ), - xEnv ); - m_aRepositories = session->getRepositories( ); - - bIsDone = true; + libcmis::SessionFactory::setOAuth2AuthCodeProvider( AuthProvider::gdriveAuthCodeFallback ); + oauth2Data.reset( new libcmis::OAuth2Data( + GDRIVE_AUTH_URL, GDRIVE_TOKEN_URL, + GDRIVE_SCOPE, GDRIVE_REDIRECT_URI, + GDRIVE_CLIENT_ID, GDRIVE_CLIENT_SECRET ) ); } - catch ( const libcmis::Exception& e ) + if ( m_aURL.getBindingUrl().startsWith( ALFRESCO_CLOUD_BASE_URL ) ) + oauth2Data.reset( new libcmis::OAuth2Data( + ALFRESCO_CLOUD_AUTH_URL, ALFRESCO_CLOUD_TOKEN_URL, + ALFRESCO_CLOUD_SCOPE, ALFRESCO_CLOUD_REDIRECT_URI, + ALFRESCO_CLOUD_CLIENT_ID, ALFRESCO_CLOUD_CLIENT_SECRET ) ); + if ( m_aURL.getBindingUrl( ) == ONEDRIVE_BASE_URL ) { - SAL_INFO( "ucb.ucp.cmis", "Error getting repositories: " << e.what() ); + libcmis::SessionFactory::setOAuth2AuthCodeProvider( AuthProvider::onedriveAuthCodeFallback ); + oauth2Data.reset( new libcmis::OAuth2Data( + ONEDRIVE_AUTH_URL, ONEDRIVE_TOKEN_URL, + ONEDRIVE_SCOPE, ONEDRIVE_REDIRECT_URI, + ONEDRIVE_CLIENT_ID, ONEDRIVE_CLIENT_SECRET ) ); + } - if ( e.getType() != "permissionDenied" ) - { - ucbhelper::cancelCommandExecution( + std::unique_ptr<libcmis::Session> session(libcmis::SessionFactory::createSession( + OUSTR_TO_STDSTR( m_aURL.getBindingUrl( ) ), + rUsername, rPassword, "", false, oauth2Data )); + if (!session) + ucbhelper::cancelCommandExecution( ucb::IOErrorCode_INVALID_DEVICE, uno::Sequence< uno::Any >( 0 ), xEnv ); - } - } + m_aRepositories = session->getRepositories( ); + + bIsDone = true; } - else + catch ( const libcmis::Exception& e ) { - // Throw user cancelled exception - ucbhelper::cancelCommandExecution( - ucb::IOErrorCode_ABORT, + SAL_INFO( "ucb.ucp.cmis", "Error getting repositories: " << e.what() ); + + if ( e.getType() != "permissionDenied" ) + { + ucbhelper::cancelCommandExecution( + ucb::IOErrorCode_INVALID_DEVICE, uno::Sequence< uno::Any >( 0 ), - xEnv, - "Authentication cancelled" ); + xEnv ); + } } } + else + { + // Throw user cancelled exception + ucbhelper::cancelCommandExecution( + ucb::IOErrorCode_ABORT, + uno::Sequence< uno::Any >( 0 ), + xEnv, + "Authentication cancelled" ); + } } } diff --git a/ucb/source/ucp/ext/ucpext_content.cxx b/ucb/source/ucp/ext/ucpext_content.cxx index 44cc30f511f0..58d0dcb31fad 100644 --- a/ucb/source/ucp/ext/ucpext_content.cxx +++ b/ucb/source/ucp/ext/ucpext_content.cxx @@ -134,19 +134,19 @@ namespace ucb::ucp::ext } } - if ( m_eExtContentType != E_ROOT ) - { - const OUString sRootURL = ContentProvider::getRootURL(); - m_sExtensionId = sURL.copy( sRootURL.getLength() ); + if ( m_eExtContentType == E_ROOT ) + return; - const sal_Int32 nNextSep = m_sExtensionId.indexOf( '/' ); - if ( nNextSep > -1 ) - { - m_sPathIntoExtension = m_sExtensionId.copy( nNextSep + 1 ); - m_sExtensionId = m_sExtensionId.copy( 0, nNextSep ); - } - m_sExtensionId = Content::decodeIdentifier( m_sExtensionId ); + const OUString sRootURL = ContentProvider::getRootURL(); + m_sExtensionId = sURL.copy( sRootURL.getLength() ); + + const sal_Int32 nNextSep = m_sExtensionId.indexOf( '/' ); + if ( nNextSep > -1 ) + { + m_sPathIntoExtension = m_sExtensionId.copy( nNextSep + 1 ); + m_sExtensionId = m_sExtensionId.copy( 0, nNextSep ); } + m_sExtensionId = Content::decodeIdentifier( m_sExtensionId ); } @@ -607,19 +607,19 @@ namespace ucb::ucp::ext return; m_aContentType = ContentProvider::getArtificialNodeContentType(); - if ( m_eExtContentType == E_EXTENSION_CONTENT ) + if ( m_eExtContentType != E_EXTENSION_CONTENT ) + return; + + try { - try - { - Sequence< Property > aProps(1); - aProps[0].Name = "ContentType"; - Reference< XRow > xRow( getPropertyValues( aProps, nullptr ), UNO_SET_THROW ); - m_aContentType = xRow->getString(1); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION("ucb.ucp.ext"); - } + Sequence< Property > aProps(1); + aProps[0].Name = "ContentType"; + Reference< XRow > xRow( getPropertyValues( aProps, nullptr ), UNO_SET_THROW ); + m_aContentType = xRow->getString(1); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("ucb.ucp.ext"); } } diff --git a/ucb/source/ucp/file/filtask.cxx b/ucb/source/ucp/file/filtask.cxx index 658b47e2a9ed..b515cc11a72e 100644 --- a/ucb/source/ucp/file/filtask.cxx +++ b/ucb/source/ucp/file/filtask.cxx @@ -2194,44 +2194,42 @@ TaskManager::getMaskFromProperties( void TaskManager::load( const ContentMap::iterator& it, bool create ) { - if( ( ! it->second.xS.is() || - ! it->second.xC.is() || - ! it->second.xA.is() ) - && m_xFileRegistry.is() ) - { + if( ( it->second.xS.is() && it->second.xC.is() && it->second.xA.is() ) + || !m_xFileRegistry.is() ) + return; - uno::Reference< ucb::XPersistentPropertySet > xS = m_xFileRegistry->openPropertySet( it->first,create ); - if( xS.is() ) - { - uno::Reference< beans::XPropertyContainer > xC( xS,uno::UNO_QUERY ); - uno::Reference< beans::XPropertyAccess > xA( xS,uno::UNO_QUERY ); - it->second.xS = xS; - it->second.xC = xC; - it->second.xA = xA; + uno::Reference< ucb::XPersistentPropertySet > xS = m_xFileRegistry->openPropertySet( it->first,create ); + if( xS.is() ) + { + uno::Reference< beans::XPropertyContainer > xC( xS,uno::UNO_QUERY ); + uno::Reference< beans::XPropertyAccess > xA( xS,uno::UNO_QUERY ); - // Now put in all values in the storage in the local hash; + it->second.xS = xS; + it->second.xC = xC; + it->second.xA = xA; - PropertySet& properties = it->second.properties; - const uno::Sequence< beans::Property > seq = xS->getPropertySetInfo()->getProperties(); + // Now put in all values in the storage in the local hash; - for( const auto& rProp : seq ) - { - MyProperty readProp( false, - rProp.Name, - rProp.Handle, - rProp.Type, - xS->getPropertyValue( rProp.Name ), - beans::PropertyState_DIRECT_VALUE, - rProp.Attributes ); - properties.insert( readProp ); - } - } - else if( create ) + PropertySet& properties = it->second.properties; + const uno::Sequence< beans::Property > seq = xS->getPropertySetInfo()->getProperties(); + + for( const auto& rProp : seq ) { - // Catastrophic error + MyProperty readProp( false, + rProp.Name, + rProp.Handle, + rProp.Type, + xS->getPropertyValue( rProp.Name ), + beans::PropertyState_DIRECT_VALUE, + rProp.Attributes ); + properties.insert( readProp ); } } + else if( create ) + { + // Catastrophic error + } } diff --git a/ucb/source/ucp/file/prov.cxx b/ucb/source/ucp/file/prov.cxx index 6cf0ace2daf2..1577488df3e4 100644 --- a/ucb/source/ucp/file/prov.cxx +++ b/ucb/source/ucp/file/prov.cxx @@ -309,28 +309,28 @@ XPropertySetInfoImpl2::hasPropertyByName( void FileProvider::initProperties() { osl::MutexGuard aGuard( m_aMutex ); - if( ! m_xPropertySetInfo.is() ) - { - osl_getLocalHostname( &m_HostName.pData ); + if( m_xPropertySetInfo.is() ) + return; + + osl_getLocalHostname( &m_HostName.pData ); #if defined ( UNX ) - m_FileSystemNotation = FileSystemNotation::UNIX_NOTATION; + m_FileSystemNotation = FileSystemNotation::UNIX_NOTATION; #elif defined( _WIN32 ) - m_FileSystemNotation = FileSystemNotation::DOS_NOTATION; + m_FileSystemNotation = FileSystemNotation::DOS_NOTATION; #else - m_FileSystemNotation = FileSystemNotation::UNKNOWN_NOTATION; + m_FileSystemNotation = FileSystemNotation::UNKNOWN_NOTATION; #endif - osl::Security aSecurity; - aSecurity.getHomeDir( m_HomeDirectory ); + osl::Security aSecurity; + aSecurity.getHomeDir( m_HomeDirectory ); - // static const sal_Int32 UNKNOWN_NOTATION = (sal_Int32)0; - // static const sal_Int32 UNIX_NOTATION = (sal_Int32)1; - // static const sal_Int32 DOS_NOTATION = (sal_Int32)2; - // static const sal_Int32 MAC_NOTATION = (sal_Int32)3; + // static const sal_Int32 UNKNOWN_NOTATION = (sal_Int32)0; + // static const sal_Int32 UNIX_NOTATION = (sal_Int32)1; + // static const sal_Int32 DOS_NOTATION = (sal_Int32)2; + // static const sal_Int32 MAC_NOTATION = (sal_Int32)3; - XPropertySetInfoImpl2* p = new XPropertySetInfoImpl2(); - m_xPropertySetInfo.set( p ); - } + XPropertySetInfoImpl2* p = new XPropertySetInfoImpl2(); + m_xPropertySetInfo.set( p ); } diff --git a/ucb/source/ucp/gio/gio_content.cxx b/ucb/source/ucp/gio/gio_content.cxx index 8576713974a8..87c50d498fc5 100644 --- a/ucb/source/ucp/gio/gio_content.cxx +++ b/ucb/source/ucp/gio/gio_content.cxx @@ -639,18 +639,18 @@ void Content::getFileInfo( css::uno::Reference<css::ucb::XCommandEnvironment> const & env, GFileInfo ** info, bool fail) { assert(info != nullptr); - if (*info == nullptr) + if (*info != nullptr) + return; + + GError * err = nullptr; + *info = getGFileInfo(env, &err); + if (*info == nullptr && !mbTransient && fail) { - GError * err = nullptr; - *info = getGFileInfo(env, &err); - if (*info == nullptr && !mbTransient && fail) - { - ucbhelper::cancelCommandExecution(mapGIOError(err), env); - } - else if (err != nullptr) - { - g_error_free(err); - } + ucbhelper::cancelCommandExecution(mapGIOError(err), env); + } + else if (err != nullptr) + { + g_error_free(err); } } diff --git a/ucb/source/ucp/hierarchy/hierarchycontent.cxx b/ucb/source/ucp/hierarchy/hierarchycontent.cxx index 707f0e31a1f7..6228f2bd9e07 100644 --- a/ucb/source/ucp/hierarchy/hierarchycontent.cxx +++ b/ucb/source/ucp/hierarchy/hierarchycontent.cxx @@ -1701,29 +1701,29 @@ void HierarchyContent::transfer( // 5) Destroy source ( when moving only ) . - if ( rInfo.MoveData ) - { - xSource->destroy( true, xEnv ); + if ( !rInfo.MoveData ) + return; - // Remove all persistent data of source and its children. - if ( !xSource->removeData() ) - { - uno::Sequence<uno::Any> aArgs(comphelper::InitAnyPropertySequence( - { - {"Uri", uno::Any(xSource->m_xIdentifier->getContentIdentifier())} - })); - ucbhelper::cancelCommandExecution( - ucb::IOErrorCode_CANT_WRITE, - aArgs, - xEnv, - "Cannot remove persistent data of source object!", - this ); - // Unreachable - } + xSource->destroy( true, xEnv ); - // Remove own and all children's Additional Core Properties. - xSource->removeAdditionalPropertySet(); + // Remove all persistent data of source and its children. + if ( !xSource->removeData() ) + { + uno::Sequence<uno::Any> aArgs(comphelper::InitAnyPropertySequence( + { + {"Uri", uno::Any(xSource->m_xIdentifier->getContentIdentifier())} + })); + ucbhelper::cancelCommandExecution( + ucb::IOErrorCode_CANT_WRITE, + aArgs, + xEnv, + "Cannot remove persistent data of source object!", + this ); + // Unreachable } + + // Remove own and all children's Additional Core Properties. + xSource->removeAdditionalPropertySet(); } diff --git a/ucb/source/ucp/hierarchy/hierarchyuri.cxx b/ucb/source/ucp/hierarchy/hierarchyuri.cxx index 8cb26e0f70b1..d936b810a3ab 100644 --- a/ucb/source/ucp/hierarchy/hierarchyuri.cxx +++ b/ucb/source/ucp/hierarchy/hierarchyuri.cxx @@ -40,139 +40,139 @@ using namespace hierarchy_ucp; void HierarchyUri::init() const { // Already inited? - if ( !m_aUri.isEmpty() && m_aPath.isEmpty() ) + if ( m_aUri.isEmpty() || !m_aPath.isEmpty() ) + return; + + // Note: Maybe it's a re-init, setUri only resets m_aPath! + m_aService.clear(); + m_aParentUri.clear(); + + // URI must match at least: <scheme>: + if ( m_aUri.getLength() < HIERARCHY_URL_SCHEME_LENGTH + 1 ) + { + // error, but remember that we did an init(). + m_aPath = "/"; + return; + } + + // Scheme is case insensitive. + OUString aScheme + = m_aUri.copy( 0, HIERARCHY_URL_SCHEME_LENGTH ).toAsciiLowerCase(); + if ( aScheme == HIERARCHY_URL_SCHEME ) { - // Note: Maybe it's a re-init, setUri only resets m_aPath! - m_aService.clear(); - m_aParentUri.clear(); + m_aUri = m_aUri.replaceAt( 0, aScheme.getLength(), aScheme ); + + sal_Int32 nPos = 0; - // URI must match at least: <scheme>: - if ( m_aUri.getLength() < HIERARCHY_URL_SCHEME_LENGTH + 1 ) + // If the URI has no service specifier, insert default service. + // This is for backward compatibility and for convenience. + + if ( m_aUri.getLength() == HIERARCHY_URL_SCHEME_LENGTH + 1 ) { - // error, but remember that we did an init(). - m_aPath = "/"; - return; - } + // root folder URI without path and service specifier. + m_aUri += "//" DEFAULT_DATA_SOURCE_SERVICE "/"; + m_aService = DEFAULT_DATA_SOURCE_SERVICE ; - // Scheme is case insensitive. - OUString aScheme - = m_aUri.copy( 0, HIERARCHY_URL_SCHEME_LENGTH ).toAsciiLowerCase(); - if ( aScheme == HIERARCHY_URL_SCHEME ) + nPos = m_aUri.getLength() - 1; + } + else if ( ( m_aUri.getLength() == HIERARCHY_URL_SCHEME_LENGTH + 2 ) + && + ( m_aUri[ HIERARCHY_URL_SCHEME_LENGTH + 1 ] == '/' ) ) { - m_aUri = m_aUri.replaceAt( 0, aScheme.getLength(), aScheme ); + // root folder URI without service specifier. + m_aUri += "/" DEFAULT_DATA_SOURCE_SERVICE "/"; + m_aService = DEFAULT_DATA_SOURCE_SERVICE; - sal_Int32 nPos = 0; + nPos = m_aUri.getLength() - 1; + } + else if ( ( m_aUri.getLength() > HIERARCHY_URL_SCHEME_LENGTH + 2 ) + && + ( m_aUri[ HIERARCHY_URL_SCHEME_LENGTH + 2 ] != '/' ) ) + { + // other (no root folder) URI without service specifier. + m_aUri = m_aUri.replaceAt( + HIERARCHY_URL_SCHEME_LENGTH + 2, + 0, + "/" DEFAULT_DATA_SOURCE_SERVICE "/" ); + m_aService = DEFAULT_DATA_SOURCE_SERVICE; + + nPos + = HIERARCHY_URL_SCHEME_LENGTH + 3 + m_aService.getLength(); + } + else + { + // URI with service specifier. + sal_Int32 nStart = HIERARCHY_URL_SCHEME_LENGTH + 3; - // If the URI has no service specifier, insert default service. - // This is for backward compatibility and for convenience. + // Here: - m_aUri has at least the form "<scheme>://" + // - nStart points to char after <scheme>: - if ( m_aUri.getLength() == HIERARCHY_URL_SCHEME_LENGTH + 1 ) + // Only <scheme>:// ? + if ( nStart == m_aUri.getLength() ) { - // root folder URI without path and service specifier. - m_aUri += "//" DEFAULT_DATA_SOURCE_SERVICE "/"; - m_aService = DEFAULT_DATA_SOURCE_SERVICE ; - - nPos = m_aUri.getLength() - 1; + // error, but remember that we did an init(). + m_aPath = "/"; + return; } - else if ( ( m_aUri.getLength() == HIERARCHY_URL_SCHEME_LENGTH + 2 ) - && - ( m_aUri[ HIERARCHY_URL_SCHEME_LENGTH + 1 ] == '/' ) ) - { - // root folder URI without service specifier. - m_aUri += "/" DEFAULT_DATA_SOURCE_SERVICE "/"; - m_aService = DEFAULT_DATA_SOURCE_SERVICE; - nPos = m_aUri.getLength() - 1; + // Empty path segments? + if ( m_aUri.indexOf("//", nStart) != -1 ) + { + // error, but remember that we did an init(). + m_aPath = "/"; + return; } - else if ( ( m_aUri.getLength() > HIERARCHY_URL_SCHEME_LENGTH + 2 ) - && - ( m_aUri[ HIERARCHY_URL_SCHEME_LENGTH + 2 ] != '/' ) ) + + sal_Int32 nEnd = m_aUri.indexOf( '/', nStart ); + + // Only <scheme>:/// ? + if ( nEnd == nStart ) { - // other (no root folder) URI without service specifier. - m_aUri = m_aUri.replaceAt( - HIERARCHY_URL_SCHEME_LENGTH + 2, - 0, - "/" DEFAULT_DATA_SOURCE_SERVICE "/" ); - m_aService = DEFAULT_DATA_SOURCE_SERVICE; - - nPos - = HIERARCHY_URL_SCHEME_LENGTH + 3 + m_aService.getLength(); + // error, but remember that we did an init(). + m_aPath = "/"; + return; } - else + + if ( nEnd == -1 ) { - // URI with service specifier. - sal_Int32 nStart = HIERARCHY_URL_SCHEME_LENGTH + 3; - - // Here: - m_aUri has at least the form "<scheme>://" - // - nStart points to char after <scheme>: - - // Only <scheme>:// ? - if ( nStart == m_aUri.getLength() ) - { - // error, but remember that we did an init(). - m_aPath = "/"; - return; - } - - // Empty path segments? - if ( m_aUri.indexOf("//", nStart) != -1 ) - { - // error, but remember that we did an init(). - m_aPath = "/"; - return; - } - - sal_Int32 nEnd = m_aUri.indexOf( '/', nStart ); - - // Only <scheme>:/// ? - if ( nEnd == nStart ) - { - // error, but remember that we did an init(). - m_aPath = "/"; - return; - } - - if ( nEnd == -1 ) - { - // Trailing slash missing. - nEnd = m_aUri.getLength(); - m_aUri += "/"; - } - - m_aService = m_aUri.copy( nStart, nEnd - nStart ); - - nPos = nEnd; + // Trailing slash missing. + nEnd = m_aUri.getLength(); + m_aUri += "/"; } - // Here: - m_aUri has at least the form "<scheme>://<service>/" - // - m_aService was set - // - m_aPath, m_aParentPath, m_aName not yet set - // - nPos points to slash after service specifier + m_aService = m_aUri.copy( nStart, nEnd - nStart ); - // Remove trailing slash, if not a root folder URI. - sal_Int32 nEnd = m_aUri.lastIndexOf( '/' ); - if ( ( nEnd > nPos ) && ( nEnd == ( m_aUri.getLength() - 1 ) ) ) - m_aUri = m_aUri.copy( 0, nEnd ); + nPos = nEnd; + } - // Path (includes leading slash) - m_aPath = m_aUri.copy( nPos ); + // Here: - m_aUri has at least the form "<scheme>://<service>/" + // - m_aService was set + // - m_aPath, m_aParentPath, m_aName not yet set + // - nPos points to slash after service specifier - // parent URI + name - sal_Int32 nLastSlash = m_aUri.lastIndexOf( '/' ); - if ( ( nLastSlash != -1 ) && - ( nLastSlash != m_aUri.getLength() - 1 ) ) // root - { - m_aParentUri = m_aUri.copy( 0, nLastSlash ); - } + // Remove trailing slash, if not a root folder URI. + sal_Int32 nEnd = m_aUri.lastIndexOf( '/' ); + if ( ( nEnd > nPos ) && ( nEnd == ( m_aUri.getLength() - 1 ) ) ) + m_aUri = m_aUri.copy( 0, nEnd ); - // success - m_bValid = true; - } - else + // Path (includes leading slash) + m_aPath = m_aUri.copy( nPos ); + + // parent URI + name + sal_Int32 nLastSlash = m_aUri.lastIndexOf( '/' ); + if ( ( nLastSlash != -1 ) && + ( nLastSlash != m_aUri.getLength() - 1 ) ) // root { - // error, but remember that we did an init(). - m_aPath = "/"; + m_aParentUri = m_aUri.copy( 0, nLastSlash ); } + + // success + m_bValid = true; + } + else + { + // error, but remember that we did an init(). + m_aPath = "/"; } } diff --git a/ucb/source/ucp/package/pkgcontent.cxx b/ucb/source/ucp/package/pkgcontent.cxx index 19f2017716bb..127c1cfb63e7 100644 --- a/ucb/source/ucp/package/pkgcontent.cxx +++ b/ucb/source/ucp/package/pkgcontent.cxx @@ -1909,29 +1909,29 @@ void Content::transfer( // 5) Destroy source ( when moving only ) . - if ( rInfo.MoveData ) - { - xSource->destroy( true, xEnv ); + if ( !rInfo.MoveData ) + return; - // Remove all persistent data of source and its children. - if ( !xSource->removeData() ) - { - uno::Sequence<uno::Any> aArgs(comphelper::InitAnyPropertySequence( - { - {"Uri", uno::Any(xSource->m_xIdentifier->getContentIdentifier())} - })); - ucbhelper::cancelCommandExecution( - ucb::IOErrorCode_CANT_WRITE, - aArgs, - xEnv, - "Cannot remove persistent data of source object!", - this ); - // Unreachable - } + xSource->destroy( true, xEnv ); - // Remove own and all children's Additional Core Properties. - xSource->removeAdditionalPropertySet(); + // Remove all persistent data of source and its children. + if ( !xSource->removeData() ) + { + uno::Sequence<uno::Any> aArgs(comphelper::InitAnyPropertySequence( + { + {"Uri", uno::Any(xSource->m_xIdentifier->getContentIdentifier())} + })); + ucbhelper::cancelCommandExecution( + ucb::IOErrorCode_CANT_WRITE, + aArgs, + xEnv, + "Cannot remove persistent data of source object!", + this ); + // Unreachable } + + // Remove own and all children's Additional Core Properties. + xSource->removeAdditionalPropertySet(); } diff --git a/ucb/source/ucp/tdoc/tdoc_content.cxx b/ucb/source/ucp/tdoc/tdoc_content.cxx index fa7aa636d21a..089aaa8275ae 100644 --- a/ucb/source/ucp/tdoc/tdoc_content.cxx +++ b/ucb/source/ucp/tdoc/tdoc_content.cxx @@ -1749,19 +1749,19 @@ void Content::notifyChildRemoved( const OUString & rRelativeChildUri ) uno::Reference< ucb::XContent > xChild = queryChildContent( rRelativeChildUri ); - if ( xChild.is() ) - { - // callback follows! - aGuard.clear(); + if ( !xChild.is() ) + return; - // Notify "REMOVED" event. - ucb::ContentEvent aEvt( - static_cast< cppu::OWeakObject * >( this ), - ucb::ContentAction::REMOVED, - xChild, - getIdentifier() ); - notifyContentEvent( aEvt ); - } + // callback follows! + aGuard.clear(); + + // Notify "REMOVED" event. + ucb::ContentEvent aEvt( + static_cast< cppu::OWeakObject * >( this ), + ucb::ContentAction::REMOVED, + xChild, + getIdentifier() ); + notifyContentEvent( aEvt ); } @@ -1773,19 +1773,19 @@ void Content::notifyChildInserted( const OUString & rRelativeChildUri ) uno::Reference< ucb::XContent > xChild = queryChildContent( rRelativeChildUri ); - if ( xChild.is() ) - { - // callback follows! - aGuard.clear(); + if ( !xChild.is() ) + return; - // Notify "INSERTED" event. - ucb::ContentEvent aEvt( - static_cast< cppu::OWeakObject * >( this ), - ucb::ContentAction::INSERTED, - xChild, - getIdentifier() ); - notifyContentEvent( aEvt ); - } + // callback follows! + aGuard.clear(); + + // Notify "INSERTED" event. + ucb::ContentEvent aEvt( + static_cast< cppu::OWeakObject * >( this ), + ucb::ContentAction::INSERTED, + xChild, + getIdentifier() ); + notifyContentEvent( aEvt ); } @@ -2030,75 +2030,74 @@ void Content::transfer( // Remove source, if requested - if ( rInfo.MoveData ) + if ( !rInfo.MoveData ) + return; + + rtl::Reference< Content > xSource; + try { - rtl::Reference< Content > xSource; - try - { - uno::Reference< ucb::XContentIdentifier > - xSourceId = new ::ucbhelper::ContentIdentifier( rInfo.SourceURL ); + uno::Reference< ucb::XContentIdentifier > + xSourceId = new ::ucbhelper::ContentIdentifier( rInfo.SourceURL ); - // Note: The static cast is okay here, because its sure - // that m_xProvider is always the ContentProvider. - xSource = static_cast< Content * >( - m_xProvider->queryContent( xSourceId ).get() ); - } - catch ( ucb::IllegalIdentifierException const & ) - { - // queryContent - } + // Note: The static cast is okay here, because its sure + // that m_xProvider is always the ContentProvider. + xSource = static_cast< Content * >( + m_xProvider->queryContent( xSourceId ).get() ); + } + catch ( ucb::IllegalIdentifierException const & ) + { + // queryContent + } - if ( !xSource.is() ) + if ( !xSource.is() ) + { + uno::Sequence<uno::Any> aArgs(comphelper::InitAnyPropertySequence( { - uno::Sequence<uno::Any> aArgs(comphelper::InitAnyPropertySequence( - { - {"Uri", uno::Any(rInfo.SourceURL)} - })); - ucbhelper::cancelCommandExecution( - ucb::IOErrorCode_CANT_READ, - aArgs, - xEnv, - "Cannot instantiate target object!", - this ); - // Unreachable - } + {"Uri", uno::Any(rInfo.SourceURL)} + })); + ucbhelper::cancelCommandExecution( + ucb::IOErrorCode_CANT_READ, + aArgs, + xEnv, + "Cannot instantiate target object!", + this ); + // Unreachable + } - // Propagate destruction (recursively). - xSource->destroy( true, xEnv ); + // Propagate destruction (recursively). + xSource->destroy( true, xEnv ); - // Remove all persistent data of source and its children. - if ( !xSource->removeData() ) + // Remove all persistent data of source and its children. + if ( !xSource->removeData() ) + { + uno::Sequence<uno::Any> aArgs(comphelper::InitAnyPropertySequence( { - uno::Sequence<uno::Any> aArgs(comphelper::InitAnyPropertySequence( - { - {"Uri", uno::Any(rInfo.SourceURL)} - })); - ucbhelper::cancelCommandExecution( - ucb::IOErrorCode_CANT_WRITE, - aArgs, - xEnv, - "Cannot remove persistent data of source object!", - this ); - // Unreachable - } + {"Uri", uno::Any(rInfo.SourceURL)} + })); + ucbhelper::cancelCommandExecution( + ucb::IOErrorCode_CANT_WRITE, + aArgs, + xEnv, + "Cannot remove persistent data of source object!", + this ); + // Unreachable + } - // Remove own and all children's Additional Core Properties. - if ( !xSource->removeAdditionalPropertySet() ) - { - uno::Sequence<uno::Any> aArgs(comphelper::InitAnyPropertySequence( - { - {"Uri", uno::Any(rInfo.SourceURL)} - })); - ucbhelper::cancelCommandExecution( - ucb::IOErrorCode_CANT_WRITE, - aArgs, - xEnv, - "Cannot remove additional properties of source object!", - this ); - // Unreachable - } + // Remove own and all children's Additional Core Properties. + if ( xSource->removeAdditionalPropertySet() ) + return; - } // rInfo.MoveData + uno::Sequence<uno::Any> aArgs(comphelper::InitAnyPropertySequence( + { + {"Uri", uno::Any(rInfo.SourceURL)} + })); + ucbhelper::cancelCommandExecution( + ucb::IOErrorCode_CANT_WRITE, + aArgs, + xEnv, + "Cannot remove additional properties of source object!", + this ); + // Unreachable } diff --git a/ucb/source/ucp/tdoc/tdoc_stgelems.cxx b/ucb/source/ucp/tdoc/tdoc_stgelems.cxx index 57052d55433c..96748056b166 100644 --- a/ucb/source/ucp/tdoc/tdoc_stgelems.cxx +++ b/ucb/source/ucp/tdoc/tdoc_stgelems.cxx @@ -94,21 +94,21 @@ Storage::Storage( const uno::Reference< uno::XComponentContext > & rxContext, OSL_ENSURE( m_xAggProxy.is(), "Storage::Storage: Wrapped storage cannot be aggregated!" ); - if ( m_xAggProxy.is() ) + if ( !m_xAggProxy.is() ) + return; + + osl_atomic_increment( &m_refCount ); { - osl_atomic_increment( &m_refCount ); - { - // Solaris compiler problem: - // Extra block to enforce destruction of temporary object created - // in next statement _before_ osl_atomic_decrement is - // called. Otherwise 'this' will destroy itself even before ctor - // is completed (See impl. of XInterface::release())! - - m_xAggProxy->setDelegator( - static_cast< cppu::OWeakObject * >( this ) ); - } - osl_atomic_decrement( &m_refCount ); + // Solaris compiler problem: + // Extra block to enforce destruction of temporary object created + // in next statement _before_ osl_atomic_decrement is + // called. Otherwise 'this' will destroy itself even before ctor + // is completed (See impl. of XInterface::release())! + + m_xAggProxy->setDelegator( + static_cast< cppu::OWeakObject * >( this ) ); } + osl_atomic_decrement( &m_refCount ); } @@ -119,24 +119,24 @@ Storage::~Storage() m_xAggProxy->setDelegator( uno::Reference< uno::XInterface >() ); // Never dispose a document storage. Not owner! - if ( !m_bIsDocumentStorage ) + if ( m_bIsDocumentStorage ) + return; + + if ( !m_xWrappedComponent.is() ) + return; + + // "Auto-dispose"... + try { - if ( m_xWrappedComponent.is() ) - { - // "Auto-dispose"... - try - { - m_xWrappedComponent->dispose(); - } - catch ( lang::DisposedException const & ) - { - // might happen. - } - catch ( ... ) - { - OSL_FAIL( "Storage::~Storage - Caught exception!" ); - } - } + m_xWrappedComponent->dispose(); + } + catch ( lang::DisposedException const & ) + { + // might happen. + } + catch ( ... ) + { + OSL_FAIL( "Storage::~Storage - Caught exception!" ); } } @@ -399,24 +399,24 @@ void SAL_CALL Storage::commit() // Would lead in writing the whole document to disk. uno::Reference< embed::XStorage > xParentStorage = getParentStorage(); - if ( xParentStorage.is() ) - { - OSL_ENSURE( m_xWrappedTransObj.is(), "No XTransactedObject interface!" ); + if ( !xParentStorage.is() ) + return; - if ( m_xWrappedTransObj.is() ) - { - m_xWrappedTransObj->commit(); + OSL_ENSURE( m_xWrappedTransObj.is(), "No XTransactedObject interface!" ); - if ( !isParentARootStorage() ) - { - uno::Reference< embed::XTransactedObject > xParentTA( - xParentStorage, uno::UNO_QUERY ); - OSL_ENSURE( xParentTA.is(), "No XTransactedObject interface!" ); + if ( !m_xWrappedTransObj.is() ) + return; - if ( xParentTA.is() ) - xParentTA->commit(); - } - } + m_xWrappedTransObj->commit(); + + if ( !isParentARootStorage() ) + { + uno::Reference< embed::XTransactedObject > xParentTA( + xParentStorage, uno::UNO_QUERY ); + OSL_ENSURE( xParentTA.is(), "No XTransactedObject interface!" ); + + if ( xParentTA.is() ) + xParentTA->commit(); } } @@ -425,24 +425,24 @@ void SAL_CALL Storage::commit() void SAL_CALL Storage::revert() { uno::Reference< embed::XStorage > xParentStorage = getParentStorage(); - if ( xParentStorage.is() ) - { - OSL_ENSURE( m_xWrappedTransObj.is(), "No XTransactedObject interface!" ); + if ( !xParentStorage.is() ) + return; - if ( m_xWrappedTransObj.is() ) - { - m_xWrappedTransObj->revert(); + OSL_ENSURE( m_xWrappedTransObj.is(), "No XTransactedObject interface!" ); - if ( !isParentARootStorage() ) - { - uno::Reference< embed::XTransactedObject > xParentTA( - xParentStorage, uno::UNO_QUERY ); - OSL_ENSURE( xParentTA.is(), "No XTransactedObject interface!" ); + if ( !m_xWrappedTransObj.is() ) + return; - if ( xParentTA.is() ) - xParentTA->revert(); - } - } + m_xWrappedTransObj->revert(); + + if ( !isParentARootStorage() ) + { + uno::Reference< embed::XTransactedObject > xParentTA( + xParentStorage, uno::UNO_QUERY ); + OSL_ENSURE( xParentTA.is(), "No XTransactedObject interface!" ); + + if ( xParentTA.is() ) + xParentTA->revert(); } } @@ -484,21 +484,21 @@ OutputStream::OutputStream( OSL_ENSURE( m_xAggProxy.is(), "OutputStream::OutputStream: Wrapped stream cannot be aggregated!" ); - if ( m_xAggProxy.is() ) + if ( !m_xAggProxy.is() ) + return; + + osl_atomic_increment( &m_refCount ); { - osl_atomic_increment( &m_refCount ); - { - // Solaris compiler problem: - // Extra block to enforce destruction of temporary object created - // in next statement _before_ osl_atomic_decrement is - // called. Otherwise 'this' will destroy itself even before ctor - // is completed (See impl. of XInterface::release())! - - m_xAggProxy->setDelegator( - static_cast< cppu::OWeakObject * >( this ) ); - } - osl_atomic_decrement( &m_refCount ); + // Solaris compiler problem: + // Extra block to enforce destruction of temporary object created + // in next statement _before_ osl_atomic_decrement is + // called. Otherwise 'this' will destroy itself even before ctor + // is completed (See impl. of XInterface::release())! + + m_xAggProxy->setDelegator( + static_cast< cppu::OWeakObject * >( this ) ); } + osl_atomic_decrement( &m_refCount ); } @@ -649,21 +649,21 @@ Stream::Stream( OSL_ENSURE( m_xAggProxy.is(), "OutputStream::OutputStream: Wrapped stream cannot be aggregated!" ); - if ( m_xAggProxy.is() ) + if ( !m_xAggProxy.is() ) + return; + + osl_atomic_increment( &m_refCount ); { - osl_atomic_increment( &m_refCount ); - { - // Solaris compiler problem: - // Extra block to enforce destruction of temporary object created - // in next statement _before_ osl_atomic_decrement is - // called. Otherwise 'this' will destroy itself even before ctor - // is completed (See impl. of XInterface::release())! - - m_xAggProxy->setDelegator( - static_cast< cppu::OWeakObject * >( this ) ); - } - osl_atomic_decrement( &m_refCount ); + // Solaris compiler problem: + // Extra block to enforce destruction of temporary object created + // in next statement _before_ osl_atomic_decrement is + // called. Otherwise 'this' will destroy itself even before ctor + // is completed (See impl. of XInterface::release())! + + m_xAggProxy->setDelegator( + static_cast< cppu::OWeakObject * >( this ) ); } + osl_atomic_decrement( &m_refCount ); } diff --git a/ucb/source/ucp/webdav-neon/DAVResourceAccess.cxx b/ucb/source/ucp/webdav-neon/DAVResourceAccess.cxx index 436f26dd93cf..97205dd14a81 100644 --- a/ucb/source/ucp/webdav-neon/DAVResourceAccess.cxx +++ b/ucb/source/ucp/webdav-neon/DAVResourceAccess.cxx @@ -1018,40 +1018,40 @@ void DAVResourceAccess::setURL( const OUString & rNewURL ) void DAVResourceAccess::initialize() { osl::Guard< osl::Mutex > aGuard( m_aMutex ); - if ( m_aPath.isEmpty() ) - { - NeonUri aURI( m_aURL ); - const OUString& aPath( aURI.GetPath() ); + if ( !m_aPath.isEmpty() ) + return; - /* #134089# - Check URI */ - if ( aPath.isEmpty() ) - throw DAVException( DAVException::DAV_INVALID_ARG ); + NeonUri aURI( m_aURL ); + const OUString& aPath( aURI.GetPath() ); - /* #134089# - Check URI */ - if ( aURI.GetHost().isEmpty() ) - throw DAVException( DAVException::DAV_INVALID_ARG ); + /* #134089# - Check URI */ + if ( aPath.isEmpty() ) + throw DAVException( DAVException::DAV_INVALID_ARG ); - if ( !m_xSession.is() || !m_xSession->CanUse( m_aURL, m_aFlags ) ) - { - m_xSession.clear(); + /* #134089# - Check URI */ + if ( aURI.GetHost().isEmpty() ) + throw DAVException( DAVException::DAV_INVALID_ARG ); - // create new webdav session - m_xSession - = m_xSessionFactory->createDAVSession( m_aURL, m_aFlags, m_xContext ); + if ( !m_xSession.is() || !m_xSession->CanUse( m_aURL, m_aFlags ) ) + { + m_xSession.clear(); - if ( !m_xSession.is() ) - return; - } + // create new webdav session + m_xSession + = m_xSessionFactory->createDAVSession( m_aURL, m_aFlags, m_xContext ); - // Own URI is needed to redirect cycle detection. - m_aRedirectURIs.push_back( aURI ); + if ( !m_xSession.is() ) + return; + } - // Success. - m_aPath = aPath; + // Own URI is needed to redirect cycle detection. + m_aRedirectURIs.push_back( aURI ); - // Not only the path has to be encoded - m_aURL = aURI.GetURI(); - } + // Success. + m_aPath = aPath; + + // Not only the path has to be encoded + m_aURL = aURI.GetURI(); } diff --git a/ucb/source/ucp/webdav-neon/DAVTypes.cxx b/ucb/source/ucp/webdav-neon/DAVTypes.cxx index 6cf4a01b304a..c7c6ff356f7f 100644 --- a/ucb/source/ucp/webdav-neon/DAVTypes.cxx +++ b/ucb/source/ucp/webdav-neon/DAVTypes.cxx @@ -175,19 +175,19 @@ void DAVOptionsCache::setHeadAllowed( const OUString & rURL, const bool HeadAllo normalizeURLLastChar( aEncodedUrl ); DAVOptionsMap::iterator it = m_aTheCache.find( aEncodedUrl ); - if ( it != m_aTheCache.end() ) + if ( it == m_aTheCache.end() ) + return; + + // first check for stale + TimeValue t1; + osl_getSystemTime( &t1 ); + if( (*it).second.getStaleTime() < t1.Seconds ) { - // first check for stale - TimeValue t1; - osl_getSystemTime( &t1 ); - if( (*it).second.getStaleTime() < t1.Seconds ) - { - m_aTheCache.erase( it ); - return; - } - // check if the resource was present on server - (*it).second.setHeadAllowed( HeadAllowed ); + m_aTheCache.erase( it ); + return; } + // check if the resource was present on server + (*it).second.setHeadAllowed( HeadAllowed ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/ucb/source/ucp/webdav-neon/NeonSession.cxx b/ucb/source/ucp/webdav-neon/NeonSession.cxx index 4773514cd3fa..b914f41cd903 100644 --- a/ucb/source/ucp/webdav-neon/NeonSession.cxx +++ b/ucb/source/ucp/webdav-neon/NeonSession.cxx @@ -2007,47 +2007,47 @@ void runResponseHeaderHandler( void * userdata, OUString aHeader(value, strlen(value), RTL_TEXTENCODING_ASCII_US); sal_Int32 nPos = aHeader.indexOf( ':' ); - if ( nPos != -1 ) - { - OUString aHeaderName( aHeader.copy( 0, nPos ) ); + if ( nPos == -1 ) + return; - NeonRequestContext * pCtx - = static_cast< NeonRequestContext * >( userdata ); + OUString aHeaderName( aHeader.copy( 0, nPos ) ); - // Note: Empty vector means that all headers are requested. - bool bIncludeIt = pCtx->pHeaderNames->empty(); + NeonRequestContext * pCtx + = static_cast< NeonRequestContext * >( userdata ); - if ( !bIncludeIt ) - { - // Check whether this header was requested. - auto it = std::find_if(pCtx->pHeaderNames->cbegin(), pCtx->pHeaderNames->cend(), - [&aHeaderName](const OUString& rName) { - // header names are case insensitive - return rName.equalsIgnoreAsciiCase( aHeaderName ); }); + // Note: Empty vector means that all headers are requested. + bool bIncludeIt = pCtx->pHeaderNames->empty(); - if ( it != pCtx->pHeaderNames->end() ) - { - aHeaderName = *it; - bIncludeIt = true; - } - } + if ( !bIncludeIt ) + { + // Check whether this header was requested. + auto it = std::find_if(pCtx->pHeaderNames->cbegin(), pCtx->pHeaderNames->cend(), + [&aHeaderName](const OUString& rName) { + // header names are case insensitive + return rName.equalsIgnoreAsciiCase( aHeaderName ); }); - if ( bIncludeIt ) + if ( it != pCtx->pHeaderNames->end() ) { - // Create & set the PropertyValue - DAVPropertyValue thePropertyValue; - // header names are case insensitive, so are the - // corresponding property names. - thePropertyValue.Name = aHeaderName.toAsciiLowerCase(); - thePropertyValue.IsCaseSensitive = false; - - if ( nPos < aHeader.getLength() ) - thePropertyValue.Value <<= aHeader.copy( nPos + 1 ).trim(); - - // Add the newly created PropertyValue - pCtx->pResource->properties.push_back( thePropertyValue ); + aHeaderName = *it; + bIncludeIt = true; } } + + if ( !bIncludeIt ) + return; + + // Create & set the PropertyValue + DAVPropertyValue thePropertyValue; + // header names are case insensitive, so are the + // corresponding property names. + thePropertyValue.Name = aHeaderName.toAsciiLowerCase(); + thePropertyValue.IsCaseSensitive = false; + + if ( nPos < aHeader.getLength() ) + thePropertyValue.Value <<= aHeader.copy( nPos + 1 ).trim(); + + // Add the newly created PropertyValue + pCtx->pResource->properties.push_back( thePropertyValue ); } } // namespace diff --git a/ucb/source/ucp/webdav-neon/webdavcontent.cxx b/ucb/source/ucp/webdav-neon/webdavcontent.cxx index 931195e35f07..6967cc7b52c4 100644 --- a/ucb/source/ucp/webdav-neon/webdavcontent.cxx +++ b/ucb/source/ucp/webdav-neon/webdavcontent.cxx @@ -1256,37 +1256,37 @@ void GetPropsUsingHeadRequest(DAVResource& resource, const std::vector< OUString >& aHTTPNames, const uno::Reference< ucb::XCommandEnvironment >& xEnv) { - if (!aHTTPNames.empty()) - { - DAVOptions aDAVOptions; - OUString aTargetURL = xResAccess->getURL(); - // retrieve the cached options if any - aStaticDAVOptionsCache.getDAVOptions(aTargetURL, aDAVOptions); - - // clean cached value of PROPFIND property names - // PROPPATCH can change them - Content::removeCachedPropertyNames(aTargetURL); - // test if HEAD allowed, if not, throw, should be caught immediately - // SC_GONE used internally by us, see comment in Content::getPropertyValues - // in the catch scope - if (aDAVOptions.getHttpResponseStatusCode() != SC_GONE && - !aDAVOptions.isHeadAllowed()) - { - throw DAVException(DAVException::DAV_HTTP_ERROR, "405 Not Implemented", SC_METHOD_NOT_ALLOWED); - } - // if HEAD is enabled on this site - // check if there is a relevant HTTP response status code cached - if (aDAVOptions.getHttpResponseStatusCode() != SC_NONE) - { - // throws exception as if there was a server error, a DAV exception - throw DAVException(DAVException::DAV_HTTP_ERROR, - aDAVOptions.getHttpResponseStatusText(), - aDAVOptions.getHttpResponseStatusCode()); - // Unreachable - } + if (aHTTPNames.empty()) + return; - xResAccess->HEAD(aHTTPNames, resource, xEnv); + DAVOptions aDAVOptions; + OUString aTargetURL = xResAccess->getURL(); + // retrieve the cached options if any + aStaticDAVOptionsCache.getDAVOptions(aTargetURL, aDAVOptions); + + // clean cached value of PROPFIND property names + // PROPPATCH can change them + Content::removeCachedPropertyNames(aTargetURL); + // test if HEAD allowed, if not, throw, should be caught immediately + // SC_GONE used internally by us, see comment in Content::getPropertyValues + // in the catch scope + if (aDAVOptions.getHttpResponseStatusCode() != SC_GONE && + !aDAVOptions.isHeadAllowed()) + { + throw DAVException(DAVException::DAV_HTTP_ERROR, "405 Not Implemented", SC_METHOD_NOT_ALLOWED); } + // if HEAD is enabled on this site + // check if there is a relevant HTTP response status code cached + if (aDAVOptions.getHttpResponseStatusCode() != SC_NONE) + { + // throws exception as if there was a server error, a DAV exception + throw DAVException(DAVException::DAV_HTTP_ERROR, + aDAVOptions.getHttpResponseStatusText(), + aDAVOptions.getHttpResponseStatusCode()); + // Unreachable + } + + xResAccess->HEAD(aHTTPNames, resource, xEnv); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits