diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2013-08-09 11:47:56 +0000 |
|---|---|---|
| committer | Javiertxo <jtx@jtx.marker.es> | 2013-08-09 11:47:56 +0000 |
| commit | 4e358f420a7a1512c722d9eccd864416bc4c075b (patch) | |
| tree | 223e826158e09ab2c864abf0214fe1e6a714ab61 /src/style.cpp | |
| parent | Update to trunk (diff) | |
| parent | Remove missing files from POTFILES.in (diff) | |
| download | inkscape-4e358f420a7a1512c722d9eccd864416bc4c075b.tar.gz inkscape-4e358f420a7a1512c722d9eccd864416bc4c075b.zip | |
update to trunk
(bzr r11950.1.127)
Diffstat (limited to 'src/style.cpp')
| -rw-r--r-- | src/style.cpp | 110 |
1 files changed, 91 insertions, 19 deletions
diff --git a/src/style.cpp b/src/style.cpp index 479f30597..4a808fac6 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -45,7 +45,7 @@ #include "svg/css-ostringstream.h" #include "xml/repr.h" #include "xml/simple-document.h" -#include "unit-constants.h" +#include "util/units.h" #include "macros.h" #include "preferences.h" @@ -2483,11 +2483,11 @@ sp_style_css_size_px_to_units(double size, int unit) case SP_CSS_UNIT_NONE: unit_size = size; break; case SP_CSS_UNIT_PX: unit_size = size; break; - case SP_CSS_UNIT_PT: unit_size = size * PT_PER_PX; break; - case SP_CSS_UNIT_PC: unit_size = size * (PT_PER_PX / PT_PER_PC); break; - case SP_CSS_UNIT_MM: unit_size = size * MM_PER_PX; break; - case SP_CSS_UNIT_CM: unit_size = size * CM_PER_PX; break; - case SP_CSS_UNIT_IN: unit_size = size * IN_PER_PX; break; + case SP_CSS_UNIT_PT: unit_size = size * Inkscape::Util::Quantity::convert(1, "px", "pt"); break; + case SP_CSS_UNIT_PC: unit_size = size * (Inkscape::Util::Quantity::convert(1, "px", "pt") / Inkscape::Util::Quantity::convert(1, "pc", "pt")); break; + case SP_CSS_UNIT_MM: unit_size = size * Inkscape::Util::Quantity::convert(1, "px", "mm"); break; + case SP_CSS_UNIT_CM: unit_size = size * Inkscape::Util::Quantity::convert(1, "px", "cm"); break; + case SP_CSS_UNIT_IN: unit_size = size * Inkscape::Util::Quantity::convert(1, "px", "in"); break; case SP_CSS_UNIT_EM: unit_size = size / SP_CSS_FONT_SIZE_DEFAULT; break; case SP_CSS_UNIT_EX: unit_size = size * 2.0 / SP_CSS_FONT_SIZE_DEFAULT ; break; case SP_CSS_UNIT_PERCENT: unit_size = size * 100.0 / SP_CSS_FONT_SIZE_DEFAULT; break; @@ -2945,14 +2945,19 @@ sp_style_clear(SPStyle *style) style->stroke.clear(); sp_style_filter_clear(style); + style->release_connection.disconnect(); + + style->fill_ps_modified_connection.disconnect(); if (style->fill.value.href) { delete style->fill.value.href; style->fill.value.href = NULL; } + style->stroke_ps_modified_connection.disconnect(); if (style->stroke.value.href) { delete style->stroke.value.href; style->stroke.value.href = NULL; } + style->filter_modified_connection.disconnect(); if (style->filter.href) { delete style->filter.href; style->filter.href = NULL; @@ -2972,7 +2977,6 @@ sp_style_clear(SPStyle *style) SPTextStyle *text = style->text; unsigned const text_private = style->text_private; - memset(style, 0, sizeof(SPStyle)); style->refcount = refcount; style->object = object; @@ -2997,49 +3001,63 @@ sp_style_clear(SPStyle *style) style->text->font_family.set = FALSE; style->font_size.set = FALSE; + style->font_size.inherit = FALSE; style->font_size.type = SP_FONT_SIZE_LITERAL; + style->font_size.unit = 0; style->font_size.literal = SP_CSS_FONT_SIZE_MEDIUM; + style->font_size.value = 12.0; style->font_size.computed = 12.0; style->font_style.set = FALSE; + style->font_style.inherit = FALSE; style->font_style.value = style->font_style.computed = SP_CSS_FONT_STYLE_NORMAL; style->font_variant.set = FALSE; + style->font_variant.inherit = FALSE; style->font_variant.value = style->font_variant.computed = SP_CSS_FONT_VARIANT_NORMAL; style->font_weight.set = FALSE; + style->font_weight.inherit = FALSE; style->font_weight.value = SP_CSS_FONT_WEIGHT_NORMAL; style->font_weight.computed = SP_CSS_FONT_WEIGHT_400; style->font_stretch.set = FALSE; + style->font_stretch.inherit = FALSE; style->font_stretch.value = style->font_stretch.computed = SP_CSS_FONT_STRETCH_NORMAL; /* text */ style->text_indent.set = FALSE; + style->text_indent.inherit = FALSE; style->text_indent.unit = SP_CSS_UNIT_NONE; style->text_indent.computed = 0.0; style->text_align.set = FALSE; + style->text_align.inherit = FALSE; style->text_align.value = style->text_align.computed = SP_CSS_TEXT_ALIGN_START; style->text_decoration.set = FALSE; + style->text_decoration.inherit = FALSE; style->text_decoration.underline = FALSE; style->text_decoration.overline = FALSE; style->text_decoration.line_through = FALSE; style->text_decoration.blink = FALSE; style->line_height.set = FALSE; + style->line_height.inherit = FALSE; style->line_height.unit = SP_CSS_UNIT_PERCENT; style->line_height.normal = TRUE; style->line_height.value = style->line_height.computed = 1.0; style->letter_spacing.set = FALSE; + style->letter_spacing.inherit = FALSE; style->letter_spacing.unit = SP_CSS_UNIT_NONE; style->letter_spacing.normal = TRUE; style->letter_spacing.value = style->letter_spacing.computed = 0.0; style->word_spacing.set = FALSE; + style->word_spacing.inherit = FALSE; style->word_spacing.unit = SP_CSS_UNIT_NONE; style->word_spacing.normal = TRUE; style->word_spacing.value = style->word_spacing.computed = 0.0; style->baseline_shift.set = FALSE; + style->baseline_shift.inherit = FALSE; style->baseline_shift.type = SP_BASELINE_SHIFT_LITERAL; style->baseline_shift.unit = SP_CSS_UNIT_NONE; style->baseline_shift.literal = SP_CSS_BASELINE_SHIFT_BASELINE; @@ -3047,74 +3065,128 @@ sp_style_clear(SPStyle *style) style->baseline_shift.computed = 0.0; style->text_transform.set = FALSE; + style->text_transform.inherit = FALSE; style->text_transform.value = style->text_transform.computed = SP_CSS_TEXT_TRANSFORM_NONE; style->direction.set = FALSE; + style->direction.inherit = FALSE; style->direction.value = style->direction.computed = SP_CSS_DIRECTION_LTR; style->block_progression.set = FALSE; + style->block_progression.inherit = FALSE; style->block_progression.value = style->block_progression.computed = SP_CSS_BLOCK_PROGRESSION_TB; style->writing_mode.set = FALSE; + style->writing_mode.inherit = FALSE; style->writing_mode.value = style->writing_mode.computed = SP_CSS_WRITING_MODE_LR_TB; style->text_anchor.set = FALSE; + style->text_anchor.inherit = FALSE; style->text_anchor.value = style->text_anchor.computed = SP_CSS_TEXT_ANCHOR_START; + style->clip_set = FALSE; + style->color_set = FALSE; + style->cursor_set = FALSE; + style->overflow_set = FALSE; + style->clip_path_set = FALSE; + style->mask_set = FALSE; + + style->clip_rule.set = FALSE; + style->clip_rule.inherit = FALSE; + style->clip_rule.value = style->clip_rule.computed = SP_WIND_RULE_NONZERO; + style->opacity.set = FALSE; + style->opacity.inherit = FALSE; style->opacity.value = SP_SCALE24_MAX; style->visibility.set = FALSE; + style->visibility.inherit = FALSE; style->visibility.value = style->visibility.computed = SP_CSS_VISIBILITY_VISIBLE; style->display.set = FALSE; + style->display.inherit = FALSE; style->display.value = style->display.computed = SP_CSS_DISPLAY_INLINE; style->overflow.set = FALSE; + style->overflow.inherit = FALSE; style->overflow.value = style->overflow.computed = SP_CSS_OVERFLOW_VISIBLE; style->color.clear(); style->color.setColor(0.0, 0.0, 0.0); + style->color_interpolation.set = FALSE; + style->color_interpolation.inherit = FALSE; style->color_interpolation.value = style->color_interpolation.computed = SP_CSS_COLOR_INTERPOLATION_SRGB; + style->color_interpolation_filters.set = FALSE; + style->color_interpolation_filters.inherit = FALSE; style->color_interpolation_filters.value = style->color_interpolation_filters.computed = SP_CSS_COLOR_INTERPOLATION_LINEARRGB; style->fill.clear(); style->fill.setColor(0.0, 0.0, 0.0); + style->fill_opacity.set = FALSE; + style->fill_opacity.inherit = FALSE; style->fill_opacity.value = SP_SCALE24_MAX; + style->fill_rule.set = FALSE; + style->fill_rule.inherit = FALSE; style->fill_rule.value = style->fill_rule.computed = SP_WIND_RULE_NONZERO; style->stroke.clear(); + style->stroke_opacity.set = FALSE; + style->stroke_opacity.inherit = FALSE; style->stroke_opacity.value = SP_SCALE24_MAX; style->stroke_width.set = FALSE; + style->stroke_width.inherit = FALSE; style->stroke_width.unit = SP_CSS_UNIT_NONE; - style->stroke_width.computed = 1.0; + style->stroke_width.value = style->stroke_width.computed = 1.0; style->stroke_linecap.set = FALSE; + style->stroke_linecap.inherit = FALSE; style->stroke_linecap.value = style->stroke_linecap.computed = SP_STROKE_LINECAP_BUTT; style->stroke_linejoin.set = FALSE; + style->stroke_linejoin.inherit = FALSE; style->stroke_linejoin.value = style->stroke_linejoin.computed = SP_STROKE_LINEJOIN_MITER; style->stroke_miterlimit.set = FALSE; + style->stroke_miterlimit.inherit = FALSE; style->stroke_miterlimit.value = 4.0; style->stroke_dash.n_dash = 0; style->stroke_dash.dash = NULL; style->stroke_dash.offset = 0.0; + style->stroke_dasharray_set = FALSE; + style->stroke_dasharray_inherit = FALSE; + style->stroke_dashoffset_set = FALSE; + style->stroke_dashoffset_inherit = FALSE; + for (unsigned i = SP_MARKER_LOC; i < SP_MARKER_LOC_QTY; i++) { g_free(style->marker[i].value); style->marker[i].set = FALSE; + style->marker[i].inherit = FALSE; + style->marker[i].data = 0; + style->marker[i].value = NULL; } + style->filter.set = FALSE; + style->filter.inherit = FALSE; + style->filter.href = NULL; + style->enable_background.value = SP_CSS_BACKGROUND_ACCUMULATE; style->enable_background.set = false; style->enable_background.inherit = false; - style->clip_rule.value = style->clip_rule.computed = SP_WIND_RULE_NONZERO; + style->filter_blend_mode.set = style->filter_blend_mode.inherit = false; + style->filter_blend_mode.value = style->filter_blend_mode.computed = 0; + style->filter_gaussianBlur_deviation.set = style->filter_gaussianBlur_deviation.inherit = false; + style->filter_gaussianBlur_deviation.value = style->filter_gaussianBlur_deviation.computed = 0; + style->color_rendering.set = style->color_rendering.inherit = false; style->color_rendering.value = style->color_rendering.computed = SP_CSS_COLOR_RENDERING_AUTO; + style->image_rendering.set = style->image_rendering.inherit = false; style->image_rendering.value = style->image_rendering.computed = SP_CSS_IMAGE_RENDERING_AUTO; + style->shape_rendering.set = style->shape_rendering.inherit = false; style->shape_rendering.value = style->shape_rendering.computed = SP_CSS_SHAPE_RENDERING_AUTO; + style->text_rendering.set = style->text_rendering.inherit = false; style->text_rendering.value = style->text_rendering.computed = SP_CSS_TEXT_RENDERING_AUTO; + style->cloned = false; } @@ -3400,19 +3472,19 @@ sp_style_read_ilength(SPILength *val, gchar const *str) } else if (!strcmp(e, "pt")) { /* Userspace / DEVICESCALE */ val->unit = SP_CSS_UNIT_PT; - val->computed = value * PX_PER_PT; + val->computed = value * Inkscape::Util::Quantity::convert(1, "pt", "px"); } else if (!strcmp(e, "pc")) { val->unit = SP_CSS_UNIT_PC; - val->computed = value * PX_PER_PC; + val->computed = value * Inkscape::Util::Quantity::convert(1, "pc", "px"); } else if (!strcmp(e, "mm")) { val->unit = SP_CSS_UNIT_MM; - val->computed = value * PX_PER_MM; + val->computed = value * Inkscape::Util::Quantity::convert(1, "mm", "px"); } else if (!strcmp(e, "cm")) { val->unit = SP_CSS_UNIT_CM; - val->computed = value * PX_PER_CM; + val->computed = value * Inkscape::Util::Quantity::convert(1, "cm", "px"); } else if (!strcmp(e, "in")) { val->unit = SP_CSS_UNIT_IN; - val->computed = value * PX_PER_IN; + val->computed = value * Inkscape::Util::Quantity::convert(1, "in", "px"); } else if (!strcmp(e, "em")) { /* EM square */ val->unit = SP_CSS_UNIT_EM; @@ -3971,23 +4043,23 @@ sp_style_write_ilength(gchar *p, gint const len, gchar const *const key, return g_strlcpy(p, os.str().c_str(), len); break; case SP_CSS_UNIT_PT: - os << key << ":" << val->computed * PT_PER_PX << "pt;"; + os << key << ":" << val->computed * Inkscape::Util::Quantity::convert(1, "px", "pt") << "pt;"; return g_strlcpy(p, os.str().c_str(), len); break; case SP_CSS_UNIT_PC: - os << key << ":" << val->computed * PT_PER_PX / 12.0 << "pc;"; + os << key << ":" << val->computed * Inkscape::Util::Quantity::convert(1, "px", "pt") / 12.0 << "pc;"; return g_strlcpy(p, os.str().c_str(), len); break; case SP_CSS_UNIT_MM: - os << key << ":" << val->computed * MM_PER_PX << "mm;"; + os << key << ":" << val->computed * Inkscape::Util::Quantity::convert(1, "px", "mm") << "mm;"; return g_strlcpy(p, os.str().c_str(), len); break; case SP_CSS_UNIT_CM: - os << key << ":" << val->computed * CM_PER_PX << "cm;"; + os << key << ":" << val->computed * Inkscape::Util::Quantity::convert(1, "px", "cm") << "cm;"; return g_strlcpy(p, os.str().c_str(), len); break; case SP_CSS_UNIT_IN: - os << key << ":" << val->computed * IN_PER_PX << "in;"; + os << key << ":" << val->computed * Inkscape::Util::Quantity::convert(1, "px", "in") << "in;"; return g_strlcpy(p, os.str().c_str(), len); break; case SP_CSS_UNIT_EM: |
