summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-02-28 12:00:38 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-03-01 12:34:10 +0100
commiteb1049597bd92d61a2ad319bc9a2c3f9a08dd259 (patch)
tree17134859a83dea6b86dcaff5d5595bc19f6ff10d /sw
parentbaf5038e6e8ee66f67a3d3f76d7ba88587fe0f80 (diff)
sw HTML export: ReqIf implies we write a fragment
Test that for a very simple input we roundtrip perfectly (not counting whitespace changes). Change-Id: I89cfbe1da594f8a5343444ca20a107021d6a1a37 Reviewed-on: https://gerrit.libreoffice.org/50522 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/htmlexport/data/reqif-p.xhtml1
-rw-r--r--sw/qa/extras/htmlexport/htmlexport.cxx19
-rw-r--r--sw/source/filter/html/css1atr.cxx4
-rw-r--r--sw/source/filter/html/htmlatr.cxx2
-rw-r--r--sw/source/filter/html/wrthtml.cxx5
5 files changed, 30 insertions, 1 deletions
diff --git a/sw/qa/extras/htmlexport/data/reqif-p.xhtml b/sw/qa/extras/htmlexport/data/reqif-p.xhtml
new file mode 100644
index 000000000000..36f5aa11768b
--- /dev/null
+++ b/sw/qa/extras/htmlexport/data/reqif-p.xhtml
@@ -0,0 +1 @@
+<reqif-xhtml:p>aaa<reqif-xhtml:br/>bbb</reqif-xhtml:p>
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 74ffc3818685..e1b7313195e3 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -50,6 +50,14 @@ private:
setFilterOptions("EmbedImages");
else if (getTestName().indexOf("XHTML") != -1)
setFilterOptions("XHTML");
+ else if (getTestName().indexOf("ReqIf") != -1)
+ {
+ setImportFilterOptions("xhtmlns=reqif-xhtml");
+ // Bypass filter detect.
+ setImportFilterName("HTML (StarWriter)");
+ // Export options.
+ setFilterOptions("XHTML,xhtmlns=reqif-xhtml");
+ }
else
setFilterOptions("");
@@ -323,6 +331,17 @@ DECLARE_HTMLEXPORT_TEST(testXHTML, "hello.html")
assertXPath(pDoc, "/html/body", "xml:lang", "en-US");
}
+DECLARE_HTMLEXPORT_TEST(testReqIfParagraph, "reqif-p.xhtml")
+{
+ SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
+ CPPUNIT_ASSERT(pStream);
+
+ OString aExpected("<reqif-xhtml:p>aaa<reqif-xhtml:br/>\nbbb</reqif-xhtml:p>" SAL_NEWLINE_STRING);
+ OString aActual(read_uInt8s_ToOString(*pStream, aExpected.getLength()));
+ // This was a HTML header, like '<!DOCTYPE html ...'.
+ CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx
index 3ef2ed278510..006ec185e0f1 100644
--- a/sw/source/filter/html/css1atr.cxx
+++ b/sw/source/filter/html/css1atr.cxx
@@ -3061,6 +3061,10 @@ static Writer& OutCSS1_SvxFormatBreak_SwFormatPDesc_SvxFormatKeep( Writer& rWrt,
}
}
+ if (rHTMLWrt.mbSkipHeaderFooter)
+ // No page break when writing only a fragment.
+ return rWrt;
+
if( pBreakBefore )
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_page_break_before,
pBreakBefore );
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index a87351d6d570..d4fcf1d70c94 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -741,7 +741,7 @@ void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
(rHWrt.m_nDefListLvl-1) * rHWrt.m_nDefListMargin;
}
- if( rHWrt.m_bLFPossible )
+ if( rHWrt.m_bLFPossible && !rHWrt.m_bFirstLine )
rHWrt.OutNewLine(); // paragraph tag on a new line
rInfo.bOutPara = false;
diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx
index 3c673e1845ea..d40ff9e448c9 100644
--- a/sw/source/filter/html/wrthtml.cxx
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -191,7 +191,12 @@ void SwHTMLWriter::SetupFilterOptions(SfxMedium& rMedium)
if (rOption == "XHTML")
mbXHTML = true;
else if (rOption.startsWith(aXhtmlNsKey))
+ {
maNamespace = rOption.copy(aXhtmlNsKey.getLength()).toUtf8();
+ if (maNamespace == "reqif-xhtml")
+ // XHTML is always just a fragment inside ReqIF.
+ mbSkipHeaderFooter = true;
+ }
}
}