summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-11-11 00:47:03 +0100
committerMichael Stahl <mstahl@redhat.com>2012-11-11 16:59:16 +0100
commit0c2206081de38a41597aadfb2255540d6308be63 (patch)
tree667d02a5821d79579d2e4b41037f280ed750d405
parentf3aa69b0257744df7105606c1a8f0d1b44ac8d0a (diff)
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
-rw-r--r--sfx2/source/doc/docfile.cxx15
1 files changed, 14 insertions, 1 deletions
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 9be89f51114a..b1f3541c22d2 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -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();
}
}