summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-08-23 17:23:26 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-08-27 15:40:08 +0200
commit206c70eef30f7b6f538b88f7fb9505f397bef073 (patch)
treed311561f2eb90b57aeed5c1642882a90ddbd4c6a /package
parent7634d064adc2c773288cec751674ff691de20b2b (diff)
fdo#46808, Adapt TempFile UNO service to new style
Change-Id: Ia448d6d74201e2be487c6d8317f94be3745808aa
Diffstat (limited to 'package')
-rw-r--r--package/source/xstor/owriteablestream.cxx10
-rw-r--r--package/source/xstor/switchpersistencestream.cxx4
-rw-r--r--package/source/xstor/xfactory.cxx8
-rw-r--r--package/source/xstor/xstorage.cxx9
-rw-r--r--package/source/zippackage/ZipPackage.cxx3
-rw-r--r--package/source/zippackage/ZipPackageStream.cxx28
6 files changed, 28 insertions, 34 deletions
diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx
index 25e66390754d..ce8b36e2382b 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -24,6 +24,7 @@
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/io/TempFile.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/io/IOException.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
@@ -236,11 +237,8 @@ const sal_Int32 n_ConstBufferSize = 32000;
::rtl::OUString aTempURL;
uno::Reference < beans::XPropertySet > xTempFile(
- xFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.TempFile") ) ),
- uno::UNO_QUERY );
-
- if ( !xTempFile.is() )
- throw uno::RuntimeException(); // TODO
+ io::TempFile::create(comphelper::ComponentContext(xFactory).getUNOContext()),
+ uno::UNO_QUERY_THROW );
try {
xTempFile->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveFile") ), uno::makeAny( sal_False ) );
@@ -1513,7 +1511,7 @@ void OWriteStream_Impl::CreateReadonlyCopyBasedOnData( const uno::Reference< io:
uno::Reference < io::XStream > xTempFile;
if ( !xTargetStream.is() )
xTempFile = uno::Reference < io::XStream >(
- m_xFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.TempFile") ) ),
+ io::TempFile::create(comphelper::ComponentContext(m_xFactory).getUNOContext()),
uno::UNO_QUERY );
else
xTempFile = xTargetStream;
diff --git a/package/source/xstor/switchpersistencestream.cxx b/package/source/xstor/switchpersistencestream.cxx
index 41f43f51ec56..359a65a0ac40 100644
--- a/package/source/xstor/switchpersistencestream.cxx
+++ b/package/source/xstor/switchpersistencestream.cxx
@@ -19,6 +19,8 @@
#include <osl/diagnose.h>
+#include <com/sun/star/io/TempFile.hpp>
+#include <comphelper/componentcontext.hxx>
#include <comphelper/storagehelper.hxx>
#include <switchpersistencestream.hxx>
@@ -174,7 +176,7 @@ void SwitchablePersistenceStream::CopyAndSwitchPersistenceTo( const uno::Referen
if ( !xTargetStream.is() )
{
xTargetStream = uno::Reference < io::XStream >(
- m_xFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.TempFile") ) ),
+ io::TempFile::create(comphelper::ComponentContext(m_xFactory).getUNOContext()),
uno::UNO_QUERY_THROW );
xTargetSeek = uno::Reference< io::XSeekable >( xTargetStream, uno::UNO_QUERY_THROW );
diff --git a/package/source/xstor/xfactory.cxx b/package/source/xstor/xfactory.cxx
index 8012c82072d5..302334646d25 100644
--- a/package/source/xstor/xfactory.cxx
+++ b/package/source/xstor/xfactory.cxx
@@ -22,6 +22,7 @@
#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/TempFile.hpp>
#include <com/sun/star/io/XSeekable.hpp>
#include <comphelper/componentcontext.hxx>
@@ -84,11 +85,8 @@ uno::Reference< uno::XInterface > SAL_CALL OStorageFactory::createInstance()
{
// TODO: reimplement TempStream service to support XStream interface
uno::Reference < io::XStream > xTempStream(
- m_xFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.TempFile") ) ),
- uno::UNO_QUERY );
-
- if ( !xTempStream.is() )
- throw uno::RuntimeException(); // TODO:
+ io::TempFile::create(comphelper::ComponentContext(m_xFactory).getUNOContext()),
+ uno::UNO_QUERY_THROW );
return uno::Reference< uno::XInterface >(
static_cast< OWeakObject* >( new OStorage( xTempStream,
diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx
index d8fade3b2912..9900cbc4dcad 100644
--- a/package/source/xstor/xstorage.cxx
+++ b/package/source/xstor/xstorage.cxx
@@ -22,6 +22,7 @@
#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/io/TempFile.hpp>
#include <com/sun/star/ucb/SimpleFileAccess.hpp>
#include <com/sun/star/ucb/XSimpleFileAccess2.hpp>
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
@@ -144,7 +145,7 @@ uno::Reference< io::XInputStream > GetSeekableTempCopy( uno::Reference< io::XInp
uno::Reference< lang::XMultiServiceFactory > xFactory )
{
uno::Reference < io::XOutputStream > xTempOut(
- xFactory->createInstance ( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.io.TempFile" ) ) ),
+ io::TempFile::create(comphelper::ComponentContext(xFactory).getUNOContext()),
uno::UNO_QUERY );
uno::Reference < io::XInputStream > xTempIn( xTempOut, uno::UNO_QUERY );
@@ -3800,8 +3801,7 @@ uno::Reference< io::XInputStream > SAL_CALL OStorage::getPlainRawStreamElement(
throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
uno::Reference < io::XOutputStream > xTempOut(
- m_pImpl->GetServiceFactory()->createInstance (
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.io.TempFile" ) ) ),
+ io::TempFile::create(comphelper::ComponentContext(m_pImpl->GetServiceFactory()).getUNOContext()),
uno::UNO_QUERY );
xTempIn = uno::Reference < io::XInputStream >( xTempOut, uno::UNO_QUERY );
uno::Reference < io::XSeekable > xSeek( xTempOut, uno::UNO_QUERY );
@@ -3913,8 +3913,7 @@ uno::Reference< io::XInputStream > SAL_CALL OStorage::getRawEncrStreamElement(
throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
uno::Reference < io::XOutputStream > xTempOut(
- m_pImpl->GetServiceFactory()->createInstance (
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.io.TempFile" ) ) ),
+ io::TempFile::create(comphelper::ComponentContext(m_pImpl->GetServiceFactory()).getUNOContext()),
uno::UNO_QUERY );
xTempIn = uno::Reference < io::XInputStream >( xTempOut, uno::UNO_QUERY );
uno::Reference < io::XSeekable > xSeek( xTempOut, uno::UNO_QUERY );
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index e6abbea5b4ee..bc941a61b7f3 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -31,6 +31,7 @@
#include <com/sun/star/packages/zip/ZipConstants.hpp>
#include <com/sun/star/packages/manifest/XManifestReader.hpp>
#include <com/sun/star/packages/manifest/XManifestWriter.hpp>
+#include <com/sun/star/io/TempFile.hpp>
#include <com/sun/star/io/XStream.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
@@ -1177,7 +1178,7 @@ uno::Reference< io::XInputStream > ZipPackage::writeTempFile()
if( bUseTemp )
{
// create temporary file
- uno::Reference < io::XStream > xTempFile( m_xFactory->createInstance ("com.sun.star.io.TempFile"), UNO_QUERY_THROW );
+ uno::Reference < io::XStream > xTempFile( io::TempFile::create(comphelper::ComponentContext(m_xFactory).getUNOContext()), UNO_QUERY_THROW );
xTempOut.set( xTempFile->getOutputStream(), UNO_SET_THROW );
xTempIn.set( xTempFile->getInputStream(), UNO_SET_THROW );
}
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index a8029ff9ec72..5c7feb7645ca 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -21,6 +21,7 @@
#include <com/sun/star/packages/zip/ZipConstants.hpp>
#include <com/sun/star/embed/StorageFormats.hpp>
#include <com/sun/star/packages/zip/ZipIOException.hpp>
+#include <com/sun/star/io/TempFile.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/io/XStream.hpp>
@@ -37,6 +38,7 @@
#include <osl/diagnose.h>
#include "wrapstreamforshare.hxx"
+#include <comphelper/componentcontext.hxx>
#include <comphelper/seekableinput.hxx>
#include <comphelper/storagehelper.hxx>
@@ -175,12 +177,10 @@ uno::Reference< io::XInputStream > ZipPackageStream::GetRawEncrStreamNoHeaderCop
// create temporary stream
uno::Reference < io::XOutputStream > xTempOut(
- m_xFactory->createInstance("com.sun.star.io.TempFile"),
- uno::UNO_QUERY );
- uno::Reference < io::XInputStream > xTempIn( xTempOut, UNO_QUERY );
- uno::Reference < io::XSeekable > xTempSeek( xTempOut, UNO_QUERY );
- if ( !xTempOut.is() || !xTempIn.is() || !xTempSeek.is() )
- throw io::IOException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
+ io::TempFile::create(comphelper::ComponentContext(m_xFactory).getUNOContext()),
+ uno::UNO_QUERY_THROW );
+ uno::Reference < io::XInputStream > xTempIn( xTempOut, UNO_QUERY_THROW );
+ uno::Reference < io::XSeekable > xTempSeek( xTempOut, UNO_QUERY_THROW );
// copy the raw stream to the temporary file starting from the current position
::comphelper::OStorageHelper::CopyInputToOutput( GetOwnSeekStream(), xTempOut );
@@ -282,10 +282,8 @@ uno::Reference< io::XInputStream > ZipPackageStream::TryToGetRawFromDataStream(
{
// create temporary file
uno::Reference < io::XStream > xTempStream(
- m_xFactory->createInstance ("com.sun.star.io.TempFile"),
- uno::UNO_QUERY );
- if ( !xTempStream.is() )
- throw io::IOException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
+ io::TempFile::create(comphelper::ComponentContext(m_xFactory).getUNOContext()),
+ uno::UNO_QUERY_THROW );
// create a package based on it
ZipPackage* pPackage = new ZipPackage( m_xFactory );
@@ -341,12 +339,10 @@ uno::Reference< io::XInputStream > ZipPackageStream::TryToGetRawFromDataStream(
// create another temporary file
uno::Reference < io::XOutputStream > xTempOut(
- m_xFactory->createInstance ("com.sun.star.io.TempFile"),
- uno::UNO_QUERY );
- uno::Reference < io::XInputStream > xTempIn( xTempOut, UNO_QUERY );
- uno::Reference < io::XSeekable > xTempSeek( xTempOut, UNO_QUERY );
- if ( !xTempOut.is() || !xTempIn.is() || !xTempSeek.is() )
- throw io::IOException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
+ io::TempFile::create(comphelper::ComponentContext(m_xFactory).getUNOContext()),
+ uno::UNO_QUERY_THROW );
+ uno::Reference < io::XInputStream > xTempIn( xTempOut, UNO_QUERY_THROW );
+ uno::Reference < io::XSeekable > xTempSeek( xTempOut, UNO_QUERY_THROW );
// copy the raw stream to the temporary file
::comphelper::OStorageHelper::CopyInputToOutput( xInRaw, xTempOut );