tdf#147589 In document with OLE link, don't show temp-file is in use
Regression from 218f36dd614cf828e949f605faaf6a6fd615da26 change the handling in OTempFileService::closeOutput That was the problem in the OLE-Link handling Change-Id: I5a7fa74b4a731f758e1c405dfb9cd298b30086a3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130408 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
This commit is contained in:
parent
f461c889ac
commit
0498c52272
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user