diff options
-rw-r--r-- | sw/qa/extras/indexing/IndexingExportTest.cxx | 31 | ||||
-rw-r--r-- | sw/qa/extras/indexing/data/IndexingExport_Sections.odt | bin | 0 -> 10245 bytes | |||
-rw-r--r-- | sw/source/filter/indexing/IndexingExport.cxx | 16 |
3 files changed, 45 insertions, 2 deletions
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 Binary files differnew file mode 100644 index 000000000000..ef92c83efd25 --- /dev/null +++ b/sw/qa/extras/indexing/data/IndexingExport_Sections.odt 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()) |