diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-01-09 14:47:04 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-09 18:02:08 +0100 |
commit | a3fa2c3bad77b976e7f79de5d0f2abc0283e7b3e (patch) | |
tree | 9de61ffd3c1c50e23af81f02bff9a0892b0b0026 /embeddedobj | |
parent | 9754b3feb4092243f30c665abc0344b1a665b5f6 (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>
Diffstat (limited to 'embeddedobj')
-rw-r--r-- | embeddedobj/source/msole/oleembed.cxx | 15 | ||||
-rw-r--r-- | embeddedobj/source/msole/olepersist.cxx | 18 | ||||
-rw-r--r-- | embeddedobj/source/msole/ownview.cxx | 14 |
3 files changed, 20 insertions, 27 deletions
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& ) { |