diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-11-22 20:57:40 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-11-25 10:55:10 -0500 |
commit | e00562d9835bd82d74ef0301ea7425ff769915df (patch) | |
tree | 60a1b5331b09171a852c318afbcc7f4d7b8870d7 /oox | |
parent | 8e5fd4a15ae2c7d55842b1b768b7807a2d3a298e (diff) |
Allow worker threads to use their own FastParser instances.
To prevent deadlock during threaded sheet stream parsing. It now
deadlocks at a different place.
Change-Id: I0ba0f2c9a257e71b0a340ab14e369b06d5fd8829
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/core/xmlfilterbase.cxx | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index dddc29c7e5a8..30f384898ce9 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -143,6 +143,13 @@ struct NamespaceIds: public rtl::StaticWithInit< } }; +void registerNamespaces( FastParser& rParser ) +{ + const Sequence< beans::Pair<OUString, sal_Int32> > ids = NamespaceIds::get(); + for (sal_Int32 i = 0; i < ids.getLength(); ++i) + rParser.registerNamespace(ids[i].Second); +} + } // namespace struct XmlFilterBaseImpl @@ -164,10 +171,7 @@ XmlFilterBaseImpl::XmlFilterBaseImpl( const Reference< XComponentContext >& rxCo maVmlSuffix( ".vml" ) { // register XML namespaces - const Sequence< beans::Pair< OUString, sal_Int32 > > ids= - NamespaceIds::get(); - for( sal_Int32 i=0; i<ids.getLength(); ++i ) - maFastParser.registerNamespace( ids[i].Second ); + registerNamespaces(maFastParser); } XmlFilterBase::XmlFilterBase( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) : @@ -203,13 +207,25 @@ void XmlFilterBase::importDocumentProperties() xImporter->importProperties( xDocumentStorage, xPropSupplier->getDocumentProperties() ); } +FastParser* XmlFilterBase::createParser() const +{ + FastParser* pParser = new FastParser(getComponentContext()); + registerNamespaces(*pParser); + return pParser; +} + OUString XmlFilterBase::getFragmentPathFromFirstType( const OUString& rType ) { // importRelations() caches the relations map for subsequence calls return importRelations( OUString() )->getFragmentPathFromFirstType( rType ); } -bool XmlFilterBase::importFragment( const ::rtl::Reference< FragmentHandler >& rxHandler ) +bool XmlFilterBase::importFragment( const rtl::Reference<FragmentHandler>& rxHandler ) +{ + return importFragment(rxHandler, mxImpl->maFastParser); +} + +bool XmlFilterBase::importFragment( const rtl::Reference<FragmentHandler>& rxHandler, FastParser& rParser ) { OSL_ENSURE( rxHandler.is(), "XmlFilterBase::importFragment - missing fragment handler" ); if( !rxHandler.is() ) @@ -263,8 +279,8 @@ bool XmlFilterBase::importFragment( const ::rtl::Reference< FragmentHandler >& r // own try/catch block for showing parser failure assertion with fragment path if( xInStrm.is() ) try { - mxImpl->maFastParser.setDocumentHandler( xDocHandler ); - mxImpl->maFastParser.parseStream( xInStrm, aFragmentPath ); + rParser.setDocumentHandler(xDocHandler); + rParser.parseStream(xInStrm, aFragmentPath); return true; } catch( Exception& ) |