From 9610a5aebd3ffdf76bcb734c633b5f88b78ad4dd Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 23 Feb 2016 15:50:40 +0100 Subject: Use passed-in context instead of comphelper::getProcessComponentContext() (and the passed-in context is required to always be non-null) Change-Id: I1197a2bafba8cb645e15df4310c1c5767b648670 --- package/source/xstor/xstorage.cxx | 29 +++++++++++++---------------- package/source/xstor/xstorage.hxx | 1 - 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx index ccfa1bbb2bf9..a268c0cccfbf 100644 --- a/package/source/xstor/xstorage.cxx +++ b/package/source/xstor/xstorage.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include + +#include + #include #include #include @@ -44,7 +48,6 @@ #include #include -#include #include #include @@ -207,6 +210,7 @@ OStorage_Impl::OStorage_Impl( uno::Reference< io::XInputStream > xInputStream, { // all the checks done below by assertion statements must be done by factory SAL_WARN_IF( !xInputStream.is(), "package.xstor", "No input stream is provided!" ); + assert(xContext.is()); m_pSwitchStream = new SwitchablePersistenceStream(xContext, xInputStream); m_xInputStream = m_pSwitchStream->getInputStream(); @@ -247,6 +251,7 @@ OStorage_Impl::OStorage_Impl( uno::Reference< io::XStream > xStream, { // all the checks done below by assertion statements must be done by factory SAL_WARN_IF( !xStream.is(), "package.xstor", "No stream is provided!" ); + assert(xContext.is()); if ( m_nStorageMode & embed::ElementModes::WRITE ) { @@ -289,6 +294,7 @@ OStorage_Impl::OStorage_Impl( OStorage_Impl* pParent, , m_nRelInfoStatus( RELINFO_NO_INIT ) { SAL_WARN_IF( !xPackageFolder.is(), "package.xstor", "No package folder!" ); + assert(xContext.is()); } OStorage_Impl::~OStorage_Impl() @@ -388,8 +394,7 @@ void OStorage_Impl::AddLog( const OUString& aMessage ) { try { - uno::Reference xContext( ::comphelper::getProcessComponentContext() ); - m_xLogRing = logging::DocumentIOLogRing::get(xContext); + m_xLogRing = logging::DocumentIOLogRing::get(m_xContext); } catch( const uno::Exception& ) { @@ -495,8 +500,8 @@ void OStorage_Impl::OpenOwnPackage() aArguments[nArgNum-1] <<= aNamedValue; } - m_xPackage.set( GetComponentContext()->getServiceManager()->createInstanceWithArgumentsAndContext( - "com.sun.star.packages.comp.ZipPackage", aArguments, GetComponentContext()), + m_xPackage.set( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( + "com.sun.star.packages.comp.ZipPackage", aArguments, m_xContext), uno::UNO_QUERY ); } @@ -515,14 +520,6 @@ void OStorage_Impl::OpenOwnPackage() throw embed::InvalidStorageException( THROW_WHERE ); } -uno::Reference< uno::XComponentContext > OStorage_Impl::GetComponentContext() -{ - if ( m_xContext.is() ) - return m_xContext; - - return ::comphelper::getProcessComponentContext(); -} - SotElementList_Impl& OStorage_Impl::GetChildrenList() { ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() ); @@ -1421,7 +1418,7 @@ void OStorage_Impl::InsertRawStream( const OUString& aName, const uno::Reference uno::Reference< io::XSeekable > xSeek( xInStream, uno::UNO_QUERY ); uno::Reference< io::XInputStream > xInStrToInsert = xSeek.is() ? xInStream : - GetSeekableTempCopy( xInStream, GetComponentContext() ); + GetSeekableTempCopy( xInStream, m_xContext ); uno::Sequence< uno::Any > aSeq( 1 ); aSeq[0] <<= sal_False; @@ -3650,7 +3647,7 @@ uno::Reference< io::XInputStream > SAL_CALL OStorage::getPlainRawStreamElement( if ( !xRawInStream.is() ) throw io::IOException( THROW_WHERE ); - uno::Reference < io::XTempFile > xTempFile = io::TempFile::create( m_pImpl->GetComponentContext() ); + uno::Reference < io::XTempFile > xTempFile = io::TempFile::create( m_pImpl->m_xContext ); uno::Reference < io::XOutputStream > xTempOut = xTempFile->getOutputStream(); xTempIn = xTempFile->getInputStream(); uno::Reference < io::XSeekable > xSeek( xTempOut, uno::UNO_QUERY ); @@ -3758,7 +3755,7 @@ uno::Reference< io::XInputStream > SAL_CALL OStorage::getRawEncrStreamElement( if ( !xRawInStream.is() ) throw io::IOException( THROW_WHERE ); - uno::Reference < io::XTempFile > xTempFile = io::TempFile::create(m_pImpl->GetComponentContext()); + uno::Reference < io::XTempFile > xTempFile = io::TempFile::create(m_pImpl->m_xContext); uno::Reference < io::XOutputStream > xTempOut = xTempFile->getOutputStream(); xTempIn = xTempFile->getInputStream(); uno::Reference < io::XSeekable > xSeek( xTempOut, uno::UNO_QUERY ); diff --git a/package/source/xstor/xstorage.hxx b/package/source/xstor/xstorage.hxx index c0e7e48fec15..712afd3a9848 100644 --- a/package/source/xstor/xstorage.hxx +++ b/package/source/xstor/xstorage.hxx @@ -208,7 +208,6 @@ struct OStorage_Impl void ReadContents(); void ReadRelInfoIfNecessary(); - css::uno::Reference< css::uno::XComponentContext > GetComponentContext(); SotElementList_Impl& GetChildrenList(); void GetStorageProperties(); -- cgit v1.2.3