[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Mar 1 11:34:37 UTC 2018


 sw/qa/extras/htmlexport/data/reqif-p.xhtml |    1 +
 sw/qa/extras/htmlexport/htmlexport.cxx     |   19 +++++++++++++++++++
 sw/source/filter/html/css1atr.cxx          |    4 ++++
 sw/source/filter/html/htmlatr.cxx          |    2 +-
 sw/source/filter/html/wrthtml.cxx          |    5 +++++
 5 files changed, 30 insertions(+), 1 deletion(-)

New commits:
commit eb1049597bd92d61a2ad319bc9a2c3f9a08dd259
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Feb 28 12:00:38 2018 +0100

    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 at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

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;
+        }
     }
 }
 


More information about the Libreoffice-commits mailing list