summaryrefslogtreecommitdiff
path: root/package/source/zippackage
diff options
context:
space:
mode:
authorNoel <noel.grandin@collabora.co.uk>2021-02-21 12:34:46 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-02-21 19:00:26 +0100
commite150c78cdfbe112bd880107b476ac42e72d4643c (patch)
tree8f67a46bd60ee89d28d485f0ada90ab7871566cc /package/source/zippackage
parentbb8fb3237c9d1b9516f5803d476c1db09570c2dc (diff)
loplugin:refcounting in package..sax
Change-Id: I83618f54a4117cd81d8626307716129a761e14c5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111274 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'package/source/zippackage')
-rw-r--r--package/source/zippackage/ZipPackage.cxx16
-rw-r--r--package/source/zippackage/ZipPackageStream.cxx7
2 files changed, 9 insertions, 14 deletions
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index c91947992047..3de64f6502b2 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -558,10 +558,10 @@ void ZipPackage::getZipFileContents()
break;
if ( !pCurrent->hasByName( sTemp ) )
{
- ZipPackageFolder* pPkgFolder = new ZipPackageFolder(m_xContext, m_nFormat, m_bAllowRemoveOnInsert);
+ rtl::Reference<ZipPackageFolder> pPkgFolder = new ZipPackageFolder(m_xContext, m_nFormat, m_bAllowRemoveOnInsert);
pPkgFolder->setName( sTemp );
pPkgFolder->doSetParent( pCurrent );
- pCurrent = pPkgFolder;
+ pCurrent = pPkgFolder.get();
}
else
{
@@ -582,7 +582,7 @@ void ZipPackage::getZipFileContents()
if (!pCurrent->hasByName(sTemp))
{
- ZipPackageStream *pPkgStream = new ZipPackageStream(*this, m_xContext, m_nFormat, m_bAllowRemoveOnInsert);
+ rtl::Reference<ZipPackageStream> pPkgStream = new ZipPackageStream(*this, m_xContext, m_nFormat, m_bAllowRemoveOnInsert);
pPkgStream->SetPackageMember(true);
pPkgStream->setZipEntryOnLoading(rEntry);
pPkgStream->setName(sTemp);
@@ -1056,8 +1056,7 @@ void ZipPackage::WriteManifest( ZipOutputStream& aZipOut, const vector< uno::Seq
// Write the manifest
uno::Reference < XManifestWriter > xWriter = ManifestWriter::create( m_xContext );
ZipEntry * pEntry = new ZipEntry;
- ZipPackageBuffer *pBuffer = new ZipPackageBuffer;
- uno::Reference < XOutputStream > xManOutStream( *pBuffer, UNO_QUERY );
+ rtl::Reference<ZipPackageBuffer> pBuffer = new ZipPackageBuffer;
pEntry->sPath = "META-INF/manifest.xml";
pEntry->nMethod = DEFLATED;
@@ -1065,7 +1064,7 @@ void ZipPackage::WriteManifest( ZipOutputStream& aZipOut, const vector< uno::Seq
pEntry->nSize = pEntry->nCompressedSize = -1;
pEntry->nTime = ZipOutputStream::getCurrentDosTime();
- xWriter->writeManifestSequence ( xManOutStream, comphelper::containerToSequence(aManList) );
+ xWriter->writeManifestSequence ( pBuffer, comphelper::containerToSequence(aManList) );
sal_Int32 nBufferLength = static_cast < sal_Int32 > ( pBuffer->getPosition() );
pBuffer->realloc( nBufferLength );
@@ -1082,8 +1081,7 @@ void ZipPackage::WriteManifest( ZipOutputStream& aZipOut, const vector< uno::Seq
void ZipPackage::WriteContentTypes( ZipOutputStream& aZipOut, const vector< uno::Sequence < PropertyValue > >& aManList )
{
ZipEntry* pEntry = new ZipEntry;
- ZipPackageBuffer *pBuffer = new ZipPackageBuffer;
- uno::Reference< io::XOutputStream > xConTypeOutStream( *pBuffer, UNO_QUERY );
+ rtl::Reference<ZipPackageBuffer> pBuffer = new ZipPackageBuffer;
pEntry->sPath = "[Content_Types].xml";
pEntry->nMethod = DEFLATED;
@@ -1125,7 +1123,7 @@ void ZipPackage::WriteContentTypes( ZipOutputStream& aZipOut, const vector< uno:
aOverridesSequence.realloc(nOverSeqLength);
::comphelper::OFOPXMLHelper::WriteContentSequence(
- xConTypeOutStream, aDefaultsSequence, aOverridesSequence, m_xContext );
+ pBuffer, aDefaultsSequence, aOverridesSequence, m_xContext );
sal_Int32 nBufferLength = static_cast < sal_Int32 > ( pBuffer->getPosition() );
pBuffer->realloc( nBufferLength );
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index 962d206ed1cb..fb1794841809 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -285,17 +285,14 @@ uno::Reference< io::XInputStream > ZipPackageStream::TryToGetRawFromDataStream(
uno::UNO_QUERY_THROW );
// create a package based on it
- ZipPackage* pPackage = new ZipPackage( m_xContext );
- uno::Reference< XSingleServiceFactory > xPackageAsFactory( static_cast< XSingleServiceFactory* >( pPackage ) );
- if ( !xPackageAsFactory.is() )
- throw RuntimeException(THROW_WHERE );
+ rtl::Reference<ZipPackage> pPackage = new ZipPackage( m_xContext );
Sequence< Any > aArgs( 1 );
aArgs[0] <<= xTempStream;
pPackage->initialize( aArgs );
// create a new package stream
- uno::Reference< XDataSinkEncrSupport > xNewPackStream( xPackageAsFactory->createInstance(), UNO_QUERY_THROW );
+ uno::Reference< XDataSinkEncrSupport > xNewPackStream( pPackage->createInstance(), UNO_QUERY_THROW );
xNewPackStream->setDataStream(
new WrapStreamForShare(GetOwnSeekStream(), m_rZipPackage.GetSharedMutexRef()));