sw/qa/extras/ooxmlexport/data/tdf148361.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport15.cxx   |   16 ++++++++++++++++
 writerfilter/source/dmapper/SdtHelper.cxx    |   17 ++++++++++++-----
 writerfilter/source/dmapper/SdtHelper.hxx    |    3 +++
 4 files changed, 31 insertions(+), 5 deletions(-)

New commits:
commit 3ddf0f924b2b5fbb5f409e0c6cb59cf2e82e4854
Author:     Vasily Melenchuk <vasily.melenc...@cib.de>
AuthorDate: Mon Apr 4 18:05:18 2022 +0300
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Tue Jun 21 01:18:48 2022 +0200

    tdf#148361: docx sdt: cleanup databinding data after inserting
    
    Databinding data is used only for current sdt block. It should
    be clean up after usage to avoid impact on next sdt blocks.
    
    Change-Id: I53f47dd655ed027d40eb518784dcae69813e612f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132524
    Tested-by: Jenkins
    Tested-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-by: Vasily Melenchuk <vasily.melenc...@cib.de>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132634
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>
    Tested-by: Thorsten Behrens <thorsten.behr...@allotropia.de>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf148361.docx 
b/sw/qa/extras/ooxmlexport/data/tdf148361.docx
new file mode 100644
index 000000000000..ecf9a5f0087c
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf148361.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index f63b5aa5a5fe..3867254edb69 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -211,6 +211,22 @@ DECLARE_OOXMLEXPORT_TEST(testTdf148111, "tdf148111.docx")
     CPPUNIT_ASSERT(!xFields->hasMoreElements());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf148361, "tdf148361.docx")
+{
+    // Refresh fields and ensure cross-reference to numbered para is okay
+    uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<container::XEnumerationAccess> 
xFieldsAccess(xTextFieldsSupplier->getTextFields());
+
+    uno::Reference<container::XEnumeration> 
xFields(xFieldsAccess->createEnumeration());
+    CPPUNIT_ASSERT(xFields->hasMoreElements());
+
+    uno::Reference<text::XTextField> xTextField1(xFields->nextElement(), 
uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("itadmin"), 
xTextField1->getPresentation(false));
+
+    uno::Reference<text::XTextField> xTextField2(xFields->nextElement(), 
uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("[Type text]"), 
xTextField2->getPresentation(false));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/SdtHelper.cxx 
b/writerfilter/source/dmapper/SdtHelper.cxx
index 71d1ffd7fc9f..8a5e769ad011 100644
--- a/writerfilter/source/dmapper/SdtHelper.cxx
+++ b/writerfilter/source/dmapper/SdtHelper.cxx
@@ -268,8 +268,7 @@ void SdtHelper::createDropDownControl()
     }
 
     // clean up
-    m_aDropDownItems.clear();
-    setControlType(SdtControlType::unknown);
+    clear();
 }
 
 void SdtHelper::createPlainTextControl()
@@ -300,8 +299,7 @@ void SdtHelper::createPlainTextControl()
                                    uno::makeAny(getInteropGrabBagAndClear()));
 
     // clean up
-    m_aDropDownItems.clear();
-    setControlType(SdtControlType::unknown);
+    clear();
 }
 
 void SdtHelper::createDateContentControl()
@@ -374,7 +372,7 @@ void SdtHelper::createDateContentControl()
         }
     }
 
-    setControlType(SdtControlType::unknown);
+    clear();
 }
 
 void SdtHelper::createControlShape(awt::Size aSize,
@@ -423,6 +421,15 @@ bool SdtHelper::containedInInteropGrabBag(const OUString& 
rValueName)
     return false;
 }
 
+void SdtHelper::clear()
+{
+    m_aDropDownItems.clear();
+    setControlType(SdtControlType::unknown);
+    m_sDataBindingPrefixMapping.clear();
+    m_sDataBindingXPath.clear();
+    m_sDataBindingStoreItemID.clear();
+    m_aGrabBag.clear();
+}
 } // namespace dmapper
 } // namespace writerfilter
 
diff --git a/writerfilter/source/dmapper/SdtHelper.hxx 
b/writerfilter/source/dmapper/SdtHelper.hxx
index 330ffbbca88c..863c449a211e 100644
--- a/writerfilter/source/dmapper/SdtHelper.hxx
+++ b/writerfilter/source/dmapper/SdtHelper.hxx
@@ -111,6 +111,9 @@ class SdtHelper final : public virtual SvRefBase
 
     void loadPropertiesXMLs();
 
+    /// Clear all collected attributes for futher reuse
+    void clear();
+
 public:
     explicit SdtHelper(DomainMapper_Impl& rDM_Impl,
                        css::uno::Reference<css::uno::XComponentContext> const& 
xContext);

Reply via email to