[Libreoffice-commits] core.git: Branch 'distro/vector/vector-5.4' - include/svtools svtools/source sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Mon Jul 9 08:28:35 UTC 2018


 include/svtools/htmlout.hxx                |    2 +-
 svtools/source/svhtml/htmlout.cxx          |    7 +++++--
 sw/qa/extras/htmlexport/data/reqif-p.xhtml |    1 +
 sw/qa/extras/htmlexport/htmlexport.cxx     |    3 +++
 sw/source/filter/html/htmlatr.cxx          |   26 +++++++++++++++++++++-----
 5 files changed, 31 insertions(+), 8 deletions(-)

New commits:
commit bd6a11360a626964c68d2c6aedba42b99b558f5b
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Jul 6 16:33:10 2018 +0200

    sw HTML export: avoid writing <font> in XHTML mode
    
    First, it should be <$prefix:font>, not <font>, but then XHTML prefers
    CSS for font color.
    
    Reviewed-on: https://gerrit.libreoffice.org/57085
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins
    (cherry picked from commit fafc6f046f9e92d5776d31ea6abb188ec74aaa71)
    
    Conflicts:
            include/svtools/htmlout.hxx
            svtools/source/svhtml/htmlout.cxx
    
    Change-Id: I947c0b93a117c8e88e4aec91c3c7f843bd943c59

diff --git a/include/svtools/htmlout.hxx b/include/svtools/htmlout.hxx
index a906fed1f566..8ebc9ef59bb6 100644
--- a/include/svtools/htmlout.hxx
+++ b/include/svtools/htmlout.hxx
@@ -68,7 +68,7 @@ struct HTMLOutFuncs
                         OUString *pNonConvertableChars = nullptr );
     SVT_DLLPUBLIC static SvStream& Out_Hex( SvStream&, sal_uLong nHex, sal_uInt8 nLen,
                         rtl_TextEncoding eDestEnc = RTL_TEXTENCODING_MS_1252 );
-    SVT_DLLPUBLIC static SvStream& Out_Color( SvStream&, const Color& );
+    SVT_DLLPUBLIC static SvStream& Out_Color( SvStream&, const Color&, bool bXHTML = false );
     SVT_DLLPUBLIC static SvStream& Out_ImageMap( SvStream&, const OUString&, const ImageMap&, const OUString&,
                                    const HTMLOutEvent *pEventTable,
                                    bool bOutStarBasic,
diff --git a/svtools/source/svhtml/htmlout.cxx b/svtools/source/svhtml/htmlout.cxx
index 66d4206c430d..acdbc936792a 100644
--- a/svtools/source/svhtml/htmlout.cxx
+++ b/svtools/source/svhtml/htmlout.cxx
@@ -581,9 +581,12 @@ SvStream& HTMLOutFuncs::Out_Hex( SvStream& rStream, sal_uLong nHex, sal_uInt8 nL
 }
 
 
-SvStream& HTMLOutFuncs::Out_Color( SvStream& rStream, const Color& rColor )
+SvStream& HTMLOutFuncs::Out_Color( SvStream& rStream, const Color& rColor, bool bXHTML )
 {
-    rStream.WriteCharPtr( "\"#" );
+    rStream.WriteCharPtr( "\"" );
+    if (bXHTML)
+        rStream.WriteCharPtr( "color: " );
+    rStream.WriteCharPtr( "#" );
     if( rColor.GetColor() == COL_AUTO )
     {
         rStream.WriteCharPtr( "000000" );
diff --git a/sw/qa/extras/htmlexport/data/reqif-p.xhtml b/sw/qa/extras/htmlexport/data/reqif-p.xhtml
index b05cdeb9d8e7..fa69342d00a6 100644
--- a/sw/qa/extras/htmlexport/data/reqif-p.xhtml
+++ b/sw/qa/extras/htmlexport/data/reqif-p.xhtml
@@ -4,3 +4,4 @@
 <reqif-xhtml:span style="text-decoration: underline">u</reqif-xhtml:span>
 <reqif-xhtml:strong>s</reqif-xhtml:strong>
 <reqif-xhtml:strike>s</reqif-xhtml:strike>
+<reqif-xhtml:font color="#ce181e">s</reqif-xhtml:font>
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index a9ed8dde14c4..bf46da807fa6 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -369,6 +369,9 @@ DECLARE_HTMLEXPORT_TEST(testReqIfParagraph, "reqif-p.xhtml")
 
     // This was "<strike>" instead of CSS.
     CPPUNIT_ASSERT(aStream.indexOf("<reqif-xhtml:span style=\"text-decoration: line-through\"") != -1);
+
+    // This was "<font>" instead of CSS + namespace prefix was missing.
+    CPPUNIT_ASSERT(aStream.indexOf("<reqif-xhtml:span style=\"color: #ce181e\"") != -1);
 }
 
 DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testReqIfOleData, "reqif-ole-data.xhtml")
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index 83c9718a0ce6..27e7c818d146 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -2640,13 +2640,29 @@ static Writer& OutHTML_SvxColor( Writer& rWrt, const SfxPoolItem& rHt )
         if( COL_AUTO == aColor.GetColor() )
             aColor.SetColor( COL_BLACK );
 
-        OString sOut = "<" OOO_STRING_SVTOOLS_HTML_font " "
-            OOO_STRING_SVTOOLS_HTML_O_color "=";
-        rWrt.Strm().WriteOString( sOut );
-        HTMLOutFuncs::Out_Color( rWrt.Strm(), aColor ).WriteChar( '>' );
+        if (rHTMLWrt.mbXHTML)
+        {
+            OString sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span
+                           " " OOO_STRING_SVTOOLS_HTML_O_style "=";
+            rWrt.Strm().WriteOString(sOut);
+            HTMLOutFuncs::Out_Color(rWrt.Strm(), aColor, /*bXHTML=*/true).WriteChar('>');
+        }
+        else
+        {
+            OString sOut = "<" OOO_STRING_SVTOOLS_HTML_font " "
+                OOO_STRING_SVTOOLS_HTML_O_color "=";
+            rWrt.Strm().WriteOString( sOut );
+            HTMLOutFuncs::Out_Color( rWrt.Strm(), aColor ).WriteChar( '>' );
+        }
     }
     else
-        HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_font, false );
+    {
+        if (rHTMLWrt.mbXHTML)
+            HTMLOutFuncs::Out_AsciiTag(
+                rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span, false);
+        else
+            HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_font, false );
+    }
 
     return rWrt;
 }


More information about the Libreoffice-commits mailing list