diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-29 10:19:55 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-11-01 08:23:16 +0100 |
commit | 5e7e62b937721850ff762c063e9e58c58ce2fb80 (patch) | |
tree | e1646f71285b049e4852abde2b323fe608d0a3fa /ucb | |
parent | cae7b855a5fd479e6df822f974870f42e91ce068 (diff) |
Prepare for removal of non-const operator[] from Sequence in ucb
Change-Id: I16f3de8398323a308e20d04643a11dd9c3ec59f3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124404
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'ucb')
29 files changed, 326 insertions, 350 deletions
diff --git a/ucb/source/cacher/cachedcontentresultset.cxx b/ucb/source/cacher/cachedcontentresultset.cxx index 3adfcc45a225..c169a3734b58 100644 --- a/ucb/source/cacher/cachedcontentresultset.cxx +++ b/ucb/source/cacher/cachedcontentresultset.cxx @@ -212,7 +212,7 @@ Any& CachedContentResultSet::CCRS_Cache if( nDiff < 0 ) nDiff *= -1; - return (m_pResult->Rows)[nDiff]; + return m_pResult->Rows.getArray()[nDiff]; } void CachedContentResultSet::CCRS_Cache @@ -226,7 +226,10 @@ void CachedContentResultSet::CCRS_Cache nDiff *= -1; Sequence< sal_Bool >& rMappedReminder = getMappedReminder(); if( nDiff < rMappedReminder.getLength() ) - rMappedReminder[nDiff] = true; + { + sal_Bool* pMappedReminder = rMappedReminder.getArray(); + pMappedReminder[nDiff] = true; + } } bool CachedContentResultSet::CCRS_Cache @@ -449,15 +452,16 @@ CCRS_PropertySetInfo::CCRS_PropertySetInfo( sal_Int32 nOrigProps = aOrigProps.getLength(); m_xProperties->realloc( nOrigProps + 2 - nDeleted );//note that nDeleted is <= 2 + auto pProperties = m_xProperties->getArray(); for( sal_Int32 n = 0, m = 0; n < nOrigProps; n++, m++ ) { if( n == nFetchSize || n == nFetchDirection ) m--; else - (*m_xProperties)[ m ] = aOrigProps[ n ]; + pProperties[ m ] = aOrigProps[ n ]; } { - Property& rMyProp = (*m_xProperties)[ nOrigProps - nDeleted ]; + Property& rMyProp = pProperties[ nOrigProps - nDeleted ]; rMyProp.Name = g_sPropertyNameForFetchSize; rMyProp.Type = cppu::UnoType<sal_Int32>::get(); rMyProp.Attributes = PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT; @@ -471,7 +475,7 @@ CCRS_PropertySetInfo::CCRS_PropertySetInfo( } { - Property& rMyProp = (*m_xProperties)[ nOrigProps - nDeleted + 1 ]; + Property& rMyProp = pProperties[ nOrigProps - nDeleted + 1 ]; rMyProp.Name = g_sPropertyNameForFetchDirection; rMyProp.Type = cppu::UnoType<sal_Bool>::get(); rMyProp.Attributes = PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT; diff --git a/ucb/source/cacher/cachedcontentresultsetstub.cxx b/ucb/source/cacher/cachedcontentresultsetstub.cxx index 19ca0dd060f8..a84d8f98f5bf 100644 --- a/ucb/source/cacher/cachedcontentresultsetstub.cxx +++ b/ucb/source/cacher/cachedcontentresultsetstub.cxx @@ -211,7 +211,7 @@ FetchResult CachedContentResultSetStub::impl_fetchHelper( try { - impl_loadRow( aRet.Rows[0] ); + impl_loadRow( aRet.Rows.getArray()[0] ); } catch( SQLException& ) { @@ -222,6 +222,7 @@ FetchResult CachedContentResultSetStub::impl_fetchHelper( return aRet; } aRet.Rows.realloc( nRowCount ); + auto pRows = aRet.Rows.getArray(); bool bOldOriginal_AfterLast = false; if( !nOldOriginal_Pos ) bOldOriginal_AfterLast = m_xResultSetOrigin->isAfterLast(); @@ -257,7 +258,7 @@ FetchResult CachedContentResultSetStub::impl_fetchHelper( } for( ; nN <= nRowCount; ) { - impl_loadRow( aRet.Rows[nN-1] ); + impl_loadRow( pRows[nN-1] ); nN++; if( nN <= nRowCount ) { @@ -344,9 +345,10 @@ void CachedContentResultSetStub sal_Int32 nCount = impl_getColumnCount(); Sequence< Any > aContent( nCount ); + auto aContentRange = asNonConstRange(aContent); for( sal_Int32 nN = 1; nN <= nCount; nN++ ) { - aContent[nN-1] = xRow->getObject( nN, nullptr ); + aContentRange[nN-1] = xRow->getObject( nN, nullptr ); } rRowContent <<= aContent; diff --git a/ucb/source/core/ucb.cxx b/ucb/source/core/ucb.cxx index a6d8817fae2c..450fa670e1ac 100644 --- a/ucb/source/core/ucb.cxx +++ b/ucb/source/core/ucb.cxx @@ -330,9 +330,7 @@ void SAL_CALL UniversalContentBroker::initialize( const css::uno::Sequence< Any } if (!aArguments.hasElements()) { - m_aArguments.realloc(2); - m_aArguments[0] <<= OUString("Local"); - m_aArguments[1] <<= OUString("Office"); + m_aArguments = { Any(OUString("Local")), Any(OUString("Office")) }; } else { diff --git a/ucb/source/core/ucbcmds.cxx b/ucb/source/core/ucbcmds.cxx index d3a08c695a6f..77b6ca347754 100644 --- a/ucb/source/core/ucbcmds.cxx +++ b/ucb/source/core/ucbcmds.cxx @@ -18,7 +18,6 @@ */ #include <memory> -#include <optional> #include <osl/diagnose.h> #include <comphelper/propertysequence.hxx> #include <cppuhelper/implbase.hxx> @@ -67,7 +66,11 @@ using namespace com::sun::star; namespace { - +// Helper to provide defaults for type and attributes (save some typing) +beans::Property makeProperty(const OUString& n, sal_Int32 h, uno::Type t = {}, sal_Int16 a = {}) +{ + return { n, h, t, a }; +} // struct TransferCommandContext. @@ -194,7 +197,7 @@ uno::Reference< io::XInputStream > SAL_CALL ActiveDataSink::getInputStream() class CommandProcessorInfo : public cppu::WeakImplHelper< ucb::XCommandInfo > { - std::optional< uno::Sequence< ucb::CommandInfo > > m_xInfo; + uno::Sequence< ucb::CommandInfo > m_xInfo; public: CommandProcessorInfo(); @@ -211,23 +214,20 @@ public: CommandProcessorInfo::CommandProcessorInfo() - : m_xInfo( 3 ) -{ - (*m_xInfo)[ 0 ] - = ucb::CommandInfo( + : m_xInfo{ + ucb::CommandInfo( GETCOMMANDINFO_NAME, // Name GETCOMMANDINFO_HANDLE, // Handle - cppu::UnoType<void>::get() ); // ArgType - (*m_xInfo)[ 1 ] - = ucb::CommandInfo( + cppu::UnoType<void>::get() ), // ArgType + ucb::CommandInfo( GLOBALTRANSFER_NAME, // Name GLOBALTRANSFER_HANDLE, // Handle - cppu::UnoType<ucb::GlobalTransferCommandArgument>::get() ); // ArgType - (*m_xInfo)[ 2 ] - = ucb::CommandInfo( + cppu::UnoType<ucb::GlobalTransferCommandArgument>::get() ), // ArgType + ucb::CommandInfo( CHECKIN_NAME, // Name CHECKIN_HANDLE, // Handle - cppu::UnoType<ucb::CheckinArgument>::get() ); // ArgType + cppu::UnoType<ucb::CheckinArgument>::get() ) } // ArgType +{ } @@ -235,7 +235,7 @@ CommandProcessorInfo::CommandProcessorInfo() uno::Sequence< ucb::CommandInfo > SAL_CALL CommandProcessorInfo::getCommands() { - return *m_xInfo; + return m_xInfo; } @@ -243,9 +243,9 @@ CommandProcessorInfo::getCommands() ucb::CommandInfo SAL_CALL CommandProcessorInfo::getCommandInfoByName( const OUString& Name ) { - auto pInfo = std::find_if(std::cbegin(*m_xInfo), std::cend(*m_xInfo), + auto pInfo = std::find_if(std::cbegin(m_xInfo), std::cend(m_xInfo), [&Name](const ucb::CommandInfo& rInfo) { return rInfo.Name == Name; }); - if (pInfo != std::cend(*m_xInfo)) + if (pInfo != std::cend(m_xInfo)) return *pInfo; throw ucb::UnsupportedCommandException(); @@ -256,9 +256,9 @@ CommandProcessorInfo::getCommandInfoByName( const OUString& Name ) ucb::CommandInfo SAL_CALL CommandProcessorInfo::getCommandInfoByHandle( sal_Int32 Handle ) { - auto pInfo = std::find_if(std::cbegin(*m_xInfo), std::cend(*m_xInfo), + auto pInfo = std::find_if(std::cbegin(m_xInfo), std::cend(m_xInfo), [&Handle](const ucb::CommandInfo& rInfo) { return rInfo.Handle == Handle; }); - if (pInfo != std::cend(*m_xInfo)) + if (pInfo != std::cend(m_xInfo)) return *pInfo; throw ucb::UnsupportedCommandException(); @@ -269,7 +269,7 @@ CommandProcessorInfo::getCommandInfoByHandle( sal_Int32 Handle ) sal_Bool SAL_CALL CommandProcessorInfo::hasCommandByName( const OUString& Name ) { - return std::any_of(std::cbegin(*m_xInfo), std::cend(*m_xInfo), + return std::any_of(std::cbegin(m_xInfo), std::cend(m_xInfo), [&Name](const ucb::CommandInfo& rInfo) { return rInfo.Name == Name; }); } @@ -277,7 +277,7 @@ sal_Bool SAL_CALL CommandProcessorInfo::hasCommandByName( // virtual sal_Bool SAL_CALL CommandProcessorInfo::hasCommandByHandle( sal_Int32 Handle ) { - return std::any_of(std::cbegin(*m_xInfo), std::cend(*m_xInfo), + return std::any_of(std::cbegin(m_xInfo), std::cend(m_xInfo), [&Handle](const ucb::CommandInfo& rInfo) { return rInfo.Handle == Handle; }); } @@ -426,10 +426,10 @@ bool setTitle( { try { - uno::Sequence< beans::PropertyValue > aPropValues( 1 ); - aPropValues[ 0 ].Name = "Title"; - aPropValues[ 0 ].Handle = -1; - aPropValues[ 0 ].Value <<= rNewTitle; + uno::Sequence< beans::PropertyValue > aPropValues{ { /* Name */ "Title", + /* Handle */ -1, + /* Value */ uno::Any(rNewTitle), + /* State */ {} } }; ucb::Command aSetPropsCommand( "setPropertyValues", @@ -497,9 +497,7 @@ uno::Reference< ucb::XContent > createNew( // Unreachable } - uno::Sequence< beans::Property > aPropsToObtain( 1 ); - aPropsToObtain[ 0 ].Name = "CreatableContentsInfo"; - aPropsToObtain[ 0 ].Handle = -1; + uno::Sequence< beans::Property > aPropsToObtain{ makeProperty("CreatableContentsInfo", -1) }; ucb::Command aGetPropsCommand( "getPropertyValues", @@ -710,6 +708,7 @@ void transferProperties( // Note: Make room for additional Title and TargetURL too. -> + 2 uno::Sequence< beans::PropertyValue > aPropValues( aAllProps.getLength() + 2 ); + auto pPropValues = aPropValues.getArray(); bool bHasTitle = rContext.aArg.NewTitle.isEmpty(); bool bHasTargetURL = ( rContext.aArg.Operation @@ -719,7 +718,7 @@ void transferProperties( for ( sal_Int32 m = 0; m < aAllProps.getLength(); ++m ) { const beans::Property & rCurrProp = aAllProps[ m ]; - beans::PropertyValue & rCurrValue = aPropValues[ nWritePos ]; + beans::PropertyValue & rCurrValue = pPropValues[ nWritePos ]; uno::Any aValue; @@ -770,9 +769,9 @@ void transferProperties( // Title needed, but not set yet? if ( !bHasTitle && !rContext.aArg.NewTitle.isEmpty() ) { - aPropValues[ nWritePos ].Name = "Title"; - aPropValues[ nWritePos ].Handle = -1; - aPropValues[ nWritePos ].Value <<= rContext.aArg.NewTitle; + pPropValues[ nWritePos ].Name = "Title"; + pPropValues[ nWritePos ].Handle = -1; + pPropValues[ nWritePos ].Value <<= rContext.aArg.NewTitle; nWritePos++; } @@ -781,9 +780,9 @@ void transferProperties( if ( !bHasTargetURL && ( rContext.aArg.Operation == ucb::TransferCommandOperation_LINK ) ) { - aPropValues[ nWritePos ].Name = "TargetURL"; - aPropValues[ nWritePos ].Handle = -1; - aPropValues[ nWritePos ].Value <<= rContext.aArg.SourceURL; + pPropValues[ nWritePos ].Name = "TargetURL"; + pPropValues[ nWritePos ].Handle = -1; + pPropValues[ nWritePos ].Value <<= rContext.aArg.SourceURL; nWritePos++; } @@ -887,14 +886,9 @@ uno::Reference< sdbc::XResultSet > getResultSet( { uno::Reference< sdbc::XResultSet > xResultSet; - uno::Sequence< beans::Property > aProps( 3 ); - - aProps[ 0 ].Name = "IsFolder"; - aProps[ 0 ].Handle = -1; /* unknown */ - aProps[ 1 ].Name = "IsDocument"; - aProps[ 1 ].Handle = -1; /* unknown */ - aProps[ 2 ].Name = "TargetURL"; - aProps[ 2 ].Handle = -1; /* unknown */ + uno::Sequence< beans::Property > aProps{ makeProperty("IsFolder", -1 /* unknown */), + makeProperty("IsDocument", -1 /* unknown */), + makeProperty("TargetURL", -1 /* unknown */) }; ucb::OpenCommandArgument2 aArg; aArg.Mode = ucb::OpenMode::ALL; @@ -938,9 +932,7 @@ void handleNameClashRename( sal_Int32 nTry = 0; // Obtain old title. - uno::Sequence< beans::Property > aProps( 1 ); - aProps[ 0 ].Name = "Title"; - aProps[ 0 ].Handle = -1; + uno::Sequence< beans::Property > aProps{ makeProperty("Title", -1) }; ucb::Command aGetPropsCommand( "getPropertyValues", @@ -1785,16 +1777,10 @@ void UniversalContentBroker::globalTransfer( // Obtain interesting property values from source... - uno::Sequence< beans::Property > aProps( 4 ); - - aProps[ 0 ].Name = "IsFolder"; - aProps[ 0 ].Handle = -1; /* unknown */ - aProps[ 1 ].Name = "IsDocument"; - aProps[ 1 ].Handle = -1; /* unknown */ - aProps[ 2 ].Name = "TargetURL"; - aProps[ 2 ].Handle = -1; /* unknown */ - aProps[ 3 ].Name = "BaseURI"; - aProps[ 3 ].Handle = -1; /* unknown */ + uno::Sequence< beans::Property > aProps{ makeProperty("IsFolder", -1 /* unknown */), + makeProperty("IsDocument", -1 /* unknown */), + makeProperty("TargetURL", -1 /* unknown */), + makeProperty("BaseURI", -1 /* unknown */) }; ucb::Command aGetPropsCommand( "getPropertyValues", diff --git a/ucb/source/core/ucbstore.cxx b/ucb/source/core/ucbstore.cxx index 223f66dc34bb..4126d7988c4e 100644 --- a/ucb/source/core/ucbstore.cxx +++ b/ucb/source/core/ucbstore.cxx @@ -1687,6 +1687,7 @@ Sequence< PropertyValue > SAL_CALL PersistentPropertySet::getPropertyValues() if ( xHierNameAccess.is() ) { Sequence< PropertyValue > aValues( nCount ); + auto pValues = aValues.getArray(); static const OUStringLiteral aHandleName(u"/Handle"); static const OUStringLiteral aValueName(u"/Value"); @@ -1694,7 +1695,7 @@ Sequence< PropertyValue > SAL_CALL PersistentPropertySet::getPropertyValues() for ( sal_Int32 n = 0; n < nCount; ++n ) { - PropertyValue& rValue = aValues[ n ]; + PropertyValue& rValue = pValues[ n ]; OUString rName = aElems[ n ]; OUString aXMLName = makeHierarchalNameSegment( rName ); diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx index 7ba1a129ebf5..7980a1821bba 100644 --- a/ucb/source/ucp/cmis/cmis_content.cxx +++ b/ucb/source/ucp/cmis/cmis_content.cxx @@ -238,26 +238,21 @@ namespace uno::Sequence< uno::Any > generateErrorArguments( const cmis::URL & rURL ) { - uno::Sequence< uno::Any > aArguments(3); - - size_t i = 0; - aArguments[i++] <<= beans::PropertyValue( - "Binding URL", - - 1, - uno::makeAny( rURL.getBindingUrl() ), - beans::PropertyState_DIRECT_VALUE ); - - aArguments[i++] <<= beans::PropertyValue( - "Username", - -1, - uno::makeAny( rURL.getUsername() ), - beans::PropertyState_DIRECT_VALUE ); - - aArguments[i++] <<= beans::PropertyValue( - "Repository Id", - -1, - uno::makeAny( rURL.getRepositoryId() ), - beans::PropertyState_DIRECT_VALUE ); + uno::Sequence< uno::Any > aArguments{ uno::Any(beans::PropertyValue( + "Binding URL", + - 1, + uno::makeAny( rURL.getBindingUrl() ), + beans::PropertyState_DIRECT_VALUE )), + uno::Any(beans::PropertyValue( + "Username", + -1, + uno::makeAny( rURL.getUsername() ), + beans::PropertyState_DIRECT_VALUE )), + uno::Any(beans::PropertyValue( + "Repository Id", + -1, + uno::makeAny( rURL.getRepositoryId() ), + beans::PropertyState_DIRECT_VALUE )) }; return aArguments; } @@ -974,8 +969,7 @@ namespace cmis // Handle the case of the non-existing file if ( !getObject( xEnv ) ) { - uno::Sequence< uno::Any > aArgs( 1 ); - aArgs[ 0 ] <<= m_xIdentifier->getContentIdentifier(); + uno::Sequence< uno::Any > aArgs{ uno::Any(m_xIdentifier->getContentIdentifier()) }; uno::Any aErr = uno::makeAny( ucb::InteractiveAugmentedIOException(OUString(), static_cast< cppu::OWeakObject * >( this ), task::InteractionClassification_ERROR, @@ -1229,14 +1223,15 @@ namespace cmis } std::vector< libcmis::DocumentPtr > aCmisVersions = pDoc->getAllVersions( ); uno::Sequence< document::CmisVersion > aVersions( aCmisVersions.size( ) ); + auto aVersionsRange = asNonConstRange(aVersions); int i = 0; for ( const auto& rVersion : aCmisVersions ) { libcmis::DocumentPtr pVersion = rVersion; - aVersions[i].Id = STD_TO_OUSTR( pVersion->getId( ) ); - aVersions[i].Author = STD_TO_OUSTR( pVersion->getCreatedBy( ) ); - aVersions[i].TimeStamp = lcl_boostToUnoTime( pVersion->getLastModificationDate( ) ); - aVersions[i].Comment = STD_TO_OUSTR( pVersion->getStringProperty("cmis:checkinComment") ); + aVersionsRange[i].Id = STD_TO_OUSTR( pVersion->getId( ) ); + aVersionsRange[i].Author = STD_TO_OUSTR( pVersion->getCreatedBy( ) ); + aVersionsRange[i].TimeStamp = lcl_boostToUnoTime( pVersion->getLastModificationDate( ) ); + aVersionsRange[i].Comment = STD_TO_OUSTR( pVersion->getStringProperty("cmis:checkinComment") ); ++i; } return aVersions; @@ -1460,7 +1455,7 @@ namespace cmis sal_Int32 nCount = rValues.getLength(); uno::Sequence< uno::Any > aRet( nCount ); - + auto aRetRange = asNonConstRange(aRet); bool bChanged = false; const beans::PropertyValue* pValues = rValues.getConstArray(); for ( sal_Int32 n = 0; n < nCount; ++n ) @@ -1475,14 +1470,14 @@ namespace cmis { lang::IllegalAccessException e ( "Property is read-only!", static_cast< cppu::OWeakObject* >( this ) ); - aRet[ n ] <<= e; + aRetRange[ n ] <<= e; } else if ( rValue.Name == "Title" ) { OUString aNewTitle; if (!( rValue.Value >>= aNewTitle )) { - aRet[ n ] <<= beans::IllegalTypeException + aRetRange[ n ] <<= beans::IllegalTypeException ( "Property value has wrong type!", static_cast< cppu::OWeakObject * >( this ) ); continue; @@ -1490,7 +1485,7 @@ namespace cmis if ( aNewTitle.isEmpty() ) { - aRet[ n ] <<= lang::IllegalArgumentException + aRetRange[ n ] <<= lang::IllegalArgumentException ( "Empty title not allowed!", static_cast< cppu::OWeakObject * >( this ), -1 ); continue; @@ -1505,7 +1500,7 @@ namespace cmis SAL_INFO( "ucb.ucp.cmis", "Couldn't set property: " << rValue.Name ); lang::IllegalAccessException e ( "Property is read-only!", static_cast< cppu::OWeakObject* >( this ) ); - aRet[ n ] <<= e; + aRetRange[ n ] <<= e; } } diff --git a/ucb/source/ucp/ext/ucpext_content.cxx b/ucb/source/ucp/ext/ucpext_content.cxx index fabbfda3129a..214ca98045a9 100644 --- a/ucb/source/ucp/ext/ucpext_content.cxx +++ b/ucb/source/ucp/ext/ucpext_content.cxx @@ -585,8 +585,7 @@ namespace ucb::ucp::ext bool bIsFolder = false; try { - Sequence< Property > aProps(1); - aProps[0].Name = "IsFolder"; + Sequence< Property > aProps{ { /*Name*/ "IsFolder", {}, {}, {} } }; Reference< XRow > xRow( getPropertyValues( aProps, nullptr ), UNO_SET_THROW ); bIsFolder = xRow->getBoolean(1); } @@ -610,8 +609,7 @@ namespace ucb::ucp::ext try { - Sequence< Property > aProps(1); - aProps[0].Name = "ContentType"; + Sequence< Property > aProps{ { /*Name*/ "ContentType", {}, {}, {} } }; Reference< XRow > xRow( getPropertyValues( aProps, nullptr ), UNO_SET_THROW ); m_aContentType = xRow->getString(1); } diff --git a/ucb/source/ucp/file/bc.cxx b/ucb/source/ucp/file/bc.cxx index 7460fbbd23f1..b453ab6b882a 100644 --- a/ucb/source/ucp/file/bc.cxx +++ b/ucb/source/ucp/file/bc.cxx @@ -754,6 +754,7 @@ BaseContent::setPropertyValues( { Sequence< Any > ret = m_pMyShell->setv( m_aUncPath, // Does not handle Title Values ); + auto retRange = asNonConstRange(ret); // Special handling Title: Setting Title is equivalent to a renaming of the underlying file for( sal_Int32 i = 0; i < Values.getLength(); ++i ) @@ -764,12 +765,12 @@ BaseContent::setPropertyValues( OUString NewTitle; if( !( Values[i].Value >>= NewTitle ) ) { - ret[i] <<= beans::IllegalTypeException( THROW_WHERE ); + retRange[i] <<= beans::IllegalTypeException( THROW_WHERE ); break; } else if( NewTitle.isEmpty() ) { - ret[i] <<= lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 0 ); + retRange[i] <<= lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 0 ); break; } @@ -794,7 +795,7 @@ BaseContent::setPropertyValues( } catch(const Exception& e) { - ret[i] <<= e; + retRange[i] <<= e; } // NameChanges come back through a ContentEvent diff --git a/ucb/source/ucp/file/filglob.cxx b/ucb/source/ucp/file/filglob.cxx index 20c14da193bc..5772934cd161 100644 --- a/ucb/source/ucp/file/filglob.cxx +++ b/ucb/source/ucp/file/filglob.cxx @@ -118,26 +118,27 @@ namespace { (bResourceName ? 1 : 0) + (bResourceType ? 1 : 0) + (bRemoveProperty ? 1 : 0) ); + auto pArguments = aArguments.getArray(); sal_Int32 i = 0; - aArguments[i++] + pArguments[i++] <<= PropertyValue("Uri", -1, makeAny(rPhysicalUrl), PropertyState_DIRECT_VALUE); if (bResourceName) - aArguments[i++] + pArguments[i++] <<= PropertyValue("ResourceName", -1, makeAny(aResourceName), PropertyState_DIRECT_VALUE); if (bResourceType) - aArguments[i++] + pArguments[i++] <<= PropertyValue("ResourceType", -1, makeAny(aResourceType), PropertyState_DIRECT_VALUE); if (bRemoveProperty) - aArguments[i++] + pArguments[i++] <<= PropertyValue("Removable", -1, makeAny(bRemovable), @@ -499,11 +500,11 @@ namespace fileaccess { else if( errorCode == TASKHANDLING_NONAMESET_INSERT_COMMAND || errorCode == TASKHANDLING_NOCONTENTTYPE_INSERT_COMMAND ) { - Sequence< OUString > aSeq( 1 ); - aSeq[0] = - ( errorCode == TASKHANDLING_NONAMESET_INSERT_COMMAND ) ? - std::u16string_view(u"Title") : - std::u16string_view(u"ContentType"); + static constexpr OUStringLiteral sTitle = u"Title"; + static constexpr OUStringLiteral sContentType = u"ContentType"; + Sequence< OUString > aSeq{ (errorCode == TASKHANDLING_NONAMESET_INSERT_COMMAND) + ? OUString(sTitle) + : OUString(sContentType) }; aAny <<= MissingPropertiesException( "a property is missing, necessary to create a content", diff --git a/ucb/source/ucp/file/filnot.cxx b/ucb/source/ucp/file/filnot.cxx index dadeffdb9cde..48ac14b2fa64 100644 --- a/ucb/source/ucp/file/filnot.cxx +++ b/ucb/source/ucp/file/filnot.cxx @@ -223,10 +223,9 @@ void PropertyChangeNotifier::notifyPropertyChanged( } } - uno::Sequence< beans::PropertyChangeEvent > seq(1); for( const auto& rChange : std::as_const(Changes) ) { - seq[0] = rChange; + uno::Sequence< beans::PropertyChangeEvent > seq{ rChange }; it = m_aListeners.find( rChange.PropertyName ); if (it != m_aListeners.end()) { diff --git a/ucb/source/ucp/file/filprp.cxx b/ucb/source/ucp/file/filprp.cxx index 3cab28c70ddf..fb895ebe28bb 100644 --- a/ucb/source/ucp/file/filprp.cxx +++ b/ucb/source/ucp/file/filprp.cxx @@ -39,11 +39,12 @@ XPropertySetInfo_impl::XPropertySetInfo_impl( TaskManager* pMyShell,const OUStri TaskManager::PropertySet& properties = it->second.properties; m_seq.realloc( properties.size() ); + auto p_seq = m_seq.getArray(); sal_Int32 count = 0; for( const auto& rProp : properties ) { - m_seq[ count++ ] = beans::Property( rProp.getPropertyName(), + p_seq[ count++ ] = beans::Property( rProp.getPropertyName(), rProp.getHandle(), rProp.getType(), rProp.getAttributes() ); diff --git a/ucb/source/ucp/file/filrow.cxx b/ucb/source/ucp/file/filrow.cxx index 8da0b4d52b94..e352e7919907 100644 --- a/ucb/source/ucp/file/filrow.cxx +++ b/ucb/source/ucp/file/filrow.cxx @@ -38,7 +38,7 @@ using namespace css::uno; template< class _type_ > static bool convert( TaskManager const * pShell, uno::Reference< script::XTypeConverter >& xConverter, - uno::Any& rValue, + const uno::Any& rValue, _type_& aReturn ) { // Try first without converting diff --git a/ucb/source/ucp/file/filtask.cxx b/ucb/source/ucp/file/filtask.cxx index b17092d2c2f8..dcbe2a128b74 100644 --- a/ucb/source/ucp/file/filtask.cxx +++ b/ucb/source/ucp/file/filtask.cxx @@ -137,7 +137,43 @@ TaskManager::TaskManager( const uno::Reference< uno::XComponentContext >& rxCont : m_nCommandId( 0 ), m_pProvider( pProvider ), m_xContext( rxContext ), - m_sCommandInfo( 9 ) + // Commands + m_sCommandInfo{ + { /* Name */ "getCommandInfo", + /* Handle */ -1, + /* ArgType */ cppu::UnoType<void>::get() }, + + { /* Name */ "getPropertySetInfo", + /* Handle */ -1, + /* ArgType */ cppu::UnoType<void>::get() }, + + { /* Name */ "getPropertyValues", + /* Handle */ -1, + /* ArgType */ cppu::UnoType<uno::Sequence< beans::Property >>::get() }, + + { /* Name */ "setPropertyValues", + /* Handle */ -1, + /* ArgType */ cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get() }, + + { /* Name */ "open", + /* Handle */ -1, + /* ArgType */ cppu::UnoType<OpenCommandArgument>::get() }, + + { /* Name */ "transfer", + /* Handle */ -1, + /* ArgType */ cppu::UnoType<TransferInfo>::get() }, + + { /* Name */ "delete", + /* Handle */ -1, + /* ArgType */ cppu::UnoType<sal_Bool>::get() }, + + { /* Name */ "insert", + /* Handle */ -1, + /* ArgType */ cppu::UnoType<InsertCommandArgument>::get() }, + + { /* Name */ "createNewContent", + /* Handle */ -1, + /* ArgType */ cppu::UnoType<ucb::ContentInfo>::get() } } { // Title m_aDefaultProperties.insert( MyProperty( true, @@ -313,43 +349,6 @@ TaskManager::TaskManager( const uno::Reference< uno::XComponentContext >& rxCont | beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ) ); - // Commands - m_sCommandInfo[0].Name = "getCommandInfo"; - m_sCommandInfo[0].Handle = -1; - m_sCommandInfo[0].ArgType = cppu::UnoType<void>::get(); - - m_sCommandInfo[1].Name = "getPropertySetInfo"; - m_sCommandInfo[1].Handle = -1; - m_sCommandInfo[1].ArgType = cppu::UnoType<void>::get(); - - m_sCommandInfo[2].Name = "getPropertyValues"; - m_sCommandInfo[2].Handle = -1; - m_sCommandInfo[2].ArgType = cppu::UnoType<uno::Sequence< beans::Property >>::get(); - - m_sCommandInfo[3].Name = "setPropertyValues"; - m_sCommandInfo[3].Handle = -1; - m_sCommandInfo[3].ArgType = cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get(); - - m_sCommandInfo[4].Name = "open"; - m_sCommandInfo[4].Handle = -1; - m_sCommandInfo[4].ArgType = cppu::UnoType<OpenCommandArgument>::get(); - - m_sCommandInfo[5].Name = "transfer"; - m_sCommandInfo[5].Handle = -1; - m_sCommandInfo[5].ArgType = cppu::UnoType<TransferInfo>::get(); - - m_sCommandInfo[6].Name = "delete"; - m_sCommandInfo[6].Handle = -1; - m_sCommandInfo[6].ArgType = cppu::UnoType<sal_Bool>::get(); - - m_sCommandInfo[7].Name = "insert"; - m_sCommandInfo[7].Handle = -1; - m_sCommandInfo[7].ArgType = cppu::UnoType<InsertCommandArgument>::get(); - - m_sCommandInfo[8].Name = "createNewContent"; - m_sCommandInfo[8].Handle = -1; - m_sCommandInfo[8].ArgType = cppu::UnoType<ucb::ContentInfo>::get(); - if(bWithConfig) { uno::Reference< XPropertySetRegistryFactory > xRegFac = ucb::Store::create( m_xContext ); @@ -840,7 +839,9 @@ TaskManager::setv( const OUString& aUnqPath, sal_Int32 propChanged = 0; uno::Sequence< uno::Any > ret( values.getLength() ); + auto retRange = asNonConstRange(ret); uno::Sequence< beans::PropertyChangeEvent > seqChanged( values.getLength() ); + auto seqChangedRange = asNonConstRange(seqChanged); TaskManager::ContentMap::iterator it = m_aContent.find( aUnqPath ); PropertySet& properties = it->second.properties; @@ -853,7 +854,7 @@ TaskManager::setv( const OUString& aUnqPath, it1 = properties.find( toset ); if( it1 == properties.end() ) { - ret[i] <<= beans::UnknownPropertyException( THROW_WHERE ); + retRange[i] <<= beans::UnknownPropertyException( THROW_WHERE ); continue; } @@ -863,15 +864,15 @@ TaskManager::setv( const OUString& aUnqPath, if( it1->getAttributes() & beans::PropertyAttribute::READONLY ) { - ret[i] <<= lang::IllegalAccessException( THROW_WHERE ); + retRange[i] <<= lang::IllegalAccessException( THROW_WHERE ); continue; } - seqChanged[ propChanged ].PropertyName = values[i].Name; - seqChanged[ propChanged ].PropertyHandle = -1; - seqChanged[ propChanged ].Further = false; - seqChanged[ propChanged ].OldValue = aAny; - seqChanged[ propChanged++ ].NewValue = values[i].Value; + seqChangedRange[ propChanged ].PropertyName = values[i].Name; + seqChangedRange[ propChanged ].PropertyHandle = -1; + seqChangedRange[ propChanged ].Further = false; + seqChangedRange[ propChanged ].OldValue = aAny; + seqChangedRange[ propChanged++ ].NewValue = values[i].Value; it1->setValue( values[i].Value ); // Put the new value into the local cash @@ -898,7 +899,7 @@ TaskManager::setv( const OUString& aUnqPath, catch (const uno::Exception&e) { --propChanged; // unsuccessful setting - ret[i] <<= e; + retRange[i] <<= e; } } else @@ -923,7 +924,7 @@ TaskManager::setv( const OUString& aUnqPath, { {"Uri", uno::Any(aUnqPath)} })); - ret[i] <<= InteractiveAugmentedIOException( + retRange[i] <<= InteractiveAugmentedIOException( OUString(), nullptr, task::InteractionClassification_ERROR, @@ -932,7 +933,7 @@ TaskManager::setv( const OUString& aUnqPath, } } else - ret[i] <<= beans::IllegalTypeException( THROW_WHERE ); + retRange[i] <<= beans::IllegalTypeException( THROW_WHERE ); } else if(values[i].Name == IsReadOnly || values[i].Name == IsHidden) @@ -1030,7 +1031,7 @@ TaskManager::setv( const OUString& aUnqPath, ioError = IOErrorCode_GENERAL; break; } - ret[i] <<= InteractiveAugmentedIOException( + retRange[i] <<= InteractiveAugmentedIOException( OUString(), nullptr, task::InteractionClassification_ERROR, @@ -1039,7 +1040,7 @@ TaskManager::setv( const OUString& aUnqPath, } } else - ret[i] <<= beans::IllegalTypeException( THROW_WHERE ); + retRange[i] <<= beans::IllegalTypeException( THROW_WHERE ); } } } // end for diff --git a/ucb/source/ucp/file/prov.cxx b/ucb/source/ucp/file/prov.cxx index f3ed2e84ca70..4145080fb18f 100644 --- a/ucb/source/ucp/file/prov.cxx +++ b/ucb/source/ucp/file/prov.cxx @@ -234,22 +234,19 @@ private: } XPropertySetInfoImpl2::XPropertySetInfoImpl2() - : m_seq( 3 ) -{ - m_seq[0] = Property( "HostName", + : m_seq{ Property( "HostName", -1, cppu::UnoType<OUString>::get(), - PropertyAttribute::READONLY ); - - m_seq[1] = Property( "HomeDirectory", + PropertyAttribute::READONLY ), + Property( "HomeDirectory", -1, cppu::UnoType<OUString>::get(), - PropertyAttribute::READONLY ); - - m_seq[2] = Property( "FileSystemNotation", + PropertyAttribute::READONLY ), + Property( "FileSystemNotation", -1, cppu::UnoType<sal_Int32>::get(), - PropertyAttribute::READONLY ); + PropertyAttribute::READONLY )} +{ } void SAL_CALL diff --git a/ucb/source/ucp/ftp/ftpcontent.cxx b/ucb/source/ucp/ftp/ftpcontent.cxx index ec74d7aeca8b..b10d6469506f 100644 --- a/ucb/source/ucp/ftp/ftpcontent.cxx +++ b/ucb/source/ucp/ftp/ftpcontent.cxx @@ -571,13 +571,12 @@ FTPContent::queryCreatableContentsInfo( ) Sequence<ContentInfo > FTPContent::queryCreatableContentsInfo_Static( ) { - Sequence< Property > props( 1 ); - props[0] = Property( + Sequence< Property > props{ Property( "Title", -1, cppu::UnoType<OUString>::get(), PropertyAttribute::MAYBEVOID - | PropertyAttribute::BOUND ); + | PropertyAttribute::BOUND ) }; return { { FTP_FILE, ContentInfoAttribute::INSERT_WITH_INPUTSTREAM | ContentInfoAttribute::KIND_DOCUMENT, props }, @@ -659,8 +658,7 @@ void FTPContent::insert(const InsertCommandArgument& aInsertCommand, if(m_bInserted && !m_bTitleSet) { MissingPropertiesException excep; - excep.Properties.realloc(1); - excep.Properties[0] = "Title"; + excep.Properties = { "Title" }; ucbhelper::cancelCommandExecution(Any(excep), Env); } @@ -771,6 +769,7 @@ Sequence<Any> FTPContent::setPropertyValues( const Sequence<PropertyValue>& seqPropVal) { Sequence<Any> ret(seqPropVal.getLength()); + auto retRange = asNonConstRange(ret); Sequence<PropertyChangeEvent > evt; osl::MutexGuard aGuard(m_aMutex); @@ -778,10 +777,10 @@ Sequence<Any> FTPContent::setPropertyValues( if ( seqPropVal[i].Name == "Title" ) { OUString Title; if(!(seqPropVal[i].Value >>= Title)) { - ret[i] <<= IllegalTypeException(); + retRange[i] <<= IllegalTypeException(); continue; } else if(Title.isEmpty()) { - ret[i] <<= IllegalArgumentException(); + retRange[i] <<= IllegalArgumentException(); continue; } @@ -793,30 +792,30 @@ Sequence<Any> FTPContent::setPropertyValues( } else try { OUString OldTitle = m_aFTPURL.ren(Title); - evt.realloc(1); - evt[0].PropertyName = "Title"; - evt[0].Further = false; - evt[0].PropertyHandle = -1; - evt[0].OldValue <<= OldTitle; - evt[0].NewValue <<= Title; + evt = { { /* Source */ {}, + /* PropertyName */ "Title", + /* Further */ false, + /* PropertyHandle */ -1, + /* OldValue */ Any(OldTitle), + /* NewValue */ Any(Title) } }; } catch(const curl_exception&) { InteractiveIOException excep; // any better possibility here? // ( the error code is always CURLE_FTP_QUOTE_ERROR ) excep.Code = IOErrorCode_ACCESS_DENIED; - ret[i] <<= excep; + retRange[i] <<= excep; } } else { const Sequence<Property> props = getProperties(Reference<XCommandEnvironment>(nullptr)); // either unknown or read-only - ret[i] <<= UnknownPropertyException(); + retRange[i] <<= UnknownPropertyException(); const auto& rName = seqPropVal[i].Name; auto pProp = std::find_if(props.begin(), props.end(), [&rName](const Property& rProp) { return rProp.Name == rName; }); if (pProp != props.end()) { - ret[i] <<= IllegalAccessException( + retRange[i] <<= IllegalAccessException( "Property is read-only!", //props[j].Attributes & PropertyAttribute::READONLY // ? "Property is read-only!" diff --git a/ucb/source/ucp/gio/gio_content.cxx b/ucb/source/ucp/gio/gio_content.cxx index 1edca770b394..52509a361163 100644 --- a/ucb/source/ucp/gio/gio_content.cxx +++ b/ucb/source/ucp/gio/gio_content.cxx @@ -143,8 +143,7 @@ css::uno::Any convertToException(GError *pError, const css::uno::Reference< css: OUString sName; - css::uno::Sequence< css::uno::Any > aArgs( 1 ); - aArgs[ 0 ] <<= sName; + css::uno::Sequence< css::uno::Any > aArgs{ css::uno::Any(sName) }; switch (eCode) { @@ -686,8 +685,10 @@ css::uno::Sequence< css::uno::Any > Content::setPropertyValues( sal_Int32 nChanged = 0, nTitlePos = -1; OUString aNewTitle; css::uno::Sequence< css::beans::PropertyChangeEvent > aChanges(nCount); + auto aChangesRange = asNonConstRange(aChanges); css::uno::Sequence< css::uno::Any > aRet( nCount ); + auto aRetRange = asNonConstRange(aRet); const css::beans::PropertyValue* pValues = rValues.getConstArray(); for ( sal_Int32 n = 0; n < nCount; ++n ) { @@ -700,13 +701,13 @@ css::uno::Sequence< css::uno::Any > Content::setPropertyValues( rValue.Name == "Size" || rValue.Name == "CreatableContentsInfo" ) { - aRet[ n ] <<= getReadOnlyException( static_cast< cppu::OWeakObject * >(this) ); + aRetRange[ n ] <<= getReadOnlyException( static_cast< cppu::OWeakObject * >(this) ); } else if ( rValue.Name == "Title" ) { if (!( rValue.Value >>= aNewTitle )) { - aRet[ n ] <<= css::beans::IllegalTypeException + aRetRange[ n ] <<= css::beans::IllegalTypeException ( "Property value has wrong type!", static_cast< cppu::OWeakObject * >( this ) ); continue; @@ -714,7 +715,7 @@ css::uno::Sequence< css::uno::Any > Content::setPropertyValues( if ( aNewTitle.isEmpty() ) { - aRet[ n ] <<= css::lang::IllegalArgumentException + aRetRange[ n ] <<= css::lang::IllegalArgumentException ( "Empty title not allowed!", static_cast< cppu::OWeakObject * >( this ), -1 ); continue; @@ -733,7 +734,7 @@ css::uno::Sequence< css::uno::Any > Content::setPropertyValues( if (oldName) aEvent.OldValue <<= OUString(oldName, strlen(oldName), RTL_TEXTENCODING_UTF8); aEvent.NewValue <<= aNewTitle; - aChanges.getArray()[ nChanged ] = aEvent; + aChangesRange[ nChanged ] = aEvent; nTitlePos = nChanged++; g_file_info_set_name(pNewInfo, newName); @@ -742,7 +743,7 @@ css::uno::Sequence< css::uno::Any > Content::setPropertyValues( else { SAL_WARN("ucb.ucp.gio", "Unknown property " << rValue.Name); - aRet[ n ] <<= getReadOnlyException( static_cast< cppu::OWeakObject * >(this) ); + aRetRange[ n ] <<= getReadOnlyException( static_cast< cppu::OWeakObject * >(this) ); } } @@ -754,7 +755,7 @@ css::uno::Sequence< css::uno::Any > Content::setPropertyValues( if ((bOk = doSetFileInfo(pNewInfo))) { for (sal_Int32 i = 0; i < nChanged; ++i) - aRet[ i ] = getBadArgExcept(); + aRetRange[ i ] = getBadArgExcept(); } } @@ -772,7 +773,7 @@ css::uno::Sequence< css::uno::Any > Content::setPropertyValues( if (!exchangeIdentity( xNewId ) ) { - aRet[ nTitlePos ] <<= css::uno::Exception + aRetRange[ nTitlePos ] <<= css::uno::Exception ( "Exchange failed!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -873,8 +874,8 @@ css::uno::Any Content::open(const css::ucb::OpenCommandArgument2 & rOpenCommand, if (!g_file_query_exists(getGFile(), nullptr)) { - css::uno::Sequence< css::uno::Any > aArgs( 1 ); - aArgs[ 0 ] <<= m_xIdentifier->getContentIdentifier(); + css::uno::Sequence< css::uno::Any > aArgs{ css::uno::Any( + m_xIdentifier->getContentIdentifier()) }; css::uno::Any aErr = css::uno::makeAny( css::ucb::InteractiveAugmentedIOException(OUString(), static_cast< cppu::OWeakObject * >( this ), css::task::InteractionClassification_ERROR, diff --git a/ucb/source/ucp/hierarchy/hierarchycontent.cxx b/ucb/source/ucp/hierarchy/hierarchycontent.cxx index c92264fc4c16..2151cbaf3c71 100644 --- a/ucb/source/ucp/hierarchy/hierarchycontent.cxx +++ b/ucb/source/ucp/hierarchy/hierarchycontent.cxx @@ -987,6 +987,7 @@ uno::Sequence< uno::Any > HierarchyContent::setPropertyValues( osl::ResettableGuard< osl::Mutex > aGuard( m_aMutex ); uno::Sequence< uno::Any > aRet( rValues.getLength() ); + auto aRetRange = asNonConstRange(aRet); uno::Sequence< beans::PropertyChangeEvent > aChanges( rValues.getLength() ); sal_Int32 nChanged = 0; @@ -1016,28 +1017,28 @@ uno::Sequence< uno::Any > HierarchyContent::setPropertyValues( if ( rValue.Name == "ContentType" ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } else if ( rValue.Name == "IsDocument" ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } else if ( rValue.Name == "IsFolder" ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } else if ( rValue.Name == "CreatableContentsInfo" ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1045,7 +1046,7 @@ uno::Sequence< uno::Any > HierarchyContent::setPropertyValues( { if ( isReadOnly() ) { - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1080,7 +1081,7 @@ uno::Sequence< uno::Any > HierarchyContent::setPropertyValues( } else { - aRet[ n ] <<= lang::IllegalArgumentException( + aRetRange[ n ] <<= lang::IllegalArgumentException( "Empty title not allowed!", static_cast< cppu::OWeakObject * >( this ), -1 ); @@ -1088,7 +1089,7 @@ uno::Sequence< uno::Any > HierarchyContent::setPropertyValues( } else { - aRet[ n ] <<= beans::IllegalTypeException( + aRetRange[ n ] <<= beans::IllegalTypeException( "Property value has wrong type!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1098,7 +1099,7 @@ uno::Sequence< uno::Any > HierarchyContent::setPropertyValues( { if ( isReadOnly() ) { - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1128,7 +1129,7 @@ uno::Sequence< uno::Any > HierarchyContent::setPropertyValues( } else { - aRet[ n ] <<= lang::IllegalArgumentException( + aRetRange[ n ] <<= lang::IllegalArgumentException( "Empty target URL not allowed!", static_cast< cppu::OWeakObject * >( this ), -1 ); @@ -1136,14 +1137,14 @@ uno::Sequence< uno::Any > HierarchyContent::setPropertyValues( } else { - aRet[ n ] <<= beans::IllegalTypeException( + aRetRange[ n ] <<= beans::IllegalTypeException( "Property value has wrong type!", static_cast< cppu::OWeakObject * >( this ) ); } } else { - aRet[ n ] <<= beans::UnknownPropertyException( + aRetRange[ n ] <<= beans::UnknownPropertyException( "TargetURL only supported by links!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1180,24 +1181,24 @@ uno::Sequence< uno::Any > HierarchyContent::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 ) ); } @@ -1231,7 +1232,7 @@ uno::Sequence< uno::Any > HierarchyContent::setPropertyValues( aOldName.clear(); // Set error . - aRet[ nTitlePos ] <<= uno::Exception( + aRetRange[ nTitlePos ] <<= uno::Exception( "Exchange failed!", static_cast< cppu::OWeakObject * >( this ) ); } diff --git a/ucb/source/ucp/hierarchy/hierarchydatasource.cxx b/ucb/source/ucp/hierarchy/hierarchydatasource.cxx index 8e77576134bb..3345df6fe76c 100644 --- a/ucb/source/ucp/hierarchy/hierarchydatasource.cxx +++ b/ucb/source/ucp/hierarchy/hierarchydatasource.cxx @@ -30,6 +30,7 @@ #include <osl/diagnose.h> #include <comphelper/interfacecontainer2.hxx> +#include <comphelper/propertyvalue.hxx> #include <cppuhelper/queryinterface.hxx> #include <cppuhelper/weak.hxx> #include <com/sun/star/beans/PropertyValue.hpp> @@ -268,12 +269,10 @@ HierarchyDataSource::createInstance( const OUString & aServiceSpecifier ) { // Create view to root node. - beans::PropertyValue aProp; - aProp.Name = CFGPROPERTY_NODEPATH; - aProp.Value <<= OUString( CONFIG_DATA_ROOT_KEY ); + beans::PropertyValue aProp = comphelper::makePropertyValue(CFGPROPERTY_NODEPATH, + OUString( CONFIG_DATA_ROOT_KEY )); - uno::Sequence< uno::Any > aArguments( 1 ); - aArguments[ 0 ] <<= aProp; + uno::Sequence< uno::Any > aArguments{ uno::Any(aProp) }; return createInstanceWithArguments( aServiceSpecifier, aArguments, false ); } @@ -293,10 +292,7 @@ HierarchyDataSource::createInstanceWithArguments( uno::Sequence< OUString > SAL_CALL HierarchyDataSource::getAvailableServiceNames() { - uno::Sequence< OUString > aNames( 2 ); - aNames[ 0 ] = READ_SERVICE_NAME; - aNames[ 1 ] = READWRITE_SERVICE_NAME; - return aNames; + return { READ_SERVICE_NAME, READWRITE_SERVICE_NAME }; } @@ -323,6 +319,7 @@ HierarchyDataSource::createInstanceWithArguments( } uno::Sequence< uno::Any > aNewArgs( Arguments ); + auto aNewArgsRange = asNonConstRange(aNewArgs); if ( bCheckArgs ) { @@ -354,7 +351,7 @@ HierarchyDataSource::createInstanceWithArguments( aProp.Value <<= aConfigPath; // Set new path in arguments. - aNewArgs[ n ] <<= aProp; + aNewArgsRange[ n ] <<= aProp; break; } diff --git a/ucb/source/ucp/hierarchy/hierarchyprovider.cxx b/ucb/source/ucp/hierarchy/hierarchyprovider.cxx index fa8cdaca8887..09ac0a2e7245 100644 --- a/ucb/source/ucp/hierarchy/hierarchyprovider.cxx +++ b/ucb/source/ucp/hierarchy/hierarchyprovider.cxx @@ -231,11 +231,10 @@ HierarchyContentProvider::getRootConfigReadNameAccess( if ( xConfigProv.is() ) { - uno::Sequence< uno::Any > aArguments( 1 ); beans::PropertyValue aProperty; aProperty.Name = "nodepath" ; aProperty.Value <<= OUString(); // root path - aArguments[ 0 ] <<= aProperty; + uno::Sequence< uno::Any > aArguments{ uno::Any(aProperty) }; (*it).second.bTriedToGetRootReadAccess = true; diff --git a/ucb/source/ucp/package/pkgcontent.cxx b/ucb/source/ucp/package/pkgcontent.cxx index 346a5781050d..cf08c8bdfaaf 100644 --- a/ucb/source/ucp/package/pkgcontent.cxx +++ b/ucb/source/ucp/package/pkgcontent.cxx @@ -947,6 +947,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); uno::Sequence< uno::Any > aRet( rValues.getLength() ); + auto aRetRange = asNonConstRange(aRet); uno::Sequence< beans::PropertyChangeEvent > aChanges( rValues.getLength() ); sal_Int32 nChanged = 0; @@ -975,28 +976,28 @@ uno::Sequence< uno::Any > Content::setPropertyValues( if ( rValue.Name == "ContentType" ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } else if ( rValue.Name == "IsDocument" ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } else if ( rValue.Name == "IsFolder" ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } else if ( rValue.Name == "CreatableContentsInfo" ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1005,7 +1006,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( if ( m_aUri.isRootFolder() ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1033,7 +1034,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( } else { - aRet[ n ] <<= + aRetRange[ n ] <<= lang::IllegalArgumentException( "Empty title not allowed!", static_cast< cppu::OWeakObject * >( this ), @@ -1042,7 +1043,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( } else { - aRet[ n ] <<= + aRetRange[ n ] <<= beans::IllegalTypeException( "Property value has wrong type!", static_cast< cppu::OWeakObject * >( this ) ); @@ -1068,7 +1069,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 ) ); } @@ -1076,7 +1077,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( else if ( rValue.Name == "Size" ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1102,14 +1103,14 @@ 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 ) ); } } else { - aRet[ n ] <<= beans::UnknownPropertyException( + aRetRange[ n ] <<= beans::UnknownPropertyException( "Compressed only supported by streams!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1136,14 +1137,14 @@ 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 ) ); } } else { - aRet[ n ] <<= beans::UnknownPropertyException( + aRetRange[ n ] <<= beans::UnknownPropertyException( "Encrypted only supported by streams!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1151,7 +1152,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( else if ( rValue.Name == "HasEncryptedEntries" ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1181,14 +1182,14 @@ 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 ) ); } } else { - aRet[ n ] <<= beans::UnknownPropertyException( + aRetRange[ n ] <<= beans::UnknownPropertyException( "EncryptionKey not supported by non-root folder!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1224,24 +1225,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 ) ); } @@ -1274,7 +1275,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 ) ); } @@ -2372,8 +2373,7 @@ bool Content::storeData( const uno::Reference< io::XInputStream >& xStream ) return false; } - uno::Sequence< uno::Any > aArgs( 1 ); - aArgs[ 0 ] <<= isFolder(); + uno::Sequence< uno::Any > aArgs{ uno::Any(isFolder()) }; uno::Reference< uno::XInterface > xNew = xFac->createInstanceWithArguments( aArgs ); diff --git a/ucb/source/ucp/package/pkgprovider.cxx b/ucb/source/ucp/package/pkgprovider.cxx index 05fd6481d2b8..8ec89e87d329 100644 --- a/ucb/source/ucp/package/pkgprovider.cxx +++ b/ucb/source/ucp/package/pkgprovider.cxx @@ -219,8 +219,7 @@ ContentProvider::createPackage( const PackageUri & rURI ) m_pPackages.reset( new Packages ); // Create new package... - uno::Sequence< uno::Any > aArguments( 1 ); - aArguments[ 0 ] <<= rURL; + uno::Sequence< uno::Any > aArguments{ uno::Any(rURL) }; uno::Reference< container::XHierarchicalNameAccess > xNameAccess; try { diff --git a/ucb/source/ucp/tdoc/tdoc_content.cxx b/ucb/source/ucp/tdoc/tdoc_content.cxx index da4058ff0d69..39d44cd42628 100644 --- a/ucb/source/ucp/tdoc/tdoc_content.cxx +++ b/ucb/source/ucp/tdoc/tdoc_content.cxx @@ -1045,6 +1045,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); uno::Sequence< uno::Any > aRet( rValues.getLength() ); + auto aRetRange = asNonConstRange(aRet); uno::Sequence< beans::PropertyChangeEvent > aChanges( rValues.getLength() ); sal_Int32 nChanged = 0; @@ -1073,28 +1074,28 @@ uno::Sequence< uno::Any > Content::setPropertyValues( if ( rValue.Name == "ContentType" ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } else if ( rValue.Name == "IsDocument" ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } else if ( rValue.Name == "IsFolder" ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } else if ( rValue.Name == "CreatableContentsInfo" ) { // Read-only property! - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1104,7 +1105,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( ContentType eType = m_aProps.getType(); if ( ( eType == ROOT ) || ( eType == DOCUMENT ) ) { - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1134,7 +1135,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 ); @@ -1142,7 +1143,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( } else { - aRet[ n ] <<= beans::IllegalTypeException( + aRetRange[ n ] <<= beans::IllegalTypeException( "Title Property value has wrong type!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1153,14 +1154,14 @@ uno::Sequence< uno::Any > Content::setPropertyValues( ContentType eType = m_aProps.getType(); if ( eType == FOLDER ) { - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } else { // Storage is only supported by folders. - aRet[ n ] <<= beans::UnknownPropertyException( + aRetRange[ n ] <<= beans::UnknownPropertyException( "Storage property only supported by folders", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1170,14 +1171,14 @@ uno::Sequence< uno::Any > Content::setPropertyValues( ContentType eType = m_aProps.getType(); if ( eType == DOCUMENT ) { - aRet[ n ] <<= lang::IllegalAccessException( + aRetRange[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } else { // Storage is only supported by folders. - aRet[ n ] <<= beans::UnknownPropertyException( + aRetRange[ n ] <<= beans::UnknownPropertyException( "DocumentModel property only supported by documents", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1213,24 +1214,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 ) ); } @@ -1261,7 +1262,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( aOldTitle.clear(); // Set error . - aRet[ nTitlePos ] <<= uno::Exception( + aRetRange[ nTitlePos ] <<= uno::Exception( "Exchange failed!", static_cast< cppu::OWeakObject * >( this ) ); } diff --git a/ucb/source/ucp/tdoc/tdoc_passwordrequest.cxx b/ucb/source/ucp/tdoc/tdoc_passwordrequest.cxx index fe853d84c45b..b190ba1884d8 100644 --- a/ucb/source/ucp/tdoc/tdoc_passwordrequest.cxx +++ b/ucb/source/ucp/tdoc/tdoc_passwordrequest.cxx @@ -179,10 +179,11 @@ DocumentPasswordRequest::DocumentPasswordRequest( // Fill continuations... uno::Sequence< - uno::Reference< task::XInteractionContinuation > > aContinuations( 3 ); - aContinuations[ 0 ] = new ucbhelper::InteractionAbort( this ); - aContinuations[ 1 ] = new ucbhelper::InteractionRetry( this ); - aContinuations[ 2 ] = new InteractionSupplyPassword( this ); + uno::Reference< task::XInteractionContinuation > > aContinuations{ + new ucbhelper::InteractionAbort( this ), + new ucbhelper::InteractionRetry( this ), + new InteractionSupplyPassword( this ) + }; setContinuations( aContinuations ); } diff --git a/ucb/source/ucp/webdav-neon/LinkSequence.cxx b/ucb/source/ucp/webdav-neon/LinkSequence.cxx index ea49352d93ba..9ff9d877ec30 100644 --- a/ucb/source/ucp/webdav-neon/LinkSequence.cxx +++ b/ucb/source/ucp/webdav-neon/LinkSequence.cxx @@ -183,7 +183,7 @@ bool LinkSequence::createFromXML( const OString & rInData, if ( nCount > rOutData.getLength() ) rOutData.realloc( rOutData.getLength() + 1 ); - rOutData[ nCount - 1 ] = *aCtx.pLink; + rOutData.getArray()[ nCount - 1 ] = *aCtx.pLink; } nStart = nEnd + TOKEN_LENGTH; diff --git a/ucb/source/ucp/webdav-neon/LockEntrySequence.cxx b/ucb/source/ucp/webdav-neon/LockEntrySequence.cxx index 61be4420c7b9..1ba2466d5aa2 100644 --- a/ucb/source/ucp/webdav-neon/LockEntrySequence.cxx +++ b/ucb/source/ucp/webdav-neon/LockEntrySequence.cxx @@ -232,7 +232,7 @@ bool LockEntrySequence::createFromXML( const OString & rInData, if ( nCount > rOutData.getLength() ) rOutData.realloc( rOutData.getLength() + 2 ); - rOutData[ nCount - 1 ] = *aCtx.pEntry; + rOutData.getArray()[ nCount - 1 ] = *aCtx.pEntry; } nStart = nEnd + TOKEN_LENGTH; diff --git a/ucb/source/ucp/webdav-neon/LockSequence.cxx b/ucb/source/ucp/webdav-neon/LockSequence.cxx index b9399c60d64e..8680a31363d7 100644 --- a/ucb/source/ucp/webdav-neon/LockSequence.cxx +++ b/ucb/source/ucp/webdav-neon/LockSequence.cxx @@ -225,7 +225,7 @@ static int LockSequence_chardata_callback( // collect hrefs. sal_Int32 nPos = pCtx->pLock->LockTokens.getLength(); pCtx->pLock->LockTokens.realloc( nPos + 1 ); - pCtx->pLock->LockTokens[ nPos ] + pCtx->pLock->LockTokens.getArray()[ nPos ] = OUString( buf, len, RTL_TEXTENCODING_ASCII_US ); pCtx->hasHREF = true; break; @@ -347,7 +347,7 @@ bool LockSequence::createFromXML( const OString & rInData, if ( nCount > rOutData.getLength() ) rOutData.realloc( rOutData.getLength() + 1 ); - rOutData[ nCount - 1 ] = *aCtx.pLock; + rOutData.getArray()[ nCount - 1 ] = *aCtx.pLock; } nStart = nEnd + TOKEN_LENGTH; diff --git a/ucb/source/ucp/webdav-neon/NeonSession.cxx b/ucb/source/ucp/webdav-neon/NeonSession.cxx index 246b42fb7fb7..f08e41a4646f 100644 --- a/ucb/source/ucp/webdav-neon/NeonSession.cxx +++ b/ucb/source/ucp/webdav-neon/NeonSession.cxx @@ -1588,8 +1588,7 @@ void NeonSession::LOCK( const OUString & inPath, lastChanceToSendRefreshRequest( startCall, theLock->timeout ) ); - uno::Sequence< OUString > aTokens( 1 ); - aTokens[ 0 ] = OUString::createFromAscii( theLock->token ); + uno::Sequence< OUString > aTokens{ OUString::createFromAscii( theLock->token ) }; rLock.LockTokens = aTokens; SAL_INFO( "ucb.ucp.webdav", "LOCK (create) - Created lock for <" << makeAbsoluteURL( inPath ) @@ -2242,7 +2241,7 @@ NeonSession::getDataFromInputStream( if ( bAppendTrailingZeroByte ) { rData.realloc( nSize + 1 ); - rData[ nSize ] = sal_Int8( 0 ); + rData.getArray()[ nSize ] = sal_Int8( 0 ); } return true; } @@ -2286,7 +2285,7 @@ NeonSession::getDataFromInputStream( if ( bAppendTrailingZeroByte ) { rData.realloc( nPos + 1 ); - rData[ nPos ] = sal_Int8( 0 ); + rData.getArray()[ nPos ] = sal_Int8( 0 ); } return true; } diff --git a/ucb/source/ucp/webdav-neon/webdavcontent.cxx b/ucb/source/ucp/webdav-neon/webdavcontent.cxx index a40d4e1dcf1a..c3310e24f9cc 100644 --- a/ucb/source/ucp/webdav-neon/webdavcontent.cxx +++ b/ucb/source/ucp/webdav-neon/webdavcontent.cxx @@ -1697,6 +1697,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; @@ -1733,7 +1734,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; @@ -1746,21 +1747,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 ) ); } @@ -1793,7 +1794,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 ); @@ -1801,7 +1802,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 ); @@ -1809,7 +1810,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 ) ); } @@ -1834,7 +1835,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; @@ -1843,21 +1844,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 ) ); } @@ -1865,14 +1866,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 ) ); } @@ -1916,24 +1917,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 ) ); } @@ -2025,7 +2026,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 ) ); } @@ -2036,7 +2037,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( aNewTitle.clear(); // Set error . - aRet[ nTitlePos ] = MapDAVException( e, true ); + aRetRange[ nTitlePos ] = MapDAVException( e, true ); } } @@ -2982,8 +2983,9 @@ Content::ResourceType Content::resourceTypeForLocks( // we need only DAV:supportedlock std::vector< DAVResource > resources; std::vector< OUString > aPropNames; - uno::Sequence< beans::Property > aProperties( 1 ); - aProperties[ 0 ].Name = DAVProperties::SUPPORTEDLOCK; + uno::Sequence< beans::Property > aProperties{ + { /* Name */ DAVProperties::SUPPORTEDLOCK, {}, {}, {} } + }; ContentProperties::UCBNamesToDAVNames( aProperties, aPropNames ); rResAccess->PROPFIND( DAVZERO, aPropNames, resources, Environment ); @@ -3439,9 +3441,9 @@ bool Content::isFolder( return m_bCollection; } - uno::Sequence< beans::Property > aProperties( 1 ); - aProperties[ 0 ].Name = "IsFolder"; - aProperties[ 0 ].Handle = -1; + uno::Sequence< beans::Property > aProperties{ + { /* Name */ "IsFolder", /* Handle */ -1, {}, {} } + }; uno::Reference< sdbc::XRow > xRow( getPropertyValues( aProperties, xEnv ) ); if ( xRow.is() ) { @@ -3481,11 +3483,10 @@ uno::Any Content::MapDAVException( const DAVException & e, bool bWrite ) { case SC_NOT_FOUND: { - uno::Sequence< uno::Any > aArgs( 1 ); - aArgs[ 0 ] <<= beans::PropertyValue( + uno::Sequence< uno::Any > aArgs{ uno::Any(beans::PropertyValue( "Uri", -1, uno::makeAny(aURL), - beans::PropertyState_DIRECT_VALUE); + beans::PropertyState_DIRECT_VALUE)) }; aException <<= ucb::InteractiveAugmentedIOException( @@ -3705,12 +3706,13 @@ Content::ResourceType Content::getResourceType( // this is a DAV resource. 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; + uno::Sequence< beans::Property > aProperties{ + { /* Name */ "IsFolder", {}, {}, {} }, + { /* Name */ "IsDocument", {}, {}, {} }, + { /* Name */ "IsReadOnly", {}, {}, {} }, + { /* Name */ "MediaType", {}, {}, {} }, + { /* Name */ DAVProperties::SUPPORTEDLOCK, {}, {}, {} } + }; ContentProperties::UCBNamesToDAVNames( aProperties, aPropNames ); diff --git a/ucb/source/ucp/webdav-neon/webdavcontentcaps.cxx b/ucb/source/ucp/webdav-neon/webdavcontentcaps.cxx index ddeeec03fe28..f3e3abe8783d 100644 --- a/ucb/source/ucp/webdav-neon/webdavcontentcaps.cxx +++ b/ucb/source/ucp/webdav-neon/webdavcontentcaps.cxx @@ -500,6 +500,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); sal_Int32 n = 0; beans::Property aProp; @@ -507,7 +508,7 @@ uno::Sequence< beans::Property > Content::getProperties( for ( const auto& rProp : aPropSet ) { xProvider->getProperty( rProp, aProp ); - aProperties[ n++ ] = aProp; + aPropertiesRange[ n++ ] = aProp; } return aProperties; @@ -520,72 +521,63 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands( { osl::Guard< osl::Mutex > aGuard( m_aMutex ); - uno::Sequence< ucb::CommandInfo > aCmdInfo( 10 ); + uno::Sequence< ucb::CommandInfo > aCmdInfo{ // Mandatory commands - aCmdInfo[ 0 ] = ucb::CommandInfo( "getCommandInfo", -1, - cppu::UnoType<void>::get() ); - aCmdInfo[ 1 ] = + cppu::UnoType<void>::get() ), ucb::CommandInfo( "getPropertySetInfo", -1, - cppu::UnoType<void>::get() ); - aCmdInfo[ 2 ] = + cppu::UnoType<void>::get() ), ucb::CommandInfo( "getPropertyValues", -1, - cppu::UnoType<uno::Sequence< beans::Property >>::get() ); - aCmdInfo[ 3 ] = + cppu::UnoType<uno::Sequence< beans::Property >>::get() ), ucb::CommandInfo( "setPropertyValues", -1, - cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get() ); + cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get() ), // Optional standard commands - aCmdInfo[ 4 ] = ucb::CommandInfo( "delete", -1, - cppu::UnoType<bool>::get() ); - aCmdInfo[ 5 ] = + cppu::UnoType<bool>::get() ), ucb::CommandInfo( "insert", -1, - cppu::UnoType<ucb::InsertCommandArgument>::get() ); - aCmdInfo[ 6 ] = + cppu::UnoType<ucb::InsertCommandArgument>::get() ), ucb::CommandInfo( "open", -1, - cppu::UnoType<ucb::OpenCommandArgument2>::get() ); + cppu::UnoType<ucb::OpenCommandArgument2>::get() ), // New commands - aCmdInfo[ 7 ] = ucb::CommandInfo( "post", -1, - cppu::UnoType<ucb::PostCommandArgument2>::get() ); - aCmdInfo[ 8 ] = + cppu::UnoType<ucb::PostCommandArgument2>::get() ), ucb::CommandInfo( "addProperty", -1, - cppu::UnoType<ucb::PropertyCommandArgument>::get() ); - aCmdInfo[ 9 ] = + cppu::UnoType<ucb::PropertyCommandArgument>::get() ), ucb::CommandInfo( "removeProperty", -1, - cppu::UnoType<OUString>::get() ); + cppu::UnoType<OUString>::get() ), + }; bool bFolder = false; @@ -608,19 +600,20 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands( else return aCmdInfo; + auto 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, @@ -634,13 +627,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, |