diff options
author | Vinaya Mandke <vinaya.mandke@synerzip.com> | 2013-12-30 16:22:30 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-01-03 09:37:58 +0100 |
commit | 9679e9c23216decb5f9f25f85b04cb3f25211111 (patch) | |
tree | 0e65d1d7b478c5fdb55aafede301681cf22d5162 /sw | |
parent | c619f8747bcf04454645774729ccf5d91fac55f1 (diff) |
fdo#69649 Fix for pre-rendered Table Of Contents
Added Import and Export Uts for the same
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Reviewed on:
https://gerrit.libreoffice.org/7207
Change-Id: I966b3d268dd407aa05823e29fe1da4d097091265
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo69649.docx | bin | 0 -> 35048 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 13 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/fdo69649.docx | bin | 0 -> 35048 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 17 |
4 files changed, 29 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo69649.docx b/sw/qa/extras/ooxmlexport/data/fdo69649.docx Binary files differnew file mode 100644 index 000000000000..cb0f78999880 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo69649.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 1e20734dae9c..fa9030485d16 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -43,6 +43,7 @@ #include <unotools/tempfile.hxx> #include <unotools/ucbstreamhelper.hxx> #include <rtl/strbuf.hxx> +#include <com/sun/star/text/XDocumentIndex.hpp> #include <libxml/xpathInternals.h> #include <libxml/parserInternals.h> @@ -2213,6 +2214,18 @@ DECLARE_OOXMLEXPORT_TEST(testTrackChangesInsertedParagraphMark, "testTrackChange assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:ins"); } +DECLARE_OOXMLEXPORT_TEST(testFdo69649, "fdo69649.docx") +{ + // The DOCX containing the Table of Contents was not exported with correct page nos + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc,"/w:document/w:body/w:p[21]/w:hyperlink/w:r[2]/w:t"); + xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0]; + OUString contents = OUString::createFromAscii((const char*)((pXmlNode->children[0]).content)); + CPPUNIT_ASSERT(contents.match("15")); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/ooxmlimport/data/fdo69649.docx b/sw/qa/extras/ooxmlimport/data/fdo69649.docx Binary files differnew file mode 100644 index 000000000000..cb0f78999880 --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/fdo69649.docx diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 7804340d4f83..b79b6fb92576 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -43,7 +43,7 @@ #include <com/sun/star/table/TableBorder2.hpp> #include <com/sun/star/text/SizeType.hpp> #include <com/sun/star/xml/dom/XDocument.hpp> - +#include <com/sun/star/text/XDocumentIndex.hpp> #include <vcl/svapp.hxx> #include <unotools/fltrcfg.hxx> @@ -1670,6 +1670,21 @@ DECLARE_OOXMLIMPORT_TEST(testFdo65090, "fdo65090.docx") CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators").getLength()); } +DECLARE_OOXMLIMPORT_TEST(testFdo69649, "fdo69649.docx") +{ + // The DOCX containing the Table of Contents was not imported with correct page nos + 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); + uno::Reference<text::XTextRange> xTextRange(xTOCIndex->getAnchor(), uno::UNO_QUERY); + uno::Reference<text::XText> xText(xTextRange->getText( ), uno::UNO_QUERY); + uno::Reference<text::XTextCursor> xTextCursor(xText->createTextCursor( ), uno::UNO_QUERY); + xTextCursor->gotoRange(xTextRange->getStart(),false); + xTextCursor->gotoRange(xTextRange->getEnd(),true); + OUString xTocString(xTextCursor->getString()); + xTocString = xTocString.copy(256); + CPPUNIT_ASSERT(xTocString.startsWithIgnoreAsciiCase( "Heading 15.1:\t15" ) ); +} #endif CPPUNIT_PLUGIN_IMPLEMENT(); |