[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - 2 commits - sw/qa sw/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Tue Aug 31 07:58:51 UTC 2021
sw/qa/extras/indexing/IndexingExportTest.cxx | 64 +++++++++++++++++++
sw/qa/extras/indexing/data/IndexingExport_Tables.odt |binary
sw/source/filter/indexing/IndexingExport.cxx | 41 ++++++++++++
3 files changed, 105 insertions(+)
New commits:
commit 09c85fe330b3ed02c5a9480053b8198b44bcef32
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Fri Jun 18 21:13:38 2021 +0900
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Tue Aug 31 09:58:26 2021 +0200
indexing: write parent index to paragraphs if possible
When writing paragraphs from a table we want to associate the
parent table to the paragraphs so we also write the parent index.
Change-Id: Idf9c285f08481ed0556700e92adda27027b91408
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117451
Tested-by: Tomaž Vajngerl <quikee at gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
(cherry picked from commit 705fe1c44b41cd11518069e0627d0f48a65a7dfc)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121104
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
diff --git a/sw/source/filter/indexing/IndexingExport.cxx b/sw/source/filter/indexing/IndexingExport.cxx
index 83bac26fc51d..b02bef0c9fe2 100644
--- a/sw/source/filter/indexing/IndexingExport.cxx
+++ b/sw/source/filter/indexing/IndexingExport.cxx
@@ -83,10 +83,17 @@ public:
void handleTextNode(SwTextNode* pTextNode)
{
+ sal_Int64 nParentIndex = -1;
+ if (!maNodeStack.empty() && maNodeStack.back())
+ {
+ nParentIndex = maNodeStack.back()->GetIndex();
+ }
const OUString& rString
= pTextNode->GetText().replaceAll(OUStringChar(CH_TXTATR_BREAKWORD), "");
m_rXmlWriter.startElement("paragraph");
m_rXmlWriter.attribute("index", pTextNode->GetIndex());
+ if (nParentIndex >= 0)
+ m_rXmlWriter.attribute("parent", nParentIndex);
m_rXmlWriter.content(rString);
m_rXmlWriter.endElement();
}
commit c2aaa178a33f6386edb4f4b42c95214e91250440
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Fri Jun 18 20:21:20 2021 +0900
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Tue Aug 31 09:58:14 2021 +0200
indexing: indexing tables for the IndexingExport
Adds handling of tables to the IndexingExport and also handling
of the end node (as table node is also a start node), so we know
which paragraphs belong to a table.
Change-Id: I624ce12a3e810797a37ae2efe5baa552828f75dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117450
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
(cherry picked from commit b3a62ab0a43510cf43c88aa4d6e145e46db7e7e5)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121103
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 350e75c3d49f..fbc2c9d0ece2 100644
--- a/sw/qa/extras/indexing/IndexingExportTest.cxx
+++ b/sw/qa/extras/indexing/IndexingExportTest.cxx
@@ -30,12 +30,14 @@ public:
void testIndexingExport_Images();
void testIndexingExport_OLE();
void testIndexingExport_Shapes();
+ void testIndexingExport_Tables();
CPPUNIT_TEST_SUITE(IndexingExportTest);
CPPUNIT_TEST(testIndexingExport_Paragraphs);
CPPUNIT_TEST(testIndexingExport_Images);
CPPUNIT_TEST(testIndexingExport_OLE);
CPPUNIT_TEST(testIndexingExport_Shapes);
+ CPPUNIT_TEST(testIndexingExport_Tables);
CPPUNIT_TEST_SUITE_END();
};
@@ -150,6 +152,68 @@ void IndexingExportTest::testIndexingExport_Shapes()
assertXPathContent(pXmlDoc, "/indexing/shape[3]/paragraph[3]", "Para3");
}
+void IndexingExportTest::testIndexingExport_Tables()
+{
+ SwDoc* pDoc = createDoc("IndexingExport_Tables.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/table[1]", "name", "Table1");
+ assertXPathContent(pXmlDoc, "/indexing/table[1]/paragraph[1]", "A");
+ assertXPathContent(pXmlDoc, "/indexing/table[1]/paragraph[2]", "B");
+ assertXPathContent(pXmlDoc, "/indexing/table[1]/paragraph[3]", "1");
+ assertXPathContent(pXmlDoc, "/indexing/table[1]/paragraph[4]", "2");
+
+ assertXPath(pXmlDoc, "/indexing/table[2]", "name", "Table2");
+ assertXPathContent(pXmlDoc, "/indexing/table[2]/paragraph[1]", "A");
+ assertXPathContent(pXmlDoc, "/indexing/table[2]/paragraph[2]", "B");
+ assertXPathContent(pXmlDoc, "/indexing/table[2]/paragraph[3]", "C");
+ assertXPathContent(pXmlDoc, "/indexing/table[2]/paragraph[4]", "1");
+ assertXPathContent(pXmlDoc, "/indexing/table[2]/paragraph[5]", "10");
+ assertXPathContent(pXmlDoc, "/indexing/table[2]/paragraph[6]", "100");
+ assertXPathContent(pXmlDoc, "/indexing/table[2]/paragraph[7]", "2");
+ assertXPathContent(pXmlDoc, "/indexing/table[2]/paragraph[8]", "20");
+ assertXPathContent(pXmlDoc, "/indexing/table[2]/paragraph[9]", "200");
+ assertXPathContent(pXmlDoc, "/indexing/table[2]/paragraph[10]", "3");
+ assertXPathContent(pXmlDoc, "/indexing/table[2]/paragraph[11]", "30");
+ assertXPathContent(pXmlDoc, "/indexing/table[2]/paragraph[12]", "300");
+ assertXPathContent(pXmlDoc, "/indexing/table[2]/paragraph[13]", "4");
+ assertXPathContent(pXmlDoc, "/indexing/table[2]/paragraph[14]", "40");
+ assertXPathContent(pXmlDoc, "/indexing/table[2]/paragraph[15]", "400");
+
+ assertXPath(pXmlDoc, "/indexing/table[3]", "name", "WeirdTable");
+ assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[1]", "A1");
+ assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[2]", "B1");
+ assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[3]", "C1");
+ assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[4]", "D1");
+ assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[5]", "A2B2");
+ assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[6]", "C2D2");
+ assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[7]", "A3B3C3D3");
+ assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[8]", "A4-1");
+ assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[9]", "A4-2");
+ assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[10]", "B4-1");
+ assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[11]", "C4-1");
+ assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[12]", "D4-1");
+ assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[13]", "D4-2");
+ assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[14]", "");
+ assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[15]", "");
+ assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[16]", "B4-2");
+ assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[17]", "C4-2");
+ assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[18]", "");
+ assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[19]", "");
+ assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[20]", "A5B5C5");
+ assertXPathContent(pXmlDoc, "/indexing/table[3]/paragraph[21]", "D5");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(IndexingExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/indexing/data/IndexingExport_Tables.odt b/sw/qa/extras/indexing/data/IndexingExport_Tables.odt
new file mode 100644
index 000000000000..a15acc7de309
Binary files /dev/null and b/sw/qa/extras/indexing/data/IndexingExport_Tables.odt differ
diff --git a/sw/source/filter/indexing/IndexingExport.cxx b/sw/source/filter/indexing/IndexingExport.cxx
index 3ec39c1d338c..83bac26fc51d 100644
--- a/sw/source/filter/indexing/IndexingExport.cxx
+++ b/sw/source/filter/indexing/IndexingExport.cxx
@@ -18,6 +18,8 @@
#include <svx/svdotext.hxx>
#include <editeng/outlobj.hxx>
#include <editeng/editobj.hxx>
+#include <swtable.hxx>
+#include <deque>
namespace sw
{
@@ -28,6 +30,8 @@ class IndexingNodeHandler : public ModelTraverseHandler
private:
tools::XmlWriter& m_rXmlWriter;
+ std::deque<SwNode*> maNodeStack;
+
public:
IndexingNodeHandler(tools::XmlWriter& rXmlWriter)
: m_rXmlWriter(rXmlWriter)
@@ -48,6 +52,15 @@ public:
{
handleTextNode(pNode->GetTextNode());
}
+ else if (pNode->IsTableNode())
+ {
+ handleTableNode(pNode->GetTableNode());
+ }
+
+ if (pNode->IsEndNode())
+ {
+ handleEndNode(pNode->GetEndNode());
+ }
}
void handleOLENode(SwOLENode* pOleNode)
@@ -105,6 +118,27 @@ public:
m_rXmlWriter.endElement();
}
+
+ void handleTableNode(SwTableNode* pTableNode)
+ {
+ const SwTableFormat* pFormat = pTableNode->GetTable().GetFrameFormat();
+ OUString sName = pFormat->GetName();
+
+ m_rXmlWriter.startElement("table");
+ m_rXmlWriter.attribute("index", pTableNode->GetIndex());
+ m_rXmlWriter.attribute("name", sName);
+
+ maNodeStack.push_back(pTableNode);
+ }
+
+ void handleEndNode(SwEndNode* pEndNode)
+ {
+ if (!maNodeStack.empty() && pEndNode->StartOfSectionNode() == maNodeStack.back())
+ {
+ maNodeStack.pop_back();
+ m_rXmlWriter.endElement();
+ }
+ }
};
} // end anonymous namespace
More information about the Libreoffice-commits
mailing list