summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2021-09-09 11:41:33 +0300
committerThorsten Behrens <thorsten.behrens@allotropia.de>2021-09-14 10:00:24 +0200
commit683842708664e37210eb0db5f974c042b1ee7ff6 (patch)
treee42d12a217c785dc689401cb19140114a6247ef0 /sw
parent141c6f932ed6eb52b3da99143520f058bb3b4a99 (diff)
tdf#123642: keep last bookmark at the document end
In some cases DomainMapper_Impl::RemoveLastParagraph() can also remove last bookmark from real last paragraph. This does never happens when we use xParagraph->dispose(), but pretty always during older way with xCursor->setString(OUString()). Unfortunately without deep refactoring of redlines, bookmarks, etc. I see no other way to avoid this removal except given hack which is trying to store last bookmark and if it did disappear restore it. Some existing unittests were adjusted: corresponding original DOCX files did contain final bookmarks not taken into account by the code. In some cases test code is modified, in some just removed final bookmark in DOCX: such multi-format tests as in ooxmlfieldexport.cxx will be more identical to RTF & DOC variants. Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport17.cxx Change-Id: Ie9948b58cda705a0b85fa8e5e08b72fbb7d682b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121409 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122015
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/globalfilter/data/char_background_editing.docxbin12713 -> 12672 bytes
-rw-r--r--sw/qa/extras/globalfilter/data/fieldmark_QUOTE_nest.docxbin13183 -> 13179 bytes
-rw-r--r--sw/qa/extras/layout/layout.cxx2
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf123642.docxbin0 -> 17814 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport17.cxx21
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport8.cxx2
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx6
7 files changed, 26 insertions, 5 deletions
diff --git a/sw/qa/extras/globalfilter/data/char_background_editing.docx b/sw/qa/extras/globalfilter/data/char_background_editing.docx
index 3e3302d00c71..5e92fe8bbd49 100644
--- a/sw/qa/extras/globalfilter/data/char_background_editing.docx
+++ b/sw/qa/extras/globalfilter/data/char_background_editing.docx
Binary files differ
diff --git a/sw/qa/extras/globalfilter/data/fieldmark_QUOTE_nest.docx b/sw/qa/extras/globalfilter/data/fieldmark_QUOTE_nest.docx
index ba886edfa777..9fbec01e0ab6 100644
--- a/sw/qa/extras/globalfilter/data/fieldmark_QUOTE_nest.docx
+++ b/sw/qa/extras/globalfilter/data/fieldmark_QUOTE_nest.docx
Binary files differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 12fb7c421967..c13333d3a86b 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -1319,7 +1319,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf116486)
{
SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf116486.docx");
CPPUNIT_ASSERT(pDoc);
- OUString aTop = parseDump("/root/page/body/txt/Special", "nHeight");
+ OUString aTop = parseDump("/root/page/body/txt/Special[1]", "nHeight");
CPPUNIT_ASSERT_EQUAL(OUString("4006"), aTop);
}
diff --git a/sw/qa/extras/ooxmlexport/data/tdf123642.docx b/sw/qa/extras/ooxmlexport/data/tdf123642.docx
new file mode 100644
index 000000000000..9817093e02f8
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf123642.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 4eb9d0d6aa1b..6884ea3ebc03 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -10,6 +10,7 @@
#include <sal/config.h>
#include <string_view>
+#include <com/sun/star/text/XBookmarksSupplier.hpp>
#include <swmodeltestbase.hxx>
@@ -42,6 +43,26 @@ DECLARE_OOXMLEXPORT_TEST(testTdf135164_cancelledNumbering, "tdf135164_cancelledN
CPPUNIT_ASSERT_EQUAL(OUString("i"), getProperty<OUString>(xPara, "ListLabelString"));
}
+DECLARE_OOXMLEXPORT_TEST(testTdf123642_BookmarkAtDocEnd, "tdf123642.docx")
+{
+ // get bookmark interface
+ uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks();
+
+ // check: we have 1 bookmark (previously there were 0)
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xBookmarksByIdx->getCount());
+ CPPUNIT_ASSERT(xBookmarksByName->hasByName("Bookmark1"));
+
+ // and it is really in exprted DOCX (let's ensure)
+ xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return; // initial import, no futher checks
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Bookmark1"), getXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:bookmarkStart[1]", "name"));
+}
+
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
index 0faed8c2ac02..049b9091b81a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
@@ -1036,7 +1036,7 @@ DECLARE_OOXMLEXPORT_TEST(testN820509, "n820509.docx")
CPPUNIT_ASSERT(pTextDoc);
SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), pMarkAccess->getAllMarksCount());
::sw::mark::IFieldmark* pFieldmark = dynamic_cast<::sw::mark::IFieldmark*>(*pMarkAccess->getAllMarksBegin());
diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
index d92c29fefbe7..f6e6ea78bc99 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
@@ -455,7 +455,7 @@ DECLARE_OOXMLEXPORT_TEST(testSdtDateDuplicate, "sdt-date-duplicate.docx")
CPPUNIT_ASSERT(pTextDoc);
SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), pMarkAccess->getAllMarksCount());
::sw::mark::IDateFieldmark* pFieldmark
= dynamic_cast<::sw::mark::IDateFieldmark*>(*pMarkAccess->getAllMarksBegin());
@@ -614,7 +614,7 @@ DECLARE_OOXMLEXPORT_TEST( testDateFieldInShape, "date_field_in_shape.docx" )
CPPUNIT_ASSERT(pTextDoc);
SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), pMarkAccess->getAllMarksCount());
::sw::mark::IDateFieldmark* pFieldmark
= dynamic_cast<::sw::mark::IDateFieldmark*>(*pMarkAccess->getAllMarksBegin());
@@ -630,7 +630,7 @@ DECLARE_OOXMLEXPORT_TEST( testDateFieldAtEndOfParagraph, "date_field_at_end_of_p
CPPUNIT_ASSERT(pTextDoc);
SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), pMarkAccess->getAllMarksCount());
::sw::mark::IDateFieldmark* pFieldmark
= dynamic_cast<::sw::mark::IDateFieldmark*>(*pMarkAccess->getAllMarksBegin());