diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-11-05 18:26:01 +0300 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-11-05 20:56:03 +0100 |
commit | 7e33e24181ffaddcee4bc1358650a0bac48f8ebd (patch) | |
tree | b508e4f246cc40a40948dafb1fbac92ec62aa792 /ucb | |
parent | 35eef8ec9b122a761400f3c6590ca1f9a187d772 (diff) |
webdav-curl: there's no non-const Sequence::operator[]
... since commit fb3c04bd1930eedacd406874e1a285d62bbf27d9
Change-Id: Ib56e854206074dd247dcd0f876a8a92b3f9af7ee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124763
Tested-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/webdav-curl/webdavcontent.cxx | 87 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-curl/webdavcontentcaps.cxx | 34 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-curl/webdavresponseparser.cxx | 4 |
3 files changed, 56 insertions, 69 deletions
diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx b/ucb/source/ucp/webdav-curl/webdavcontent.cxx index 8baa7b95de46..6d70ff77f8bc 100644 --- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx +++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx @@ -1376,24 +1376,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues( // Only DAV resources support PROPFIND std::vector< OUString > aPropNames; - uno::Sequence< beans::Property > aProperties( - rProperties.getLength() ); - - if ( !m_aFailedPropNames.empty() ) - { - sal_Int32 nProps = 0; - sal_Int32 nCount = rProperties.getLength(); - for ( sal_Int32 n = 0; n < nCount; ++n, ++nProps ) - { - aProperties[ nProps ] = rProperties[ n ]; - } - - aProperties.realloc( nProps ); - } - else - { - aProperties = rProperties; - } + uno::Sequence< beans::Property > aProperties(rProperties); if ( aProperties.getLength() > 0 ) ContentProperties::UCBNamesToDAVNames( @@ -1739,6 +1722,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( } uno::Sequence< uno::Any > aRet( rValues.getLength() ); + auto aRetRange = asNonConstRange(aRet); uno::Sequence< beans::PropertyChangeEvent > aChanges( rValues.getLength() ); sal_Int32 nChanged = 0; @@ -1776,7 +1760,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( if ( aTmpProp.Attributes & beans::PropertyAttribute::READONLY ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); continue; @@ -1789,21 +1773,21 @@ uno::Sequence< uno::Any > Content::setPropertyValues( if ( rName == "ContentType" ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } else if ( rName == "IsDocument" ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } else if ( rName == "IsFolder" ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1836,7 +1820,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( } catch ( DAVException const & ) { - aRet[ n ] <<= lang::IllegalArgumentException( + aRetRange[ n ] <<= lang::IllegalArgumentException( "Invalid content identifier!", static_cast< cppu::OWeakObject * >( this ), -1 ); @@ -1844,7 +1828,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( } else { - aRet[ n ] <<= lang::IllegalArgumentException( + aRetRange[ n ] <<= lang::IllegalArgumentException( "Empty title not allowed!", static_cast< cppu::OWeakObject * >( this ), -1 ); @@ -1852,7 +1836,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( } else { - aRet[ n ] <<= beans::IllegalTypeException( + aRetRange[ n ] <<= beans::IllegalTypeException( "Property value has wrong type!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1875,7 +1859,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( // Check, whether property exists. Skip otherwise. // PROPPATCH::set would add the property automatically, which // is not allowed for "setPropertyValues" command! - aRet[ n ] <<= beans::UnknownPropertyException( + aRetRange[ n ] <<= beans::UnknownPropertyException( "Property is unknown!", static_cast< cppu::OWeakObject * >( this ) ); continue; @@ -1884,21 +1868,21 @@ uno::Sequence< uno::Any > Content::setPropertyValues( if ( rName == "Size" ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } else if ( rName == "DateCreated" ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } else if ( rName == "DateModified" ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1906,14 +1890,14 @@ uno::Sequence< uno::Any > Content::setPropertyValues( { // Read-only property! // (but could be writable, if 'getcontenttype' would be) - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } if ( rName == "CreatableContentsInfo" ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1961,24 +1945,24 @@ uno::Sequence< uno::Any > Content::setPropertyValues( } catch ( beans::UnknownPropertyException const & e ) { - aRet[ n ] <<= e; + aRetRange[ n ] <<= e; } catch ( lang::WrappedTargetException const & e ) { - aRet[ n ] <<= e; + aRetRange[ n ] <<= e; } catch ( beans::PropertyVetoException const & e ) { - aRet[ n ] <<= e; + aRetRange[ n ] <<= e; } catch ( lang::IllegalArgumentException const & e ) { - aRet[ n ] <<= e; + aRetRange[ n ] <<= e; } } else { - aRet[ n ] <<= uno::Exception( + aRetRange[ n ] <<= uno::Exception( "No property set for storing the value!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -2027,7 +2011,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( while ( it != end ) { // Set error. - aRet[ (*it) ] <<= MapDAVException( e, true ); + aRetRange[ (*it) ] <<= MapDAVException( e, true ); ++it; } #endif @@ -2089,7 +2073,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( aNewTitle.clear(); // Set error . - aRet[ nTitlePos ] <<= uno::Exception( + aRetRange[ nTitlePos ] <<= uno::Exception( "Exchange failed!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -2100,7 +2084,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( aNewTitle.clear(); // Set error . - aRet[ nTitlePos ] = MapDAVException( e, true ); + aRetRange[ nTitlePos ] = MapDAVException( e, true ); } } @@ -3049,7 +3033,7 @@ Content::ResourceType Content::resourceTypeForLocks( std::vector< DAVResource > resources; std::vector< OUString > aPropNames; uno::Sequence< beans::Property > aProperties( 1 ); - aProperties[ 0 ].Name = DAVProperties::SUPPORTEDLOCK; + aProperties.getArray()[ 0 ].Name = DAVProperties::SUPPORTEDLOCK; ContentProperties::UCBNamesToDAVNames( aProperties, aPropNames ); rResAccess->PROPFIND( DAVZERO, aPropNames, resources, Environment ); @@ -3514,8 +3498,9 @@ bool Content::isFolder( } uno::Sequence< beans::Property > aProperties( 1 ); - aProperties[ 0 ].Name = "IsFolder"; - aProperties[ 0 ].Handle = -1; + auto pProperties = aProperties.getArray(); + pProperties[ 0 ].Name = "IsFolder"; + pProperties[ 0 ].Handle = -1; uno::Reference< sdbc::XRow > xRow( getPropertyValues( aProperties, xEnv ) ); if ( xRow.is() ) { @@ -3555,11 +3540,8 @@ uno::Any Content::MapDAVException( const DAVException & e, bool bWrite ) { case SC_NOT_FOUND: { - uno::Sequence< uno::Any > aArgs( 1 ); - aArgs[ 0 ] <<= beans::PropertyValue( - "Uri", -1, - uno::makeAny(aURL), - beans::PropertyState_DIRECT_VALUE); + uno::Sequence<uno::Any> aArgs{ uno::Any(beans::PropertyValue( + "Uri", -1, uno::makeAny(aURL), beans::PropertyState_DIRECT_VALUE)) }; aException <<= ucb::InteractiveAugmentedIOException( @@ -3792,11 +3774,12 @@ Content::ResourceType Content::getResourceType( std::vector< DAVResource > resources; std::vector< OUString > aPropNames; uno::Sequence< beans::Property > aProperties( 5 ); - aProperties[ 0 ].Name = "IsFolder"; - aProperties[ 1 ].Name = "IsDocument"; - aProperties[ 2 ].Name = "IsReadOnly"; - aProperties[ 3 ].Name = "MediaType"; - aProperties[ 4 ].Name = DAVProperties::SUPPORTEDLOCK; + auto pProperties = aProperties.getArray(); + pProperties[ 0 ].Name = "IsFolder"; + pProperties[ 1 ].Name = "IsDocument"; + pProperties[ 2 ].Name = "IsReadOnly"; + pProperties[ 3 ].Name = "MediaType"; + pProperties[ 4 ].Name = DAVProperties::SUPPORTEDLOCK; ContentProperties::UCBNamesToDAVNames( aProperties, aPropNames ); diff --git a/ucb/source/ucp/webdav-curl/webdavcontentcaps.cxx b/ucb/source/ucp/webdav-curl/webdavcontentcaps.cxx index f4bef01c631b..a7e2bb96893b 100644 --- a/ucb/source/ucp/webdav-curl/webdavcontentcaps.cxx +++ b/ucb/source/ucp/webdav-curl/webdavcontentcaps.cxx @@ -479,6 +479,7 @@ uno::Sequence< beans::Property > Content::getProperties( // std::set -> uno::Sequence sal_Int32 nCount = aPropSet.size(); uno::Sequence< beans::Property > aProperties( nCount ); + auto aPropertiesRange = asNonConstRange(aProperties); beans::Property aProp; sal_Int32 n = 0; @@ -486,7 +487,7 @@ uno::Sequence< beans::Property > Content::getProperties( for ( const auto& rProp : aPropSet ) { xProvider->getProperty( rProp, aProp ); - aProperties[ n++ ] = aProp; + aPropertiesRange[ n++ ] = aProp; } return aProperties; @@ -500,27 +501,28 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands( osl::Guard< osl::Mutex > aGuard( m_aMutex ); uno::Sequence< ucb::CommandInfo > aCmdInfo( 10 ); + auto pCmdInfo = aCmdInfo.getArray(); // Mandatory commands - aCmdInfo[ 0 ] = + pCmdInfo[ 0 ] = ucb::CommandInfo( "getCommandInfo", -1, cppu::UnoType<void>::get() ); - aCmdInfo[ 1 ] = + pCmdInfo[ 1 ] = ucb::CommandInfo( "getPropertySetInfo", -1, cppu::UnoType<void>::get() ); - aCmdInfo[ 2 ] = + pCmdInfo[ 2 ] = ucb::CommandInfo( "getPropertyValues", -1, cppu::UnoType<uno::Sequence< beans::Property >>::get()); - aCmdInfo[ 3 ] = + pCmdInfo[ 3 ] = ucb::CommandInfo( "setPropertyValues", -1, @@ -530,17 +532,17 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands( // Optional standard commands - aCmdInfo[ 4 ] = + pCmdInfo[ 4 ] = ucb::CommandInfo( "delete", -1, cppu::UnoType<bool>::get() ); - aCmdInfo[ 5 ] = + pCmdInfo[ 5 ] = ucb::CommandInfo( "insert", -1, cppu::UnoType<ucb::InsertCommandArgument>::get() ); - aCmdInfo[ 6 ] = + pCmdInfo[ 6 ] = ucb::CommandInfo( "open", -1, @@ -550,17 +552,17 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands( // New commands - aCmdInfo[ 7 ] = + pCmdInfo[ 7 ] = ucb::CommandInfo( "post", -1, cppu::UnoType<ucb::PostCommandArgument2>::get() ); - aCmdInfo[ 8 ] = + pCmdInfo[ 8 ] = ucb::CommandInfo( "addProperty", -1, cppu::UnoType<ucb::PropertyCommandArgument>::get() ); - aCmdInfo[ 9 ] = + pCmdInfo[ 9 ] = ucb::CommandInfo( "removeProperty", -1, @@ -587,19 +589,21 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands( else return aCmdInfo; + pCmdInfo = aCmdInfo.getArray(); + if ( bFolder ) { // Optional standard commands - aCmdInfo[ nPos ] = + pCmdInfo[ nPos ] = ucb::CommandInfo( "transfer", -1, cppu::UnoType<ucb::TransferInfo>::get() ); nPos++; - aCmdInfo[ nPos ] = + pCmdInfo[ nPos ] = ucb::CommandInfo( "createNewContent", -1, @@ -613,13 +617,13 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands( if ( bSupportsLocking ) { - aCmdInfo[ nPos ] = + pCmdInfo[ nPos ] = ucb::CommandInfo( "lock", -1, cppu::UnoType<void>::get() ); nPos++; - aCmdInfo[ nPos ] = + pCmdInfo[ nPos ] = ucb::CommandInfo( "unlock", -1, diff --git a/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx b/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx index 9595d42a03b2..a236957c096e 100644 --- a/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx +++ b/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx @@ -669,7 +669,7 @@ namespace aEntry.Scope = maLockScope; aEntry.Type = maLockType; maLockEntries.realloc(nLength + 1); - maLockEntries[nLength] = aEntry; + maLockEntries.getArray()[nLength] = aEntry; } break; } @@ -694,7 +694,7 @@ namespace "Parser error: wrong 'locktoken' value."); const sal_Int32 nLength(maLock.LockTokens.getLength()); maLock.LockTokens.realloc(nLength+1); - maLock.LockTokens[nLength] = sLockToken; + maLock.LockTokens.getArray()[nLength] = sLockToken; break; } case WebDAVName_exclusive: |