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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Jul 13 15:15:24 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 8feac85c6fb6901569e674afc0344b6a7c4dd997
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 17:07:59 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
    (cherry picked from commit 2b9e55aa4ce070eb5301adb67af85d062eb1dc36)

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 161d1fc098e5..ce773347d25c 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 27e7c818d146..137febd1d86a 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -2698,14 +2698,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;
 }
@@ -2718,24 +2736,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