summaryrefslogtreecommitdiff
path: root/sw/qa/extras/ooxmlexport
diff options
context:
space:
mode:
Diffstat (limited to 'sw/qa/extras/ooxmlexport')
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf129353.docxbin0 -> 4420 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport14.cxx29
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport5.cxx29
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx16
4 files changed, 65 insertions, 9 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf129353.docx b/sw/qa/extras/ooxmlexport/data/tdf129353.docx
new file mode 100644
index 000000000000..c5cf8865eda6
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf129353.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 2271aa413dd6..062831503404 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -14,8 +14,10 @@
#include <editsh.hxx>
#include <frmatr.hxx>
+#include <tools/lineend.hxx>
#include <com/sun/star/text/TableColumnSeparator.hpp>
#include <com/sun/star/text/RelOrientation.hpp>
+#include <com/sun/star/text/XDocumentIndex.hpp>
class Test : public SwModelTestBase
{
@@ -207,6 +209,33 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf128889, "tdf128889.fodt")
assertXPath(pXml, "/w:document/w:body/w:p[1]/w:r[2]/w:br", "type", "page");
}
+DECLARE_OOXMLEXPORT_TEST(testTdf129353, "tdf129353.docx")
+{
+ CPPUNIT_ASSERT_EQUAL(8, getParagraphs());
+ getParagraph(1, "(Verne, 1870)");
+ getParagraph(2, "Bibliography");
+ getParagraph(4, "Christie, A. (1922). The Secret Adversary. ");
+ CPPUNIT_ASSERT_EQUAL(OUString(), getParagraph(8)->getString());
+
+ uno::Reference<text::XDocumentIndexesSupplier> xIndexSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xIndexes = xIndexSupplier->getDocumentIndexes();
+ uno::Reference<text::XDocumentIndex> xIndex(xIndexes->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xTextRange = xIndex->getAnchor();
+ uno::Reference<text::XText> xText = xTextRange->getText();
+ uno::Reference<text::XTextCursor> xTextCursor = xText->createTextCursor();
+ xTextCursor->gotoRange(xTextRange->getStart(), false);
+ xTextCursor->gotoRange(xTextRange->getEnd(), true);
+ OUString aIndexString(convertLineEnd(xTextCursor->getString(), LineEnd::LINEEND_LF));
+
+ // Check that all the pre-rendered entries are correct, including trailing spaces
+ CPPUNIT_ASSERT_EQUAL(OUString("\n" // starting with an empty paragraph
+ "Christie, A. (1922). The Secret Adversary. \n"
+ "\n"
+ "Verne, J. G. (1870). Twenty Thousand Leagues Under the Sea. \n"
+ ""), // ending with an empty paragraph
+ aIndexString);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index 2560cf89a506..1c2560320cdc 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -9,6 +9,8 @@
#include <swmodeltestbase.hxx>
+#include <com/sun/star/text/XDocumentIndex.hpp>
+#include <com/sun/star/text/XDocumentIndexesSupplier.hpp>
#include <com/sun/star/text/XFootnote.hpp>
#include <com/sun/star/text/XTextTable.hpp>
#include <com/sun/star/style/LineSpacing.hpp>
@@ -694,6 +696,33 @@ DECLARE_OOXMLEXPORT_TEST(testFdo77129, "fdo77129.docx")
assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[4]/w:r[1]/w:t", "Abstract");
}
+// Test the same testdoc used for testFdo77129.
+DECLARE_OOXMLEXPORT_TEST(testTdf129402, "fdo77129.docx")
+{
+ // tdf#129402: ToC title must be "Contents", not "Content"; the index field must include
+ // pre-rendered element.
+
+ // Currently export drops empty paragraph after ToC, so skip getParagraphs test for now
+// CPPUNIT_ASSERT_EQUAL(5, getParagraphs());
+ CPPUNIT_ASSERT_EQUAL(OUString("owners."), getParagraph(1)->getString());
+ CPPUNIT_ASSERT_EQUAL(OUString("Contents"), getParagraph(2)->getString());
+ CPPUNIT_ASSERT_EQUAL(OUString("How\t2"), getParagraph(3)->getString());
+// CPPUNIT_ASSERT_EQUAL(OUString(), getParagraph(4)->getString());
+
+ uno::Reference<text::XDocumentIndexesSupplier> xIndexSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xIndexes = xIndexSupplier->getDocumentIndexes();
+ uno::Reference<text::XDocumentIndex> xIndex(xIndexes->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xTextRange = xIndex->getAnchor();
+ uno::Reference<text::XText> xText = xTextRange->getText();
+ uno::Reference<text::XTextCursor> xTextCursor = xText->createTextCursor();
+ xTextCursor->gotoRange(xTextRange->getStart(), false);
+ xTextCursor->gotoRange(xTextRange->getEnd(), true);
+ OUString aTocString(xTextCursor->getString());
+
+ // Check that the pre-rendered entry is inside the index
+ CPPUNIT_ASSERT_EQUAL(OUString("How\t2"), aTocString);
+}
+
DECLARE_OOXMLEXPORT_TEST(testfdo79969_xlsm, "fdo79969_xlsm.docx")
{
// This UT for DOCX embedded with excel work sheet.
diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
index 15390ccd574c..d20d8a90938f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
@@ -282,9 +282,9 @@ DECLARE_OOXMLEXPORT_TEST(testAlphabeticalIndex_MultipleColumns,"alphabeticalInde
// check for section breaks after and before the Index Section
assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:sectPr/w:type","val","continuous");
- assertXPath(pXmlDoc, "/w:document/w:body/w:p[9]/w:pPr/w:sectPr/w:type","val","continuous");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[8]/w:pPr/w:sectPr/w:type","val","continuous");
// check for "w:space" attribute for the columns in Section Properties
- assertXPath(pXmlDoc, "/w:document/w:body/w:p[9]/w:pPr/w:sectPr/w:cols/w:col[1]","space","720");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[8]/w:pPr/w:sectPr/w:cols/w:col[1]","space","720");
}
DECLARE_OOXMLEXPORT_TEST(testPageref, "testPageref.docx")
@@ -353,15 +353,13 @@ DECLARE_OOXMLEXPORT_TEST(testGenericTextField, "Unsupportedtextfields.docx")
xmlXPathFreeObject(pXmlObj);
}
-DECLARE_OOXMLEXPORT_TEST(test_FieldType, "99_Fields.docx")
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(test_FieldType, "99_Fields.docx")
{
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
- if (!pXmlDoc)
- return;
// Checking for three field types (BIBLIOGRAPHY, BIDIOUTLINE, CITATION) in sequence
- assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[2]/w:r[2]/w:instrText[1]",1);
- assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[5]/w:r[2]/w:instrText[1]",1);
- assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p/w:sdt/w:sdtContent/w:r[2]/w:instrText[1]",1);
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:instrText");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[2]/w:instrText");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:sdt/w:sdtContent/w:r[2]/w:instrText");
}
DECLARE_OOXMLEXPORT_TEST(testCitation,"FDO74775.docx")
@@ -411,7 +409,7 @@ DECLARE_OOXMLEXPORT_TEST(testFDO78654 , "fdo78654.docx")
return;
// In case of two "Hyperlink" tags in one paragraph and one of them
// contains "PAGEREF" field then field end tag was missing from hyperlink.
- assertXPath ( pXmlDoc, "/w:document/w:body/w:p[2]/w:hyperlink[3]/w:r[5]/w:fldChar", "fldCharType", "end" );
+ assertXPath ( pXmlDoc, "/w:document/w:body/w:sdt/w:sdtContent/w:p[2]/w:hyperlink[3]/w:r[5]/w:fldChar", "fldCharType", "end" );
}