summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-06-15 14:04:57 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-06-15 15:56:08 +0200
commitfdf1db0010104294c01c7780d9daba5adf38450b (patch)
tree2e91fc6b21f40558883ce67c74d412735da83193 /sw/qa
parentbbd6def8df823fcc2f5c6aef4dce775d87eef59f (diff)
sw XHTML / reqif export: handle multiple lists when detecting header-only lists
The case when the list was at the end of the text node section (body text, table cell, etc) was already handled, this handles when the list is followed by a different list. Change-Id: I131402cb577bd16814f56a5bd6bcad7c99947dbd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117246 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/htmlexport/htmlexport.cxx87
1 files changed, 87 insertions, 0 deletions
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 5d9232c8b286..044a6ad29e72 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -1847,6 +1847,93 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifOleBmpTransparent)
CPPUNIT_ASSERT_EQUAL(COL_WHITE, nActualColor);
}
+CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testListsHeading)
+{
+ // Given a document with lh, lh, li, li, lh and lh nodes:
+ loadURL("private:factory/swriter", nullptr);
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->Insert("list 1, header 1");
+ pWrtShell->SplitNode();
+ pWrtShell->Insert("list 1, header 2");
+ pWrtShell->SplitNode();
+ pWrtShell->Insert("list 2, item 1");
+ pWrtShell->SplitNode();
+ pWrtShell->Insert("list 2, item 2");
+ pWrtShell->SplitNode();
+ pWrtShell->Insert("list 3, header 1");
+ pWrtShell->SplitNode();
+ pWrtShell->Insert("list 3, header 2");
+ SwDoc* pDoc = pWrtShell->GetDoc();
+ pWrtShell->Up(false, 5);
+ {
+ sal_uInt16 nPos = pDoc->MakeNumRule(pDoc->GetUniqueNumRuleName());
+ SwNumRule* pNumRule = pDoc->GetNumRuleTable()[nPos];
+ {
+ SwNode& rNode = pWrtShell->GetCursor()->GetPoint()->nNode.GetNode();
+ SwTextNode& rTextNode = *rNode.GetTextNode();
+ rTextNode.SetAttr(SwNumRuleItem(pNumRule->GetName()));
+ rTextNode.SetCountedInList(false);
+ }
+ pWrtShell->Down(false, 1);
+ {
+ SwNode& rNode = pWrtShell->GetCursor()->GetPoint()->nNode.GetNode();
+ SwTextNode& rTextNode = *rNode.GetTextNode();
+ rTextNode.SetAttr(SwNumRuleItem(pNumRule->GetName()));
+ rTextNode.SetCountedInList(false);
+ }
+ }
+ pWrtShell->Down(false, 1);
+ {
+ sal_uInt16 nPos = pDoc->MakeNumRule(pDoc->GetUniqueNumRuleName());
+ SwNumRule* pNumRule = pDoc->GetNumRuleTable()[nPos];
+ {
+ SwNode& rNode = pWrtShell->GetCursor()->GetPoint()->nNode.GetNode();
+ SwTextNode& rTextNode = *rNode.GetTextNode();
+ rTextNode.SetAttr(SwNumRuleItem(pNumRule->GetName()));
+ }
+ pWrtShell->Down(false, 1);
+ {
+ SwNode& rNode = pWrtShell->GetCursor()->GetPoint()->nNode.GetNode();
+ SwTextNode& rTextNode = *rNode.GetTextNode();
+ rTextNode.SetAttr(SwNumRuleItem(pNumRule->GetName()));
+ }
+ }
+ pWrtShell->Down(false, 1);
+ {
+ sal_uInt16 nPos = pDoc->MakeNumRule(pDoc->GetUniqueNumRuleName());
+ SwNumRule* pNumRule = pDoc->GetNumRuleTable()[nPos];
+ {
+ SwNode& rNode = pWrtShell->GetCursor()->GetPoint()->nNode.GetNode();
+ SwTextNode& rTextNode = *rNode.GetTextNode();
+ rTextNode.SetAttr(SwNumRuleItem(pNumRule->GetName()));
+ rTextNode.SetCountedInList(false);
+ }
+ pWrtShell->Down(false, 1);
+ {
+ SwNode& rNode = pWrtShell->GetCursor()->GetPoint()->nNode.GetNode();
+ SwTextNode& rTextNode = *rNode.GetTextNode();
+ rTextNode.SetAttr(SwNumRuleItem(pNumRule->GetName()));
+ rTextNode.SetCountedInList(false);
+ }
+ }
+
+ // When exporting to ReqIF:
+ ExportToReqif();
+
+ // Then make sure the output is valid xhtml:
+ SvMemoryStream aStream;
+ HtmlExportTest::wrapFragment(maTempFile, aStream);
+ xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream);
+ CPPUNIT_ASSERT(pDoc);
+
+ // Without the accompanying fix in place, this test would have failed with:
+ // - In <>, XPath '/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:p' not found
+ // Because the headers of list 1 were inside <div><ol>, not directly under <div>.
+ assertXPathContent(pXmlDoc, "/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:p",
+ "list 1, header 1");
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */