summaryrefslogtreecommitdiffstats
path: root/src/object
diff options
context:
space:
mode:
authorMartin Owens <doctormo@gmail.com>2018-11-13 00:25:05 +0000
committerMartin Owens <doctormo@gmail.com>2018-11-13 00:25:05 +0000
commitdb722f5b79ef1517f0b6e9a96968ad257dffc6f9 (patch)
treef7992f8cc42739e3aef74233efaf840045c9cb87 /src/object
parentSupport multiple style sheets or style elements in an svg document (diff)
downloadinkscape-db722f5b79ef1517f0b6e9a96968ad257dffc6f9.tar.gz
inkscape-db722f5b79ef1517f0b6e9a96968ad257dffc6f9.zip
Add capability to get style rulesets as SPStyle objects
Diffstat (limited to 'src/object')
-rw-r--r--src/object/sp-style-elem.cpp17
-rw-r--r--src/object/sp-style-elem.h14
2 files changed, 25 insertions, 6 deletions
diff --git a/src/object/sp-style-elem.cpp b/src/object/sp-style-elem.cpp
index 14e4a8d90..de2041764 100644
--- a/src/object/sp-style-elem.cpp
+++ b/src/object/sp-style-elem.cpp
@@ -450,6 +450,23 @@ void update_style_recursively( SPObject *object ) {
}
}
+/*
+ * Returns each statement as an SPStyle
+ */
+std::vector<SPStyle *> SPStyleElem::getStyles() {
+ std::vector<SPStyle *> ret;
+ gint count = cr_stylesheet_nr_rules(style_sheet);
+
+ for (gint x = 0; x < count; x++) {
+ SPStyle *item = new SPStyle(nullptr, nullptr);
+ CRStatement *statement = cr_stylesheet_statement_get_from_list(style_sheet, x);
+ item->mergeStatement(statement);
+ ret.push_back(item);
+ }
+
+ return ret;
+}
+
void SPStyleElem::read_content() {
// First, create the style-sheet object and track it in this
diff --git a/src/object/sp-style-elem.h b/src/object/sp-style-elem.h
index b2c38f20b..76089172e 100644
--- a/src/object/sp-style-elem.h
+++ b/src/object/sp-style-elem.h
@@ -15,8 +15,8 @@
class SPStyleElem : public SPObject {
public:
- SPStyleElem();
- ~SPStyleElem() override;
+ SPStyleElem();
+ ~SPStyleElem() override;
// Container for the libcroco style sheet instance created on load.
CRStyleSheet *style_sheet;
@@ -24,10 +24,12 @@ public:
Media media;
bool is_css;
- void build(SPDocument* doc, Inkscape::XML::Node* repr) override;
- void set(SPAttributeEnum key, char const* value) override;
- void read_content() override;
- Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags) override;
+ void build(SPDocument* doc, Inkscape::XML::Node* repr) override;
+ void set(SPAttributeEnum key, char const* value) override;
+ void read_content() override;
+ Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags) override;
+
+ std::vector<SPStyle *> getStyles();
};