Code

No more NRMatrix or NRPoint.
[inkscape.git] / src / desktop-style.cpp
index e56e7fbbe8acf99eb26155b5eb2f617e83f226ed..3504dcf4070ffc0284816547751a8dda5e1c8a2c 100644 (file)
@@ -12,6 +12,9 @@
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
 
+#include <string>
+#include <cstring>
+
 #include "desktop.h"
 #include "color-rgba.h"
 #include "svg/css-ostringstream.h"
@@ -402,7 +405,7 @@ stroke_average_width (GSList const *objects)
             notstroked = false;
         }
 
-        avgwidth += SP_OBJECT_STYLE (object)->stroke_width.computed * i2d.expansion();
+        avgwidth += SP_OBJECT_STYLE (object)->stroke_width.computed * NR::expansion(i2d);
     }
 
     if (notstroked)
@@ -658,7 +661,7 @@ objects_query_strokewidth (GSList *objects, SPStyle *style_res)
         n_stroked ++;
 
         NR::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj));
-        double sw = style->stroke_width.computed * i2d.expansion();
+        double sw = style->stroke_width.computed * NR::expansion(i2d);
 
         if (prev_sw != -1 && fabs(sw - prev_sw) > 1e-3)
             same_sw = false;
@@ -1075,21 +1078,25 @@ objects_query_fontspecification (GSList *objects, SPStyle *style_res)
 
         texts ++;
 
-        if (style_res->text->font_specification.value && style->text->font_specification.value &&
+        if (style_res->text->font_specification.value && style_res->text->font_specification.set &&   
+            style->text->font_specification.value && style->text->font_specification.set &&
             strcmp (style_res->text->font_specification.value, style->text->font_specification.value)) {
             different = true;  // different fonts
         }
+        
+        if (style->text->font_specification.set) {
 
-        if (style_res->text->font_specification.value) {
-            g_free(style_res->text->font_specification.value);
-            style_res->text->font_specification.value = NULL;
+            if (style_res->text->font_specification.value) {
+                g_free(style_res->text->font_specification.value);
+                style_res->text->font_specification.value = NULL;
+            }
+    
+            style_res->text->font_specification.set = TRUE;
+            style_res->text->font_specification.value = g_strdup(style->text->font_specification.value);
         }
-
-        style_res->text->font_specification.set = TRUE;
-        style_res->text->font_specification.value = g_strdup(style->text->font_specification.value);
     }
 
-    if (texts == 0 || !style_res->text->font_specification.set)
+    if (texts == 0)
         return QUERY_STYLE_NOTHING;
 
     if (texts > 1) {
@@ -1310,8 +1317,8 @@ sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property)
 }
 
 /**
- * Do the same as sp_desktop_query_style for all (defined) style properties, return true if none of
- * the properties returned QUERY_STYLE_NOTHING.
+ * Do the same as sp_desktop_query_style for all (defined) style properties, return true if at 
+ * least one of the properties did not return QUERY_STYLE_NOTHING.
  */
 bool
 sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query)
@@ -1328,7 +1335,17 @@ sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query)
         int result_opacity = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_MASTEROPACITY);
         int result_blur = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_BLUR);
         
-        return (result_family != QUERY_STYLE_NOTHING && result_fstyle != QUERY_STYLE_NOTHING && result_fnumbers != QUERY_STYLE_NOTHING && result_fill != QUERY_STYLE_NOTHING && result_stroke != QUERY_STYLE_NOTHING && result_opacity != QUERY_STYLE_NOTHING && result_strokewidth != QUERY_STYLE_NOTHING && result_strokemiterlimit != QUERY_STYLE_NOTHING && result_strokecap != QUERY_STYLE_NOTHING && result_strokejoin != QUERY_STYLE_NOTHING && result_blur != QUERY_STYLE_NOTHING);
+        return (result_family != QUERY_STYLE_NOTHING || 
+                result_fstyle != QUERY_STYLE_NOTHING || 
+                result_fnumbers != QUERY_STYLE_NOTHING || 
+                result_fill != QUERY_STYLE_NOTHING || 
+                result_stroke != QUERY_STYLE_NOTHING || 
+                result_opacity != QUERY_STYLE_NOTHING || 
+                result_strokewidth != QUERY_STYLE_NOTHING || 
+                result_strokemiterlimit != QUERY_STYLE_NOTHING ||
+                result_strokecap != QUERY_STYLE_NOTHING ||
+                result_strokejoin != QUERY_STYLE_NOTHING ||
+                result_blur != QUERY_STYLE_NOTHING);
 }