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 fafc6f046f9e92d5776d31ea6abb188ec74aaa71 Author: Miklos Vajna <vmik...@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. Change-Id: I947c0b93a117c8e88e4aec91c3c7f843bd943c59 Reviewed-on: https://gerrit.libreoffice.org/57085 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins diff --git a/include/svtools/htmlout.hxx b/include/svtools/htmlout.hxx index 3d95640e29cb..3adbb23db673 100644 --- a/include/svtools/htmlout.hxx +++ b/include/svtools/htmlout.hxx @@ -66,7 +66,7 @@ struct HTMLOutFuncs rtl_TextEncoding eDestEnc, OUString *pNonConvertableChars = nullptr ); SVT_DLLPUBLIC static SvStream& Out_Hex( SvStream&, sal_uLong nHex, sal_uInt8 nLen ); - 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 8ee63d19b757..fb0a5b941a17 100644 --- a/svtools/source/svhtml/htmlout.cxx +++ b/svtools/source/svhtml/htmlout.cxx @@ -580,9 +580,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 == 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 5d82b82c9524..229c553502cd 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 fffc6dcf320d..fbdb746c726c 100644 --- a/sw/source/filter/html/htmlatr.cxx +++ b/sw/source/filter/html/htmlatr.cxx @@ -2631,13 +2631,29 @@ static Writer& OutHTML_SvxColor( Writer& rWrt, const SfxPoolItem& rHt ) if( COL_AUTO == aColor ) aColor = 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; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits