Kaydet (Commit) 0c220608 authored tarafından Michael Stahl's avatar Michael Stahl

SfxMedium::GetOutputStream(): re-use existing XStream

The ScExportTest::testConditionalFormatExportXLSX() fails on Windows
because of how SfxMedium handles its streams:
1. SfxMedium::GetOutputStorage() creates some temp file
2. SfxMedium::GetMedium_Impl() opens a XStream on the temp file
3. SfxMedium::GetOutStream() wants to open a SvFileStream on the temp
   file, but because the file is already open and the sharing options
   are set to deny sharing, opening fails with ERROR_SHARING_VIOLATION

Prevent that by re-using the already open XStream in GetOutStream.
Hopefully this does not break anything, and there is already a comment
in CloseInStream_Impl() indicating that m_pOutStream and xStream are
related.

(interestingly ERROR_SHARING_VIOLATION is documented to occur if
_another_ process has the file open, but evidently it happens here on
NT 6.1 for the same process...)

Change-Id: I6d2ec36fd45a0317e947ddfb436472a8b86fbe26
üst f3aa69b0
......@@ -637,7 +637,20 @@ SvStream* SfxMedium::GetOutStream()
if ( pImp->pTempFile )
{
pImp->m_pOutStream = new SvFileStream( pImp->m_aName, STREAM_STD_READWRITE );
// try to re-use XOutStream from xStream if that exists;
// opening new SvFileStream in this situation may fail on
// Windows with ERROR_SHARING_VIOLATION
if (pImp->xStream.is())
{
assert(pImp->xStream->getOutputStream().is()); // need that...
pImp->m_pOutStream = utl::UcbStreamHelper::CreateStream(
pImp->xStream, false);
}
else
{
pImp->m_pOutStream = new SvFileStream(
pImp->m_aName, STREAM_STD_READWRITE);
}
CloseStorage();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment