summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2022-12-01 11:39:05 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2023-02-08 11:09:46 +0000
commit54298f7f23e699e99e979bdf945c6ae2bee1a12f (patch)
tree9cf3804d063318273adc5ccbd3564bac822bfacb /sw/qa
parenta0875d09d9eeb368e9e319f3f2f29ec3be71b56c (diff)
htmlexport: close li mark not only in xhtml
As commented in sw/source/filter/html/htmlatr.cxx:766 "// OutHTML_NumberBulletListEnd() will end a list item" We have to do it also in HTML not only XHTML so node will be closed and we get correct structure. This is followup for: commit 2466b9fcf20ee61f6fc621298011c0efaa55e7c6 Author: Miklos Vajna <vmiklos@collabora.com> Date: Mon Feb 21 16:38:51 2022 +0100 sw HTML export, XHTML mode: fix lost </li> when last list item is not numbered Change-Id: I99baa59b437572b157df8057445cf6c741f936b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143508 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146651 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/htmlexport/htmlexport.cxx53
-rw-r--r--sw/qa/inc/swmodeltestbase.hxx2
-rw-r--r--sw/qa/unit/swmodeltestbase.cxx7
3 files changed, 62 insertions, 0 deletions
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 11ab26d56185..670feca6b4c1 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -272,6 +272,8 @@ public:
void ExportToReqif();
/// Import using the C++ HTML import filter, with xhtmlns=reqif-xhtml.
void ImportFromReqif(const OUString& rUrl);
+ /// Export using the C++ HTML export filter
+ void ExportToHTML();
};
OUString SwHtmlDomExportTest::GetOlePath()
@@ -322,6 +324,15 @@ void SwHtmlDomExportTest::ExportToReqif()
save("HTML (StarWriter)");
}
+void SwHtmlDomExportTest::ExportToHTML()
+{
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyValue> aStoreProperties = {
+ comphelper::makePropertyValue("FilterName", OUString("HTML (StarWriter)")),
+ };
+ xStorable->storeToURL(maTempFile.GetURL(), aStoreProperties);
+}
+
void SwHtmlDomExportTest::ImportFromReqif(const OUString& rUrl)
{
uno::Sequence<beans::PropertyValue> aLoadProperties = {
@@ -1520,6 +1531,48 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testPartiallyNumberedList)
"/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:ol/reqif-xhtml:li/reqif-xhtml:p", 2);
}
+CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testPartiallyNumberedListHTML)
+{
+ // Given a document with a list, first para is numbered, second is not:
+ createSwDoc();
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->Insert("list header");
+ SwDoc* pDoc = pWrtShell->GetDoc();
+ 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->Insert2("numbered");
+ pWrtShell->SplitNode();
+ pWrtShell->Insert2("not numbered");
+ {
+ SwNode& rNode = pWrtShell->GetCursor()->GetPoint()->nNode.GetNode();
+ SwTextNode& rTextNode = *rNode.GetTextNode();
+ rTextNode.SetAttr(SwNumRuleItem(pNumRule->GetName()));
+ rTextNode.SetCountedInList(false);
+ }
+
+ // When exporting to HTML:
+ ExportToHTML();
+
+ SvMemoryStream aStream;
+ WrapFromTempFile(aStream);
+ xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream);
+ CPPUNIT_ASSERT(pXmlDoc); // if we have missing closing marks - parse error
+
+ // Without the accompanying fix in place, this test would have failed:
+ // - expected: <li><p>...</p><p>...</p></li>
+ // - actual : <li><p>...</p><p>...</p>
+ // because a <li> without a matching </li> is not well-formed, and the </li> was omitted because
+ // the second para was not numbered.
+
+ assertXPath(pXmlDoc, "/html/body/ol/li/p", 2);
+}
+
CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testListHeaderAndItem)
{
// Given a document with a list, first para is not numbered, but the second is:
diff --git a/sw/qa/inc/swmodeltestbase.hxx b/sw/qa/inc/swmodeltestbase.hxx
index dda083f76539..4c5ba58103d5 100644
--- a/sw/qa/inc/swmodeltestbase.hxx
+++ b/sw/qa/inc/swmodeltestbase.hxx
@@ -341,6 +341,8 @@ protected:
*/
void WrapReqifFromTempFile(SvMemoryStream& rStream);
+ void WrapFromTempFile(SvMemoryStream& rStream);
+
bool isExported(){ return mbExported; }
private:
diff --git a/sw/qa/unit/swmodeltestbase.cxx b/sw/qa/unit/swmodeltestbase.cxx
index 05918c52397a..1163ace48efa 100644
--- a/sw/qa/unit/swmodeltestbase.cxx
+++ b/sw/qa/unit/swmodeltestbase.cxx
@@ -603,4 +603,11 @@ void SwModelTestBase::WrapReqifFromTempFile(SvMemoryStream& rStream)
rStream.Seek(0);
}
+void SwModelTestBase::WrapFromTempFile(SvMemoryStream& rStream)
+{
+ SvFileStream aFileStream(maTempFile.GetURL(), StreamMode::READ);
+ rStream.WriteStream(aFileStream);
+ rStream.Seek(0);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */