summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2019-08-21 17:00:35 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2019-08-22 06:57:52 +0200
commit0d1490dbbdd6a4cbe2486f993517383cc8112003 (patch)
treef49a694fe32246de63a331f6fb8af4fd9c9cbd59 /package
parent52cff86bc74cec1a6755809c6b5434afa32a274c (diff)
Deduplicate some code
Change-Id: I2cdc9f1416a9089e91f30cebe071a4855edc4536 Reviewed-on: https://gerrit.libreoffice.org/77892 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'package')
-rw-r--r--package/source/xstor/owriteablestream.cxx41
1 files changed, 16 insertions, 25 deletions
diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx
index 041363cb5142..1c9332e9e845 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -930,43 +930,34 @@ uno::Sequence< beans::PropertyValue > OWriteStream_Impl::InsertOwnProps(
bool bUseCommonEncryption )
{
uno::Sequence< beans::PropertyValue > aResult( aProps );
- sal_Int32 nLen = aResult.getLength();
+ beans::PropertyValue aPropVal;
if ( m_nStorageType == embed::StorageFormats::PACKAGE )
{
- for ( sal_Int32 nInd = 0; nInd < nLen; nInd++ )
- if ( aResult[nInd].Name == "UseCommonStoragePasswordEncryption" )
- {
- aResult[nInd].Value <<= bUseCommonEncryption;
- return aResult;
- }
-
- aResult.realloc( ++nLen );
- aResult[nLen - 1].Name = "UseCommonStoragePasswordEncryption";
- aResult[nLen - 1].Value <<= bUseCommonEncryption;
+ aPropVal.Name = "UseCommonStoragePasswordEncryption";
+ aPropVal.Value <<= bUseCommonEncryption;
}
else if ( m_nStorageType == embed::StorageFormats::OFOPXML )
{
ReadRelInfoIfNecessary();
- uno::Any aValue;
+ aPropVal.Name = "RelationsInfo";
if ( m_nRelInfoStatus == RELINFO_READ )
- aValue <<= m_aOrigRelInfo;
+ aPropVal.Value <<= m_aOrigRelInfo;
else if ( m_nRelInfoStatus == RELINFO_CHANGED_STREAM_READ || m_nRelInfoStatus == RELINFO_CHANGED )
- aValue <<= m_aNewRelInfo;
+ aPropVal.Value <<= m_aNewRelInfo;
else // m_nRelInfoStatus == RELINFO_CHANGED_BROKEN || m_nRelInfoStatus == RELINFO_BROKEN
throw io::IOException( "Wrong relinfo stream!" );
-
- for ( sal_Int32 nInd = 0; nInd < nLen; nInd++ )
- if ( aResult[nInd].Name == "RelationsInfo" )
- {
- aResult[nInd].Value = aValue;
- return aResult;
- }
-
- aResult.realloc( ++nLen );
- aResult[nLen - 1].Name = "RelationsInfo";
- aResult[nLen - 1].Value = aValue;
+ }
+ if (!aPropVal.Name.isEmpty())
+ {
+ sal_Int32 i = 0;
+ for (auto p = aResult.getConstArray(); i < aResult.getLength(); ++i)
+ if (p[i].Name == aPropVal.Name)
+ break;
+ if (i == aResult.getLength())
+ aResult.realloc(i + 1);
+ aResult[i] = aPropVal;
}
return aResult;