From 5ced1a6e42ff7e2425a9e1c374eb25295091b26d Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 4 Nov 2015 14:38:56 +0200 Subject: use uno::Reference::set method instead of assignment Change-Id: I1c7240fe2e2b5eb825f028ca7502e5ba8793046b --- package/source/xstor/ohierarchyholder.cxx | 2 +- package/source/xstor/oseekinstream.cxx | 4 +- package/source/xstor/owriteablestream.cxx | 62 +++++++++++------------- package/source/xstor/switchpersistencestream.cxx | 9 ++-- package/source/xstor/xstorage.cxx | 56 ++++++++++----------- 5 files changed, 60 insertions(+), 73 deletions(-) (limited to 'package/source/xstor') diff --git a/package/source/xstor/ohierarchyholder.cxx b/package/source/xstor/ohierarchyholder.cxx index 32e09ed719d7..73c50b0ad781 100644 --- a/package/source/xstor/ohierarchyholder.cxx +++ b/package/source/xstor/ohierarchyholder.cxx @@ -253,7 +253,7 @@ void OHierarchyElement_Impl::TestForClosing() m_rParent->RemoveElement( this ); } - m_xOwnStorage = uno::Reference< embed::XStorage >(); + m_xOwnStorage.clear(); } } } diff --git a/package/source/xstor/oseekinstream.cxx b/package/source/xstor/oseekinstream.cxx index 53bf7a3db989..4d6521aecbfc 100644 --- a/package/source/xstor/oseekinstream.cxx +++ b/package/source/xstor/oseekinstream.cxx @@ -33,7 +33,7 @@ OInputSeekStream::OInputSeekStream( OWriteStream_Impl& pImpl, sal_Int32 nStorageType ) : OInputCompStream( pImpl, xStream, aProps, nStorageType ) { - m_xSeekable = uno::Reference< io::XSeekable >( m_xStream, uno::UNO_QUERY ); + m_xSeekable.set( m_xStream, uno::UNO_QUERY ); OSL_ENSURE( m_xSeekable.is(), "No seeking support!\n" ); } @@ -42,7 +42,7 @@ OInputSeekStream::OInputSeekStream( uno::Reference < io::XInputStream > xStream, sal_Int32 nStorageType ) : OInputCompStream( xStream, aProps, nStorageType ) { - m_xSeekable = uno::Reference< io::XSeekable >( m_xStream, uno::UNO_QUERY ); + m_xSeekable.set( m_xStream, uno::UNO_QUERY ); OSL_ENSURE( m_xSeekable.is(), "No seeking support!\n" ); } diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx index 1b8fac8c904e..4967e23a96f5 100644 --- a/package/source/xstor/owriteablestream.cxx +++ b/package/source/xstor/owriteablestream.cxx @@ -323,8 +323,8 @@ void OWriteStream_Impl::CleanCacheStream() catch( const uno::Exception& ) {} - m_xCacheStream = uno::Reference< io::XStream >(); - m_xCacheSeek = uno::Reference< io::XSeekable >(); + m_xCacheStream.clear(); + m_xCacheSeek.clear(); } } @@ -528,7 +528,7 @@ OUString OWriteStream_Impl::GetFilledTempFileIfNo( const uno::Reference< io::XIn // the current position of the original stream should be still OK, copy further ::comphelper::OStorageHelper::CopyInputToOutput( xStream, xTempOutStream ); xTempOutStream->closeOutput(); - xTempOutStream = uno::Reference< io::XOutputStream >(); + xTempOutStream.clear(); } else throw io::IOException(); // TODO: @@ -614,7 +614,7 @@ OUString OWriteStream_Impl::FillTempGetFileName() // the current position of the original stream should be still OK, copy further ::comphelper::OStorageHelper::CopyInputToOutput( xOrigStream, xTempOutStream ); xTempOutStream->closeOutput(); - xTempOutStream = uno::Reference< io::XOutputStream >(); + xTempOutStream.clear(); } else throw io::IOException(); // TODO: @@ -819,14 +819,12 @@ void OWriteStream_Impl::Commit() uno::Reference< io::XInputStream > xInStream( m_xCacheStream->getInputStream(), uno::UNO_SET_THROW ); - xNewPackageStream = uno::Reference< packages::XDataSinkEncrSupport >( - m_xPackage->createInstanceWithArguments( aSeq ), - uno::UNO_QUERY_THROW ); + xNewPackageStream.set( m_xPackage->createInstanceWithArguments( aSeq ), uno::UNO_QUERY_THROW ); xNewPackageStream->setDataStream( xInStream ); - m_xCacheStream = uno::Reference< io::XStream >(); - m_xCacheSeek = uno::Reference< io::XSeekable >(); + m_xCacheStream.clear(); + m_xCacheSeek.clear(); } else if ( !m_aTempURL.isEmpty() ) @@ -846,9 +844,7 @@ void OWriteStream_Impl::Commit() if ( !xInStream.is() ) throw io::IOException(); - xNewPackageStream = uno::Reference< packages::XDataSinkEncrSupport >( - m_xPackage->createInstanceWithArguments( aSeq ), - uno::UNO_QUERY_THROW ); + xNewPackageStream.set( m_xPackage->createInstanceWithArguments( aSeq ), uno::UNO_QUERY_THROW ); // TODO/NEW: Let the temporary file be removed after commit xNewPackageStream->setDataStream( xInStream ); @@ -919,8 +915,8 @@ void OWriteStream_Impl::Revert() if ( m_xCacheStream.is() ) { - m_xCacheStream = uno::Reference< io::XStream >(); - m_xCacheSeek = uno::Reference< io::XSeekable >(); + m_xCacheStream.clear(); + m_xCacheSeek.clear(); } if ( !m_aTempURL.isEmpty() ) @@ -940,7 +936,7 @@ void OWriteStream_Impl::Revert() if ( m_nStorageType == embed::StorageFormats::OFOPXML ) { // currently the relations storage is changed only on commit - m_xNewRelInfoStream = uno::Reference< io::XInputStream >(); + m_xNewRelInfoStream.clear(); m_aNewRelInfo = uno::Sequence< uno::Sequence< beans::StringPair > >(); if ( m_xOrigRelInfoStream.is() ) { @@ -1039,7 +1035,7 @@ void OWriteStream_Impl::ReadRelInfoIfNecessary() // in case of success the stream must be thrown away, that means that the OrigRelInfo is initialized // the reason for this is that the original stream might not be seekable ( at the same time the new // provided stream must be seekable ), so it must be read only once - m_xOrigRelInfoStream = uno::Reference< io::XInputStream >(); + m_xOrigRelInfoStream.clear(); m_nRelInfoStatus = RELINFO_READ; } catch( const uno::Exception& rException ) @@ -1446,9 +1442,7 @@ void OWriteStream_Impl::CreateReadonlyCopyBasedOnData( const uno::Reference< io: { uno::Reference < io::XStream > xTempFile; if ( !xTargetStream.is() ) - xTempFile = uno::Reference < io::XStream >( - io::TempFile::create(m_xContext), - uno::UNO_QUERY ); + xTempFile.set( io::TempFile::create(m_xContext), uno::UNO_QUERY ); else xTempFile = xTargetStream; @@ -1472,7 +1466,7 @@ void OWriteStream_Impl::CreateReadonlyCopyBasedOnData( const uno::Reference< io: // TODO: remember last state of m_bUseCommonEncryption if ( !xTargetStream.is() ) - xTargetStream = uno::Reference< io::XStream > ( + xTargetStream.set( static_cast< ::cppu::OWeakObject* >( new OInputSeekStream( xInStream, InsertOwnProps( aProps, m_bUseCommonEncryption ), m_nStorageType ) ), uno::UNO_QUERY_THROW ); @@ -1663,7 +1657,7 @@ void OWriteStream_Impl::CommitStreamRelInfo( const uno::Reference< embed::XStora else { // the information is already parsed and the stream is stored, no need in temporary stream any more - m_xNewRelInfoStream = uno::Reference< io::XInputStream >(); + m_xNewRelInfoStream.clear(); m_nRelInfoStatus = RELINFO_READ; } } @@ -1673,7 +1667,7 @@ void OWriteStream_Impl::CommitStreamRelInfo( const uno::Reference< embed::XStora m_aOrigRelInfo = m_aNewRelInfo; m_bOrigRelInfoBroken = false; m_aNewRelInfo = uno::Sequence< uno::Sequence< beans::StringPair > >(); - m_xNewRelInfoStream = uno::Reference< io::XInputStream >(); + m_xNewRelInfoStream.clear(); } else { @@ -1721,7 +1715,7 @@ OWriteStream::OWriteStream( OWriteStream_Impl* pImpl, uno::Reference< io::XStrea { m_xInStream = xStream->getInputStream(); m_xOutStream = xStream->getOutputStream(); - m_xSeekable = uno::Reference< io::XSeekable >( xStream, uno::UNO_QUERY ); + m_xSeekable.set( xStream, uno::UNO_QUERY ); OSL_ENSURE( m_xInStream.is() && m_xOutStream.is() && m_xSeekable.is(), "Stream implementation is incomplete!\n" ); } } @@ -1751,9 +1745,9 @@ void OWriteStream::DeInit() if ( m_xSeekable.is() ) m_nInitPosition = m_xSeekable->getPosition(); - m_xInStream = uno::Reference< io::XInputStream >(); - m_xOutStream = uno::Reference< io::XOutputStream >(); - m_xSeekable = uno::Reference< io::XSeekable >(); + m_xInStream.clear(); + m_xOutStream.clear(); + m_xSeekable.clear(); m_bInitOnDemand = true; } @@ -2155,7 +2149,7 @@ void SAL_CALL OWriteStream::closeInput( ) // since it can not be reopened until output part is closed, it will be closed with output part. m_bInStreamDisconnected = true; // m_xInStream->closeInput(); - // m_xInStream = uno::Reference< io::XInputStream >(); + // m_xInStream.clear(); if ( !m_xOutStream.is() ) dispose(); @@ -2306,7 +2300,7 @@ void OWriteStream::CloseOutput_Impl() // all the checks must be done in calling method m_xOutStream->closeOutput(); - m_xOutStream = uno::Reference< io::XOutputStream >(); + m_xOutStream.clear(); if ( !m_bInitOnDemand ) { @@ -2460,10 +2454,10 @@ void SAL_CALL OWriteStream::dispose() if ( m_xInStream.is() ) { m_xInStream->closeInput(); - m_xInStream = uno::Reference< io::XInputStream >(); + m_xInStream.clear(); } - m_xSeekable = uno::Reference< io::XSeekable >(); + m_xSeekable.clear(); m_pImpl->m_pAntiImpl = NULL; @@ -2853,7 +2847,7 @@ void SAL_CALL OWriteStream::insertRelationshipByID( const OUString& sID, const throw container::ElementExistException(); // TODO m_pImpl->m_aNewRelInfo = aSeq; - m_pImpl->m_xNewRelInfoStream = uno::Reference< io::XInputStream >(); + m_pImpl->m_xNewRelInfoStream.clear(); m_pImpl->m_nRelInfoStatus = RELINFO_CHANGED; } @@ -2885,7 +2879,7 @@ void SAL_CALL OWriteStream::removeRelationshipByID( const OUString& sID ) aSeq.realloc( nLength - 1 ); m_pImpl->m_aNewRelInfo = aSeq; - m_pImpl->m_xNewRelInfoStream = uno::Reference< io::XInputStream >(); + m_pImpl->m_xNewRelInfoStream.clear(); m_pImpl->m_nRelInfoStatus = RELINFO_CHANGED; // TODO/LATER: in future the unification of the ID could be checked @@ -2976,7 +2970,7 @@ void SAL_CALL OWriteStream::insertRelationships( const uno::Sequence< uno::Sequ aResultSeq.realloc( nResultInd ); m_pImpl->m_aNewRelInfo = aResultSeq; - m_pImpl->m_xNewRelInfoStream = uno::Reference< io::XInputStream >(); + m_pImpl->m_xNewRelInfoStream.clear(); m_pImpl->m_nRelInfoStatus = RELINFO_CHANGED; } @@ -2996,7 +2990,7 @@ void SAL_CALL OWriteStream::clearRelationships() throw uno::RuntimeException(); m_pImpl->m_aNewRelInfo.realloc( 0 ); - m_pImpl->m_xNewRelInfoStream = uno::Reference< io::XInputStream >(); + m_pImpl->m_xNewRelInfoStream.clear(); m_pImpl->m_nRelInfoStatus = RELINFO_CHANGED; } diff --git a/package/source/xstor/switchpersistencestream.cxx b/package/source/xstor/switchpersistencestream.cxx index 9e241f2694a0..1eca85ff62ef 100644 --- a/package/source/xstor/switchpersistencestream.cxx +++ b/package/source/xstor/switchpersistencestream.cxx @@ -162,16 +162,13 @@ void SwitchablePersistenceStream::CopyAndSwitchPersistenceTo( const uno::Referen if ( !xTargetStream.is() ) { - xTargetStream = uno::Reference < io::XStream >( - io::TempFile::create(m_xContext), - uno::UNO_QUERY_THROW ); - - xTargetSeek = uno::Reference< io::XSeekable >( xTargetStream, uno::UNO_QUERY_THROW ); + xTargetStream.set( io::TempFile::create(m_xContext), uno::UNO_QUERY_THROW ); + xTargetSeek.set( xTargetStream, uno::UNO_QUERY_THROW ); } else { // the provided stream must be empty - xTargetSeek = uno::Reference< io::XSeekable >( xTargetStream, uno::UNO_QUERY_THROW ); + xTargetSeek.set( xTargetStream, uno::UNO_QUERY_THROW ); if ( xTargetSeek->getLength() ) throw io::IOException(); } diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx index db24890076f0..3c37bba00551 100644 --- a/package/source/xstor/xstorage.cxx +++ b/package/source/xstor/xstorage.cxx @@ -344,8 +344,8 @@ OStorage_Impl::~OStorage_Impl() m_pRelStorElement = NULL; } - m_xPackageFolder = uno::Reference< container::XNameContainer >(); - m_xPackage = uno::Reference< lang::XSingleServiceFactory >(); + m_xPackageFolder.clear(); + m_xPackage.clear(); OUString aPropertyName = "URL"; for ( sal_Int32 aInd = 0; aInd < m_xProperties.getLength(); ++aInd ) @@ -358,7 +358,7 @@ OStorage_Impl::~OStorage_Impl() if ( m_xInputStream.is() ) { m_xInputStream->closeInput(); - m_xInputStream = uno::Reference< io::XInputStream >(); + m_xInputStream.clear(); } if ( m_xStream.is() ) @@ -371,7 +371,7 @@ OStorage_Impl::~OStorage_Impl() if ( xOutStr.is() ) xOutStr->closeOutput(); - m_xStream = uno::Reference< io::XStream >(); + m_xStream.clear(); } } catch( const uno::Exception& rException ) @@ -496,10 +496,9 @@ void OStorage_Impl::OpenOwnPackage() aArguments[nArgNum-1] <<= aNamedValue; } - m_xPackage = uno::Reference< lang::XSingleServiceFactory > ( - GetComponentContext()->getServiceManager()->createInstanceWithArgumentsAndContext( - "com.sun.star.packages.comp.ZipPackage", aArguments, GetComponentContext()), - uno::UNO_QUERY ); + m_xPackage.set( GetComponentContext()->getServiceManager()->createInstanceWithArgumentsAndContext( + "com.sun.star.packages.comp.ZipPackage", aArguments, GetComponentContext()), + uno::UNO_QUERY ); } uno::Reference< container::XHierarchicalNameAccess > xHNameAccess( m_xPackage, uno::UNO_QUERY ); @@ -670,7 +669,7 @@ void OStorage_Impl::ReadContents() if ( ( m_nStorageMode & embed::ElementModes::TRUNCATE ) == embed::ElementModes::TRUNCATE ) { // if a storage is truncated the relations information should be cleaned - m_xNewRelInfoStream = uno::Reference< io::XInputStream >(); + m_xNewRelInfoStream.clear(); m_aRelInfo = uno::Sequence< uno::Sequence< beans::StringPair > >(); m_nRelInfoStatus = RELINFO_CHANGED; } @@ -1054,9 +1053,8 @@ void OStorage_Impl::Commit() uno::Sequence< uno::Any > aSeq( 1 ); aSeq[0] <<= sal_True; - xNewPackageFolder = uno::Reference< container::XNameContainer >( - m_xPackage->createInstanceWithArguments( aSeq ), - uno::UNO_QUERY ); + xNewPackageFolder.set( m_xPackage->createInstanceWithArguments( aSeq ), + uno::UNO_QUERY ); } else xNewPackageFolder = m_xPackageFolder; @@ -1255,8 +1253,8 @@ void OStorage_Impl::Commit() embed::UseBackupException aException; if ( r.TargetException >>= aException ) { - m_xStream = uno::Reference< io::XStream >(); - m_xInputStream = uno::Reference< io::XInputStream >(); + m_xStream.clear(); + m_xInputStream.clear(); throw aException; } @@ -1330,7 +1328,7 @@ void OStorage_Impl::Revert() if ( m_nStorageType == embed::StorageFormats::OFOPXML ) { // currently the relations storage is changed only on commit - m_xNewRelInfoStream = uno::Reference< io::XInputStream >(); + m_xNewRelInfoStream.clear(); m_aRelInfo = uno::Sequence< uno::Sequence< beans::StringPair > >(); m_nRelInfoStatus = RELINFO_NO_INIT; } @@ -1724,7 +1722,7 @@ void OStorage_Impl::CreateRelStorage() throw uno::RuntimeException( THROW_WHERE ); OStorage* pResultStorage = new OStorage( m_pRelStorElement->m_pStorage, false ); - m_xRelStorage = uno::Reference< embed::XStorage >( static_cast(pResultStorage) ); + m_xRelStorage.set( static_cast(pResultStorage) ); } } @@ -1838,7 +1836,7 @@ void OStorage_Impl::CommitRelInfo( const uno::Reference< container::XNameContain "MediaType", uno::makeAny( OUString( "application/vnd.openxmlformats-package.relationships+xml" ) ) ); - m_xNewRelInfoStream = uno::Reference< io::XInputStream >(); + m_xNewRelInfoStream.clear(); if ( m_nRelInfoStatus == RELINFO_CHANGED_STREAM ) { m_aRelInfo = uno::Sequence< uno::Sequence< beans::StringPair > >(); @@ -1866,7 +1864,7 @@ void OStorage_Impl::CommitRelInfo( const uno::Reference< container::XNameContain // the empty relations storage should not be created delete m_pRelStorElement; m_pRelStorElement = NULL; - m_xRelStorage = uno::Reference< embed::XStorage >(); + m_xRelStorage.clear(); } else if ( m_pRelStorElement && m_pRelStorElement->m_pStorage && xNewPackageFolder.is() ) m_pRelStorElement->m_pStorage->InsertIntoPackageFolder( aRelsStorName, xNewPackageFolder ); @@ -2578,7 +2576,7 @@ uno::Reference< embed::XStorage > SAL_CALL OStorage::openStorageElement( bool bReadOnlyWrap = ( ( nStorageMode & embed::ElementModes::WRITE ) != embed::ElementModes::WRITE ); OStorage* pResultStorage = new OStorage( pElement->m_pStorage, bReadOnlyWrap ); - xResult = uno::Reference< embed::XStorage >( static_cast(pResultStorage) ); + xResult.set( static_cast(pResultStorage) ); if ( bReadOnlyWrap ) { @@ -4807,7 +4805,7 @@ void SAL_CALL OStorage::setPropertyValue( const OUString& aPropertyName, const u { if ( aValue >>= m_pImpl->m_aRelInfo ) { - m_pImpl->m_xNewRelInfoStream = uno::Reference< io::XInputStream >(); + m_pImpl->m_xNewRelInfoStream.clear(); m_pImpl->m_nRelInfoStatus = RELINFO_CHANGED; m_pImpl->m_bBroadcastModified = true; m_pImpl->m_bIsModified = true; @@ -5247,7 +5245,7 @@ void SAL_CALL OStorage::insertRelationshipByID( const OUString& sID, const uno: throw container::ElementExistException( THROW_WHERE ); m_pImpl->m_aRelInfo = aSeq; - m_pImpl->m_xNewRelInfoStream = uno::Reference< io::XInputStream >(); + m_pImpl->m_xNewRelInfoStream.clear(); m_pImpl->m_nRelInfoStatus = RELINFO_CHANGED; } @@ -5279,7 +5277,7 @@ void SAL_CALL OStorage::removeRelationshipByID( const OUString& sID ) aSeq.realloc( nLength - 1 ); m_pImpl->m_aRelInfo = aSeq; - m_pImpl->m_xNewRelInfoStream = uno::Reference< io::XInputStream >(); + m_pImpl->m_xNewRelInfoStream.clear(); m_pImpl->m_nRelInfoStatus = RELINFO_CHANGED; // TODO/LATER: in future the unification of the ID could be checked @@ -5370,7 +5368,7 @@ void SAL_CALL OStorage::insertRelationships( const uno::Sequence< uno::Sequence aResultSeq.realloc( nResultInd ); m_pImpl->m_aRelInfo = aResultSeq; - m_pImpl->m_xNewRelInfoStream = uno::Reference< io::XInputStream >(); + m_pImpl->m_xNewRelInfoStream.clear(); m_pImpl->m_nRelInfoStatus = RELINFO_CHANGED; } @@ -5390,7 +5388,7 @@ void SAL_CALL OStorage::clearRelationships() throw uno::RuntimeException( THROW_WHERE ); m_pImpl->m_aRelInfo.realloc( 0 ); - m_pImpl->m_xNewRelInfoStream = uno::Reference< io::XInputStream >(); + m_pImpl->m_xNewRelInfoStream.clear(); m_pImpl->m_nRelInfoStatus = RELINFO_CHANGED; } @@ -5972,9 +5970,8 @@ uno::Reference< embed::XExtendedStorageStream > SAL_CALL OStorage::openStreamEle SotElement_Impl *pElement = OpenStreamElement_Impl( aStreamPath, nOpenMode, false ); assert(pElement && pElement->m_pStream && "In case element can not be created an exception must be thrown!"); - xResult = uno::Reference< embed::XExtendedStorageStream >( - pElement->m_pStream->GetStream( nOpenMode, true ), - uno::UNO_QUERY_THROW ); + xResult.set( pElement->m_pStream->GetStream( nOpenMode, true ), + uno::UNO_QUERY_THROW ); } catch ( const container::NoSuchElementException & ) { @@ -6088,9 +6085,8 @@ uno::Reference< embed::XExtendedStorageStream > SAL_CALL OStorage::openEncrypted SotElement_Impl *pElement = OpenStreamElement_Impl( aStreamPath, nOpenMode, true ); OSL_ENSURE( pElement && pElement->m_pStream, "In case element can not be created an exception must be thrown!" ); - xResult = uno::Reference< embed::XExtendedStorageStream >( - pElement->m_pStream->GetStream( nOpenMode, aEncryptionData, true ), - uno::UNO_QUERY_THROW ); + xResult.set( pElement->m_pStream->GetStream( nOpenMode, aEncryptionData, true ), + uno::UNO_QUERY_THROW ); } else { -- cgit