diff options
author | Noel Grandin <noel@peralex.com> | 2012-05-29 17:17:28 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-06-06 10:01:22 +0200 |
commit | d08578912f2c9ef42d4349079422e25b951e544e (patch) | |
tree | d029b5a9110bcdc255e72ef9c98887f3f8521ea6 /package | |
parent | 7d2a5b5114987f1ab415e32ebb5bb9a46b98dc17 (diff) |
fdo#46808, Adapt UNO services to new style, Part 7, updating ::create
Update calls to factories to use new SimpleFileAccess::create method
Change-Id: Ie5b0696fe2228a9033b19969245a53c21a61aa14
Signed-off-by: Stephan Bergmann <sbergman@redhat.com>, added some tweaks.
Diffstat (limited to 'package')
-rw-r--r-- | package/source/xstor/owriteablestream.cxx | 67 | ||||
-rw-r--r-- | package/source/xstor/selfterminatefilestream.cxx | 8 | ||||
-rw-r--r-- | package/source/xstor/selfterminatefilestream.hxx | 4 | ||||
-rw-r--r-- | package/source/xstor/xfactory.cxx | 14 | ||||
-rw-r--r-- | package/source/xstor/xstorage.cxx | 9 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackage.cxx | 9 |
6 files changed, 41 insertions, 70 deletions
diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx index 114a2ff2226a..f5fb01224287 100644 --- a/package/source/xstor/owriteablestream.cxx +++ b/package/source/xstor/owriteablestream.cxx @@ -26,7 +26,9 @@ * ************************************************************************/ -#include <com/sun/star/ucb/XSimpleFileAccess.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/ucb/SimpleFileAccess.hpp> +#include <com/sun/star/ucb/XSimpleFileAccess2.hpp> #include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> @@ -212,25 +214,19 @@ bool SequencesEqual( const uno::Sequence< beans::NamedValue >& aSequence1, const } //----------------------------------------------- -sal_Bool KillFile( const ::rtl::OUString& aURL, const uno::Reference< lang::XMultiServiceFactory >& xFactory ) +sal_Bool KillFile( const ::rtl::OUString& aURL, const uno::Reference< uno::XComponentContext >& xContext ) { - if ( !xFactory.is() ) + if ( !xContext.is() ) return sal_False; sal_Bool bRet = sal_False; try { - uno::Reference < ucb::XSimpleFileAccess > xAccess( - xFactory->createInstance ( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess" ) ) ), - uno::UNO_QUERY ); + uno::Reference < ucb::XSimpleFileAccess2 > xAccess( ucb::SimpleFileAccess::create( xContext ) ); - if ( xAccess.is() ) - { - xAccess->kill( aURL ); - bRet = sal_True; - } + xAccess->kill( aURL ); + bRet = sal_True; } catch( const uno::Exception& rException ) { @@ -325,7 +321,7 @@ OWriteStream_Impl::~OWriteStream_Impl() if ( !m_aTempURL.isEmpty() ) { - KillFile( m_aTempURL, GetServiceFactory() ); + KillFile( m_aTempURL, comphelper::getProcessComponentContext() ); m_aTempURL = ::rtl::OUString(); } @@ -570,13 +566,7 @@ uno::Reference< lang::XMultiServiceFactory > OWriteStream_Impl::GetServiceFactor try { if ( !aTempURL.isEmpty() && xStream.is() ) { - uno::Reference < ucb::XSimpleFileAccess > xTempAccess( - GetServiceFactory()->createInstance ( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess") ) ), - uno::UNO_QUERY ); - - if ( !xTempAccess.is() ) - throw uno::RuntimeException(); // TODO: + uno::Reference < ucb::XSimpleFileAccess2 > xTempAccess( ucb::SimpleFileAccess::create( ::comphelper::getProcessComponentContext() ) ); uno::Reference< io::XOutputStream > xTempOutStream = xTempAccess->openFileWrite( aTempURL ); if ( xTempOutStream.is() ) @@ -595,7 +585,7 @@ uno::Reference< lang::XMultiServiceFactory > OWriteStream_Impl::GetServiceFactor AddLog( rWrongPasswordException.Message ); AddLog( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow") ) ); - KillFile( aTempURL, GetServiceFactory() ); + KillFile( aTempURL, comphelper::getProcessComponentContext() ); throw; } catch( const uno::Exception& rException ) @@ -603,7 +593,7 @@ uno::Reference< lang::XMultiServiceFactory > OWriteStream_Impl::GetServiceFactor AddLog( rException.Message ); AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow") ) ); - KillFile( aTempURL, GetServiceFactory() ); + KillFile( aTempURL, comphelper::getProcessComponentContext() ); throw; } @@ -660,14 +650,7 @@ uno::Reference< lang::XMultiServiceFactory > OWriteStream_Impl::GetServiceFactor try { if ( !m_aTempURL.isEmpty() ) { - uno::Reference < ucb::XSimpleFileAccess > xTempAccess( - GetServiceFactory()->createInstance ( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess") ) ), - uno::UNO_QUERY ); - - if ( !xTempAccess.is() ) - throw uno::RuntimeException(); // TODO: - + uno::Reference < ucb::XSimpleFileAccess2 > xTempAccess( ucb::SimpleFileAccess::create( ::comphelper::getProcessComponentContext() ) ); uno::Reference< io::XOutputStream > xTempOutStream = xTempAccess->openFileWrite( m_aTempURL ); if ( xTempOutStream.is() ) @@ -686,14 +669,14 @@ uno::Reference< lang::XMultiServiceFactory > OWriteStream_Impl::GetServiceFactor } catch( const packages::WrongPasswordException& ) { - KillFile( m_aTempURL, GetServiceFactory() ); + KillFile( m_aTempURL, comphelper::getProcessComponentContext() ); m_aTempURL = ::rtl::OUString(); throw; } catch( const uno::Exception& ) { - KillFile( m_aTempURL, GetServiceFactory() ); + KillFile( m_aTempURL, comphelper::getProcessComponentContext() ); m_aTempURL = ::rtl::OUString(); } } @@ -716,13 +699,7 @@ uno::Reference< io::XStream > OWriteStream_Impl::GetTempFileAsStream() if ( !m_aTempURL.isEmpty() ) { // the temporary file is not used if the cache is used - uno::Reference < ucb::XSimpleFileAccess > xTempAccess( - GetServiceFactory()->createInstance ( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess") ) ), - uno::UNO_QUERY ); - - if ( !xTempAccess.is() ) - throw uno::RuntimeException(); // TODO: + uno::Reference < ucb::XSimpleFileAccess2 > xTempAccess( ucb::SimpleFileAccess::create( ::comphelper::getProcessComponentContext() ) ); try { @@ -761,13 +738,7 @@ uno::Reference< io::XInputStream > OWriteStream_Impl::GetTempFileAsInputStream() if ( !m_aTempURL.isEmpty() ) { // the temporary file is not used if the cache is used - uno::Reference < ucb::XSimpleFileAccess > xTempAccess( - GetServiceFactory()->createInstance ( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess") ) ), - uno::UNO_QUERY ); - - if ( !xTempAccess.is() ) - throw uno::RuntimeException(); // TODO: + uno::Reference < ucb::XSimpleFileAccess2 > xTempAccess( ucb::SimpleFileAccess::create( ::comphelper::getProcessComponentContext() ) ); try { @@ -1009,7 +980,7 @@ void OWriteStream_Impl::Revert() if ( !m_aTempURL.isEmpty() ) { - KillFile( m_aTempURL, GetServiceFactory() ); + KillFile( m_aTempURL, comphelper::getProcessComponentContext() ); m_aTempURL = ::rtl::OUString(); } @@ -1445,7 +1416,7 @@ uno::Reference< io::XStream > OWriteStream_Impl::GetStream_Impl( sal_Int32 nStre { if ( !m_aTempURL.isEmpty() ) { - KillFile( m_aTempURL, GetServiceFactory() ); + KillFile( m_aTempURL, comphelper::getProcessComponentContext() ); m_aTempURL = ::rtl::OUString(); } if ( m_xCacheStream.is() ) diff --git a/package/source/xstor/selfterminatefilestream.cxx b/package/source/xstor/selfterminatefilestream.cxx index 62ff69b14caa..b0c55157f344 100644 --- a/package/source/xstor/selfterminatefilestream.cxx +++ b/package/source/xstor/selfterminatefilestream.cxx @@ -27,9 +27,10 @@ ************************************************************************/ -#include <com/sun/star/ucb/XSimpleFileAccess.hpp> +#include <com/sun/star/ucb/SimpleFileAccess.hpp> #include "selfterminatefilestream.hxx" +#include <comphelper/componentcontext.hxx> #include <comphelper/processfactory.hxx> using namespace ::com::sun::star; @@ -45,9 +46,8 @@ OSelfTerminateFileStream::OSelfTerminateFileStream( const uno::Reference< lang:: // IMPORTANT: The implementation is based on idea that m_xFileAccess, m_xInputStream and m_xSeekable are always set // otherwise an exception is thrown in constructor - m_xFileAccess.set( xOwnFactory->createInstance ( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess") ) ), - uno::UNO_QUERY_THROW ); + m_xFileAccess.set( ucb::SimpleFileAccess::create( + comphelper::ComponentContext(xOwnFactory).getUNOContext() ) ); m_xInputStream.set( m_xFileAccess->openFileRead( aURL ), uno::UNO_SET_THROW ); m_xSeekable.set( m_xInputStream, uno::UNO_QUERY_THROW ); diff --git a/package/source/xstor/selfterminatefilestream.hxx b/package/source/xstor/selfterminatefilestream.hxx index 16bc65c5d6cd..5a569d0204a2 100644 --- a/package/source/xstor/selfterminatefilestream.hxx +++ b/package/source/xstor/selfterminatefilestream.hxx @@ -31,7 +31,7 @@ #include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/io/XSeekable.hpp> -#include <com/sun/star/ucb/XSimpleFileAccess.hpp> +#include <com/sun/star/ucb/XSimpleFileAccess2.hpp> #include <cppuhelper/implbase2.hxx> struct OWriteStream_Impl; @@ -40,7 +40,7 @@ class OSelfTerminateFileStream : public cppu::WeakImplHelper2< ::com::sun::star: ::com::sun::star::io::XSeekable > { protected: - ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > m_xFileAccess; + ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess2 > m_xFileAccess; ::rtl::OUString m_aURL; diff --git a/package/source/xstor/xfactory.cxx b/package/source/xstor/xfactory.cxx index 3a0011c3fb4c..150c72a45a81 100644 --- a/package/source/xstor/xfactory.cxx +++ b/package/source/xstor/xfactory.cxx @@ -26,12 +26,14 @@ * ************************************************************************/ -#include <com/sun/star/ucb/XSimpleFileAccess.hpp> +#include <com/sun/star/ucb/SimpleFileAccess.hpp> +#include <com/sun/star/ucb/XSimpleFileAccess2.hpp> #include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/embed/StorageFormats.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/io/XSeekable.hpp> +#include <comphelper/componentcontext.hxx> #include <comphelper/storagehelper.hxx> #include "xfactory.hxx" @@ -162,13 +164,9 @@ uno::Reference< uno::XInterface > SAL_CALL OStorageFactory::createInstanceWithAr throw lang::IllegalArgumentException(); // TODO: } - uno::Reference < ::com::sun::star::ucb::XSimpleFileAccess > xTempAccess( - m_xFactory->createInstance ( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess") ) ), - uno::UNO_QUERY ); - - if ( !xTempAccess.is() ) - throw uno::RuntimeException(); // TODO: + uno::Reference < ucb::XSimpleFileAccess2 > xTempAccess( + ucb::SimpleFileAccess::create( + comphelper::ComponentContext(m_xFactory).getUNOContext() ) ); if ( nStorageMode & embed::ElementModes::WRITE ) xStream = xTempAccess->openFileReadWrite( aURL ); diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx index 0950ec491fe4..84c9400467f1 100644 --- a/package/source/xstor/xstorage.cxx +++ b/package/source/xstor/xstorage.cxx @@ -31,6 +31,8 @@ #include <com/sun/star/embed/UseBackupException.hpp> #include <com/sun/star/embed/StorageFormats.hpp> #include <com/sun/star/ucb/XProgressHandler.hpp> +#include <com/sun/star/ucb/SimpleFileAccess.hpp> +#include <com/sun/star/ucb/XSimpleFileAccess2.hpp> #include <com/sun/star/container/XHierarchicalNameAccess.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/container/XNamed.hpp> @@ -5954,10 +5956,9 @@ void SAL_CALL OStorage::attachToURL( const ::rtl::OUString& sURL, if ( !m_pImpl->m_pSwitchStream ) throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); - uno::Reference < ucb::XSimpleFileAccess > xAccess( - m_pImpl->m_xFactory->createInstance ( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.SimpleFileAccess" ) ) ), - uno::UNO_QUERY_THROW ); + uno::Reference < ucb::XSimpleFileAccess2 > xAccess( + ucb::SimpleFileAccess::create( + comphelper::ComponentContext(m_pImpl->m_xFactory).getUNOContext() ) ); try { diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx index 799f2bf00002..eab1a6e1cd14 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -56,7 +56,8 @@ #include <com/sun/star/ucb/OpenCommandArgument2.hpp> #include <com/sun/star/ucb/OpenMode.hpp> #include <com/sun/star/ucb/XProgressHandler.hpp> -#include <com/sun/star/ucb/XSimpleFileAccess.hpp> +#include <com/sun/star/ucb/SimpleFileAccess.hpp> +#include <com/sun/star/ucb/XSimpleFileAccess2.hpp> #include <com/sun/star/io/XActiveDataStreamer.hpp> #include <com/sun/star/embed/XTransactedObject.hpp> #include <com/sun/star/embed/UseBackupException.hpp> @@ -80,6 +81,7 @@ #include <ucbhelper/contentbroker.hxx> #include <ucbhelper/fileidentifierconverter.hxx> +#include <comphelper/componentcontext.hxx> #include <comphelper/seekableinput.hxx> #include <comphelper/storagehelper.hxx> #include <comphelper/ofopxmlhelper.hxx> @@ -1476,9 +1478,8 @@ void SAL_CALL ZipPackage::commitChanges() if( isLocalFile_Impl( m_aURL ) ) { // write directly in case of local file - uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > xSimpleAccess( - m_xFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess") ) ), - uno::UNO_QUERY ); + uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess2 > xSimpleAccess( + SimpleFileAccess::create( comphelper::ComponentContext(m_xFactory).getUNOContext() ) ); OSL_ENSURE( xSimpleAccess.is(), "Can't instatiate SimpleFileAccess service!\n" ); uno::Reference< io::XTruncate > xOrigTruncate; if ( xSimpleAccess.is() ) |