summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-01-09 14:47:04 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-01-09 18:02:08 +0100
commita3fa2c3bad77b976e7f79de5d0f2abc0283e7b3e (patch)
tree9de61ffd3c1c50e23af81f02bff9a0892b0b0026
parent9754b3feb4092243f30c665abc0344b1a665b5f6 (diff)
Simplify some TempFile service code
Change-Id: Id39be33dcc5aa9378e29c850cb71d3662093ab25 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128189 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--comphelper/source/misc/backupfilehelper.cxx10
-rw-r--r--embeddedobj/source/msole/oleembed.cxx15
-rw-r--r--embeddedobj/source/msole/olepersist.cxx18
-rw-r--r--embeddedobj/source/msole/ownview.cxx14
-rw-r--r--package/source/xstor/owriteablestream.cxx9
-rw-r--r--package/source/zipapi/ZipOutputEntry.cxx9
-rw-r--r--sfx2/source/doc/doctemplates.cxx10
7 files changed, 35 insertions, 50 deletions
diff --git a/comphelper/source/misc/backupfilehelper.cxx b/comphelper/source/misc/backupfilehelper.cxx
index c091ee7ab06b..527c761d834a 100644
--- a/comphelper/source/misc/backupfilehelper.cxx
+++ b/comphelper/source/misc/backupfilehelper.cxx
@@ -629,7 +629,7 @@ namespace
// create a SAXWriter
uno::Reference< xml::sax::XWriter > const xSaxWriter = xml::sax::Writer::create(xContext);
- uno::Reference< io::XStream > xTempFile = io::TempFile::create(xContext);
+ uno::Reference< io::XTempFile > xTempFile = io::TempFile::create(xContext);
uno::Reference< io::XOutputStream > xOutStrm = xTempFile->getOutputStream();
// set output stream and do the serialization
@@ -638,9 +638,7 @@ namespace
// get URL from temp file
uno::Reference < beans::XPropertySet > xTempFileProps(xTempFile, uno::UNO_QUERY);
- uno::Any aUrl = xTempFileProps->getPropertyValue("Uri");
- OUString aTempURL;
- aUrl >>= aTempURL;
+ OUString aTempURL = xTempFile->getUri();
// copy back file
if (aTempURL.isEmpty() || !DirectoryHelper::fileExists(aTempURL))
@@ -1923,9 +1921,7 @@ namespace comphelper
xSerializer->serialize(xSaxWriter, uno::Sequence< beans::StringPair >());
// get URL from temp file
- uno::Reference < beans::XPropertySet > xTempFileProps(xTempFile, uno::UNO_QUERY);
- uno::Any aUrl = xTempFileProps->getPropertyValue("Uri");
- aUrl >>= aTempURL;
+ aTempURL = xTempFile->getUri();
}
// copy back file
diff --git a/embeddedobj/source/msole/oleembed.cxx b/embeddedobj/source/msole/oleembed.cxx
index 15418042f528..b3e4db405015 100644
--- a/embeddedobj/source/msole/oleembed.cxx
+++ b/embeddedobj/source/msole/oleembed.cxx
@@ -681,10 +681,10 @@ namespace
const css::uno::Reference< css::uno::XComponentContext >& xContext,
const css::uno::Reference< css::io::XStream >& xObjectStream )
{
- uno::Reference <beans::XPropertySet> xNativeTempFile(
+ uno::Reference <io::XTempFile> xNativeTempFile(
io::TempFile::create(xContext),
- uno::UNO_QUERY_THROW);
- uno::Reference < io::XStream > xStream(xNativeTempFile, uno::UNO_QUERY_THROW);
+ uno::UNO_SET_THROW);
+ uno::Reference < io::XStream > xStream(xNativeTempFile);
uno::Sequence< uno::Any > aArgs{ uno::Any(xObjectStream),
uno::Any(true) }; // do not create copy
@@ -775,10 +775,8 @@ namespace
if (bCopied)
{
- xNativeTempFile->setPropertyValue("RemoveFile",
- uno::makeAny(false));
- uno::Any aUrl = xNativeTempFile->getPropertyValue("Uri");
- aUrl >>= rUrl;
+ xNativeTempFile->setRemoveFile(false);
+ rUrl = xNativeTempFile->getUri();
xNativeTempFile.clear();
@@ -789,8 +787,7 @@ namespace
}
else
{
- xNativeTempFile->setPropertyValue("RemoveFile",
- uno::makeAny(true));
+ xNativeTempFile->setRemoveFile(true);
}
return xStream;
diff --git a/embeddedobj/source/msole/olepersist.cxx b/embeddedobj/source/msole/olepersist.cxx
index 2686daa2c2c4..c739e0355f67 100644
--- a/embeddedobj/source/msole/olepersist.cxx
+++ b/embeddedobj/source/msole/olepersist.cxx
@@ -89,14 +89,13 @@ OUString GetNewTempFileURL_Impl( const uno::Reference< uno::XComponentContext >&
OUString aResult;
- uno::Reference < beans::XPropertySet > xTempFile(
+ uno::Reference < io::XTempFile > xTempFile(
io::TempFile::create(xContext),
- uno::UNO_QUERY_THROW );
+ uno::UNO_SET_THROW );
try {
- xTempFile->setPropertyValue("RemoveFile", uno::makeAny( false ) );
- uno::Any aUrl = xTempFile->getPropertyValue("Uri");
- aUrl >>= aResult;
+ xTempFile->setRemoveFile( false );
+ aResult = xTempFile->getUri();
}
catch ( const uno::Exception& )
{
@@ -163,16 +162,15 @@ static OUString GetNewFilledTempFile_Impl( const uno::Reference< embed::XOptimiz
try
{
- uno::Reference < beans::XPropertySet > xTempFile(
+ uno::Reference < io::XTempFile > xTempFile(
io::TempFile::create(xContext),
uno::UNO_QUERY );
- uno::Reference < io::XStream > xTempStream( xTempFile, uno::UNO_QUERY_THROW );
+ uno::Reference < io::XStream > xTempStream = xTempFile;
xParentStorage->copyStreamElementData( aEntryName, xTempStream );
- xTempFile->setPropertyValue("RemoveFile", uno::makeAny( false ) );
- uno::Any aUrl = xTempFile->getPropertyValue("Uri");
- aUrl >>= aResult;
+ xTempFile->setRemoveFile( false );
+ aResult = xTempFile->getUri();
}
catch( const uno::RuntimeException& )
{
diff --git a/embeddedobj/source/msole/ownview.cxx b/embeddedobj/source/msole/ownview.cxx
index 4aaf35499124..e739359249b2 100644
--- a/embeddedobj/source/msole/ownview.cxx
+++ b/embeddedobj/source/msole/ownview.cxx
@@ -243,19 +243,17 @@ bool OwnView_Impl::ReadContentsAndGenerateTempFile( const uno::Reference< io::XI
// create m_aNativeTempURL
OUString aNativeTempURL;
- uno::Reference < beans::XPropertySet > xNativeTempFile(
+ uno::Reference < io::XTempFile > xNativeTempFile(
io::TempFile::create(m_xContext),
- uno::UNO_QUERY_THROW );
- uno::Reference < io::XStream > xNativeTempStream( xNativeTempFile, uno::UNO_QUERY_THROW );
- uno::Reference < io::XOutputStream > xNativeOutTemp = xNativeTempStream->getOutputStream();
- uno::Reference < io::XInputStream > xNativeInTemp = xNativeTempStream->getInputStream();
+ uno::UNO_SET_THROW );
+ uno::Reference < io::XOutputStream > xNativeOutTemp = xNativeTempFile->getOutputStream();
+ uno::Reference < io::XInputStream > xNativeInTemp = xNativeTempFile->getInputStream();
if ( !xNativeOutTemp.is() || !xNativeInTemp.is() )
throw uno::RuntimeException();
try {
- xNativeTempFile->setPropertyValue("RemoveFile", uno::makeAny( false ) );
- uno::Any aUrl = xNativeTempFile->getPropertyValue("Uri");
- aUrl >>= aNativeTempURL;
+ xNativeTempFile->setRemoveFile( false );
+ aNativeTempURL = xNativeTempFile->getUri();
}
catch ( uno::Exception& )
{
diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx
index b141a469ece2..720632c87d60 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -222,14 +222,13 @@ OUString GetNewTempFileURL( const uno::Reference< uno::XComponentContext >& rCon
{
OUString aTempURL;
- uno::Reference < beans::XPropertySet > xTempFile(
+ uno::Reference < io::XTempFile > xTempFile(
io::TempFile::create(rContext),
- uno::UNO_QUERY_THROW );
+ uno::UNO_SET_THROW );
try {
- xTempFile->setPropertyValue( "RemoveFile", uno::makeAny( false ) );
- uno::Any aUrl = xTempFile->getPropertyValue( "Uri" );
- aUrl >>= aTempURL;
+ xTempFile->setRemoveFile( false );
+ aTempURL = xTempFile->getUri();
}
catch ( const uno::Exception& )
{
diff --git a/package/source/zipapi/ZipOutputEntry.cxx b/package/source/zipapi/ZipOutputEntry.cxx
index 5115c7a3ebc1..a30eba7c981c 100644
--- a/package/source/zipapi/ZipOutputEntry.cxx
+++ b/package/source/zipapi/ZipOutputEntry.cxx
@@ -252,12 +252,11 @@ void ZipOutputEntryInThread::createBufferFile()
{
assert(!m_xOutStream.is() && m_aTempURL.isEmpty() &&
"should only be called in the threaded mode where there is no existing stream yet");
- uno::Reference < beans::XPropertySet > xTempFileProps(
+ uno::Reference < io::XTempFile > xTempFile(
io::TempFile::create(m_xContext),
- uno::UNO_QUERY_THROW );
- xTempFileProps->setPropertyValue("RemoveFile", uno::makeAny(false));
- uno::Any aUrl = xTempFileProps->getPropertyValue( "Uri" );
- aUrl >>= m_aTempURL;
+ uno::UNO_SET_THROW );
+ xTempFile->setRemoveFile(false);
+ m_aTempURL = xTempFile->getUri();
assert(!m_aTempURL.isEmpty());
uno::Reference < ucb::XSimpleFileAccess3 > xTempAccess(ucb::SimpleFileAccess::create(m_xContext));
diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx
index f2e13da357e2..9ac236b3b4f4 100644
--- a/sfx2/source/doc/doctemplates.cxx
+++ b/sfx2/source/doc/doctemplates.cxx
@@ -1269,15 +1269,13 @@ bool SfxDocTplService_Impl::WriteUINamesForTemplateDir_Impl( const OUString& aUs
{
bool bResult = false;
try {
- uno::Reference< beans::XPropertySet > xTempFile(
+ uno::Reference< io::XTempFile > xTempFile(
io::TempFile::create(mxContext),
- uno::UNO_QUERY_THROW );
+ uno::UNO_SET_THROW );
- OUString aTempURL;
- uno::Any aUrl = xTempFile->getPropertyValue("Uri");
- aUrl >>= aTempURL;
+ OUString aTempURL = xTempFile->getUri();
- uno::Reference< io::XStream > xStream( xTempFile, uno::UNO_QUERY_THROW );
+ uno::Reference< io::XStream > xStream( xTempFile );
uno::Reference< io::XOutputStream > xOutStream = xStream->getOutputStream();
if ( !xOutStream.is() )
throw uno::RuntimeException();