summaryrefslogtreecommitdiff
path: root/package/source/xstor/owriteablestream.cxx
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-10-29 09:54:10 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-10-30 20:17:13 +0200
commitd0a8d4a973b5ae395b6fa925e27c7a120a324f4a (patch)
treeb2e527a20258a829bffc3918e4a7f81119411bbe /package/source/xstor/owriteablestream.cxx
parentce9611d13ff69306f8c44ac53110cc2cb4116e85 (diff)
Prepare for removal of non-const operator[] from Sequence in package
Change-Id: Ib5d7fa143c4c5e3b4862ed4b91acf1e2dfc4d8bb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124378 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'package/source/xstor/owriteablestream.cxx')
-rw-r--r--package/source/xstor/owriteablestream.cxx34
1 files changed, 18 insertions, 16 deletions
diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx
index c91996d0756c..b141a469ece2 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -775,8 +775,7 @@ void OWriteStream_Impl::Commit()
return;
uno::Reference< packages::XDataSinkEncrSupport > xNewPackageStream;
- uno::Sequence< uno::Any > aSeq( 1 );
- aSeq[0] <<= false;
+ uno::Sequence< uno::Any > aSeq{ uno::Any(false) };
if ( m_xCacheStream.is() )
{
@@ -959,7 +958,7 @@ uno::Sequence< beans::PropertyValue > OWriteStream_Impl::InsertOwnProps(
break;
if (i == aResult.getLength())
aResult.realloc(i + 1);
- aResult[i] = aPropVal;
+ aResult.getArray()[i] = aPropVal;
}
return aResult;
@@ -1030,30 +1029,32 @@ uno::Sequence< beans::PropertyValue > OWriteStream_Impl::ReadPackageStreamProper
nPropNum = 3;
else if ( m_nStorageType == embed::StorageFormats::PACKAGE )
nPropNum = 4;
+ assert(nPropNum >= 2);
uno::Sequence< beans::PropertyValue > aResult( nPropNum );
+ auto aResultRange = asNonConstRange(aResult);
// The "Compressed" property must be set after "MediaType" property,
// since the setting of the last one can change the value of the first one
if ( m_nStorageType == embed::StorageFormats::OFOPXML || m_nStorageType == embed::StorageFormats::PACKAGE )
{
- aResult[0].Name = "MediaType";
- aResult[1].Name = "Compressed";
- aResult[2].Name = "Size";
+ aResultRange[0].Name = "MediaType";
+ aResultRange[1].Name = "Compressed";
+ aResultRange[2].Name = "Size";
if ( m_nStorageType == embed::StorageFormats::PACKAGE )
- aResult[3].Name = "Encrypted";
+ aResultRange[3].Name = "Encrypted";
}
else
{
- aResult[0].Name = "Compressed";
- aResult[1].Name = "Size";
+ aResultRange[0].Name = "Compressed";
+ aResultRange[1].Name = "Size";
}
// TODO: may be also raw stream should be marked
uno::Reference< beans::XPropertySet > xPropSet( m_xPackageStream, uno::UNO_QUERY_THROW );
- for ( auto& rProp : asNonConstRange(aResult) )
+ for ( auto& rProp : aResultRange )
{
try {
rProp.Value = xPropSet->getPropertyValue( rProp.Name );
@@ -2612,7 +2613,7 @@ void SAL_CALL OWriteStream::insertRelationshipByID( const OUString& sID, const
const beans::StringPair aIDRel("Id", sID);
- sal_Int32 nIDInd = -1;
+ uno::Sequence<beans::StringPair>* pPair = nullptr;
// TODO/LATER: in future the unification of the ID could be checked
uno::Sequence< uno::Sequence< beans::StringPair > > aSeq = getAllRelationships();
@@ -2620,16 +2621,17 @@ void SAL_CALL OWriteStream::insertRelationshipByID( const OUString& sID, const
{
const auto& rRel = aSeq[nInd];
if (std::find(rRel.begin(), rRel.end(), aIDRel) != rRel.end())
- nIDInd = nInd;
+ pPair = &aSeq.getArray()[nInd];
}
- if ( nIDInd != -1 && !bReplace )
+ if ( pPair && !bReplace )
throw container::ElementExistException(); // TODO
- if ( nIDInd == -1 )
+ if ( !pPair )
{
- nIDInd = aSeq.getLength();
+ sal_Int32 nIDInd = aSeq.getLength();
aSeq.realloc( nIDInd + 1 );
+ pPair = &aSeq.getArray()[nIDInd];
}
std::vector<beans::StringPair> aResult;
@@ -2639,7 +2641,7 @@ void SAL_CALL OWriteStream::insertRelationshipByID( const OUString& sID, const
std::copy_if(aEntry.begin(), aEntry.end(), std::back_inserter(aResult),
[](const beans::StringPair& rRel) { return rRel.First != "Id"; });
- aSeq[nIDInd] = comphelper::containerToSequence(aResult);
+ *pPair = comphelper::containerToSequence(aResult);
m_pImpl->m_aNewRelInfo = aSeq;
m_pImpl->m_xNewRelInfoStream.clear();