filter/source/config/fragments/types/generic_HTML.xcu |    3 +
 sw/qa/extras/htmlexport/data/reqif-list.xhtml         |   11 ++++++
 sw/qa/extras/htmlexport/htmlexport.cxx                |   28 ++++++++++++---
 sw/source/filter/html/css1atr.cxx                     |   33 ++++++++++++------
 sw/source/filter/html/htmlatr.cxx                     |   13 ++++++-
 sw/source/filter/html/htmlnumwriter.cxx               |    1 
 sw/source/filter/html/htmltabw.cxx                    |   11 +-----
 sw/source/filter/html/wrthtml.hxx                     |    4 +-
 8 files changed, 75 insertions(+), 29 deletions(-)

New commits:
commit 4319558aeba00a229275e24a569cfb6327d10e71
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Wed Apr 11 18:17:14 2018 +0200

    sw XHTML export: properly write <li>...</li> around paragraphs
    
    HTML allows just writing <li>, but XHTML really insist on an explicit
    end element for list items.
    
    Change-Id: Ia4aef95c290800d6dc2f6559e7b7bfa3a4213376
    Reviewed-on: https://gerrit.libreoffice.org/52734
    Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk>
    Tested-by: Jenkins <c...@libreoffice.org>
    (cherry picked from commit b6f7a4908d1c3fc610440a1cbbbc1673a53da8b6)

diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx 
b/sw/qa/extras/htmlexport/htmlexport.cxx
index 0efc1a09e9e7..9901d0cac702 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -489,6 +489,9 @@ DECLARE_HTMLEXPORT_TEST(testReqIfList, "reqif-list.xhtml")
     // This failed, the 'style' attribute was written, even if the input did
     // not had one.
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1), aStream.indexOf(" 
style=\""));
+
+    // This failed <li> was only opened, not closed.
+    CPPUNIT_ASSERT(aStream.indexOf("</reqif-xhtml:li>") != -1);
 }
 
 DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testReqIfOle2, "reqif-ole2.xhtml")
diff --git a/sw/source/filter/html/htmlatr.cxx 
b/sw/source/filter/html/htmlatr.cxx
index e4e4b1ad67eb..24fbe2a18b48 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -207,6 +207,7 @@ struct SwHTMLTextCollOutputInfo
     bool bParaPossible;         // a </P> may be output additionally
     bool bOutPara;              // a </P> is supposed to be output
     bool bOutDiv;               // write a </DIV>
+    bool bOutLi = false;        // write a </li>
 
     SwHTMLTextCollOutputInfo() :
         bInNumBulList( false ),
@@ -756,7 +757,13 @@ void OutHTML_SwFormat( Writer& rWrt, const SwFormat& 
rFormat,
         html.start(OOO_STRING_SVTOOLS_HTML_li);
         if( USHRT_MAX != nNumStart )
             html.attribute(OOO_STRING_SVTOOLS_HTML_O_value, 
OString::number(nNumStart));
-        html.endAttribute();
+        if (rHWrt.mbXHTML)
+        {
+            rWrt.Strm().WriteCharPtr(">");
+            rInfo.bOutLi = true;
+        }
+        else
+            html.endAttribute();
     }
 
     if( rHWrt.m_nDefListLvl > 0 && !bForceDL )
@@ -1008,6 +1015,10 @@ void OutHTML_SwFormatOff( Writer& rWrt, const 
SwHTMLTextCollOutputInfo& rInfo )
         rHWrt.m_bLFPossible = true;
     }
 
+    if (rInfo.bOutLi)
+        HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), rHWrt.GetNamespace() + 
OOO_STRING_SVTOOLS_HTML_li,
+                                   false);
+
     // if necessary, close a bulleted or numbered list
     if( rInfo.bInNumBulList )
     {
commit 9a8f2658bebc2ad6ecb79a34b99b8f2b5a85bb6b
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Wed Apr 11 14:41:10 2018 +0200

    sw reqif-xhtml export: limit values of the style attribute
    
    The ReqIF spec (v1.2, page 56) says that on import only these attributes
    should be considered, so it's pointless to write them (even if doing so
    is not strictly invalid).
    
    This more general approach also means that the earlier merging that was
    specific to tables in commit c0149b1c028450411d36457593f4af3406541b00
    (sw XHTML export: fix duplicated style attribute for table
    border/background, 2018-03-20) is no longer needed.
    
    Change-Id: I340e6a9f726f42072bf1aaa49ea72162004e5493
    Reviewed-on: https://gerrit.libreoffice.org/52725
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk>
    (cherry picked from commit 4cd3c436923bfba281b1bf16d9785208a2119cea)

diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx 
b/sw/qa/extras/htmlexport/htmlexport.cxx
index ac54b66ece1d..0efc1a09e9e7 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -468,12 +468,9 @@ DECLARE_HTMLEXPORT_TEST(testReqIfTable, 
"reqif-table.xhtml")
     // <div> was missing, so the XHTML fragment wasn't a valid
     // xhtml.BlkStruct.class type anymore.
     assertXPath(pDoc, "/html/body/div/table/tr/th", 1);
-    OUString aStyle = getXPath(pDoc, "/html/body/div/table/tr/th", "style");
-    CPPUNIT_ASSERT(aStyle.indexOf("background") != -1);
-    // This failed, there were 2 style attributes, so as a best effort the
-    // parser took the value of the first.
-    CPPUNIT_ASSERT(aStyle.indexOf("border") != -1);
-
+    // The attribute was present to contain "background" and "border", which is
+    // ignored in reqif-xhtml.
+    assertXPathNoAttribute(pDoc, "/html/body/div/table/tr/th", "style");
     // The attribute was present, which is not valid in reqif-xhtml.
     assertXPathNoAttribute(pDoc, "/html/body/div/table/tr/th", "bgcolor");
 }
@@ -488,6 +485,10 @@ DECLARE_HTMLEXPORT_TEST(testReqIfList, "reqif-list.xhtml")
     OString aStream(read_uInt8s_ToOString(*pStream, nLength));
     // This failed, <ul> was written.
     CPPUNIT_ASSERT(aStream.indexOf("<reqif-xhtml:ul>") != -1);
+
+    // This failed, the 'style' attribute was written, even if the input did
+    // not had one.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1), aStream.indexOf(" 
style=\""));
 }
 
 DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testReqIfOle2, "reqif-ole2.xhtml")
diff --git a/sw/source/filter/html/css1atr.cxx 
b/sw/source/filter/html/css1atr.cxx
index d02f3e05deb6..71af340d119b 100644
--- a/sw/source/filter/html/css1atr.cxx
+++ b/sw/source/filter/html/css1atr.cxx
@@ -191,6 +191,21 @@ OString lclGetCSS1Color(const Color& rColor)
     return "#" + lclConvToHex(rColor.GetRed()) + 
lclConvToHex(rColor.GetGreen()) + lclConvToHex(rColor.GetBlue());
 }
 
+/// Determines if rProperty has to be suppressed due to ReqIF mode.
+bool IgnorePropertyForReqIF(bool bReqIF, const OString& rProperty)
+{
+    if (!bReqIF)
+        return false;
+
+    // Only allow these two keys, nothing else in ReqIF mode.
+    if (rProperty == sCSS1_P_text_decoration)
+        return false;
+
+    if (rProperty == sCSS1_P_color)
+        return false;
+
+    return true;
+}
 }
 
 class SwCSS1OutMode
@@ -221,6 +236,9 @@ void SwHTMLWriter::OutCSS1_Property( const sal_Char *pProp,
                                      const sal_Char *pVal,
                                      const OUString *pSVal )
 {
+    if (IgnorePropertyForReqIF(mbReqIF, pProp))
+        return;
+
     OStringBuffer sOut;
 
     if( m_bFirstCSS1Rule && (m_nCSS1OutMode & CSS1_OUTMODE_RULE_ON)!=0 )
@@ -1824,7 +1842,7 @@ Writer& OutCSS1_ParaTagStyleOpt( Writer& rWrt, const 
SfxItemSet& rItemSet )
 }
 
 // Wrapper for Table background
-Writer& OutCSS1_TableBGStyleOpt( Writer& rWrt, const SfxPoolItem& rHt, bool 
bClose )
+Writer& OutCSS1_TableBGStyleOpt( Writer& rWrt, const SfxPoolItem& rHt )
 {
     SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
 
@@ -1833,7 +1851,7 @@ Writer& OutCSS1_TableBGStyleOpt( Writer& rWrt, const 
SfxPoolItem& rHt, bool bClo
                                    CSS1_OUTMODE_TABLEBOX, nullptr );
     OutCSS1_SvxBrush( rWrt, rHt, Css1Background::Table, nullptr );
 
-    if( !rHTMLWrt.m_bFirstCSS1Property && bClose )
+    if( !rHTMLWrt.m_bFirstCSS1Property )
         rWrt.Strm().WriteChar( '\"' );
 
     return rWrt;
@@ -2091,19 +2109,12 @@ void SwHTMLWriter::OutCSS1_TableFrameFormatOptions( 
const SwFrameFormat& rFrameF
         Strm().WriteChar( '\"' );
 }
 
-void SwHTMLWriter::OutCSS1_TableCellBorderHack(SwFrameFormat const& 
rFrameFormat, bool bClose)
+void SwHTMLWriter::OutCSS1_TableCellBorderHack(SwFrameFormat const& 
rFrameFormat)
 {
-    bool bFirstCSS1Property = m_bFirstCSS1Property;
-
     SwCSS1OutMode const aMode( *this,
         CSS1_OUTMODE_STYLE_OPT_ON|CSS1_OUTMODE_ENCODE|CSS1_OUTMODE_TABLEBOX, 
nullptr );
-
-    if (!bFirstCSS1Property)
-        // Don't start the style attribute again if it was started already.
-        m_bFirstCSS1Property = bFirstCSS1Property;
-
     OutCSS1_SvxBox(*this, rFrameFormat.GetBox());
-    if (!m_bFirstCSS1Property && bClose)
+    if (!m_bFirstCSS1Property)
     {
         this->Strm().WriteChar( cCSS1_style_opt_end );
     }
diff --git a/sw/source/filter/html/htmltabw.cxx 
b/sw/source/filter/html/htmltabw.cxx
index 89aacba1ad31..a28157019d84 100644
--- a/sw/source/filter/html/htmltabw.cxx
+++ b/sw/source/filter/html/htmltabw.cxx
@@ -416,7 +416,6 @@ void SwHTMLWrtTable::OutTableCell( SwHTMLWriter& rWrt,
     if( !pBrushItem )
         pBrushItem = pCell->GetBackground();
 
-    // Start writing the style attribute.
     if( pBrushItem )
     {
         // Hintergrund ausgeben
@@ -425,14 +424,10 @@ void SwHTMLWrtTable::OutTableCell( SwHTMLWriter& rWrt,
             rWrt.OutBackground( pBrushItem, false );
 
         if( rWrt.m_bCfgOutStyles )
-            OutCSS1_TableBGStyleOpt( rWrt, *pBrushItem, /*bClose=*/false );
+            OutCSS1_TableBGStyleOpt( rWrt, *pBrushItem );
     }
 
-    rWrt.OutCSS1_TableCellBorderHack(*pBox->GetFrameFormat(), 
/*bClose=*/false);
-
-    // Now is the time to end the style attribute.
-    if (!rWrt.m_bFirstCSS1Property)
-        rWrt.Strm().WriteChar('\"');
+    rWrt.OutCSS1_TableCellBorderHack(*pBox->GetFrameFormat());
 
     sal_uInt32 nNumFormat = 0;
     double nValue = 0.0;
@@ -537,7 +532,7 @@ void SwHTMLWrtTable::OutTableCells( SwHTMLWriter& rWrt,
         rWrt.m_bTextAttr = false;
         rWrt.m_bOutOpts = true;
         if( rWrt.m_bCfgOutStyles )
-            OutCSS1_TableBGStyleOpt( rWrt, *pBrushItem, /*bClose=*/true );
+            OutCSS1_TableBGStyleOpt( rWrt, *pBrushItem );
     }
 
     if( text::VertOrientation::TOP==eRowVertOri || 
text::VertOrientation::BOTTOM==eRowVertOri )
diff --git a/sw/source/filter/html/wrthtml.hxx 
b/sw/source/filter/html/wrthtml.hxx
index c8e953e322ff..7ce840b34d7e 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -480,7 +480,7 @@ public:
     void writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameFormat& 
rFrameFormat, const OUString& rAltText, HtmlFrmOpts nFrameOpts);
 
     void OutCSS1_TableFrameFormatOptions( const SwFrameFormat& rFrameFormat );
-    void OutCSS1_TableCellBorderHack(const SwFrameFormat& rFrameFormat, bool 
bClose);
+    void OutCSS1_TableCellBorderHack(const SwFrameFormat& rFrameFormat);
     void OutCSS1_SectionFormatOptions( const SwFrameFormat& rFrameFormat, 
const SwFormatCol *pCol );
     void OutCSS1_FrameFormatOptions( const SwFrameFormat& rFrameFormat, 
HtmlFrmOpts nFrameOpts,
                                      const SdrObject *pSdrObj=nullptr,
@@ -679,7 +679,7 @@ Writer& OutCSS1_ParaTagStyleOpt( Writer& rWrt, const 
SfxItemSet& rItemSet );
 Writer& OutCSS1_HintSpanTag( Writer& rWrt, const SfxPoolItem& rHt );
 Writer& OutCSS1_HintStyleOpt( Writer& rWrt, const SfxPoolItem& rHt );
 
-Writer& OutCSS1_TableBGStyleOpt( Writer& rWrt, const SfxPoolItem& rHt, bool 
bClose );
+Writer& OutCSS1_TableBGStyleOpt( Writer& rWrt, const SfxPoolItem& rHt );
 Writer& OutCSS1_NumBulListStyleOpt( Writer& rWrt, const SwNumRule& rNumRule,
                                     sal_uInt8 nLevel );
 
commit 2d1ceb06bbac11135b8579a8810a242a208be4c3
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Wed Apr 11 11:51:12 2018 +0200

    sw XHTML export: fix missing namespace prefix of lists
    
    Unordered lists, but fixes ordered lists as a side effect, too.
    
    Change-Id: I1752522e906975b112e6938ffc5456e53a165996
    Reviewed-on: https://gerrit.libreoffice.org/52724
    Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk>
    Tested-by: Jenkins <c...@libreoffice.org>
    (cherry picked from commit adc10e62ddc4a65f6b1fecbcfc7c6560489e3aaa)

diff --git a/sw/qa/extras/htmlexport/data/reqif-list.xhtml 
b/sw/qa/extras/htmlexport/data/reqif-list.xhtml
new file mode 100644
index 000000000000..5433ee10a6ea
--- /dev/null
+++ b/sw/qa/extras/htmlexport/data/reqif-list.xhtml
@@ -0,0 +1,11 @@
+<reqif-xhtml:div>Heading<reqif-xhtml:br/>
+       <reqif-xhtml:ul>
+               <reqif-xhtml:li>
+                       
<reqif-xhtml:strong>First</reqif-xhtml:strong></reqif-xhtml:li>
+               <reqif-xhtml:li>
+                       
<reqif-xhtml:strong>Second</reqif-xhtml:strong></reqif-xhtml:li>
+               <reqif-xhtml:li>
+                       <reqif-xhtml:strong>Third</reqif-xhtml:strong>
+               </reqif-xhtml:li>
+       </reqif-xhtml:ul>
+</reqif-xhtml:div>
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx 
b/sw/qa/extras/htmlexport/htmlexport.cxx
index 8072e530859d..ac54b66ece1d 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -478,6 +478,18 @@ DECLARE_HTMLEXPORT_TEST(testReqIfTable, 
"reqif-table.xhtml")
     assertXPathNoAttribute(pDoc, "/html/body/div/table/tr/th", "bgcolor");
 }
 
+DECLARE_HTMLEXPORT_TEST(testReqIfList, "reqif-list.xhtml")
+{
+    SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
+    CPPUNIT_ASSERT(pStream);
+    pStream->Seek(STREAM_SEEK_TO_END);
+    sal_uInt64 nLength = pStream->Tell();
+    pStream->Seek(0);
+    OString aStream(read_uInt8s_ToOString(*pStream, nLength));
+    // This failed, <ul> was written.
+    CPPUNIT_ASSERT(aStream.indexOf("<reqif-xhtml:ul>") != -1);
+}
+
 DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testReqIfOle2, "reqif-ole2.xhtml")
 {
     uno::Reference<text::XTextEmbeddedObjectsSupplier> xSupplier(mxComponent, 
uno::UNO_QUERY);
diff --git a/sw/source/filter/html/htmlnumwriter.cxx 
b/sw/source/filter/html/htmlnumwriter.cxx
index a488f8f77a80..5ee8044f1b4f 100644
--- a/sw/source/filter/html/htmlnumwriter.cxx
+++ b/sw/source/filter/html/htmlnumwriter.cxx
@@ -181,6 +181,7 @@ Writer& OutHTML_NumBulListStart( SwHTMLWriter& rWrt,
 
         rWrt.m_aBulletGrfs[i].clear();
         OString sOut = "<";
+        sOut += rWrt.GetNamespace();
         const SwNumFormat& rNumFormat = rInfo.GetNumRule()->Get( i );
         sal_Int16 eType = rNumFormat.GetNumberingType();
         if( SVX_NUM_CHAR_SPECIAL == eType )
commit 69a726578c5188cc3ebb8d5340f91b731a724557
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Tue Apr 10 08:57:09 2018 +0200

    tdf#116555 filter: make sure default extension for HTML is not .xhtml
    
    Since by default we don't write XHTML markup in the sw HTML export.
    
    Change-Id: Ifbf9850652d7838582725be391b2fd1a062495e5
    Reviewed-on: https://gerrit.libreoffice.org/52663
    Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk>
    Tested-by: Jenkins <c...@libreoffice.org>
    (cherry picked from commit 87e7fd163bc587b5c7cbb59ba40a9856f8bb225d)

diff --git a/filter/source/config/fragments/types/generic_HTML.xcu 
b/filter/source/config/fragments/types/generic_HTML.xcu
index b29ba333aded..92ac87ffbf3e 100644
--- a/filter/source/config/fragments/types/generic_HTML.xcu
+++ b/filter/source/config/fragments/types/generic_HTML.xcu
@@ -18,7 +18,8 @@
     <node oor:name="generic_HTML" oor:op="replace" >
         <prop 
oor:name="DetectService"><value>com.sun.star.comp.filters.PlainTextFilterDetect</value></prop>
         <prop 
oor:name="URLPattern"><value>private:factory/swriter/web*</value></prop>
-        <prop oor:name="Extensions"><value>html htm xhtml</value></prop>
+        <!-- the last extension is used when the code wants to know the 
extension of this type -->
+        <prop oor:name="Extensions"><value>html xhtml htm</value></prop>
         <prop oor:name="MediaType"><value>text/html</value></prop>
         <prop oor:name="Preferred"><value>false</value></prop>
         <prop oor:name="PreferredFilter"><value>HTML</value></prop>
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to