tdf#144364 sw: Revert "Use FastParser in SwXMLTextBlocks"
This reverts 7.0 commit fd6feb4f538b0c5c9061529ff002be9f62a7239a.
Noel said this was just a performance fix, so just go ahead
and revert it.
It caused the regression documented in bug 144364.
Change-Id: I044c49e42873db120a94d93a00e9b35105778b9c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127012
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index ca37d6f..3589d4d 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -1939,6 +1939,25 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf116315)
}
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf144364)
{
SwDoc* const pDoc = createSwDoc();
SwWrtShell* const pWrtSh = pDoc->GetDocShell()->GetWrtShell();
CPPUNIT_ASSERT(pWrtSh);
// expands autotext (via F3)
pWrtSh->Insert("AR");
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_F3);
Scheduler::ProcessEventsToIdle();
// was ...'letter of <placeholder:"November 21, 2004":"Click placeholder and overwrite">'
CPPUNIT_ASSERT_EQUAL(
OUString("We hereby acknowledge the receipt of your letter of <November 21, 2004>."),
getParagraph(1)->getString());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf141613)
{
SwDoc* const pDoc = createSwDoc();
diff --git a/sw/source/core/swg/SwXMLTextBlocks1.cxx b/sw/source/core/swg/SwXMLTextBlocks1.cxx
index 9f0c6cb..36ff822 100644
--- a/sw/source/core/swg/SwXMLTextBlocks1.cxx
+++ b/sw/source/core/swg/SwXMLTextBlocks1.cxx
@@ -31,6 +31,7 @@
#include <com/sun/star/io/IOException.hpp>
#include <com/sun/star/xml/sax/FastParser.hpp>
#include <com/sun/star/xml/sax/FastToken.hpp>
#include <com/sun/star/xml/sax/Parser.hpp>
#include <com/sun/star/xml/sax/Writer.hpp>
#include <com/sun/star/xml/sax/SAXParseException.hpp>
#include <com/sun/star/document/XStorageBasedDocument.hpp>
@@ -194,6 +195,9 @@ ErrCode SwXMLTextBlocks::GetMacroTable( sal_uInt16 nIdx,
uno::Reference< uno::XComponentContext > xContext =
comphelper::getProcessComponentContext();
// get parser
uno::Reference< xml::sax::XParser > xParser = xml::sax::Parser::create( xContext );
// create descriptor and reference to it. Either
// both or neither must be kept because of the
// reference counting!
@@ -205,15 +209,21 @@ ErrCode SwXMLTextBlocks::GetMacroTable( sal_uInt16 nIdx,
OUString sFilterComponent = bOasis
? OUString("com.sun.star.comp.Writer.XMLOasisAutotextEventsImporter")
: OUString("com.sun.star.comp.Writer.XMLAutotextEventsImporter");
uno::Reference< xml::sax::XFastParser > xFilter(
uno::Reference< xml::sax::XDocumentHandler > xFilter(
xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
sFilterComponent, aFilterArguments, xContext),
UNO_QUERY_THROW );
UNO_QUERY );
OSL_ENSURE( xFilter.is(), "can't instantiate autotext-events filter");
if ( !xFilter.is() )
return ERR_SWG_READ_ERROR;
// connect parser and filter
xParser->setDocumentHandler( xFilter );
// parse the stream
try
{
xFilter->parseStream( aParserInput );
xParser->parseStream( aParserInput );
}
catch( xml::sax::SAXParseException& )
{