sp-item.cpp revision 1eb4534a71df4ce43561ff82b33dbd4d7696c919
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#define __SP_ITEM_C__
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson/** \file
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson * Base class for visual SVG elements
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson */
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson/*
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson * Authors:
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson * Lauris Kaplinski <lauris@kaplinski.com>
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac * bulia byak <buliabyak@users.sf.net>
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac * Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson *
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson * Copyright (C) 2001-2006 authors
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson * Copyright (C) 2001 Ximian, Inc.
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson *
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac * Released under GNU GPL, read the file 'COPYING' for more information
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac */
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac/** \class SPItem
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson *
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson * SPItem is an abstract base class for all graphic (visible) SVG nodes. It
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson * is a subclass of SPObject, with great deal of specific functionality.
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson */
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
590f36c69fc71ee8f5956de003054a842f78ccc5matthew_swift#ifdef HAVE_CONFIG_H
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson# include "config.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#endif
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "sp-item.h"
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov#include "svg/svg.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "print.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "display/nr-arena.h"
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov#include "display/nr-arena-item.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "attributes.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "document.h"
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift#include "uri.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "style.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include <glibmm/i18n.h>
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "sp-root.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "sp-clippath.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "sp-mask.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "sp-rect.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "sp-use.h"
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov#include "sp-text.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "sp-item-rm-unsatisfied-cns.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "sp-pattern.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "sp-switch.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "gradient-chemistry.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "prefs-utils.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "conn-avoid-ref.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "conditions.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "libnr/nr-matrix-div.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "libnr/nr-matrix-fns.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "libnr/nr-matrix-scale-ops.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "libnr/nr-matrix-translate-ops.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "libnr/nr-scale-translate-ops.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "libnr/nr-translate-scale-ops.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "algorithms/find-last-if.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "util/reverse-list.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#include "xml/repr.h"
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson#define noSP_ITEM_DEBUG_IDLE
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonstatic void sp_item_class_init(SPItemClass *klass);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonstatic void sp_item_init(SPItem *item);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonstatic void sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonstatic void sp_item_release(SPObject *object);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonstatic void sp_item_set(SPObject *object, unsigned key, gchar const *value);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonstatic void sp_item_update(SPObject *object, SPCtx *ctx, guint flags);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonstatic Inkscape::XML::Node *sp_item_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonstatic gchar *sp_item_private_description(SPItem *item);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonstatic void sp_item_private_snappoints(SPItem const *item, SnapPointsIter p);
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonstatic SPItemView *sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, NRArenaItem *arenaitem);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonstatic SPItemView *sp_item_view_list_remove(SPItemView *list, SPItemView *view);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonstatic SPObjectClass *parent_class;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonstatic void clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonstatic void mask_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson/**
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson * Registers SPItem class and returns its type number.
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson */
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonGType
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonsp_item_get_type(void)
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson{
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson static GType type = 0;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson if (!type) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson GTypeInfo info = {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sizeof(SPItemClass),
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson NULL, NULL,
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson (GClassInitFunc) sp_item_class_init,
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson NULL, NULL,
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sizeof(SPItem),
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson 16,
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson (GInstanceInitFunc) sp_item_init,
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson NULL, /* value_table */
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson };
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson type = g_type_register_static(SP_TYPE_OBJECT, "SPItem", &info, (GTypeFlags)0);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson return type;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson/**
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson * SPItem vtable initialization.
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson */
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonstatic void
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonsp_item_class_init(SPItemClass *klass)
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson{
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson SPObjectClass *sp_object_class = (SPObjectClass *) klass;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson parent_class = (SPObjectClass *)g_type_class_ref(SP_TYPE_OBJECT);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sp_object_class->build = sp_item_build;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sp_object_class->release = sp_item_release;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sp_object_class->set = sp_item_set;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sp_object_class->update = sp_item_update;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sp_object_class->write = sp_item_write;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff klass->description = sp_item_private_description;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson klass->snappoints = sp_item_private_snappoints;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson/**
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson * Callback for SPItem object initialization.
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson */
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonstatic void
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonsp_item_init(SPItem *item)
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson{
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson item->init();
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonvoid SPItem::init() {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson this->sensitive = TRUE;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson this->transform_center_x = 0;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson this->transform_center_y = 0;
1a70437cb8d25051f6259cbe5889eb67de86716eabobrov
1a70437cb8d25051f6259cbe5889eb67de86716eabobrov this->_is_evaluated = true;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson this->_evaluated_status = StatusUnknown;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson this->transform = NR::identity();
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson this->display = NULL;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson this->clip_ref = new SPClipPathReference(this);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sigc::signal<void, SPObject *, SPObject *> cs1=this->clip_ref->changedSignal();
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sigc::slot2<void,SPObject*, SPObject *> sl1=sigc::bind(sigc::ptr_fun(clip_ref_changed), this);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson _clip_ref_connection = cs1.connect(sl1);
1a70437cb8d25051f6259cbe5889eb67de86716eabobrov
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson this->mask_ref = new SPMaskReference(this);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sigc::signal<void, SPObject *, SPObject *> cs2=this->mask_ref->changedSignal();
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sigc::slot2<void,SPObject*, SPObject *> sl2=sigc::bind(sigc::ptr_fun(mask_ref_changed), this);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson _mask_ref_connection = cs2.connect(sl2);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson if (!this->style) this->style = sp_style_new_from_object(this);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson this->avoidRef = new SPAvoidRef(this);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
1a70437cb8d25051f6259cbe5889eb67de86716eabobrov new (&this->_transformed_signal) sigc::signal<void, NR::Matrix const *, SPItem *>();
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonbool SPItem::isVisibleAndUnlocked() const {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson return (!isHidden() && !isLocked());
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonbool SPItem::isVisibleAndUnlocked(unsigned display_key) const {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson return (!isHidden(display_key) && !isLocked());
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonbool SPItem::isLocked() const {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson for (SPObject *o = SP_OBJECT(this); o != NULL; o = SP_OBJECT_PARENT(o)) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson if (SP_IS_ITEM(o) && !(SP_ITEM(o)->sensitive))
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson return true;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson return false;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonvoid SPItem::setLocked(bool locked) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson SP_OBJECT_REPR(this)->setAttribute("sodipodi:insensitive",
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson ( locked ? "1" : NULL ));
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson updateRepr();
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonbool SPItem::isHidden() const {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson if (!isEvaluated())
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson return true;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson return style->display.computed == SP_CSS_DISPLAY_NONE;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonvoid SPItem::setHidden(bool hide) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson style->display.set = TRUE;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson style->display.value = ( hide ? SP_CSS_DISPLAY_NONE : SP_CSS_DISPLAY_INLINE );
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson style->display.computed = style->display.value;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson style->display.inherit = FALSE;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson updateRepr();
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonbool SPItem::isHidden(unsigned display_key) const {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson if (!isEvaluated())
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson return true;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson for ( SPItemView *view(display) ; view ; view = view->next ) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson if ( view->key == display_key ) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson g_assert(view->arenaitem != NULL);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson for ( NRArenaItem *arenaitem = view->arenaitem ;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson arenaitem ; arenaitem = arenaitem->parent )
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson if (!arenaitem->visible) {
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff return true;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson return false;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson return true;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonvoid SPItem::setEvaluated(bool evaluated) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson _is_evaluated = evaluated;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson _evaluated_status = StatusSet;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonvoid SPItem::resetEvaluated() {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson if ( StatusCalculated == _evaluated_status ) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson _evaluated_status = StatusUnknown;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson bool oldValue = _is_evaluated;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson if ( oldValue != isEvaluated() ) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson } if ( StatusSet == _evaluated_status ) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson SPObject const *const parent = SP_OBJECT_PARENT(this);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson if (SP_IS_SWITCH(parent)) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson SP_SWITCH(parent)->resetChildEvaluated();
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonbool SPItem::isEvaluated() const {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson if ( StatusUnknown == _evaluated_status ) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson _is_evaluated = sp_item_evaluate(this);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson _evaluated_status = StatusCalculated;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson return _is_evaluated;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson/**
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson * Returns something suitable for the `Hide' checkbox in the Object Properties dialog box.
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson * Corresponds to setExplicitlyHidden.
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson */
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonbool
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonSPItem::isExplicitlyHidden() const
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson{
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson return (this->style->display.set
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff && this->style->display.value == SP_CSS_DISPLAY_NONE);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson/**
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson * Sets the display CSS property to `hidden' if \a val is true,
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson * otherwise makes it unset
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson */
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonvoid
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonSPItem::setExplicitlyHidden(bool const val) {
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff this->style->display.set = val;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson this->style->display.value = ( val ? SP_CSS_DISPLAY_NONE : SP_CSS_DISPLAY_INLINE );
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson this->style->display.computed = this->style->display.value;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson this->updateRepr();
d145114ec122033a8bc1ab7c743313b7b427942dJnRouvignac}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson/**
1a70437cb8d25051f6259cbe5889eb67de86716eabobrov * Sets the transform_center_x and transform_center_y properties to retain the rotation centre
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff */
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonvoid
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonSPItem::setCenter(NR::Point object_centre) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson NR::Maybe<NR::Rect> bbox = getBounds(sp_item_i2d_affine(this));
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson if (bbox) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson transform_center_x = object_centre[NR::X] - bbox->midpoint()[NR::X];
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson if (fabs(transform_center_x) < 1e-5) // rounding error
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson transform_center_x = 0;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson transform_center_y = object_centre[NR::Y] - bbox->midpoint()[NR::Y];
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson if (fabs(transform_center_y) < 1e-5) // rounding error
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson transform_center_y = 0;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonvoid
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonSPItem::unsetCenter() {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson transform_center_x = 0;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson transform_center_y = 0;
1a70437cb8d25051f6259cbe5889eb67de86716eabobrov}
1a70437cb8d25051f6259cbe5889eb67de86716eabobrov
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonbool SPItem::isCenterSet() {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson return (transform_center_x != 0 || transform_center_y != 0);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonNR::Point SPItem::getCenter() {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson NR::Maybe<NR::Rect> bbox = getBounds(sp_item_i2d_affine(this));
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson if (bbox) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson return bbox->midpoint() + NR::Point (this->transform_center_x, this->transform_center_y);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson } else {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson return NR::Point (0, 0); // something's wrong!
1a70437cb8d25051f6259cbe5889eb67de86716eabobrov }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonnamespace {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonbool is_item(SPObject const &object) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson return SP_IS_ITEM(&object);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
1a70437cb8d25051f6259cbe5889eb67de86716eabobrov}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonvoid SPItem::raiseToTop() {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson using Inkscape::Algorithms::find_last_if;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson SPObject *topmost=find_last_if<SPObject::SiblingIterator>(
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson SP_OBJECT_NEXT(this), NULL, &is_item
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson );
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson if (topmost) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson Inkscape::XML::Node *repr=SP_OBJECT_REPR(this);
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff sp_repr_parent(repr)->changeOrder(repr, SP_OBJECT_REPR(topmost));
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonvoid SPItem::raiseOne() {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson SPObject *next_higher=std::find_if<SPObject::SiblingIterator>(
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson SP_OBJECT_NEXT(this), NULL, &is_item
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson );
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson if (next_higher) {
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff Inkscape::XML::Node *repr=SP_OBJECT_REPR(this);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson Inkscape::XML::Node *ref=SP_OBJECT_REPR(next_higher);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sp_repr_parent(repr)->changeOrder(repr, ref);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonvoid SPItem::lowerOne() {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson using Inkscape::Util::MutableList;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson using Inkscape::Util::reverse_list;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson MutableList<SPObject &> next_lower=std::find_if(
1a70437cb8d25051f6259cbe5889eb67de86716eabobrov reverse_list<SPObject::SiblingIterator>(
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson SP_OBJECT_PARENT(this)->firstChild(), this
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson ),
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson MutableList<SPObject &>(),
1a70437cb8d25051f6259cbe5889eb67de86716eabobrov &is_item
1a70437cb8d25051f6259cbe5889eb67de86716eabobrov );
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff if (next_lower) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson ++next_lower;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson Inkscape::XML::Node *repr=SP_OBJECT_REPR(this);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson Inkscape::XML::Node *ref=( next_lower ? SP_OBJECT_REPR(&*next_lower) : NULL );
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sp_repr_parent(repr)->changeOrder(repr, ref);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonvoid SPItem::lowerToBottom() {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson using Inkscape::Algorithms::find_last_if;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson using Inkscape::Util::MutableList;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson using Inkscape::Util::reverse_list;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson MutableList<SPObject &> bottom=find_last_if(
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson reverse_list<SPObject::SiblingIterator>(
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson SP_OBJECT_PARENT(this)->firstChild(), this
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson ),
1a70437cb8d25051f6259cbe5889eb67de86716eabobrov MutableList<SPObject &>(),
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson &is_item
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson );
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson if (bottom) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson ++bottom;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson Inkscape::XML::Node *repr=SP_OBJECT_REPR(this);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson Inkscape::XML::Node *ref=( bottom ? SP_OBJECT_REPR(&*bottom) : NULL );
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sp_repr_parent(repr)->changeOrder(repr, ref);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonstatic void
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonsp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson{
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sp_object_read_attr(object, "style");
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sp_object_read_attr(object, "transform");
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sp_object_read_attr(object, "clip-path");
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sp_object_read_attr(object, "mask");
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sp_object_read_attr(object, "sodipodi:insensitive");
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sp_object_read_attr(object, "sodipodi:nonprintable");
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff sp_object_read_attr(object, "inkscape:transform-center-x");
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sp_object_read_attr(object, "inkscape:transform-center-y");
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson sp_object_read_attr(object, "inkscape:connector-avoid");
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson if (((SPObjectClass *) (parent_class))->build) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson (* ((SPObjectClass *) (parent_class))->build)(object, document, repr);
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson}
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduffstatic void
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilsonsp_item_release(SPObject *object)
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson{
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson SPItem *item = (SPItem *) object;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson item->_clip_ref_connection.disconnect();
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson item->_mask_ref_connection.disconnect();
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov if (item->clip_ref) {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift item->clip_ref->detach();
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift delete item->clip_ref;
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift item->clip_ref = NULL;
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift }
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift if (item->mask_ref) {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift item->mask_ref->detach();
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift delete item->mask_ref;
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift item->mask_ref = NULL;
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift }
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift if (item->avoidRef) {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift delete item->avoidRef;
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift item->avoidRef = NULL;
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift }
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift if (((SPObjectClass *) (parent_class))->release) {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift ((SPObjectClass *) parent_class)->release(object);
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift }
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift while (item->display) {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift nr_arena_item_unparent(item->display->arenaitem);
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift item->display = sp_item_view_list_remove(item->display, item->display);
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift }
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift item->_transformed_signal.~signal();
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift}
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swiftstatic void
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swiftsp_item_set(SPObject *object, unsigned key, gchar const *value)
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift{
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift SPItem *item = (SPItem *) object;
590f36c69fc71ee8f5956de003054a842f78ccc5matthew_swift
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift switch (key) {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift case SP_ATTR_TRANSFORM: {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift NR::Matrix t;
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift if (value && sp_svg_transform_read(value, &t)) {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift sp_item_set_item_transform(item, t);
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift } else {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift sp_item_set_item_transform(item, NR::identity());
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift }
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift break;
c16e2b0b696c033b4aa1256249b9d9755d787970abobrov }
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift case SP_PROP_CLIP_PATH: {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift gchar *uri = Inkscape::parse_css_url(value);
c16e2b0b696c033b4aa1256249b9d9755d787970abobrov if (uri) {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift try {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift item->clip_ref->attach(Inkscape::URI(uri));
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift } catch (Inkscape::BadURIException &e) {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift g_warning("%s", e.what());
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift item->clip_ref->detach();
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift }
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift g_free(uri);
c16e2b0b696c033b4aa1256249b9d9755d787970abobrov } else {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift item->clip_ref->detach();
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift }
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift break;
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift }
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov case SP_PROP_MASK: {
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov gchar *uri=Inkscape::parse_css_url(value);
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift if (uri) {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift try {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift item->mask_ref->attach(Inkscape::URI(uri));
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov } catch (Inkscape::BadURIException &e) {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift g_warning("%s", e.what());
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift item->mask_ref->detach();
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov }
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov g_free(uri);
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov } else {
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov item->mask_ref->detach();
0a873588d0c3ba63e71d8dae4b914e4ff99ae8c8abobrov }
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov break;
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov }
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov case SP_ATTR_SODIPODI_INSENSITIVE:
0a873588d0c3ba63e71d8dae4b914e4ff99ae8c8abobrov item->sensitive = !value;
0a873588d0c3ba63e71d8dae4b914e4ff99ae8c8abobrov for (SPItemView *v = item->display; v != NULL; v = v->next) {
0a873588d0c3ba63e71d8dae4b914e4ff99ae8c8abobrov nr_arena_item_set_sensitive(v->arenaitem, item->sensitive);
0a873588d0c3ba63e71d8dae4b914e4ff99ae8c8abobrov }
0a873588d0c3ba63e71d8dae4b914e4ff99ae8c8abobrov break;
0a873588d0c3ba63e71d8dae4b914e4ff99ae8c8abobrov case SP_ATTR_STYLE:
0a873588d0c3ba63e71d8dae4b914e4ff99ae8c8abobrov sp_style_read_from_object(object->style, object);
0a873588d0c3ba63e71d8dae4b914e4ff99ae8c8abobrov object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
0a873588d0c3ba63e71d8dae4b914e4ff99ae8c8abobrov break;
0a873588d0c3ba63e71d8dae4b914e4ff99ae8c8abobrov case SP_ATTR_CONNECTOR_AVOID:
c3690e9ed9bf853b95a31df6d7c8e169bf167050abobrov item->avoidRef->setAvoid(value);
c3690e9ed9bf853b95a31df6d7c8e169bf167050abobrov break;
c3690e9ed9bf853b95a31df6d7c8e169bf167050abobrov case SP_ATTR_TRANSFORM_CENTER_X:
c3690e9ed9bf853b95a31df6d7c8e169bf167050abobrov if (value) {
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov item->transform_center_x = g_strtod(value, NULL);
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov } else {
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov item->transform_center_x = 0;
c3690e9ed9bf853b95a31df6d7c8e169bf167050abobrov }
c3690e9ed9bf853b95a31df6d7c8e169bf167050abobrov object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
c3690e9ed9bf853b95a31df6d7c8e169bf167050abobrov break;
c3690e9ed9bf853b95a31df6d7c8e169bf167050abobrov case SP_ATTR_TRANSFORM_CENTER_Y:
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov if (value) {
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov item->transform_center_y = g_strtod(value, NULL);
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift } else {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift item->transform_center_y = 0;
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift }
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift break;
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov case SP_PROP_SYSTEM_LANGUAGE:
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov case SP_PROP_REQUIRED_FEATURES:
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov case SP_PROP_REQUIRED_EXTENSIONS:
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift item->resetEvaluated();
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift // pass to default handler
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov }
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov default:
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov if (SP_ATTRIBUTE_IS_CSS(key)) {
eb23f8af24de5ef87b129db2de8f849d1092e9b9abobrov sp_style_read_from_object(object->style, object);
c3690e9ed9bf853b95a31df6d7c8e169bf167050abobrov object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
c3690e9ed9bf853b95a31df6d7c8e169bf167050abobrov } else {
c3690e9ed9bf853b95a31df6d7c8e169bf167050abobrov if (((SPObjectClass *) (parent_class))->set) {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift (* ((SPObjectClass *) (parent_class))->set)(object, key, value);
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov }
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov }
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift break;
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift }
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift}
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swiftstatic void
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swiftclip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item)
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift{
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift if (old_clip) {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift SPItemView *v;
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift /* Hide clippath */
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift for (v = item->display; v != NULL; v = v->next) {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift sp_clippath_hide(SP_CLIPPATH(old_clip), NR_ARENA_ITEM_GET_KEY(v->arenaitem));
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift nr_arena_item_set_clip(v->arenaitem, NULL);
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift }
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift }
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift if (SP_IS_CLIPPATH(clip)) {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift NRRect bbox;
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift sp_item_invoke_bbox(item, &bbox, NR::identity(), TRUE);
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift for (SPItemView *v = item->display; v != NULL; v = v->next) {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift if (!v->arenaitem->key) {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift NR_ARENA_ITEM_SET_KEY(v->arenaitem, sp_item_display_key_new(3));
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift }
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift NRArenaItem *ai = sp_clippath_show(SP_CLIPPATH(clip),
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift NR_ARENA_ITEM_ARENA(v->arenaitem),
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift NR_ARENA_ITEM_GET_KEY(v->arenaitem));
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift nr_arena_item_set_clip(v->arenaitem, ai);
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift nr_arena_item_unref(ai);
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift sp_clippath_set_bbox(SP_CLIPPATH(clip), NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox);
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift SP_OBJECT(clip)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift }
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift }
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift}
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swiftstatic void
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swiftmask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item)
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift{
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift if (old_mask) {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift /* Hide mask */
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift for (SPItemView *v = item->display; v != NULL; v = v->next) {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift sp_mask_hide(SP_MASK(old_mask), NR_ARENA_ITEM_GET_KEY(v->arenaitem));
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift nr_arena_item_set_mask(v->arenaitem, NULL);
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift }
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift }
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift if (SP_IS_MASK(mask)) {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift NRRect bbox;
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov sp_item_invoke_bbox(item, &bbox, NR::identity(), TRUE);
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov for (SPItemView *v = item->display; v != NULL; v = v->next) {
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov if (!v->arenaitem->key) {
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov NR_ARENA_ITEM_SET_KEY(v->arenaitem, sp_item_display_key_new(3));
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov }
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov NRArenaItem *ai = sp_mask_show(SP_MASK(mask),
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov NR_ARENA_ITEM_ARENA(v->arenaitem),
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov NR_ARENA_ITEM_GET_KEY(v->arenaitem));
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov nr_arena_item_set_mask(v->arenaitem, ai);
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov nr_arena_item_unref(ai);
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov sp_mask_set_bbox(SP_MASK(mask), NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox);
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov SP_OBJECT(mask)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov }
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov }
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov}
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrovstatic void
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrovsp_item_update(SPObject *object, SPCtx *ctx, guint flags)
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov{
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov SPItem *item = SP_ITEM(object);
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov if (((SPObjectClass *) (parent_class))->update)
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov (* ((SPObjectClass *) (parent_class))->update)(object, ctx, flags);
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov if (flags & (SP_OBJECT_CHILD_MODIFIED_FLAG | SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG)) {
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov if (flags & SP_OBJECT_MODIFIED_FLAG) {
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov for (SPItemView *v = item->display; v != NULL; v = v->next) {
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov nr_arena_item_set_transform(v->arenaitem, item->transform);
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov }
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov }
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov SPClipPath *clip_path = item->clip_ref->getObject();
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov SPMask *mask = item->mask_ref->getObject();
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov if ( clip_path || mask ) {
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov NRRect bbox;
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov sp_item_invoke_bbox(item, &bbox, NR::identity(), TRUE);
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov if (clip_path) {
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov for (SPItemView *v = item->display; v != NULL; v = v->next) {
b1af91c303f77cdd421dc0519e363b2d60c15a63matthew_swift sp_clippath_set_bbox(clip_path, NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox);
d145114ec122033a8bc1ab7c743313b7b427942dJnRouvignac }
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov }
c8d962c30776d1b772e3f4d0c72760bd05f68647abobrov if (mask) {
for (SPItemView *v = item->display; v != NULL; v = v->next) {
sp_mask_set_bbox(mask, NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox);
}
}
}
if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) {
for (SPItemView *v = item->display; v != NULL; v = v->next) {
nr_arena_item_set_opacity(v->arenaitem, SP_SCALE24_TO_FLOAT(object->style->opacity.value));
nr_arena_item_set_visible(v->arenaitem, !item->isHidden());
}
}
}
// Update libavoid with item geometry (for connector routing).
item->avoidRef->handleSettingChange();
}
static Inkscape::XML::Node *
sp_item_write(SPObject *const object, Inkscape::XML::Node *repr, guint flags)
{
SPItem *item = SP_ITEM(object);
gchar *c = sp_svg_transform_write(item->transform);
repr->setAttribute("transform", c);
g_free(c);
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);
}
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
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);
}
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) {
((SPObjectClass *) (parent_class))->write(object, repr, flags);
}
return repr;
}
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, 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_full(item, bbox, transform, 0, 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)
{
g_assert(item != NULL);
g_assert(SP_IS_ITEM(item));
g_assert(bbox != NULL);
if (clear) {
bbox->x0 = bbox->y0 = 1e18;
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, &this_bbox, transform, flags);
}
// crop the bbox by clip path, if any
if (item->clip_ref->getObject()) {
NRRect b;
sp_clippath_get_bbox(SP_CLIPPATH(item->clip_ref->getObject()), &b, transform, flags);
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);
}
}
unsigned sp_item_pos_in_parent(SPItem *item)
{
g_assert(item != NULL);
g_assert(SP_IS_ITEM(item));
SPObject *parent = SP_OBJECT_PARENT(item);
g_assert(parent != NULL);
g_assert(SP_IS_OBJECT(parent));
SPObject *object = SP_OBJECT(item);
unsigned pos=0;
for ( SPObject *iter = sp_object_first_child(parent) ; iter ; iter = SP_OBJECT_NEXT(iter)) {
if ( iter == object ) {
return pos;
}
if (SP_IS_ITEM(iter)) {
pos++;
}
}
g_assert_not_reached();
return 0;
}
void
sp_item_bbox_desktop(SPItem *item, NRRect *bbox)
{
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);
}
NR::Rect sp_item_bbox_desktop(SPItem *item)
{
NRRect ret;
sp_item_invoke_bbox(item, &ret, sp_item_i2d_affine(item), TRUE);
NR::Maybe<NR::Rect> result = ret.upgrade();
if (result) {
return *result;
} else {
// FIXME
return NR::Rect(NR::Point(0, 0), NR::Point(0, 0));
}
}
static void sp_item_private_snappoints(SPItem const *item, SnapPointsIter p)
{
NR::Maybe<NR::Rect> bbox = item->getBounds(sp_item_i2d_affine(item));
/* Just a pair of opposite corners of the bounding box suffices given that we don't yet
support angled guide lines. */
if (bbox) {
*p = bbox->min();
*p = bbox->max();
}
}
void sp_item_snappoints(SPItem const *item, SnapPointsIter p)
{
g_assert (item != NULL);
g_assert (SP_IS_ITEM(item));
SPItemClass const &item_class = *(SPItemClass const *) G_OBJECT_GET_CLASS(item);
if (item_class.snappoints) {
item_class.snappoints(item, p);
}
}
void
sp_item_invoke_print(SPItem *item, SPPrintContext *ctx)
{
if (!item->isHidden()) {
if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->print) {
if (!item->transform.test_identity()
|| SP_OBJECT_STYLE(item)->opacity.value != SP_SCALE24_MAX)
{
sp_print_bind(ctx, item->transform, SP_SCALE24_TO_FLOAT(SP_OBJECT_STYLE(item)->opacity.value));
((SPItemClass *) G_OBJECT_GET_CLASS(item))->print(item, ctx);
sp_print_release(ctx);
} else {
((SPItemClass *) G_OBJECT_GET_CLASS(item))->print(item, ctx);
}
}
}
}
static gchar *
sp_item_private_description(SPItem *item)
{
return g_strdup(_("Object"));
}
/**
* Returns a string suitable for status bar, formatted in pango markup language.
*
* Must be freed by caller.
*/
gchar *
sp_item_description(SPItem *item)
{
g_assert(item != NULL);
g_assert(SP_IS_ITEM(item));
if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->description) {
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();
return NULL;
}
/**
* Allocates unique integer keys.
* \param numkeys Number of keys required.
* \return First allocated key; hence if the returned key is n
* you can use n, n + 1, ..., n + (numkeys - 1)
*/
unsigned
sp_item_display_key_new(unsigned numkeys)
{
static unsigned dkey = 0;
dkey += numkeys;
return dkey - numkeys;
}
NRArenaItem *
sp_item_invoke_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags)
{
g_assert(item != NULL);
g_assert(SP_IS_ITEM(item));
g_assert(arena != NULL);
g_assert(NR_IS_ARENA(arena));
NRArenaItem *ai = NULL;
if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->show) {
ai = ((SPItemClass *) G_OBJECT_GET_CLASS(item))->show(item, arena, key, flags);
}
if (ai != NULL) {
item->display = sp_item_view_new_prepend(item->display, item, flags, key, ai);
nr_arena_item_set_transform(ai, item->transform);
nr_arena_item_set_opacity(ai, SP_SCALE24_TO_FLOAT(SP_OBJECT_STYLE(item)->opacity.value));
nr_arena_item_set_visible(ai, !item->isHidden());
nr_arena_item_set_sensitive(ai, item->sensitive);
if (item->clip_ref->getObject()) {
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()) {
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);
}
return ai;
}
void
sp_item_invoke_hide(SPItem *item, unsigned key)
{
g_assert(item != NULL);
g_assert(SP_IS_ITEM(item));
if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->hide) {
((SPItemClass *) G_OBJECT_GET_CLASS(item))->hide(item, key);
}
SPItemView *ref = NULL;
SPItemView *v = item->display;
while (v != NULL) {
SPItemView *next = v->next;
if (v->key == key) {
if (item->clip_ref->getObject()) {
sp_clippath_hide(item->clip_ref->getObject(), NR_ARENA_ITEM_GET_KEY(v->arenaitem));
nr_arena_item_set_clip(v->arenaitem, NULL);
}
if (item->mask_ref->getObject()) {
sp_mask_hide(item->mask_ref->getObject(), NR_ARENA_ITEM_GET_KEY(v->arenaitem));
nr_arena_item_set_mask(v->arenaitem, NULL);
}
if (!ref) {
item->display = v->next;
} else {
ref->next = v->next;
}
nr_arena_item_unparent(v->arenaitem);
nr_arena_item_unref(v->arenaitem);
g_free(v);
} else {
ref = v;
}
v = next;
}
}
// Adjusters
void
sp_item_adjust_pattern (SPItem *item, NR::Matrix const &postmul, bool set)
{
SPStyle *style = SP_OBJECT_STYLE (item);
if (style && (style->fill.type == SP_PAINT_TYPE_PAINTSERVER)) {
SPObject *server = SP_OBJECT_STYLE_FILL_SERVER (item);
if (SP_IS_PATTERN (server)) {
SPPattern *pattern = sp_pattern_clone_if_necessary (item, SP_PATTERN (server), "fill");
sp_pattern_transform_multiply (pattern, postmul, set);
}
}
if (style && (style->stroke.type == SP_PAINT_TYPE_PAINTSERVER)) {
SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER (item);
if (SP_IS_PATTERN (server)) {
SPPattern *pattern = sp_pattern_clone_if_necessary (item, SP_PATTERN (server), "stroke");
sp_pattern_transform_multiply (pattern, postmul, set);
}
}
}
void
sp_item_adjust_gradient (SPItem *item, NR::Matrix const &postmul, bool set)
{
SPStyle *style = SP_OBJECT_STYLE (item);
if (style && (style->fill.type == SP_PAINT_TYPE_PAINTSERVER)) {
SPObject *server = SP_OBJECT_STYLE_FILL_SERVER(item);
if (SP_IS_GRADIENT (server)) {
/**
* \note Bbox units for a gradient are generally a bad idea because
* with them, you cannot preserve the relative position of the
* object and its gradient after rotation or skew. So now we
* convert them to userspace units which are easy to keep in sync
* just by adding the object's transform to gradientTransform.
* \todo FIXME: convert back to bbox units after transforming with
* the item, so as to preserve the original units.
*/
SPGradient *gradient = sp_gradient_convert_to_userspace (SP_GRADIENT (server), item, "fill");
sp_gradient_transform_multiply (gradient, postmul, set);
}
}
if (style && (style->stroke.type == SP_PAINT_TYPE_PAINTSERVER)) {
SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER(item);
if (SP_IS_GRADIENT (server)) {
SPGradient *gradient = sp_gradient_convert_to_userspace (SP_GRADIENT (server), item, "stroke");
sp_gradient_transform_multiply (gradient, postmul, set);
}
}
}
void
sp_item_adjust_stroke (SPItem *item, gdouble ex)
{
SPStyle *style = SP_OBJECT_STYLE (item);
if (style && style->stroke.type != SP_PAINT_TYPE_NONE && !NR_DF_TEST_CLOSE (ex, 1.0, NR_EPSILON)) {
style->stroke_width.computed *= ex;
style->stroke_width.set = TRUE;
if (style->stroke_dash.n_dash != 0) {
int i;
for (i = 0; i < style->stroke_dash.n_dash; i++) {
style->stroke_dash.dash[i] *= ex;
}
style->stroke_dash.offset *= ex;
}
SP_OBJECT(item)->updateRepr();
}
}
/**
* Find out the inverse of previous transform of an item (from its repr)
*/
NR::Matrix
sp_item_transform_repr (SPItem *item)
{
NR::Matrix t_old(NR::identity());
gchar const *t_attr = SP_OBJECT_REPR(item)->attribute("transform");
if (t_attr) {
NR::Matrix t;
if (sp_svg_transform_read(t_attr, &t)) {
t_old = t;
}
}
return t_old;
}
/**
* Recursively scale stroke width in \a item and its children by \a expansion.
*/
void
sp_item_adjust_stroke_width_recursive(SPItem *item, double expansion)
{
sp_item_adjust_stroke (item, expansion);
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);
}
}
/**
* Recursively adjust rx and ry of rects.
*/
void
sp_item_adjust_rects_recursive(SPItem *item, NR::Matrix advertized_transform)
{
if (SP_IS_RECT (item)) {
sp_rect_compensate_rxry (SP_RECT(item), advertized_transform);
}
for (SPObject *o = SP_OBJECT(item)->children; o != NULL; o = o->next) {
if (SP_IS_ITEM(o))
sp_item_adjust_rects_recursive(SP_ITEM(o), advertized_transform);
}
}
/**
* Recursively compensate pattern or gradient 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();
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);
}
}
}
/**
* A temporary wrapper for the next function accepting the NRMatrix
* instead of NR::Matrix
*/
void
sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NRMatrix const *transform, NR::Matrix const *adv)
{
if (transform == NULL)
sp_item_write_transform(item, repr, NR::identity(), adv);
else
sp_item_write_transform(item, repr, NR::Matrix (transform), adv);
}
/**
* Set a new transform on an object.
*
* Compensate for stroke scaling and gradient/pattern fill transform, if
* necessary. Call the object's set_transform method if transforms are
* stored optimized. Send _transformed_signal. Invoke _write method so that
* 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, bool compensate)
{
g_return_if_fail(item != NULL);
g_return_if_fail(SP_IS_ITEM(item));
g_return_if_fail(repr != NULL);
// calculate the relative transform, if not given by the adv attribute
NR::Matrix advertized_transform;
if (adv != NULL) {
advertized_transform = *adv;
} 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)
gint preserve = prefs_get_int_attribute("options.preservetransform", "value", 0);
NR::Matrix transform_attr (transform);
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)->filter.filter)
// 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);
// Note: updateRepr comes before emitting the transformed signal since
// it causes clone SPUse's copy of the original object to brought up to
// date with the original. Otherwise, sp_use_bbox returns incorrect
// values if called in code handling the transformed signal.
SP_OBJECT(item)->updateRepr();
// send the relative transform with a _transformed_signal
item->_transformed_signal.emit(&advertized_transform, item);
}
gint
sp_item_event(SPItem *item, SPEvent *event)
{
g_return_val_if_fail(item != NULL, FALSE);
g_return_val_if_fail(SP_IS_ITEM(item), FALSE);
g_return_val_if_fail(event != NULL, FALSE);
if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->event)
return ((SPItemClass *) G_OBJECT_GET_CLASS(item))->event(item, event);
return FALSE;
}
/**
* Sets item private transform (not propagated to repr), without compensating stroke widths,
* gradients, patterns as sp_item_write_transform does.
*/
void
sp_item_set_item_transform(SPItem *item, NR::Matrix const &transform)
{
g_return_if_fail(item != NULL);
g_return_if_fail(SP_IS_ITEM(item));
if (!matrix_equalp(transform, item->transform, NR_EPSILON)) {
item->transform = transform;
/* The SP_OBJECT_USER_MODIFIED_FLAG_B is used to mark the fact that it's only a
transformation. It's apparently not used anywhere else. */
item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_USER_MODIFIED_FLAG_B);
sp_item_rm_unsatisfied_cns(*item);
}
}
/**
* \pre \a ancestor really is an ancestor (\>=) of \a object, or NULL.
* ("Ancestor (\>=)" here includes as far as \a object itself.)
*/
NR::Matrix
i2anc_affine(SPObject const *object, SPObject const *const ancestor) {
NR::Matrix ret(NR::identity());
g_return_val_if_fail(object != NULL, ret);
/* stop at first non-renderable ancestor */
while ( object != ancestor && SP_IS_ITEM(object) ) {
if (SP_IS_ROOT(object)) {
ret *= SP_ROOT(object)->c2p;
}
ret *= SP_ITEM(object)->transform;
object = SP_OBJECT_PARENT(object);
}
return ret;
}
NR::Matrix
i2i_affine(SPObject const *src, SPObject const *dest) {
g_return_val_if_fail(src != NULL && dest != NULL, NR::identity());
SPObject const *ancestor = src->nearestCommonAncestor(dest);
return i2anc_affine(src, ancestor) / i2anc_affine(dest, ancestor);
}
NR::Matrix SPItem::getRelativeTransform(SPObject const *dest) const {
return i2i_affine(this, dest);
}
/**
* Returns the accumulated transformation of the item and all its ancestors, including root's viewport.
* \pre (item != NULL) and SP_IS_ITEM(item).
*/
NR::Matrix sp_item_i2doc_affine(SPItem const *item)
{
return i2anc_affine(item, NULL);
}
/**
* Returns the accumulated transformation of the item and all its ancestors, but excluding root's viewport.
* Used in path operations mostly.
* \pre (item != NULL) and SP_IS_ITEM(item).
*/
NR::Matrix sp_item_i2root_affine(SPItem const *item)
{
g_assert(item != NULL);
g_assert(SP_IS_ITEM(item));
NR::Matrix ret(NR::identity());
g_assert(ret.test_identity());
while ( NULL != SP_OBJECT_PARENT(item) ) {
ret *= item->transform;
item = SP_ITEM(SP_OBJECT_PARENT(item));
}
g_assert(SP_IS_ROOT(item));
ret *= item->transform;
return ret;
}
/* fixme: This is EVIL!!! */
NR::Matrix sp_item_i2d_affine(SPItem const *item)
{
g_assert(item != NULL);
g_assert(SP_IS_ITEM(item));
NR::Matrix const ret( sp_item_i2doc_affine(item)
* NR::scale(1, -1)
* NR::translate(0, sp_document_height(SP_OBJECT_DOCUMENT(item))) );
return ret;
}
// same as i2d but with i2root instead of i2doc
NR::Matrix sp_item_i2r_affine(SPItem const *item)
{
g_assert(item != NULL);
g_assert(SP_IS_ITEM(item));
NR::Matrix const ret( sp_item_i2root_affine(item)
* NR::scale(1, -1)
* NR::translate(0, sp_document_height(SP_OBJECT_DOCUMENT(item))) );
return ret;
}
/**
* Converts a matrix \a m into the desktop coords of the \a item.
* Will become a noop when we eliminate the coordinate flipping.
*/
NR::Matrix matrix_to_desktop(NR::Matrix const m, SPItem const *item)
{
NR::Matrix const ret(m
* NR::translate(0, -sp_document_height(SP_OBJECT_DOCUMENT(item)))
* NR::scale(1, -1));
return ret;
}
/**
* Converts a matrix \a m from the desktop coords of the \a item.
* Will become a noop when we eliminate the coordinate flipping.
*/
NR::Matrix matrix_from_desktop(NR::Matrix const m, SPItem const *item)
{
NR::Matrix const ret(NR::scale(1, -1)
* NR::translate(0, sp_document_height(SP_OBJECT_DOCUMENT(item)))
* m);
return ret;
}
void sp_item_set_i2d_affine(SPItem *item, NR::Matrix const &i2dt)
{
g_return_if_fail( item != NULL );
g_return_if_fail( SP_IS_ITEM(item) );
NR::Matrix dt2p; /* desktop to item parent transform */
if (SP_OBJECT_PARENT(item)) {
dt2p = sp_item_i2d_affine((SPItem *) SP_OBJECT_PARENT(item)).inverse();
} else {
dt2p = ( NR::translate(0, -sp_document_height(SP_OBJECT_DOCUMENT(item)))
* NR::scale(1, -1) );
}
NR::Matrix const i2p( i2dt * dt2p );
sp_item_set_item_transform(item, i2p);
}
NR::Matrix
sp_item_dt2i_affine(SPItem const *item)
{
/* fixme: Implement the right way (Lauris) */
return sp_item_i2d_affine(item).inverse();
}
/* Item views */
static SPItemView *
sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, NRArenaItem *arenaitem)
{
SPItemView *new_view;
g_assert(item != NULL);
g_assert(SP_IS_ITEM(item));
g_assert(arenaitem != NULL);
g_assert(NR_IS_ARENA_ITEM(arenaitem));
new_view = g_new(SPItemView, 1);
new_view->next = list;
new_view->flags = flags;
new_view->key = key;
new_view->arenaitem = nr_arena_item_ref(arenaitem);
return new_view;
}
static SPItemView *
sp_item_view_list_remove(SPItemView *list, SPItemView *view)
{
if (view == list) {
list = list->next;
} else {
SPItemView *prev;
prev = list;
while (prev->next != view) prev = prev->next;
prev->next = view->next;
}
nr_arena_item_unref(view->arenaitem);
g_free(view);
return list;
}
/**
* Return the arenaitem corresponding to the given item in the display
* with the given key
*/
NRArenaItem *
sp_item_get_arenaitem(SPItem *item, unsigned key)
{
for ( SPItemView *iv = item->display ; iv ; iv = iv->next ) {
if ( iv->key == key ) {
return iv->arenaitem;
}
}
return NULL;
}
int
sp_item_repr_compare_position(SPItem *first, SPItem *second)
{
return sp_repr_compare_position(SP_OBJECT_REPR(first),
SP_OBJECT_REPR(second));
}
SPItem *
sp_item_first_item_child (SPObject *obj)
{
for ( SPObject *iter = sp_object_first_child(obj) ; iter ; iter = SP_OBJECT_NEXT(iter)) {
if (SP_IS_ITEM (iter))
return SP_ITEM (iter);
}
return NULL;
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :