summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e847461)
raw | patch | inline | side by side (parent: e847461)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Wed, 27 Jun 2007 05:41:53 +0000 (05:41 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Wed, 27 Jun 2007 05:41:53 +0000 (05:41 +0000) |
22 files changed:
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index 5685dc4d6502208c853848a1e6dbff5d5b1c525f..c6344da5cc54e4e9f485f1fb52a1c17975f5eb4c 100644 (file)
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
#include "sp-use.h"
#include "sp-feblend.h"
#include "sp-filter.h"
+#include "sp-filter-reference.h"
#include "sp-gaussian-blur.h"
#include "sp-flowtext.h"
#include "sp-flowregion.h"
double ret = 12;
if (style_str) {
- SPStyle *style = sp_style_new();
+ SPStyle *style = sp_style_new(SP_ACTIVE_DOCUMENT);
sp_style_merge_from_style_string(style, style_str);
ret = style->font_size.computed;
sp_style_unref(style);
items++;
//if object has a filter
- if (style->filter.set && style->filter.filter) {
+ if (style->filter.set && style->filter.href->getObject()) {
int blurcount = 0;
int blendcount = 0;
// determine whether filter is simple (blend and/or blur) or complex
- for(SPObject *primitive_obj = style->filter.filter->children;
+ for(SPObject *primitive_obj = style->filter.href->getObject()->children;
primitive_obj && SP_IS_FILTER_PRIMITIVE(primitive_obj);
primitive_obj = primitive_obj->next) {
SPFilterPrimitive *primitive = SP_FILTER_PRIMITIVE(primitive_obj);
// simple filter
if(blurcount == 1 || blendcount == 1) {
- for(SPObject *primitive_obj = style->filter.filter->children;
+ for(SPObject *primitive_obj = style->filter.href->getObject()->children;
primitive_obj && SP_IS_FILTER_PRIMITIVE(primitive_obj);
primitive_obj = primitive_obj->next) {
if(SP_IS_FEBLEND(primitive_obj)) {
items ++;
//if object has a filter
- if (style->filter.set && style->filter.filter) {
+ if (style->filter.set && style->filter.href->getObject()) {
//cycle through filter primitives
- SPObject *primitive_obj = style->filter.filter->children;
+ SPObject *primitive_obj = style->filter.href->getObject()->children;
while (primitive_obj) {
if (SP_IS_FILTER_PRIMITIVE(primitive_obj)) {
SPFilterPrimitive *primitive = SP_FILTER_PRIMITIVE(primitive_obj);
index 086838727a83566fcd3ab94c40b6adafff8c70f8..7ff5ebc96d7f9542c5089da53fdbe444dac05476 100644 (file)
SPPaintSelector *psel = SP_PAINT_SELECTOR (g_object_get_data (G_OBJECT (spw), "paint-selector"));
// create temporary style
- SPStyle *query = sp_style_new ();
+ SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
// query style from desktop into it. This returns a result flag and fills query with the style of subselection, if any, or selection
int result = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FILL);
if (!vector) {
/* No vector in paint selector should mean that we just changed mode */
- SPStyle *query = sp_style_new ();
+ SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
int result = objects_query_fillstroke ((GSList *) items, query, true);
guint32 common_rgb = 0;
if (result == QUERY_STYLE_MULTIPLE_SAME) {
index 7aa33fc5b9f72d0ea3aab33dcfd947cc1905f641..126deff3834967a3ffea298331b3ce40d333af30 100644 (file)
GtkAdjustment *a = GTK_ADJUSTMENT(gtk_object_get_data(GTK_OBJECT(dlg), "master_opacity_adjustment"));
// create temporary style
- SPStyle *query = sp_style_new ();
+ SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
// query style from desktop into it. This returns a result flag and fills query with the style of subselection, if any, or selection
int result = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_MASTEROPACITY);
index ed1082e26ef0d3b365fd082247bdf48cbf6661d0..fd43d374c9dd1a044dfb6a1be32a02e55a2cacf1 100644 (file)
SPPaintSelector *psel = SP_PAINT_SELECTOR(gtk_object_get_data(GTK_OBJECT(spw), "paint-selector"));
// create temporary style
- SPStyle *query = sp_style_new ();
+ SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
// query into it
int result = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKE);
if (!vector) {
/* No vector in paint selector should mean that we just changed mode */
- SPStyle *query = sp_style_new ();
+ SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
int result = objects_query_fillstroke ((GSList *) items, query, false);
guint32 common_rgb = 0;
if (result == QUERY_STYLE_MULTIPLE_SAME) {
GtkWidget *dsel = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "dash"));
// create temporary style
- SPStyle *query = sp_style_new ();
+ SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
// query into it
int result_sw = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKEWIDTH);
int result_ml = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKEMITERLIMIT);
index b2302372144f7e62814d5cb3ab00ef590295ae2f..5a59fd2e52f7677329f32bdf866c43133f82d285 100644 (file)
if (dostyle) {
// create temporary style
- SPStyle *query = sp_style_new ();
+ SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
// query style from desktop into it. This returns a result flag and fills query with the style of subselection, if any, or selection
int result_family = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTFAMILY);
int result_style = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTSTYLE);
index da3a240a64558a98bd41c242693d829d37cface8..3f08f42f4393bd5d8cb8e23be6a0082fe3372719 100644 (file)
#include "display/nr-filter-types.h"
#include "style.h"
#include "sp-filter.h"
+#include "sp-filter-reference.h"
#include "sp-gaussian-blur.h"
#include "sp-feblend.h"
#include "display/nr-filter-blend.h"
group->style = style;
//if group has a filter
- if (style->filter.set && style->filter.filter) {
+ if (style->filter.set && style->filter.href->getObject()) {
if (!group->filter) {
- int primitives = sp_filter_primitive_count(style->filter.filter);
+ int primitives = sp_filter_primitive_count(style->filter.href->getObject());
group->filter = new NR::Filter(primitives);
}
- sp_filter_build_renderer(style->filter.filter, group->filter);
+ sp_filter_build_renderer(style->filter.href->getObject(), group->filter);
} else {
//no filter set for this group
delete group->filter;
index 5f22dc5cd5010c0ffd53e2e5ea1339faaf30d45a..87cc94e1b72e115af6193805d34c45d8172e2860 100644 (file)
#include <livarot/Path.h>
#include <livarot/Shape.h>
#include "sp-filter.h"
+#include "sp-filter-reference.h"
#include "sp-gaussian-blur.h"
#include "sp-feblend.h"
#include "display/nr-filter-blend.h"
image->style = style;
//if image has a filter
- if (style->filter.set && style->filter.filter) {
+ if (style->filter.set && style->filter.href->getObject()) {
if (!image->filter) {
- int primitives = sp_filter_primitive_count(style->filter.filter);
+ int primitives = sp_filter_primitive_count(style->filter.href->getObject());
image->filter = new NR::Filter(primitives);
}
- sp_filter_build_renderer(style->filter.filter, image->filter);
+ sp_filter_build_renderer(style->filter.href->getObject(), image->filter);
} else {
//no filter set for this image
delete image->filter;
index c09bdb9dd9e1a405937d9a5f6edcb8a946c7640e..0e7dd27985614581aa397c02251d3549958e7302 100644 (file)
#include "inkscape-cairo.h"
#include "sp-filter.h"
+#include "sp-filter-reference.h"
#include "display/nr-filter.h"
#include <cairo.h>
shape->setMitreLimit(style->stroke_miterlimit.value);
//if shape has a filter
- if (style->filter.set && style->filter.filter) {
+ if (style->filter.set && style->filter.href->getObject()) {
if (!shape->filter) {
- int primitives = sp_filter_primitive_count(style->filter.filter);
+ int primitives = sp_filter_primitive_count(style->filter.href->getObject());
shape->filter = new NR::Filter(primitives);
}
- sp_filter_build_renderer(style->filter.filter, shape->filter);
+ sp_filter_build_renderer(style->filter.href->getObject(), shape->filter);
} else {
//no filter set for this shape
delete shape->filter;
index d3a02852eed3b2f5ecbbf12d23bae703dd2bf2e2..5515d0a049d69cca18b7174c8b9f6ecf63f94504 100644 (file)
--- a/src/filter-chemistry.cpp
+++ b/src/filter-chemistry.cpp
#include "sp-feblend.h"
#include "sp-filter.h"
+#include "sp-filter-reference.h"
#include "sp-gaussian-blur.h"
#include "svg/css-ostringstream.h"
SPStyle *style = SP_OBJECT_STYLE(o);
if (style
&& style->filter.set
- && style->filter.filter == filter)
+ && style->filter.href->getObject() == filter)
{
i ++;
}
//return new_filter_gaussian_blur_from_item(document, item, radius);
}
- SPFilter *filter = SP_FILTER(item->style->filter.filter);
+ SPFilter *filter = SP_FILTER(item->style->filter.href->getObject());
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document);
// If there are more users for this filter, duplicate it
if (SP_OBJECT_HREFCOUNT(filter) > count_filter_hrefs(item, filter)) {
Inkscape::XML::Node *repr;
- repr = SP_OBJECT_REPR(item->style->filter.filter)->duplicate(xml_doc);
+ repr = SP_OBJECT_REPR(item->style->filter.href->getObject())->duplicate(xml_doc);
SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document);
SP_OBJECT_REPR(defs)->appendChild(repr);
}
// Set the filter effects area
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(item->style->filter.filter);
+ Inkscape::XML::Node *repr = SP_OBJECT_REPR(item->style->filter.href->getObject());
set_filter_area(repr, radius, expansion, i2d.expansionX(),
i2d.expansionY(), width, height);
* be handled gracefully */
void remove_filter_gaussian_blur (SPObject *item)
{
- if (item->style && item->style->filter.set && item->style->filter.filter) {
+ if (item->style && item->style->filter.set && item->style->filter.href->getObject()) {
// Search for the first blur primitive and remove it. (if found)
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(item->style->filter.filter);
+ Inkscape::XML::Node *repr = SP_OBJECT_REPR(item->style->filter.href->getObject());
Inkscape::XML::Node *primitive = repr->firstChild();
while (primitive) {
if (strcmp("svg:feGaussianBlur", primitive->name()) == 0) {
index ed8d6379e4aaae48dd74060d3f0a0cf6b029abd3..27c04f1ddd4e9f10b9015edb930873335b852f63 100644 (file)
#include "sp-item.h"
#include "unit-constants.h"
#include "xml/simple-document.h"
+#include "sp-filter-reference.h"
using NR::X;
using NR::Y;
}
}
- if (style->filter.filter) {
- SPObject *filter = style->filter.filter;
+ if (style->filter.href->getObject()) {
+ SPObject *filter = style->filter.href->getObject();
if (SP_IS_FILTER(filter)) {
sp_copy_single (defs_clip, filter, xml_doc);
}
sp_selection_copy_impl (items, &clipboard, &defs_clipboard, &style_clipboard, clipboard_document);
if (tools_isactive (desktop, TOOLS_TEXT)) { // take style from cursor/text selection, overwriting the style just set by copy_impl
- SPStyle *const query = sp_style_new();
+ SPStyle *const query = sp_style_new(SP_ACTIVE_DOCUMENT);
if (sp_desktop_query_style_all (desktop, query)) {
SPCSSAttr *css = sp_css_attr_from_style (query, SP_STYLE_FLAG_ALWAYS);
if (css != NULL) {
index 226e033bb9dc330c67b59b9b03ae808c6e736539..216ff1d6f7a8bc10c57be0ac948a262209222edc 100644 (file)
class SPFilterReference : public Inkscape::URIReference {
public:
SPFilterReference(SPObject *obj) : URIReference(obj) {}
+ SPFilterReference(SPDocument *doc) : URIReference(doc) {}
SPFilter *getObject() const {
return (SPFilter *)URIReference::getObject();
diff --git a/src/sp-item.cpp b/src/sp-item.cpp
index fbcc7b4a895b006c0538c9b5e917425a3d6596d9..7c1a464479684a86e8f4e50feae2520891e62fa7 100644 (file)
--- a/src/sp-item.cpp
+++ b/src/sp-item.cpp
#include "prefs-utils.h"
#include "conn-avoid-ref.h"
#include "conditions.h"
+#include "sp-filter-reference.h"
#include "libnr/nr-matrix-div.h"
#include "libnr/nr-matrix-fns.h"
@@ -1200,7 +1201,7 @@ sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NR::Matrix cons
!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)
+ !(!transform.is_translation() && SP_OBJECT_STYLE(item) && SP_OBJECT_STYLE(item)->filter.href->getObject())
// 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);
diff --git a/src/style.cpp b/src/style.cpp
index e15c54636adf10b496766cfd5eebe0431e27ff93..46b544382a751c3ad8335747e4dd9ac96ea42dbd 100644 (file)
--- a/src/style.cpp
+++ b/src/style.cpp
#include "document.h"
#include "extract-uri.h"
#include "uri-references.h"
+#include "uri.h"
#include "sp-paint-server.h"
#include "streq.h"
#include "strneq.h"
#include "xml/repr.h"
#include "unit-constants.h"
#include "isnan.h"
+#include "macros.h"
+
+#include "sp-filter-reference.h"
#include <sigc++/functors/ptr_fun.h>
#include <sigc++/adaptors/bind.h>
style->object = NULL;
}
+/**
+ * Emit style modified signal on style's object if the filter changed.
+ */
+static void
+sp_style_filter_ref_modified(SPObject *obj, guint flags, SPStyle *style)
+{
+ SPFilter *filter=static_cast<SPFilter *>(obj);
+ if (style->filter.href->getObject() == filter)
+ {
+ if (style->object) {
+ style->object->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
+ }
+ }
+}
+/**
+ * Gets called when the filter is (re)attached to the style
+ */
+static void
+sp_style_filter_ref_changed(SPObject *old_ref, SPObject *ref, SPStyle *style)
+{
+ if (old_ref) {
+ sp_signal_disconnect_by_data(old_ref, style);
+ }
+ if ( SP_IS_FILTER(ref))
+ {
+ ref->connectModified(sigc::bind(sigc::ptr_fun(&sp_style_filter_ref_modified), style));
+ }
+
+ sp_style_filter_ref_modified(ref, 0, style);
+}
/**
* Returns a new SPStyle object with settings as per sp_style_clear().
*/
SPStyle *
-sp_style_new()
+sp_style_new(SPDocument *document)
{
SPStyle *const style = g_new0(SPStyle, 1);
style->text = sp_text_style_new();
style->text_private = TRUE;
+ if (document) {
+ style->filter.href = new SPFilterReference(document);
+ style->filter.href->changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_style_filter_ref_changed), style));
+ }
+
sp_style_clear(style);
style->cloned = false;
style->fill_hreffed = false;
style->stroke_hreffed = false;
- style->filter_hreffed = false;
new (&style->release_connection) sigc::connection();
new (&style->stroke_release_connection) sigc::connection();
new (&style->stroke_modified_connection) sigc::connection();
- new (&style->filter_release_connection) sigc::connection();
- new (&style->filter_modified_connection) sigc::connection();
-
return style;
}
g_return_val_if_fail(object != NULL, NULL);
g_return_val_if_fail(SP_IS_OBJECT(object), NULL);
- SPStyle *style = sp_style_new();
+ SPStyle *style = sp_style_new(SP_OBJECT_DOCUMENT(object));
style->object = object;
style->release_connection = object->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_style_object_release), style));
style->stroke_release_connection.~connection();
style->stroke_modified_connection.disconnect();
style->stroke_modified_connection.~connection();
- style->filter_modified_connection.disconnect();
- style->filter_modified_connection.~connection();
- style->filter_release_connection.disconnect();
- style->filter_release_connection.~connection();
g_free(style->stroke_dash.dash);
g_free(style);
}
} else {
if (sp_repr_parent(repr)) {
/// \todo fixme: This is not the prettiest thing (Lauris)
- SPStyle *parent = sp_style_new();
+ SPStyle *parent = sp_style_new(NULL);
sp_style_read(parent, NULL, sp_repr_parent(repr));
sp_style_merge_from_parent(style, parent);
sp_style_unref(parent);
}
}
-
-
-/**
- * Disconnects from filter.
- */
-static void
-sp_style_filter_release(SPObject *obj, SPStyle *style)
-{
- SPFilter *filter=static_cast<SPFilter *>(obj);
- if (style->filter.filter == filter)
- {
- sp_style_filter_clear(style);
- }
-}
-
-
-/**
- * Emit style modified signal on style's object if the filter changed.
- */
-static void
-sp_style_filter_modified(SPObject *obj, guint flags, SPStyle *style)
-{
- SPFilter *filter=static_cast<SPFilter *>(obj);
- if (style->filter.filter == filter)
- {
- if (style->object) {
- style->object->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
- }
- }
-}
-
-
/**
*
*/
sp_style_filter_clear(style);
style->filter.set = parent->set;
style->filter.inherit = parent->inherit;
- style->filter.filter = parent->filter;
- style->filter.uri = parent->uri;
- if (style->filter.filter) {
- if (style->object && !style->cloned) { // href filter for style of non-clones only
- sp_object_href(SP_OBJECT(style->filter.filter), style);
- style->filter_hreffed = true;
- }
- if (style->object || style->cloned) { // connect to signals for style of real objects or clones (this excludes temp styles)
- SPObject *filter = style->filter.filter;
- style->filter_release_connection
- = filter->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_style_filter_release), style));
- style->filter_modified_connection
- = filter->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_style_filter_modified), style));
- }
+
+ if (style->filter.href && style->filter.href->getObject())
+ style->filter.href->detach();
+
+ try {
+ style->filter.href->attach(*parent->href->getURI());
+ } catch (Inkscape::BadURIException &e) {
+ g_warning("%s", e.what());
+ style->filter.href->detach();
}
}
style->marker[i].set = FALSE;
}
- style->filter.set = FALSE;
- style->filter.uri = NULL;
- style->filter.filter = NULL;
-
style->enable_background.value = SP_CSS_BACKGROUND_ACCUMULATE;
style->enable_background.set = false;
style->enable_background.inherit = false;
@@ -3162,49 +3152,46 @@ sp_style_read_ifilter(gchar const *str, SPStyle * style, SPDocument *document)
if (streq(str, "inherit")) {
f->set = TRUE;
f->inherit = TRUE;
- f->filter = NULL;
+ if (f->href && f->href->getObject())
+ f->href->detach(); //f->filter = NULL;
} else if(streq(str, "none")) {
f->set = TRUE;
f->inherit = FALSE;
- f->filter = NULL;
+ if (f->href && f->href->getObject())
+ f->href->detach(); //f->filter = NULL;
} else if (strneq(str, "url", 3)) {
- f->uri = extract_uri(str);
- if(f->uri == NULL || f->uri[0] == '\0') {
+ char *uri = extract_uri(str);
+ if(uri == NULL || uri[0] == '\0') {
g_warning("Specified filter url is empty");
f->set = TRUE;
f->inherit = FALSE;
- f->filter = NULL;
return;
}
f->set = TRUE;
f->inherit = FALSE;
- f->filter = NULL;
- if (document) {
- SPObject *obj = sp_uri_reference_resolve(document, str);
- if (SP_IS_FILTER(obj)) {
- f->filter = SP_FILTER(obj);
- if (style->object && !style->cloned) {
- sp_object_href(obj, style);
- style->filter_hreffed = true;
- }
- if (style->object || style->cloned) { // connect to signals for style of real objects or clones (this excludes temp styles)
- SPObject *filter = style->filter.filter;
- style->filter_release_connection
- = filter->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_style_filter_release), style));
- style->filter_modified_connection
- = filter->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_style_filter_modified), style));
- }
- } else {
- g_warning("Element '%s' not found or is not a filter", f->uri);
- }
+ if (f->href && f->href->getObject())
+ f->href->detach();
+
+ // it may be that this style has not yet created its SPFilterReference;
+ // now that we have a document, we can create it here
+ if (!f->href) {
+ f->href = new SPFilterReference(document);
+ f->href->changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_style_filter_ref_changed), style));
+ }
+
+ try {
+ f->href->attach(Inkscape::URI(uri));
+ } catch (Inkscape::BadURIException &e) {
+ g_warning("%s", e.what());
+ f->href->detach();
}
} else {
/* We shouldn't reach this if SVG input is well-formed */
f->set = FALSE;
f->inherit = FALSE;
- f->filter = NULL;
- f->uri = NULL;
+ if (f->href && f->href->getObject())
+ f->href->detach();
}
}
{
if (val->inherit) {
return g_snprintf(p, len, "%s:inherit;", key);
- } else if (val->uri) {
- return g_snprintf(p, len, "%s:url(%s);", key, val->uri);
+ } else if (val->href->getURI()) {
+ return g_snprintf(p, len, "%s:url(%s);", key, val->href->getURI()->toString());
}
}
static void
sp_style_filter_clear(SPStyle *style)
{
-
- if (style->filter_hreffed) {
- sp_object_hunref(SP_OBJECT(style->filter.filter), style);
- style->filter_hreffed = false;
- }
- style->filter_release_connection.disconnect();
- style->filter_modified_connection.disconnect();
-
- style->filter.filter = NULL;
+ if (style->filter.href && style->filter.href->getObject())
+ style->filter.href->detach();
}
diff --git a/src/style.h b/src/style.h
index 544bde55778251ae3c9bf978c7cbd67ae3b5757a..df2ba127f6b374ccdb401fb4155afcfe10a0ffd4 100644 (file)
--- a/src/style.h
+++ b/src/style.h
} value;
};
+struct SPFilterReference;
+
/// Filter type internal to SPStyle
struct SPIFilter {
unsigned set : 1;
unsigned inherit : 1;
- SPFilter *filter;
- gchar *uri;
+ SPFilterReference *href;
};
enum {
/// style has hreffed its fill/stroke paintservers, needs to release.
bool fill_hreffed;
bool stroke_hreffed;
- bool filter_hreffed;
sigc::connection release_connection;
sigc::connection stroke_release_connection;
sigc::connection stroke_modified_connection;
-
- sigc::connection filter_release_connection;
- sigc::connection filter_modified_connection;
};
-SPStyle *sp_style_new();
+SPStyle *sp_style_new(SPDocument *document);
SPStyle *sp_style_new_from_object(SPObject *object);
diff --git a/src/text-editing.cpp b/src/text-editing.cpp
index b84361324338c62735017ba15f2407bd624e9d60..233ac8d3fe764f98cefb2ff1808541a31c2bc8f7 100644 (file)
--- a/src/text-editing.cpp
+++ b/src/text-editing.cpp
underneath the existing styles (ie ignoring already set properties). */
static void overwrite_style_with_string(SPObject *item, gchar const *style_string)
{
- SPStyle *new_style = sp_style_new();
+ SPStyle *new_style = sp_style_new(SP_OBJECT_DOCUMENT(item));
sp_style_merge_from_style_string(new_style, style_string);
gchar const *item_style_string = SP_OBJECT_REPR(item)->attribute("style");
if (item_style_string && *item_style_string)
@@ -1128,7 +1128,7 @@ static bool objects_have_equal_style(SPObject const *parent, SPObject const *chi
gchar *parent_style = sp_style_write_string(parent->style, SP_STYLE_FLAG_ALWAYS);
// we have to write parent_style then read it again, because some properties format their values
// differently depending on whether they're set or not (*cough*dash-offset*cough*)
- SPStyle *parent_spstyle = sp_style_new();
+ SPStyle *parent_spstyle = sp_style_new(SP_OBJECT_DOCUMENT(parent));
sp_style_merge_from_style_string(parent_spstyle, parent_style);
g_free(parent_style);
parent_style = sp_style_write_string(parent_spstyle, SP_STYLE_FLAG_ALWAYS);
@@ -1144,7 +1144,7 @@ static bool objects_have_equal_style(SPObject const *parent, SPObject const *chi
}
child = SP_OBJECT_PARENT(child);
}
- SPStyle *child_spstyle = sp_style_new();
+ SPStyle *child_spstyle = sp_style_new(SP_OBJECT_DOCUMENT(parent));
sp_style_merge_from_style_string(child_spstyle, child_style_construction.c_str());
gchar *child_style = sp_style_write_string(child_spstyle, SP_STYLE_FLAG_ALWAYS);
sp_style_unref(child_spstyle);
index 2967cf15164b782987cfd687961b250c44ae03c2..fdcfc763631f2cddd86d1bfadee7302889f1f0f3 100644 (file)
_blocked = true;
// create temporary style
- SPStyle *query = sp_style_new ();
+ SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
// query style from desktop into it. This returns a result flag and fills query with the style of subselection, if any, or selection
int result = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_MASTEROPACITY);
index 2c5da4380130dbfeb411552ebfa534990f717c29..fcd56ad441333185317f9b4999230e5bc45d22d7 100644 (file)
return;
// create temporary style
- SPStyle *query = sp_style_new ();
+ SPStyle *query = sp_style_new (sp_desktop_document(_desktop));
for (int i = SS_FILL; i <= SS_STROKE; i++) {
Gtk::EventBox *place = (i == SS_FILL)? &_fill_place : &_stroke_place;
index 705083a8f9afa2784671dc53797939722812f76e..cad07fbd6ed3435cb6b87e2e31baf3a50152357c 100644 (file)
sp_repr_css_merge(_css, css);
gchar const *css_string = sp_repr_css_write_string (_css);
- SPStyle *temp_spstyle = sp_style_new();
+ SPStyle *temp_spstyle = sp_style_new(SP_ACTIVE_DOCUMENT);
if (css_string)
sp_style_merge_from_style_string (temp_spstyle, css_string);
diff --git a/src/uri-references.cpp b/src/uri-references.cpp
index 6b2a8401fdeb9d78799af866b5423fbad5e6ed5e..8e14c9336522197fb9a63fa2b1992f9655b0838c 100644 (file)
--- a/src/uri-references.cpp
+++ b/src/uri-references.cpp
namespace Inkscape {
URIReference::URIReference(SPObject *owner)
-: _owner(owner), _obj(NULL), _uri(NULL)
+ : _owner(owner), _owner_document(NULL), _obj(NULL), _uri(NULL)
{
g_assert(_owner != NULL);
/* FIXME !!! attach to owner's destroy signal to clean up in case */
}
+URIReference::URIReference(SPDocument *owner_document)
+ : _owner_document(owner_document), _owner(NULL), _obj(NULL), _uri(NULL)
+{
+ g_assert(_owner_document != NULL);
+}
+
URIReference::~URIReference() {
detach();
}
void URIReference::attach(const URI &uri) throw(BadURIException)
{
- SPDocument *document = SP_OBJECT_DOCUMENT(_owner);
+ SPDocument *document;
+ if (_owner) {
+ document = SP_OBJECT_DOCUMENT(_owner);
+ } else if (_owner_document) {
+ document = _owner_document;
+ } else {
+ g_assert_not_reached();
+ }
gchar const *fragment = uri.getFragment();
if ( !uri.isRelative() || uri.getQuery() || !fragment ) {
throw UnsupportedURIException();
diff --git a/src/uri-references.h b/src/uri-references.h
index 38f346987933ba810e50b6093f9dc5166b550414..89cdff82743870ecba567b53709a9a271554a210 100644 (file)
--- a/src/uri-references.h
+++ b/src/uri-references.h
* is holding a reference to the target object.
*/
URIReference(SPObject *owner);
+ URIReference(SPDocument *owner_document);
/**
* Destructor. Calls shutdown() if the reference has not been
private:
SPObject *_owner;
+ SPDocument *_owner_document;
sigc::connection _connection;
sigc::connection _release_connection;
SPObject *_obj;
index 78303c60b8335a4080922da8054b23002468c0fe..474ab90f9f95069411e96948a02fd5d5b705298f 100644 (file)
if (ndashes > 0) {
int pos = 0;
- SPStyle *style = sp_style_new ();
+ SPStyle *style = sp_style_new (NULL);
dashes = g_new (double *, ndashes + 1);
for (Inkscape::XML::Node *dr = drepr->firstChild(); dr; dr = dr->next()) {
if (!strcmp (dr->name(), "dash")) {
index c15337e0db4772de6ae4da82c9749f725c76d576..aa5165d15ef6bdabad3b57ef130a923cc3c310d7 100644 (file)
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
sp_text_toolbox_selection_changed (Inkscape::Selection *selection, GObject *tbl)
{
SPStyle *query =
- sp_style_new ();
+ sp_style_new (SP_ACTIVE_DOCUMENT);
int result_family =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTFAMILY);
gtk_entry_set_text (GTK_ENTRY (entry), family);
SPStyle *query =
- sp_style_new ();
+ sp_style_new (SP_ACTIVE_DOCUMENT);
int result_numbers =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
}
SPStyle *query =
- sp_style_new ();
+ sp_style_new (SP_ACTIVE_DOCUMENT);
int result_numbers =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
}
SPStyle *query =
- sp_style_new ();
+ sp_style_new (SP_ACTIVE_DOCUMENT);
int result_numbers =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
}
SPStyle *query =
- sp_style_new ();
+ sp_style_new (SP_ACTIVE_DOCUMENT);
int result_numbers =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
free (text);
SPStyle *query =
- sp_style_new ();
+ sp_style_new (SP_ACTIVE_DOCUMENT);
int result_numbers =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);