summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embeddedobj/source/commonembedding/miscobj.cxx8
-rw-r--r--embeddedobj/source/commonembedding/persistence.cxx11
2 files changed, 9 insertions, 10 deletions
diff --git a/embeddedobj/source/commonembedding/miscobj.cxx b/embeddedobj/source/commonembedding/miscobj.cxx
index d65380cdc87e..a5d5573416d1 100644
--- a/embeddedobj/source/commonembedding/miscobj.cxx
+++ b/embeddedobj/source/commonembedding/miscobj.cxx
@@ -231,14 +231,14 @@ void OCommonEmbeddedObject::LinkInit_Impl(
{
// create temporary file
m_aLinkTempFile = io::TempFile::create(m_xContext);
+ uno::Reference< ucb::XSimpleFileAccess > xTempOutAccess(ucb::SimpleFileAccess::create(m_xContext));
+ // if the temp stream is used, then the temp file remains locked
+ uno::Reference< io::XOutputStream > xOutStream(xTempOutAccess->openFileWrite(m_aLinkTempFile->getUri()));
if(m_aLinkTempFile.is())
{
// completely copy content of original OLE data
- uno::Reference < io::XOutputStream > xTempOut = m_aLinkTempFile->getOutputStream();
- ::comphelper::OStorageHelper::CopyInputToOutput( xInStream, xTempOut );
- xTempOut->flush();
- xTempOut->closeOutput();
+ ::comphelper::OStorageHelper::CopyInputToOutput(xInStream, xOutStream);
// reset flag m_bLinkTempFileChanged, so it will also work for multiple
// save op's of the containing file/document
diff --git a/embeddedobj/source/commonembedding/persistence.cxx b/embeddedobj/source/commonembedding/persistence.cxx
index 2aeb60e8eda0..77bc947650af 100644
--- a/embeddedobj/source/commonembedding/persistence.cxx
+++ b/embeddedobj/source/commonembedding/persistence.cxx
@@ -1284,18 +1284,17 @@ void SAL_CALL OCommonEmbeddedObject::storeAsEntry( const uno::Reference< embed::
// tdf#141529 if we have a changed copy of the original OLE data we now
// need to write it back 'over' the original OLE data
uno::Reference < ucb::XSimpleFileAccess2 > xFileAccess(ucb::SimpleFileAccess::create( m_xContext ));
- uno::Reference < io::XInputStream > xTempIn = m_aLinkTempFile->getInputStream();
+ uno::Reference< ucb::XSimpleFileAccess > xTempAccess(ucb::SimpleFileAccess::create(m_xContext));
+ // if the temp stream is used, then the temp file remains locked
+ uno::Reference< io::XInputStream > xInStream(xTempAccess->openFileRead(m_aLinkTempFile->getUri()));
// This is *needed* since OTempFileService calls OTempFileService::readBytes which
// ensures the SvStream mpStream gets/is opened, *but* also sets the mnCachedPos from
// OTempFileService which still points to the end-of-file (from write-cc'ing).
- uno::Reference < io::XSeekable > xSeek( xTempIn, uno::UNO_QUERY_THROW );
+ uno::Reference < io::XSeekable > xSeek( xInStream, uno::UNO_QUERY_THROW );
xSeek->seek(0);
- xFileAccess->writeFile(m_aLinkURL, xTempIn);
-
- // Do *not* close input, that would remove the temporary file too early
- // xTempIn->closeInput();
+ xFileAccess->writeFile(m_aLinkURL, xInStream);
// reset flag m_bLinkTempFileChanged
m_bLinkTempFileChanged = false;