summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2014-11-15 19:08:00 +0000
committerJabiertxof <jtx@jtx.marker.es>2014-11-15 19:08:00 +0000
commit11fd7a608db9b2133bb0fc067545557fedfd2643 (patch)
treeb9a97dd449e410b7a6c0c2f496204cac0730338b /src
parentAdd vertical and horizontal modes (diff)
parentPurged GTKish SP_IS_RECT_CONTEXT/SP_RECT_CONTEXT macros. (diff)
downloadinkscape-11fd7a608db9b2133bb0fc067545557fedfd2643.tar.gz
inkscape-11fd7a608db9b2133bb0fc067545557fedfd2643.zip
update to trunk
(bzr r13682.1.12)
Diffstat (limited to 'src')
-rw-r--r--src/sp-object.cpp4
-rw-r--r--src/sp-script.h4
-rw-r--r--src/sp-style-elem.cpp54
-rw-r--r--src/sp-style-elem.h3
-rw-r--r--src/ui/dialog/document-properties.cpp19
-rw-r--r--src/ui/tools/rect-tool.h4
-rw-r--r--src/widgets/rect-toolbar.cpp3
7 files changed, 40 insertions, 51 deletions
diff --git a/src/sp-object.cpp b/src/sp-object.cpp
index fcff43aa5..024fce85a 100644
--- a/src/sp-object.cpp
+++ b/src/sp-object.cpp
@@ -406,9 +406,9 @@ void SPObject::requestOrphanCollection() {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
// do not remove style or script elements (Bug #276244)
- if (SP_IS_STYLE_ELEM(this)) {
+ if (dynamic_cast<SPStyleElem *>(this)) {
// leave it
- } else if (SP_IS_SCRIPT(this)) {
+ } else if (dynamic_cast<SPScript *>(this)) {
// leave it
} else if ((! prefs->getBool("/options/cleanupswatches/value", false)) && SP_IS_PAINT_SERVER(this) && static_cast<SPPaintServer*>(this)->isSwatch() ) {
diff --git a/src/sp-script.h b/src/sp-script.h
index b71f86720..cdacb8493 100644
--- a/src/sp-script.h
+++ b/src/sp-script.h
@@ -6,6 +6,7 @@
*
* Author:
* Felipe C. da S. Sanches <juca@members.fsf.org>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2008 Author
*
@@ -15,9 +16,6 @@
#include "sp-object.h"
#include "document.h"
-#define SP_SCRIPT(obj) (dynamic_cast<SPScript*>((SPObject*)obj))
-#define SP_IS_SCRIPT(obj) (dynamic_cast<const SPScript*>((SPObject*)obj) != NULL)
-
/* SPScript */
class SPScript : public SPObject {
public:
diff --git a/src/sp-style-elem.cpp b/src/sp-style-elem.cpp
index 84f110134..da17b08d9 100644
--- a/src/sp-style-elem.cpp
+++ b/src/sp-style-elem.cpp
@@ -26,23 +26,18 @@ SPStyleElem::~SPStyleElem() {
}
void SPStyleElem::set(unsigned int key, const gchar* value) {
- SPStyleElem* object = this;
-
- g_return_if_fail(object);
- SPStyleElem &style_elem = *SP_STYLE_ELEM(object);
-
switch (key) {
case SP_ATTR_TYPE: {
if (!value) {
/* TODO: `type' attribute is required. Give error message as per
http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing. */
- style_elem.is_css = false;
+ is_css = false;
} else {
/* fixme: determine what whitespace is allowed. Will probably need to ask on SVG
- * list; though the relevant RFC may give info on its lexer. */
- style_elem.is_css = ( g_ascii_strncasecmp(value, "text/css", 8) == 0
- && ( value[8] == '\0' ||
- value[8] == ';' ) );
+ list; though the relevant RFC may give info on its lexer. */
+ is_css = ( g_ascii_strncasecmp(value, "text/css", 8) == 0
+ && ( value[8] == '\0' ||
+ value[8] == ';' ) );
}
break;
}
@@ -67,14 +62,18 @@ static void
child_add_rm_cb(Inkscape::XML::Node *, Inkscape::XML::Node *, Inkscape::XML::Node *,
void *const data)
{
- static_cast<SPObject *>(data)->read_content();
+ SPObject *obj = reinterpret_cast<SPObject *>(data);
+ g_assert(data != NULL);
+ obj->read_content();
}
static void
content_changed_cb(Inkscape::XML::Node *, gchar const *, gchar const *,
void *const data)
{
- static_cast<SPObject *>(data)->read_content();
+ SPObject *obj = reinterpret_cast<SPObject *>(data);
+ g_assert(data != NULL);
+ obj->read_content();
}
static void
@@ -82,24 +81,22 @@ child_order_changed_cb(Inkscape::XML::Node *, Inkscape::XML::Node *,
Inkscape::XML::Node *, Inkscape::XML::Node *,
void *const data)
{
- static_cast<SPObject *>(data)->read_content();
+ SPObject *obj = reinterpret_cast<SPObject *>(data);
+ g_assert(data != NULL);
+ obj->read_content();
}
Inkscape::XML::Node* SPStyleElem::write(Inkscape::XML::Document* xml_doc, Inkscape::XML::Node* repr, guint flags) {
- SPStyleElem* object = this;
-
if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
repr = xml_doc->createElement("svg:style");
}
- g_return_val_if_fail(object, repr);
- SPStyleElem &style_elem = *SP_STYLE_ELEM(object);
if (flags & SP_OBJECT_WRITE_BUILD) {
g_warning("nyi: Forming <style> content for SP_OBJECT_WRITE_BUILD.");
/* fixme: Consider having the CRStyleSheet be a member of SPStyleElem, and then
pretty-print to a string s, then repr->addChild(xml_doc->createTextNode(s), NULL). */
}
- if (style_elem.is_css) {
+ if (is_css) {
repr->setAttribute("type", "text/css");
}
/* todo: media */
@@ -263,10 +260,6 @@ property_cb(CRDocHandler *const a_handler,
}
void SPStyleElem::read_content() {
- SPStyleElem* object = this;
-
- SPStyleElem &style_elem = *SP_STYLE_ELEM(object);
-
/* 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.
*
@@ -283,7 +276,7 @@ void SPStyleElem::read_content() {
*/
//XML Tree being used directly here while it shouldn't be.
- GString *const text = concat_children(*style_elem.getRepr());
+ GString *const text = concat_children(*getRepr());
CRParser *parser = cr_parser_new_from_buf(reinterpret_cast<guchar *>(text->str), text->len,
CR_UTF_8, FALSE);
@@ -312,7 +305,7 @@ void SPStyleElem::read_content() {
CRStatus const parse_status = cr_parser_parse(parser);
g_assert(sac_handler->app_data == &parse_tmp);
if (parse_status == CR_OK) {
- cr_cascade_set_sheet(style_elem.document->style_cascade, stylesheet, ORIGIN_AUTHOR);
+ cr_cascade_set_sheet(document->style_cascade, stylesheet, ORIGIN_AUTHOR);
} else {
if (parse_status != CR_PARSING_ERROR) {
g_printerr("parsing error code=%u\n", unsigned(parse_status));
@@ -323,7 +316,7 @@ void SPStyleElem::read_content() {
}
}
cr_parser_destroy(parser);
- //object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ //requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
// Style references via class= do not, and actually cannot, use autoupdating URIReferences.
// Therefore, if an object refers to a stylesheet which has not yet loaded when the object is being loaded
@@ -331,7 +324,6 @@ void SPStyleElem::read_content() {
// Below is a partial hack that fixes this for a single case: when 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.
- SPObject *parent = object->parent;
if ( parent ) {
sp_style_read_from_object(parent->style, parent);
}
@@ -351,12 +343,10 @@ rec_add_listener(Inkscape::XML::Node &repr,
}
void SPStyleElem::build(SPDocument *document, Inkscape::XML::Node *repr) {
- SPStyleElem* object = this;
-
- object->read_content();
+ read_content();
- object->readAttr( "type" );
- object->readAttr( "media" );
+ readAttr( "type" );
+ readAttr( "media" );
static Inkscape::XML::NodeEventVector const nodeEventVector = {
child_add_rm_cb, // child_added
@@ -365,7 +355,7 @@ void SPStyleElem::build(SPDocument *document, Inkscape::XML::Node *repr) {
content_changed_cb, // content_changed
child_order_changed_cb, // order_changed
};
- rec_add_listener(*repr, &nodeEventVector, object);
+ rec_add_listener(*repr, &nodeEventVector, this);
SPObject::build(document, repr);
}
diff --git a/src/sp-style-elem.h b/src/sp-style-elem.h
index 766770216..a3f4bdc70 100644
--- a/src/sp-style-elem.h
+++ b/src/sp-style-elem.h
@@ -4,9 +4,6 @@
#include "sp-object.h"
#include "media.h"
-#define SP_STYLE_ELEM(obj) (dynamic_cast<SPStyleElem*>((SPObject*)obj))
-#define SP_IS_STYLE_ELEM(obj) (dynamic_cast<const SPStyleElem*>((SPObject*)obj) != NULL)
-
class SPStyleElem : public SPObject {
public:
SPStyleElem();
diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp
index dc8a0fee2..6064c2a5e 100644
--- a/src/ui/dialog/document-properties.cpp
+++ b/src/ui/dialog/document-properties.cpp
@@ -1205,10 +1205,10 @@ void DocumentProperties::removeExternalScript(){
const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" );
while ( current ) {
- if (current->data && SP_IS_OBJECT(current->data)) {
- SPObject* obj = SP_OBJECT(current->data);
- SPScript* script = SP_SCRIPT(obj);
- if (name == script->xlinkhref){
+ SPObject* obj = reinterpret_cast<SPObject *>(current->data);
+ if (obj) {
+ SPScript* script = dynamic_cast<SPScript *>(obj);
+ if (script && (name == script->xlinkhref)) {
//XML Tree being used directly here while it shouldn't be.
Inkscape::XML::Node *repr = obj->getRepr();
@@ -1354,10 +1354,15 @@ void DocumentProperties::populate_script_lists(){
_ExternalScriptsListStore->clear();
_EmbeddedScriptsListStore->clear();
const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" );
- if (current) _scripts_observer.set(SP_OBJECT(current->data)->parent);
+ if (current) {
+ SPObject *obj = reinterpret_cast<SPObject *>(current->data);
+ g_assert(obj != NULL);
+ _scripts_observer.set(obj->parent);
+ }
while ( current ) {
- SPObject* obj = SP_OBJECT(current->data);
- SPScript* script = SP_SCRIPT(obj);
+ SPObject* obj = reinterpret_cast<SPObject *>(current->data);
+ SPScript* script = dynamic_cast<SPScript *>(obj);
+ g_assert(script != NULL);
if (script->xlinkhref)
{
Gtk::TreeModel::Row row = *(_ExternalScriptsListStore->append());
diff --git a/src/ui/tools/rect-tool.h b/src/ui/tools/rect-tool.h
index a50fd7b24..a22f1caa8 100644
--- a/src/ui/tools/rect-tool.h
+++ b/src/ui/tools/rect-tool.h
@@ -6,6 +6,7 @@
*
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2000 Lauris Kaplinski
* Copyright (C) 2000-2001 Ximian, Inc.
@@ -21,9 +22,6 @@
#include "sp-rect.h"
-#define SP_RECT_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::RectTool*>((Inkscape::UI::Tools::ToolBase*)obj))
-#define SP_IS_RECT_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::RectTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL)
-
namespace Inkscape {
namespace UI {
namespace Tools {
diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp
index e1ce01eaf..b6b7e435d 100644
--- a/src/widgets/rect-toolbar.cpp
+++ b/src/widgets/rect-toolbar.cpp
@@ -404,7 +404,8 @@ static void rect_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolB
{
static sigc::connection changed;
- if (SP_IS_RECT_CONTEXT(ec)) {
+ // TODO fixme: use of dynamic_cast<> seems wrong here.
+ if (dynamic_cast<Inkscape::UI::Tools::RectTool *>(ec)) {
changed = sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_rect_toolbox_selection_changed), holder));
} else {
if (changed)