summaryrefslogtreecommitdiff
path: root/comphelper
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
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')
-rw-r--r--comphelper/source/container/embeddedobjectcontainer.cxx88
-rw-r--r--comphelper/source/eventattachermgr/eventattachermgr.cxx4
-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
-rw-r--r--comphelper/source/xml/ofopxmlhelper.cxx40
8 files changed, 172 insertions, 212 deletions
diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx b/comphelper/source/container/embeddedobjectcontainer.cxx
index faed14065082..ac85e9cfdc70 100644
--- a/comphelper/source/container/embeddedobjectcontainer.cxx
+++ b/comphelper/source/container/embeddedobjectcontainer.cxx
@@ -42,6 +42,7 @@
#include <comphelper/embeddedobjectcontainer.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/propertysequence.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <cppuhelper/weakref.hxx>
#include <sal/log.hxx>
@@ -322,24 +323,24 @@ uno::Reference<embed::XEmbeddedObject> EmbeddedObjectContainer::Get_Impl(
//TODO/LATER: it would be good to detect an error when an object should be created already, but isn't (not an "inside" call)
uno::Reference < embed::XEmbeddedObjectCreator > xFactory = embed::EmbeddedObjectCreator::create( ::comphelper::getProcessComponentContext() );
uno::Sequence< beans::PropertyValue > aObjDescr(1 + (xCopy.is() ? 1 : 0) + (pBaseURL ? 1 : 0));
- aObjDescr[0].Name = "Parent";
- aObjDescr[0].Value <<= pImpl->m_xModel.get();
- sal_Int32 i = 1;
+ auto itObjDescr = aObjDescr.getArray();
+ itObjDescr->Name = "Parent";
+ itObjDescr->Value <<= pImpl->m_xModel.get();
if (pBaseURL)
{
- aObjDescr[i].Name = "DefaultParentBaseURL";
- aObjDescr[i].Value <<= *pBaseURL;
- ++i;
+ ++itObjDescr;
+ itObjDescr->Name = "DefaultParentBaseURL";
+ itObjDescr->Value <<= *pBaseURL;
}
if ( xCopy.is() )
{
- aObjDescr[i].Name = "CloneFrom";
- aObjDescr[i].Value <<= xCopy;
+ ++itObjDescr;
+ itObjDescr->Name = "CloneFrom";
+ itObjDescr->Value <<= xCopy;
}
- uno::Sequence< beans::PropertyValue > aMediaDescr( 1 );
- aMediaDescr[0].Name = "ReadOnly";
- aMediaDescr[0].Value <<= bReadOnlyMode;
+ uno::Sequence< beans::PropertyValue > aMediaDescr{ comphelper::makePropertyValue(
+ "ReadOnly", bReadOnlyMode) };
xObj.set( xFactory->createInstanceInitFromEntry(
pImpl->mxStorage, rName,
aMediaDescr, aObjDescr ), uno::UNO_QUERY );
@@ -371,14 +372,15 @@ uno::Reference < embed::XEmbeddedObject > EmbeddedObjectContainer::CreateEmbedde
const size_t nExtraArgs = pBaseURL ? 2 : 1;
uno::Sequence< beans::PropertyValue > aObjDescr( rArgs.getLength() + nExtraArgs );
- aObjDescr[0].Name = "Parent";
- aObjDescr[0].Value <<= pImpl->m_xModel.get();
+ auto pObjDescr = aObjDescr.getArray();
+ pObjDescr[0].Name = "Parent";
+ pObjDescr[0].Value <<= pImpl->m_xModel.get();
if (pBaseURL)
{
- aObjDescr[1].Name = "DefaultParentBaseURL";
- aObjDescr[1].Value <<= *pBaseURL;
+ pObjDescr[1].Name = "DefaultParentBaseURL";
+ pObjDescr[1].Value <<= *pBaseURL;
}
- std::copy( rArgs.begin(), rArgs.end(), aObjDescr.getArray() + nExtraArgs );
+ std::copy( rArgs.begin(), rArgs.end(), pObjDescr + nExtraArgs );
xObj.set( xFactory->createInstanceInitNew(
rClassId, OUString(), pImpl->mxStorage, rNewName,
aObjDescr ), uno::UNO_QUERY );
@@ -591,12 +593,13 @@ uno::Reference < embed::XEmbeddedObject > EmbeddedObjectContainer::InsertEmbedde
{
uno::Reference < embed::XEmbeddedObjectCreator > xFactory = embed::EmbeddedObjectCreator::create( ::comphelper::getProcessComponentContext() );
uno::Sequence< beans::PropertyValue > aObjDescr(pBaseURL ? 2 : 1);
- aObjDescr[0].Name = "Parent";
- aObjDescr[0].Value <<= pImpl->m_xModel.get();
+ auto pObjDescr = aObjDescr.getArray();
+ pObjDescr[0].Name = "Parent";
+ pObjDescr[0].Value <<= pImpl->m_xModel.get();
if (pBaseURL)
{
- aObjDescr[1].Name = "DefaultParentBaseURL";
- aObjDescr[1].Value <<= *pBaseURL;
+ pObjDescr[1].Name = "DefaultParentBaseURL";
+ pObjDescr[1].Value <<= *pBaseURL;
}
xObj.set( xFactory->createInstanceInitFromMediaDescriptor(
pImpl->mxStorage, rNewName, aMedium, aObjDescr ), uno::UNO_QUERY );
@@ -627,9 +630,8 @@ uno::Reference < embed::XEmbeddedObject > EmbeddedObjectContainer::InsertEmbedde
try
{
uno::Reference < embed::XEmbeddedObjectCreator > xFactory = embed::EmbeddedObjectCreator::create(::comphelper::getProcessComponentContext());
- uno::Sequence< beans::PropertyValue > aObjDescr( 1 );
- aObjDescr[0].Name = "Parent";
- aObjDescr[0].Value <<= pImpl->m_xModel.get();
+ uno::Sequence< beans::PropertyValue > aObjDescr{ comphelper::makePropertyValue(
+ "Parent", pImpl->m_xModel.get()) };
xObj.set( xFactory->createInstanceLink( pImpl->mxStorage, rNewName, aMedium, aObjDescr ), uno::UNO_QUERY );
uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY );
@@ -714,12 +716,10 @@ uno::Reference < embed::XEmbeddedObject > EmbeddedObjectContainer::CopyAndGetEmb
uno::Reference < embed::XEmbeddedObjectCreator > xCreator =
embed::EmbeddedObjectCreator::create( ::comphelper::getProcessComponentContext() );
- uno::Sequence< beans::PropertyValue > aMediaDescr( 1 );
- aMediaDescr[0].Name = "URL";
- aMediaDescr[0].Value <<= aURL;
- uno::Sequence< beans::PropertyValue > aObjDescr( 1 );
- aObjDescr[0].Name = "Parent";
- aObjDescr[0].Value <<= pImpl->m_xModel.get();
+ uno::Sequence< beans::PropertyValue > aMediaDescr{ comphelper::makePropertyValue(
+ "URL", aURL) };
+ uno::Sequence< beans::PropertyValue > aObjDescr{ comphelper::makePropertyValue(
+ "Parent", pImpl->m_xModel.get()) };
xResult.set(xCreator->createInstanceLink(
pImpl->mxStorage,
rName,
@@ -740,9 +740,8 @@ uno::Reference < embed::XEmbeddedObject > EmbeddedObjectContainer::CopyAndGetEmb
uno::Reference < embed::XEmbeddedObjectCreator > xCreator =
embed::EmbeddedObjectCreator::create( ::comphelper::getProcessComponentContext() );
- uno::Sequence< beans::PropertyValue > aObjDescr( 1 );
- aObjDescr[0].Name = "Parent";
- aObjDescr[0].Value <<= pImpl->m_xModel.get();
+ uno::Sequence< beans::PropertyValue > aObjDescr{ comphelper::makePropertyValue(
+ "Parent", pImpl->m_xModel.get()) };
xResult.set(xCreator->createInstanceInitNew(
xObj->getClassID(),
xObj->getClassName(),
@@ -1095,13 +1094,11 @@ bool EmbeddedObjectContainer::InsertGraphicStreamDirectly( const css::uno::Refer
uno::Reference < embed::XOptimizedStorage > xOptRepl( xReplacement, uno::UNO_QUERY_THROW );
// store it into the subfolder
- uno::Sequence< beans::PropertyValue > aProps( 3 );
- aProps[0].Name = "MediaType";
- aProps[0].Value <<= rMediaType;
- aProps[1].Name = "UseCommonStoragePasswordEncryption";
- aProps[1].Value <<= true;
- aProps[2].Name = "Compressed";
- aProps[2].Value <<= true;
+ uno::Sequence< beans::PropertyValue > aProps{
+ comphelper::makePropertyValue("MediaType", rMediaType),
+ comphelper::makePropertyValue("UseCommonStoragePasswordEncryption", true),
+ comphelper::makePropertyValue("Compressed", true)
+ };
if ( xReplacement->hasByName( rObjectName ) )
xReplacement->removeElement( rObjectName );
@@ -1226,17 +1223,18 @@ bool EmbeddedObjectContainer::StoreAsChildren(bool _bOasisFormat,bool _bCreateEm
if ( xPersist.is() )
{
uno::Sequence< beans::PropertyValue > aArgs( _bOasisFormat ? 2 : 3 );
- aArgs[0].Name = "StoreVisualReplacement";
- aArgs[0].Value <<= !_bOasisFormat;
+ auto pArgs = aArgs.getArray();
+ pArgs[0].Name = "StoreVisualReplacement";
+ pArgs[0].Value <<= !_bOasisFormat;
// if it is an embedded object or the optimized inserting fails the normal inserting should be done
- aArgs[1].Name = "CanTryOptimization";
- aArgs[1].Value <<= !_bCreateEmbedded;
+ pArgs[1].Name = "CanTryOptimization";
+ pArgs[1].Value <<= !_bCreateEmbedded;
if ( !_bOasisFormat )
{
// if object has no cached replacement it will use this one
- aArgs[2].Name = "VisualReplacement";
- aArgs[2].Value <<= xStream;
+ pArgs[2].Name = "VisualReplacement";
+ pArgs[2].Value <<= xStream;
}
try
diff --git a/comphelper/source/eventattachermgr/eventattachermgr.cxx b/comphelper/source/eventattachermgr/eventattachermgr.cxx
index 4a36c0f1192f..1fc4673b631a 100644
--- a/comphelper/source/eventattachermgr/eventattachermgr.cxx
+++ b/comphelper/source/eventattachermgr/eventattachermgr.cxx
@@ -358,9 +358,7 @@ ImplEventAttacherManager::ImplEventAttacherManager( const Reference< XIntrospect
Reference< XInitialization > xInit( xAttacher, UNO_QUERY );
if( xInit.is() )
{
- Sequence< Any > Arguments( 1 );
- Arguments[0] <<= rIntrospection;
- xInit->initialize( Arguments );
+ xInit->initialize({ Any(rIntrospection) });
}
}
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
diff --git a/comphelper/source/xml/ofopxmlhelper.cxx b/comphelper/source/xml/ofopxmlhelper.cxx
index 10840368d976..52f6c63568a9 100644
--- a/comphelper/source/xml/ofopxmlhelper.cxx
+++ b/comphelper/source/xml/ofopxmlhelper.cxx
@@ -328,8 +328,10 @@ void SAL_CALL OFOPXMLHelper_Impl::startElement( const OUString& aName, const uno
sal_Int32 nNewEntryNum = m_aResultSeq.getLength() + 1;
m_aResultSeq.realloc( nNewEntryNum );
+ auto pResultSeq = m_aResultSeq.getArray();
sal_Int32 nAttrNum = 0;
- m_aResultSeq[nNewEntryNum-1].realloc( 4 ); // the maximal expected number of arguments is 4
+ pResultSeq[nNewEntryNum-1].realloc( 4 ); // the maximal expected number of arguments is 4
+ auto pAttrs = pResultSeq[nNewEntryNum-1].getArray();
OUString aIDValue = xAttribs->getValueByName( g_aIDAttr );
if ( aIDValue.isEmpty() )
@@ -339,28 +341,28 @@ void SAL_CALL OFOPXMLHelper_Impl::startElement( const OUString& aName, const uno
OUString aTargetValue = xAttribs->getValueByName( g_aTargetAttr );
OUString aTargetModeValue = xAttribs->getValueByName( g_aTargetModeAttr );
- m_aResultSeq[nNewEntryNum-1][++nAttrNum - 1].First = g_aIDAttr;
- m_aResultSeq[nNewEntryNum-1][nAttrNum - 1].Second = aIDValue;
+ pAttrs[++nAttrNum - 1].First = g_aIDAttr;
+ pAttrs[nAttrNum - 1].Second = aIDValue;
if ( !aTypeValue.isEmpty() )
{
- m_aResultSeq[nNewEntryNum-1][++nAttrNum - 1].First = g_aTypeAttr;
- m_aResultSeq[nNewEntryNum-1][nAttrNum - 1].Second = aTypeValue;
+ pAttrs[++nAttrNum - 1].First = g_aTypeAttr;
+ pAttrs[nAttrNum - 1].Second = aTypeValue;
}
if ( !aTargetValue.isEmpty() )
{
- m_aResultSeq[nNewEntryNum-1][++nAttrNum - 1].First = g_aTargetAttr;
- m_aResultSeq[nNewEntryNum-1][nAttrNum - 1].Second = aTargetValue;
+ pAttrs[++nAttrNum - 1].First = g_aTargetAttr;
+ pAttrs[nAttrNum - 1].Second = aTargetValue;
}
if ( !aTargetModeValue.isEmpty() )
{
- m_aResultSeq[nNewEntryNum-1][++nAttrNum - 1].First = g_aTargetModeAttr;
- m_aResultSeq[nNewEntryNum-1][nAttrNum - 1].Second = aTargetModeValue;
+ pAttrs[++nAttrNum - 1].First = g_aTargetModeAttr;
+ pAttrs[nAttrNum - 1].Second = aTargetModeValue;
}
- m_aResultSeq[nNewEntryNum-1].realloc( nAttrNum );
+ pResultSeq[nNewEntryNum-1].realloc( nAttrNum );
}
else
throw css::xml::sax::SAXException(); // TODO: no other elements expected!
@@ -395,6 +397,8 @@ void SAL_CALL OFOPXMLHelper_Impl::startElement( const OUString& aName, const uno
if ( m_aResultSeq.getLength() != 2 )
throw uno::RuntimeException();
+ auto pResultSeq = m_aResultSeq.getArray();
+
const OUString aExtensionValue = xAttribs->getValueByName( g_aExtensionAttr );
if ( aExtensionValue.isEmpty() )
throw css::xml::sax::SAXException(); // TODO: the Extension value must present
@@ -404,10 +408,11 @@ void SAL_CALL OFOPXMLHelper_Impl::startElement( const OUString& aName, const uno
throw css::xml::sax::SAXException(); // TODO: the ContentType value must present
const sal_Int32 nNewResultLen = m_aResultSeq[0].getLength() + 1;
- m_aResultSeq[0].realloc( nNewResultLen );
+ pResultSeq[0].realloc( nNewResultLen );
+ auto pSeq = pResultSeq[0].getArray();
- m_aResultSeq[0][nNewResultLen-1].First = aExtensionValue;
- m_aResultSeq[0][nNewResultLen-1].Second = aContentTypeValue;
+ pSeq[nNewResultLen-1].First = aExtensionValue;
+ pSeq[nNewResultLen-1].Second = aContentTypeValue;
}
else if ( aName == g_aOverrideElement )
{
@@ -423,6 +428,8 @@ void SAL_CALL OFOPXMLHelper_Impl::startElement( const OUString& aName, const uno
if ( m_aResultSeq.getLength() != 2 )
throw uno::RuntimeException();
+ auto pResultSeq = m_aResultSeq.getArray();
+
OUString aPartNameValue = xAttribs->getValueByName( g_aPartNameAttr );
if ( aPartNameValue.isEmpty() )
throw css::xml::sax::SAXException(); // TODO: the PartName value must present
@@ -432,10 +439,11 @@ void SAL_CALL OFOPXMLHelper_Impl::startElement( const OUString& aName, const uno
throw css::xml::sax::SAXException(); // TODO: the ContentType value must present
sal_Int32 nNewResultLen = m_aResultSeq[1].getLength() + 1;
- m_aResultSeq[1].realloc( nNewResultLen );
+ pResultSeq[1].realloc( nNewResultLen );
+ auto pSeq = pResultSeq[1].getArray();
- m_aResultSeq[1][nNewResultLen-1].First = aPartNameValue;
- m_aResultSeq[1][nNewResultLen-1].Second = aContentTypeValue;
+ pSeq[nNewResultLen-1].First = aPartNameValue;
+ pSeq[nNewResultLen-1].Second = aContentTypeValue;
}
else
throw css::xml::sax::SAXException(); // TODO: no other elements expected!