Kaydet (Commit) fafc6f04 authored tarafından Miklos Vajna's avatar Miklos Vajna

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/57085Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins
üst 510209df
......@@ -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,
......
......@@ -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" );
......
......@@ -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>
......@@ -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")
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment