[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - sw/qa sw/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Wed Sep 1 03:09:40 UTC 2021
sw/qa/extras/indexing/IndexingExportTest.cxx | 31 +++++++++++++++++
sw/qa/extras/indexing/data/IndexingExport_Sections.odt |binary
sw/source/filter/indexing/IndexingExport.cxx | 16 +++++++-
3 files changed, 45 insertions(+), 2 deletions(-)
New commits:
commit 27230f51281e3ce608de6632a485cebd4de3a781
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Fri Jun 18 21:36:29 2021 +0900
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Sep 1 05:09:03 2021 +0200
indexing: indexing sections for the IndexingExport
Adds handling of sections to the IndexingExport. SectionNode also
derives from StartNode, so we handle it similar as the tables.
Change-Id: I5eb8d599bdf680144b161aa93295ea3d360eb5c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117452
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
(cherry picked from commit 2ce10eedfb1de8beef8ddfa457f1e19545846f86)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121105
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
diff --git a/sw/qa/extras/indexing/IndexingExportTest.cxx b/sw/qa/extras/indexing/IndexingExportTest.cxx
index fbc2c9d0ece2..f714b50f042a 100644
--- a/sw/qa/extras/indexing/IndexingExportTest.cxx
+++ b/sw/qa/extras/indexing/IndexingExportTest.cxx
@@ -31,6 +31,7 @@ public:
void testIndexingExport_OLE();
void testIndexingExport_Shapes();
void testIndexingExport_Tables();
+ void testIndexingExport_Sections();
CPPUNIT_TEST_SUITE(IndexingExportTest);
CPPUNIT_TEST(testIndexingExport_Paragraphs);
@@ -38,6 +39,7 @@ public:
CPPUNIT_TEST(testIndexingExport_OLE);
CPPUNIT_TEST(testIndexingExport_Shapes);
CPPUNIT_TEST(testIndexingExport_Tables);
+ CPPUNIT_TEST(testIndexingExport_Sections);
CPPUNIT_TEST_SUITE_END();
};
@@ -214,6 +216,35 @@ void IndexingExportTest::testIndexingExport_Tables()
assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[21]", "D5");
}
+void IndexingExportTest::testIndexingExport_Sections()
+{
+ SwDoc* pDoc = createDoc("IndexingExport_Sections.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");
+
+ assertXPath(pXmlDoc, "/indexing/section[1]", "name", "Section1");
+ assertXPathContent(pXmlDoc, "/indexing/section[1]/paragraph[1]",
+ "This is a paragraph in a Section1");
+ assertXPathContent(pXmlDoc, "/indexing/section[1]/paragraph[2]", "Section1 - Paragraph 2");
+ assertXPathContent(pXmlDoc, "/indexing/section[1]/paragraph[3]", "Section1 - Paragraph 3");
+
+ assertXPath(pXmlDoc, "/indexing/section[2]", "name", "Section2");
+ assertXPathContent(pXmlDoc, "/indexing/section[2]/paragraph[1]", "Section2 - Paragraph 1");
+ assertXPathContent(pXmlDoc, "/indexing/section[2]/paragraph[2]", "Section2 - Paragraph 2");
+
+ assertXPathContent(pXmlDoc, "/indexing/paragraph[1]", "This is a paragraph outside sections");
+ assertXPathContent(pXmlDoc, "/indexing/paragraph[2]", "This is a paragraph outside sections");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(IndexingExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/indexing/data/IndexingExport_Sections.odt b/sw/qa/extras/indexing/data/IndexingExport_Sections.odt
new file mode 100644
index 000000000000..ef92c83efd25
Binary files /dev/null and b/sw/qa/extras/indexing/data/IndexingExport_Sections.odt differ
diff --git a/sw/source/filter/indexing/IndexingExport.cxx b/sw/source/filter/indexing/IndexingExport.cxx
index b02bef0c9fe2..17a1670bd73c 100644
--- a/sw/source/filter/indexing/IndexingExport.cxx
+++ b/sw/source/filter/indexing/IndexingExport.cxx
@@ -56,8 +56,11 @@ public:
{
handleTableNode(pNode->GetTableNode());
}
-
- if (pNode->IsEndNode())
+ else if (pNode->IsSectionNode())
+ {
+ handleSectionNode(pNode->GetSectionNode());
+ }
+ else if (pNode->IsEndNode())
{
handleEndNode(pNode->GetEndNode());
}
@@ -138,6 +141,15 @@ public:
maNodeStack.push_back(pTableNode);
}
+ void handleSectionNode(SwSectionNode* pSectionNode)
+ {
+ m_rXmlWriter.startElement("section");
+ m_rXmlWriter.attribute("index", pSectionNode->GetIndex());
+ m_rXmlWriter.attribute("name", pSectionNode->GetSection().GetSectionName());
+
+ maNodeStack.push_back(pSectionNode);
+ }
+
void handleEndNode(SwEndNode* pEndNode)
{
if (!maNodeStack.empty() && pEndNode->StartOfSectionNode() == maNodeStack.back())
More information about the Libreoffice-commits
mailing list