Code

Merged from Poppler's Gfx.cc; Unset the font if it doesn't exist or we can not load...
[inkscape.git] / src / extension / internal / emf-win32-inout.cpp
index eb499588548c758c2b7ed05a34468460788421fd..6e008b7542a2295a89d58b6a564634656ec99d43 100644 (file)
@@ -332,7 +332,7 @@ select_pen(PEMF_CALLBACK_DATA d, int index)
     r = SP_COLOR_U_TO_F( GetRValue(pEmr->lopn.lopnColor) );
     g = SP_COLOR_U_TO_F( GetGValue(pEmr->lopn.lopnColor) );
     b = SP_COLOR_U_TO_F( GetBValue(pEmr->lopn.lopnColor) );
-    sp_color_set_rgb_float( &(d->style.stroke.value.color), r,g,b );
+    d->style.stroke.value.color.set( r, g, b );
 
     d->style.stroke_linejoin.computed = 1;
 
@@ -420,7 +420,7 @@ select_extpen(PEMF_CALLBACK_DATA d, int index)
     g = SP_COLOR_U_TO_F( GetGValue(pEmr->elp.elpColor) );
     b = SP_COLOR_U_TO_F( GetBValue(pEmr->elp.elpColor) );
 
-    sp_color_set_rgb_float( &(d->style.stroke.value.color), r,g,b );
+    d->style.stroke.value.color.set( r, g, b );
 
     d->stroke_set = true;
 }
@@ -442,7 +442,7 @@ select_brush(PEMF_CALLBACK_DATA d, int index)
         r = SP_COLOR_U_TO_F( GetRValue(pEmr->lb.lbColor) );
         g = SP_COLOR_U_TO_F( GetGValue(pEmr->lb.lbColor) );
         b = SP_COLOR_U_TO_F( GetBValue(pEmr->lb.lbColor) );
-        sp_color_set_rgb_float( &(d->style.fill.value.color), r,g,b );
+        d->style.fill.value.color.set( r, g, b );
     }
 
     d->fill_set = true;
@@ -505,6 +505,15 @@ myEnhMetaFileProc(HDC hDC, HANDLETABLE *lpHTable, ENHMETARECORD *lpEMFR, int nOb
             if (pEmr->nHandles) {
                 d->n_obj = pEmr->nHandles;
                 d->emf_obj = new EMF_OBJECT[d->n_obj];
+
+                // Init the new emf_obj list elements to null, provided the
+                // dynamic allocation succeeded.
+                if ( d->emf_obj != NULL )
+                {
+                    for( unsigned int i=0; i < d->n_obj; ++i )
+                        d->emf_obj[i].lpEMFR = NULL;
+                } //if
+
             } else {
                 d->emf_obj = NULL;
             }
@@ -794,7 +803,7 @@ myEnhMetaFileProc(HDC hDC, HANDLETABLE *lpHTable, ENHMETARECORD *lpEMFR, int nOb
                                 val = 255.0 / 255.0;
                                 break;
                         }
-                        sp_color_set_rgb_float( &(d->style.fill.value.color), val,val,val );
+                        d->style.fill.value.color.set( val, val, val );
 
                         d->fill_set = true;
                         break;
@@ -808,7 +817,7 @@ myEnhMetaFileProc(HDC hDC, HANDLETABLE *lpHTable, ENHMETARECORD *lpEMFR, int nOb
                         float val = index == BLACK_PEN ? 0 : 1;
                         d->style.stroke_dasharray_set = 0;
                         d->style.stroke_width.value = 1.0;
-                        sp_color_set_rgb_float( &(d->style.stroke.value.color), val,val,val );
+                        d->style.stroke.value.color.set( val, val, val );
 
                         d->stroke_set = true;
 
@@ -1349,7 +1358,7 @@ EmfWin32::open( Inkscape::Extension::Input *mod, const gchar *uri )
             delete_object(&d, i);
         delete[] d.emf_obj;
     }
-    
+
     if (d.style.stroke_dash.dash)
         delete[] d.style.stroke_dash.dash;