/*
5 * Authors: see git history
7 * Copyright (C) 2018 Authors
8 * Released under GNU GPL v2+, read the file
'COPYING' for more information.
34#include <glibmm/ustring.h>
52 :
SimpleNode(g_quark_from_static_string(
"css"), doc) {}
53 SPCSSAttrImpl(SPCSSAttrImpl
const &other,
Document *doc)
70 return new SPCSSAttrImpl(attr_doc);
78 g_assert(
css !=
nullptr);
90 g_assert(repr !=
nullptr);
91 g_assert(attr !=
nullptr);
118 g_assert(repr !=
nullptr);
119 g_assert(attr !=
nullptr);
135 g_assert(
css !=
nullptr);
136 g_assert(repr !=
nullptr);
137 g_assert(attr !=
nullptr);
149 g_assert(
css !=
nullptr);
150 g_assert(
name !=
nullptr);
153 return ( attr ==
nullptr
164 g_assert(
css !=
nullptr);
166 Glib::ustring retval = defval;
167 char const *attr = ((
Node *)
css)->attribute(
name.c_str());
180 g_assert(
css !=
nullptr);
181 g_assert(
name !=
nullptr);
184 return (attr && !strcmp(attr,
"inkscape:unset"));
193 g_assert(
css !=
nullptr);
194 g_assert(
name !=
nullptr);
204 g_assert(
css !=
nullptr);
205 g_assert(
name !=
nullptr);
207 ((
Node *)
css)->setAttribute(
name,
"inkscape:unset");
215 g_assert(
css !=
nullptr);
216 g_assert(
name !=
nullptr);
218 return css->getAttributeDouble(
name, defval);
226 g_assert(
css !=
nullptr);
227 g_assert(
name !=
nullptr);
229 ((
Node *)
css)->setAttributeCssDouble(
name, value);
246 for (
const auto & iter :
css->attributeList())
248 if (iter.value && !strcmp(iter.value,
"inkscape:unset")) {
256 str.append(g_quark_to_string(iter.key));
258 str.append(iter.value);
267 g_assert(repr !=
nullptr);
268 g_assert(
css !=
nullptr);
269 g_assert(attr !=
nullptr);
288 for (
const auto & attr:
css->attributeList() )
290 gchar
const *
key = g_quark_to_string(attr.key);
291 gchar
const * val = attr.value;
292 g_print(
"%s:\t%s\n",
key,val);
301 g_assert(dst !=
nullptr);
302 g_assert(src !=
nullptr);
317 css->setAttribute(decl->property->stryng->str,
reinterpret_cast<char const *
>(str_value_unsigned));
318 g_free(str_value_unsigned);
332 if (decl_list->
next) {
360 g_assert(repr !=
nullptr);
361 g_assert(
css !=
nullptr);
362 g_assert(attr !=
nullptr);
373 g_assert(repr !=
nullptr);
374 g_assert(
css !=
nullptr);
375 g_assert(attr !=
nullptr);
390 for (
const auto & iter :
css->attributeList() ) {
Interface for refcounted XML nodes.
virtual Node * parent()=0
Get the parent of this node.
void setAttributeOrRemoveIfEmpty(Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
Change an attribute of this node.
virtual Node * firstChild()=0
Get the first child of this node.
virtual void mergeFrom(Node const *src, char const *key, bool extension=false, bool clean=false)=0
Merge all children of another node with the current.
virtual char const * attribute(char const *key) const =0
Get the string representation of a node's attribute.
Default implementation of the XML node stored in memory.
The declaration of the CRDeclaration class.
CRDeclaration * cr_declaration_parse_list_from_buf(const guchar *a_str, enum CREncoding a_enc)
void cr_declaration_destroy(CRDeclaration *a_this)
guchar * cr_term_to_string(CRTerm const *a_this)
TODO: insert short description here.
std::shared_ptr< Css const > css
static char const *const current
static char const *const parent
void duplicate(InkscapeApplication *app)
static R & release(R &r)
Decrements the reference count of a anchored object.
GType type()
Returns the type used for storing an object of type T inside a value.
NodeType
Enumeration containing all supported node types.
@ ELEMENT_NODE
Regular element node, e.g. <group />.
static cairo_user_data_key_t key
SPCSSAttr * sp_repr_css_attr_new()
Creates an empty SPCSSAttr (a class for manipulating CSS style properties).
void sp_repr_css_write_string(SPCSSAttr *css, Glib::ustring &str)
Write a style attribute string from a list of properties stored in an SPCSAttr object.
void sp_repr_css_merge(SPCSSAttr *dst, SPCSSAttr *src)
Merges two SPCSSAttr's.
SPCSSAttr * sp_repr_css_attr_inherited(Node const *repr, gchar const *attr)
Creates a new SPCSSAttr with one attribute whose value is determined by cascading.
static void sp_repr_css_attr_inherited_recursive(SPCSSAttr *css, Node const *repr, gchar const *attr)
Adds an attribute to an existing SPCSAttr with the cascaded value including all parents.
void sp_repr_css_change(Node *repr, SPCSSAttr *css, gchar const *attr)
Creates a new SPCSAttr with the values filled from a repr, merges in properties from the given SPCSAt...
void sp_repr_css_set(Node *repr, SPCSSAttr *css, gchar const *attr)
Sets an attribute (e.g.
void sp_repr_css_set_property_double(SPCSSAttr *css, gchar const *name, double value)
Set a style property to a new float value (e.g.
void sp_repr_css_attr_unref(SPCSSAttr *css)
Unreferences an SPCSSAttr (will be garbage collected if no references remain).
double sp_repr_css_double_property(SPCSSAttr *css, gchar const *name, double defval)
Return the value of a style property if property define, or a default value if not.
SPCSSAttr * sp_repr_css_attr(Node const *repr, gchar const *attr)
Creates a new SPCSSAttr with one attribute (i.e.
void sp_repr_css_set_property_string(SPCSSAttr *css, char const *name, std::string const &value)
Set a style property to a standard string.
void sp_repr_css_print(SPCSSAttr *css)
Loops through a List of style properties, printing key/value pairs.
void sp_repr_css_change_recursive(Node *repr, SPCSSAttr *css, gchar const *attr)
char const * sp_repr_css_property(SPCSSAttr *css, gchar const *name, gchar const *defval)
Returns a character string of the value of a given style property or a default value if the attribute...
SPCSSAttr * sp_repr_css_attr_unset_all(SPCSSAttr *css)
Return a new SPCSSAttr with all the properties found in the input SPCSSAttr unset.
static void sp_repr_css_add_components(SPCSSAttr *css, Node const *repr, gchar const *attr)
Adds components (style properties) to an existing SPCSAttr from the specified attribute's data (nomin...
void sp_repr_css_unset_property(SPCSSAttr *css, gchar const *name)
Set a style property to "inkscape:unset".
bool sp_repr_css_property_is_unset(SPCSSAttr *css, gchar const *name)
Returns true if a style property is present and its value is unset.
static void sp_repr_css_merge_from_decl(SPCSSAttr *css, CRDeclaration const *const decl)
Merges style properties as parsed by libcroco into an existing SPCSSAttr.
static void sp_repr_css_merge_from_decl_list(SPCSSAttr *css, CRDeclaration const *const decl_list)
Merges style properties as parsed by libcroco into an existing SPCSSAttr.
void sp_repr_css_set_property(SPCSSAttr *css, gchar const *name, gchar const *value)
Set a style property to a new value (e.g.
void sp_repr_css_attr_add_from_string(SPCSSAttr *css, gchar const *p)
Use libcroco to parse a string for CSS properties and then merge them into an existing SPCSSAttr.
C facade to Inkscape::XML::Node.
Inkscape::XML::SimpleDocument - generic XML document implementation.
SPCSSAttr - interface for CSS Attributes.
Interface for XML documents.
CRString *CRTerm * value
The property.