X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fxml%2Frepr-css.cpp;h=be125f45358481f40259bb75bbc6ad297897872f;hb=95b315afbe1dd2b6df33883e32456b86605bf104;hp=afa0ca2ef36a8b439443cc36a8f58886eca162f0;hpb=f61e22edfbabba7d9ffdfb87c7661a372989e858;p=inkscape.git diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp index afa0ca2ef..be125f453 100644 --- a/src/xml/repr-css.cpp +++ b/src/xml/repr-css.cpp @@ -8,6 +8,7 @@ #include #include "xml/repr.h" +#include "xml/simple-document.h" #include "xml/simple-node.h" #include "style.h" #include "libcroco/cr-sel-eng.h" @@ -21,20 +22,28 @@ using Inkscape::XML::Document; struct SPCSSAttrImpl : public SimpleNode, public SPCSSAttr { public: - SPCSSAttrImpl() : SimpleNode(g_quark_from_static_string("css")) {} + SPCSSAttrImpl(Document *doc) + : SimpleNode(g_quark_from_static_string("css"), doc) {} + SPCSSAttrImpl(SPCSSAttrImpl const &other, Document *doc) + : SimpleNode(other, doc) {} NodeType type() const { return Inkscape::XML::ELEMENT_NODE; } protected: - SimpleNode *_duplicate(Document* /*doc*/) const { return new SPCSSAttrImpl(*this); } + SimpleNode *_duplicate(Document* doc) const { return new SPCSSAttrImpl(*this, doc); } }; static void sp_repr_css_add_components(SPCSSAttr *css, Node *repr, gchar const *attr); + SPCSSAttr * sp_repr_css_attr_new() { - return new SPCSSAttrImpl(); + static Inkscape::XML::Document *attr_doc=NULL; + if (!attr_doc) { + attr_doc = new Inkscape::XML::SimpleDocument(); + } + return new SPCSSAttrImpl(attr_doc); } void @@ -120,7 +129,7 @@ sp_repr_css_set_property(SPCSSAttr *css, gchar const *name, gchar const *value) g_assert(css != NULL); g_assert(name != NULL); - sp_repr_set_attr((Node *) css, name, value); + ((Node *) css)->setAttribute(name, value, false); } void @@ -129,7 +138,7 @@ sp_repr_css_unset_property(SPCSSAttr *css, gchar const *name) g_assert(css != NULL); g_assert(name != NULL); - sp_repr_set_attr((Node *) css, name, "inkscape:unset"); + ((Node *) css)->setAttribute(name, "inkscape:unset", false); } double @@ -219,7 +228,7 @@ sp_repr_css_merge_from_decl(SPCSSAttr *css, CRDeclaration const *const decl) guchar *const str_value_unsigned = cr_term_to_string(decl->value); gchar *const str_value = reinterpret_cast(str_value_unsigned); gchar *value_unquoted = attribute_unquote (str_value); // libcroco returns strings quoted in "" - sp_repr_set_attr((Node *) css, decl->property->stryng->str, value_unquoted); + ((Node *) css)->setAttribute(decl->property->stryng->str, value_unquoted, false); g_free(value_unquoted); g_free(str_value); }