sw/qa/extras/ooxmlexport/ooxmlexport11.cxx   |    5 +++++
 sw/source/filter/ww8/docxattributeoutput.cxx |   15 +++++++++++++++
 2 files changed, 20 insertions(+)

New commits:
commit 05a5037f489971676737808c37ad1cfb9dcd53d9
Author:     Serge Krot <serge.k...@cib.de>
AuthorDate: Fri Jan 18 12:51:33 2019 +0100
Commit:     Thorsten Behrens <thorsten.behr...@cib.de>
CommitDate: Thu Jan 24 09:42:46 2019 +0100

    tdf#121561 sw DOCX: output toc-end inside last toc paragraph
    
    During export of the TOC into DOCX all TOC field parts
    should be placed inside one STD frame: field start-begin,
    field-separate and field-end mark.
    
    Updated unit test.
    
    Change-Id: I10e37a48160e1dc4f0074c4e2e7621a59f79c2ee
    Reviewed-on: https://gerrit.libreoffice.org/66587
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de>
    (cherry picked from commit fd5599b9d23a2d9b13af6dd88bd2d38f438f7e00)
    Reviewed-on: https://gerrit.libreoffice.org/66810

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 41194b02db98..bcc136d31ef2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -99,11 +99,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf121561_tocTitleDocx, 
"tdf121456_tabsOffset.odt")
     if (!pXmlDoc)
         return;
 
+    // get TOC node
     uno::Reference<text::XDocumentIndexesSupplier> xIndexSupplier(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<container::XIndexAccess> 
xIndexes(xIndexSupplier->getDocumentIndexes( ), uno::UNO_QUERY);
     uno::Reference<text::XDocumentIndex> xTOCIndex(xIndexes->getByIndex(0), 
uno::UNO_QUERY);
 
+    // ensure TOC title was set in TOC properties
     CPPUNIT_ASSERT_EQUAL(OUString("Inhaltsverzeichnis"), 
getProperty<OUString>(xTOCIndex, "Title"));
+
+    // ensure TOC end-field mark is placed inside TOC section
+    assertXPath(pXmlDoc, 
"/w:document/w:body/w:sdt/w:sdtContent/w:p[16]/w:r/w:fldChar", "fldCharType", 
"end");
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf82065_Ind_start_strict, 
"tdf82065_Ind_start_strict.docx")
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index a73f90de5153..e332bee8d747 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1411,6 +1411,21 @@ void DocxAttributeOutput::EndRun(const SwTextNode* 
pNode, sal_Int32 nPos, bool /
         m_nFieldsInHyperlink = 0;
     }
 
+    // end ToX fields
+    for (auto it = m_Fields.rbegin(); it != m_Fields.rend(); )
+    {
+        if (it->bClose && !it->pField)
+        {
+            EndField_Impl( pNode, nPos, *it );
+            it = decltype(m_Fields)::reverse_iterator(m_Fields.erase(it.base() 
- 1));
+        }
+        else
+        {
+            ++it;
+        }
+    }
+
+
     DoWriteBookmarksStart(m_rFinalBookmarksStart);
     DoWriteBookmarksEnd(m_rFinalBookmarksEnd);
     DoWriteBookmarkEndIfExist(nPos);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to