[Libreoffice-commits] core.git: package/source
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Thu Aug 22 04:58:36 UTC 2019
package/source/xstor/owriteablestream.cxx | 41 +++++++++++-------------------
1 file changed, 16 insertions(+), 25 deletions(-)
New commits:
commit 0d1490dbbdd6a4cbe2486f993517383cc8112003
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Wed Aug 21 17:00:35 2019 +0200
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Thu Aug 22 06:57:52 2019 +0200
Deduplicate some code
Change-Id: I2cdc9f1416a9089e91f30cebe071a4855edc4536
Reviewed-on: https://gerrit.libreoffice.org/77892
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
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;
More information about the Libreoffice-commits
mailing list