summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-06-11 12:23:45 +0900
committerTomaž Vajngerl <quikee@gmail.com>2021-06-19 11:12:44 +0200
commit686c35a3c37674d08c1f8585a621143c959b3f29 (patch)
treed5add6b678d48c825d2a0a2cc3985b75cb8aae6d /sw/qa
parente6cb7f9ab25bca32dc85aef8ff127e070cd109b6 (diff)
indexing: indexing paragraph text with the ModelTraverser
This adds the basic paragraph text export for indexing, which uses the new ModelTraverser, which is inspired by AccessibilityCheck (and in the future it will be changed to use the ModelTraverser too, when it matures). ModelTraverser implements traversing through the model and executes a handler for a element of a model (which can be various things). IndexingExport class implements indexing export that uses the ModelTraverser to write into the indexing xml document, that uses the tools::XmlWriter. Change-Id: I7a6a5de332534270fe894a881131e5eb5ea9d881 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117356 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/indexing/IndexingExportTest.cxx29
1 files changed, 29 insertions, 0 deletions
diff --git a/sw/qa/extras/indexing/IndexingExportTest.cxx b/sw/qa/extras/indexing/IndexingExportTest.cxx
index eed303c3e97b..9d943e3b9593 100644
--- a/sw/qa/extras/indexing/IndexingExportTest.cxx
+++ b/sw/qa/extras/indexing/IndexingExportTest.cxx
@@ -13,6 +13,8 @@
#include <docsh.hxx>
#include <unotxdoc.hxx>
+#include <IndexingExport.hxx>
+
namespace
{
constexpr OUStringLiteral DATA_DIRECTORY = u"sw/qa/extras/indexing/data/";
@@ -47,6 +49,33 @@ void IndexingExportTest::testIndexingExport()
{
SwDoc* pDoc = createDoc("IndexingExport_VariousParagraphs.odt");
CPPUNIT_ASSERT(pDoc);
+
+ SvMemoryStream aMemoryStream;
+ sw::IndexingExport aIndexingExport(aMemoryStream, pDoc);
+ aIndexingExport.runExport();
+ aMemoryStream.Seek(0);
+
+ xmlDocUniquePtr pXmlDoc = parseXmlStream(&aMemoryStream);
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ assertXPath(pXmlDoc, "/indexing");
+ assertXPathContent(pXmlDoc, "/indexing/paragraph[1]", "Title");
+ assertXPathContent(pXmlDoc, "/indexing/paragraph[2]", "Heading 1");
+ assertXPathContent(pXmlDoc, "/indexing/paragraph[3]", "Heading 2");
+ assertXPathContent(pXmlDoc, "/indexing/paragraph[4]", "Paragraph 1");
+ assertXPathContent(pXmlDoc, "/indexing/paragraph[5]", "Paragraph 2");
+ assertXPathContent(pXmlDoc, "/indexing/paragraph[6]", "Bullet 1");
+ assertXPathContent(pXmlDoc, "/indexing/paragraph[7]", "Bullet 2");
+ assertXPathContent(pXmlDoc, "/indexing/paragraph[8]", "Bullet 3");
+ assertXPathContent(pXmlDoc, "/indexing/paragraph[9]", "Paragraph 3");
+ assertXPathContent(pXmlDoc, "/indexing/paragraph[10]", "Paragraph 4");
+ assertXPathContent(pXmlDoc, "/indexing/paragraph[11]", "List 1");
+ assertXPathContent(pXmlDoc, "/indexing/paragraph[12]", "List 2");
+ assertXPathContent(pXmlDoc, "/indexing/paragraph[13]", "List 3");
+ assertXPathContent(pXmlDoc, "/indexing/paragraph[14]", "Left");
+ assertXPathContent(pXmlDoc, "/indexing/paragraph[15]", "Center");
+ assertXPathContent(pXmlDoc, "/indexing/paragraph[16]", "Right");
+ assertXPathContent(pXmlDoc, "/indexing/paragraph[17]", "Bold Italic Underline Strikeout");
}
CPPUNIT_TEST_SUITE_REGISTRATION(IndexingExportTest);