sw/qa/extras/uiwriter/uiwriter3.cxx     |   19 +++++++++++++++++++
 sw/source/core/swg/SwXMLTextBlocks1.cxx |   16 +++++++++++++---
 2 files changed, 32 insertions(+), 3 deletions(-)

New commits:
commit 97783676a85ea49aee856b5bd7193a4911856946
Author:     Justin Luth <justin_l...@sil.org>
AuthorDate: Fri Dec 17 18:45:42 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Dec 20 08:32:24 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>

diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 43ef4250aaba..978c61255354 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -1905,6 +1905,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 9f0c6cb545af..36ff82236c9e 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& )
         {

Reply via email to