summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <>2016-07-13 02:42:57 +0000
committerkamalpreetgrewal <grewalkamal005@gmail.com>2016-07-13 02:42:57 +0000
commit798cda4430354143e90fb7ce81c3593a6dc24bc5 (patch)
tree0daf3d324bf8f2ebc0ac3300bdcb6fff3a6251ad /src
parentMerge changes from trunk (diff)
downloadinkscape-798cda4430354143e90fb7ce81c3593a6dc24bc5.tar.gz
inkscape-798cda4430354143e90fb7ce81c3593a6dc24bc5.zip
Propagate changes to object tree with changes in style element
(bzr r14949.1.46)
Diffstat (limited to 'src')
-rw-r--r--src/path-chemistry.cpp6
-rw-r--r--src/sp-flowtext.cpp2
-rw-r--r--src/sp-object.cpp4
-rw-r--r--src/sp-style-elem.cpp25
-rw-r--r--src/style-internal.cpp200
-rw-r--r--src/style-internal.h36
-rw-r--r--src/style.cpp160
-rw-r--r--src/style.h7
8 files changed, 233 insertions, 207 deletions
diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp
index 1a345b565..f66c8cbf5 100644
--- a/src/path-chemistry.cpp
+++ b/src/path-chemistry.cpp
@@ -493,7 +493,7 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 /*text_grouping_policy*/)
/* Whole text's style */
Glib::ustring style_str =
- item->style->write( SP_STYLE_FLAG_IFDIFF, item->parent ? item->parent->style : NULL); // TODO investigate posibility
+ item->style->write( SP_STYLE_FLAG_IFDIFF, SP_STYLE_SRC_UNSET, item->parent ? item->parent->style : NULL); // TODO investigate posibility
g_repr->setAttribute("style", style_str.c_str());
Inkscape::Text::Layout::iterator iter = te_get_layout(item)->begin();
@@ -514,7 +514,7 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 /*text_grouping_policy*/)
pos_obj = pos_obj->parent; // SPStrings don't have style
}
Glib::ustring style_str =
- pos_obj->style->write( SP_STYLE_FLAG_IFDIFF, pos_obj->parent ? pos_obj->parent->style : NULL); // TODO investigate posibility
+ pos_obj->style->write( SP_STYLE_FLAG_IFDIFF, SP_STYLE_SRC_UNSET, pos_obj->parent ? pos_obj->parent->style : NULL); // TODO investigate posibility
// get path from iter to iter_next:
SPCurve *curve = te_get_layout(item)->convertToCurves(iter, iter_next);
@@ -573,7 +573,7 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 /*text_grouping_policy*/)
/* Style */
Glib::ustring style_str =
- item->style->write( SP_STYLE_FLAG_IFDIFF, item->parent ? item->parent->style : NULL); // TODO investigate posibility
+ item->style->write( SP_STYLE_FLAG_IFDIFF, SP_STYLE_SRC_UNSET, item->parent ? item->parent->style : NULL); // TODO investigate posibility
repr->setAttribute("style", style_str.c_str());
/* Mask */
diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp
index 51fb3ae89..90d4be87c 100644
--- a/src/sp-flowtext.cpp
+++ b/src/sp-flowtext.cpp
@@ -540,7 +540,7 @@ Inkscape::XML::Node *SPFlowtext::getAsText()
this->layout.getSourceOfCharacter(it, &rawptr, &span_text_start_iter);
SPObject *source_obj = reinterpret_cast<SPObject *>(rawptr);
- Glib::ustring style_text = (dynamic_cast<SPString *>(source_obj) ? source_obj->parent : source_obj)->style->write( SP_STYLE_FLAG_IFDIFF, this->style);
+ Glib::ustring style_text = (dynamic_cast<SPString *>(source_obj) ? source_obj->parent : source_obj)->style->write( SP_STYLE_FLAG_IFDIFF, SP_STYLE_SRC_UNSET, this->style);
if (!style_text.empty()) {
span_tspan->setAttribute("style", style_text.c_str());
}
diff --git a/src/sp-object.cpp b/src/sp-object.cpp
index d1659eedc..6d36ec833 100644
--- a/src/sp-object.cpp
+++ b/src/sp-object.cpp
@@ -1043,7 +1043,9 @@ Inkscape::XML::Node* SPObject::write(Inkscape::XML::Document *doc, Inkscape::XML
}
if (style) {
- Glib::ustring s = style->write(SP_STYLE_FLAG_IFSET);
+ // Write if property set by style attribute in this object
+ Glib::ustring s =
+ style->write(SP_STYLE_FLAG_IFSET & SP_STYLE_FLAG_IFSRC, SP_STYLE_SRC_STYLE_PROP);
// Check for valid attributes. This may be time consuming.
// It is useful, though, for debugging Inkscape code.
diff --git a/src/sp-style-elem.cpp b/src/sp-style-elem.cpp
index 80e45677c..0f5af619b 100644
--- a/src/sp-style-elem.cpp
+++ b/src/sp-style-elem.cpp
@@ -3,6 +3,7 @@
#include "xml/repr.h"
#include "document.h"
#include "sp-style-elem.h"
+#include "sp-root.h"
#include "attributes.h"
#include "style.h"
using Inkscape::XML::TEXT_NODE;
@@ -64,6 +65,7 @@ content_changed_cb(Inkscape::XML::Node *, gchar const *, gchar const *,
SPObject *obj = reinterpret_cast<SPObject *>(data);
g_assert(data != NULL);
obj->read_content();
+ obj->document->getRoot()->emitModified( SP_OBJECT_MODIFIED_CASCADE );
}
static void
@@ -249,6 +251,19 @@ property_cb(CRDocHandler *const a_handler,
g_return_if_fail(append_status == CR_OK);
}
+void update_style_recursively( SPObject *object ) {
+ if (object) {
+ // std::cout << "update_style_recursively: "
+ // << (object->getId()?object->getId():"null") << std::endl;
+ if (object->style) {
+ object->style->readFromObject( object );
+ }
+ for (SPObject *child = object->children; child; child = child->next) {
+ update_style_recursively( child );
+ }
+ }
+}
+
void SPStyleElem::read_content() {
/* fixme: If there's more than one <style> element in a document, then the document stylesheet
* will be set to a random one of them, even switching between them.
@@ -315,9 +330,13 @@ void SPStyleElem::read_content() {
// the <style> is a child of the object that uses a style from it. It just forces the parent of
// <style> to reread its style as soon as the stylesheet is fully loaded. Naturally, this won't
// work if the user of the stylesheet is its grandparent or precedent.
- if ( parent ) {
- parent->style->readFromObject( parent );
- }
+ // if ( parent ) {
+ // parent->style->readFromObject( parent );
+ // }
+
+ // If style sheet has changed, we need to cascade the entire object tree, top down
+ // Get root, read style, loop through children
+ update_style_recursively( (SPObject *)document->getRoot() );
}
/**
diff --git a/src/style-internal.cpp b/src/style-internal.cpp
index 62b0de52d..f25eb730e 100644
--- a/src/style-internal.cpp
+++ b/src/style-internal.cpp
@@ -58,6 +58,20 @@ using Inkscape::CSSOStringStream;
// SPIBase --------------------------------------------------------------
+// Standard criteria for writing a property
+// dfp == different from parent
+inline bool should_write( guint const flags, bool set, bool dfp, bool src) {
+
+ bool should_write = false;
+ if ( ((flags & SP_STYLE_FLAG_ALWAYS)) ||
+ ((flags & SP_STYLE_FLAG_IFSET) && set && src) ||
+ ((flags & SP_STYLE_FLAG_IFDIFF) && set && src && dfp)) {
+ should_write = true;
+ }
+ return should_write;
+}
+
+
// SPIFloat -------------------------------------------------------------
@@ -80,14 +94,12 @@ SPIFloat::read( gchar const *str ) {
}
const Glib::ustring
-SPIFloat::write( guint const flags, SPIBase const *const base) const {
+SPIFloat::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const {
SPIFloat const *const my_base = dynamic_cast<const SPIFloat*>(base);
- if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
- ((flags & SP_STYLE_FLAG_IFSET) && this->set) ||
- ((flags & SP_STYLE_FLAG_IFDIFF) && this->set
- && (!my_base->set || this != my_base )))
- {
+ bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent
+ bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC));
+ if (should_write(flags, set, dfp, src)) {
if (this->inherit) {
return (name + ":inherit;");
} else {
@@ -156,14 +168,12 @@ SPIScale24::read( gchar const *str ) {
}
const Glib::ustring
-SPIScale24::write( guint const flags, SPIBase const *const base) const {
+SPIScale24::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const {
SPIScale24 const *const my_base = dynamic_cast<const SPIScale24*>(base);
- if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
- ((flags & SP_STYLE_FLAG_IFSET) && this->set) ||
- ((flags & SP_STYLE_FLAG_IFDIFF) && this->set
- && (!my_base->set || this != my_base )))
- {
+ bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent
+ bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC));
+ if (should_write(flags, set, dfp, src)) {
if (this->inherit) {
return (name + ":inherit;");
} else {
@@ -308,14 +318,12 @@ SPILength::read( gchar const *str ) {
}
const Glib::ustring
-SPILength::write( guint const flags, SPIBase const *const base) const {
+SPILength::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const {
SPILength const *const my_base = dynamic_cast<const SPILength*>(base);
- if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
- ((flags & SP_STYLE_FLAG_IFSET) && this->set) ||
- ((flags & SP_STYLE_FLAG_IFDIFF) && this->set
- && (!my_base->set || this != my_base )))
- {
+ bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent
+ bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC));
+ if (should_write(flags, set, dfp, src)) {
if (this->inherit) {
return (name + ":inherit;");
} else {
@@ -465,18 +473,16 @@ SPILengthOrNormal::read( gchar const *str ) {
};
const Glib::ustring
-SPILengthOrNormal::write( guint const flags, SPIBase const *const base) const {
+SPILengthOrNormal::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const {
SPILength const *const my_base = dynamic_cast<const SPILength*>(base);
- if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
- ((flags & SP_STYLE_FLAG_IFSET) && this->set) ||
- ((flags & SP_STYLE_FLAG_IFDIFF) && this->set
- && (!my_base->set || this != my_base )))
- {
+ bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent
+ bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC));
+ if (should_write(flags, set, dfp, src)) {
if (this->normal) {
return (name + ":normal;");
} else {
- return SPILength::write(flags, base);
+ return SPILength::write(flags, style_src_req, base);
}
}
return Glib::ustring("");
@@ -552,14 +558,12 @@ SPIEnum::read( gchar const *str ) {
}
const Glib::ustring
-SPIEnum::write( guint const flags, SPIBase const *const base) const {
+SPIEnum::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const {
SPIEnum const *const my_base = dynamic_cast<const SPIEnum*>(base);
- if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
- ((flags & SP_STYLE_FLAG_IFSET) && this->set) ||
- ((flags & SP_STYLE_FLAG_IFDIFF) && this->set
- && (!my_base->set || this != my_base )))
- {
+ bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent
+ bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC));
+ if (should_write(flags, set, dfp, src)) {
if (this->inherit) {
return (name + ":inherit;");
}
@@ -691,14 +695,12 @@ SPIEnumBits::read( gchar const *str ) {
}
const Glib::ustring
-SPIEnumBits::write( guint const flags, SPIBase const *const base) const {
+SPIEnumBits::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const {
SPIEnum const *const my_base = dynamic_cast<const SPIEnum*>(base);
- if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
- ((flags & SP_STYLE_FLAG_IFSET) && this->set) ||
- ((flags & SP_STYLE_FLAG_IFDIFF) && this->set
- && (!my_base->set || this != my_base )))
- {
+ bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent
+ bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC));
+ if (should_write(flags, set, dfp, src)) {
if (this->inherit) {
return (name + ":inherit;");
}
@@ -762,14 +764,12 @@ SPILigatures::read( gchar const *str ) {
}
const Glib::ustring
-SPILigatures::write( guint const flags, SPIBase const *const base) const {
+SPILigatures::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const {
SPIEnum const *const my_base = dynamic_cast<const SPIEnum*>(base);
- if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
- ((flags & SP_STYLE_FLAG_IFSET) && this->set) ||
- ((flags & SP_STYLE_FLAG_IFDIFF) && this->set
- && (!my_base->set || this != my_base )))
- {
+ bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent
+ bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC));
+ if (should_write(flags, set, dfp, src)) {
if (this->inherit) {
return (name + ":inherit;");
}
@@ -863,14 +863,12 @@ SPINumeric::read( gchar const *str ) {
}
const Glib::ustring
-SPINumeric::write( guint const flags, SPIBase const *const base) const {
+SPINumeric::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const {
SPIEnum const *const my_base = dynamic_cast<const SPIEnum*>(base);
- if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
- ((flags & SP_STYLE_FLAG_IFSET) && this->set) ||
- ((flags & SP_STYLE_FLAG_IFDIFF) && this->set
- && (!my_base->set || this != my_base )))
- {
+ bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent
+ bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC));
+ if (should_write(flags, set, dfp, src)) {
if (this->inherit) {
return (name + ":inherit;");
}
@@ -934,14 +932,12 @@ SPIString::read( gchar const *str ) {
// This routine is actually rarely used. Writing is done usually
// in sp_repr_css_write_string...
const Glib::ustring
-SPIString::write( guint const flags, SPIBase const *const base) const {
+SPIString::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const {
SPIString const *const my_base = dynamic_cast<const SPIString*>(base);
- if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
- ((flags & SP_STYLE_FLAG_IFSET) && this->set) ||
- ((flags & SP_STYLE_FLAG_IFDIFF) && this->set
- && (!my_base->set || this != my_base )))
- {
+ bool dfp = (!inherits || !my_base || (my_base != this) ); // Different from parent
+ bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC));
+ if (should_write(flags, set, dfp, src)) {
if (this->inherit) {
return (name + ":inherit;");
} else {
@@ -1045,14 +1041,12 @@ void SPIColor::read( gchar const *str ) {
}
const Glib::ustring
-SPIColor::write( guint const flags, SPIBase const *const base) const {
+SPIColor::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const {
SPIColor const *const my_base = dynamic_cast<const SPIColor*>(base);
- if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
- ((flags & SP_STYLE_FLAG_IFSET) && this->set) ||
- ((flags & SP_STYLE_FLAG_IFDIFF) && this->set
- && (!my_base->set || this != my_base )))
- {
+ bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent
+ bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC));
+ if (should_write(flags, set, dfp, src)) {
CSSOStringStream css;
if (this->currentcolor) {
@@ -1274,14 +1268,12 @@ SPIPaint::read( gchar const *str, SPStyle &style_in, SPDocument *document_in ) {
}
const Glib::ustring
-SPIPaint::write( guint const flags, SPIBase const *const base) const {
+SPIPaint::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const {
SPIPaint const *const my_base = dynamic_cast<const SPIPaint*>(base);
- if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
- ((flags & SP_STYLE_FLAG_IFSET) && this->set) ||
- ((flags & SP_STYLE_FLAG_IFDIFF) && this->set
- && (!my_base->set || this != my_base )))
- {
+ bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent
+ bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC));
+ if (should_write(flags, set, dfp, src)) {
CSSOStringStream css;
if (this->inherit) {
@@ -1546,14 +1538,12 @@ SPIPaintOrder::read( gchar const *str ) {
}
const Glib::ustring
-SPIPaintOrder::write( guint const flags, SPIBase const *const base) const {
+SPIPaintOrder::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const {
SPIPaintOrder const *const my_base = dynamic_cast<const SPIPaintOrder*>(base);
- if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
- ((flags & SP_STYLE_FLAG_IFSET) && this->set) ||
- ((flags & SP_STYLE_FLAG_IFDIFF) && this->set
- && (!my_base->set || this != my_base )))
- {
+ bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent
+ bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC));
+ if (should_write(flags, set, dfp, src)) {
CSSOStringStream css;
if (this->inherit) {
@@ -1694,14 +1684,14 @@ SPIFilter::read( gchar const *str ) {
}
}
-const Glib::ustring SPIFilter::write( guint const flags, SPIBase const *const /*base*/) const
+const Glib::ustring SPIFilter::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const /*base*/) const
{
// TODO: fix base
//SPILength const *const my_base = dynamic_cast<const SPILength*>(base);
- if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
- ((flags & SP_STYLE_FLAG_IFSET) && this->set) ||
- ((flags & SP_STYLE_FLAG_IFDIFF) && this->set))
- {
+ // bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent
+ bool dfp = true;
+ bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC));
+ if (should_write(flags, set, dfp, src)) {
if (this->inherit) {
return (name + ":inherit;");
} else if(this->href && this->href->getURI()) {
@@ -1833,14 +1823,12 @@ SPIDashArray::read( gchar const *str ) {
}
const Glib::ustring
-SPIDashArray::write( guint const flags, SPIBase const *const base) const {
+SPIDashArray::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const {
SPIDashArray const *const my_base = dynamic_cast<const SPIDashArray*>(base);
- if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
- ((flags & SP_STYLE_FLAG_IFSET) && this->set) ||
- ((flags & SP_STYLE_FLAG_IFDIFF) && this->set
- && (!my_base->set || this != my_base )))
- {
+ bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent
+ bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC));
+ if (should_write(flags, set, dfp, src)) {
if (this->inherit) {
return (name + ":inherit;");
} else if (this->values.empty() ) {
@@ -1950,14 +1938,12 @@ SPIFontSize::read( gchar const *str ) {
}
const Glib::ustring
-SPIFontSize::write( guint const flags, SPIBase const *const base) const {
+SPIFontSize::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const {
SPIFontSize const *const my_base = dynamic_cast<const SPIFontSize*>(base);
- if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
- ((flags & SP_STYLE_FLAG_IFSET) && this->set) ||
- ((flags & SP_STYLE_FLAG_IFDIFF) && this->set
- && (!my_base->set || this != my_base )))
- {
+ bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent
+ bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC));
+ if (should_write(flags, set, dfp, src)) {
CSSOStringStream css;
if (this->inherit) {
@@ -2244,7 +2230,7 @@ SPIFont::read( gchar const *str ) {
}
}
-const Glib::ustring SPIFont::write( guint const /*flags*/, SPIBase const *const /*base*/) const
+const Glib::ustring SPIFont::write( guint const /*flags*/, SPStyleSrc const & /*style_src_req*/, SPIBase const *const /*base*/) const
{
// At the moment, do nothing. We could add a preference to write out
// 'font' shorthand rather than longhand properties.
@@ -2321,14 +2307,12 @@ SPIBaselineShift::read( gchar const *str ) {
}
const Glib::ustring
-SPIBaselineShift::write( guint const flags, SPIBase const *const base) const {
+SPIBaselineShift::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const {
SPIBaselineShift const *const my_base = dynamic_cast<const SPIBaselineShift*>(base);
- if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
- ((flags & SP_STYLE_FLAG_IFSET) && this->set) ||
- ((flags & SP_STYLE_FLAG_IFDIFF) && this->set
- && (!my_base->set || !this->isZero() )))
- {
+ bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent
+ bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC));
+ if (should_write(flags, set, dfp, src)) {
CSSOStringStream css;
if (this->inherit) {
@@ -2512,13 +2496,11 @@ SPITextDecorationLine::read( gchar const *str ) {
}
const Glib::ustring
-SPITextDecorationLine::write( guint const flags, SPIBase const *const base) const {
+SPITextDecorationLine::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const {
SPITextDecorationLine const *const my_base = dynamic_cast<const SPITextDecorationLine*>(base);
- if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
- ((flags & SP_STYLE_FLAG_IFSET) && this->set) ||
- ((flags & SP_STYLE_FLAG_IFDIFF) && this->set
- && (!my_base->set || this != my_base )))
- {
+ bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent
+ bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC));
+ if (should_write(flags, set, dfp, src)) {
Inkscape::CSSOStringStream os;
os << name << ":";
if( inherit ) {
@@ -2644,13 +2626,11 @@ SPITextDecorationStyle::read( gchar const *str ) {
}
const Glib::ustring
-SPITextDecorationStyle::write( guint const flags, SPIBase const *const base) const {
+SPITextDecorationStyle::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const {
SPITextDecorationStyle const *const my_base = dynamic_cast<const SPITextDecorationStyle*>(base);
- if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
- ((flags & SP_STYLE_FLAG_IFSET) && this->set) ||
- ((flags & SP_STYLE_FLAG_IFDIFF) && this->set
- && (!my_base->set || this != my_base )))
- {
+ bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent
+ bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC));
+ if (should_write(flags, set, dfp, src)) {
Inkscape::CSSOStringStream os;
os << name << ":";
if( inherit ) {
@@ -2800,7 +2780,7 @@ SPITextDecoration::read( gchar const *str ) {
// Returns CSS2 'text-decoration' (using settings in SPTextDecorationLine)
// This is required until all SVG renderers support CSS3 'text-decoration'
const Glib::ustring
-SPITextDecoration::write( guint const flags, SPIBase const *const base) const {
+SPITextDecoration::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const {
SPITextDecoration const *const my_base = dynamic_cast<const SPITextDecoration*>(base);
if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
((flags & SP_STYLE_FLAG_IFSET) && style->text_decoration_line.set) ||
diff --git a/src/style-internal.h b/src/style-internal.h
index 6cc8c6c4e..69b03f503 100644
--- a/src/style-internal.h
+++ b/src/style-internal.h
@@ -35,12 +35,13 @@ struct SPStyleEnum;
static const unsigned SP_STYLE_FLAG_ALWAYS (1 << 2);
static const unsigned SP_STYLE_FLAG_IFSET (1 << 0);
static const unsigned SP_STYLE_FLAG_IFDIFF (1 << 1);
+static const unsigned SP_STYLE_FLAG_IFSRC (1 << 3); // If source matches
enum SPStyleSrc {
SP_STYLE_SRC_UNSET,
- SP_STYLE_SRC_STYLE_PROP,
- SP_STYLE_SRC_STYLE_SHEET,
- SP_STYLE_SRC_ATTRIBUTE
+ SP_STYLE_SRC_ATTRIBUTE, // fill="red"
+ SP_STYLE_SRC_STYLE_PROP, // style="fill:red"
+ SP_STYLE_SRC_STYLE_SHEET, // .red { fill:red; }
};
/* General comments:
@@ -77,6 +78,7 @@ enum SPStyleSrc {
* IFSET: Write a property if 'set' flag is true, otherwise return empty string.
* IFDIFF: Write a property if computed values are different, otherwise return empty string,
* This is only used for text!!
+ * IFSRC Write a property if the source matches the requested source (style sheet, etc.).
*
* read(): Set a property value from a string.
* clear(): Set a property to its default value and set the 'set' flag to false.
@@ -127,17 +129,19 @@ public:
{}
virtual void read( gchar const *str ) = 0;
- virtual void readIfUnset( gchar const *str ) {
+ virtual void readIfUnset( gchar const *str, SPStyleSrc const &source = SP_STYLE_SRC_STYLE_PROP ) {
if ( !set ) {
read( str );
+ style_src = source;
}
}
virtual void readAttribute( Inkscape::XML::Node *repr ) {
- readIfUnset( repr->attribute( name.c_str() ) );
+ readIfUnset( repr->attribute( name.c_str() ), SP_STYLE_SRC_ATTRIBUTE );
}
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPIBase const *const base = NULL ) const = 0;
virtual void clear() {
set = false, inherit = false;
@@ -176,7 +180,7 @@ public:
unsigned inherits : 1; // Property inherits by default from parent.
unsigned set : 1; // Property has been explicitly set (vs. inherited).
unsigned inherit : 1; // Property value set to 'inherit'.
- SPStyleSrc style_src : 2; // Source (attribute, style attribute, style-sheet). NOT USED YET FIX ME
+ SPStyleSrc style_src : 2; // Source (attribute, style attribute, style-sheet).
// To do: make private after g_asserts removed
public:
@@ -202,6 +206,7 @@ public:
virtual ~SPIFloat() {}
virtual void read( gchar const *str );
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPIBase const *const base = NULL ) const;
virtual void clear() {
SPIBase::clear();
@@ -283,6 +288,7 @@ public:
virtual void read( gchar const *str );
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPIBase const *const base = NULL ) const;
virtual void clear() {
SPIBase::clear();
@@ -355,6 +361,7 @@ public:
virtual void read( gchar const *str );
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPIBase const *const base = NULL ) const;
virtual void clear() {
SPIBase::clear();
@@ -411,6 +418,7 @@ public:
virtual void read( gchar const *str );
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPIBase const *const base = NULL ) const;
virtual void clear() {
SPILength::clear();
@@ -474,6 +482,7 @@ public:
virtual void read( gchar const *str );
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPIBase const *const base = NULL ) const;
virtual void clear() {
SPIBase::clear();
@@ -528,6 +537,7 @@ public:
virtual void read( gchar const *str );
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPIBase const *const base = NULL ) const;
};
@@ -554,6 +564,7 @@ public:
virtual void read( gchar const *str );
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPIBase const *const base = NULL ) const;
};
@@ -577,6 +588,7 @@ public:
virtual void read( gchar const *str );
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPIBase const *const base = NULL ) const;
};
@@ -606,6 +618,7 @@ public:
virtual void read( gchar const *str );
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPIBase const *const base = NULL ) const;
virtual void clear(); // TODO check about value and value_default
virtual void cascade( const SPIBase* const parent );
@@ -653,6 +666,7 @@ public:
virtual void read( gchar const *str );
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPIBase const *const base = NULL ) const;
virtual void clear() {
SPIBase::clear();
@@ -734,6 +748,7 @@ public:
virtual void read( gchar const *str );
virtual void read( gchar const *str, SPStyle &style, SPDocument *document = 0);
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPIBase const *const base = NULL ) const;
virtual void clear();
virtual void reset( bool init ); // Used internally when reading or cascading
@@ -833,6 +848,7 @@ public:
virtual void read( gchar const *str );
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPIBase const *const base = NULL ) const;
virtual void clear() {
SPIBase::clear();
@@ -885,6 +901,7 @@ public:
virtual void read( gchar const *str );
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPIBase const *const base = NULL ) const;
virtual void clear() {
SPIBase::clear();
@@ -924,6 +941,7 @@ public:
virtual ~SPIFilter();
virtual void read( gchar const *str );
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPIBase const *const base = NULL ) const;
virtual void clear();
virtual void cascade( const SPIBase* const parent );
@@ -968,6 +986,7 @@ public:
virtual void read( gchar const *str );
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPIBase const *const base = NULL ) const;
virtual void clear() {
SPIBase::clear();
@@ -1024,6 +1043,7 @@ public:
virtual void read( gchar const *str );
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPIBase const *const base = NULL ) const;
virtual void clear() {
SPIBase::clear();
@@ -1068,6 +1088,7 @@ public:
virtual void read( gchar const *str );
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPIBase const *const base = NULL ) const;
virtual void clear() {
SPIBase::clear();
@@ -1124,6 +1145,7 @@ public:
virtual void read( gchar const *str );
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPIBase const *const base = NULL ) const;
virtual void clear() {
SPIBase::clear();
@@ -1171,6 +1193,7 @@ public:
virtual void read( gchar const *str );
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPIBase const *const base = NULL ) const;
virtual void clear() {
SPIBase::clear();
@@ -1227,6 +1250,7 @@ public:
virtual void read( gchar const *str );
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPIBase const *const base = NULL ) const;
virtual void clear() {
SPIBase::clear();
diff --git a/src/style.cpp b/src/style.cpp
index c24818f2a..022b3a580 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -685,22 +685,22 @@ SPStyle::readFromPrefs(Glib::ustring const &path) {
// Matches sp_style_merge_property(SPStyle *style, gint id, gchar const *val)
void
-SPStyle::readIfUnset( gint id, gchar const *val ) {
+SPStyle::readIfUnset( gint id, gchar const *val, SPStyleSrc const &source ) {
- // std::cout << "SPStyle::readIfUnset: Entrance: " << (val?val:"null") << std::endl;
+ // std::cout << "SPStyle::readIfUnset: Entrance: " << id << ": " << (val?val:"null") << std::endl;
// To Do: If it is not too slow, use std::map instead of std::vector inorder to remove switch()
// (looking up SP_PROP_xxxx already uses a hash).
g_return_if_fail(val != NULL);
switch (id) {
case SP_PROP_INKSCAPE_FONT_SPEC:
- font_specification.readIfUnset( val );
+ font_specification.readIfUnset( val, source );
break;
case SP_PROP_FONT_FAMILY:
- font_family.readIfUnset( val );
+ font_family.readIfUnset( val, source );
break;
case SP_PROP_FONT_SIZE:
- font_size.readIfUnset( val );
+ font_size.readIfUnset( val, source );
break;
case SP_PROP_FONT_SIZE_ADJUST:
if (strcmp(val, "none") != 0) {
@@ -708,105 +708,105 @@ SPStyle::readIfUnset( gint id, gchar const *val ) {
}
break;
case SP_PROP_FONT_STYLE:
- font_style.readIfUnset( val );
+ font_style.readIfUnset( val, source );
break;
case SP_PROP_FONT_VARIANT:
- font_variant.readIfUnset( val );
+ font_variant.readIfUnset( val, source );
break;
case SP_PROP_FONT_WEIGHT:
- font_weight.readIfUnset( val );
+ font_weight.readIfUnset( val, source );
break;
case SP_PROP_FONT_STRETCH:
- font_stretch.readIfUnset( val );
+ font_stretch.readIfUnset( val, source );
break;
case SP_PROP_FONT:
- font.readIfUnset( val );
+ font.readIfUnset( val, source );
break;
/* Font Variants CSS 3 */
case SP_PROP_FONT_VARIANT_LIGATURES:
- font_variant_ligatures.readIfUnset( val );
+ font_variant_ligatures.readIfUnset( val, source );
break;
case SP_PROP_FONT_VARIANT_POSITION:
- font_variant_position.readIfUnset( val );
+ font_variant_position.readIfUnset( val, source );
break;
case SP_PROP_FONT_VARIANT_CAPS:
- font_variant_caps.readIfUnset( val );
+ font_variant_caps.readIfUnset( val, source );
break;
case SP_PROP_FONT_VARIANT_NUMERIC:
- font_variant_numeric.readIfUnset( val );
+ font_variant_numeric.readIfUnset( val, source );
break;
case SP_PROP_FONT_VARIANT_ALTERNATES:
- font_variant_alternates.readIfUnset( val );
+ font_variant_alternates.readIfUnset( val, source );
break;
case SP_PROP_FONT_VARIANT_EAST_ASIAN:
- font_variant_east_asian.readIfUnset( val );
+ font_variant_east_asian.readIfUnset( val, source );
break;
case SP_PROP_FONT_FEATURE_SETTINGS:
- font_feature_settings.readIfUnset( val );
+ font_feature_settings.readIfUnset( val, source );
break;
/* Text */
case SP_PROP_TEXT_INDENT:
- text_indent.readIfUnset( val );
+ text_indent.readIfUnset( val, source );
break;
case SP_PROP_TEXT_ALIGN:
- text_align.readIfUnset( val );
+ text_align.readIfUnset( val, source );
break;
case SP_PROP_TEXT_DECORATION:
- text_decoration.readIfUnset( val );
+ text_decoration.readIfUnset( val, source );
break;
case SP_PROP_TEXT_DECORATION_LINE:
- text_decoration_line.readIfUnset( val );
+ text_decoration_line.readIfUnset( val, source );
break;
case SP_PROP_TEXT_DECORATION_STYLE:
- text_decoration_style.readIfUnset( val );
+ text_decoration_style.readIfUnset( val, source );
break;
case SP_PROP_TEXT_DECORATION_COLOR:
- text_decoration_color.readIfUnset( val );
+ text_decoration_color.readIfUnset( val, source );
break;
case SP_PROP_LINE_HEIGHT:
- line_height.readIfUnset( val );
+ line_height.readIfUnset( val, source );
break;
case SP_PROP_LETTER_SPACING:
- letter_spacing.readIfUnset( val );
+ letter_spacing.readIfUnset( val, source );
break;
case SP_PROP_WORD_SPACING:
- word_spacing.readIfUnset( val );
+ word_spacing.readIfUnset( val, source );
break;
case SP_PROP_TEXT_TRANSFORM:
- text_transform.readIfUnset( val );
+ text_transform.readIfUnset( val, source );
break;
/* Text (css3) */
case SP_PROP_DIRECTION:
- direction.readIfUnset( val );
+ direction.readIfUnset( val, source );
break;
case SP_PROP_WRITING_MODE:
- writing_mode.readIfUnset( val );
+ writing_mode.readIfUnset( val, source );
break;
case SP_PROP_TEXT_ORIENTATION:
- text_orientation.readIfUnset( val );
+ text_orientation.readIfUnset( val, source );
break;
case SP_PROP_TEXT_ANCHOR:
- text_anchor.readIfUnset( val );
+ text_anchor.readIfUnset( val, source );
break;
case SP_PROP_WHITE_SPACE:
- white_space.readIfUnset( val );
+ white_space.readIfUnset( val, source );
break;
case SP_PROP_SHAPE_INSIDE:
- shape_inside.readIfUnset( val );
+ shape_inside.readIfUnset( val, source );
break;
case SP_PROP_SHAPE_PADDING:
- shape_padding.readIfUnset( val );
+ shape_padding.readIfUnset( val, source );
break;
case SP_PROP_DOMINANT_BASELINE:
- dominant_baseline.readIfUnset( val );
+ dominant_baseline.readIfUnset( val, source );
break;
case SP_PROP_BASELINE_SHIFT:
- baseline_shift.readIfUnset( val );
+ baseline_shift.readIfUnset( val, source );
break;
case SP_PROP_TEXT_RENDERING:
- text_rendering.readIfUnset( val );
+ text_rendering.readIfUnset( val, source );
break;
case SP_PROP_ALIGNMENT_BASELINE:
g_warning("Unimplemented style property SP_PROP_ALIGNMENT_BASELINE: value: %s", val);
@@ -825,25 +825,25 @@ SPStyle::readIfUnset( gint id, gchar const *val ) {
g_warning("Unimplemented style property SP_PROP_CLIP: value: %s", val);
break;
case SP_PROP_COLOR:
- color.readIfUnset( val );
+ color.readIfUnset( val, source );
break;
case SP_PROP_CURSOR:
g_warning("Unimplemented style property SP_PROP_CURSOR: value: %s", val);
break;
case SP_PROP_DISPLAY:
- display.readIfUnset( val );
+ display.readIfUnset( val, source );
break;
case SP_PROP_OVERFLOW:
- overflow.readIfUnset( val );
+ overflow.readIfUnset( val, source );
break;
case SP_PROP_VISIBILITY:
- visibility.readIfUnset( val );
+ visibility.readIfUnset( val, source );
break;
case SP_PROP_ISOLATION:
- isolation.readIfUnset( val );
+ isolation.readIfUnset( val, source );
break;
case SP_PROP_MIX_BLEND_MODE:
- mix_blend_mode.readIfUnset( val );
+ mix_blend_mode.readIfUnset( val, source );
break;
/* SVG */
@@ -861,7 +861,7 @@ SPStyle::readIfUnset( gint id, gchar const *val ) {
this->object->getRepr()->setAttribute("clip-path", val);
break;
case SP_PROP_CLIP_RULE:
- clip_rule.readIfUnset( val );
+ clip_rule.readIfUnset( val, source );
break;
case SP_PROP_MASK:
/** \todo
@@ -873,14 +873,14 @@ SPStyle::readIfUnset( gint id, gchar const *val ) {
this->object->getRepr()->setAttribute("mask", val);
break;
case SP_PROP_OPACITY:
- opacity.readIfUnset( val );
+ opacity.readIfUnset( val, source );
break;
case SP_PROP_ENABLE_BACKGROUND:
- enable_background.readIfUnset( val );
+ enable_background.readIfUnset( val, source );
break;
/* Filter */
case SP_PROP_FILTER:
- if( !filter.inherit ) filter.readIfUnset( val );
+ if( !filter.inherit ) filter.readIfUnset( val, source );
break;
case SP_PROP_FLOOD_COLOR:
g_warning("Unimplemented style property SP_PROP_FLOOD_COLOR: value: %s", val);
@@ -905,83 +905,83 @@ SPStyle::readIfUnset( gint id, gchar const *val ) {
/* Paint */
case SP_PROP_COLOR_INTERPOLATION:
// We read it but issue warning
- color_interpolation.readIfUnset( val );
+ color_interpolation.readIfUnset( val, source );
if( color_interpolation.value != SP_CSS_COLOR_INTERPOLATION_SRGB ) {
g_warning("Inkscape currently only supports color-interpolation = sRGB");
}
break;
case SP_PROP_COLOR_INTERPOLATION_FILTERS:
- color_interpolation_filters.readIfUnset( val );
+ color_interpolation_filters.readIfUnset( val, source );
break;
case SP_PROP_COLOR_PROFILE:
g_warning("Unimplemented style property SP_PROP_COLOR_PROFILE: value: %s", val);
break;
case SP_PROP_COLOR_RENDERING:
- color_rendering.readIfUnset( val );
+ color_rendering.readIfUnset( val, source );
break;
case SP_PROP_SOLID_COLOR:
- solid_color.readIfUnset( val );
+ solid_color.readIfUnset( val, source );
break;
case SP_PROP_SOLID_OPACITY:
- solid_opacity.readIfUnset( val );
+ solid_opacity.readIfUnset( val, source );
break;
case SP_PROP_FILL:
- fill.readIfUnset( val );
+ fill.readIfUnset( val, source );
break;
case SP_PROP_FILL_OPACITY:
- fill_opacity.readIfUnset( val );
+ fill_opacity.readIfUnset( val, source );
break;
case SP_PROP_FILL_RULE:
- fill_rule.readIfUnset( val );
+ fill_rule.readIfUnset( val, source );
break;
case SP_PROP_IMAGE_RENDERING:
- image_rendering.readIfUnset( val );
+ image_rendering.readIfUnset( val, source );
break;
case SP_PROP_MARKER:
/* TODO: Call sp_uri_reference_resolve(SPDocument *document, guchar const *uri) */
- marker.readIfUnset( val );
+ marker.readIfUnset( val, source );
break;
case SP_PROP_MARKER_START:
/* TODO: Call sp_uri_reference_resolve(SPDocument *document, guchar const *uri) */
- marker_start.readIfUnset( val );
+ marker_start.readIfUnset( val, source );
break;
case SP_PROP_MARKER_MID:
/* TODO: Call sp_uri_reference_resolve(SPDocument *document, guchar const *uri) */
- marker_mid.readIfUnset( val );
+ marker_mid.readIfUnset( val, source );
break;
case SP_PROP_MARKER_END:
/* TODO: Call sp_uri_reference_resolve(SPDocument *document, guchar const *uri) */
- marker_end.readIfUnset( val );
+ marker_end.readIfUnset( val, source );
break;
case SP_PROP_SHAPE_RENDERING:
- shape_rendering.readIfUnset( val );
+ shape_rendering.readIfUnset( val, source );
break;
case SP_PROP_STROKE:
- stroke.readIfUnset( val );
+ stroke.readIfUnset( val, source );
break;
case SP_PROP_STROKE_WIDTH:
- stroke_width.readIfUnset( val );
+ stroke_width.readIfUnset( val, source );
break;
case SP_PROP_STROKE_DASHARRAY:
- stroke_dasharray.readIfUnset( val );
+ stroke_dasharray.readIfUnset( val, source );
break;
case SP_PROP_STROKE_DASHOFFSET:
- stroke_dashoffset.readIfUnset( val );
+ stroke_dashoffset.readIfUnset( val, source );
break;
case SP_PROP_STROKE_LINECAP:
- stroke_linecap.readIfUnset( val );
+ stroke_linecap.readIfUnset( val, source );
break;
case SP_PROP_STROKE_LINEJOIN:
- stroke_linejoin.readIfUnset( val );
+ stroke_linejoin.readIfUnset( val, source );
break;
case SP_PROP_STROKE_MITERLIMIT:
- stroke_miterlimit.readIfUnset( val );
+ stroke_miterlimit.readIfUnset( val, source );
break;
case SP_PROP_STROKE_OPACITY:
- stroke_opacity.readIfUnset( val );
+ stroke_opacity.readIfUnset( val, source );
break;
case SP_PROP_PAINT_ORDER:
- paint_order.readIfUnset( val );
+ paint_order.readIfUnset( val, source );
break;
default:
g_warning("SPIStyle::readIfUnset(): Invalid style property id: %d value: %s", id, val);
@@ -1003,16 +1003,16 @@ SPStyle::readIfUnset( gint id, gchar const *val ) {
* \post ret != NULL.
*/
Glib::ustring
-SPStyle::write( guint const flags, SPStyle const *const base ) const {
+SPStyle::write( guint const flags, SPStyleSrc const &style_src_req, SPStyle const *const base ) const {
// std::cout << "SPStyle::write" << std::endl;
Glib::ustring style_string;
for(std::vector<SPIBase*>::size_type i = 0; i != _properties.size(); ++i) {
if( base != NULL ) {
- style_string += _properties[i]->write( flags, base->_properties[i] );
+ style_string += _properties[i]->write( flags, style_src_req, base->_properties[i] );
} else {
- style_string += _properties[i]->write( flags, NULL );
+ style_string += _properties[i]->write( flags, style_src_req, NULL );
}
}
// for(SPPropMap::iterator i = _propmap.begin(); i != _propmap.end(); ++i ) {
@@ -1116,13 +1116,13 @@ SPStyle::_mergeString( gchar const *const p ) {
CRDeclaration *const decl_list
= cr_declaration_parse_list_from_buf(reinterpret_cast<guchar const *>(p), CR_UTF_8);
if (decl_list) {
- _mergeDeclList( decl_list );
+ _mergeDeclList( decl_list, SP_STYLE_SRC_ATTRIBUTE );
cr_declaration_destroy(decl_list);
}
}
void
-SPStyle::_mergeDeclList( CRDeclaration const *const decl_list ) {
+SPStyle::_mergeDeclList( CRDeclaration const *const decl_list, SPStyleSrc const &source ) {
// std::cout << "SPStyle::_mergeDeclList" << std::endl;
@@ -1130,13 +1130,13 @@ SPStyle::_mergeDeclList( CRDeclaration const *const decl_list ) {
// (Properties are only set if not previously set. See:
// Ref: http://www.w3.org/TR/REC-CSS2/cascade.html#cascading-order point 4.)
if (decl_list->next) {
- _mergeDeclList( decl_list->next );
+ _mergeDeclList( decl_list->next, source );
}
- _mergeDecl( decl_list );
+ _mergeDecl( decl_list, source );
}
void
-SPStyle::_mergeDecl( CRDeclaration const *const decl ) {
+SPStyle::_mergeDecl( CRDeclaration const *const decl, SPStyleSrc const &source ) {
// std::cout << "SPStyle::_mergeDecl" << std::endl;
@@ -1149,7 +1149,7 @@ SPStyle::_mergeDecl( CRDeclaration const *const decl ) {
*/
guchar *const str_value_unsigned = cr_term_to_string(decl->value);
gchar *const str_value = reinterpret_cast<gchar *>(str_value_unsigned);
- readIfUnset( prop_idx, str_value );
+ readIfUnset( prop_idx, str_value, source );
g_free(str_value);
}
}
@@ -1164,7 +1164,7 @@ SPStyle::_mergeProps( CRPropList *const props ) {
_mergeProps( cr_prop_list_get_next( props ) );
CRDeclaration *decl = NULL;
cr_prop_list_get_decl(props, &decl);
- _mergeDecl( decl );
+ _mergeDecl( decl, SP_STYLE_SRC_STYLE_SHEET );
}
}
diff --git a/src/style.h b/src/style.h
index 0e8e34145..2370d06ae 100644
--- a/src/style.h
+++ b/src/style.h
@@ -50,8 +50,9 @@ public:
void read(SPObject *object, Inkscape::XML::Node *repr);
void readFromObject(SPObject *object);
void readFromPrefs(Glib::ustring const &path);
- void readIfUnset( int id, char const *val );
+ void readIfUnset( int id, char const *val, SPStyleSrc const &source = SP_STYLE_SRC_STYLE_PROP );
Glib::ustring write( unsigned int const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
SPStyle const *const base = NULL ) const;
void cascade( SPStyle const *const parent );
void merge( SPStyle const *const parent );
@@ -64,8 +65,8 @@ public:
private:
void _mergeString( char const *const p );
- void _mergeDeclList( CRDeclaration const *const decl_list );
- void _mergeDecl( CRDeclaration const *const decl );
+ void _mergeDeclList( CRDeclaration const *const decl_list, SPStyleSrc const &source );
+ void _mergeDecl( CRDeclaration const *const decl, SPStyleSrc const &source );
void _mergeProps( CRPropList *const props );
void _mergeObjectStylesheet( SPObject const *const object );