diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-07-13 15:26:34 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-07-13 16:35:55 +0200 |
commit | 2b9e55aa4ce070eb5301adb67af85d062eb1dc36 (patch) | |
tree | e78653ce4eb176b19f607d0ac2233714bf89373e /sw | |
parent | 660c0b54a18be5ec0c87dc55e6ca8196606ea999 (diff) |
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@collabora.co.uk>
Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/htmlexport/data/reqif.odt | bin | 0 -> 8559 bytes | |||
-rw-r--r-- | sw/qa/extras/htmlexport/htmlexport.cxx | 14 | ||||
-rw-r--r-- | sw/source/filter/html/htmlatr.cxx | 70 |
3 files changed, 67 insertions, 17 deletions
diff --git a/sw/qa/extras/htmlexport/data/reqif.odt b/sw/qa/extras/htmlexport/data/reqif.odt Binary files differnew file mode 100644 index 000000000000..a094202e9775 --- /dev/null +++ b/sw/qa/extras/htmlexport/data/reqif.odt 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; |