[Libreoffice-commits] core.git: emfio/source

Stephan Bergmann sbergman at redhat.com
Wed Aug 30 06:31:57 UTC 2017


 emfio/source/reader/mtftools.cxx |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

New commits:
commit f86552ea150c971a995db4856482746df9ffdbba
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Aug 30 08:25:33 2017 +0200

    This check for GDIObj subtypes is exhaustive
    
    For one, catches issues like d5ed3cd6dbd22bb18542778f1c48f4d5b3ae0f95 "Make
    WinMtfFontStyle's base class EMFIO_DLLPUBLIC, too" earlier.  For another, uses
    if/else to avoid unnecessary, expensive dynamic casts.
    
    Change-Id: I695b1e8673d5af22060b05b982789ad0ddcd39c3

diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx
index 1698eec4a37a..d02dd6b902b5 100644
--- a/emfio/source/reader/mtftools.cxx
+++ b/emfio/source/reader/mtftools.cxx
@@ -609,20 +609,19 @@ namespace emfio
 
             if ( pGDIObj )
             {
-                const auto pen = dynamic_cast<WinMtfLineStyle*>(pGDIObj);
-                if (pen)
+                if (const auto pen = dynamic_cast<WinMtfLineStyle*>(pGDIObj))
                     maLineStyle = *pen;
-
-                const auto brush = dynamic_cast<WinMtfFillStyle*>(pGDIObj);
-                if (brush)
+                else if (const auto brush = dynamic_cast<WinMtfFillStyle*>(
+                             pGDIObj))
                 {
                     maFillStyle = *brush;
                     mbFillStyleSelected = true;
                 }
-
-                const auto font = dynamic_cast<WinMtfFontStyle*>(pGDIObj);
-                if (font)
+                else if (const auto font = dynamic_cast<WinMtfFontStyle*>(
+                             pGDIObj))
                     maFont = font->aFont;
+                else
+                    assert(false);
             }
         }
     }


More information about the Libreoffice-commits mailing list