[Libreoffice-commits] core.git: vcl/inc vcl/source

Noel Grandin noel.grandin at collabora.co.uk
Fri Jun 1 13:18:22 UTC 2018


 vcl/inc/svmconverter.hxx        |    9 +++----
 vcl/source/gdi/gdimtf.cxx       |   25 +-------------------
 vcl/source/gdi/svmconverter.cxx |   49 +---------------------------------------
 3 files changed, 8 insertions(+), 75 deletions(-)

New commits:
commit 1cfe22ff1d8327f015a2ef17175f8c7845929432
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Fri Jun 1 11:45:31 2018 +0200

    remove old "convert to SVM1" code only active in debug mode
    
    Change-Id: I1d83e6ea5f8eb998f95e6ec334a695eb1df78df1
    Reviewed-on: https://gerrit.libreoffice.org/55173
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/vcl/inc/svmconverter.hxx b/vcl/inc/svmconverter.hxx
index 0b2c41fa6640..a1d066b7a02b 100644
--- a/vcl/inc/svmconverter.hxx
+++ b/vcl/inc/svmconverter.hxx
@@ -26,9 +26,6 @@
 
 #include <stack>
 
-#define CONVERT_TO_SVM1                 0x00000001UL
-#define CONVERT_FROM_SVM1               0x00000002UL
-
 #define GDI_PIXEL_ACTION                1
 #define GDI_POINT_ACTION                2
 #define GDI_LINE_ACTION                 3
@@ -75,18 +72,20 @@
 
 #define GDI_LINECAP_ACTION              1036
 
+/**
+ * Converts old SVGDI aka SVM1 format data to current VCLMTF aka SVM2 format metafile data.
+ */
 class VCL_PLUGIN_PUBLIC SVMConverter
 {
 private:
     SAL_DLLPRIVATE static void      ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf );
-    SAL_DLLPRIVATE void             ImplConvertToSVM1( SvStream& rOStm, GDIMetaFile const & rMtf );
     SAL_DLLPRIVATE sal_uLong        ImplWriteActions( SvStream& rOStm, GDIMetaFile const & rMtf,
                                           VirtualDevice& rSaveVDev, bool& rRop_0_1,
                                           Color& rLineCol, ::std::stack<Color*>& rLineColStack,
                                           rtl_TextEncoding& rActualCharSet );
 
 public:
-                        SVMConverter( SvStream& rIStm, GDIMetaFile& rMtf, sal_uLong nConvertMode  );
+                        SVMConverter( SvStream& rIStm, GDIMetaFile& rMtf  );
 
 private:
                         SVMConverter( const SVMConverter& ) = delete;
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
index 35f19577eb78..d0dded107ed3 100644
--- a/vcl/source/gdi/gdimtf.cxx
+++ b/vcl/source/gdi/gdimtf.cxx
@@ -2687,9 +2687,8 @@ SvStream& ReadGDIMetaFile(SvStream& rIStm, GDIMetaFile& rGDIMetaFile, ImplMetaRe
         }
         else
         {
-            // to avoid possible compiler optimizations => new/delete
             rIStm.Seek( nStmPos );
-            delete new SVMConverter( rIStm, rGDIMetaFile, CONVERT_FROM_SVM1 );
+            SVMConverter( rIStm, rGDIMetaFile );
         }
     }
     catch (...)
@@ -2713,28 +2712,8 @@ SvStream& WriteGDIMetaFile( SvStream& rOStm, const GDIMetaFile& rGDIMetaFile )
 {
     if( !rOStm.GetError() )
     {
-        static const char*  pEnableSVM1 = getenv( "SAL_ENABLE_SVM1" );
-        static const bool   bNoSVM1 = (nullptr == pEnableSVM1 ) || ( '0' == *pEnableSVM1 );
-
-        if( bNoSVM1 || rOStm.GetVersion() >= SOFFICE_FILEFORMAT_50  )
-        {
-            const_cast< GDIMetaFile& >( rGDIMetaFile ).Write( rOStm );
-        }
-        else
-        {
-            delete new SVMConverter( rOStm, const_cast< GDIMetaFile& >( rGDIMetaFile ), CONVERT_TO_SVM1 );
-        }
-
-#ifdef DEBUG
-        if( !bNoSVM1 && rOStm.GetVersion() < SOFFICE_FILEFORMAT_50 )
-        {
-            SAL_WARN( "vcl", "GDIMetaFile would normally be written in old SVM1 format by this call. "
-                "The current implementation always writes in VCLMTF format. "
-                "Please set environment variable SAL_ENABLE_SVM1 to '1' to reenable old behavior" );
-        }
-#endif // DEBUG
+        const_cast< GDIMetaFile& >( rGDIMetaFile ).Write( rOStm );
     }
-
     return rOStm;
 }
 
diff --git a/vcl/source/gdi/svmconverter.cxx b/vcl/source/gdi/svmconverter.cxx
index 8e6db507764d..039fd2d252ea 100644
--- a/vcl/source/gdi/svmconverter.cxx
+++ b/vcl/source/gdi/svmconverter.cxx
@@ -484,14 +484,11 @@ void ImplReadExtendedPolyPolygonAction(SvStream& rIStm, tools::PolyPolygon& rPol
     }
 }
 
-SVMConverter::SVMConverter( SvStream& rStm, GDIMetaFile& rMtf, sal_uLong nConvertMode )
+SVMConverter::SVMConverter( SvStream& rStm, GDIMetaFile& rMtf )
 {
     if( !rStm.GetError() )
     {
-        if( CONVERT_FROM_SVM1 == nConvertMode )
-            ImplConvertFromSVM1( rStm, rMtf );
-        else if( CONVERT_TO_SVM1 == nConvertMode )
-            ImplConvertToSVM1( rStm, rMtf );
+        ImplConvertFromSVM1( rStm, rMtf );
     }
 }
 
@@ -1479,48 +1476,6 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
     rIStm.SetEndian( nOldFormat );
 }
 
-void SVMConverter::ImplConvertToSVM1( SvStream& rOStm, GDIMetaFile const & rMtf )
-{
-    sal_uLong           nCountPos;
-    vcl::Font           aSaveFont;
-    const SvStreamEndian nOldFormat = rOStm.GetEndian();
-    rtl_TextEncoding    eActualCharSet = osl_getThreadTextEncoding();
-    const Size          aPrefSize( rMtf.GetPrefSize() );
-    bool                bRop_0_1 = false;
-    ScopedVclPtrInstance< VirtualDevice > aSaveVDev;
-    Color               aLineCol( COL_BLACK );
-    ::std::stack< Color* >  aLineColStack;
-
-    rOStm.SetEndian( SvStreamEndian::LITTLE );
-
-    // Write MagicCode
-    rOStm.WriteCharPtr( "SVGDI" );                                   // Identifier
-    rOStm.WriteInt16( 42 );                            // HeaderSize
-    rOStm.WriteInt16( 200 );                           // VERSION
-    rOStm.WriteInt32( aPrefSize.Width() );
-    rOStm.WriteInt32( aPrefSize.Height() );
-    ImplWriteMapMode( rOStm, rMtf.GetPrefMapMode() );
-
-    // ActionCount will be written later
-    nCountPos = rOStm.Tell();
-    rOStm.SeekRel( 4 );
-
-    const sal_Int32 nActCount = ImplWriteActions( rOStm, rMtf, *aSaveVDev.get(), bRop_0_1, aLineCol, aLineColStack, eActualCharSet );
-    const sal_uLong nActPos = rOStm.Tell();
-
-    rOStm.Seek( nCountPos );
-    rOStm.WriteInt32( nActCount );
-    rOStm.Seek( nActPos );
-    rOStm.SetEndian( nOldFormat );
-
-    // cleanup push-pop stack if necessary
-    while ( !aLineColStack.empty() )
-    {
-        delete aLineColStack.top();
-        aLineColStack.pop();
-    }
-}
-
 sal_uLong SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile const & rMtf,
                                       VirtualDevice& rSaveVDev, bool& rRop_0_1,
                                       Color& rLineCol, ::std::stack< Color* >& rLineColStack,


More information about the Libreoffice-commits mailing list