oox/source/helper/zipstorage.cxx    |   30 ++++++++++++++++++++----------
 sal/inc/sal/log-areas.dox           |    1 +
 sax/source/tools/fastserializer.cxx |    2 ++
 sfx2/source/doc/docfile.cxx         |   15 ++++++++++++++-
 4 files changed, 37 insertions(+), 11 deletions(-)

New commits:
commit 3f899eae02eaad0b967de749fe09b869ba93ad6d
Author: Michael Stahl <mst...@redhat.com>
Date:   Sun Nov 11 16:39:10 2012 +0100

    oox: ZipStorage: better exception tracing
    
    Change-Id: I2b81f92cea8a8c9577c3f9ca33b915942708330c

diff --git a/oox/source/helper/zipstorage.cxx b/oox/source/helper/zipstorage.cxx
index 4ddb09e..1845afd 100644
--- a/oox/source/helper/zipstorage.cxx
+++ b/oox/source/helper/zipstorage.cxx
@@ -67,8 +67,10 @@ ZipStorage::ZipStorage( const Reference< XComponentContext 
>& rxContext, const R
             ZIP_STORAGE_FORMAT_STRING, rxInStream, xFactory,
             sal_False );    // DEV300_m80: Was sal_True, but DOCX and others 
did not load
     }
-    catch( Exception& )
+    catch (Exception const& e)
     {
+        SAL_WARN("oox.storage", "ZipStorage::ZipStorage "
+                "exception opening input storage: " << e.Message);
     }
 }
 
@@ -84,9 +86,10 @@ ZipStorage::ZipStorage( const Reference< XComponentContext 
>& rxContext, const R
         mxStorage = ::comphelper::OStorageHelper::GetStorageOfFormatFromStream(
             OFOPXML_STORAGE_FORMAT_STRING, rxStream, nOpenMode, xFactory, 
sal_True );
     }
-    catch( Exception& )
+    catch (Exception const& e)
     {
-        OSL_FAIL( "ZipStorage::ZipStorage - cannot open output storage" );
+        SAL_WARN("oox.storage", "ZipStorage::ZipStorage "
+                "exception opening output storage: " << e.Message);
     }
 }
 
@@ -94,7 +97,8 @@ ZipStorage::ZipStorage( const ZipStorage& rParentStorage, 
const Reference< XStor
     StorageBase( rParentStorage, rElementName, rParentStorage.isReadOnly() ),
     mxStorage( rxStorage )
 {
-    OSL_ENSURE( mxStorage.is(), "ZipStorage::ZipStorage - missing storage" );
+    SAL_WARN_IF(!mxStorage.is(), "oox.storage", "ZipStorage::ZipStorage "
+            " - missing storage" );
 }
 
 ZipStorage::~ZipStorage()
@@ -120,8 +124,9 @@ void ZipStorage::implGetElementNames( ::std::vector< 
OUString >& orElementNames
         if( aNames.getLength() > 0 )
             orElementNames.insert( orElementNames.end(), 
aNames.getConstArray(), aNames.getConstArray() + aNames.getLength() );
     }
-    catch( Exception& )
+    catch (Exception const& e)
     {
+        SAL_INFO("oox.storage", "getElementNames: exception: " << e.Message);
     }
 }
 
@@ -140,8 +145,9 @@ StorageRef ZipStorage::implOpenSubStorage( const OUString& 
rElementName, bool bC
     {
         bMissing = true;
     }
-    catch( Exception& )
+    catch (Exception const& e)
     {
+        SAL_INFO("oox.storage", "openStorageElement: exception: " << 
e.Message);
     }
 
     if( bMissing && bCreateMissing ) try
@@ -149,8 +155,9 @@ StorageRef ZipStorage::implOpenSubStorage( const OUString& 
rElementName, bool bC
         xSubXStorage = mxStorage->openStorageElement(
             rElementName, ::com::sun::star::embed::ElementModes::READWRITE );
     }
-    catch( Exception& )
+    catch (Exception const& e)
     {
+        SAL_INFO("oox.storage", "openStorageElement: exception: " << 
e.Message);
     }
 
     StorageRef xSubStorage;
@@ -166,8 +173,9 @@ Reference< XInputStream > ZipStorage::implOpenInputStream( 
const OUString& rElem
     {
         xInStream.set( mxStorage->openStreamElement( rElementName, 
::com::sun::star::embed::ElementModes::READ ), UNO_QUERY );
     }
-    catch( Exception& )
+    catch (Exception const& e)
     {
+        SAL_INFO("oox.storage", "openStreamElement: exception: " << e.Message);
     }
     return xInStream;
 }
@@ -179,8 +187,9 @@ Reference< XOutputStream > 
ZipStorage::implOpenOutputStream( const OUString& rEl
     {
         xOutStream.set( mxStorage->openStreamElement( rElementName, 
::com::sun::star::embed::ElementModes::READWRITE ), UNO_QUERY );
     }
-    catch( Exception& )
+    catch (Exception const& e)
     {
+        SAL_INFO("oox.storage", "openStreamElement: exception: " << e.Message);
     }
     return xOutStream;
 }
@@ -191,8 +200,9 @@ void ZipStorage::implCommit() const
     {
         Reference< XTransactedObject >( mxStorage, UNO_QUERY_THROW )->commit();
     }
-    catch( Exception& )
+    catch (Exception const& e)
     {
+        SAL_WARN("oox.storage", "commit: exception: " << e.Message);
     }
 }
 
diff --git a/sal/inc/sal/log-areas.dox b/sal/inc/sal/log-areas.dox
index 0eadebb..45220ee 100644
--- a/sal/inc/sal/log-areas.dox
+++ b/sal/inc/sal/log-areas.dox
@@ -81,6 +81,7 @@ certain functionality.
 @li @c filter.ms - escher import/export
 @li @c filter.xslt - xslt import/export
 @li @c oox.xmlstream - XmlStream class
+@li @c oox.storage - ZipStorage class
 
 @section formula
 
commit 9decde005bc32c7fa495621548f6310737a89120
Author: Michael Stahl <mst...@redhat.com>
Date:   Sun Nov 11 16:37:56 2012 +0100

    sax: FastSaxSerializer: cannot do anything without a stream
    
    Change-Id: If2fbfe776039fe1a3104d541279ab52f219f45bf

diff --git a/sax/source/tools/fastserializer.cxx 
b/sax/source/tools/fastserializer.cxx
index d12e771..bc2b12e 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -73,6 +73,7 @@ namespace sax_fastparser {
 
     void SAL_CALL FastSaxSerializer::startDocument(  ) throw (SAXException, 
RuntimeException)
     {
+        assert(mxOutputStream.is()); // cannot do anything without that
         if (!mxOutputStream.is())
             return;
         rtl::ByteSequence aXmlHeader((const sal_Int8*) "<?xml version=\"1.0\" 
encoding=\"UTF-8\" standalone=\"yes\"?>\n", 56);
@@ -186,6 +187,7 @@ namespace sax_fastparser {
         throw (::com::sun::star::uno::RuntimeException)
     {
         mxOutputStream = xOutputStream;
+        assert(mxOutputStream.is()); // cannot do anything without that
     }
 
     void SAL_CALL FastSaxSerializer::setFastTokenHandler( const 
::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler 
>& xFastTokenHandler )
commit 0c2206081de38a41597aadfb2255540d6308be63
Author: Michael Stahl <mst...@redhat.com>
Date:   Sun Nov 11 00:47:03 2012 +0100

    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

diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 9be89f5..b1f3541 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();
         }
     }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to