summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sax/source/fastparser/fastparser.cxx17
-rw-r--r--writerfilter/source/ooxml/factoryimpl.py6
2 files changed, 18 insertions, 5 deletions
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index 83b36d122f42..4ae2f4fdaf4a 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -247,6 +247,7 @@ public:
void parse();
void produce( bool bForceFlush = false );
bool m_bIgnoreMissingNSDecl;
+ bool m_bDisableThreadedParser;
private:
bool consume(EventList&);
@@ -634,6 +635,7 @@ namespace sax_fastparser {
FastSaxParserImpl::FastSaxParserImpl() :
m_bIgnoreMissingNSDecl(false),
+ m_bDisableThreadedParser(false),
mpTop(nullptr)
{
mxDocumentLocator.set( new FastLocatorImpl( this ) );
@@ -781,7 +783,7 @@ void FastSaxParserImpl::parseStream(const InputSource& rStructSource)
rEntity.mxDocumentHandler->startDocument();
}
- if (!getenv("SAX_DISABLE_THREADS"))
+ if (!getenv("SAX_DISABLE_THREADS") && !m_bDisableThreadedParser)
{
Reference<css::io::XSeekable> xSeekable(rEntity.maStructSource.aInputStream, UNO_QUERY);
// available() is not __really__ relevant here, but leave it in as a heuristic for non-seekable streams
@@ -1325,11 +1327,16 @@ FastSaxParser::initialize(css::uno::Sequence< css::uno::Any > const& rArguments)
if (rArguments.getLength())
{
OUString str;
- if ( ( rArguments[0] >>= str ) && "IgnoreMissingNSDecl" == str )
- mpImpl->m_bIgnoreMissingNSDecl = true;
- else if ( str == "DoSmeplease" )
+ if ( rArguments[0] >>= str )
{
- //just ignore as this is already immune to billion laughs
+ if ( str == "IgnoreMissingNSDecl" )
+ mpImpl->m_bIgnoreMissingNSDecl = true;
+ else if ( str == "DoSmeplease" )
+ ; //just ignore as this is already immune to billion laughs
+ else if ( str == "DisableThreadedParser" )
+ mpImpl->m_bDisableThreadedParser = true;
+ else
+ throw IllegalArgumentException();
}
else
throw IllegalArgumentException();
diff --git a/writerfilter/source/ooxml/factoryimpl.py b/writerfilter/source/ooxml/factoryimpl.py
index acbaf4234261..2d54ee8ff6b8 100644
--- a/writerfilter/source/ooxml/factoryimpl.py
+++ b/writerfilter/source/ooxml/factoryimpl.py
@@ -152,6 +152,11 @@ def getFastParser():
if (!mxFastParser.is())
{
mxFastParser = css::xml::sax::FastParser::create(mxContext);
+ // the threaded parser is about 20% slower loading writer documents
+ css::uno::Reference< css::lang::XInitialization > xInit( mxFastParser, css::uno::UNO_QUERY_THROW );
+ css::uno::Sequence< css::uno::Any > args(1);
+ args[0] <<= OUString("DisableThreadedParser");
+ xInit->initialize(args);
""")
for url in sorted(ooxUrlAliases.keys()):
print(""" mxFastParser->registerNamespace("%s", oox::NMSP_%s);""" % (url, ooxUrlAliases[url]))
@@ -167,6 +172,7 @@ def getFastParser():
def createImpl(model):
print("""
#include <com/sun/star/xml/sax/FastParser.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
#include "ooxml/OOXMLFactory.hxx"
#include "ooxml/OOXMLFastHelper.hxx"
#include "ooxml/OOXMLStreamImpl.hxx"