[Libreoffice-commits] core.git: sw/qa sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Jul 13 14:36:28 UTC 2018
sw/qa/extras/htmlexport/data/reqif.odt |binary
sw/qa/extras/htmlexport/htmlexport.cxx | 14 ++++++
sw/source/filter/html/htmlatr.cxx | 70 ++++++++++++++++++++++++---------
3 files changed, 67 insertions(+), 17 deletions(-)
New commits:
commit 2b9e55aa4ce070eb5301adb67af85d062eb1dc36
Author: Miklos Vajna <vmiklos at collabora.co.uk>
AuthorDate: Fri Jul 13 15:26:34 2018 +0200
Commit: Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Fri Jul 13 16:35:55 2018 +0200
sw HTML export: fix XHTML mode of 'Heading 7' style
Font name, font size.
Change-Id: I32b8b2d596b0e0aeb72156edaae83b4b04765583
Reviewed-on: https://gerrit.libreoffice.org/57392
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins
diff --git a/sw/qa/extras/htmlexport/data/reqif.odt b/sw/qa/extras/htmlexport/data/reqif.odt
new file mode 100644
index 000000000000..a094202e9775
Binary files /dev/null and b/sw/qa/extras/htmlexport/data/reqif.odt differ
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 499d8c3dc0c8..0cc519ab288d 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -508,6 +508,20 @@ DECLARE_HTMLEXPORT_TEST(testReqIfTable2, "reqif-table2.odt")
CPPUNIT_ASSERT(aStream.indexOf("<reqif-xhtml:td>") != -1);
}
+DECLARE_HTMLEXPORT_TEST(testReqIfWellFormed, "reqif.odt")
+{
+ 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, <font face="..."> was written.
+ CPPUNIT_ASSERT(aStream.indexOf("<reqif-xhtml:span style=\"font-family:") != -1);
+ // This failed, <font size="..."> was written.
+ CPPUNIT_ASSERT(aStream.indexOf("<reqif-xhtml:span style=\"font-size:") != -1);
+}
+
DECLARE_HTMLEXPORT_TEST(testReqIfList, "reqif-list.xhtml")
{
SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index fbdb746c726c..e69dac37946f 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -2689,14 +2689,32 @@ static Writer& OutHTML_SvxFont( Writer& rWrt, const SfxPoolItem& rHt )
OUString aNames;
SwHTMLWriter::PrepareFontList( static_cast<const SvxFontItem&>(rHt), aNames, 0,
rHTMLWrt.IsHTMLMode(HTMLMODE_FONT_GENERIC) );
- OString sOut = "<" OOO_STRING_SVTOOLS_HTML_font " "
- OOO_STRING_SVTOOLS_HTML_O_face "=\"";
- rWrt.Strm().WriteOString( sOut );
- HTMLOutFuncs::Out_String( rWrt.Strm(), aNames, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters )
- .WriteCharPtr( "\">" );
+ if (rHTMLWrt.mbXHTML)
+ {
+ OString sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span
+ " " OOO_STRING_SVTOOLS_HTML_O_style "=\"font-family: ";
+ rWrt.Strm().WriteOString(sOut);
+ HTMLOutFuncs::Out_String(rWrt.Strm(), aNames, rHTMLWrt.m_eDestEnc,
+ &rHTMLWrt.m_aNonConvertableCharacters)
+ .WriteCharPtr("\">");
+ }
+ else
+ {
+ OString sOut = "<" OOO_STRING_SVTOOLS_HTML_font " "
+ OOO_STRING_SVTOOLS_HTML_O_face "=\"";
+ rWrt.Strm().WriteOString( sOut );
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aNames, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters )
+ .WriteCharPtr( "\">" );
+ }
}
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;
}
@@ -2709,24 +2727,42 @@ static Writer& OutHTML_SvxFontHeight( Writer& rWrt, const SfxPoolItem& rHt )
if( rHTMLWrt.m_bTagOn )
{
- OString sOut = "<" OOO_STRING_SVTOOLS_HTML_font;
-
- sal_uInt32 nHeight = static_cast<const SvxFontHeightItem&>(rHt).GetHeight();
- sal_uInt16 nSize = rHTMLWrt.GetHTMLFontSize( nHeight );
- sOut += " " OOO_STRING_SVTOOLS_HTML_O_size "=\"" +
- OString::number(static_cast<sal_Int32>(nSize)) + "\"";
- rWrt.Strm().WriteOString( sOut );
+ if (rHTMLWrt.mbXHTML)
+ {
+ OString sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span;
- if( rHTMLWrt.m_bCfgOutStyles && rHTMLWrt.m_bTextAttr )
+ sal_uInt32 nHeight = static_cast<const SvxFontHeightItem&>(rHt).GetHeight();
+ // Twips -> points.
+ sal_uInt16 nSize = nHeight / 20;
+ sOut += " " OOO_STRING_SVTOOLS_HTML_O_style "=\"font-size: "
+ + OString::number(static_cast<sal_Int32>(nSize)) + "pt\"";
+ rWrt.Strm().WriteOString(sOut);
+ }
+ else
{
- // always export font size as CSS option, too
- OutCSS1_HintStyleOpt( rWrt, rHt );
+ OString sOut = "<" OOO_STRING_SVTOOLS_HTML_font;
+
+ sal_uInt32 nHeight = static_cast<const SvxFontHeightItem&>(rHt).GetHeight();
+ sal_uInt16 nSize = rHTMLWrt.GetHTMLFontSize( nHeight );
+ sOut += " " OOO_STRING_SVTOOLS_HTML_O_size "=\"" +
+ OString::number(static_cast<sal_Int32>(nSize)) + "\"";
+ rWrt.Strm().WriteOString( sOut );
+
+ if( rHTMLWrt.m_bCfgOutStyles && rHTMLWrt.m_bTextAttr )
+ {
+ // always export font size as CSS option, too
+ OutCSS1_HintStyleOpt( rWrt, rHt );
+ }
}
rWrt.Strm().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