sw/qa/extras/uiwriter/uiwriter3.cxx | 19 +++++++++++++++++++ sw/source/core/swg/SwXMLTextBlocks1.cxx | 16 +++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-)
New commits: commit d8cf8482ae5ed72dc969d9adb47c113c442452be Author: Justin Luth <justin_l...@sil.org> AuthorDate: Fri Dec 17 18:45:42 2021 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Dec 20 13:54:05 2021 +0100 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 <jl...@mail.com> (cherry picked from commit 1addd8c104f6ad390bdd0ca61cd5ce97b55ce218) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126982 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127147 diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index 514a13e88ff1..b536692fc5a6 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -1689,6 +1689,25 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf130629) CPPUNIT_ASSERT_EQUAL(1, getShapes()); } +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 0297d68fa442..589d4e192097 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! @@ -206,15 +210,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& ) {