[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - include/vcl svx/source sw/source vcl/source

László Németh nemeth at numbertext.org
Mon Jun 25 13:38:03 UTC 2018


 include/vcl/gfxlink.hxx                     |    1 +
 svx/source/xml/xmlgrhlp.cxx                 |    7 ++++++-
 sw/source/filter/ww8/rtfattributeoutput.cxx |   19 ++-----------------
 vcl/source/gdi/gfxlink.cxx                  |   16 ++++++++++++++++
 4 files changed, 25 insertions(+), 18 deletions(-)

New commits:
commit 9ff1a70edfd2cf92a65825a5c6b0a68cd79c9056
Author: László Németh <nemeth at numbertext.org>
Date:   Mon Jun 18 16:48:02 2018 +0200

    tdf#103913 keep ".emf" file extension and mime type
    
    in documents, don't change them to wmf and image/x-wmf
    silently, resulting for example, dropping or rejecting
    modified documents by firewall packet filtering.
    
    Reviewed-on: https://gerrit.libreoffice.org/56045
    Reviewed-by: László Németh <nemeth at numbertext.org>
    Tested-by: László Németh <nemeth at numbertext.org>
    (cherry-picked from commit 4cb1e86e5217f09e1d98e51e46803a06fb72f5ce)
    
    Change-Id: I3b8634ae022c7c026b0ed4ebc345c1c3b3f96337
    Reviewed-on: https://gerrit.libreoffice.org/56080
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: Gabor Kelemen <kelemeng at ubuntu.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/vcl/gfxlink.hxx b/include/vcl/gfxlink.hxx
index 054ab2cf2dca..29e7a0e53c88 100644
--- a/include/vcl/gfxlink.hxx
+++ b/include/vcl/gfxlink.hxx
@@ -111,6 +111,7 @@ public:
     void                SwapIn();
     bool                IsSwappedOut() const { return( bool(mpSwapOutData) ); }
 
+    bool                IsEMF() const; // WMF & EMF stored under the same type (NativeWmf)
 public:
 
     friend VCL_DLLPUBLIC SvStream&  WriteGfxLink( SvStream& rOStream, const GfxLink& rGfxLink );
diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx
index a0f01b8671ac..3ebb6730b928 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -659,7 +659,12 @@ OUString SvXMLGraphicHelper::implSaveGraphic(css::uno::Reference<css::graphic::X
                 case GfxLinkType::NativeJpg: aExtension = ".jpg"; break;
                 case GfxLinkType::NativePng: aExtension = ".png"; break;
                 case GfxLinkType::NativeTif: aExtension = ".tif"; break;
-                case GfxLinkType::NativeWmf: aExtension = ".wmf"; break;
+                case GfxLinkType::NativeWmf:
+                    if (aGfxLink.IsEMF())
+                        aExtension = ".emf";
+                    else
+                        aExtension = ".wmf";
+                    break;
                 case GfxLinkType::NativeMet: aExtension = ".met"; break;
                 case GfxLinkType::NativePct: aExtension = ".pct"; break;
                 case GfxLinkType::NativeSvg:
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 42199d4770b6..99b283f92e9c 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -3701,21 +3701,6 @@ void RtfAttributeOutput::FontPitchType(FontPitch ePitch) const
     m_rExport.OutULong(nVal);
 }
 
-static bool IsEMF(const sal_uInt8* pGraphicAry, unsigned long nSize)
-{
-    if (pGraphicAry && (nSize > 0x2c))
-    {
-        // check the magic number
-        if ((pGraphicAry[0x28] == 0x20) && (pGraphicAry[0x29] == 0x45)
-            && (pGraphicAry[0x2a] == 0x4d) && (pGraphicAry[0x2b] == 0x46))
-        {
-            //emf detected
-            return true;
-        }
-    }
-    return false;
-}
-
 static bool StripMetafileHeader(const sal_uInt8*& rpGraphicAry, unsigned long& rSize)
 {
     if (rpGraphicAry && (rSize > 0x22))
@@ -3957,8 +3942,8 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrameFormat* pFlyFrameFormat
                 pBLIPType = OOO_STRING_SVTOOLS_RTF_PNGBLIP;
                 break;
             case GfxLinkType::NativeWmf:
-                pBLIPType = IsEMF(pGraphicAry, nSize) ? OOO_STRING_SVTOOLS_RTF_EMFBLIP
-                                                      : OOO_STRING_SVTOOLS_RTF_WMETAFILE;
+                pBLIPType = aGraphicLink.IsEMF() ? OOO_STRING_SVTOOLS_RTF_EMFBLIP
+                                                 : OOO_STRING_SVTOOLS_RTF_WMETAFILE;
                 break;
             case GfxLinkType::NativeGif:
                 // GIF is not supported by RTF, but we override default conversion to WMF, PNG seems fits better here.
diff --git a/vcl/source/gdi/gfxlink.cxx b/vcl/source/gdi/gfxlink.cxx
index 885385cb51b0..d37938dba8a0 100644
--- a/vcl/source/gdi/gfxlink.cxx
+++ b/vcl/source/gdi/gfxlink.cxx
@@ -286,4 +286,20 @@ std::shared_ptr<sal_uInt8> GfxLink::GetSwapInData() const
     return pData;
 }
 
+bool GfxLink::IsEMF() const
+{
+    const sal_uInt8* pGraphicAry = GetData();
+    if ((GetType() == GfxLinkType::NativeWmf) && pGraphicAry && (GetDataSize() > 0x2c))
+    {
+        // check the magic number
+        if ((pGraphicAry[0x28] == 0x20) && (pGraphicAry[0x29] == 0x45)
+            && (pGraphicAry[0x2a] == 0x4d) && (pGraphicAry[0x2b] == 0x46))
+        {
+            //emf detected
+            return true;
+        }
+    }
+    return false;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list