diff --git a/src/sp-item.cpp b/src/sp-item.cpp
index ab241a0cde9f32b7c0f4fe997992fadd74918548..469b95222cba39a74e921de55a31113367bae5a6 100644 (file)
--- a/src/sp-item.cpp
+++ b/src/sp-item.cpp
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
+ * Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
*
- * Copyright (C) 2001-2005 authors
+ * Copyright (C) 2001-2006 authors
* Copyright (C) 2001 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
#endif
-
+#include "sp-item.h"
#include "svg/svg.h"
#include "print.h"
#include "display/nr-arena.h"
#include "sp-text.h"
#include "sp-item-rm-unsatisfied-cns.h"
#include "sp-pattern.h"
+#include "sp-switch.h"
#include "gradient-chemistry.h"
#include "prefs-utils.h"
#include "conn-avoid-ref.h"
+#include "conditions.h"
+#include "sp-filter-reference.h"
#include "libnr/nr-matrix-div.h"
#include "libnr/nr-matrix-fns.h"
#include "util/reverse-list.h"
#include "xml/repr.h"
+#include "extract-uri.h"
#define noSP_ITEM_DEBUG_IDLE
static void
sp_item_init(SPItem *item)
{
- SPObject *object = SP_OBJECT(item);
+ item->init();
+}
- item->sensitive = TRUE;
+void SPItem::init() {
+ this->sensitive = TRUE;
- item->transform_center_x = 0;
- item->transform_center_y = 0;
+ this->transform_center_x = 0;
+ this->transform_center_y = 0;
- item->transform = NR::identity();
+ this->_is_evaluated = true;
+ this->_evaluated_status = StatusUnknown;
- item->display = NULL;
+ this->transform = NR::identity();
- item->clip_ref = new SPClipPathReference(SP_OBJECT(item));
- {
- sigc::signal<void, SPObject *, SPObject *> cs1=item->clip_ref->changedSignal();
- sigc::slot2<void,SPObject*, SPObject *> sl1=sigc::bind(sigc::ptr_fun(clip_ref_changed), item);
- cs1.connect(sl1);
- }
+ this->display = NULL;
- item->mask_ref = new SPMaskReference(SP_OBJECT(item));
- sigc::signal<void, SPObject *, SPObject *> cs2=item->mask_ref->changedSignal();
- sigc::slot2<void,SPObject*, SPObject *> sl2=sigc::bind(sigc::ptr_fun(mask_ref_changed), item);
- cs2.connect(sl2);
+ this->clip_ref = new SPClipPathReference(this);
+ sigc::signal<void, SPObject *, SPObject *> cs1=this->clip_ref->changedSignal();
+ sigc::slot2<void,SPObject*, SPObject *> sl1=sigc::bind(sigc::ptr_fun(clip_ref_changed), this);
+ _clip_ref_connection = cs1.connect(sl1);
- if (!object->style) object->style = sp_style_new_from_object(SP_OBJECT(item));
+ this->mask_ref = new SPMaskReference(this);
+ sigc::signal<void, SPObject *, SPObject *> cs2=this->mask_ref->changedSignal();
+ sigc::slot2<void,SPObject*, SPObject *> sl2=sigc::bind(sigc::ptr_fun(mask_ref_changed), this);
+ _mask_ref_connection = cs2.connect(sl2);
- item->avoidRef = new SPAvoidRef(item);
+ this->avoidRef = new SPAvoidRef(this);
- new (&item->_transformed_signal) sigc::signal<void, NR::Matrix const *, SPItem *>();
+ new (&this->_transformed_signal) sigc::signal<void, NR::Matrix const *, SPItem *>();
}
bool SPItem::isVisibleAndUnlocked() const {
}
bool SPItem::isHidden() const {
+ if (!isEvaluated())
+ return true;
return style->display.computed == SP_CSS_DISPLAY_NONE;
}
}
bool SPItem::isHidden(unsigned display_key) const {
+ if (!isEvaluated())
+ return true;
for ( SPItemView *view(display) ; view ; view = view->next ) {
if ( view->key == display_key ) {
g_assert(view->arenaitem != NULL);
return true;
}
+void SPItem::setEvaluated(bool evaluated) {
+ _is_evaluated = evaluated;
+ _evaluated_status = StatusSet;
+}
+
+void SPItem::resetEvaluated() {
+ if ( StatusCalculated == _evaluated_status ) {
+ _evaluated_status = StatusUnknown;
+ bool oldValue = _is_evaluated;
+ if ( oldValue != isEvaluated() ) {
+ requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
+ }
+ } if ( StatusSet == _evaluated_status ) {
+ SPObject const *const parent = SP_OBJECT_PARENT(this);
+ if (SP_IS_SWITCH(parent)) {
+ SP_SWITCH(parent)->resetChildEvaluated();
+ }
+ }
+}
+
+bool SPItem::isEvaluated() const {
+ if ( StatusUnknown == _evaluated_status ) {
+ _is_evaluated = sp_item_evaluate(this);
+ _evaluated_status = StatusCalculated;
+ }
+ return _is_evaluated;
+}
+
/**
* Returns something suitable for the `Hide' checkbox in the Object Properties dialog box.
* Corresponds to setExplicitlyHidden.
*/
void
SPItem::setCenter(NR::Point object_centre) {
- NR::Rect bbox = invokeBbox(sp_item_i2d_affine(this));
- if (!bbox.isEmpty()) {
- transform_center_x = object_centre[NR::X] - bbox.midpoint()[NR::X];
+ NR::Maybe<NR::Rect> bbox = getBounds(sp_item_i2d_affine(this));
+ if (bbox) {
+ transform_center_x = object_centre[NR::X] - bbox->midpoint()[NR::X];
if (fabs(transform_center_x) < 1e-5) // rounding error
transform_center_x = 0;
- transform_center_y = object_centre[NR::Y] - bbox.midpoint()[NR::Y];
+ transform_center_y = object_centre[NR::Y] - bbox->midpoint()[NR::Y];
if (fabs(transform_center_y) < 1e-5) // rounding error
transform_center_y = 0;
}
return (transform_center_x != 0 || transform_center_y != 0);
}
-NR::Point SPItem::getCenter() {
- NR::Rect bbox = invokeBbox(sp_item_i2d_affine(this));
- if (!bbox.isEmpty()) {
- return bbox.midpoint() + NR::Point (this->transform_center_x, this->transform_center_y);
+NR::Point SPItem::getCenter() const {
+ NR::Maybe<NR::Rect> bbox = getBounds(sp_item_i2d_affine(this));
+ if (bbox) {
+ return bbox->midpoint() + NR::Point (this->transform_center_x, this->transform_center_y);
} else {
return NR::Point (0, 0); // something's wrong!
}
{
SPItem *item = (SPItem *) object;
+ item->_clip_ref_connection.disconnect();
+ item->_mask_ref_connection.disconnect();
+
if (item->clip_ref) {
item->clip_ref->detach();
delete item->clip_ref;
break;
}
case SP_PROP_CLIP_PATH: {
- gchar *uri = Inkscape::parse_css_url(value);
+ gchar *uri = extract_uri(value);
if (uri) {
try {
item->clip_ref->attach(Inkscape::URI(uri));
break;
}
case SP_PROP_MASK: {
- gchar *uri=Inkscape::parse_css_url(value);
+ gchar *uri = extract_uri(value);
if (uri) {
try {
item->mask_ref->attach(Inkscape::URI(uri));
nr_arena_item_set_sensitive(v->arenaitem, item->sensitive);
}
break;
- case SP_ATTR_STYLE:
- sp_style_read_from_object(object->style, object);
- object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
- break;
case SP_ATTR_CONNECTOR_AVOID:
item->avoidRef->setAvoid(value);
break;
} else {
item->transform_center_x = 0;
}
+ object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_TRANSFORM_CENTER_Y:
if (value) {
} else {
item->transform_center_y = 0;
}
+ object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
break;
+ case SP_PROP_SYSTEM_LANGUAGE:
+ case SP_PROP_REQUIRED_FEATURES:
+ case SP_PROP_REQUIRED_EXTENSIONS:
+ {
+ item->resetEvaluated();
+ // pass to default handler
+ }
default:
if (SP_ATTRIBUTE_IS_CSS(key)) {
sp_style_read_from_object(object->style, object);
nr_arena_item_set_mask(v->arenaitem, ai);
nr_arena_item_unref(ai);
sp_mask_set_bbox(SP_MASK(mask), NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox);
+ SP_OBJECT(mask)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
}
}
{
SPItem *item = SP_ITEM(object);
- gchar c[256];
- if (sp_svg_transform_write(c, 256, item->transform)) {
- repr->setAttribute("transform", c);
- } else {
- repr->setAttribute("transform", NULL);
- }
-
- SPObject const *const parent = SP_OBJECT_PARENT(object);
- /** \todo Can someone please document why this is conditional on having
- * a parent? The only parentless thing I can think of is the top-level
- * <svg> element (SPRoot). SPRoot is derived from SPGroup, and can have
- * style. I haven't looked at callers.
- */
- if (parent) {
- SPStyle const *const obj_style = SP_OBJECT_STYLE(object);
- if (obj_style) {
- gchar *s = sp_style_write_string(obj_style, SP_STYLE_FLAG_IFSET);
- repr->setAttribute("style", ( *s ? s : NULL ));
- g_free(s);
- } else {
- /** \todo I'm not sure what to do in this case. Bug #1165868
- * suggests that it can arise, but the submitter doesn't know
- * how to do so reliably. The main two options are either
- * leave repr's style attribute unchanged, or explicitly clear it.
- * Must also consider what to do with property attributes for
- * the element; see below.
- */
- char const *style_str = repr->attribute("style");
- if (!style_str) {
- style_str = "NULL";
- }
- g_warning("Item's style is NULL; repr style attribute is %s", style_str);
- }
-
- /** \note We treat object->style as authoritative. Its effects have
- * been written to the style attribute above; any properties that are
- * unset we take to be deliberately unset (e.g. so that clones can
- * override the property).
- *
- * Note that the below has an undesirable consequence of changing the
- * appearance on renderers that lack CSS support (e.g. SVG tiny);
- * possibly we should write property attributes instead of a style
- * attribute.
- */
- sp_style_unset_property_attrs (object);
- }
+ gchar *c = sp_svg_transform_write(item->transform);
+ repr->setAttribute("transform", c);
+ g_free(c);
if (flags & SP_OBJECT_WRITE_EXT) {
repr->setAttribute("sodipodi:insensitive", ( item->sensitive ? NULL : "true" ));
if (item->transform_center_x != 0)
sp_repr_set_svg_double (repr, "inkscape:transform-center-x", item->transform_center_x);
- else
+ else
repr->setAttribute ("inkscape:transform-center-x", NULL);
if (item->transform_center_y != 0)
sp_repr_set_svg_double (repr, "inkscape:transform-center-y", item->transform_center_y);
- else
- repr->setAttribute ("inkscape:transform-center-y", NULL);
+ else
+ repr->setAttribute ("inkscape:transform-center-y", NULL);
+ }
+
+ if (item->clip_ref->getObject()) {
+ const gchar *value = g_strdup_printf ("url(%s)", item->clip_ref->getURI()->toString());
+ repr->setAttribute ("clip-path", value);
+ g_free ((void *) value);
+ }
+ if (item->mask_ref->getObject()) {
+ const gchar *value = g_strdup_printf ("url(%s)", item->mask_ref->getURI()->toString());
+ repr->setAttribute ("mask", value);
+ g_free ((void *) value);
}
if (((SPObjectClass *) (parent_class))->write) {
return repr;
}
-NR::Rect SPItem::invokeBbox(NR::Matrix const &transform) const
+NR::Maybe<NR::Rect> SPItem::getBounds(NR::Matrix const &transform,
+ SPItem::BBoxType type,
+ unsigned int dkey) const
{
NRRect r;
- sp_item_invoke_bbox_full(this, &r, transform, 0, TRUE);
- return NR::Rect(r);
+ sp_item_invoke_bbox_full(this, &r, transform, type, TRUE);
+ return r;
}
void
-sp_item_invoke_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const clear)
+sp_item_invoke_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const clear, SPItem::BBoxType type)
{
- sp_item_invoke_bbox_full(item, bbox, transform, 0, clear);
+ sp_item_invoke_bbox_full(item, bbox, transform, type, clear);
}
+/** Calls \a item's subclass' bounding box method; clips it by the bbox of clippath, if any; and
+ * unions the resulting bbox with \a bbox. If \a clear is true, empties \a bbox first. Passes the
+ * transform and the flags to the actual bbox methods. Note that many of subclasses (e.g. groups,
+ * clones), in turn, call this function in their bbox methods. */
void
sp_item_invoke_bbox_full(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags, unsigned const clear)
{
@@ -676,15 +697,25 @@ sp_item_invoke_bbox_full(SPItem const *item, NRRect *bbox, NR::Matrix const &tra
bbox->x1 = bbox->y1 = -1e18;
}
+ NRRect this_bbox;
+ this_bbox.x0 = this_bbox.y0 = 1e18;
+ this_bbox.x1 = this_bbox.y1 = -1e18;
+
+ // call the subclass method
if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox) {
- ((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox(item, bbox, transform, flags);
+ ((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox(item, &this_bbox, transform, flags);
}
- // crop the bbox by clip path, if any
- if (item->clip_ref->getObject()) {
+ // unless this is geometric bbox, crop the bbox by clip path, if any
+ if ((SPItem::BBoxType) flags != SPItem::GEOMETRIC_BBOX && item->clip_ref->getObject()) {
NRRect b;
sp_clippath_get_bbox(SP_CLIPPATH(item->clip_ref->getObject()), &b, transform, flags);
- nr_rect_d_intersect (bbox, bbox, &b);
+ nr_rect_d_intersect (&this_bbox, &this_bbox, &b);
+ }
+
+ // if non-empty (with some tolerance - ?) union this_bbox with the bbox we've got passed
+ if ( fabs(this_bbox.x1-this_bbox.x0) > -0.00001 && fabs(this_bbox.y1-this_bbox.y0) > -0.00001 ) {
+ nr_rect_d_union (bbox, bbox, &this_bbox);
}
}
}
void
-sp_item_bbox_desktop(SPItem *item, NRRect *bbox)
+sp_item_bbox_desktop(SPItem *item, NRRect *bbox, SPItem::BBoxType type)
{
g_assert(item != NULL);
g_assert(SP_IS_ITEM(item));
g_assert(bbox != NULL);
- sp_item_invoke_bbox(item, bbox, sp_item_i2d_affine(item), TRUE);
+ sp_item_invoke_bbox(item, bbox, sp_item_i2d_affine(item), TRUE, type);
}
-NR::Rect sp_item_bbox_desktop(SPItem *item)
+NR::Maybe<NR::Rect> sp_item_bbox_desktop(SPItem *item, SPItem::BBoxType type)
{
NRRect ret;
- sp_item_bbox_desktop(item, &ret);
- return NR::Rect(ret);
+ sp_item_invoke_bbox(item, &ret, sp_item_i2d_affine(item), TRUE, type);
+ return ret.upgrade();
}
static void sp_item_private_snappoints(SPItem const *item, SnapPointsIter p)
{
- NR::Rect const bbox = item->invokeBbox(sp_item_i2d_affine(item));
- /* Just a pair of opposite corners of the bounding box suffices given that we don't yet
+ NR::Maybe<NR::Rect> bbox = item->getBounds(sp_item_i2d_affine(item));
+ /* Just the corners of the bounding box suffices given that we don't yet
support angled guide lines. */
- *p = bbox.min();
- *p = bbox.max();
+ if (bbox) {
+ NR::Point p1, p2;
+ p1 = bbox->min();
+ p2 = bbox->max();
+ *p = p1;
+ *p = NR::Point(p1[NR::X], p2[NR::Y]);
+ *p = p2;
+ *p = NR::Point(p1[NR::Y], p2[NR::X]);
+ }
}
void sp_item_snappoints(SPItem const *item, SnapPointsIter p)
if (item_class.snappoints) {
item_class.snappoints(item, p);
}
+
+ *p = item->getCenter();
}
void
g_assert(SP_IS_ITEM(item));
if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->description) {
- return ((SPItemClass *) G_OBJECT_GET_CLASS(item))->description(item);
+ gchar *s = ((SPItemClass *) G_OBJECT_GET_CLASS(item))->description(item);
+ if (s && item->clip_ref->getObject()) {
+ gchar *snew = g_strdup_printf (_("%s; <i>clipped</i>"), s);
+ g_free (s);
+ s = snew;
+ }
+ if (s && item->mask_ref->getObject()) {
+ gchar *snew = g_strdup_printf (_("%s; <i>masked</i>"), s);
+ g_free (s);
+ s = snew;
+ }
+ return s;
}
g_assert_not_reached();
@@ -830,18 +881,42 @@ sp_item_invoke_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags)
nr_arena_item_set_visible(ai, !item->isHidden());
nr_arena_item_set_sensitive(ai, item->sensitive);
if (item->clip_ref->getObject()) {
- NRArenaItem *ac;
- if (!item->display->arenaitem->key) NR_ARENA_ITEM_SET_KEY(item->display->arenaitem, sp_item_display_key_new(3));
- ac = sp_clippath_show(item->clip_ref->getObject(), arena, NR_ARENA_ITEM_GET_KEY(item->display->arenaitem));
+ SPClipPath *cp = item->clip_ref->getObject();
+
+ if (!item->display->arenaitem->key) {
+ NR_ARENA_ITEM_SET_KEY(item->display->arenaitem, sp_item_display_key_new(3));
+ }
+ int clip_key = NR_ARENA_ITEM_GET_KEY(item->display->arenaitem);
+
+ // Show and set clip
+ NRArenaItem *ac = sp_clippath_show(cp, arena, clip_key);
nr_arena_item_set_clip(ai, ac);
nr_arena_item_unref(ac);
+
+ // Update bbox, in case the clip uses bbox units
+ NRRect bbox;
+ sp_item_invoke_bbox(item, &bbox, NR::identity(), TRUE);
+ sp_clippath_set_bbox(SP_CLIPPATH(cp), clip_key, &bbox);
+ SP_OBJECT(cp)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
if (item->mask_ref->getObject()) {
- NRArenaItem *ac;
- if (!item->display->arenaitem->key) NR_ARENA_ITEM_SET_KEY(item->display->arenaitem, sp_item_display_key_new(3));
- ac = sp_mask_show(item->mask_ref->getObject(), arena, NR_ARENA_ITEM_GET_KEY(item->display->arenaitem));
+ SPMask *mask = item->mask_ref->getObject();
+
+ if (!item->display->arenaitem->key) {
+ NR_ARENA_ITEM_SET_KEY(item->display->arenaitem, sp_item_display_key_new(3));
+ }
+ int mask_key = NR_ARENA_ITEM_GET_KEY(item->display->arenaitem);
+
+ // Show and set mask
+ NRArenaItem *ac = sp_mask_show(mask, arena, mask_key);
nr_arena_item_set_mask(ai, ac);
nr_arena_item_unref(ac);
+
+ // Update bbox, in case the mask uses bbox units
+ NRRect bbox;
+ sp_item_invoke_bbox(item, &bbox, NR::identity(), TRUE);
+ sp_mask_set_bbox(SP_MASK(mask), mask_key, &bbox);
+ SP_OBJECT(mask)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
NR_ARENA_ITEM_SET_DATA(ai, item);
}
{
sp_item_adjust_stroke (item, expansion);
+// A clone's child is the ghost of its original - we must not touch it, skip recursion
+ if (item && SP_IS_USE(item))
+ return;
+
for (SPObject *o = SP_OBJECT(item)->children; o != NULL; o = o->next) {
if (SP_IS_ITEM(o))
sp_item_adjust_stroke_width_recursive(SP_ITEM(o), expansion);
@@ -1022,32 +1101,35 @@ sp_item_adjust_rects_recursive(SPItem *item, NR::Matrix advertized_transform)
void
sp_item_adjust_paint_recursive (SPItem *item, NR::Matrix advertized_transform, NR::Matrix t_ancestors, bool is_pattern)
{
-// A clone must not touch the style (it's that of its parent!) and has no children, so quit now
- if (item && SP_IS_USE(item))
- return;
-
// _Before_ full pattern/gradient transform: t_paint * t_item * t_ancestors
// _After_ full pattern/gradient transform: t_paint_new * t_item * t_ancestors * advertised_transform
// By equating these two expressions we get t_paint_new = t_paint * paint_delta, where:
NR::Matrix t_item = sp_item_transform_repr (item);
NR::Matrix paint_delta = t_item * t_ancestors * advertized_transform * t_ancestors.inverse() * t_item.inverse();
+// Within text, we do not fork gradients, and so must not recurse to avoid double compensation;
+// also we do not recurse into clones, because a clone's child is the ghost of its original -
+// we must not touch it
+ if (!(item && (SP_IS_TEXT(item) || SP_IS_USE(item)))) {
+ for (SPObject *o = SP_OBJECT(item)->children; o != NULL; o = o->next) {
+ if (SP_IS_ITEM(o)) {
+// At the level of the transformed item, t_ancestors is identity;
+// below it, it is the accmmulated chain of transforms from this level to the top level
+ sp_item_adjust_paint_recursive (SP_ITEM(o), advertized_transform, t_item * t_ancestors, is_pattern);
+ }
+ }
+ }
+
+// We recursed into children first, and are now adjusting this object second;
+// this is so that adjustments in a tree are done from leaves up to the root,
+// and paintservers on leaves inheriting their values from ancestors could adjust themselves properly
+// before ancestors themselves are adjusted, probably differently (bug 1286535)
+
if (is_pattern)
sp_item_adjust_pattern (item, paint_delta);
else
sp_item_adjust_gradient (item, paint_delta);
-// Within text, we do not fork gradients, and so must not recurse to avoid double compensation
- if (item && SP_IS_TEXT(item))
- return;
-
- for (SPObject *o = SP_OBJECT(item)->children; o != NULL; o = o->next) {
- if (SP_IS_ITEM(o)) {
-// At the level of the transformed item, t_ancestors is identity;
-// below it, it is the accmmulated chain of transforms from this level to the top level
- sp_item_adjust_paint_recursive (SP_ITEM(o), advertized_transform, t_item * t_ancestors, is_pattern);
- }
- }
}
/**
@@ -1072,7 +1154,7 @@ sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NRMatrix const
* the repr is updated with the new transform.
*/
void
-sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NR::Matrix const &transform, NR::Matrix const *adv)
+sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NR::Matrix const &transform, NR::Matrix const *adv, bool compensate)
{
g_return_if_fail(item != NULL);
g_return_if_fail(SP_IS_ITEM(item));
@@ -1085,36 +1167,46 @@ sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NR::Matrix cons
} else {
advertized_transform = sp_item_transform_repr (item).inverse() * transform;
}
+
+ if (compensate) {
+
+ // recursively compensate for stroke scaling, depending on user preference
+ if (prefs_get_int_attribute("options.transform", "stroke", 1) == 0) {
+ double const expansion = 1. / NR::expansion(advertized_transform);
+ sp_item_adjust_stroke_width_recursive(item, expansion);
+ }
+
+ // recursively compensate rx/ry of a rect if requested
+ if (prefs_get_int_attribute("options.transform", "rectcorners", 1) == 0) {
+ sp_item_adjust_rects_recursive(item, advertized_transform);
+ }
+
+ // recursively compensate pattern fill if it's not to be transformed
+ if (prefs_get_int_attribute("options.transform", "pattern", 1) == 0) {
+ sp_item_adjust_paint_recursive (item, advertized_transform.inverse(), NR::identity(), true);
+ }
+ /// \todo FIXME: add the same else branch as for gradients below, to convert patterns to userSpaceOnUse as well
+ /// recursively compensate gradient fill if it's not to be transformed
+ if (prefs_get_int_attribute("options.transform", "gradient", 1) == 0) {
+ sp_item_adjust_paint_recursive (item, advertized_transform.inverse(), NR::identity(), false);
+ } else {
+ // this converts the gradient/pattern fill/stroke, if any, to userSpaceOnUse; we need to do
+ // it here _before_ the new transform is set, so as to use the pre-transform bbox
+ sp_item_adjust_paint_recursive (item, NR::identity(), NR::identity(), false);
+ }
+
+ } // endif(compensate)
- // recursively compensate for stroke scaling, depending on user preference
- if (prefs_get_int_attribute("options.transform", "stroke", 1) == 0) {
- double const expansion = 1. / NR::expansion(advertized_transform);
- sp_item_adjust_stroke_width_recursive(item, expansion);
- }
-
- // recursively compensate rx/ry of a rect if requested
- if (prefs_get_int_attribute("options.transform", "rectcorners", 1) == 0) {
- sp_item_adjust_rects_recursive(item, advertized_transform);
- }
-
- // recursively compensate pattern fill if it's not to be transformed
- if (prefs_get_int_attribute("options.transform", "pattern", 1) == 0) {
- sp_item_adjust_paint_recursive (item, advertized_transform.inverse(), NR::identity(), true);
- }
- /// \todo FIXME: add the same else branch as for gradients below, to convert patterns to userSpaceOnUse as well
- /// recursively compensate gradient fill if it's not to be transformed
- if (prefs_get_int_attribute("options.transform", "gradient", 1) == 0) {
- sp_item_adjust_paint_recursive (item, advertized_transform.inverse(), NR::identity(), false);
- } else {
- // this converts the gradient/pattern fill/stroke, if any, to userSpaceOnUse; we need to do
- // it here _before_ the new transform is set, so as to use the pre-transform bbox
- sp_item_adjust_paint_recursive (item, NR::identity(), NR::identity(), false);
- }
-
- // run the object's set_transform if transforms are stored optimized
gint preserve = prefs_get_int_attribute("options.preservetransform", "value", 0);
NR::Matrix transform_attr (transform);
- if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->set_transform && !preserve) {
+ if ( // run the object's set_transform (i.e. embed transform) only if:
+ ((SPItemClass *) G_OBJECT_GET_CLASS(item))->set_transform && // it does have a set_transform method
+ !preserve && // user did not chose to preserve all transforms
+ !item->clip_ref->getObject() && // the object does not have a clippath
+ !item->mask_ref->getObject() && // the object does not have a mask
+ !(!transform.is_translation() && SP_OBJECT_STYLE(item) && SP_OBJECT_STYLE(item)->getFilter())
+ // the object does not have a filter, or the transform is translation (which is supposed to not affect filters)
+ ) {
transform_attr = ((SPItemClass *) G_OBJECT_GET_CLASS(item))->set_transform(item, transform);
}
sp_item_set_item_transform(item, transform_attr);