diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-29 09:54:10 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-30 20:17:13 +0200 |
commit | d0a8d4a973b5ae395b6fa925e27c7a120a324f4a (patch) | |
tree | b2e527a20258a829bffc3918e4a7f81119411bbe /package | |
parent | ce9611d13ff69306f8c44ac53110cc2cb4116e85 (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')
-rw-r--r-- | package/qa/cppunit/test_package.cxx | 8 | ||||
-rw-r--r-- | package/source/xstor/owriteablestream.cxx | 34 | ||||
-rw-r--r-- | package/source/xstor/xfactory.cxx | 15 | ||||
-rw-r--r-- | package/source/xstor/xstorage.cxx | 68 | ||||
-rw-r--r-- | package/source/zipapi/XBufferedThreadedStream.cxx | 3 | ||||
-rw-r--r-- | package/source/zipapi/ZipFile.cxx | 3 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackage.cxx | 22 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackageFolder.cxx | 13 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackageStream.cxx | 74 | ||||
-rw-r--r-- | package/source/zippackage/zipfileaccess.cxx | 14 |
10 files changed, 131 insertions, 123 deletions
diff --git a/package/qa/cppunit/test_package.cxx b/package/qa/cppunit/test_package.cxx index 6f767295618c..022d8a9eea53 100644 --- a/package/qa/cppunit/test_package.cxx +++ b/package/qa/cppunit/test_package.cxx @@ -53,12 +53,8 @@ namespace BootstrapFixtureBase::setUp(); OUString aURL = m_directories.getURLFromSrc(u"/package/qa/cppunit/data/a2z.zip"); - uno::Sequence<beans::NamedValue> aNVs(1); - aNVs[0].Name = "URL"; - aNVs[0].Value <<= aURL; - - uno::Sequence<uno::Any> aArgs(1); - aArgs[0] <<= aNVs; + uno::Sequence<beans::NamedValue> aNVs{ { "URL", uno::Any(aURL) } }; + uno::Sequence<uno::Any> aArgs{ uno::Any(aNVs) }; uno::Reference<uno::XComponentContext> xCxt = comphelper::getProcessComponentContext(); uno::Reference<lang::XMultiComponentFactory> xSvcMgr = xCxt->getServiceManager(); 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(); diff --git a/package/source/xstor/xfactory.cxx b/package/source/xstor/xfactory.cxx index f369acca6fd2..575715dab15b 100644 --- a/package/source/xstor/xfactory.cxx +++ b/package/source/xstor/xfactory.cxx @@ -30,6 +30,7 @@ #include <com/sun/star/io/XSeekable.hpp> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/storagehelper.hxx> #include <cppuhelper/supportsservice.hxx> #include <cppuhelper/weak.hxx> @@ -161,9 +162,7 @@ uno::Reference< uno::XInterface > SAL_CALL OStorageFactory::createInstanceWithAr { if ( !aURL.isEmpty() ) { - aPropsToSet.realloc(1); - aPropsToSet[0].Name = "URL"; - aPropsToSet[0].Value <<= aURL; + aPropsToSet = { comphelper::makePropertyValue("URL", aURL) }; } sal_Int32 nNumArgs = 1; @@ -175,8 +174,9 @@ uno::Reference< uno::XInterface > SAL_CALL OStorageFactory::createInstanceWithAr || rProp.Name == "StatusIndicator" ) { aPropsToSet.realloc( ++nNumArgs ); - aPropsToSet[nNumArgs-1].Name = rProp.Name; - aPropsToSet[nNumArgs-1].Value = rProp.Value; + auto pPropsToSet = aPropsToSet.getArray(); + pPropsToSet[nNumArgs-1].Name = rProp.Name; + pPropsToSet[nNumArgs-1].Value = rProp.Value; } else if ( rProp.Name == "StorageFormat" ) { @@ -209,8 +209,9 @@ uno::Reference< uno::XInterface > SAL_CALL OStorageFactory::createInstanceWithAr { // Forward NoFileSync to the storage. aPropsToSet.realloc(++nNumArgs); - aPropsToSet[nNumArgs - 1].Name = rProp.Name; - aPropsToSet[nNumArgs - 1].Value = rProp.Value; + auto pPropsToSet = aPropsToSet.getArray(); + pPropsToSet[nNumArgs - 1].Name = rProp.Name; + pPropsToSet[nNumArgs - 1].Value = rProp.Value; } else OSL_FAIL( "Unacceptable property, will be ignored!" ); diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx index ddadab15afce..de84e2372bd3 100644 --- a/package/source/xstor/xstorage.cxx +++ b/package/source/xstor/xstorage.cxx @@ -120,15 +120,10 @@ void OStorage_Impl::completeStorageStreamCopy_Impl( // TODO: headers of encrypted streams should be copied also ::comphelper::OStorageHelper::CopyInputToOutput( xSourceInStream, xDestOutStream ); - uno::Sequence<OUString> aPropNames { "Compressed" }; + uno::Sequence<OUString> aPropNames { "Compressed", "MediaType", + "UseCommonStoragePasswordEncryption" }; - if ( nStorageType == embed::StorageFormats::PACKAGE ) - { - aPropNames.realloc( 3 ); - aPropNames[1] = "MediaType"; - aPropNames[2] = "UseCommonStoragePasswordEncryption"; - } - else if ( nStorageType == embed::StorageFormats::OFOPXML ) + if ( nStorageType == embed::StorageFormats::OFOPXML ) { // TODO/LATER: in future it might make sense to provide the stream if there is one uno::Reference< embed::XRelationshipAccess > xRelAccess( xDest, uno::UNO_QUERY_THROW ); @@ -136,7 +131,10 @@ void OStorage_Impl::completeStorageStreamCopy_Impl( xRelAccess->insertRelationships( aRelInfo, false ); aPropNames.realloc( 2 ); - aPropNames[1] = "MediaType"; + } + else if ( nStorageType != embed::StorageFormats::PACKAGE ) + { + aPropNames.realloc( 1 ); } for ( const auto& rPropName : std::as_const(aPropNames) ) @@ -409,18 +407,19 @@ void OStorage_Impl::OpenOwnPackage() if ( !m_xPackage.is() ) { uno::Sequence< uno::Any > aArguments( 2 ); + auto pArguments = aArguments.getArray(); if ( m_nStorageMode & embed::ElementModes::WRITE ) - aArguments[ 0 ] <<= m_xStream; + pArguments[ 0 ] <<= m_xStream; else { SAL_WARN_IF( !m_xInputStream.is(), "package.xstor", "Input stream must be set for readonly access!" ); - aArguments[ 0 ] <<= m_xInputStream; + pArguments[ 0 ] <<= m_xInputStream; // TODO: if input stream is not seekable or XSeekable interface is supported // on XStream object a wrapper must be used } // do not allow elements to remove themself from the old container in case of insertion to another container - aArguments[ 1 ] <<= beans::NamedValue( "AllowRemoveOnInsert", + pArguments[ 1 ] <<= beans::NamedValue( "AllowRemoveOnInsert", uno::makeAny( false ) ); sal_Int32 nArgNum = 2; @@ -433,7 +432,8 @@ void OStorage_Impl::OpenOwnPackage() // Forward these to the package. beans::NamedValue aNamedValue( rProp.Name, rProp.Value ); aArguments.realloc( ++nArgNum ); - aArguments[nArgNum-1] <<= aNamedValue; + pArguments = aArguments.getArray(); + pArguments[nArgNum-1] <<= aNamedValue; } else if ( rProp.Name == "Password" ) { @@ -449,7 +449,8 @@ void OStorage_Impl::OpenOwnPackage() aNamedValue.Name = "StorageFormat"; aNamedValue.Value <<= OUString( "ZipFormat" ); aArguments.realloc( ++nArgNum ); - aArguments[nArgNum-1] <<= aNamedValue; + pArguments = aArguments.getArray(); + pArguments[nArgNum-1] <<= aNamedValue; } else if ( m_nStorageType == embed::StorageFormats::OFOPXML ) { @@ -458,7 +459,8 @@ void OStorage_Impl::OpenOwnPackage() aNamedValue.Name = "StorageFormat"; aNamedValue.Value <<= OUString( "OFOPXMLFormat" ); aArguments.realloc( ++nArgNum ); - aArguments[nArgNum-1] <<= aNamedValue; + pArguments = aArguments.getArray(); + pArguments[nArgNum-1] <<= aNamedValue; } m_xPackage.set( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( @@ -770,16 +772,18 @@ void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement, if ( rSrcPkgProp.Name == "MediaType" || rSrcPkgProp.Name == "Compressed" ) { aStrProps.realloc( ++nNum ); - aStrProps[nNum-1].Name = rSrcPkgProp.Name; - aStrProps[nNum-1].Value = rSrcPkgProp.Value; + auto pStrProps = aStrProps.getArray(); + pStrProps[nNum-1].Name = rSrcPkgProp.Name; + pStrProps[nNum-1].Value = rSrcPkgProp.Value; } } if ( m_nStorageType == embed::StorageFormats::PACKAGE ) { aStrProps.realloc( ++nNum ); - aStrProps[nNum-1].Name = "UseCommonStoragePasswordEncryption"; - aStrProps[nNum-1].Value <<= pElement->m_xStream->UsesCommonEncryption_Impl(); + auto pStrProps = aStrProps.getArray(); + pStrProps[nNum-1].Name = "UseCommonStoragePasswordEncryption"; + pStrProps[nNum-1].Value <<= pElement->m_xStream->UsesCommonEncryption_Impl(); } else if ( m_nStorageType == embed::StorageFormats::OFOPXML ) { @@ -991,9 +995,7 @@ void OStorage_Impl::Commit() // it can be detected by m_bCommited flag ( root storage doesn't need temporary representation ) if ( !m_bCommited && !m_bIsRoot ) { - uno::Sequence< uno::Any > aSeq( 1 ); - aSeq[0] <<= true; - + uno::Sequence< uno::Any > aSeq{ uno::Any(true) }; xNewPackageFolder.set( m_xPackage->createInstanceWithArguments( aSeq ), uno::UNO_QUERY ); } @@ -1307,8 +1309,7 @@ SotElement_Impl* OStorage_Impl::InsertStream( const OUString& aName, bool bEncr if ( !m_xPackage.is() ) throw embed::InvalidStorageException( THROW_WHERE); - uno::Sequence< uno::Any > aSeq( 1 ); - aSeq[0] <<= false; + uno::Sequence< uno::Any > aSeq{ uno::Any(false) }; uno::Reference< lang::XUnoTunnel > xNewElement( m_xPackage->createInstanceWithArguments( aSeq ), uno::UNO_QUERY ); @@ -1347,8 +1348,7 @@ void OStorage_Impl::InsertRawStream( const OUString& aName, const uno::Reference uno::Reference< io::XInputStream > xInStrToInsert = xSeek.is() ? xInStream : GetSeekableTempCopy( xInStream, m_xContext ); - uno::Sequence< uno::Any > aSeq( 1 ); - aSeq[0] <<= false; + uno::Sequence< uno::Any > aSeq{ uno::Any(false) }; uno::Reference< lang::XUnoTunnel > xNewElement( m_xPackage->createInstanceWithArguments( aSeq ), uno::UNO_QUERY ); @@ -1376,8 +1376,7 @@ std::unique_ptr<OStorage_Impl> OStorage_Impl::CreateNewStorageImpl( sal_Int32 nS if ( !m_xPackage.is() ) throw embed::InvalidStorageException( THROW_WHERE ); - uno::Sequence< uno::Any > aSeq( 1 ); - aSeq[0] <<= true; + uno::Sequence< uno::Any > aSeq{ uno::Any(true) }; uno::Reference< lang::XUnoTunnel > xNewElement( m_xPackage->createInstanceWithArguments( aSeq ), uno::UNO_QUERY ); @@ -4779,7 +4778,7 @@ void SAL_CALL OStorage::insertRelationshipByID( const OUString& sID, const uno: const beans::StringPair aIDRel("Id", sID); - sal_Int32 nIDInd = -1; + uno::Sequence<beans::StringPair>* pResult = nullptr; // TODO/LATER: in future the unification of the ID could be checked uno::Sequence< uno::Sequence< beans::StringPair > > aSeq = getAllRelationships(); @@ -4787,16 +4786,17 @@ void SAL_CALL OStorage::insertRelationshipByID( const OUString& sID, const uno: { const auto& rRel = aSeq[nInd]; if (std::find(rRel.begin(), rRel.end(), aIDRel) != rRel.end()) - nIDInd = nInd; + pResult = &aSeq.getArray()[nInd]; } - if ( nIDInd != -1 && !bReplace ) + if ( pResult && !bReplace ) throw container::ElementExistException( THROW_WHERE ); - if ( nIDInd == -1 ) + if ( !pResult ) { - nIDInd = aSeq.getLength(); + const sal_Int32 nIDInd = aSeq.getLength(); aSeq.realloc( nIDInd + 1 ); + pResult = &aSeq.getArray()[nIDInd]; } std::vector<beans::StringPair> aResult; @@ -4806,7 +4806,7 @@ void SAL_CALL OStorage::insertRelationshipByID( const OUString& sID, const uno: std::copy_if(aEntry.begin(), aEntry.end(), std::back_inserter(aResult), [](const beans::StringPair& rPair) { return rPair.First != "Id"; }); - aSeq[nIDInd] = comphelper::containerToSequence(aResult); + *pResult = comphelper::containerToSequence(aResult); m_pImpl->m_aRelInfo = aSeq; m_pImpl->m_xNewRelInfoStream.clear(); diff --git a/package/source/zipapi/XBufferedThreadedStream.cxx b/package/source/zipapi/XBufferedThreadedStream.cxx index c36a1845be6c..e2f963bf88c1 100644 --- a/package/source/zipapi/XBufferedThreadedStream.cxx +++ b/package/source/zipapi/XBufferedThreadedStream.cxx @@ -137,6 +137,7 @@ sal_Int32 SAL_CALL XBufferedThreadedStream::readBytes( Sequence< sal_Int8 >& rDa const sal_Int32 nAvailableSize = static_cast< sal_Int32 > ( std::min< sal_Int64 >( nBytesToRead, remainingSize() ) ); rData.realloc( nAvailableSize ); + auto pData = rData.getArray(); sal_Int32 i = 0, nPendingBytes = nAvailableSize; while( nPendingBytes ) @@ -149,7 +150,7 @@ sal_Int32 SAL_CALL XBufferedThreadedStream::readBytes( Sequence< sal_Int8 >& rDa } const sal_Int32 limit = std::min<sal_Int32>( nPendingBytes, pBuffer.getLength() - mnOffset ); - memcpy( &rData[i], &pBuffer[mnOffset], limit ); + memcpy( &pData[i], &pBuffer[mnOffset], limit ); nPendingBytes -= limit; mnOffset += limit; diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx index 0869d58931c9..2b298e0ebdf8 100644 --- a/package/source/zipapi/ZipFile.cxx +++ b/package/source/zipapi/ZipFile.cxx @@ -579,10 +579,11 @@ public: sal_Int32 nReadSize = std::min<sal_Int32>(nBytesToRead, remainingSize()); rData.realloc(nReadSize); + auto pData = rData.getArray(); std::vector<sal_Int8>::const_iterator it = maBytes.cbegin(); std::advance(it, mnPos); for (sal_Int32 i = 0; i < nReadSize; ++i, ++it) - rData[i] = *it; + pData[i] = *it; mnPos += nReadSize; diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx index 8a74267d755f..3882bb887c99 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -1092,6 +1092,7 @@ void ZipPackage::WriteContentTypes( ZipOutputStream& aZipOut, const std::vector< }; uno::Sequence< beans::StringPair > aOverridesSequence(aManList.size()); + auto aOverridesSequenceRange = asNonConstRange(aOverridesSequence); sal_Int32 nOverSeqLength = 0; for (const auto& rMan : aManList) { @@ -1105,8 +1106,8 @@ void ZipPackage::WriteContentTypes( ZipOutputStream& aZipOut, const std::vector< // only nonempty type makes sense here rMan[PKG_MNFST_FULLPATH].Value >>= aPath; //FIXME: For now we have no way of differentiating defaults from others. - aOverridesSequence[nOverSeqLength].First = "/" + aPath; - aOverridesSequence[nOverSeqLength].Second = aType; + aOverridesSequenceRange[nOverSeqLength].First = "/" + aPath; + aOverridesSequenceRange[nOverSeqLength].Second = aType; ++nOverSeqLength; } } @@ -1255,17 +1256,18 @@ uno::Reference< io::XInputStream > ZipPackage::writeTempFile() { uno::Sequence < PropertyValue > aPropSeq( bIsGpgEncrypt ? PKG_SIZE_NOENCR_MNFST+1 : PKG_SIZE_NOENCR_MNFST ); - aPropSeq [PKG_MNFST_MEDIATYPE].Name = sMediaType; - aPropSeq [PKG_MNFST_MEDIATYPE].Value <<= m_xRootFolder->GetMediaType(); - aPropSeq [PKG_MNFST_VERSION].Name = sVersion; - aPropSeq [PKG_MNFST_VERSION].Value <<= m_xRootFolder->GetVersion(); - aPropSeq [PKG_MNFST_FULLPATH].Name = sFullPath; - aPropSeq [PKG_MNFST_FULLPATH].Value <<= OUString("/"); + auto pPropSeq = aPropSeq.getArray(); + pPropSeq [PKG_MNFST_MEDIATYPE].Name = sMediaType; + pPropSeq [PKG_MNFST_MEDIATYPE].Value <<= m_xRootFolder->GetMediaType(); + pPropSeq [PKG_MNFST_VERSION].Name = sVersion; + pPropSeq [PKG_MNFST_VERSION].Value <<= m_xRootFolder->GetVersion(); + pPropSeq [PKG_MNFST_FULLPATH].Name = sFullPath; + pPropSeq [PKG_MNFST_FULLPATH].Value <<= OUString("/"); if( bIsGpgEncrypt ) { - aPropSeq[PKG_SIZE_NOENCR_MNFST].Name = "KeyInfo"; - aPropSeq[PKG_SIZE_NOENCR_MNFST].Value <<= m_aGpgProps; + pPropSeq[PKG_SIZE_NOENCR_MNFST].Name = "KeyInfo"; + pPropSeq[PKG_SIZE_NOENCR_MNFST].Value <<= m_aGpgProps; } aManList.push_back( aPropSeq ); } diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx index 5ea4213f95fd..5690fd2fb530 100644 --- a/package/source/zippackage/ZipPackageFolder.cxx +++ b/package/source/zippackage/ZipPackageFolder.cxx @@ -240,12 +240,13 @@ bool ZipPackageFolder::saveChild( if ( !GetMediaType().isEmpty() ) { - aPropSet[PKG_MNFST_MEDIATYPE].Name = "MediaType"; - aPropSet[PKG_MNFST_MEDIATYPE].Value <<= GetMediaType(); - aPropSet[PKG_MNFST_VERSION].Name = "Version"; - aPropSet[PKG_MNFST_VERSION].Value <<= GetVersion(); - aPropSet[PKG_MNFST_FULLPATH].Name = "FullPath"; - aPropSet[PKG_MNFST_FULLPATH].Value <<= sTempName; + auto pPropSet = aPropSet.getArray(); + pPropSet[PKG_MNFST_MEDIATYPE].Name = "MediaType"; + pPropSet[PKG_MNFST_MEDIATYPE].Value <<= GetMediaType(); + pPropSet[PKG_MNFST_VERSION].Name = "Version"; + pPropSet[PKG_MNFST_VERSION].Value <<= GetVersion(); + pPropSet[PKG_MNFST_FULLPATH].Name = "FullPath"; + pPropSet[PKG_MNFST_FULLPATH].Value <<= sTempName; } else aPropSet.realloc( 0 ); diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx index 2b3bf5b5e7e3..58f55768066a 100644 --- a/package/source/zippackage/ZipPackageStream.cxx +++ b/package/source/zippackage/ZipPackageStream.cxx @@ -284,8 +284,7 @@ uno::Reference< io::XInputStream > ZipPackageStream::TryToGetRawFromDataStream( // create a package based on it rtl::Reference<ZipPackage> pPackage = new ZipPackage( m_xContext ); - Sequence< Any > aArgs( 1 ); - aArgs[0] <<= xTempStream; + Sequence< Any > aArgs{ Any(xTempStream) }; pPackage->initialize( aArgs ); // create a new package stream @@ -471,12 +470,13 @@ bool ZipPackageStream::saveChild( const bool bToBeEncrypted = m_bToBeEncrypted && (rEncryptionKey.hasElements() || m_bHaveOwnKey); const bool bToBeCompressed = bToBeEncrypted || m_bToBeCompressed; - aPropSet[PKG_MNFST_MEDIATYPE].Name = "MediaType"; - aPropSet[PKG_MNFST_MEDIATYPE].Value <<= GetMediaType( ); - aPropSet[PKG_MNFST_VERSION].Name = "Version"; - aPropSet[PKG_MNFST_VERSION].Value <<= OUString(); // no version is stored for streams currently - aPropSet[PKG_MNFST_FULLPATH].Name = "FullPath"; - aPropSet[PKG_MNFST_FULLPATH].Value <<= pTempEntry->sPath; + auto pPropSet = aPropSet.getArray(); + pPropSet[PKG_MNFST_MEDIATYPE].Name = "MediaType"; + pPropSet[PKG_MNFST_MEDIATYPE].Value <<= GetMediaType( ); + pPropSet[PKG_MNFST_VERSION].Name = "Version"; + pPropSet[PKG_MNFST_VERSION].Value <<= OUString(); // no version is stored for streams currently + pPropSet[PKG_MNFST_FULLPATH].Name = "FullPath"; + pPropSet[PKG_MNFST_FULLPATH].Value <<= pTempEntry->sPath; OSL_ENSURE( m_nStreamMode != PACKAGE_STREAM_NOTSET, "Unacceptable ZipPackageStream mode!" ); @@ -597,18 +597,18 @@ bool ZipPackageStream::saveChild( // last property is digest, which is inserted later if we didn't have // a magic header aPropSet.realloc(PKG_SIZE_ENCR_MNFST); - - aPropSet[PKG_MNFST_INIVECTOR].Name = "InitialisationVector"; - aPropSet[PKG_MNFST_INIVECTOR].Value <<= m_xBaseEncryptionData->m_aInitVector; - aPropSet[PKG_MNFST_SALT].Name = "Salt"; - aPropSet[PKG_MNFST_SALT].Value <<= m_xBaseEncryptionData->m_aSalt; - aPropSet[PKG_MNFST_ITERATION].Name = "IterationCount"; - aPropSet[PKG_MNFST_ITERATION].Value <<= m_xBaseEncryptionData->m_nIterationCount; + pPropSet = aPropSet.getArray(); + pPropSet[PKG_MNFST_INIVECTOR].Name = "InitialisationVector"; + pPropSet[PKG_MNFST_INIVECTOR].Value <<= m_xBaseEncryptionData->m_aInitVector; + pPropSet[PKG_MNFST_SALT].Name = "Salt"; + pPropSet[PKG_MNFST_SALT].Value <<= m_xBaseEncryptionData->m_aSalt; + pPropSet[PKG_MNFST_ITERATION].Name = "IterationCount"; + pPropSet[PKG_MNFST_ITERATION].Value <<= m_xBaseEncryptionData->m_nIterationCount; // Need to store the uncompressed size in the manifest OSL_ENSURE( m_nOwnStreamOrigSize >= 0, "The stream size was not correctly initialized!" ); - aPropSet[PKG_MNFST_UCOMPSIZE].Name = "Size"; - aPropSet[PKG_MNFST_UCOMPSIZE].Value <<= m_nOwnStreamOrigSize; + pPropSet[PKG_MNFST_UCOMPSIZE].Name = "Size"; + pPropSet[PKG_MNFST_UCOMPSIZE].Value <<= m_nOwnStreamOrigSize; if ( m_bRawStream || bTransportOwnEncrStreamAsRaw ) { @@ -616,16 +616,16 @@ bool ZipPackageStream::saveChild( if ( !xEncData.is() ) throw uno::RuntimeException(); - aPropSet[PKG_MNFST_DIGEST].Name = sDigestProperty; - aPropSet[PKG_MNFST_DIGEST].Value <<= m_xBaseEncryptionData->m_aDigest; - aPropSet[PKG_MNFST_ENCALG].Name = sEncryptionAlgProperty; - aPropSet[PKG_MNFST_ENCALG].Value <<= xEncData->m_nEncAlg; - aPropSet[PKG_MNFST_STARTALG].Name = sStartKeyAlgProperty; - aPropSet[PKG_MNFST_STARTALG].Value <<= xEncData->m_nStartKeyGenID; - aPropSet[PKG_MNFST_DIGESTALG].Name = sDigestAlgProperty; - aPropSet[PKG_MNFST_DIGESTALG].Value <<= xEncData->m_nCheckAlg; - aPropSet[PKG_MNFST_DERKEYSIZE].Name = sDerivedKeySizeProperty; - aPropSet[PKG_MNFST_DERKEYSIZE].Value <<= xEncData->m_nDerivedKeySize; + pPropSet[PKG_MNFST_DIGEST].Name = sDigestProperty; + pPropSet[PKG_MNFST_DIGEST].Value <<= m_xBaseEncryptionData->m_aDigest; + pPropSet[PKG_MNFST_ENCALG].Name = sEncryptionAlgProperty; + pPropSet[PKG_MNFST_ENCALG].Value <<= xEncData->m_nEncAlg; + pPropSet[PKG_MNFST_STARTALG].Name = sStartKeyAlgProperty; + pPropSet[PKG_MNFST_STARTALG].Value <<= xEncData->m_nStartKeyGenID; + pPropSet[PKG_MNFST_DIGESTALG].Name = sDigestAlgProperty; + pPropSet[PKG_MNFST_DIGESTALG].Value <<= xEncData->m_nCheckAlg; + pPropSet[PKG_MNFST_DERKEYSIZE].Name = sDerivedKeySizeProperty; + pPropSet[PKG_MNFST_DERKEYSIZE].Value <<= xEncData->m_nDerivedKeySize; } } } @@ -807,16 +807,16 @@ bool ZipPackageStream::saveChild( if ( !xEncData.is() ) throw uno::RuntimeException(); - aPropSet[PKG_MNFST_DIGEST].Name = sDigestProperty; - aPropSet[PKG_MNFST_DIGEST].Value <<= m_xBaseEncryptionData->m_aDigest; - aPropSet[PKG_MNFST_ENCALG].Name = sEncryptionAlgProperty; - aPropSet[PKG_MNFST_ENCALG].Value <<= xEncData->m_nEncAlg; - aPropSet[PKG_MNFST_STARTALG].Name = sStartKeyAlgProperty; - aPropSet[PKG_MNFST_STARTALG].Value <<= xEncData->m_nStartKeyGenID; - aPropSet[PKG_MNFST_DIGESTALG].Name = sDigestAlgProperty; - aPropSet[PKG_MNFST_DIGESTALG].Value <<= xEncData->m_nCheckAlg; - aPropSet[PKG_MNFST_DERKEYSIZE].Name = sDerivedKeySizeProperty; - aPropSet[PKG_MNFST_DERKEYSIZE].Value <<= xEncData->m_nDerivedKeySize; + pPropSet[PKG_MNFST_DIGEST].Name = sDigestProperty; + pPropSet[PKG_MNFST_DIGEST].Value <<= m_xBaseEncryptionData->m_aDigest; + pPropSet[PKG_MNFST_ENCALG].Name = sEncryptionAlgProperty; + pPropSet[PKG_MNFST_ENCALG].Value <<= xEncData->m_nEncAlg; + pPropSet[PKG_MNFST_STARTALG].Name = sStartKeyAlgProperty; + pPropSet[PKG_MNFST_STARTALG].Value <<= xEncData->m_nStartKeyGenID; + pPropSet[PKG_MNFST_DIGESTALG].Name = sDigestAlgProperty; + pPropSet[PKG_MNFST_DIGESTALG].Value <<= xEncData->m_nCheckAlg; + pPropSet[PKG_MNFST_DERKEYSIZE].Name = sDerivedKeySizeProperty; + pPropSet[PKG_MNFST_DERKEYSIZE].Value <<= xEncData->m_nDerivedKeySize; SetIsEncrypted ( true ); } diff --git a/package/source/zippackage/zipfileaccess.cxx b/package/source/zippackage/zipfileaccess.cxx index 801a9fe79e54..1e66e67936b0 100644 --- a/package/source/zippackage/zipfileaccess.cxx +++ b/package/source/zippackage/zipfileaccess.cxx @@ -75,6 +75,7 @@ uno::Sequence< OUString > OZipFileAccess::GetPatternsFromString_Impl( const OUSt return uno::Sequence< OUString >(); uno::Sequence< OUString > aPattern( 1 ); + auto pPattern = aPattern.getArray(); sal_Int32 nInd = 0; const sal_Unicode* pString = aString.getStr(); @@ -86,28 +87,29 @@ uno::Sequence< OUString > OZipFileAccess::GetPatternsFromString_Impl( const OUSt if ( *pString == '\\' ) { - aPattern[nInd] += "\\"; + pPattern[nInd] += "\\"; pString++; } else if ( *pString == '*' ) { - aPattern[nInd] += "*"; + pPattern[nInd] += "*"; pString++; } else { OSL_FAIL( "The backslash is not guarded!" ); - aPattern[nInd] += "\\"; + pPattern[nInd] += "\\"; } } else if ( *pString == '*' ) { aPattern.realloc( ( ++nInd ) + 1 ); + pPattern = aPattern.getArray(); pString++; } else { - aPattern[nInd] += OUStringChar( *pString ); + pPattern[nInd] += OUStringChar( *pString ); pString++; } } @@ -306,6 +308,7 @@ uno::Sequence< OUString > SAL_CALL OZipFileAccess::getElementNames() throw uno::RuntimeException(THROW_WHERE); uno::Sequence< OUString > aNames( m_pZipFile->GetEntryHash().size() ); + auto pNames = aNames.getArray(); sal_Int32 nLen = 0; for ( const auto& rEntry : m_pZipFile->GetEntryHash() ) @@ -314,9 +317,10 @@ uno::Sequence< OUString > SAL_CALL OZipFileAccess::getElementNames() { OSL_FAIL( "The size must be the same!" ); aNames.realloc( nLen ); + pNames = aNames.getArray(); } - aNames[nLen-1] = rEntry.second.sPath; + pNames[nLen-1] = rEntry.second.sPath; } if ( aNames.getLength() != nLen ) |