summaryrefslogtreecommitdiff
path: root/comphelper/source/misc
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-10-28 21:14:28 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-10-29 10:31:35 +0200
commit5661f257f9edd8bc80bb9dc62855d6bbe88a541f (patch)
treee3d240eef9700bbb45d6f364cc71c2425369d2c6 /comphelper/source/misc
parentda5143365264aaa4634278fe13c36ba6b3039e47 (diff)
Prepare for removal of non-const operator[] from Sequence in comphelper
Change-Id: Ie4f3675adc888ecf175c5342c87d416f34f8dce1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124351 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'comphelper/source/misc')
-rw-r--r--comphelper/source/misc/docpasswordhelper.cxx42
-rw-r--r--comphelper/source/misc/documentinfo.cxx5
-rw-r--r--comphelper/source/misc/graphicmimetype.cxx6
-rw-r--r--comphelper/source/misc/mimeconfighelper.cxx85
-rw-r--r--comphelper/source/misc/storagehelper.cxx114
5 files changed, 104 insertions, 148 deletions
diff --git a/comphelper/source/misc/docpasswordhelper.cxx b/comphelper/source/misc/docpasswordhelper.cxx
index 81ed4bcfed77..71f92db48d00 100644
--- a/comphelper/source/misc/docpasswordhelper.cxx
+++ b/comphelper/source/misc/docpasswordhelper.cxx
@@ -23,6 +23,7 @@
#include <string_view>
#include <comphelper/docpasswordhelper.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <comphelper/storagehelper.hxx>
#include <comphelper/hash.hxx>
#include <comphelper/base64.hxx>
@@ -95,15 +96,10 @@ uno::Sequence< beans::PropertyValue > DocPasswordHelper::GenerateNewModifyPasswo
uno::Sequence< sal_Int8 > aNewHash = GeneratePBKDF2Hash(aPassword, aSalt, nPBKDF2IterationCount, 16);
if ( aNewHash.hasElements() )
{
- aResult.realloc( 4 );
- aResult[0].Name = "algorithm-name";
- aResult[0].Value <<= OUString( "PBKDF2" );
- aResult[1].Name = "salt";
- aResult[1].Value <<= aSalt;
- aResult[2].Name = "iteration-count";
- aResult[2].Value <<= nPBKDF2IterationCount;
- aResult[3].Name = "hash";
- aResult[3].Value <<= aNewHash;
+ aResult = { comphelper::makePropertyValue("algorithm-name", OUString( "PBKDF2" )),
+ comphelper::makePropertyValue("salt", aSalt),
+ comphelper::makePropertyValue("iteration-count", nPBKDF2IterationCount),
+ comphelper::makePropertyValue("hash", aNewHash) };
}
return aResult;
@@ -128,15 +124,10 @@ DocPasswordHelper::GenerateNewModifyPasswordInfoOOXML(std::u16string_view aPassw
if (!sHash.isEmpty())
{
- aResult.realloc(4);
- aResult[0].Name = "algorithm-name";
- aResult[0].Value <<= sAlgorithm;
- aResult[1].Name = "salt";
- aResult[1].Value <<= sSalt;
- aResult[2].Name = "iteration-count";
- aResult[2].Value <<= nIterationCount;
- aResult[3].Name = "hash";
- aResult[3].Value <<= sHash;
+ aResult = { comphelper::makePropertyValue("algorithm-name", sAlgorithm),
+ comphelper::makePropertyValue("salt", sSalt),
+ comphelper::makePropertyValue("iteration-count", nIterationCount),
+ comphelper::makePropertyValue("hash", sHash) };
}
return aResult;
@@ -611,7 +602,7 @@ OUString DocPasswordHelper::GetOoxHashAsBase64(
if ( !rGpgProperties.hasElements() )
return uno::Sequence< beans::NamedValue >();
- uno::Sequence< beans::NamedValue > aEncryptionData(1);
+ uno::Sequence< beans::NamedValue > aEncryptionData;
std::unique_ptr<GpgME::Context> ctx;
GpgME::initializeLibrary();
GpgME::Error err = GpgME::checkEngine(GpgME::OpenPGP);
@@ -666,19 +657,16 @@ OUString DocPasswordHelper::GetOoxHashAsBase64(
SAL_INFO("comphelper.crypto", "Extracted gpg session key of length: " << len);
- aEncryptionData[0].Name = PACKAGE_ENCRYPTIONDATA_SHA256UTF8;
- aEncryptionData[0].Value <<= aKeyValue;
+ aEncryptionData = { { PACKAGE_ENCRYPTIONDATA_SHA256UTF8, uno::Any(aKeyValue) } };
break;
}
}
- if ( aEncryptionData[0].Value.hasValue() )
+ if ( aEncryptionData.hasElements() )
{
- uno::Sequence< beans::NamedValue > aContainer(2);
- aContainer[0].Name = "GpgInfos";
- aContainer[0].Value <<= rGpgProperties;
- aContainer[1].Name = "EncryptionKey";
- aContainer[1].Value <<= aEncryptionData;
+ uno::Sequence< beans::NamedValue > aContainer{
+ { "GpgInfos", uno::Any(rGpgProperties) }, { "EncryptionKey", uno::Any(aEncryptionData) }
+ };
return aContainer;
}
diff --git a/comphelper/source/misc/documentinfo.cxx b/comphelper/source/misc/documentinfo.cxx
index 60901fefeefe..0a1c04347c84 100644
--- a/comphelper/source/misc/documentinfo.cxx
+++ b/comphelper/source/misc/documentinfo.cxx
@@ -166,8 +166,9 @@ namespace comphelper {
css::uno::Sequence<css::beans::PropertyValue> aMedDescr = rModel->getArgs();
sal_Int32 nNewLen = aMedDescr.getLength() + 1;
aMedDescr.realloc(nNewLen);
- aMedDescr[nNewLen-1].Name = "MacroEventRead";
- aMedDescr[nNewLen-1].Value <<= true;
+ auto pMedDescr = aMedDescr.getArray();
+ pMedDescr[nNewLen-1].Name = "MacroEventRead";
+ pMedDescr[nNewLen-1].Value <<= true;
rModel->attachResource(rModel->getURL(), aMedDescr);
}
diff --git a/comphelper/source/misc/graphicmimetype.cxx b/comphelper/source/misc/graphicmimetype.cxx
index acee8ff80de7..4448c832971f 100644
--- a/comphelper/source/misc/graphicmimetype.cxx
+++ b/comphelper/source/misc/graphicmimetype.cxx
@@ -27,6 +27,7 @@
#include <com/sun/star/uno/Reference.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/propertyvalue.hxx>
using namespace css;
using namespace css::beans;
@@ -81,9 +82,8 @@ GraphicMimeTypeHelper::GetMimeTypeForImageStream(const Reference<XInputStream>&
// Create the graphic to retrieve the mimetype from it
Reference<XGraphicProvider> xProvider
= css::graphic::GraphicProvider::create(comphelper::getProcessComponentContext());
- Sequence<PropertyValue> aMediaProperties(1);
- aMediaProperties[0].Name = "InputStream";
- aMediaProperties[0].Value <<= xInputStream;
+ Sequence<PropertyValue> aMediaProperties{ comphelper::makePropertyValue("InputStream",
+ xInputStream) };
Reference<XGraphic> xGraphic(xProvider->queryGraphic(aMediaProperties));
return GetMimeTypeForXGraphic(xGraphic);
diff --git a/comphelper/source/misc/mimeconfighelper.cxx b/comphelper/source/misc/mimeconfighelper.cxx
index 3093aef3a9f6..82867b7bae48 100644
--- a/comphelper/source/misc/mimeconfighelper.cxx
+++ b/comphelper/source/misc/mimeconfighelper.cxx
@@ -88,6 +88,7 @@ uno::Sequence< sal_Int8 > MimeConfigurationHelper::GetSequenceClassIDRepresentat
{
OString aCharClassID = OUStringToOString( aClassID, RTL_TEXTENCODING_ASCII_US );
uno::Sequence< sal_Int8 > aResult( 16 );
+ auto pResult = aResult.getArray();
sal_Int32 nStrPointer = 0;
sal_Int32 nSeqInd = 0;
@@ -99,7 +100,7 @@ uno::Sequence< sal_Int8 > MimeConfigurationHelper::GetSequenceClassIDRepresentat
if ( nDigit1 > 15 || nDigit2 > 15 )
break;
- aResult[nSeqInd++] = static_cast<sal_Int8>( nDigit1 * 16 + nDigit2 );
+ pResult[nSeqInd++] = static_cast<sal_Int8>( nDigit1 * 16 + nDigit2 );
if ( nStrPointer < nLength && aCharClassID[nStrPointer] == '-' )
nStrPointer++;
@@ -296,15 +297,16 @@ uno::Sequence< beans::NamedValue > MimeConfigurationHelper::GetObjPropsFromConfi
{
try
{
- uno::Sequence< OUString > aObjPropNames = xObjectProps->getElementNames();
+ const uno::Sequence< OUString > aObjPropNames = xObjectProps->getElementNames();
aResult.realloc( aObjPropNames.getLength() + 1 );
- aResult[0].Name = "ClassID";
- aResult[0].Value <<= aClassID;
+ auto pResult = aResult.getArray();
+ pResult[0].Name = "ClassID";
+ pResult[0].Value <<= aClassID;
for ( sal_Int32 nInd = 0; nInd < aObjPropNames.getLength(); nInd++ )
{
- aResult[nInd + 1].Name = aObjPropNames[nInd];
+ pResult[nInd + 1].Name = aObjPropNames[nInd];
if ( aObjPropNames[nInd] == "ObjectVerbs" )
{
@@ -312,14 +314,15 @@ uno::Sequence< beans::NamedValue > MimeConfigurationHelper::GetObjPropsFromConfi
if ( !(xObjectProps->getByName( aObjPropNames[nInd] ) >>= aVerbShortcuts) )
throw uno::RuntimeException();
uno::Sequence< embed::VerbDescriptor > aVerbDescriptors( aVerbShortcuts.getLength() );
+ auto aVerbDescriptorsRange = asNonConstRange(aVerbDescriptors);
for ( sal_Int32 nVerbI = 0; nVerbI < aVerbShortcuts.getLength(); nVerbI++ )
- if ( !GetVerbByShortcut( aVerbShortcuts[nVerbI], aVerbDescriptors[nVerbI] ) )
+ if ( !GetVerbByShortcut( aVerbShortcuts[nVerbI], aVerbDescriptorsRange[nVerbI] ) )
throw uno::RuntimeException();
- aResult[nInd+1].Value <<= aVerbDescriptors;
+ pResult[nInd+1].Value <<= aVerbDescriptors;
}
else
- aResult[nInd+1].Value = xObjectProps->getByName( aObjPropNames[nInd] );
+ pResult[nInd+1].Value = xObjectProps->getByName( aObjPropNames[nInd] );
}
}
catch( uno::Exception& )
@@ -359,11 +362,9 @@ uno::Sequence< beans::NamedValue > MimeConfigurationHelper::GetObjectPropsByStri
uno::Sequence< sal_Int8 > aClassID = GetSequenceClassIDRepresentation( aStringClassID );
if ( ClassIDsEqual( aClassID, GetSequenceClassID( SO3_DUMMY_CLASSID ) ) )
{
- aObjProps.realloc(2);
- aObjProps[0].Name = "ObjectFactory";
- aObjProps[0].Value <<= OUString( "com.sun.star.embed.OOoSpecialEmbeddedObjectFactory" );
- aObjProps[1].Name = "ClassID";
- aObjProps[1].Value <<= aClassID;
+ aObjProps = { { "ObjectFactory",
+ uno::Any(OUString("com.sun.star.embed.OOoSpecialEmbeddedObjectFactory")) },
+ { "ClassID", uno::Any(aClassID) } };
return aObjProps;
}
@@ -392,11 +393,9 @@ uno::Sequence< beans::NamedValue > MimeConfigurationHelper::GetObjectPropsByClas
uno::Sequence< beans::NamedValue > aObjProps;
if ( ClassIDsEqual( aClassID, GetSequenceClassID( SO3_DUMMY_CLASSID ) ) )
{
- aObjProps.realloc(2);
- aObjProps[0].Name = "ObjectFactory";
- aObjProps[0].Value <<= OUString( "com.sun.star.embed.OOoSpecialEmbeddedObjectFactory" );
- aObjProps[1].Name = "ClassID";
- aObjProps[1].Value <<= aClassID;
+ aObjProps = { { "ObjectFactory",
+ uno::Any(OUString("com.sun.star.embed.OOoSpecialEmbeddedObjectFactory")) },
+ { "ClassID", uno::Any(aClassID) } };
}
OUString aStringClassID = GetStringClassIDRepresentation( aClassID );
@@ -590,8 +589,9 @@ OUString MimeConfigurationHelper::UpdateMediaDescriptorWithFilterName(
{
sal_Int32 nOldLen = aMediaDescr.getLength();
aMediaDescr.realloc( nOldLen + 1 );
- aMediaDescr[nOldLen].Name = "FilterName";
- aMediaDescr[ nOldLen ].Value <<= aFilterName;
+ auto pMediaDescr = aMediaDescr.getArray();
+ pMediaDescr[nOldLen].Name = "FilterName";
+ pMediaDescr[ nOldLen ].Value <<= aFilterName;
}
else if ( !aTypeName.isEmpty() && !bIgnoreType )
@@ -607,8 +607,9 @@ OUString MimeConfigurationHelper::UpdateMediaDescriptorWithFilterName(
{
sal_Int32 nOldLen = aMediaDescr.getLength();
aMediaDescr.realloc( nOldLen + 1 );
- aMediaDescr[nOldLen].Name = "FilterName";
- aMediaDescr[ nOldLen ].Value = prop.Value;
+ auto pMediaDescr = aMediaDescr.getArray();
+ pMediaDescr[nOldLen].Name = "FilterName";
+ pMediaDescr[ nOldLen ].Value = prop.Value;
break;
}
}
@@ -638,7 +639,7 @@ OUString MimeConfigurationHelper::UpdateMediaDescriptorWithFilterName(
for ( sal_Int32 nMedInd = 0; nMedInd < aMediaDescr.getLength(); nMedInd++ )
if ( aMediaDescr[nMedInd].Name == "DocumentService" )
{
- aMediaDescr[nMedInd].Value <<= aDocName;
+ aMediaDescr.getArray()[nMedInd].Value <<= aDocName;
bNeedsAddition = false;
break;
}
@@ -647,8 +648,9 @@ OUString MimeConfigurationHelper::UpdateMediaDescriptorWithFilterName(
{
sal_Int32 nOldLen = aMediaDescr.getLength();
aMediaDescr.realloc( nOldLen + 1 );
- aMediaDescr[nOldLen].Name = "DocumentService";
- aMediaDescr[nOldLen].Value <<= aDocName;
+ auto pMediaDescr = aMediaDescr.getArray();
+ pMediaDescr[nOldLen].Name = "DocumentService";
+ pMediaDescr[nOldLen].Value <<= aDocName;
}
return UpdateMediaDescriptorWithFilterName( aMediaDescr, true );
@@ -870,23 +872,22 @@ uno::Sequence< sal_Int8 > MimeConfigurationHelper::GetSequenceClassID( sal_uInt3
sal_uInt8 b8, sal_uInt8 b9, sal_uInt8 b10, sal_uInt8 b11,
sal_uInt8 b12, sal_uInt8 b13, sal_uInt8 b14, sal_uInt8 b15 )
{
- uno::Sequence< sal_Int8 > aResult( 16 );
- aResult[0] = static_cast<sal_Int8>( n1 >> 24 );
- aResult[1] = static_cast<sal_Int8>( ( n1 << 8 ) >> 24 );
- aResult[2] = static_cast<sal_Int8>( ( n1 << 16 ) >> 24 );
- aResult[3] = static_cast<sal_Int8>( ( n1 << 24 ) >> 24 );
- aResult[4] = static_cast<sal_Int8>( n2 >> 8 );
- aResult[5] = static_cast<sal_Int8>( ( n2 << 8 ) >> 8 );
- aResult[6] = static_cast<sal_Int8>( n3 >> 8 );
- aResult[7] = static_cast<sal_Int8>( ( n3 << 8 ) >> 8 );
- aResult[8] = b8;
- aResult[9] = b9;
- aResult[10] = b10;
- aResult[11] = b11;
- aResult[12] = b12;
- aResult[13] = b13;
- aResult[14] = b14;
- aResult[15] = b15;
+ uno::Sequence< sal_Int8 > aResult{ /* [ 0] */ static_cast<sal_Int8>( n1 >> 24 ),
+ /* [ 1] */ static_cast<sal_Int8>( ( n1 << 8 ) >> 24 ),
+ /* [ 2] */ static_cast<sal_Int8>( ( n1 << 16 ) >> 24 ),
+ /* [ 3] */ static_cast<sal_Int8>( ( n1 << 24 ) >> 24 ),
+ /* [ 4] */ static_cast<sal_Int8>( n2 >> 8 ),
+ /* [ 5] */ static_cast<sal_Int8>( ( n2 << 8 ) >> 8 ),
+ /* [ 6] */ static_cast<sal_Int8>( n3 >> 8 ),
+ /* [ 7] */ static_cast<sal_Int8>( ( n3 << 8 ) >> 8 ),
+ /* [ 8] */ static_cast<sal_Int8>( b8 ),
+ /* [ 9] */ static_cast<sal_Int8>( b9 ),
+ /* [10] */ static_cast<sal_Int8>( b10 ),
+ /* [11] */ static_cast<sal_Int8>( b11 ),
+ /* [12] */ static_cast<sal_Int8>( b12 ),
+ /* [13] */ static_cast<sal_Int8>( b13 ),
+ /* [14] */ static_cast<sal_Int8>( b14 ),
+ /* [15] */ static_cast<sal_Int8>( b15 ) };
return aResult;
}
diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx
index 689c1c98d870..13e9eb3aa288 100644
--- a/comphelper/source/misc/storagehelper.cxx
+++ b/comphelper/source/misc/storagehelper.cxx
@@ -52,6 +52,7 @@
#include <comphelper/hash.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/documentconstants.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <comphelper/storagehelper.hxx>
#include <comphelper/sequence.hxx>
#include <cppuhelper/exc_hlp.hxx>
@@ -98,10 +99,7 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromURL(
sal_Int32 nStorageMode,
const uno::Reference< uno::XComponentContext >& rxContext )
{
- uno::Sequence< uno::Any > aArgs( 2 );
- aArgs[0] <<= aURL;
- aArgs[1] <<= nStorageMode;
-
+ uno::Sequence< uno::Any > aArgs{ uno::Any(aURL), uno::Any(nStorageMode) };
uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( rxContext )->createInstanceWithArguments( aArgs ),
uno::UNO_QUERY_THROW );
return xTempStorage;
@@ -113,9 +111,7 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromURL2(
sal_Int32 nStorageMode,
const uno::Reference< uno::XComponentContext >& rxContext )
{
- uno::Sequence< uno::Any > aArgs( 2 );
- aArgs[0] <<= aURL;
- aArgs[1] <<= nStorageMode;
+ uno::Sequence< uno::Any > aArgs{ uno::Any(aURL), uno::Any(nStorageMode) };
uno::Reference< lang::XSingleServiceFactory > xFact;
css::uno::Any anyEx;
@@ -151,10 +147,7 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromInputStream(
const uno::Reference < io::XInputStream >& xStream,
const uno::Reference< uno::XComponentContext >& rxContext )
{
- uno::Sequence< uno::Any > aArgs( 2 );
- aArgs[0] <<= xStream;
- aArgs[1] <<= embed::ElementModes::READ;
-
+ uno::Sequence< uno::Any > aArgs{ uno::Any(xStream), uno::Any(embed::ElementModes::READ) };
uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( rxContext )->createInstanceWithArguments( aArgs ),
uno::UNO_QUERY_THROW );
return xTempStorage;
@@ -166,10 +159,7 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromStream(
sal_Int32 nStorageMode,
const uno::Reference< uno::XComponentContext >& rxContext )
{
- uno::Sequence< uno::Any > aArgs( 2 );
- aArgs[0] <<= xStream;
- aArgs[1] <<= nStorageMode;
-
+ uno::Sequence< uno::Any > aArgs{ uno::Any(xStream), uno::Any(nStorageMode) };
uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( rxContext )->createInstanceWithArguments( aArgs ),
uno::UNO_QUERY_THROW );
return xTempStorage;
@@ -303,15 +293,10 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageOfFormatFromURL(
sal_Int32 nStorageMode,
const uno::Reference< uno::XComponentContext >& rxContext )
{
- uno::Sequence< beans::PropertyValue > aProps( 1 );
- aProps[0].Name = "StorageFormat";
- aProps[0].Value <<= aFormat;
-
- uno::Sequence< uno::Any > aArgs( 3 );
- aArgs[0] <<= aURL;
- aArgs[1] <<= nStorageMode;
- aArgs[2] <<= aProps;
+ uno::Sequence< beans::PropertyValue > aProps{ comphelper::makePropertyValue("StorageFormat",
+ aFormat) };
+ uno::Sequence< uno::Any > aArgs{ uno::Any(aURL), uno::Any(nStorageMode), uno::Any(aProps) };
uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( rxContext )->createInstanceWithArguments( aArgs ),
uno::UNO_QUERY_THROW );
return xTempStorage;
@@ -324,24 +309,17 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageOfFormatFromInputStr
const uno::Reference< uno::XComponentContext >& rxContext,
bool bRepairStorage )
{
- uno::Sequence< beans::PropertyValue > aProps( 1 );
- sal_Int32 nPos = 0;
- aProps[nPos].Name = "StorageFormat";
- aProps[nPos].Value <<= aFormat;
- ++nPos;
+ uno::Sequence< beans::PropertyValue > aProps( bRepairStorage ? 2 : 1 );
+ auto pProps = aProps.getArray();
+ pProps[0].Name = "StorageFormat";
+ pProps[0].Value <<= aFormat;
if ( bRepairStorage )
{
- aProps.realloc(nPos+1);
- aProps[nPos].Name = "RepairPackage";
- aProps[nPos].Value <<= bRepairStorage;
- ++nPos;
+ pProps[1].Name = "RepairPackage";
+ pProps[1].Value <<= bRepairStorage;
}
- uno::Sequence< uno::Any > aArgs( 3 );
- aArgs[0] <<= xStream;
- aArgs[1] <<= embed::ElementModes::READ;
- aArgs[2] <<= aProps;
-
+ uno::Sequence< uno::Any > aArgs{ uno::Any(xStream), uno::Any(embed::ElementModes::READ), uno::Any(aProps) };
uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( rxContext )->createInstanceWithArguments( aArgs ),
uno::UNO_QUERY_THROW );
return xTempStorage;
@@ -355,24 +333,17 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageOfFormatFromStream(
const uno::Reference< uno::XComponentContext >& rxContext,
bool bRepairStorage )
{
- uno::Sequence< beans::PropertyValue > aProps( 1 );
- sal_Int32 nPos = 0;
- aProps[nPos].Name = "StorageFormat";
- aProps[nPos].Value <<= aFormat;
- ++nPos;
+ uno::Sequence< beans::PropertyValue > aProps( bRepairStorage ? 2 : 1 );
+ auto pProps = aProps.getArray();
+ pProps[0].Name = "StorageFormat";
+ pProps[0].Value <<= aFormat;
if ( bRepairStorage )
{
- aProps.realloc(nPos+1);
- aProps[nPos].Name = "RepairPackage";
- aProps[nPos].Value <<= bRepairStorage;
- ++nPos;
+ pProps[1].Name = "RepairPackage";
+ pProps[1].Value <<= bRepairStorage;
}
- uno::Sequence< uno::Any > aArgs( 3 );
- aArgs[0] <<= xStream;
- aArgs[1] <<= nStorageMode;
- aArgs[2] <<= aProps;
-
+ uno::Sequence< uno::Any > aArgs{ uno::Any(xStream), uno::Any(nStorageMode), uno::Any(aProps) };
uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( rxContext )->createInstanceWithArguments( aArgs ),
uno::UNO_QUERY_THROW );
return xTempStorage;
@@ -398,9 +369,8 @@ uno::Sequence< beans::NamedValue > OStorageHelper::CreatePackageEncryptionData(
xDigestContext->updateDigest( uno::Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aUTF8Password.getStr() ), aUTF8Password.getLength() ) );
uno::Sequence< sal_Int8 > aDigest = xDigestContext->finalizeDigestAndDispose();
- aEncryptionData.realloc( ++nSha1Ind );
- aEncryptionData[0].Name = PACKAGE_ENCRYPTIONDATA_SHA256UTF8;
- aEncryptionData[0].Value <<= aDigest;
+ ++nSha1Ind;
+ aEncryptionData = { { PACKAGE_ENCRYPTIONDATA_SHA256UTF8, uno::Any(aDigest) } };
}
catch ( uno::Exception& )
{
@@ -411,9 +381,10 @@ uno::Sequence< beans::NamedValue > OStorageHelper::CreatePackageEncryptionData(
// this encoding supports only a minor subset of nonascii characters,
// but for compatibility reasons it has to be used for old document formats
aEncryptionData.realloc( nSha1Ind + 3 );
+ auto pEncryptionData = aEncryptionData.getArray();
// these are StarOffice not-quite-SHA1
- aEncryptionData[nSha1Ind].Name = PACKAGE_ENCRYPTIONDATA_SHA1UTF8;
- aEncryptionData[nSha1Ind + 1].Name = PACKAGE_ENCRYPTIONDATA_SHA1MS1252;
+ pEncryptionData[nSha1Ind].Name = PACKAGE_ENCRYPTIONDATA_SHA1UTF8;
+ pEncryptionData[nSha1Ind + 1].Name = PACKAGE_ENCRYPTIONDATA_SHA1MS1252;
rtl_TextEncoding const pEncoding[2] = { RTL_TEXTENCODING_UTF8, RTL_TEXTENCODING_MS_1252 };
@@ -434,16 +405,16 @@ uno::Sequence< beans::NamedValue > OStorageHelper::CreatePackageEncryptionData(
}
// coverity[overrun-buffer-arg : FALSE] - coverity has difficulty with css::uno::Sequence
- aEncryptionData[nSha1Ind+nInd].Value <<= uno::Sequence< sal_Int8 >( reinterpret_cast<sal_Int8*>(pBuffer), RTL_DIGEST_LENGTH_SHA1 );
+ pEncryptionData[nSha1Ind+nInd].Value <<= uno::Sequence< sal_Int8 >( reinterpret_cast<sal_Int8*>(pBuffer), RTL_DIGEST_LENGTH_SHA1 );
}
// actual SHA1
- aEncryptionData[nSha1Ind + 2].Name = PACKAGE_ENCRYPTIONDATA_SHA1CORRECT;
+ pEncryptionData[nSha1Ind + 2].Name = PACKAGE_ENCRYPTIONDATA_SHA1CORRECT;
OString aByteStrPass = OUStringToOString(aPassword, RTL_TEXTENCODING_UTF8);
std::vector<unsigned char> const sha1(::comphelper::Hash::calculateHash(
reinterpret_cast<unsigned char const*>(aByteStrPass.getStr()), aByteStrPass.getLength(),
::comphelper::HashType::SHA1));
- aEncryptionData[nSha1Ind + 2].Value <<= uno::Sequence<sal_Int8>(
+ pEncryptionData[nSha1Ind + 2].Value <<= uno::Sequence<sal_Int8>(
reinterpret_cast<sal_Int8 const*>(sha1.data()), sha1.size());
}
@@ -464,10 +435,7 @@ uno::Sequence< beans::NamedValue > OStorageHelper::CreateGpgPackageEncryptionDat
rtl_random_destroyPool(aRandomPool);
- uno::Sequence< beans::NamedValue > aContainer(2);
std::vector< uno::Sequence< beans::NamedValue > > aGpgEncryptions;
- uno::Sequence< beans::NamedValue > aGpgEncryptionEntry(3);
- uno::Sequence< beans::NamedValue > aEncryptionData(1);
uno::Reference< security::XDocumentDigitalSignatures > xSigner(
// here none of the version-dependent methods are called
@@ -537,23 +505,21 @@ uno::Sequence< beans::NamedValue > OStorageHelper::CreateGpgPackageEncryptionDat
SAL_INFO("comphelper.crypto", "Generated gpg crypto of length: " << len);
- aGpgEncryptionEntry[0].Name = "KeyId";
- aGpgEncryptionEntry[0].Value <<= aKeyID;
- aGpgEncryptionEntry[1].Name = "KeyPacket";
- aGpgEncryptionEntry[1].Value <<= aKeyID;
- aGpgEncryptionEntry[2].Name = "CipherValue";
- aGpgEncryptionEntry[2].Value <<= aCipherValue;
+ uno::Sequence< beans::NamedValue > aGpgEncryptionEntry{
+ { "KeyId", uno::Any(aKeyID) },
+ { "KeyPacket", uno::Any(aKeyID) },
+ { "CipherValue", uno::Any(aCipherValue) }
+ };
aGpgEncryptions.push_back(aGpgEncryptionEntry);
}
- aEncryptionData[0].Name = PACKAGE_ENCRYPTIONDATA_SHA256UTF8;
- aEncryptionData[0].Value <<= aVector;
+ uno::Sequence<beans::NamedValue> aEncryptionData
+ = { { PACKAGE_ENCRYPTIONDATA_SHA256UTF8, uno::Any(aVector) } };
- aContainer[0].Name = "GpgInfos";
- aContainer[0].Value <<= comphelper::containerToSequence(aGpgEncryptions);
- aContainer[1].Name = "EncryptionKey";
- aContainer[1].Value <<= aEncryptionData;
+ uno::Sequence<beans::NamedValue> aContainer
+ = { { "GpgInfos", uno::Any(comphelper::containerToSequence(aGpgEncryptions)) },
+ { "EncryptionKey", uno::Any(aEncryptionData) } };
return aContainer;
#else