diff options
| author | su_v <suv-sf@users.sourceforge.net> | 2013-02-13 18:36:57 +0000 |
|---|---|---|
| committer | ~suv <suv-sf@users.sourceforge.net> | 2013-02-13 18:36:57 +0000 |
| commit | 77b788bb1c5fa861a3f12c76ad3f17bc8edc35b8 (patch) | |
| tree | 441f798cf2c8cb3a760c1ecf259f5faff356124c /src | |
| parent | changes_2013_02_01b.patch (diff) | |
| parent | Build. Adding unistd header (fixes compilation on Win32 with OpenSuse cross-c... (diff) | |
| download | inkscape-77b788bb1c5fa861a3f12c76ad3f17bc8edc35b8.tar.gz inkscape-77b788bb1c5fa861a3f12c76ad3f17bc8edc35b8.zip | |
merge from trunk (r12122)
(bzr r11668.1.51)
Diffstat (limited to 'src')
185 files changed, 2261 insertions, 8382 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 7658ab714..2baace5e0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -48,6 +48,7 @@ all_libs = \ $(INKBOARD_LIBS) \ $(LIBWPG_LIBS) \ $(LIBVISIO_LIBS) \ + $(LIBCDR_LIBS) \ $(DBUS_LIBS) \ $(GDL_LIBS) \ $(IMAGEMAGICK_LIBS) @@ -72,6 +73,7 @@ INCLUDES = \ $(INKBOARD_CFLAGS) \ $(LIBWPG_CFLAGS) \ $(LIBVISIO_CFLAGS) \ + $(LIBCDR_CFLAGS) \ $(DBUS_CFLAGS) \ $(GDL_CFLAGS) \ $(XFT_CFLAGS) \ diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp index a58059e89..1af5ed29f 100644 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@ -53,8 +53,6 @@ using Inkscape::DocumentUndo; -static void sp_box3d_context_class_init(Box3DContextClass *klass); -static void sp_box3d_context_init(Box3DContext *box3d_context); static void sp_box3d_context_dispose(GObject *object); static void sp_box3d_context_setup(SPEventContext *ec); @@ -66,34 +64,13 @@ static gint sp_box3d_context_item_handler(SPEventContext *event_context, SPItem static void sp_box3d_drag(Box3DContext &bc, guint state); static void sp_box3d_finish(Box3DContext *bc); -static SPEventContextClass *parent_class; - -GType sp_box3d_context_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(Box3DContextClass), - NULL, NULL, - (GClassInitFunc) sp_box3d_context_class_init, - NULL, NULL, - sizeof(Box3DContext), - 4, - (GInstanceInitFunc) sp_box3d_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "Box3DContext", &info, (GTypeFlags) 0); - } - return type; -} +G_DEFINE_TYPE(Box3DContext, sp_box3d_context, SP_TYPE_EVENT_CONTEXT); static void sp_box3d_context_class_init(Box3DContextClass *klass) { GObjectClass *object_class = (GObjectClass *) klass; SPEventContextClass *event_context_class = (SPEventContextClass *) klass; - parent_class = (SPEventContextClass *) g_type_class_peek_parent(klass); - object_class->dispose = sp_box3d_context_dispose; event_context_class->setup = sp_box3d_context_setup; @@ -135,8 +112,8 @@ static void sp_box3d_context_finish(SPEventContext *ec) bc->sel_changed_connection.disconnect(); // sp_repr_remove_listener_by_data(cc->active_shape_repr, cc); - if (((SPEventContextClass *) parent_class)->finish) { - ((SPEventContextClass *) parent_class)->finish(ec); + if (((SPEventContextClass *) sp_box3d_context_parent_class)->finish) { + ((SPEventContextClass *) sp_box3d_context_parent_class)->finish(ec); } } @@ -166,7 +143,7 @@ static void sp_box3d_context_dispose(GObject *object) delete bc->_message_context; } - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_box3d_context_parent_class)->dispose(object); } /** @@ -211,8 +188,8 @@ static void sp_box3d_context_setup(SPEventContext *ec) { Box3DContext *bc = SP_BOX3D_CONTEXT(ec); - if (((SPEventContextClass *) parent_class)->setup) { - ((SPEventContextClass *) parent_class)->setup(ec); + if (((SPEventContextClass *) sp_box3d_context_parent_class)->setup) { + ((SPEventContextClass *) sp_box3d_context_parent_class)->setup(ec); } ec->shape_editor = new ShapeEditor(ec->desktop); @@ -259,8 +236,8 @@ static gint sp_box3d_context_item_handler(SPEventContext *event_context, SPItem break; } - if (((SPEventContextClass *) parent_class)->item_handler) { - ret = ((SPEventContextClass *) parent_class)->item_handler(event_context, item, event); + if (((SPEventContextClass *) sp_box3d_context_parent_class)->item_handler) { + ret = ((SPEventContextClass *) sp_box3d_context_parent_class)->item_handler(event_context, item, event); } return ret; @@ -572,8 +549,8 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven } if (!ret) { - if (((SPEventContextClass *) parent_class)->root_handler) { - ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event); + if (((SPEventContextClass *) sp_box3d_context_parent_class)->root_handler) { + ret = ((SPEventContextClass *) sp_box3d_context_parent_class)->root_handler(event_context, event); } } diff --git a/src/common-context.cpp b/src/common-context.cpp index 9d5dbb048..ff99b5c0b 100644 --- a/src/common-context.cpp +++ b/src/common-context.cpp @@ -19,8 +19,6 @@ #define DRAG_MAX 1.0 -static void sp_common_context_class_init(SPCommonContextClass *klass); -static void sp_common_context_init(SPCommonContext *erc); static void sp_common_context_dispose(GObject *object); static void sp_common_context_setup(SPEventContext *ec); @@ -28,38 +26,13 @@ static void sp_common_context_set(SPEventContext *ec, Inkscape::Preferences::Ent static gint sp_common_context_root_handler(SPEventContext *event_context, GdkEvent *event); - -static SPEventContextClass *common_parent_class = 0; - -GType sp_common_context_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPCommonContextClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_common_context_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPCommonContext), - 0, // n_preallocs - (GInstanceInitFunc)sp_common_context_init, - 0 // value_table - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPCommonContext", &info, static_cast<GTypeFlags>(0)); - } - return type; -} - +G_DEFINE_TYPE(SPCommonContext, sp_common_context, SP_TYPE_EVENT_CONTEXT); static void sp_common_context_class_init(SPCommonContextClass *klass) { GObjectClass *object_class = (GObjectClass *) klass; SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass); - common_parent_class = SP_EVENT_CONTEXT_CLASS(g_type_class_peek_parent(klass)); - object_class->dispose = sp_common_context_dispose; event_context_class->setup = sp_common_context_setup; @@ -144,14 +117,14 @@ static void sp_common_context_dispose(GObject *object) ctx->_message_context = 0; } - G_OBJECT_CLASS(common_parent_class)->dispose(object); + G_OBJECT_CLASS(sp_common_context_parent_class)->dispose(object); } static void sp_common_context_setup(SPEventContext *ec) { - if ( common_parent_class->setup ) { - common_parent_class->setup(ec); + if ( SP_EVENT_CONTEXT_CLASS(sp_common_context_parent_class)->setup ) { + SP_EVENT_CONTEXT_CLASS(sp_common_context_parent_class)->setup(ec); } } @@ -199,8 +172,8 @@ static gint sp_common_context_root_handler(SPEventContext *event_context, GdkEve if ( !ret ) { - if ( common_parent_class->root_handler ) { - ret = common_parent_class->root_handler(event_context, event); + if ( SP_EVENT_CONTEXT_CLASS(sp_common_context_parent_class)->root_handler ) { + ret = SP_EVENT_CONTEXT_CLASS(sp_common_context_parent_class)->root_handler(event_context, event); } } diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 24a7203ac..9631eecb1 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -109,8 +109,6 @@ using Inkscape::DocumentUndo; -static void sp_connector_context_class_init(SPConnectorContextClass *klass); -static void sp_connector_context_init(SPConnectorContext *conn_context); static void sp_connector_context_dispose(GObject *object); static void sp_connector_context_setup(SPEventContext *ec); @@ -156,8 +154,6 @@ static void shape_event_attr_changed(Inkscape::XML::Node *repr, gchar const *nam /*static Geom::Point connector_drag_origin_w(0, 0); static bool connector_within_tolerance = false;*/ -static SPEventContextClass *parent_class; - static Inkscape::XML::NodeEventVector shape_repr_events = { NULL, /* child_added */ @@ -175,26 +171,7 @@ static Inkscape::XML::NodeEventVector layer_repr_events = { NULL /* order_changed */ }; - -GType -sp_connector_context_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPConnectorContextClass), - NULL, NULL, - (GClassInitFunc) sp_connector_context_class_init, - NULL, NULL, - sizeof(SPConnectorContext), - 4, - (GInstanceInitFunc) sp_connector_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPConnectorContext", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPConnectorContext, sp_connector_context, SP_TYPE_EVENT_CONTEXT); static void sp_connector_context_class_init(SPConnectorContextClass *klass) @@ -202,8 +179,6 @@ sp_connector_context_class_init(SPConnectorContextClass *klass) GObjectClass *object_class = G_OBJECT_CLASS(klass); SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass); - parent_class = SP_EVENT_CONTEXT_CLASS(g_type_class_peek_parent(klass)); - object_class->dispose = sp_connector_context_dispose; event_context_class->setup = sp_connector_context_setup; @@ -283,7 +258,7 @@ sp_connector_context_dispose(GObject *object) } g_assert( cc->newConnRef == NULL ); - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_connector_context_parent_class)->dispose(object); } @@ -293,8 +268,8 @@ sp_connector_context_setup(SPEventContext *ec) SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(ec); SPDesktop *dt = ec->desktop; - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->setup) { - (SP_EVENT_CONTEXT_CLASS(parent_class))->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->setup) { + (SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->setup(ec); } cc->selection = sp_desktop_selection(dt); @@ -358,8 +333,8 @@ sp_connector_context_finish(SPEventContext *ec) spcc_connector_finish(cc); cc->state = SP_CONNECTOR_CONTEXT_IDLE; - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->finish) { - (SP_EVENT_CONTEXT_CLASS(parent_class))->finish(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->finish) { + (SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->finish(ec); } if (cc->selection) { @@ -560,7 +535,7 @@ sp_connector_context_root_handler(SPEventContext *ec, GdkEvent *event) if (!ret) { gint (*const parent_root_handler)(SPEventContext *, GdkEvent *) - = (SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler; + = (SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->root_handler; if (parent_root_handler) { ret = parent_root_handler(ec, event); } diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index 1cfe018ce..9942e3a13 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -196,7 +196,6 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge sp_guideline_set_position(SP_GUIDELINE(guide), event_dt); desktop->set_coordinate_status(event_dt); - desktop->setPosition(event_dt); } break; case GDK_BUTTON_RELEASE: @@ -395,7 +394,6 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) } moved = true; desktop->set_coordinate_status(motion_dt); - desktop->setPosition(motion_dt); ret = TRUE; } @@ -483,7 +481,6 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) } moved = false; desktop->set_coordinate_status(event_dt); - desktop->setPosition (event_dt); } drag_type = SP_DRAG_NONE; sp_canvas_item_ungrab(item, event->button.time); diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 410e71730..2ea3c876b 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -39,6 +39,7 @@ #include "sp-tref.h" #include "sp-tspan.h" #include "xml/repr.h" +#include "xml/sp-css-attr.h" #include "libnrtype/font-style-to-pos.h" #include "sp-path.h" #include "event-context.h" diff --git a/src/desktop.cpp b/src/desktop.cpp index ea23ebb9c..c7a763ae1 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1539,12 +1539,6 @@ void SPDesktop::toggleSnapGlobal() // Callback implementations. The virtual ones are connected by the view. void -SPDesktop::onPositionSet (double x, double y) -{ - _widget->viewSetPosition (Geom::Point(x,y)); -} - -void SPDesktop::onResized (double /*x*/, double /*y*/) { // Nothing called here diff --git a/src/desktop.h b/src/desktop.h index 529199692..93cf3201c 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -431,7 +431,6 @@ private: sigc::connection _commit_connection; sigc::connection _modified_connection; - virtual void onPositionSet (double, double); virtual void onResized (double, double); virtual void onRedrawRequested(); virtual void onStatusMessage (Inkscape::MessageType type, gchar const *message); diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index 9655fc194..8eeee0277 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -597,11 +597,11 @@ void ink_cairo_surface_average_color_premul(cairo_surface_t *surface, double &r, a = CLAMP(a, 0.0, 1.0); } -void srgb_to_linear( guint32* c, guint32 a ) { +static guint32 srgb_to_linear( const guint32 c, const guint32 a ) { - *c = unpremul_alpha( *c, a ); + const guint32 c1 = unpremul_alpha( c, a ); - double cc = *c/255.0; + double cc = c1/255.0; if( cc < 0.04045 ) { cc /= 12.92; @@ -610,16 +610,16 @@ void srgb_to_linear( guint32* c, guint32 a ) { } cc *= 255.0; - *c = (int)cc; + const guint32 c2 = (int)cc; - *c = premul_alpha( *c, a ); + return premul_alpha( c2, a ); } -void linear_to_srgb( guint32* c, guint32 a ) { +static guint32 linear_to_srgb( const guint32 c, const guint32 a ) { - *c = unpremul_alpha( *c, a ); + const guint32 c1 = unpremul_alpha( c, a ); - double cc = *c/255.0; + double cc = c1/255.0; if( cc < 0.0031308 ) { cc *= 12.92; @@ -628,9 +628,9 @@ void linear_to_srgb( guint32* c, guint32 a ) { } cc *= 255.0; - *c = (int)cc; + const guint32 c2 = (int)cc; - *c = premul_alpha( *c, a ); + return premul_alpha( c2, a ); } int ink_cairo_surface_srgb_to_linear(cairo_surface_t *surface) @@ -647,9 +647,9 @@ int ink_cairo_surface_srgb_to_linear(cairo_surface_t *surface) guint32 px = *reinterpret_cast<guint32*>(data + 4*x); EXTRACT_ARGB32(px, a,r,g,b) ; // Unneeded semi-colon for indenting if( a != 0 ) { - srgb_to_linear( &r, a ); - srgb_to_linear( &g, a ); - srgb_to_linear( &b, a ); + r = srgb_to_linear( r, a ); + g = srgb_to_linear( g, a ); + b = srgb_to_linear( b, a ); } ASSEMBLE_ARGB32(px2, a,r,g,b); *reinterpret_cast<guint32*>(data + 4*x) = px2; @@ -672,9 +672,9 @@ int ink_cairo_surface_linear_to_srgb(cairo_surface_t *surface) guint32 px = *reinterpret_cast<guint32*>(data + 4*x); EXTRACT_ARGB32(px, a,r,g,b) ; // Unneeded semi-colon for indenting if( a != 0 ) { - linear_to_srgb( &r, a ); - linear_to_srgb( &g, a ); - linear_to_srgb( &b, a ); + r = linear_to_srgb( r, a ); + g = linear_to_srgb( g, a ); + b = linear_to_srgb( b, a ); } ASSEMBLE_ARGB32(px2, a,r,g,b); *reinterpret_cast<guint32*>(data + 4*x) = px2; diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index af4727c01..2596cd969 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -108,6 +108,7 @@ guint32 ink_cairo_surface_average_color(cairo_surface_t *surface); void ink_cairo_surface_average_color(cairo_surface_t *surface, double &r, double &g, double &b, double &a); void ink_cairo_surface_average_color_premul(cairo_surface_t *surface, double &r, double &g, double &b, double &a); +double srgb_to_linear( const double c ); int ink_cairo_surface_srgb_to_linear(cairo_surface_t *surface); int ink_cairo_surface_linear_to_srgb(cairo_surface_t *surface); @@ -127,13 +128,13 @@ G_GNUC_CONST guint32 argb32_from_rgba(guint32 in); G_GNUC_CONST inline guint32 -premul_alpha(guint32 color, guint32 alpha) +premul_alpha(const guint32 color, const guint32 alpha) { - guint32 temp = alpha * color + 128; + const guint32 temp = alpha * color + 128; return (temp + (temp >> 8)) >> 8; } G_GNUC_CONST inline guint32 -unpremul_alpha(guint32 color, guint32 alpha) +unpremul_alpha(const guint32 color, const guint32 alpha) { // NOTE: you must check for alpha != 0 yourself. return (255 * color + alpha/2) / alpha; @@ -153,6 +154,15 @@ void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv); #define ASSEMBLE_ARGB32(px,a,r,g,b) \ guint32 px = (a << 24) | (r << 16) | (g << 8) | b; +inline double srgb_to_linear( const double c ) { + if( c < 0.04045 ) { + return c / 12.92; + } else { + return pow( (c+0.055)/1.055, 2.4 ); + } +} + + namespace Inkscape { namespace Display diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index 1e6e44d6f..80664d822 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -550,10 +550,12 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag // for overlapping clip children. To fix this we use the SOURCE operator // instead of the default OVER. ict.setOperator(CAIRO_OPERATOR_SOURCE); + ict.paint(); if (_clip) { + ict.pushGroup(); _clip->clip(ict, *carea); // fixme: carea or area? - } else { - // if there is no clipping path, fill the entire surface with alpha = opacity. + ict.popGroupToSource(); + ict.setOperator(CAIRO_OPERATOR_IN); ict.paint(); } ict.setOperator(CAIRO_OPERATOR_OVER); // reset back to default diff --git a/src/display/nr-filter-diffuselighting.cpp b/src/display/nr-filter-diffuselighting.cpp index faf56a4ca..c6724e3ba 100644 --- a/src/display/nr-filter-diffuselighting.cpp +++ b/src/display/nr-filter-diffuselighting.cpp @@ -21,6 +21,8 @@ #include "display/nr-filter-units.h" #include "display/nr-filter-utils.h" #include "display/nr-light.h" +#include "svg/svg-icc-color.h" +#include "svg/svg-color.h" namespace Inkscape { namespace Filters { @@ -126,12 +128,37 @@ void FilterDiffuseLighting::render_cairo(FilterSlot &slot) cairo_surface_t *input = slot.getcairo(_input); cairo_surface_t *out = ink_cairo_surface_create_same_size(input, CAIRO_CONTENT_COLOR_ALPHA); + double r = SP_RGBA32_R_F(lighting_color); + double g = SP_RGBA32_G_F(lighting_color); + double b = SP_RGBA32_B_F(lighting_color); + +#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + + if (icc) { + guchar ru, gu, bu; + icc_color_to_sRGB(icc, &ru, &gu, &bu); + r = SP_COLOR_U_TO_F(ru); + g = SP_COLOR_U_TO_F(gu); + b = SP_COLOR_U_TO_F(bu); + } +#endif + // Only alpha channel of input is used, no need to check input color_interpolation_filter value. SPColorInterpolation ci_fp = SP_CSS_COLOR_INTERPOLATION_AUTO; if( _style ) { ci_fp = (SPColorInterpolation)_style->color_interpolation_filters.computed; + + // Lighting color is always defined in terms of sRGB, preconvert to linearRGB + // if color_interpolation_filters set to linearRGB (for efficiency assuming + // next filter primitive has same value of cif). + if( ci_fp == SP_CSS_COLOR_INTERPOLATION_LINEARRGB ) { + r = srgb_to_linear( r ); + g = srgb_to_linear( g ); + b = srgb_to_linear( b ); + } } set_cairo_surface_ci(out, ci_fp ); + guint32 color = SP_RGBA32_F_COMPOSE( r, g, b, 1.0 ); Geom::Rect slot_area = slot.get_slot_area(); Geom::Point p = slot_area.min(); @@ -142,15 +169,15 @@ void FilterDiffuseLighting::render_cairo(FilterSlot &slot) switch (light_type) { case DISTANT_LIGHT: ink_cairo_surface_synthesize(out, - DiffuseDistantLight(input, light.distant, lighting_color, scale, diffuseConstant)); + DiffuseDistantLight(input, light.distant, color, scale, diffuseConstant)); break; case POINT_LIGHT: ink_cairo_surface_synthesize(out, - DiffusePointLight(input, light.point, lighting_color, trans, scale, diffuseConstant, x0, y0)); + DiffusePointLight(input, light.point, color, trans, scale, diffuseConstant, x0, y0)); break; case SPOT_LIGHT: ink_cairo_surface_synthesize(out, - DiffuseSpotLight(input, light.spot, lighting_color, trans, scale, diffuseConstant, x0, y0)); + DiffuseSpotLight(input, light.spot, color, trans, scale, diffuseConstant, x0, y0)); break; default: { cairo_t *ct = cairo_create(out); @@ -165,6 +192,10 @@ void FilterDiffuseLighting::render_cairo(FilterSlot &slot) cairo_surface_destroy(out); } +void FilterDiffuseLighting::set_icc(SVGICCColor *icc_color) { + icc = icc_color; +} + void FilterDiffuseLighting::area_enlarge(Geom::IntRect &area, Geom::Affine const & /*trans*/) { // TODO: support kernelUnitLength diff --git a/src/display/nr-filter-diffuselighting.h b/src/display/nr-filter-diffuselighting.h index 0da6cc218..315bf9f48 100644 --- a/src/display/nr-filter-diffuselighting.h +++ b/src/display/nr-filter-diffuselighting.h @@ -22,6 +22,7 @@ class SPFeDistantLight; class SPFePointLight; class SPFeSpotLight; +class SVGICCColor; namespace Inkscape { namespace Filters { @@ -32,6 +33,7 @@ public: static FilterPrimitive *create(); virtual ~FilterDiffuseLighting(); virtual void render_cairo(FilterSlot &slot); + virtual void set_icc(SVGICCColor *icc_color); virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &trans); virtual double complexity(Geom::Affine const &ctm); @@ -46,6 +48,7 @@ public: guint32 lighting_color; private: + SVGICCColor *icc; }; } /* namespace Filters */ diff --git a/src/display/nr-filter-flood.cpp b/src/display/nr-filter-flood.cpp index 7117e0343..d1fe3e13f 100644 --- a/src/display/nr-filter-flood.cpp +++ b/src/display/nr-filter-flood.cpp @@ -45,8 +45,6 @@ void FilterFlood::render_cairo(FilterSlot &slot) #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - // DOES THIS REALLY BELONG HERE? SHOULDN'T ICC BE APPLIED AFTER ALL COMPOSITING? - // What if color_interpolation_filter is set to linear RGB? if (icc) { guchar ru, gu, bu; icc_color_to_sRGB(icc, &ru, &gu, &bu); @@ -57,10 +55,21 @@ void FilterFlood::render_cairo(FilterSlot &slot) #endif cairo_surface_t *out = ink_cairo_surface_create_same_size(input, CAIRO_CONTENT_COLOR_ALPHA); - // color_interpolation_filter is determined by CSS value (see spec. Turbulence). + + SPColorInterpolation ci_fp = SP_CSS_COLOR_INTERPOLATION_AUTO; if( _style ) { - set_cairo_surface_ci(out, (SPColorInterpolation)_style->color_interpolation_filters.computed ); + ci_fp = (SPColorInterpolation)_style->color_interpolation_filters.computed; + + // Flood color is always defined in terms of sRGB, preconvert to linearRGB + // if color_interpolation_filters set to linearRGB (for efficiency assuming + // next filter primitive has same value of cif). + if( ci_fp == SP_CSS_COLOR_INTERPOLATION_LINEARRGB ) { + r = srgb_to_linear( r ); + g = srgb_to_linear( g ); + b = srgb_to_linear( b ); + } } + set_cairo_surface_ci(out, ci_fp ); // Get filter primitive area in user units Geom::Rect fp = filter_primitive_area( slot.get_units() ); diff --git a/src/display/nr-filter-specularlighting.cpp b/src/display/nr-filter-specularlighting.cpp index 50f1b48c5..2ce02adee 100644 --- a/src/display/nr-filter-specularlighting.cpp +++ b/src/display/nr-filter-specularlighting.cpp @@ -21,6 +21,8 @@ #include "display/nr-filter-units.h" #include "display/nr-filter-utils.h" #include "display/nr-light.h" +#include "svg/svg-icc-color.h" +#include "svg/svg-color.h" namespace Inkscape { namespace Filters { @@ -139,12 +141,37 @@ void FilterSpecularLighting::render_cairo(FilterSlot &slot) cairo_surface_t *input = slot.getcairo(_input); cairo_surface_t *out = ink_cairo_surface_create_same_size(input, CAIRO_CONTENT_COLOR_ALPHA); + double r = SP_RGBA32_R_F(lighting_color); + double g = SP_RGBA32_G_F(lighting_color); + double b = SP_RGBA32_B_F(lighting_color); + +#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + + if (icc) { + guchar ru, gu, bu; + icc_color_to_sRGB(icc, &ru, &gu, &bu); + r = SP_COLOR_U_TO_F(ru); + g = SP_COLOR_U_TO_F(gu); + b = SP_COLOR_U_TO_F(bu); + } +#endif + // Only alpha channel of input is used, no need to check input color_interpolation_filter value. SPColorInterpolation ci_fp = SP_CSS_COLOR_INTERPOLATION_AUTO; if( _style ) { ci_fp = (SPColorInterpolation)_style->color_interpolation_filters.computed; + + // Lighting color is always defined in terms of sRGB, preconvert to linearRGB + // if color_interpolation_filters set to linearRGB (for efficiency assuming + // next filter primitive has same value of cif). + if( ci_fp == SP_CSS_COLOR_INTERPOLATION_LINEARRGB ) { + r = srgb_to_linear( r ); + g = srgb_to_linear( g ); + b = srgb_to_linear( b ); + } } set_cairo_surface_ci(out, ci_fp ); + guint32 color = SP_RGBA32_F_COMPOSE( r, g, b, 1.0 ); Geom::Affine trans = slot.get_units().get_matrix_primitiveunits2pb(); Geom::Point p = slot.get_slot_area().min(); @@ -157,15 +184,15 @@ void FilterSpecularLighting::render_cairo(FilterSlot &slot) switch (light_type) { case DISTANT_LIGHT: ink_cairo_surface_synthesize(out, - SpecularDistantLight(input, light.distant, lighting_color, scale, ks, se)); + SpecularDistantLight(input, light.distant, color, scale, ks, se)); break; case POINT_LIGHT: ink_cairo_surface_synthesize(out, - SpecularPointLight(input, light.point, lighting_color, trans, scale, ks, se, x0, y0)); + SpecularPointLight(input, light.point, color, trans, scale, ks, se, x0, y0)); break; case SPOT_LIGHT: ink_cairo_surface_synthesize(out, - SpecularSpotLight(input, light.spot, lighting_color, trans, scale, ks, se, x0, y0)); + SpecularSpotLight(input, light.spot, color, trans, scale, ks, se, x0, y0)); break; default: { cairo_t *ct = cairo_create(out); @@ -180,6 +207,10 @@ void FilterSpecularLighting::render_cairo(FilterSlot &slot) cairo_surface_destroy(out); } +void FilterSpecularLighting::set_icc(SVGICCColor *icc_color) { + icc = icc_color; +} + void FilterSpecularLighting::area_enlarge(Geom::IntRect &area, Geom::Affine const & /*trans*/) { // TODO: support kernelUnitLength diff --git a/src/display/nr-filter-specularlighting.h b/src/display/nr-filter-specularlighting.h index 33ea17a87..4f8c2d112 100644 --- a/src/display/nr-filter-specularlighting.h +++ b/src/display/nr-filter-specularlighting.h @@ -20,6 +20,7 @@ class SPFeDistantLight; class SPFePointLight; class SPFeSpotLight; +class SVGICCColor; namespace Inkscape { namespace Filters { @@ -33,6 +34,7 @@ public: virtual ~FilterSpecularLighting(); virtual void render_cairo(FilterSlot &slot); + virtual void set_icc(SVGICCColor *icc_color); virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &trans); virtual double complexity(Geom::Affine const &ctm); @@ -48,6 +50,7 @@ public: guint32 lighting_color; private: + SVGICCColor *icc; }; } /* namespace Filters */ diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index eb51860ab..8b20ab2de 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -227,21 +227,6 @@ public: static int pickCurrentItem(SPCanvas *canvas, GdkEvent *event); /** - * Class initialization function for SPCanvasClass. - */ - static void classInit(SPCanvasClass *klass); - - /** - * Callback: object initialization for SPCanvas. - */ - static void init(SPCanvas *canvas); - - /** - * Destroy handler for SPCanvas. - */ - static void dispose(GObject *object); - - /** * The canvas widget's realize callback. */ static void realize(GtkWidget *widget); @@ -369,25 +354,11 @@ public: static void add_idle(SPCanvas *canvas); /** - * Convenience function to remove the idle handler of a canvas. - */ - static void remove_idle(SPCanvas *canvas); - - /** - * Removes the transient state of the canvas (idle handler, grabs). - */ - static void shutdown_transients(SPCanvas *canvas); - - /** * Update callback for canvas widget. */ static void requestCanvasUpdate(SPCanvas *canvas); - - static GtkWidgetClass *parentClass; }; -GtkWidgetClass *SPCanvasImpl::parentClass = 0; - GType SPCanvasItem::getType() { static GType object_type = 0; @@ -437,9 +408,9 @@ void sp_canvas_item_class_init(SPCanvasItemClass *klass) G_TYPE_BOOLEAN, 1, GDK_TYPE_EVENT); - gobject_class->dispose = sp_canvas_item_dispose; + gobject_class->dispose = sp_canvas_item_dispose; gobject_class->finalize = sp_canvas_item_finalize; - klass->destroy = sp_canvas_item_real_destroy; + klass->destroy = sp_canvas_item_real_destroy; object_signals[DESTROY] = g_signal_new ("destroy", @@ -1218,68 +1189,46 @@ void SPCanvasGroup::remove(SPCanvasItem *item) } } -/** - * Registers the SPCanvas class if necessary, and returns the type ID - * associated to it. - * - * @return The type ID of the SPCanvas class. - */ -GType SPCanvas::getType(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPCanvasClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)SPCanvasImpl::classInit, - 0, // class_finalize - 0, // class_data - sizeof(SPCanvas), - 0, // n_preallocs - (GInstanceInitFunc)SPCanvasImpl::init, - 0 // value_table - }; - type = g_type_register_static(GTK_TYPE_WIDGET, "SPCanvas", &info, static_cast<GTypeFlags>(0)); - } - return type; -} +static void sp_canvas_dispose (GObject *object); +static void sp_canvas_shutdown_transients(SPCanvas *canvas); -void SPCanvasImpl::classInit(SPCanvasClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; - GtkWidgetClass *widget_class = (GtkWidgetClass *) klass; +G_DEFINE_TYPE(SPCanvas, sp_canvas, GTK_TYPE_WIDGET); - parentClass = reinterpret_cast<GtkWidgetClass *>(g_type_class_peek_parent(klass)); +static void +sp_canvas_class_init(SPCanvasClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS(klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); - object_class->dispose = SPCanvasImpl::dispose; + object_class->dispose = sp_canvas_dispose; - widget_class->realize = SPCanvasImpl::realize; - widget_class->unrealize = SPCanvasImpl::unrealize; + widget_class->realize = SPCanvasImpl::realize; + widget_class->unrealize = SPCanvasImpl::unrealize; #if GTK_CHECK_VERSION(3,0,0) - widget_class->get_preferred_width = SPCanvasImpl::getPreferredWidth; + widget_class->get_preferred_width = SPCanvasImpl::getPreferredWidth; widget_class->get_preferred_height = SPCanvasImpl::getPreferredHeight; - widget_class->draw = SPCanvasImpl::handleDraw; + widget_class->draw = SPCanvasImpl::handleDraw; #else - widget_class->size_request = SPCanvasImpl::sizeRequest; - widget_class->expose_event = SPCanvasImpl::handleExpose; + widget_class->size_request = SPCanvasImpl::sizeRequest; + widget_class->expose_event = SPCanvasImpl::handleExpose; #endif - widget_class->size_allocate = SPCanvasImpl::sizeAllocate; - widget_class->button_press_event = SPCanvasImpl::button; + widget_class->size_allocate = SPCanvasImpl::sizeAllocate; + widget_class->button_press_event = SPCanvasImpl::button; widget_class->button_release_event = SPCanvasImpl::button; - widget_class->motion_notify_event = SPCanvasImpl::handleMotion; - widget_class->scroll_event = SPCanvasImpl::handleScroll; - widget_class->key_press_event = SPCanvasImpl::handleKeyEvent; - widget_class->key_release_event = SPCanvasImpl::handleKeyEvent; - widget_class->enter_notify_event = SPCanvasImpl::handleCrossing; - widget_class->leave_notify_event = SPCanvasImpl::handleCrossing; - widget_class->focus_in_event = SPCanvasImpl::handleFocusIn; - widget_class->focus_out_event = SPCanvasImpl::handleFocusOut; + widget_class->motion_notify_event = SPCanvasImpl::handleMotion; + widget_class->scroll_event = SPCanvasImpl::handleScroll; + widget_class->key_press_event = SPCanvasImpl::handleKeyEvent; + widget_class->key_release_event = SPCanvasImpl::handleKeyEvent; + widget_class->enter_notify_event = SPCanvasImpl::handleCrossing; + widget_class->leave_notify_event = SPCanvasImpl::handleCrossing; + widget_class->focus_in_event = SPCanvasImpl::handleFocusIn; + widget_class->focus_out_event = SPCanvasImpl::handleFocusOut; } -void SPCanvasImpl::init(SPCanvas *canvas) +static void +sp_canvas_init(SPCanvas *canvas) { gtk_widget_set_has_window (GTK_WIDGET (canvas), TRUE); gtk_widget_set_double_buffered (GTK_WIDGET (canvas), FALSE); @@ -1318,7 +1267,7 @@ void SPCanvasImpl::init(SPCanvas *canvas) canvas->is_scrolling = false; } -void SPCanvasImpl::remove_idle(SPCanvas *canvas) +static void sp_canvas_remove_idle(SPCanvas *canvas) { if (canvas->idle_id) { g_source_remove (canvas->idle_id); @@ -1326,7 +1275,8 @@ void SPCanvasImpl::remove_idle(SPCanvas *canvas) } } -void SPCanvasImpl::shutdown_transients(SPCanvas *canvas) +static void +sp_canvas_shutdown_transients(SPCanvas *canvas) { // We turn off the need_redraw flag, since if the canvas is mapped again // it will request a redraw anyways. We do not turn off the need_update @@ -1352,10 +1302,11 @@ void SPCanvasImpl::shutdown_transients(SPCanvas *canvas) #endif } - remove_idle(canvas); + sp_canvas_remove_idle(canvas); } -void SPCanvasImpl::dispose(GObject *object) +static void +sp_canvas_dispose(GObject *object) { SPCanvas *canvas = SP_CANVAS(object); @@ -1364,12 +1315,12 @@ void SPCanvasImpl::dispose(GObject *object) canvas->root = NULL; } - shutdown_transients(canvas); + sp_canvas_shutdown_transients(canvas); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) canvas->cms_key.~ustring(); #endif - if (G_OBJECT_CLASS(parentClass)->dispose) { - (* G_OBJECT_CLASS(parentClass)->dispose)(object); + if (G_OBJECT_CLASS(sp_canvas_parent_class)->dispose) { + (* G_OBJECT_CLASS(sp_canvas_parent_class)->dispose)(object); } } @@ -1388,7 +1339,7 @@ void trackLatency(GdkEvent const *event) GtkWidget *SPCanvas::createAA() { - SPCanvas *canvas = reinterpret_cast<SPCanvas *>(g_object_new(SPCanvas::getType(), NULL)); + SPCanvas *canvas = SP_CANVAS(g_object_new(SP_TYPE_CANVAS, NULL)); return GTK_WIDGET(canvas); } @@ -1456,10 +1407,10 @@ void SPCanvasImpl::unrealize(GtkWidget *widget) canvas->grabbed_item = NULL; canvas->focused_item = NULL; - shutdown_transients(canvas); + sp_canvas_shutdown_transients(canvas); - if (GTK_WIDGET_CLASS(parentClass)->unrealize) - (* GTK_WIDGET_CLASS(parentClass)->unrealize)(widget); + if (GTK_WIDGET_CLASS(sp_canvas_parent_class)->unrealize) + (* GTK_WIDGET_CLASS(sp_canvas_parent_class)->unrealize)(widget); } diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index f0366a2e5..b570b739e 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -39,7 +39,7 @@ G_BEGIN_DECLS -#define SP_TYPE_CANVAS (SPCanvas::getType()) +#define SP_TYPE_CANVAS (sp_canvas_get_type()) #define SP_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_CANVAS, SPCanvas)) #define SP_IS_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_CANVAS)) @@ -71,14 +71,14 @@ G_END_DECLS class SPCanvasImpl; +GType sp_canvas_get_type() G_GNUC_CONST; + /** * Port of GnomeCanvas for inkscape needs. */ struct SPCanvas { friend class SPCanvasImpl; - static GType getType(); - /** * Returns new canvas as widget. */ diff --git a/src/document.cpp b/src/document.cpp index 172037518..97b3bf584 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1435,10 +1435,12 @@ bool SPDocument::isSeeking() const { void SPDocument::setModifiedSinceSave(bool modified) { this->modified_since_save = modified; - Gtk::Window *parent = SP_ACTIVE_DESKTOP->getToplevel(); - g_assert(parent != NULL); - SPDesktopWidget *dtw = static_cast<SPDesktopWidget *>(parent->get_data("desktopwidget")); - dtw->updateTitle( this->getName() ); + if (SP_ACTIVE_DESKTOP) { + Gtk::Window *parent = SP_ACTIVE_DESKTOP->getToplevel(); + g_assert(parent != NULL); + SPDesktopWidget *dtw = static_cast<SPDesktopWidget *>(parent->get_data("desktopwidget")); + dtw->updateTitle( this->getName() ); + } } diff --git a/src/dom/CMakeLists.txt b/src/dom/CMakeLists.txt index df2411b13..5d761e649 100644 --- a/src/dom/CMakeLists.txt +++ b/src/dom/CMakeLists.txt @@ -19,17 +19,12 @@ set(dom_SRC xpathparser.cpp xpathtoken.cpp - io/base64stream.cpp io/bufferstream.cpp io/domstream.cpp - io/gzipstream.cpp io/stringstream.cpp io/uristream.cpp - odf/odfdocument.cpp - util/digest.cpp - util/thread.cpp util/ziptool.cpp @@ -64,17 +59,12 @@ set(dom_SRC xpathparser.h xpathtoken.h - odf/odfdocument.h - - io/base64stream.h io/bufferstream.h io/domstream.h - io/gzipstream.h io/stringstream.h io/uristream.h util/digest.h - util/thread.h util/ziptool.h ) diff --git a/src/dom/Makefile_insert b/src/dom/Makefile_insert index ace53b4a2..91c91eeac 100644 --- a/src/dom/Makefile_insert +++ b/src/dom/Makefile_insert @@ -50,26 +50,16 @@ dom_libdom_a_SOURCES = \ dom/xpathparser.h \ dom/xpathtoken.h \ dom/xpathtoken.cpp \ - dom/io/base64stream.cpp \ - dom/io/base64stream.h \ dom/io/bufferstream.cpp \ dom/io/bufferstream.h \ dom/io/domstream.cpp \ dom/io/domstream.h \ - dom/io/gzipstream.cpp \ - dom/io/gzipstream.h \ - dom/io/gzipstream.cpp \ - dom/io/gzipstream.h \ dom/io/stringstream.cpp \ dom/io/stringstream.h \ dom/io/uristream.cpp \ dom/io/uristream.h \ - dom/odf/odfdocument.cpp \ - dom/odf/odfdocument.h \ dom/util/digest.h \ dom/util/digest.cpp \ - dom/util/thread.h \ - dom/util/thread.cpp \ dom/util/ziptool.h \ dom/util/ziptool.cpp diff --git a/src/dom/domimpl.cpp b/src/dom/domimpl.cpp index 9f25cb3be..3d9a29592 100644 --- a/src/dom/domimpl.cpp +++ b/src/dom/domimpl.cpp @@ -1701,7 +1701,6 @@ void ElementImpl::normalizeNamespaces() if (attrNode->getNodeType() != Node::ATTRIBUTE_NODE) continue; AttrImplPtr attr = reinterpret_cast<AttrImpl *>(attrNode.get()); - DOMString attrNS = attr->getNamespaceURI(); DOMString attrName = attr->getLocalName(); DOMString attrPrefix = attr->getPrefix(); DOMString attrValue = attr->getNodeValue(); @@ -1826,7 +1825,6 @@ void ElementImpl::normalizeNamespaces() AttrPtr attr = reinterpret_cast<Attr *>(attrNode.get()); DOMString attrNS = attr->getNamespaceURI(); DOMString attrPrefix = attr->getPrefix(); - DOMString attrValue = attr->getNodeValue(); if (attrNS == XMLNSNAME) continue; @@ -2360,12 +2358,15 @@ CDATASectionImpl::~CDATASectionImpl() DocumentTypeImpl::DocumentTypeImpl(const DOMString& theName, const DOMString& thePublicId, const DOMString& theSystemId) - : NodeImpl() + : NodeImpl(), + name(), //what with this variable? + publicId(thePublicId), + systemId(theSystemId), + entities(), + notations() { - nodeType = DOCUMENT_TYPE_NODE; - nodeName = theName; - publicId = thePublicId; - systemId = theSystemId; + nodeType = DOCUMENT_TYPE_NODE;//of class NodeImpl + nodeName = theName;//of class NodeImpl } /** @@ -3017,19 +3018,22 @@ NodePtr DocumentImpl::renameNode(const NodePtr node, DocumentImpl::DocumentImpl(const DOMImplementation *domImpl, const DOMString &/*theNamespaceURI*/, const DOMString &theQualifiedName, - const DocumentTypePtr theDoctype) : NodeImpl() -{ - nodeType = DOCUMENT_NODE; - nodeName = "#document"; - parent = const_cast<DOMImplementation *>(domImpl); - //documentURI = stringCache(theNamespaceURI); - qualifiedName = theQualifiedName; + const DocumentTypePtr theDoctype) + : NodeImpl(), + namespaceIndex(0), + parent(const_cast<DOMImplementation *>(domImpl)), + qualifiedName(theQualifiedName), + xmlStandalone(false), + strictErrorChecking(false), + domConfig(NULL) +{ + nodeType = DOCUMENT_NODE;//of class NodeImpl + nodeName = "#document";//of class NodeImpl if (theDoctype.get()) //only assign if not null. doctype = theDoctype; else doctype = new DocumentTypeImpl("", "", ""); documentElement = new ElementImpl(this, "root"); - namespaceIndex = 0; } diff --git a/src/dom/domimpl.h b/src/dom/domimpl.h index 5fe508076..df586f35e 100644 --- a/src/dom/domimpl.h +++ b/src/dom/domimpl.h @@ -526,11 +526,11 @@ protected: UserDataEntry(const DOMString &theKey, const DOMUserData *theData, const UserDataHandler *theHandler) + : next(NULL), + key(theKey), + data(const_cast<DOMUserData *>(theData)), + handler(const_cast<UserDataHandler *>(theHandler)) { - next = NULL; - key = theKey; - data = const_cast<DOMUserData *>(theData); - handler = const_cast<UserDataHandler *>(theHandler); } virtual ~UserDataEntry() @@ -1967,10 +1967,10 @@ protected: next = NULL; } NamedElementItem(const DOMString &nameArg, ElementPtr elemArg) + : next (NULL), + name (nameArg), + elem (elemArg) { - next = NULL; - name = nameArg; - elem = elemArg; } ~NamedElementItem() { diff --git a/src/dom/events.h b/src/dom/events.h index 9f44fe591..59d83afcf 100644 --- a/src/dom/events.h +++ b/src/dom/events.h @@ -643,8 +643,8 @@ public: * */ EventTarget(const EventTarget &other) + : listeners (other.listeners) { - listeners = other.listeners; } /** @@ -704,7 +704,9 @@ public: /** * */ - DocumentEvent() {} + DocumentEvent() + : dispatchable(false) + {} /** * @@ -791,7 +793,10 @@ public: /** * */ - CustomEvent() {} + CustomEvent() + : propagationStopped(false), + immediatePropagationStopped(false) + {} /** * @@ -884,15 +889,19 @@ public: /** * */ - UIEvent() {} + UIEvent() + : view(), + detail(0) + {} /** * */ - UIEvent(const UIEvent &other) : Event(other) + UIEvent(const UIEvent &other) + : Event(other), + view(other.view), + detail(other.detail) { - view = other.view; - detail = other.detail; } /** @@ -1152,7 +1161,18 @@ public: /** * */ - MouseEvent() {} + MouseEvent() + : screenX(0), + screenY(0), + clientX(0), + clientY(0), + ctrlKey(false), + shiftKey(false), + altKey(false), + metaKey(false), + button(0), + relatedTarget(NULL) + {} /** * @@ -1322,7 +1342,14 @@ public: /** * */ - KeyboardEvent() {} + KeyboardEvent() + : keyIdentifier(), + keyLocation(0), + ctrlKey(false), + shiftKey(false), + altKey(false), + metaKey(false) + {} /** * @@ -1472,8 +1499,9 @@ public: * */ MutationEvent() + : relatedNodePtr (NULL), + attrChange(0) { - relatedNodePtr = NULL; } /** diff --git a/src/dom/io/base64stream.cpp b/src/dom/io/base64stream.cpp deleted file mode 100644 index 433675e18..000000000 --- a/src/dom/io/base64stream.cpp +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Phoebe DOM Implementation. - * - * Base64-enabled input and output streams - * - * This class allows easy encoding and decoding - * of Base64 data with a stream interface, hiding - * the implementation from the user. - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2006 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - - -#include "base64stream.h" - - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace io -{ - - -//######################################################################### -//# B A S E 6 4 I N P U T S T R E A M -//######################################################################### - -static int base64decode[] = -{ -/*00*/ -1, -1, -1, -1, -1, -1, -1, -1, -/*08*/ -1, -1, -1, -1, -1, -1, -1, -1, -/*10*/ -1, -1, -1, -1, -1, -1, -1, -1, -/*18*/ -1, -1, -1, -1, -1, -1, -1, -1, -/*20*/ -1, -1, -1, -1, -1, -1, -1, -1, -/*28*/ -1, -1, -1, 62, -1, -1, -1, 63, -/*30*/ 52, 53, 54, 55, 56, 57, 58, 59, -/*38*/ 60, 61, -1, -1, -1, -1, -1, -1, -/*40*/ -1, 0, 1, 2, 3, 4, 5, 6, -/*48*/ 7, 8, 9, 10, 11, 12, 13, 14, -/*50*/ 15, 16, 17, 18, 19, 20, 21, 22, -/*58*/ 23, 24, 25, -1, -1, -1, -1, -1, -/*60*/ -1, 26, 27, 28, 29, 30, 31, 32, -/*68*/ 33, 34, 35, 36, 37, 38, 39, 40, -/*70*/ 41, 42, 43, 44, 45, 46, 47, 48, -/*78*/ 49, 50, 51, -1, -1, -1, -1, -1 -}; - - -/** - * - */ -Base64InputStream::Base64InputStream(InputStream &sourceStream) - : BasicInputStream(sourceStream) -{ - outCount = 0; - padCount = 0; - closed = false; - done = false; -} - -/** - * - */ -Base64InputStream::~Base64InputStream() -{ - close(); -} - -/** - * Returns the number of bytes that can be read (or skipped over) from - * this input stream without blocking by the next caller of a method for - * this input stream. - */ -int Base64InputStream::available() -{ - if (closed ) - return 0; - int len = source.available() * 2 / 3; - return len; -} - - -/** - * Closes this input stream and releases any system resources - * associated with the stream. - */ -void Base64InputStream::close() -{ - if (closed) - return; - source.close(); - closed = true; -} - -/** - * Reads the next byte of data from the input stream. -1 if EOF - */ -int Base64InputStream::get() -{ - if (closed) - return -1; - - if (outCount - padCount > 0) - { - return outBytes[3-(outCount--)]; - } - - if (done) - return -1; - - int inBytes[4]; - int inCount = 0; - while (inCount < 4) - { - int ch = source.get(); - if (ch < 0) - { - while (inCount < 4) //pad if needed - { - inBytes[inCount++] = 0; - padCount++; - } - done = true; - break; - } - if (isspace(ch)) //ascii whitespace - { - //nothing - } - else if (ch == '=') //padding - { - inBytes[inCount++] = 0; - padCount++; - } - else - { - int byteVal = base64decode[ch & 0x7f]; - //printf("char:%c %d\n", ch, byteVal); - if (byteVal < 0) - { - //Bad lookup value - } - inBytes[inCount++] = byteVal; - } - } - - outBytes[0] = ((inBytes[0]<<2) & 0xfc) | ((inBytes[1]>>4) & 0x03); - outBytes[1] = ((inBytes[1]<<4) & 0xf0) | ((inBytes[2]>>2) & 0x0f); - outBytes[2] = ((inBytes[2]<<6) & 0xc0) | ((inBytes[3] ) & 0x3f); - - outCount = 3; - - //try again - if (outCount - padCount > 0) - { - return outBytes[3-(outCount--)]; - } - - return -1; - -} - - -//######################################################################### -//# B A S E 6 4 O U T P U T S T R E A M -//######################################################################### - -static char const *base64encode = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -/** - * - */ -Base64OutputStream::Base64OutputStream(OutputStream &destinationStream) - : BasicOutputStream(destinationStream) -{ - column = 0; - columnWidth = 72; - outBuf = 0L; - bitCount = 0; -} - -/** - * - */ -Base64OutputStream::~Base64OutputStream() -{ - close(); -} - -/** - * Closes this output stream and releases any system resources - * associated with this stream. - */ -void Base64OutputStream::close() -{ - if (closed) - return; - - //get any last bytes (1 or 2) out of the buffer - if (bitCount == 16) - { - outBuf <<= 2; //pad to make 18 bits - - int indx = (int)((outBuf & 0x0003f000L) >> 12); - int obyte = (int)base64encode[indx & 63]; - putCh(obyte); - - indx = (int)((outBuf & 0x00000fc0L) >> 6); - obyte = (int)base64encode[indx & 63]; - putCh(obyte); - - indx = (int)((outBuf & 0x0000003fL) ); - obyte = (int)base64encode[indx & 63]; - putCh(obyte); - - putCh('='); - } - else if (bitCount == 8) - { - outBuf <<= 4; //pad to make 12 bits - - int indx = (int)((outBuf & 0x00000fc0L) >> 6); - int obyte = (int)base64encode[indx & 63]; - putCh(obyte); - - indx = (int)((outBuf & 0x0000003fL) ); - obyte = (int)base64encode[indx & 63]; - putCh(obyte); - - putCh('='); - putCh('='); - } - - if (columnWidth > 0) //if <=0, no newlines - destination.put('\n'); - - destination.close(); - closed = true; -} - -/** - * Flushes this output stream and forces any buffered output - * bytes to be written out. - */ -void Base64OutputStream::flush() -{ - if (closed) - return; - //dont flush here. do it on close() - destination.flush(); -} - -/** - * Private. Put a char to the output stream, checking for line length - */ -void Base64OutputStream::putCh(int ch) -{ - destination.put(ch); - column++; - if (columnWidth > 0 && column >= columnWidth) - { - destination.put('\n'); - column = 0; - } -} - - -/** - * Writes the specified byte to this output stream. - */ -int Base64OutputStream::put(XMLCh ch) -{ - if (closed) - { - //probably throw an exception here - return -1; - } - - outBuf <<= 8; - outBuf |= (ch & 0xff); - bitCount += 8; - if (bitCount >= 24) - { - int indx = (int)((outBuf & 0x00fc0000L) >> 18); - int obyte = (int)base64encode[indx & 63]; - putCh(obyte); - - indx = (int)((outBuf & 0x0003f000L) >> 12); - obyte = (int)base64encode[indx & 63]; - putCh(obyte); - - indx = (int)((outBuf & 0x00000fc0L) >> 6); - obyte = (int)base64encode[indx & 63]; - putCh(obyte); - - indx = (int)((outBuf & 0x0000003fL) ); - obyte = (int)base64encode[indx & 63]; - putCh(obyte); - - bitCount = 0; - outBuf = 0L; - } - - return 1; -} - - - -} //namespace io -} //namespace dom -} //namespace w3c -} //namespace org - - -//######################################################################### -//# E N D O F F I L E -//######################################################################### diff --git a/src/dom/io/base64stream.h b/src/dom/io/base64stream.h deleted file mode 100644 index 93bb5c7e5..000000000 --- a/src/dom/io/base64stream.h +++ /dev/null @@ -1,148 +0,0 @@ -#ifndef SEEN_DOM_IO_BASE64STREAM_H -#define SEEN_DOM_IO_BASE64STREAM_H - -/** - * @file - * Phoebe DOM Implementation. - * - * Base64-enabled input and output streams - * - * This class allows easy encoding and decoding - * of Base64 data with a stream interface, hiding - * the implementation from the user. - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - */ -/* - * Authors: - * Bob Jamison - * - * Copyright (C) 2006 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - - -#include "domstream.h" - - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace io -{ - - - -//######################################################################### -//# B A S E 6 4 I N P U T S T R E A M -//######################################################################### - -/** - * This class is for decoding a Base-64 encoded InputStream source - * - */ -class Base64InputStream : public BasicInputStream -{ - -public: - - Base64InputStream(InputStream &sourceStream); - - virtual ~Base64InputStream(); - - virtual int available(); - - virtual void close(); - - virtual int get(); - -private: - - int outBytes[3]; - - int outCount; - - int padCount; - - bool done; - -}; // class Base64InputStream - - - - -//######################################################################### -//# B A S E 6 4 O U T P U T S T R E A M -//######################################################################### - -/** - * This class is for Base-64 encoding data going to the - * destination OutputStream - * - */ -class Base64OutputStream : public BasicOutputStream -{ - -public: - - Base64OutputStream(OutputStream &destinationStream); - - virtual ~Base64OutputStream(); - - virtual void close(); - - virtual void flush(); - - virtual int put(XMLCh ch); - - /** - * Sets the maximum line length for base64 output. If - * set to <=0, then there will be no line breaks; - */ - virtual void setColumnWidth(int val) - { columnWidth = val; } - -private: - - void putCh(int ch); - - int column; - - int columnWidth; - - unsigned long outBuf; - - int bitCount; - -}; // class Base64OutputStream - - - - - - - -} //namespace io -} //namespace dom -} //namespace w3c -} //namespace org - - -#endif // SEEN_DOM_IO_BASE64STREAM_H diff --git a/src/dom/io/domstream.h b/src/dom/io/domstream.h index b2e308653..1a93e73b2 100644 --- a/src/dom/io/domstream.h +++ b/src/dom/io/domstream.h @@ -51,7 +51,8 @@ class StreamException public: StreamException(const DOMString &theReason) throw() - { reason = theReason; } + : reason(theReason) + {} virtual ~StreamException() throw() { } char const *what() @@ -576,7 +577,13 @@ protected: Writer *destination; BasicWriter() - { destination = NULL; } + { + destination = NULL; + for(int k=0;k<2048;++k) + { + formatBuf[k]=0; + } + } //Used for printf() or other things that might //require formatting before sending down the stream diff --git a/src/dom/io/gzipstream.cpp b/src/dom/io/gzipstream.cpp deleted file mode 100644 index e1f9f9a60..000000000 --- a/src/dom/io/gzipstream.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Zlib-enabled input and output streams - * - * This is a thin wrapper of libz calls, in order - * to provide a simple interface to our developers - * for gzip input and output. - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2006-2007 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - - -#include "gzipstream.h" - -#include "dom/util/ziptool.h" - - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace io -{ - - -//######################################################################### -//# G Z I P I N P U T S T R E A M -//######################################################################### - -/** - * - */ -GzipInputStream::GzipInputStream(InputStream &sourceStream) - : BasicInputStream(sourceStream) -{ - loaded = false; - bufPos = 0; -} - -/** - * - */ -GzipInputStream::~GzipInputStream() -{ - close(); -} - -/** - * Returns the number of bytes that can be read (or skipped over) from - * this input stream without blocking by the next caller of a method for - * this input stream. - */ -int GzipInputStream::available() -{ - if (closed) - return 0; - if (!loaded) - if (!load()) - return 0; - return (int) buffer.size(); -} - - -/** - * Closes this input stream and releases any system resources - * associated with the stream. - */ -void GzipInputStream::close() -{ - if (closed) - return; - - closed = true; -} - -/** - * Reads the next byte of data from the input stream. -1 if EOF - */ -int GzipInputStream::get() -{ - if (closed) - return -1; - - if (!loaded) - if (!load()) - return -1; - - if (bufPos >= buffer.size()) - return -1; - int ch = (int) buffer[bufPos++]; - - return ch; -} - -/** - * Processes input. Fills read buffer. - */ -bool GzipInputStream::load() -{ - if (closed) - return false; - - if (loaded) - return true; - - std::vector<unsigned char> compBuf; - while (true) - { - int ch = source.get(); - if (ch < 0) - break; - compBuf.push_back(ch); - } - GzipFile gz; - if (!gz.readBuffer(compBuf)) - { - return -1; - } - buffer = gz.getData(); - bufPos = 0; - loaded = true; - return true; -} - - - - - - -//######################################################################### -//# G Z I P O U T P U T S T R E A M -//######################################################################### - -/** - * - */ -GzipOutputStream::GzipOutputStream(OutputStream &destinationStream) - : BasicOutputStream(destinationStream) -{ - - closed = false; -} - -/** - * - */ -GzipOutputStream::~GzipOutputStream() -{ - close(); -} - -/** - * Closes this output stream and releases any system resources - * associated with this stream. - */ -void GzipOutputStream::close() -{ - if (closed) - return; - - flush(); - - closed = true; -} - -/** - * Flushes this output stream and forces any buffered output - * bytes to be written out. - */ -void GzipOutputStream::flush() -{ - if (closed || buffer.size()<1) - return; - - std::vector<unsigned char> compBuf; - GzipFile gz; - - gz.writeBuffer(buffer); - - std::vector<unsigned char>::iterator iter; - for (iter=compBuf.begin() ; iter!=compBuf.end() ; ++iter) - { - int ch = (int) *iter; - destination.put(ch); - } - - buffer.clear(); - - //printf("done\n"); - -} - - - -/** - * Writes the specified byte to this output stream. - */ -int GzipOutputStream::put(XMLCh ch) -{ - if (closed) - { - //probably throw an exception here - return -1; - } - - //Add char to buffer - buffer.push_back(ch); - return 1; -} - - - -} // namespace io -} // namespace dom -} // namespace w3c -} // namespace org - - - - -//######################################################################### -//# E N D O F F I L E -//######################################################################### - - - diff --git a/src/dom/io/gzipstream.h b/src/dom/io/gzipstream.h deleted file mode 100644 index 6e82c3531..000000000 --- a/src/dom/io/gzipstream.h +++ /dev/null @@ -1,126 +0,0 @@ -#ifndef SEEN_GZIPSTREAM_H -#define SEEN_GZIPSTREAM_H -/** - * Zlib-enabled input and output streams - * - * This provides a simple mechanism for reading and - * writing Gzip files. We use our own 'ZipTool' class - * to accomplish this, avoiding a zlib dependency. - */ -/* - * Authors: - * Bob Jamison - * - * Copyright (C) 2006-2007 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - - - -#include "domstream.h" - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace io -{ - -//######################################################################### -//# G Z I P I N P U T S T R E A M -//######################################################################### - -/** - * This class is for deflating a gzip-compressed InputStream source - * - */ -class GzipInputStream : public BasicInputStream -{ - -public: - - GzipInputStream(InputStream &sourceStream); - - virtual ~GzipInputStream(); - - virtual int available(); - - virtual void close(); - - virtual int get(); - -private: - - bool load(); - - bool loaded; - - std::vector<unsigned char> buffer; - unsigned int bufPos; - - -}; // class GzipInputStream - - - - -//######################################################################### -//# G Z I P O U T P U T S T R E A M -//######################################################################### - -/** - * This class is for gzip-compressing data going to the - * destination OutputStream - * - */ -class GzipOutputStream : public BasicOutputStream -{ - -public: - - GzipOutputStream(OutputStream &destinationStream); - - virtual ~GzipOutputStream(); - - virtual void close(); - - virtual void flush(); - - virtual int put(XMLCh ch); - -private: - - std::vector<unsigned char> buffer; - - -}; // class GzipOutputStream - - - - - - - -} // namespace io -} // namespace dom -} // namespace w3c -} // namespace org - - -#endif // SEEN_GZIPSTREAM_H diff --git a/src/dom/lsimpl.cpp b/src/dom/lsimpl.cpp index 94b0adeb7..d4da0d5ce 100644 --- a/src/dom/lsimpl.cpp +++ b/src/dom/lsimpl.cpp @@ -227,7 +227,7 @@ bool LSSerializerImpl::writeToURI(const NodePtr nodeArg, DOMString uri = uriArg; char *fileName = (char *) uri.c_str(); //temporary hack - FILE *f = fopen(fileName, "rb"); + FILE *f = fopen(fileName, "wb"); if (!f) return false; for (unsigned int i=0 ; i<outbuf.size() ; i++) diff --git a/src/dom/odf/odfdocument.cpp b/src/dom/odf/odfdocument.cpp deleted file mode 100644 index 1e7a61e4e..000000000 --- a/src/dom/odf/odfdocument.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * - * This class contains an ODF Document. - * Initially, we are just concerned with .odg content.xml + resources - * - * --------------------------------------------------------------------- - * - * Copyright (C) 2006-2008 Bob Jamison - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * For more information, please write to rwjj@earthlink.net - * - * RWJ : 080207: Changed to GPL2 by me - * - */ - -#include "odfdocument.h" - - -namespace odf -{ - - -//######################################################################## -//# I M A G E D A T A -//######################################################################## - - -/** - * - */ -ImageData::ImageData(const std::string &fname, - const std::vector<unsigned char> &buf) -{ - fileName = fname; - data = buf; -} - -/** - * - */ -ImageData::ImageData(const ImageData &other) -{ - fileName = other.fileName; - data = other.data; -} - -/** - * - */ -ImageData::~ImageData() -{ -} - -/** - * - */ -std::string ImageData::getFileName() -{ - return fileName; -} - -/** - * - */ -void ImageData::setFileName(const std::string &val) -{ - fileName = val; -} - -/** - * - */ -std::vector<unsigned char> &ImageData::getData() -{ - return data; -} - -/** - * - */ -void ImageData::setData(const std::vector<unsigned char> &buf) -{ - data = buf; -} - - - - - -//######################################################################## -//# O D F D O C U M E N T -//######################################################################## - - - -/** - * - */ -OdfDocument::OdfDocument() : - content(0), - images() -{ -} - - -/** - * - */ -OdfDocument::OdfDocument(const OdfDocument &other) -{ - content = other.content; - images = other.images; -} - - -/** - * - */ -OdfDocument::~OdfDocument() -{ -} - -/** - * - */ -bool OdfDocument::readFile(const std::string &/*fileName*/) -{ - return true; -} - -/** - * - */ -bool OdfDocument::writeFile(const std::string &/*fileName*/) -{ - return true; -} - - - - - -} //namespace odf - - - - -//######################################################################## -//# E N D O F F I L E -//######################################################################## - diff --git a/src/dom/odf/odfdocument.h b/src/dom/odf/odfdocument.h deleted file mode 100644 index 168df11c7..000000000 --- a/src/dom/odf/odfdocument.h +++ /dev/null @@ -1,150 +0,0 @@ -#ifndef SEEN_ODF_DOCUMENT_H -#define SEEN_ODF_DOCUMENT_H -/* - * Copyright (C) 2006 Bob Jamison - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * For more information, please write to rwjj@earthlink.net - * - * RWJ : 080207: Changed to GPL2 by me - */ - -#include <vector> -#include <string> - -#include "dom/dom.h" - -namespace odf -{ - - -//######################################################################## -//# I M A G E D A T A -//######################################################################## - -/** - * - */ -class ImageData -{ -public: - - /** - * - */ - ImageData(const std::string &fileName, - const std::vector<unsigned char> &buf); - - /** - * - */ - ImageData(const ImageData &other); - - /** - * - */ - virtual ~ImageData(); - - /** - * - */ - virtual std::string getFileName(); - - /** - * - */ - virtual void setFileName(const std::string &val); - - /** - * - */ - virtual std::vector<unsigned char> &getData(); - - /** - * - */ - virtual void setData(const std::vector<unsigned char> &buf); - -private: - - std::string fileName; - - std::vector<unsigned char> data; - -}; - - - - - -//######################################################################## -//# O D F D O C U M E N T -//######################################################################## - - -/** - * - * This class contains an ODF Document. - * Initially, we are just concerned with .odg content.xml + resources - */ -class OdfDocument -{ -public: - - /** - * - */ - OdfDocument(); - - /** - * Copy constructor - */ - OdfDocument(const OdfDocument &other); - - /** - * - */ - virtual ~OdfDocument(); - - /** - * - */ - virtual bool readFile(const std::string &fileName); - - /** - * - */ - virtual bool writeFile(const std::string &fileName); - - -private: - - org::w3c::dom::Document *content; - - std::vector<ImageData> images; - -}; - -} //namespace odf - - - -#endif // SEEN_ODF_DOCUMENT_H - -//######################################################################## -//# E N D O F F I L E -//######################################################################## - diff --git a/src/dom/smil.h b/src/dom/smil.h index 15bc361ac..14870a4e4 100644 --- a/src/dom/smil.h +++ b/src/dom/smil.h @@ -193,7 +193,12 @@ public: /** * */ - ElementLayout() {} + ElementLayout() : + title(), + backgroundColor(), + height(0), + width(0) + {} /** * @@ -274,8 +279,9 @@ public: /** * */ - SMILRegionInterface(const SMILRegionInterface &other) - { regionElement = other.regionElement; } + SMILRegionInterface(const SMILRegionInterface &other) : + regionElement (other.regionElement) + {} /** * @@ -542,9 +548,9 @@ public: /** * */ - TimeList(const TimeList &other) + TimeList(const TimeList &other) : + items (other.items) { - items = other.items; } /** @@ -1586,7 +1592,15 @@ public: /** * */ - ElementTest() + ElementTest() : + systemBitrate (0), + systemCaptions (false), + systemLanguage (), + systemRequired (false), + systemScreenSize (false), + systemScreenDepth (false), + systemOverdubOrSubtitle (), + systemAudioDesc (false) { } @@ -1629,8 +1643,6 @@ public: protected: - - long systemBitrate; bool systemCaptions; DOMString systemLanguage; diff --git a/src/dom/svgimpl.h b/src/dom/svgimpl.h index 83d56fa22..2ee5c8bc7 100644 --- a/src/dom/svgimpl.h +++ b/src/dom/svgimpl.h @@ -980,7 +980,14 @@ public: /** * */ - SVGSVGElementImpl() : SVGElementImpl() + SVGSVGElementImpl() : SVGElementImpl(), + pixelUnitToMillimeterX(0), + pixelUnitToMillimeterY(0), + screenPixelToMillimeterX(0), + screenPixelToMillimeterY(0), + useCurrentView(false), + currentScale(0), + currentTime(0) {} diff --git a/src/dom/svgtypes.h b/src/dom/svgtypes.h index 41b4de307..bb828571f 100644 --- a/src/dom/svgtypes.h +++ b/src/dom/svgtypes.h @@ -645,20 +645,20 @@ public: /** * */ - SVGTransform() + SVGTransform() : + type (SVG_TRANSFORM_UNKNOWN), + angle (0.0) { - type = SVG_TRANSFORM_UNKNOWN; - angle = 0.0; } /** * */ - SVGTransform(const SVGTransform &other) + SVGTransform(const SVGTransform &other) : + type (other.type), + angle (other.angle), + matrix (other.matrix) { - type = other.type; - angle = other.angle; - matrix = other.matrix; } /** @@ -834,9 +834,9 @@ public: /** * */ - SVGTransformList(const SVGTransformList &other) + SVGTransformList(const SVGTransformList &other) : + items (other.items) { - items = other.items; } /** @@ -893,10 +893,10 @@ public: /** * */ - SVGAnimatedTransformList(const SVGAnimatedTransformList &other) + SVGAnimatedTransformList(const SVGAnimatedTransformList &other) : + baseVal (other.baseVal), + animVal (other.animVal) { - baseVal = other.baseVal; - animVal = other.animVal; } /** @@ -1181,9 +1181,9 @@ public: /** * */ - SVGStringList(const SVGStringList &other) + SVGStringList(const SVGStringList &other) : + items (other.items) { - items = other.items; } /** @@ -1657,9 +1657,9 @@ public: /** * */ - SVGNumberList(const SVGNumberList &other) + SVGNumberList(const SVGNumberList &other) : + items (other.items) { - items = other.items; } /** @@ -1719,10 +1719,10 @@ public: /** * */ - SVGAnimatedNumberList(const SVGAnimatedNumberList &other) + SVGAnimatedNumberList(const SVGAnimatedNumberList &other) : + baseVal (other.baseVal), + animVal (other.animVal) { - baseVal = other.baseVal; - animVal = other.animVal; } /** @@ -1934,10 +1934,10 @@ public: /** * */ - SVGAnimatedLength(const SVGAnimatedLength &other) + SVGAnimatedLength(const SVGAnimatedLength &other) : + baseVal (other.baseVal), + animVal (other.animVal) { - baseVal = other.baseVal; - animVal = other.animVal; } /** @@ -2085,9 +2085,9 @@ public: /** * */ - SVGLengthList(const SVGLengthList &other) + SVGLengthList(const SVGLengthList &other) : + items (other.items) { - items = other.items; } /** @@ -2147,10 +2147,10 @@ public: /** * */ - SVGAnimatedLengthList(const SVGAnimatedLengthList &other) + SVGAnimatedLengthList(const SVGAnimatedLengthList &other) : + baseVal (other.baseVal), + animVal (other.animVal) { - baseVal = other.baseVal; - animVal = other.animVal; } /** @@ -2357,16 +2357,17 @@ public: /** * */ - SVGAnimatedAngle(const SVGAngle &angle) - { baseVal = angle; } + SVGAnimatedAngle(const SVGAngle &angle) : + baseVal (angle) + {} /** * */ - SVGAnimatedAngle(const SVGAnimatedAngle &other) + SVGAnimatedAngle(const SVGAnimatedAngle &other) : + baseVal (other.baseVal), + animVal (other.animVal) { - baseVal = other.baseVal; - animVal = other.animVal; } /** @@ -2434,10 +2435,10 @@ public: /** * */ - SVGICCColor(const SVGICCColor &other) + SVGICCColor(const SVGICCColor &other) : + colorProfile (other.colorProfile), + colors (other.colors) { - colorProfile = other.colorProfile; - colors = other.colors; } /** @@ -2448,7 +2449,6 @@ public: protected: DOMString colorProfile; - SVGNumberList colors; }; @@ -2732,10 +2732,10 @@ public: /** * */ - SVGAnimatedRect(const SVGAnimatedRect &other) + SVGAnimatedRect(const SVGAnimatedRect &other) : + baseVal (other.baseVal), + animVal (other.animVal) { - baseVal = other.baseVal; - animVal = other.animVal; } /** @@ -2956,9 +2956,9 @@ public: /** * */ - SVGPointList(const SVGPointList &other) + SVGPointList(const SVGPointList &other) : + items (other.items) { - items = other.items; } @@ -3071,10 +3071,10 @@ public: /** * */ - SVGStylable(const SVGStylable &other) + SVGStylable(const SVGStylable &other) : + className (other.className), + style (other.style) { - className = other.className; - style = other.style; } /** @@ -3168,7 +3168,10 @@ public: /** * */ - SVGLocatable(const SVGLocatable &/*other*/) + SVGLocatable(const SVGLocatable &/*other*/) : + bbox(), + ctm(), + screenCtm() { } @@ -3224,9 +3227,9 @@ public: /** * */ - SVGTransformable(const SVGTransformable &other) : SVGLocatable(other) + SVGTransformable(const SVGTransformable &other) : SVGLocatable(other), + transforms (other.transforms) { - transforms = other.transforms; } /** @@ -3303,11 +3306,11 @@ public: /** * */ - SVGTests(const SVGTests &other) + SVGTests(const SVGTests &other) : + requiredFeatures (other.requiredFeatures), + requiredExtensions (other.requiredExtensions), + systemLanguage (other.systemLanguage) { - requiredFeatures = other.requiredFeatures; - requiredExtensions = other.requiredExtensions; - systemLanguage = other.systemLanguage; } /** @@ -3445,9 +3448,9 @@ public: /** * */ - SVGExternalResourcesRequired(const SVGExternalResourcesRequired &other) + SVGExternalResourcesRequired(const SVGExternalResourcesRequired &other) : + required (other.required) { - required = other.required; } /** @@ -3611,10 +3614,10 @@ public: /** * */ - SVGAnimatedPreserveAspectRatio(const SVGAnimatedPreserveAspectRatio &other) + SVGAnimatedPreserveAspectRatio(const SVGAnimatedPreserveAspectRatio &other) : + baseVal (other.baseVal), + animVal (other.animVal) { - baseVal = other.baseVal; - baseVal = other.animVal; } /** @@ -3671,10 +3674,10 @@ public: * */ - SVGFitToViewBox(const SVGFitToViewBox &other) + SVGFitToViewBox(const SVGFitToViewBox &other) : + viewBox (other.viewBox), + preserveAspectRatio (other.preserveAspectRatio) { - viewBox = other.viewBox; - preserveAspectRatio = other.preserveAspectRatio; } /** @@ -3685,7 +3688,6 @@ public: protected: SVGAnimatedRect viewBox; - SVGAnimatedPreserveAspectRatio preserveAspectRatio; }; @@ -3828,18 +3830,19 @@ public: /** * */ - SVGViewSpec() + SVGViewSpec() : + viewTarget (NULL), + transform () { - viewTarget = NULL; } /** * */ - SVGViewSpec(const SVGViewSpec &other) : SVGZoomAndPan(other), SVGFitToViewBox(other) + SVGViewSpec(const SVGViewSpec &other) : SVGZoomAndPan(other), SVGFitToViewBox(other), + viewTarget (other.viewTarget), + transform (other.transform) { - viewTarget = other.viewTarget; - transform = other.transform; } /** @@ -3884,14 +3887,16 @@ public: /** * */ - SVGURIReference() {} + SVGURIReference() : + href () + {} /** * */ - SVGURIReference(const SVGURIReference &other) + SVGURIReference(const SVGURIReference &other) : + href (other.href) { - href = other.href; } /** @@ -6135,9 +6140,9 @@ public: /** * */ - SVGPathSegList(const SVGPathSegList &other) + SVGPathSegList(const SVGPathSegList &other) : + items (other.items) { - items = other.items; } @@ -6272,10 +6277,10 @@ public: /** * */ - SVGAnimatedPoints(const SVGAnimatedPoints &other) + SVGAnimatedPoints(const SVGAnimatedPoints &other) : + points (other.points), + animatedPoints (other.animatedPoints) { - points = other.points; - animatedPoints = other.animatedPoints; } /** @@ -6366,19 +6371,19 @@ public: /** * */ - SVGPaint() + SVGPaint() : + paintType (SVG_PAINTTYPE_UNKNOWN), + uri ("") { - uri = ""; - paintType = SVG_PAINTTYPE_UNKNOWN; } /** * */ - SVGPaint(const SVGPaint &other) : css::CSSValue(other), SVGColor(other) + SVGPaint(const SVGPaint &other) : css::CSSValue(other), SVGColor(other), + paintType (SVG_PAINTTYPE_UNKNOWN), + uri ("") { - uri = ""; - paintType = SVG_PAINTTYPE_UNKNOWN; } /** @@ -6452,17 +6457,19 @@ public: /** * */ - SVGColorProfileRule() {} + SVGColorProfileRule() : + renderingIntent(0) + {} /** * */ SVGColorProfileRule(const SVGColorProfileRule &other) - : SVGCSSRule(other), SVGRenderingIntent(other) + : SVGCSSRule(other), SVGRenderingIntent(other), + renderingIntent (other.renderingIntent), + src (other.src), + name (other.name) { - renderingIntent = other.renderingIntent; - src = other.src; - name = other.name; } /** @@ -6540,13 +6547,13 @@ public: * */ SVGFilterPrimitiveStandardAttributes(const SVGFilterPrimitiveStandardAttributes &other) - : SVGStylable(other) + : SVGStylable(other), + x (other.x), + y (other.y), + width (other.width), + height (other.height), + result (other.result) { - x = other.x; - y = other.y; - width = other.width; - height = other.height; - result = other.result; } /** @@ -6567,13 +6574,6 @@ protected: - - - - - - - /*######################################################################### ## SVGEvent #########################################################################*/ @@ -6660,20 +6660,26 @@ public: /** * */ - SVGZoomEvent() + SVGZoomEvent(): + zoomRectScreen(), + previousScale(0), + previousTranslate(), + newScale(0), + newTranslate() {} /** * */ - SVGZoomEvent(const SVGZoomEvent &other) : events::Event(other), - events::UIEvent(other) + SVGZoomEvent(const SVGZoomEvent &other) : + events::Event(other), + events::UIEvent(other), + zoomRectScreen(other.zoomRectScreen), + previousScale(other.previousScale), + previousTranslate(other.previousTranslate), + newScale(other.newScale), + newTranslate(other.newTranslate) { - zoomRectScreen = other.zoomRectScreen; - previousScale = other.previousScale; - previousTranslate = other.previousTranslate; - newScale = other.newScale; - newTranslate = other.newTranslate; } /** @@ -6776,13 +6782,18 @@ public: /** * */ - SVGElementInstance() {} + SVGElementInstance() : + correspondingElement(NULL), + correspondingUseElement(NULL) + {} /** * */ SVGElementInstance(const SVGElementInstance &other) - : events::EventTarget(other) + : events::EventTarget(other), + correspondingElement(NULL), + correspondingUseElement(NULL) { } @@ -6858,9 +6869,9 @@ public: /** * */ - SVGElementInstanceList(const SVGElementInstanceList &other) + SVGElementInstanceList(const SVGElementInstanceList &other) : + items (other.items) { - items = other.items; } /** @@ -6877,16 +6888,6 @@ protected: - - - - - - - - - - } //namespace svg } //namespace dom } //namespace w3c diff --git a/src/dom/traversal.h b/src/dom/traversal.h index 13850f78e..302ac2b1f 100644 --- a/src/dom/traversal.h +++ b/src/dom/traversal.h @@ -295,11 +295,11 @@ public: /** * */ - NodeIterator(const NodeIterator &other) + NodeIterator(const NodeIterator &other) : + whatToShow (other.whatToShow), + filter (other.filter), + expandEntityReferences (other.expandEntityReferences) { - whatToShow = other.whatToShow; - filter = other.filter; - expandEntityReferences = other.expandEntityReferences; } /** @@ -499,12 +499,12 @@ public: /** * */ - TreeWalker(const TreeWalker &other) + TreeWalker(const TreeWalker &other) : + whatToShow (other.whatToShow), + filter (other.filter), + expandEntityReferences (other.expandEntityReferences), + currentNode (other.currentNode) { - whatToShow = other.whatToShow; - filter = other.filter; - expandEntityReferences = other.expandEntityReferences; - currentNode = other.currentNode; } /** diff --git a/src/dom/util/thread.cpp b/src/dom/util/thread.cpp deleted file mode 100644 index d5368ef59..000000000 --- a/src/dom/util/thread.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2006 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * Thread wrapper. This provides a platform-independent thread - * class for IO and testing. - * - */ - -#include "thread.h" -#include <stdio.h> -#include <string.h> - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace util -{ - - -#ifdef __WIN32__ -#include <windows.h> - -static DWORD WINAPI WinThreadFunction(LPVOID context) -{ - Thread *thread = static_cast<Thread *>(context); - thread->execute(); - return 0; -} - - -void Thread::start() -{ - DWORD dwThreadId; - HANDLE hThread = CreateThread(NULL, 0, WinThreadFunction, - (LPVOID)this, 0, &dwThreadId); - //Make sure the thread is started before 'this' is deallocated - while (!started) - sleep(10); - CloseHandle(hThread); -} - -void Thread::sleep(unsigned long millis) -{ - Sleep(millis); -} - - - -#else /* UNIX */ -#include <pthread.h> - -void *PthreadThreadFunction(void *context) -{ - Thread *thread = static_cast<Thread *>(context); - thread->execute(); - return NULL; -} - - -void Thread::start() -{ - pthread_t thread; - - int ret = pthread_create(&thread, NULL, - PthreadThreadFunction, (void *)this); - if (ret != 0) - printf("Thread::start: thread creation failed: %s\n", strerror(ret)); - - //Make sure the thread is started before 'this' is deallocated - while (!started) - sleep(10); - -} - -void Thread::sleep(unsigned long millis) -{ - timespec requested; - requested.tv_sec = millis / 1000; - requested.tv_nsec = (millis % 1000 ) * 1000000L; - nanosleep(&requested, NULL); -} - -#endif /* __WIN32__ */ - -} //namespace util -} //namespace dom -} //namespace w3c -} //namespace org - - - -//######################################################################### -//# E N D O F F I L E -//######################################################################### - - diff --git a/src/dom/util/thread.h b/src/dom/util/thread.h deleted file mode 100644 index 1408cd78f..000000000 --- a/src/dom/util/thread.h +++ /dev/null @@ -1,156 +0,0 @@ -#ifndef SEEN_DOM_THREAD_H -#define SEEN_DOM_THREAD_H -/** - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - */ -/* - * Authors: - * Bob Jamison - * - * Copyright (C) 2006 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* - * Thread wrapper. This provides a platform-independent thread - * class for IO and testing. - * - */ - - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace util -{ - - -/** - * This is the interface for a delegate class which can - * be run by a Thread. - * Thread thread(runnable); - * thread.start(); - */ -class Runnable -{ -public: - - Runnable() - {} - virtual ~Runnable() - {} - - /** - * The method of a delegate class which can - * be run by a Thread. Thread is completed when this - * method is done. - */ - virtual void run() = 0; - -}; - - - -/** - * A simple wrapper of native threads in a portable class. - * It can be used either to execute its own run() method, or - * delegate to a Runnable class's run() method. - */ -class Thread -{ -public: - - /** - * Create a thread which will execute its own run() method. - */ - Thread() - { runnable = (Runnable *)0 ; started = false; } - - /** - * Create a thread which will run a Runnable class's run() method. - */ - Thread(const Runnable &runner) - { runnable = (Runnable *)&runner; started = false; } - - /** - * This does not kill a spawned thread. - */ - virtual ~Thread() - {} - - /** - * Static method to pause the current thread for a given - * number of milliseconds. - */ - static void sleep(unsigned long millis); - - /** - * This method will be executed if the Thread was created with - * no delegated Runnable class. The thread is completed when - * the method is done. - */ - virtual void run() - {} - - /** - * Starts the thread. - */ - virtual void start(); - - /** - * Calls either this class's run() method, or that of a Runnable. - * A user would normally not call this directly. - */ - virtual void execute() - { - started = true; - if (runnable) - runnable->run(); - else - run(); - } - -private: - - Runnable *runnable; - - bool started; - -}; - - -} //namespace util -} //namespace dom -} //namespace w3c -} //namespace org - - - -#endif // SEEN_DOM_THREAD_H -//######################################################################### -//# E N D O F F I L E -//######################################################################### - - diff --git a/src/dom/xpathparser.cpp b/src/dom/xpathparser.cpp index 393c12cda..b19975966 100644 --- a/src/dom/xpathparser.cpp +++ b/src/dom/xpathparser.cpp @@ -131,7 +131,7 @@ void XPathParser::lexicalTokenDump() printf("####### LEXICAL TOKENS #######\n"); for (unsigned int i=0 ; i<lexicalTokens.size() ; i++) { - printf("%d : ", i); + printf("%u : ", i); lexicalTokens[i].print(); } printf("##### END LEXICAL TOKENS #####\n\n"); diff --git a/src/dom/xpathtoken.cpp b/src/dom/xpathtoken.cpp index 79948e55e..216c7a069 100644 --- a/src/dom/xpathtoken.cpp +++ b/src/dom/xpathtoken.cpp @@ -937,19 +937,21 @@ Token Token::create(int type, long ival, /** * */ -TokenExecutor::TokenExecutor() +TokenExecutor::TokenExecutor() : + tokenList (), + nodeList () { - reset(); } /** * */ -TokenExecutor::TokenExecutor(const TokenExecutor &other) +TokenExecutor::TokenExecutor(const TokenExecutor &other) : + tokenList (other.tokenList), + nodeList () { - reset(); - assign(other); + // assign(other); } @@ -970,14 +972,6 @@ void TokenExecutor::assign(const TokenExecutor &other) } -/** - * - */ -void TokenExecutor::reset() -{ -} - - /** diff --git a/src/dom/xpathtoken.h b/src/dom/xpathtoken.h index 5bb87917b..cfd54298e 100644 --- a/src/dom/xpathtoken.h +++ b/src/dom/xpathtoken.h @@ -457,7 +457,7 @@ public: */ StackItem pop() { - if (stackItems.size() < 1) + if (stackItems.empty()) { //TODO: error here StackItem item; @@ -619,10 +619,6 @@ public: */ virtual void assign(const TokenExecutor &other); - /** - * Reset the stack to its original settings - */ - virtual void reset(); /** * Execute a list upon a given node. For each Axis encountered, diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index b30950f5a..742d52f09 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -81,8 +81,6 @@ using Inkscape::DocumentUndo; #define DYNA_MIN_WIDTH 1.0e-6 -static void sp_dyna_draw_context_class_init(SPDynaDrawContextClass *klass); -static void sp_dyna_draw_context_init(SPDynaDrawContext *ddc); static void sp_dyna_draw_context_dispose(GObject *object); static void sp_dyna_draw_context_setup(SPEventContext *ec); @@ -101,29 +99,7 @@ static Geom::Point sp_dyna_draw_get_npoint(SPDynaDrawContext const *ddc, Geom::P static Geom::Point sp_dyna_draw_get_vpoint(SPDynaDrawContext const *ddc, Geom::Point n); static void draw_temporary_box(SPDynaDrawContext *dc); - -static SPEventContextClass *dd_parent_class = 0; - -GType sp_dyna_draw_context_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPDynaDrawContextClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_dyna_draw_context_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPDynaDrawContext), - 0, // n_preallocs - (GInstanceInitFunc)sp_dyna_draw_context_init, - 0 // value_table - }; - type = g_type_register_static(SP_TYPE_COMMON_CONTEXT, "SPDynaDrawContext", &info, static_cast<GTypeFlags>(0)); - } - return type; -} +G_DEFINE_TYPE(SPDynaDrawContext, sp_dyna_draw_context, SP_TYPE_COMMON_CONTEXT); static void sp_dyna_draw_context_class_init(SPDynaDrawContextClass *klass) @@ -131,8 +107,6 @@ sp_dyna_draw_context_class_init(SPDynaDrawContextClass *klass) GObjectClass *object_class = G_OBJECT_CLASS(klass); SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass); - dd_parent_class = SP_EVENT_CONTEXT_CLASS(g_type_class_peek_parent(klass)); - object_class->dispose = sp_dyna_draw_context_dispose; event_context_class->setup = sp_dyna_draw_context_setup; @@ -182,7 +156,7 @@ sp_dyna_draw_context_dispose(GObject *object) } - G_OBJECT_CLASS(dd_parent_class)->dispose(object); + G_OBJECT_CLASS(sp_dyna_draw_context_parent_class)->dispose(object); ddc->hatch_pointer_past.~list(); ddc->hatch_nearest_past.~list(); @@ -195,8 +169,8 @@ sp_dyna_draw_context_setup(SPEventContext *ec) { SPDynaDrawContext *ddc = SP_DYNA_DRAW_CONTEXT(ec); - if ((SP_EVENT_CONTEXT_CLASS(dd_parent_class))->setup) - (SP_EVENT_CONTEXT_CLASS(dd_parent_class))->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_dyna_draw_context_parent_class))->setup) + (SP_EVENT_CONTEXT_CLASS(sp_dyna_draw_context_parent_class))->setup(ec); ddc->accumulated = new SPCurve(); ddc->currentcurve = new SPCurve(); @@ -262,8 +236,8 @@ sp_dyna_draw_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val) ddc->keep_selected = val->getBool(); } else { //pass on up to parent class to handle common attributes. - if ( dd_parent_class->set ) { - dd_parent_class->set(ec, val); + if ( SP_COMMON_CONTEXT_CLASS(sp_dyna_draw_context_parent_class)->set ) { + SP_COMMON_CONTEXT_CLASS(sp_dyna_draw_context_parent_class)->set(ec, val); } } @@ -974,8 +948,8 @@ sp_dyna_draw_context_root_handler(SPEventContext *event_context, } if (!ret) { - if ((SP_EVENT_CONTEXT_CLASS(dd_parent_class))->root_handler) { - ret = (SP_EVENT_CONTEXT_CLASS(dd_parent_class))->root_handler(event_context, event); + if ((SP_EVENT_CONTEXT_CLASS(sp_dyna_draw_context_parent_class))->root_handler) { + ret = (SP_EVENT_CONTEXT_CLASS(sp_dyna_draw_context_parent_class))->root_handler(event_context, event); } } diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index 8253818d2..5a827096f 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -50,8 +50,6 @@ #include "ui/widget/gimpspinscale.h" -static void ege_adjustment_action_class_init( EgeAdjustmentActionClass* klass ); -static void ege_adjustment_action_init( EgeAdjustmentAction* action ); static void ege_adjustment_action_finalize( GObject* object ); static void ege_adjustment_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ); static void ege_adjustment_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ); @@ -70,8 +68,6 @@ static void ege_adjustment_action_defocus( EgeAdjustmentAction* action ); static void egeAct_free_description( gpointer data, gpointer user_data ); static void egeAct_free_all_descriptions( EgeAdjustmentAction* action ); - -static GtkActionClass* gParentClass = 0; static EgeCreateAdjWidgetCB gFactoryCb = 0; static GQuark gDataName = 0; @@ -146,34 +142,11 @@ enum { BUMP_CUSTOM = 100 }; -GType ege_adjustment_action_get_type( void ) -{ - static GType myType = 0; - if ( !myType ) { - static const GTypeInfo myInfo = { - sizeof( EgeAdjustmentActionClass ), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc)ege_adjustment_action_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof( EgeAdjustmentAction ), - 0, /* n_preallocs */ - (GInstanceInitFunc)ege_adjustment_action_init, - NULL - }; - - myType = g_type_register_static( GTK_TYPE_ACTION, "EgeAdjustmentAction", &myInfo, (GTypeFlags)0 ); - } - - return myType; -} - +G_DEFINE_TYPE(EgeAdjustmentAction, ege_adjustment_action, GTK_TYPE_ACTION); static void ege_adjustment_action_class_init( EgeAdjustmentActionClass* klass ) { if ( klass ) { - gParentClass = GTK_ACTION_CLASS( g_type_class_peek_parent( klass ) ); GObjectClass * objClass = G_OBJECT_CLASS( klass ); gDataName = g_quark_from_string("ege-adj-action"); @@ -308,8 +281,8 @@ static void ege_adjustment_action_finalize( GObject* object ) egeAct_free_all_descriptions( action ); - if ( G_OBJECT_CLASS(gParentClass)->finalize ) { - (*G_OBJECT_CLASS(gParentClass)->finalize)(object); + if ( G_OBJECT_CLASS(ege_adjustment_action_parent_class)->finalize ) { + (*G_OBJECT_CLASS(ege_adjustment_action_parent_class)->finalize)(object); } } @@ -772,7 +745,7 @@ static GtkWidget* create_menu_item( GtkAction* action ) gtk_widget_show_all( subby ); g_value_unset( &value ); } else { - item = gParentClass->create_menu_item( action ); + item = GTK_ACTION_CLASS(ege_adjustment_action_parent_class)->create_menu_item( action ); } return item; @@ -910,7 +883,7 @@ static GtkWidget* create_tool_item( GtkAction* action ) g_value_unset( &value ); } else { - item = gParentClass->create_tool_item( action ); + item = GTK_ACTION_CLASS(ege_adjustment_action_parent_class)->create_tool_item( action ); } return item; @@ -918,12 +891,12 @@ static GtkWidget* create_tool_item( GtkAction* action ) static void connect_proxy( GtkAction *action, GtkWidget *proxy ) { - gParentClass->connect_proxy( action, proxy ); + GTK_ACTION_CLASS(ege_adjustment_action_parent_class)->connect_proxy( action, proxy ); } static void disconnect_proxy( GtkAction *action, GtkWidget *proxy ) { - gParentClass->disconnect_proxy( action, proxy ); + GTK_ACTION_CLASS(ege_adjustment_action_parent_class)->disconnect_proxy( action, proxy ); } void ege_adjustment_action_defocus( EgeAdjustmentAction* action ) diff --git a/src/ege-color-prof-tracker.cpp b/src/ege-color-prof-tracker.cpp index c0e095a98..2e1b8188f 100644 --- a/src/ege-color-prof-tracker.cpp +++ b/src/ege-color-prof-tracker.cpp @@ -90,11 +90,9 @@ enum { ADDED, REMOVED, MODIFIED, - LAST_SIGNAL}; - + LAST_SIGNAL +}; -static void ege_color_prof_tracker_class_init( EgeColorProfTrackerClass* klass ); -static void ege_color_prof_tracker_init( EgeColorProfTracker* tracker ); static void ege_color_prof_tracker_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ); static void ege_color_prof_tracker_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ); @@ -114,7 +112,6 @@ void handle_property_change(GdkScreen* screen, const gchar* name); void add_x11_tracking_for_screen(GdkScreen* screen, ScreenTrack* screenTrack); #endif /* GDK_WINDOWING_X11 */ -static GObjectClass* gParentClass = 0; static guint signals[LAST_SIGNAL] = {0}; static GSList* tracked_screens = 0; @@ -140,33 +137,11 @@ static void clear_profile( GdkScreen* screen, guint monitor ); static void set_profile( GdkScreen* screen, guint monitor, const guint8* data, guint len ); static void track_screen( GdkScreen* screen, EgeColorProfTracker* tracker ); -GType ege_color_prof_tracker_get_type( void ) -{ - static GType myType = 0; - if ( !myType ) { - static const GTypeInfo myInfo = { - sizeof( EgeColorProfTrackerClass ), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc)ege_color_prof_tracker_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof( EgeColorProfTracker ), - 0, /* n_preallocs */ - (GInstanceInitFunc)ege_color_prof_tracker_init, - NULL - }; - - myType = g_type_register_static( G_TYPE_OBJECT, "EgeColorProfTracker", &myInfo, (GTypeFlags)0 ); - } - - return myType; -} +G_DEFINE_TYPE(EgeColorProfTracker, ege_color_prof_tracker, G_TYPE_OBJECT); void ege_color_prof_tracker_class_init( EgeColorProfTrackerClass* klass ) { if ( klass ) { - gParentClass = G_OBJECT_CLASS( g_type_class_peek_parent( klass ) ); GObjectClass* objClass = G_OBJECT_CLASS( klass ); objClass->get_property = ege_color_prof_tracker_get_property; diff --git a/src/ege-output-action.cpp b/src/ege-output-action.cpp index 1b356c55d..214bd4b29 100644 --- a/src/ege-output-action.cpp +++ b/src/ege-output-action.cpp @@ -46,8 +46,6 @@ #include "ege-output-action.h" -static void ege_output_action_class_init( EgeOutputActionClass* klass ); -static void ege_output_action_init( EgeOutputAction* action ); static void ege_output_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ); static void ege_output_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ); static void fixup_labels( GObject *gobject, GParamSpec *arg1, gpointer user_data ); @@ -55,9 +53,6 @@ static void fixup_labels( GObject *gobject, GParamSpec *arg1, gpointer user_data /* static GtkWidget* create_menu_item( GtkAction* action ); */ static GtkWidget* create_tool_item( GtkAction* action ); -static GtkActionClass* gParentClass = 0; - - struct _EgeOutputActionPrivate { gboolean useMarkup; @@ -69,34 +64,12 @@ enum { PROP_USE_MARKUP = 1, }; -GType ege_output_action_get_type( void ) -{ - static GType myType = 0; - if ( !myType ) { - static const GTypeInfo myInfo = { - sizeof( EgeOutputActionClass ), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc)ege_output_action_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof( EgeOutputAction ), - 0, /* n_preallocs */ - (GInstanceInitFunc)ege_output_action_init, - NULL - }; - - myType = g_type_register_static( GTK_TYPE_ACTION, "EgeOutputAction", &myInfo, (GTypeFlags)0 ); - } - - return myType; -} +G_DEFINE_TYPE(EgeOutputAction, ege_output_action, GTK_TYPE_ACTION); void ege_output_action_class_init( EgeOutputActionClass* klass ) { if ( klass ) { GObjectClass* objClass = G_OBJECT_CLASS( klass ); - gParentClass = GTK_ACTION_CLASS( g_type_class_peek_parent( klass ) ); objClass->get_property = ege_output_action_get_property; objClass->set_property = ege_output_action_set_property; @@ -228,7 +201,7 @@ GtkWidget* create_tool_item( GtkAction* action ) g_value_unset( &value ); } else { - item = gParentClass->create_tool_item( action ); + item = GTK_ACTION_CLASS(ege_output_action_parent_class)->create_tool_item( action ); } return item; diff --git a/src/ege-select-one-action.cpp b/src/ege-select-one-action.cpp index a5d92e809..33cfd04f2 100644 --- a/src/ege-select-one-action.cpp +++ b/src/ege-select-one-action.cpp @@ -49,9 +49,6 @@ enum { CHANGED = 0, LAST_SIGNAL}; - -static void ege_select_one_action_class_init( EgeSelectOneActionClass* klass ); -static void ege_select_one_action_init( EgeSelectOneAction* action ); static void ege_select_one_action_finalize( GObject* action ); static void ege_select_one_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ); static void ege_select_one_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ); @@ -73,7 +70,6 @@ static void disconnect_proxy( GtkAction *action, GtkWidget *proxy ); static int scan_max_width( GtkTreeModel *model, gint labelColumn ); -static GtkActionClass* gParentClass = 0; static guint signals[LAST_SIGNAL] = {0}; static GQuark gDataName = 0; @@ -126,28 +122,7 @@ enum { PROP_SELECTION }; -GType ege_select_one_action_get_type( void ) -{ - static GType myType = 0; - if ( !myType ) { - static const GTypeInfo myInfo = { - sizeof( EgeSelectOneActionClass ), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc)ege_select_one_action_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof( EgeSelectOneAction ), - 0, /* n_preallocs */ - (GInstanceInitFunc)ege_select_one_action_init, - NULL - }; - - myType = g_type_register_static( GTK_TYPE_ACTION, "EgeSelectOneAction", &myInfo, (GTypeFlags)0 ); - } - - return myType; -} +G_DEFINE_TYPE(EgeSelectOneAction, ege_select_one_action, GTK_TYPE_ACTION); GtkTreeModel *ege_select_one_action_get_model(EgeSelectOneAction* action ){ return GTK_TREE_MODEL(action->private_data->model); @@ -155,7 +130,6 @@ GtkTreeModel *ege_select_one_action_get_model(EgeSelectOneAction* action ){ void ege_select_one_action_class_init( EgeSelectOneActionClass* klass ) { if ( klass ) { - gParentClass = GTK_ACTION_CLASS( g_type_class_peek_parent( klass ) ); GObjectClass* objClass = G_OBJECT_CLASS( klass ); gDataName = g_quark_from_string("ege-select1-action"); @@ -292,8 +266,8 @@ void ege_select_one_action_finalize( GObject* object ) g_free( action->private_data->appearance ); g_free( action->private_data->selection ); - if ( G_OBJECT_CLASS(gParentClass)->finalize ) { - (*G_OBJECT_CLASS(gParentClass)->finalize)(object); + if ( G_OBJECT_CLASS(ege_select_one_action_parent_class)->finalize ) { + (*G_OBJECT_CLASS(ege_select_one_action_parent_class)->finalize)(object); } } @@ -631,7 +605,7 @@ GtkWidget* create_menu_item( GtkAction* action ) g_free(sss); } else { - item = gParentClass->create_menu_item( action ); + item = GTK_ACTION_CLASS(ege_select_one_action_parent_class)->create_menu_item( action ); } return item; @@ -855,7 +829,7 @@ GtkWidget* create_tool_item( GtkAction* action ) gtk_widget_show_all( item ); } else { - item = gParentClass->create_tool_item( action ); + item = GTK_ACTION_CLASS(ege_select_one_action_parent_class)->create_tool_item( action ); } return item; @@ -864,12 +838,12 @@ GtkWidget* create_tool_item( GtkAction* action ) void connect_proxy( GtkAction *action, GtkWidget *proxy ) { - gParentClass->connect_proxy( action, proxy ); + GTK_ACTION_CLASS(ege_select_one_action_parent_class)->connect_proxy( action, proxy ); } void disconnect_proxy( GtkAction *action, GtkWidget *proxy ) { - gParentClass->disconnect_proxy( action, proxy ); + GTK_ACTION_CLASS(ege_select_one_action_parent_class)->disconnect_proxy( action, proxy ); } diff --git a/src/event-context.cpp b/src/event-context.cpp index 71d4a5fb9..11b814aab 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -54,8 +54,6 @@ #include "sp-guide.h" #include "color.h" -static void sp_event_context_class_init(SPEventContextClass *klass); -static void sp_event_context_init(SPEventContext *event_context); static void sp_event_context_dispose(GObject *object); static void sp_event_context_private_setup(SPEventContext *ec); @@ -66,8 +64,6 @@ static gint sp_event_context_private_item_handler( static void set_event_location(SPDesktop * desktop, GdkEvent * event); -static GObjectClass *parent_class; - // globals for temporary switching to selector by space static bool selector_toggled = FALSE; static int switch_selector_to = 0; @@ -85,22 +81,7 @@ static guint32 scroll_event_time = 0; static gdouble scroll_multiply = 1; static guint scroll_keyval = 0; -/** - * Registers the SPEventContext class with Glib and returns its type number. - */ -GType sp_event_context_get_type(void) { - static GType type = 0; - if (!type) { - GTypeInfo info = { sizeof(SPEventContextClass), NULL, NULL, - (GClassInitFunc) sp_event_context_class_init, NULL, NULL, - sizeof(SPEventContext), 4, - (GInstanceInitFunc) sp_event_context_init, NULL, /* value_table */ - }; - type = g_type_register_static(G_TYPE_OBJECT, "SPEventContext", &info, - (GTypeFlags) 0); - } - return type; -} +G_DEFINE_TYPE(SPEventContext, sp_event_context, G_TYPE_OBJECT); /** * Callback to set up the SPEventContext vtable. @@ -108,8 +89,6 @@ GType sp_event_context_get_type(void) { static void sp_event_context_class_init(SPEventContextClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); - parent_class = G_OBJECT_CLASS(g_type_class_peek_parent(klass)); - object_class->dispose = sp_event_context_dispose; klass->setup = sp_event_context_private_setup; @@ -166,7 +145,7 @@ static void sp_event_context_dispose(GObject *object) { delete ec->_delayed_snap_event; } - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_event_context_parent_class)->dispose(object); } /** @@ -733,6 +712,7 @@ static gint sp_event_context_private_root_handler( sp_toggle_selector(desktop); ret = TRUE; } + within_tolerance = false; break; case GDK_KEY_Q: case GDK_KEY_q: @@ -1103,7 +1083,7 @@ gint sp_event_context_virtual_item_handler(SPEventContext * event_context, SPIte } /** - * Emits 'position_set' signal on desktop and shows coordinates on status bar. + * Shows coordinates on status bar. */ static void set_event_location(SPDesktop *desktop, GdkEvent *event) { if (event->type != GDK_MOTION_NOTIFY) { @@ -1112,7 +1092,6 @@ static void set_event_location(SPDesktop *desktop, GdkEvent *event) { Geom::Point const button_w(event->button.x, event->button.y); Geom::Point const button_dt(desktop->w2d(button_w)); - desktop->setPosition(button_dt); desktop->set_coordinate_status(button_dt); } diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index e1f04fa10..b5634f42f 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -63,17 +63,6 @@ set(extension_SRC script/InkscapeScript.cpp - # dxf2svg/aci2rgb.cpp - # dxf2svg/entities2elements.cpp - # dxf2svg/tables2svg_info.cpp - # dxf2svg/blocks.cpp - # dxf2svg/entities.cpp - # dxf2svg/tables.cpp - # dxf2svg/dxf2svg.cpp - # dxf2svg/read_dxf.cpp - # dxf2svg/test_dxf.cpp - - # ------ # Header db.h diff --git a/src/extension/dependency.cpp b/src/extension/dependency.cpp index f53dc93b4..7c358d871 100644 --- a/src/extension/dependency.cpp +++ b/src/extension/dependency.cpp @@ -13,6 +13,8 @@ #endif #include <glibmm/i18n.h> +#include <glibmm/fileutils.h> +#include <glibmm/miscutils.h> #include "config.h" #include "path-prefix.h" #include "dependency.h" diff --git a/src/extension/dxf2svg/GPL.txt b/src/extension/dxf2svg/GPL.txt deleted file mode 100644 index 3912109b5..000000000 --- a/src/extension/dxf2svg/GPL.txt +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/src/extension/dxf2svg/LGPL.txt b/src/extension/dxf2svg/LGPL.txt deleted file mode 100644 index 8add30ad5..000000000 --- a/src/extension/dxf2svg/LGPL.txt +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - <one line to give the library's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - <signature of Ty Coon>, 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/src/extension/dxf2svg/Makefile b/src/extension/dxf2svg/Makefile deleted file mode 100644 index d0f06daf0..000000000 --- a/src/extension/dxf2svg/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -objs = read_dxf.o entities.o entities2elements.o tables.o tables2svg_info.o blocks.o -flags = -O1 - -dxf2svg : dxf2svg.cpp $(objs) - g++ $(flags) -o dxf2svg dxf2svg.cpp $(objs) - -test : test_dxf.cpp $(objs) - g++ $(flags) -o test test_dxf.cpp $(objs) - -%.o : %.cpp %.h - g++ $(flags) -c $< - -clean : - rm dxf2svg $(objs) - -install: - echo ****User intervention required**** - echo - echo Copy dxf2svg executable and dxf2svg.inx to share/extension directory - echo Make sure file permissions are set correctly - diff --git a/src/extension/dxf2svg/README b/src/extension/dxf2svg/README deleted file mode 100644 index dbf98d2cc..000000000 --- a/src/extension/dxf2svg/README +++ /dev/null @@ -1,41 +0,0 @@ -26 Aug 05 - -To use: -I have only gotten this to work with Inkscape under linux (debian sarge). But the converter works from the commandline if you want to test it otherwise. - -1. Run make and copy dxf2svg to somewhere that is looked at by the PATH variable. Or add the current directory to your path -2. Copy the dxf_import.inx to ../Inkscape/share/extensions -3. Run Inkscape -4. Click on open or import and the dxf option should be there - -I have compiled and then succesfully converted dxf files to svg files with the following setups - -WinXP Pro, Cygwin, g++ 3.3.3 -Debian Sarge, AMD x86_64, g++ 4.0.2 -RedHat(?), x86(?), g++ 3.2.3 - -I have weakly tried and failed to compile using -Borland's free compiler bcc32 -MinGW - -What is supported: -polylines, lines, arc, circles, blocks, text, and a little linetypes - -currently not supported but I hope will be in the near future (probably after Sept 05) -layers, colors, trace, splines, dimentions - -If you don't have dxf files of your own, but would like to easily test some I would suggest a few places... - -www.newfocus.com -- look under optomechanics. There are a variety of mounts and such that are posted in dxf and pdf -www.thorlabs.com -- dido what I said about newfocus - -Free CAD programs: -Windows -- A free and not too bad CAD program for windows is CadStd Lite. It exports to dxf and has a variety of samples. -Windows/Linux -- QCad is ok. It has a lot of nice features but when I used it a year ago it would import dxf files but then you couldn't edit what was imported. It is free but with a time limit. My experience is that it can be a little annoying. Because of that and others comments I didn't use their libraries for dxf reading. - - -Matt Squires -squiresm@colorado.edu - -27 Aug 05, Fixed a fair number of bugs, and broken conversions. LWPOLYLINE works now, text rotation is ok but needs multiple transfomations to get it right, can read broken dxf files (w/o dxf EOF information) - diff --git a/src/extension/dxf2svg/aci2rgb.cpp b/src/extension/dxf2svg/aci2rgb.cpp deleted file mode 100644 index 57e488bfc..000000000 --- a/src/extension/dxf2svg/aci2rgb.cpp +++ /dev/null @@ -1,114 +0,0 @@ -#include <iostream> -#include <sstream> -#include <string> - - -char* RGB(double R, double G, double B); -char* RGB(double R, double G, double B){ - int r = int (R); - int g = int (G); - int b = int (B); - - char out[6]; - char *chr_ptr; - string output; - stringstream oss; - - if (r < 16 ){ - oss << 0; - } - oss << hex << r; - - if (g < 16 ){ - oss << 0; - } - oss << hex << g; - - if (b < 16 ){ - oss << 0; - } - oss << hex << b; - - output = oss.str(); - - for (int i = 0; i < 6; i++){ - out[i] = output[i]; - } - chr_ptr = &out; - return chr_ptr; -} - - -float aci_to_rgb(int aci); - -float aci_to_rgb(int aci) - { - aci = abs(aci); // hidden layers have negative color values - if (aci<10 || aci>249) // values of these ranges are special colors - { - switch (aci) - { - case 1: return RGB(255,0,0); // basic colors - case 2: return RGB(255,255,0); - case 3: return RGB(0,255,0); - case 4: return RGB(0,255,255); - case 5: return RGB(0,0,255); - case 6: return RGB(255,0,255); - case 7: return RGB(255,255,255); - case 8: return RGB(128,128,128); - case 9: return RGB(192,192,192); - case 250: return RGB(51,51,51); // grey shades - case 251: return RGB(91,91,91); - case 252: return RGB(132,132,132); - case 253: return RGB(173,173,173); - case 254: return RGB(214,214,214); - case 255: return RGB(255,255,255); - case 256: // "by layer" - // Here you should decide how to handle "by layer" logical color. - // Maybe it is a good idea to return a value like -1. - // The outer code will find what is the color of the layer which - // this entity belongs to. - return -1; - } - } - // for all the rest of ACI codes - float H,S,L, R,G,B; - int remainder = aci % 10; - H = 1.5f * (aci - remainder - 10); // hue in range 0-360 - S = ((aci % 2) ? 0.5f : 1.0f); // odd colors have 50% of saturation, even - 100% - // set lighteness, the last digit of aci code stands for this - if (reminder == 0 || reminder == 1) L = 1.0f; - if (reminder == 2 || reminder == 3) L = 0.8f; - if (reminder == 4 || reminder == 5) L = 0.6f; - if (reminder == 6 || reminder == 7) L = 0.5f; - if (reminder == 8 || reminder == 9) L = 0.3f; - // here we have H,S,L set already - // let's convert it to RGB, first without consideration of S and L - if (H<=120) - { - R = (120-H)/60; - G = H/60; - B = 0; - } - if (H>120 && H<=240) - { - R = 0; - G = (240-H)/60; - B = (H-120)/60; - } - if (H>240 && H<=360) - { - R = (H-240)/60; - G = 0; - B = (360-H)/60; - } - R = min(R, 1); - G = min(G, 1); - B = min(B, 1); - // influence of S and L - float max_value = max(R,max(G,B)); - R = (max_value-S*(max_value-R)) * L * 255; - G = (max_value-S*(max_value-G)) * L * 255; - B = (max_value-S*(max_value-B)) * L * 255; - return RGB(R,G,B); - }
\ No newline at end of file diff --git a/src/extension/dxf2svg/blocks.cpp b/src/extension/dxf2svg/blocks.cpp deleted file mode 100644 index 36f2b9e7e..000000000 --- a/src/extension/dxf2svg/blocks.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Read Blocks from file and convert to vectors of entities - * - * Author: - * Matt Squires <squiresm@colorado.edu> - * - * Copyright (C) 2005 Matt Squires - * - * Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details - */ - - -#include"blocks.h" -#include<iostream> - -block::block(std::vector< std::vector< dxfpair > > sections) : entities( sections ){ - // Inherit most of the functionality of the entitites section - - basic_entity( sections[0] ); - block_info( sections[0] ); -} - -char* block::name(char* string){ - return( strcpy(string,block_name) ); -} - - -void block::block_info( std::vector< dxfpair > info){ - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 2: // Block name - strcpy( string," "); // Clear the string out - info[i].value_char(string); - strcpy(block_name,string); - break; - } - } -} - - -blocks::blocks(std::vector< std::vector< dxfpair > > sections){ - // Read the main information about the entities section and then put it in the enetites class - char string[10000]; - std::vector< dxfpair > single_line; - std::vector< std::vector< dxfpair > > ents; - ents.clear(); - single_line.clear(); - - int n_loop = sections.size(); - n_loop--; - //for(int i = 0; i < (sections.size()-1); i++){ // It is odd but the last value seems to be bad so don't use it - // I am not really sure if I need the -1. I needed it once upon a time to make things work but I don't have time to test it well right now - // But sections.size() is an unsigned int so when you subtract 1 it becomes 4294967295 and tries to run the loop so work around that by making n_loop that is signed - for(int i = 0; i < n_loop; i++){ // It is odd but the last value seems to be bad so don't use it - sections[i][0].value_char(string); - ents.clear(); // First clear out the pline information - - - // Get everything from the start of the BLOCK designation to an ENDBLK value - if ( strncmp(string,"BLOCK",5) == 0 && (i < sections.size())){ - do{ - ents.push_back( sections[i] ); - sections[++i][0].value_char(string); - }while( strncmp(string,"ENDBLK",6) != 0 && (i < sections.size()-1) ); - blocks_blocks.push_back( block( ents ) ); - } - } -} - -block blocks::ret_block(char block_name[10000]){ - int string_len = 0; - char temp[10000]; - - for (int i = 0; i < blocks_blocks.size();i++){ - string_len = strlen(blocks_blocks[i].name(temp)); - if (strncmp(blocks_blocks[i].name(temp),block_name,string_len) == 0 ) return blocks_blocks[i]; - } - return blocks_blocks[0]; -} - - - diff --git a/src/extension/dxf2svg/blocks.h b/src/extension/dxf2svg/blocks.h deleted file mode 100644 index 27e0b8be1..000000000 --- a/src/extension/dxf2svg/blocks.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Read Blocks from file and convert to vectors of entities -Matt Squires -Google SOC 2005 -*/ - -#ifndef DXF_BLOCKS_H -#define DXF_BLOCKS_H - -#include"read_dxf.h" -#include"entities.h" -#include<vector> - - -class block : public entity, public entities{// : public entities, { - public: - block( std::vector< std::vector< dxfpair > > sections ); // Group all of the blocks as entities - char* name(char* string); - //void blocks_display(); - - - protected: - char block_name[10000]; - double rotation; - - private: - void block_info(std::vector< dxfpair > info); -}; - -class blocks{ - public: - blocks(std::vector< std::vector< dxfpair > > sections); - block ret_block(char block_name[10000]); - - protected: - std::vector< block > blocks_blocks; -}; - -#endif diff --git a/src/extension/dxf2svg/dxf2svg.cpp b/src/extension/dxf2svg/dxf2svg.cpp deleted file mode 100644 index 4884ed3fe..000000000 --- a/src/extension/dxf2svg/dxf2svg.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Build a SVG from an dxf, will support conversion to Inkscape types - * - * Author: - * Matt Squires <squiresm@colorado.edu> - * - * Copyright (C) 2005 Matt Squires - * - * Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details - */ - - -#include<fstream> -#include<iostream> -#include"read_dxf.h" -#include"entities.h" -#include"blocks.h" -#include"entities2elements.h" - - -int main(int argc,char *argv[]){ - // Later include options for different conversions like converting as much as possible into paths - - if(argc > 1){ - double scaling = 90; // converstion from in to pt - - // Read the DXF file - std::vector< std::vector< dxfpair > > output, entities_info, tables_info, blocks_info; - //std::cout << "About to read file \n" << std::endl; - output = dxf_get_sections(argv[1]); - //std::cout << "Finished reading file \n" << std::endl; - - entities_info = separate_parts(output[4]); // Entities is the 5th part of the file. - entities ents(entities_info); // Sort entities into their respective parts - - tables_info = separate_parts(output[2]); // Tables is the 3rd part of a dxf file. - tables tbls(tables_info); // Sort the information in the tables - - blocks_info = separate_parts(output[3]); // Tables is the 4th part of a dxf file. - blocks blks(blocks_info); // Sort the information in the tables - - - - // Get the various file informations - /*std::vector< polyline > plines = ents.ret_plines(); - std::vector< lwpolyline > lwplines = ents.ret_lwplines(); - std::vector< arc > arcs = ents.ret_arcs(); - std::vector< circle > circs = ents.ret_circles(); - std::vector< line > lns = ents.ret_lines(); - std::vector< text > txts = ents.ret_texts(); - std::vector< insert > ins = ents.ret_inserts(); - */ - - - std::vector< layer > layers = tbls.ret_layers(); - - char units[5] = "in"; - char tmp_char[100000]; - char layer_string[500]; - // int ink = 1; // Assume for now there is no inkscape stuff to add extra - - /*if (ink < 1){ - // Write a general svg header - std::cout << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n\t\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg xmlns=\"http://www.w3.org/2000/svg\"\n\txmlns:xlink=\"http://www.w3.org/1999/xlink\">\n"; - std::cout << "\tx=\"0.00000000\"\n\ty=\"0.00000000\"\n\twidth=\"744.09448\"\n\theight=\"-1052.3622\"" << std::endl; - } - else{*/ - std::cout << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" << std::endl; - std::cout << "<!-- Created with dxf2svg -->" << std::endl; - std::cout << "<svg" << std::endl; - std::cout << "\txmlns:dc=\"http://purl.org/dc/elements/1.1/\"" << std::endl; - std::cout << "\txmlns:cc=\"http://web.resource.org/cc/\"" << std::endl; - std::cout << "\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"" << std::endl; - std::cout << "\txmlns:svg=\"http://www.w3.org/2000/svg\"" << std::endl; - std::cout << "\txmlns=\"http://www.w3.org/2000/svg\"" << std::endl; - std::cout << "\txmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\"" << std::endl; - std::cout << "\txmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"" << std::endl; - std::cout << "\t>" << std::endl; - //} - - - // Now write SVG elements to file - if ( layers.size() < 1 ){ - write_all(0, ents, tbls, blks, scaling, units, tmp_char); - } - else{ - for (int i = 0; i < layers.size(); i++){ - std::cout << "\t<g\n\t\tinkscape:label=\"" << layers[i].name(layer_string) << "\"\n\t\tinkscape:groupmode=\"layer\"\n\t\tid=\"layer" << i+1 << "\">" << std::endl; - write_by_layer(0, ents, tbls, blks, scaling, units, layers[i].name(layer_string), tmp_char); - std::cout << "\t</g>" << std::endl; - } - } - - // Close SVG - std::cout << "</svg>"; - } - - return 0; -} diff --git a/src/extension/dxf2svg/dxf_input.inx b/src/extension/dxf2svg/dxf_input.inx deleted file mode 100644 index b96274ade..000000000 --- a/src/extension/dxf2svg/dxf_input.inx +++ /dev/null @@ -1,16 +0,0 @@ -<inkscape-extension> - <name>DXF Input</name> - <id>org.inkscape.input.dxf</id> - <dependency type="executable" description="dxf2svg may come with Inkscape, but is also at http://dxf-svg-convert.sourceforge.net/" location="extensions">dxf2svg</dependency> - <dependency type="extension">org.inkscape.input.svg</dependency> - <input> - <extension>.dxf</extension> - <mimetype>image/x-svgz</mimetype> - <filetypename>AutoCAD DXF (*.dxf)</filetypename> - <filetypetooltip>Import AutoCAD's Document Exchange Format</filetypetooltip> - <output_extension>org.inkscape.output.svg</output_extension> - </input> - <script> - <command reldir="extensions">dxf2svg</command> - </script> -</inkscape-extension> diff --git a/src/extension/dxf2svg/dxf_input_windows.inx b/src/extension/dxf2svg/dxf_input_windows.inx deleted file mode 100644 index 7dbe6a11b..000000000 --- a/src/extension/dxf2svg/dxf_input_windows.inx +++ /dev/null @@ -1,17 +0,0 @@ -<inkscape-extension> - <name>DXF Input</name> - <id>org.inkscape.input.dxf</id> - <dependency type="executable" description="dxf2svg may come with Inkscape, but is also at -http://dxf-svg-convert.sourceforge.net/" location="extensions">dxf2svg.exe</dependency> - <dependency type="extension">org.inkscape.input.svg</dependency> - <input> - <extension>.dxf</extension> - <mimetype>image/x-svgz</mimetype> - <filetypename>AutoCAD DXF (*.dxf)</filetypename> - <filetypetooltip>Import AutoCAD's Document Exchange Format</filetypetooltip> - <output_extension>org.inkscape.output.svg</output_extension> - </input> - <script> - <command reldir="extensions">dxf2svg.exe</command> - </script> -</inkscape-extension> diff --git a/src/extension/dxf2svg/entities.cpp b/src/extension/dxf2svg/entities.cpp deleted file mode 100644 index 4e2f83ee7..000000000 --- a/src/extension/dxf2svg/entities.cpp +++ /dev/null @@ -1,996 +0,0 @@ -/* - * Class for interpereting the entities found in a DXF file - * - * Author: - * Matt Squires <squiresm@colorado.edu> - * - * Copyright (C) 2005 Matt Squires - * - * Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details - */ - - -#include"entities.h" -#include<iostream> -#include<math.h> - -int detmine_entity(char* value){ - // Common Elements as far as I am concerend - if ( strncmp(value,"POLYLINE",8) == 0 ) return 0; - if ( strncmp(value,"ARC",3) == 0 ) return 1; - if ( strncmp(value,"CIRCLE",6) == 0 ) return 2; - if ( strncmp(value,"LINE",4) == 0 ) return 3; - if ( strncmp(value,"SPLINE",6) == 0 ) return 4; - if ( strncmp(value,"XLINE",5) == 0 ) return 5; - if ( strncmp(value,"RAY",3) == 0 ) return 6; - if ( strncmp(value,"DIMENSION",9) == 0 ) return 7; - if ( strncmp(value,"ELLIPSE",7) == 0 ) return 8; - if ( strncmp(value,"INSERT",6) == 0 ) return 9; - if ( strncmp(value,"VERTEX",6) == 0 ) return 10; - if ( strncmp(value,"TEXT",4) == 0 ) return 11; - - // Less Common eletities as far as I am concerend - if ( strncmp(value,"3DSOLID",7) == 0 ) return 12; - if ( strncmp(value,"ACAD_PROXY_ENTITY",17) == 0 ) return 13; - if ( strncmp(value,"ARCALIGNEDTEXT",14) == 0 ) return 14; - if ( strncmp(value,"ATTDEF",6) == 0 ) return 15; - if ( strncmp(value,"ATTRIB",6) == 0 ) return 16; - if ( strncmp(value,"BODY",4) == 0 ) return 17; - if ( strncmp(value,"HATCH",5) == 0 ) return 18; - if ( strncmp(value,"IMAGE",5) == 0 ) return 19; - if ( strncmp(value,"LEADER",6) == 0 ) return 20; - if ( strncmp(value,"LWPOLYLINE",10) == 0 ) return 21; - if ( strncmp(value,"MLINE",5) == 0 ) return 22; - if ( strncmp(value,"MTEXT",5) == 0 ) return 23; - if ( strncmp(value,"OLEFRAME",8) == 0 ) return 24; - if ( strncmp(value,"POINT",5) == 0 ) return 25; - if ( strncmp(value,"REGION",6) == 0 ) return 26; - if ( strncmp(value,"RTEXT",5) == 0 ) return 27; - if ( strncmp(value,"SEQEND",6) == 0 ) return 28; - if ( strncmp(value,"SHAPE",5) == 0 ) return 29; - if ( strncmp(value,"SOLID",5) == 0 ) return 30; - if ( strncmp(value,"3DFACE",6) == 0 ) return 31; - if ( strncmp(value,"TOLERANCE",9) == 0 ) return 32; - if ( strncmp(value,"TRACE",5) == 0 ) return 33; - if ( strncmp(value,"VIEWPORT",8) == 0 ) return 34; - if ( strncmp(value,"WIPEOUT",7) == 0 ) return 35; - else return -1; -} - - -void entity::basic_entity( std::vector< dxfpair > info){ - // Extract all of the typical entity information (e.g. layer name, positions) - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 6: - strcpy( string," "); // Clear the string out - info[i].value_char(string); - strcpy(linetype,string); - break; - case 8: - strcpy( string," "); // Clear the string out - info[i].value_char(string); - strcpy(layer,string); - break; - case 10: - info[i].value_char(string); - x = atof(string); - if ( x < min_x ){ - min_x = x; - } - if ( x > max_x ){ - max_x = x; - } - break; - case 20: - info[i].value_char(string); - y = atof(string); - if ( y < min_y ){ - min_y = y; - } - if ( y > max_y ){ - max_y = y; - } - break; - case 30: - info[i].value_char(string); - z = atof(string); - break; - } - } - -} - -void entity::entity_display(){ - std::cout << "\tlayer = " << layer << "\n\tlinetype = " << linetype << "\n\tx = " << x << "\ty = " << y << "\tz = " << z << std::flush; -} - -double entity::ret_x(){ - return x; -} - -double entity::ret_y(){ - return y; -} - -double entity::ret_z(){ - return z; -} - - -char* entity::ret_layer_name(char* string){ - return( strcpy(string,layer) ); -} - -char* entity::ret_ltype_name(char* string){ - return( strcpy(string,linetype) ); -} - -double entity::ret_min_x(){ - return min_x; -} - -double entity::ret_max_x(){ - return max_x; -} - -double entity::ret_min_y(){ - return min_y; -} - -double entity::ret_max_y(){ - return max_y; -} - -void entity::test_coord(double x, double y){ - if ( x < min_x ){ - min_x = x; - } - if ( x > max_x ){ - max_x = x; - } - if ( y < min_y ){ - min_y = y; - } - if ( y > max_y ){ - max_y = y; - } -} - - -void entity::reset_extents(){ - min_x = -1e20; - max_x = 1e20; - min_y = -1e20; - max_y = 1e20; -} - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// VERTEX -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -vertex::vertex( std::vector< dxfpair > info){ - // Get the vertex information - - basic_entity( info ); - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 42: - info[i].value_char(string); - bulge = atof(string); - break; - } - } -} - -double vertex::ret_bulge(){ - return bulge; -} - -void vertex::display(){ - std::cout << "VERTEX\n"; - std::cout << "\tx = " << x << "\ty = " << y << "\tz = " << z << "\tbulge = " << bulge << std::flush; -} - - - - - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// POLYLINE -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -// The polyline is handled a little differently compared to the other entities because a POLYLINE is built from a bunch of VERTEX entities -polyline::polyline( std::vector< std::vector< dxfpair > > sections ){ - buldge = 0; - pline_flag = 0; - reset_extents(); - // get the polyline information - basic_entity( sections[0] ); - points.clear(); - static char string[10000]; - for (int i = 0; i < sections[0].size(); i++){ - switch( sections[0][i].group_code ){ - case 70: - sections[0][i].value_char(string); - pline_flag = atoi(string); - break; - case 40: - sections[0][i].value_char(string); - start_width = atoi(string); - break; - case 41: - sections[0][i].value_char(string); - end_width = atoi(string); - break; - case 75: - sections[0][i].value_char(string); - curves_flag = atoi(string); - break; - } - } - curves_flag = 0; - - // Now add the VERTEX entities to the POLYLINE - for (int i = 1; i < sections.size(); i++){ - points.push_back( vertex( sections[i] ) ); - } -} - - -std::vector< vertex > polyline::ret_points(){ - return points; -} - -double polyline::bulge(int point){ - return points[point].ret_bulge(); -} - -double polyline::bulge_r(int point){ - // Make sure we are not exceeding the bounds of the points vector - if (point >= (points.size()-1)) return 0; - - double dx = points[point+1].ret_x() - points[point].ret_x(); - double dy = points[point+1].ret_y() - points[point].ret_y(); - double bulge = points[point].ret_bulge(); - double l = sqrt(dx*dx + dy*dy); - double r = fabs(l*(bulge*bulge+1)/bulge/4); - - return r; -} - -double polyline::bulge_start_angle(int point){ - // Make sure we are not exceeding the bounds of the points vector - if (point >= (points.size()-1)) - { - return 0; - } - - double dx = points[point+1].ret_x() - points[point].ret_x(); - double dy = points[point+1].ret_y() - points[point].ret_y(); - double bulge = points[point].ret_bulge(); - double l = sqrt(dx*dx + dy*dy); - double r = fabs(l*(bulge*bulge+1)/bulge/4); - - if (dx > 0) - { - sb *= -1; // Correct for different point ordering and bulge direction - } - - // Now calculate the angle - double theta = asin(points[point].ret_x()/r); - if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi - - return theta; -} - -double polyline::bulge_end_angle(int point){ - // Make sure we are not exceeding the bounds of the points vector - if (point >= (points.size()-1)) - { - return 0; - } - - double dx = points[point+1].ret_x() - points[point].ret_x(); - double dy = points[point+1].ret_y() - points[point].ret_y(); - double bulge = points[point].ret_bulge(); - double l = sqrt(dx*dx + dy*dy); - double r = fabs(l*(bulge*bulge+1)/bulge/4); - - // Now calculate the angle - double theta = asin(points[point+1].ret_x()/r); - if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi - - return theta; -} - -bool polyline::is_closed(){ - // pline-flag holds info about closed pline in the 1 bit. The info is bit wise encoded so use bit wise operators - return bool(pline_flag&1); -} - -void polyline::display(){ - std::cout << "POLYLINE\n"; - entity_display(); - std::cout << std::endl; - for (int i = 0; i < points.size(); i++){ - points[i].display(); - std::cout << std::endl; - } - std::cout << std::endl; -} - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// LWPOLYLINE -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -// The lwpolyline is different than the polyline because there are no vertex entities. Use the same basic process as the polyline but parse it out differently -lwpolyline::lwpolyline( std::vector< dxfpair > section ){ - - // First break up the data into the same format that is used by the polyline entity - std::vector< std::vector< dxfpair > > sections; - std::vector< dxfpair > first; - std::vector< dxfpair > others; - - sections.clear(); - first.clear(); - others.clear(); - - int gc; // make a shorter name for group_code; - - int vertex_part; - int already_found = 0; - - for (int i = 0; i < section.size(); i++){ - gc = section[i].group_code; - // Encode bitwise information to keep track of what has been found - vertex_part = 0; - if (gc == 10 ) vertex_part += 1; - if (gc == 20 ) vertex_part += 2; - if (gc == 30 ) vertex_part += 4; - if (gc == 40 ) vertex_part += 8; - if (gc == 41 ) vertex_part += 16; - if (gc == 42 ) vertex_part += 32; - //std::cout << "\n\nvertex_part = " << vertex_part << std::endl << "already_found = " << already_found << std::endl << "(vertex_part&already_found) = " << (vertex_part&already_found) << std::endl; - if ( vertex_part == 0 ){ - // If header stuff has been found save it under first. - // I.E. in a polyline the first set of information is linetype and layer, all of what should be in here - first.push_back( section[i] ); - } - else if ( (vertex_part&already_found) == 0 ){ - // Now work on what would be the vertex information - // New information is still being found so keep saving it - others.push_back( section[i] ); - //std::cout << "add to others" << std::endl; - already_found += vertex_part; // Keep track of what has been found - } - else{ - sections.push_back( others ); - //std::cout << "sections.size() = " << sections.size() << std::endl; - // Now clear the information out and start over - others.clear(); - others.push_back( section[i] ); - already_found = vertex_part; - } - } - - // Now put on the last data that was found - if (!others.empty()){ - sections.push_back(others); - } - - reset_extents(); - basic_entity( first ); - points.clear(); - static char string[10000]; - buldge = 0; - pline_flag = 0; - curves_flag = 0; - for (int i = 0; i < first.size(); i++){ - switch( sections[0][i].group_code ){ - case 70: - first[i].value_char(string); - pline_flag = atoi(string); - break; - case 40: - first[i].value_char(string); - start_width = atoi(string); - break; - case 41: - first[i].value_char(string); - end_width = atoi(string); - break; - case 75: - first[i].value_char(string); - curves_flag = atoi(string); - break; - } - } - // Now add the VERTEX entities to the POLYLINE - for (int i = 0; i < sections.size(); i++){ - points.push_back( vertex( sections[i] ) ); - } -} - - - -std::vector< vertex > lwpolyline::ret_points(){ - return points; -} - - -double lwpolyline::bulge(int point){ - return points[point].ret_bulge(); -} - -double lwpolyline::bulge_r(int point){ - // Make sure we are not exceeding the bounds of the points vector - if (point >= (points.size()-1)) return 0; - - double dx = points[point+1].ret_x() - points[point].ret_x(); - double dy = points[point+1].ret_y() - points[point].ret_y(); - double bulge = points[point].ret_bulge(); - double l = sqrt(dx*dx + dy*dy); - double r = fabs(l*(bulge*bulge+1)/bulge/4); - - return r; -} - -double lwpolyline::bulge_start_angle(int point){ - // Make sure we are not exceeding the bounds of the points vector - if (point >= (points.size()-1)) return 0; - - double dx = points[point+1].ret_x() - points[point].ret_x(); - double dy = points[point+1].ret_y() - points[point].ret_y(); - double bulge = points[point].ret_bulge(); - double l = sqrt(dx*dx + dy*dy); - double r = fabs(l*(bulge*bulge+1)/bulge/4); - - // Now calculate the angle - double theta = asin(points[point].ret_x()/r); - if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi - - return theta; -} - -double lwpolyline::bulge_end_angle(int point){ - // Make sure we are not exceeding the bounds of the points vector - if (point >= (points.size()-1)) return 0; - - double dx = points[point+1].ret_x() - points[point].ret_x(); - double dy = points[point+1].ret_y() - points[point].ret_y(); - double bulge = points[point].ret_bulge(); - double l = sqrt(dx*dx + dy*dy); - double r = fabs(l*(bulge*bulge+1)/bulge/4); - - // Now calculate the angle - double theta = asin(points[point+1].ret_x()/r); - if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi - - return theta; -} - -bool lwpolyline::is_closed(){ - // pline-flag holds info about closed pline in the 1 bit. The info is bit wise encoded so use bit wise operators - return bool(pline_flag&1); -} - -void lwpolyline::display(){ - std::cout << "lwpolyline\n"; - entity_display(); - std::cout << std::endl; - for (int i = 0; i < points.size(); i++){ - points[i].display(); - std::cout << std::endl; - } - std::cout << std::endl; -} - - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// ARC -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -arc::arc( std::vector< dxfpair > info){ - - reset_extents(); - basic_entity( info ); - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 40: - info[i].value_char(string); - radius = atof(string); - test_coord(x+radius,y+radius); - test_coord(x-radius,y-radius); - break; - case 50: - info[i].value_char(string); - start_angle = atof(string); - break; - case 51: - info[i].value_char(string); - end_angle = atof(string); - break; - default: - break; - } - } -} - -double arc::ret_radius(){ - return radius; -} - - -double arc::ret_srt_ang(){ - return start_angle; -} - - -double arc::ret_end_ang(){ - return end_angle; -} - - -void arc::display(){ - std::cout << "ARC\n"; - entity_display(); - std::cout << "\n\tradius = " << radius << "\tstart_angle = " << start_angle << "end_angle = " << end_angle << std::flush; -} - - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// CIRCLE -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -circle::circle( std::vector< dxfpair > info){ - - reset_extents(); - basic_entity( info ); - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 40: - info[i].value_char(string); - radius = atof(string); - test_coord(x+radius,y+radius); - test_coord(x-radius,y-radius); - break; - } - } -} - -void circle::display(){ - std::cout << "CIRCLE\n"; - entity_display(); - std::cout << "\n\tradius = " << radius << std::flush; -} - - -double circle::ret_radius(){ - return radius; -} - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// LINE -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -line::line( std::vector< dxfpair > info){ - - reset_extents(); - basic_entity( info ); - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 11: - info[i].value_char(string); - xf = atof(string); - break; - case 21: - info[i].value_char(string); - yf = atof(string); - break; - case 31: - info[i].value_char(string); - zf = atof(string); - break; - } - } - test_coord(xf,yf); - -} - -void line::display(){ - std::cout << "LINE\n"; - entity_display(); - std::cout << "\n\txf = " << xf << "\tyf = " << yf << "\tzf = " << zf << std::flush; -} - - -double line::ret_xf(){ - return xf; -} - -double line::ret_yf(){ - return yf; -} - -double line::ret_zf(){ - return zf; -} - - - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// TEXT -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -text::text( std::vector< dxfpair > info){ - - reset_extents(); - basic_entity( info ); - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 1: - info[i].value_char(dxf_text); // directly copy the text into a string - break; - case 40: - info[i].value_char(string); - text_height = atof(string); - break; - case 50: - info[i].value_char(string); - text_rotation = atof(string); - break; - } - } -} - -char * text::ret_text(char *string){ - return( strcpy(string,dxf_text) ); -} - -double text::ret_txt_ht(){ - return text_height; -} - -double text::ret_txt_rot(){ - return text_rotation; -} - -void text::display(){ - char tmp[10000]; - std::cout << "TEXT\n"; - entity_display(); - std::cout << "\ndxf_text = " << ret_text(tmp) << std::flush; -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// INSERT -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -insert::insert( std::vector< dxfpair > info){ - ret_x_sf = 0; - ret_y_sf = 0; - ret_z_sf = 0; - ret_rotation = 0; - - basic_entity( info ); - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 2: - info[i].value_char(block_name); // directly copy the text into a string - break; - case 41: - info[i].value_char(string); - x_scale_factor = atof(string); - break; - case 42: - info[i].value_char(string); - y_scale_factor = atof(string); - break; - case 43: - info[i].value_char(string); - z_scale_factor = atof(string); - break; - case 50: - info[i].value_char(string); - rotation = atof(string); - break; - } - } -} - - -char * insert::name(char *string){ - return( strcpy(string,block_name) ); -} - - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// entities -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - -entities::entities(std::vector< std::vector< dxfpair > > sections){ - // Read the main information about the entities section and then put it in the enetites class - int value; - char string[10000]; - std::vector< dxfpair > single_line; - std::vector< std::vector< dxfpair > > pline; - pline.clear(); - single_line.clear(); - - for(int i = 0; i < sections.size(); i++){ - sections[i][0].value_char(string); - value = detmine_entity(string); - switch( value ){ - case 0: - // Get everything from the start of the polyline designation to an SEQEND value - pline.clear(); // First clear out the pline information - do{ - pline.push_back( sections[i] ); - sections[++i][0].value_char(string); - }while( strncmp(string,"SEQEND",6) != 0 ); - ents_polyline.push_back( polyline( pline ) ); - break; - - case 1: - // ARC - ents_arc.push_back( arc( sections[i] ) ); - break; - - case 2: - // CIRCLE - ents_circle.push_back( circle( sections[i] ) ); - break; - - case 3: - // LINE - ents_line.push_back( line( sections[i] ) ); - break; - case 11: - // TEXT - ents_text.push_back( text( sections[i] ) ); - break; - case 21: - // LWPOLYLINE - ents_lwpolyline.push_back( lwpolyline( sections[i] ) ); - case 9: - // INSERT - ents_insert.push_back( insert( sections[i] ) ); - - //default: - // Nothing here - } - - } - -} - - -// Maybe all of this could be turned into fewer function by using templates, but no time right now. MBS - -std::vector< polyline > entities::ret_plines(){ - std::vector< polyline > pls; - pls.clear(); - for(int i = 0; i < ents_polyline.size();i++){ - pls.push_back( ents_polyline[i] ); - } - return pls; -} - -std::vector< lwpolyline > entities::ret_lwplines(){ - std::vector< lwpolyline > lwpls; - lwpls.clear(); - for(int i = 0; i < ents_lwpolyline.size();i++){ - lwpls.push_back( ents_lwpolyline[i] ); - } - return lwpls; -} - - -std::vector< arc > entities::ret_arcs(){ - std::vector< arc > a; - a.clear(); - for(int i = 0; i < ents_arc.size();i++){ - a.push_back( ents_arc[i] ); - } - return a; -} - -std::vector< circle > entities::ret_circles(){ - std::vector< circle > circs; - circs.clear(); - for(int i = 0; i < ents_circle.size();i++){ - circs.push_back( ents_circle[i] ); - } - return circs; -} - - -std::vector< line > entities::ret_lines(){ - std::vector< line > lns; - lns.clear(); - for(int i = 0; i < ents_line.size();i++){ - lns.push_back( ents_line[i] ); - } - return lns; -} - - -std::vector< text > entities::ret_texts(){ - std::vector< text > txts; - txts.clear(); - for(int i = 0; i < ents_text.size();i++){ - txts.push_back( ents_text[i] ); - } - return txts; -} - - -std::vector< insert > entities::ret_inserts(){ - std::vector< insert > ins; - ins.clear(); - for(int i = 0; i < ents_insert.size();i++){ - ins.push_back( ents_insert[i] ); - } - return ins; -} - - - -// Overload the return function to depend on the layer -std::vector< polyline > entities::ret_plines(char * layer){ - char temp[10000]; - std::vector< polyline > pls; - pls.clear(); - - for(int i = 0; i < ents_polyline.size();i++){ - if ( strcmp( layer,ents_polyline[i].ret_layer_name(temp) ) == 0 ){ - pls.push_back( ents_polyline[i] ); - } - } - return pls; -} - - -std::vector< lwpolyline > entities::ret_lwplines(char * layer){ - char temp[10000]; - std::vector< lwpolyline > lwpls; - lwpls.clear(); - - for(int i = 0; i < ents_lwpolyline.size();i++){ - if ( strcmp( layer,ents_lwpolyline[i].ret_layer_name(temp) ) == 0 ){ - lwpls.push_back( ents_lwpolyline[i] ); - } - } - return lwpls; -} - - -std::vector< circle > entities::ret_circles(char * layer){ - char temp[10000]; - std::vector< circle > circs; - circs.clear(); - - for(int i = 0; i < ents_circle.size();i++){ - if ( strcmp( layer,ents_circle[i].ret_layer_name(temp) ) == 0 ){ - circs.push_back( ents_circle[i] ); - } - } - return circs; -} - - -std::vector< line > entities::ret_lines(char * layer){ - char temp[10000]; - std::vector< line > lns; - lns.clear(); - - for(int i = 0; i < ents_line.size();i++){ - if ( strcmp( layer,ents_line[i].ret_layer_name(temp) ) == 0 ){ - lns.push_back( ents_line[i] ); - } - } - return lns; -} - - -std::vector< text > entities::ret_texts(char * layer){ - char temp[10000]; - std::vector< text > txts; - txts.clear(); - - for(int i = 0; i < ents_text.size();i++){ - if ( strcmp( layer,ents_text[i].ret_layer_name(temp) ) == 0 ){ - txts.push_back( ents_text[i] ); - } - } - return txts; -} - - -/*std::vector< ellipse > entities::ret_ellipses(char * layer){ - char temp[10000]; - std::vector< polyline > pls; - pls.clear(); - - for(int i = 0; i < ents_polyline.size();i++){ - if ( strcmp( layer,ents_polyline[i].ret_layer_name(temp) ) == 0 ){ - pls.push_back( ents_polyline[i] ); - } - } - return pls; -}*/ - - -std::vector< arc > entities::ret_arcs(char * layer){ - char temp[10000]; - std::vector< arc > a; - a.clear(); - - for(int i = 0; i < ents_arc.size();i++){ - if ( strcmp( layer,ents_arc[i].ret_layer_name(temp) ) == 0 ){ - a.push_back( ents_arc[i] ); - } - } - return a; -} - - -std::vector< insert > entities::ret_inserts(char * layer){ - char temp[10000]; - std::vector< insert > ins; - ins.clear(); - - for(int i = 0; i < ents_insert.size();i++){ - if ( strcmp( layer,ents_insert[i].ret_layer_name(temp) ) == 0 ){ - ins.push_back( ents_insert[i] ); - } - } - return ins; -} - - - - -void entities::display_all(){ - for (int i = 0; i < ents_polyline.size(); i++){ - ents_polyline[i].display(); - } - std::cout << std::endl; - for (int i = 0; i < ents_lwpolyline.size(); i++){ - ents_lwpolyline[i].display(); - } - std::cout << std::endl; - for (int i = 0; i < ents_circle.size(); i++){ - ents_circle[i].display(); - } - std::cout << std::endl; - for (int i = 0; i < ents_text.size(); i++){ - ents_text[i].display(); - } -} - - diff --git a/src/extension/dxf2svg/entities.h b/src/extension/dxf2svg/entities.h deleted file mode 100644 index 3afd949b0..000000000 --- a/src/extension/dxf2svg/entities.h +++ /dev/null @@ -1,256 +0,0 @@ -/* Class for interpereting the entities found in a DXF file -Matt Squires -Google SOC -2 July 05 -*/ - -#ifndef DXF_ENTITIES_H -#define DXF_ENTITIES_H - -#include"read_dxf.h" -#include<vector> - - - - -class entity{ - public: - void basic_entity( std::vector< dxfpair > info); // Extract all of the typical entity information (e.g. layer name, positions) - void entity_display(); - double ret_x(); - double ret_y(); - double ret_z(); - char* ret_layer_name(char* string); - char* ret_ltype_name(char* string); - double ret_min_x(); - double ret_max_x(); - double ret_min_y(); - double ret_max_y(); - - - protected: - char layer[10000]; - char linetype[10000]; - double x; - double y; - double z; - double min_x; - double max_x; - double min_y; - double max_y; - void reset_extents(); - void test_coord(double x, double y); -}; - - - - - -class vertex : public entity { - public: - vertex( std::vector< dxfpair > info); - void display(); - double ret_bulge(); - - private: - double bulge; -}; - - - - - -class polyline : public entity { - public: - polyline( std::vector< std::vector< dxfpair > > sections ); - std::vector< vertex > ret_points(); - double bulge(int point); - double bulge_r(int point); - double bulge_start_angle(int point); - double bulge_end_angle(int point); - bool is_closed(); - void display(); - - private: - double buldge; - int pline_flag; // 70 - double start_width; // 40 - double end_width; // 41 - int curves_flag; - std::vector< vertex > points; -}; - -class lwpolyline : public entity { - public: - lwpolyline( std::vector< dxfpair > section ); - std::vector< vertex > ret_points(); - double bulge(int point); - double bulge_r(int point); - double bulge_start_angle(int point); - double bulge_end_angle(int point); - bool is_closed(); - void display(); - - private: - double buldge; - int pline_flag; // 70 - double start_width; // 40 - double end_width; // 41 - int curves_flag; - std::vector< vertex > points; -}; - -class arc : public entity { - public: - arc( std::vector< dxfpair > info); - double ret_radius(); - double ret_srt_ang(); - double ret_end_ang(); - void display(); - - private: - double radius; - double start_angle; - double end_angle; -}; - - - - -class circle : public entity { - public: - circle( std::vector< dxfpair > info); - void display(); - double ret_radius(); - - private: - double radius; -}; - - -class line : public entity { - public: - line( std::vector< dxfpair > info); - void display(); - double ret_xf(); - double ret_yf(); - double ret_zf(); - - private: - double xf; - double yf; - double zf; -}; - -class ellipse : public entity { - public: - ellipse( std::vector< dxfpair > info); - void display(); - double ret_x_ma; - double ret_y_ma; - double ret_z_ma; - double ret_ratio; - double ret_start_p; - double ret_end_p; - - - private: - double x_major_axis; - double y_major_axis; - double z_major_axis; - double ratio; - double start_param; - double end_param; -}; - - - -class text : public entity { - public: - text( std::vector< dxfpair > info); - void display(); - char * ret_text(char *string); - double ret_txt_ht(); - double ret_txt_rot(); - - private: - char dxf_text[10000]; - double text_height; // dxf 40 - double text_rotation; //dxf 50 -}; - - -class insert : public entity { - public: - insert( std::vector< dxfpair > info); - void display(); - char* name(char* string); - double ret_x_sf; - double ret_y_sf; - double ret_z_sf; - double ret_rotation; - - private: - char block_name[10000]; - double x_scale_factor; - double y_scale_factor; - double z_scale_factor; - double rotation; -}; - - - - - - -class entities{ - // Well I said that I would only use STL containers internally, but I would have to use a dynamically linked list, and I haven't done for a long time soo STL is my crutch. - // I also think that there are others in my same boat that prefer stl containers because they are much easier to use - public: - entities(std::vector< std::vector< dxfpair > > sections); // Put the various entities into their respective vectors - void display_all(); - std::vector< polyline > ret_plines(); - std::vector< circle > ret_circles(); - std::vector< line > ret_lines(); - std::vector< text > ret_texts(); - std::vector< ellipse > ret_ellipses(); - std::vector< arc > ret_arcs(); - std::vector< lwpolyline > ret_lwplines(); - std::vector< insert > ret_inserts(); - // Overload the return function to depend on the layer - std::vector< polyline > ret_plines(char * layer); - std::vector< circle > ret_circles(char * layer); - std::vector< line > ret_lines(char * layer); - std::vector< text > ret_texts(char * layer); - std::vector< ellipse > ret_ellipses(char * layer); - std::vector< arc > ret_arcs(char * layer); - std::vector< lwpolyline > ret_lwplines(char * layer); - std::vector< insert > ret_inserts(char * layer); - - int plines_size(); - int circles_size(); - int lines_size(); - int texts_size(); - - - - private: - void add_polyline(polyline pline); - void add_circle(circle circ); - void add_line(line ln); - - std::vector< polyline > ents_polyline; - std::vector< arc > ents_arc; - std::vector< circle > ents_circle; - std::vector< line > ents_line; - std::vector< ellipse > ents_ellipse; - std::vector< text > ents_text; - std::vector< lwpolyline > ents_lwpolyline; - std::vector< insert > ents_insert; - - -}; - - - -#endif diff --git a/src/extension/dxf2svg/entities2elements.cpp b/src/extension/dxf2svg/entities2elements.cpp deleted file mode 100644 index 8a17a0d84..000000000 --- a/src/extension/dxf2svg/entities2elements.cpp +++ /dev/null @@ -1,678 +0,0 @@ -/* - * Code for converting dxf entities to SVG elements - * There are multiple ways for converting different items - * If possible most DXF enetities will be converted to paths because that is the most flexable object - * - * Author: - * Matt Squires <squiresm@colorado.edu> - * - * Copyright (C) 2005 Matt Squires - * - * Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details - */ - - - -/* - -Matt Squires -SoC 2005 - -*/ - -#include "entities2elements.h" -#include "tables2svg_info.h" -#include <iostream> -#include <math.h> -#include <string.h> -#include <stdlib.h> -// The names indicate the DXF entitiy first and the SVG element last - -// Common elements -char* to_arc(double bulge, double r, double start_ang, double end_ang, int precision,char* delim, char * units, double scaling, char *out){ - // This is used for arcs, polylines, and lwpolylines - char temp[50]; - - // Assume that we are adding to the input and not starting over - strcat(out," A "); - // For arcs there is only one radius - strcat(out,gcvt(scaling*r,precision,temp) ); - strcat(out,","); - strcat(out,gcvt(scaling*r,precision,temp) ); - - strcat(out," 0"); // For arc assume no x-axis rotation. That seems to apply to elipse elements only - // Determine if it is a large arc - if ( (end_ang > start_ang) && ( (end_ang - start_ang) > 180) ){ - //strcat(out," 1,0 "); // Large arc flag...Always use a zero sweep flag - strcat(out," 1, "); // Large arc flag...Always use a zero sweep flag - } - else{ - //strcat(out," 0,0 "); // Small arc flag...Always use a zero sweep flag - strcat(out," 0,"); - } - // This may be easier if I allow r to be plus and minus, but for now this works - if (bulge > 0){ - strcat(out,"0 "); - } - else{ - strcat(out,"1 "); - } -} - -// Build Coordinate -void coord(entity *ent, int precision,char* delim, char * units, double scaling, char *out){ - // Pairs of coords with units will be used so often build a function build a dedicated function for returning such - - char temp[20]; - if (units != NULL) scaling = 1; // If units have been defined then ignore the scaling parameter - strcat(out, gcvt(scaling*ent->ret_x(),precision,temp) ); // There must be a better function for double to ascii conversion that is defined in most libraries - if (units != NULL) strcat(out, units); - strcat(out, delim); - strcat(out, gcvt(-scaling*ent->ret_y(),precision,temp) ); // Because SVG has a the Y-axis pointed down multiply by -1 - if (units != NULL) strcat(out, units); - strcat(out, " "); -} - -// DXF Polyline -> SVG -// General function for the conversion of a pline to a SVG element. Very similar functions just make accomidations for parts that may not be supported -void pline2svg(polyline pline, int type, int precision, char * units, double scaling, tables plot_info, char *out){ - // 0 is pline2path - // 1 is pline2pline - // 2 is pline2polygon - - - char delim[2]; - - std::vector< vertex >::iterator vver_iter; - std::vector< vertex > points = pline.ret_points(); - - if (type < 1){ - // Put the first Move To at the first, everything else will be a lineto - strcpy(delim," "); - strcat(out, "M "); - coord( &points[0], precision, delim, units, scaling, out ); - double prev_mag_bulge = sqrt(pow(points[0].ret_bulge(),2)); // Because the bulge value can be positive or negative calculate the magnitude - if ( prev_mag_bulge > pow(0.1,precision) ){ - to_arc(pline.bulge(0), pline.bulge_r(0), pline.bulge_start_angle(0), pline.bulge_end_angle(0), precision, delim, units, scaling, out); - } - for (int i = 1; i < points.size(); i++){ - if ( prev_mag_bulge < pow(0.1,precision) ){ - // If the previous point was a bulge then don't use a line to - strcat(out, "L "); - } - coord( &points[i], precision, delim, units, scaling, out ); - // If bulge > some precsion then add bulge - double mag_bulge = sqrt(pow(points[i].ret_bulge(),2)); - if ( (mag_bulge > pow(0.1,precision)) && (i < (points.size() - 1) )){ - to_arc(pline.bulge(i), pline.bulge_r(i), pline.bulge_start_angle(i), pline.bulge_end_angle(i), precision, delim, units, scaling, out); - } - prev_mag_bulge = mag_bulge; - } - if ( pline.is_closed() ){ - strcat(out,"z"); - } - strcat(out,"\" "); - } - else{ - strcpy(delim,","); - for (int i = 0; i < points.size(); i++){ - coord( &points[i], precision, delim, NULL, scaling, out ); - // If bulge > some precsion then add bulge - } - // if the element is a SVG::pline and the DXF::pline is closed then simulate by adding an extra point - if ( (type == 1) && pline.is_closed() ){ - coord( &points[0], precision, delim, NULL, scaling, out ); - } - } - -} - -char* pline2path(polyline pline, char * units, double scaling, tables plot_info){ - // Convert a dxf polyline to a SVG path. This is the closest conversion of the DXF polyline to an SVG element - char *out_ptr; - char out[10000] = "<path d=\""; - entity *ent_ptr = &pline; - char temp[20]; - int precision = 6; - - pline2svg(pline, 0, precision, units, scaling, plot_info, out); - // Add some line information - strcat(out,"fill=\"none\" stroke=\"black\" stroke-width=\"1\" "); - pattern2dasharray(plot_info.ret_ltype( ent_ptr->ret_ltype_name(temp),ent_ptr->ret_layer_name(temp) ), precision, scaling, out); // Add the linetype information - - strcat(out," />"); - out_ptr = out; - return out_ptr; -} - -char* pline2pline(polyline pline, char * units, double scaling, tables plot_info){ - // Convert a dxf polyline to a SVG polyline. The conversion is not 1:1 because the SVG pline doesn't support closed objects or curves - entity *ent_ptr = &pline; - char temp[2000]; - int precision = 6; - - char out[10000] = "<polyline fill=\"none\" stroke=\"black\" stroke-width=\"1\" "; - ltype linfo = plot_info.ret_ltype(ent_ptr->ret_ltype_name(temp), ent_ptr->ret_layer_name(temp)); - pattern2dasharray(linfo, precision, scaling, out); // Add the linetype information - //strcpy(temp," "); - - strcat(out,"points=\""); - - //strcat(out,"<polyline fill=\"none\" stroke=\"black\" stroke-width=\"1\" points=\""); - pline2svg(pline, 1, precision, units, scaling, plot_info, out); - // Add some line information - // if the DXF pline is closed then add an extra point - - strcat(out,"\"/>"); - char *out_ptr = out; - return out_ptr; -} -char* pline2polygon(polyline pline, char * units, double scaling, tables plot_info){ - // Convert a dxf polyline to a SVG polygon. The conversion is not 1:1 because the SVG polygone assumes a closed path. If the pline is not closed it will be forced closed - //return pline2svg(pline, 2, 6, units, double scaling,out); -} - - -// DXF LWPolyline -> SVG - - -// This could be a template with polyline and lwpolyline but right now it is not that important -void lwpline2svg(lwpolyline pline, int type, int precision, char * units, double scaling, tables plot_info, char *out); // General function for the conversion of a pline to a SVG element. Very similar functions just make accomidations for parts that may not be supported -void lwpline2svg(lwpolyline pline, int type, int precision, char * units, double scaling, tables plot_info, char *out){ - // 0 is pline2path - // 1 is pline2pline - // 2 is pline2polygon - - - char delim[2]; - - std::vector< vertex >::iterator vver_iter; - std::vector< vertex > points = pline.ret_points(); - - if (type < 1){ - // Put the first Move To at the first, everything else will be a lineto - strcpy(delim," "); - strcat(out, "M "); - coord( &points[0], precision, delim, NULL, scaling, out ); - double prev_mag_bulge = sqrt(pow(points[0].ret_bulge(),2)); // Because the bulge value can be positive or negative calculate the magnitude - if ( prev_mag_bulge > pow(0.1,precision) ){ - to_arc(pline.bulge(0),pline.bulge_r(0), pline.bulge_start_angle(0), pline.bulge_end_angle(0), precision, delim, NULL, scaling, out); - } - - for (int i = 1; i < points.size(); i++){ - if ( prev_mag_bulge < pow(0.1,precision) ){ - // If the previous point was a bulge then don't use a line to - strcat(out, "L "); - } - coord( &points[i], precision, delim, NULL , scaling, out ); - // If bulge > some precsion then add bulge - double mag_bulge = sqrt(pow(points[i].ret_bulge(),2)); - if ( ( mag_bulge > pow(0.1,precision) ) && (i < (points.size() - 1) )){ // Make sure the final point doesn't add a bulge on accident - to_arc(pline.bulge(i), pline.bulge_r(i), pline.bulge_start_angle(i), pline.bulge_end_angle(i), precision, delim, units, scaling, out); - } - prev_mag_bulge = mag_bulge; - } - if ( pline.is_closed() ){ - strcat(out,"z"); - } - strcat(out,"\" "); - } - else{ - strcpy(delim,","); - for (int i = 0; i < points.size(); i++){ - coord( &points[i], precision, delim, units, scaling, out ); - // If bulge > some precsion then add bulge - } - // if the element is a SVG::pline and the DXF::pline is closed then simulate by adding an extra point - if ( (type == 1) && pline.is_closed() ){ - coord( &points[0], precision, delim, units, scaling, out ); - } - } - -} - -char* lwpline2path(lwpolyline pline, char * units, double scaling, tables plot_info){ - // Convert a dxf polyline to a SVG path. This is the closest conversion of the DXF polyline to an SVG element - char *out_ptr; - char out[10000] = "<path d=\""; - entity *ent_ptr = &pline; - char temp[20]; - int precision = 6; - - lwpline2svg(pline, 0, precision, units, scaling, plot_info, out); - // Add some line information - strcat(out,"fill=\"none\" stroke=\"black\" stroke-width=\"1\" "); - pattern2dasharray(plot_info.ret_ltype( ent_ptr->ret_ltype_name(temp),ent_ptr->ret_layer_name(temp) ), precision, scaling, out); // Add the linetype information - - strcat(out," />"); - out_ptr = out; - return out_ptr; -} - -// DXF ARC -> SVG -char* arc2path(arc a, int precision, char * units, double scaling, tables plot_info, char *out){ - // So far this appears to be the only way to convert arcs into something recognized by SVG - char *out_ptr; - char temp[20]; - entity *ent_ptr = &a; - - strcpy(out,"<path d=\"M"); - // Calculate the starting point from the center and the start angle. As far as I can tell the rotation is CCW in the dxf notation and it in degrees - strcat(out,gcvt(scaling*(ent_ptr->ret_x()+a.ret_radius()*cos( a.ret_srt_ang()*3.14159/180 )),precision,temp) ); - strcat(out," "); - strcat(out,gcvt(-1*scaling*(ent_ptr->ret_y()+a.ret_radius()*sin( a.ret_srt_ang()*3.14159/180 )),precision,temp) ); - strcat(out," A "); - // For arcs there is only one radius - strcat(out,gcvt(scaling*a.ret_radius(),precision,temp) ); - strcat(out,","); - strcat(out,gcvt(scaling*a.ret_radius(),precision,temp) ); - - strcat(out," 0"); // For arc assume no x-axis rotation. That seems to apply to elipse elements only - // Determine if it is a large arc - if ( (a.ret_end_ang() > a.ret_srt_ang()) && ( (a.ret_end_ang() - a.ret_srt_ang()) > 180) ){ - strcat(out," 1,0 "); // Large arc flag...Always use a zero sweep flag - } - else{ - strcat(out," 0,0 "); // Small arc flag...Always use a zero sweep flag - } - - //The final point - strcat(out,gcvt(scaling*(ent_ptr->ret_x()+a.ret_radius()*cos( a.ret_end_ang()*3.14159/180 )),precision,temp) ); - strcat(out,","); - strcat(out,gcvt(-1*scaling*(ent_ptr->ret_y()+a.ret_radius()*sin( a.ret_end_ang()*3.14159/180 )),precision,temp) ); - strcat(out,"\" fill=\"none\" stroke=\"black\" stroke-width=\"1\" "); - ltype linfo = plot_info.ret_ltype(ent_ptr->ret_ltype_name(temp), ent_ptr->ret_layer_name(temp)); - pattern2dasharray(linfo, precision, scaling, out); // Add the linetype information - strcat(out, " />"); - - - out_ptr = out; - return out_ptr; - -} - - -// DXF Circle -> SVG -char* circle2circle(circle circ, int precision, char * units, double scaling, tables plot_info, char *out){ - // Direct conversion of DXF circle to SVG circle - char *out_ptr; - char temp[1000]="\" cy=\""; - entity *ent_ptr = ˆ - strcpy(out,"<circle cx=\""); - coord(ent_ptr, precision,temp, units, scaling, out); - strcat(out,"\" r=\""); - strcat(out,gcvt(circ.ret_radius(),precision,temp) ); - strcat(out,units); - strcat(out,"\" fill=\"none\" stroke=\"black\" stroke-width=\"1\" "); - ltype linfo = plot_info.ret_ltype(ent_ptr->ret_ltype_name(temp), ent_ptr->ret_layer_name(temp)); - //plot_info.ret_ltype(ent_ptr->ret_ltype_name(temp), ent_ptr->ret_layer_name(temp)); - pattern2dasharray(linfo, precision, scaling, out); // Add the linetype information - //pattern2dasharray(plot_info.ret_ltype(ent_ptr->ret_ltype_name(temp), ent_ptr->ret_layer_name(temp)), precision, scaling, out); // Add the linetype information - strcat(out, " />"); - out_ptr = out; - return out_ptr; -} - -char* circle2path(circle circ, int precision, char * units, double scaling, tables plot_info, char *out){ - // Conversion of DXF circle to SVG circle assuming the path will represent the circle - - char *out_ptr; - char temp[20]=","; - entity *ent_ptr = ˆ - - strcpy(out,"<path d=\"M"); - // The starting point is x-r,y so subtract off the radius from the x coord - strcat(out,gcvt(ent_ptr->ret_x()-circ.ret_radius(),precision,temp) ); - strcat(out," "); - strcat(out,gcvt(ent_ptr->ret_y(),precision,temp) ); - - strcat(out," a"); - strcat(out,gcvt(circ.ret_radius(),precision,temp) ); - strcat(out,","); - strcat(out,gcvt(circ.ret_radius(),precision,temp) ); - strcat(out,"0 0,0 0,0\" fill=\"none\" stroke=\"black\" stroke-width=\"1\""); - - out_ptr = out; - return out_ptr; -} - - -// DXF Line -> SVG -char* line2line(line ln, int precision, char * units, double scaling, tables plot_info, char *out){ - // Directly convert DXF to SVG because it works - char *out_ptr; - char temp[20]; - entity *ent_ptr = &ln; - - strcpy(out,"<line x1=\""); - strcat(out,gcvt(ent_ptr->ret_x(),precision,temp) ); - strcat(out,units); - strcat(out,"\" y1=\""); - strcat(out,gcvt(-1*ent_ptr->ret_y(),precision,temp) ); // Put in an extra minus because of the way SVG has defined the axis - strcat(out,units); - - strcat(out,"\" x2=\""); - strcat(out,gcvt(ln.ret_xf(),precision,temp) ); - strcat(out,units); - strcat(out,"\" y2=\""); - strcat(out,gcvt(-1*ln.ret_yf(),precision,temp) ); // Put in an extra minus because of the way SVG has defined the axis - strcat(out,units); - strcat(out,"\" stroke-width=\"1\" stroke=\"black\" "); - ltype linfo = plot_info.ret_ltype(ent_ptr->ret_ltype_name(temp), ent_ptr->ret_layer_name(temp)); - pattern2dasharray(linfo, precision, scaling, out); // Add the linetype information - strcat(out, " />"); - - out_ptr = out; - return out_ptr; -} - - -char* line2path(line ln, int precision, char * units, double scaling, tables plot_info, char *out){ - // Convert DXF line to SVG path - - char *out_ptr; - char temp[20]; - entity *ent_ptr = &ln; - - strcpy(out,"<path d=\"M"); - strcat(out,gcvt(scaling*ent_ptr->ret_x(),precision,temp) ); - strcat(out," "); - strcat(out,gcvt(scaling*ent_ptr->ret_y(),precision,temp) ); - - strcat(out," L"); - strcat(out,gcvt(scaling*ln.ret_xf(),precision,temp) ); - strcat(out," "); - strcat(out,gcvt(scaling*ln.ret_yf(),precision,temp) ); - strcat(out,"\" fill=\"none\" stroke=\"black\" stroke-width=\"1\" /"); - - out_ptr = out; - return out_ptr; -} - -// DXF Text -> SVG -char* text2text(text txt, int precision, char * units, double scaling, tables plot_info, char *out){ - // Directly convert DXF to SVG because it works - char *out_ptr; - char temp[10000]; - entity *ent_ptr = &txt; - - // If the text is rotated use the transform matrix - - if ( txt.ret_txt_rot() > precision ){ - double ca = cos(0.017453*txt.ret_txt_rot()); // ca = cosine(a) - double sa = sin(-0.017453*txt.ret_txt_rot()); // sa = sine(a) - double tx = ent_ptr->ret_x()*scaling; - double ty = -ent_ptr->ret_y()*scaling; - // Apply a translation to the orgin, then a rotation, then a translation back to the original position - double a = ca; - double b = sa; - double c = -sa; - double d = ca; - double e = -1*(tx*ca-ty*sa-tx); - double f = -1*(tx*sa+ty*ca-ty); - - strcpy(out, "<g transform=\"matrix("); - strcat(out,gcvt(a,precision,temp) ); - strcat(out," "); - strcat(out,gcvt(b,precision,temp) ); - strcat(out," "); - strcat(out,gcvt(c,precision,temp) ); - strcat(out," "); - strcat(out,gcvt(d,precision,temp) ); - strcat(out," "); - strcat(out,gcvt(e,precision,temp) ); - strcat(out," "); - strcat(out,gcvt(f,precision,temp) ); - strcat(out,")\" >\n<text x=\""); - } - else{ - strcpy(out,"<text x=\""); - } - /* - strcat(out,gcvt(ent_ptr->ret_x(),precision,temp) ); - strcat(out,units); - strcat(out,"\" y=\"-"); // Put in an extra minus because of the way SVG has defined the axis - strcat(out,gcvt(ent_ptr->ret_y(),precision,temp) ); - strcat(out,units); - */ - strcat(out,gcvt(ent_ptr->ret_x()*scaling,precision,temp) ); - //strcat(out,units); - strcat(out,"\" y=\"-"); // Put in an extra minus because of the way SVG has defined the axis - strcat(out,gcvt(ent_ptr->ret_y()*scaling,precision,temp) ); - //strcat(out,units); - strcat(out,"\" font-family=\"Verdana\" font-size=\""); - strcat(out,gcvt(scaling*txt.ret_txt_ht(),precision,temp) ); - strcat(out,"\" Fill=\"black\""); - - strcat(out," >"); - // Now put in the text - strcat(out,txt.ret_text(temp)); - - // Now close the text element - strcat(out,"</text>"); - // If the text was rotated finish off the tranform group - if ( txt.ret_txt_rot() > precision ){ - strcat(out,"</g>"); - } - - out_ptr = out; - return out_ptr; -} - - - -// DXF Insert -> SVG -char* insert2group(insert in, int precision, char * units, double scaling, tables plot_info, blocks blks, char *out){ - char *out_ptr; - char tmp_char[100000]; - - // get the block using the name from the insert information - block blk = blks.ret_block(in.name(tmp_char)); - - entity *ent_ptr = ∈ - entities *ents_ptr = &blk; - // For now just translations MBS 22 Aug 05 - strcpy(out, "<g transform=\"matrix(1,0,0,1,"); - strcat(out,gcvt(scaling*ent_ptr->ret_x(),precision,tmp_char) ); - strcat(out,","); - strcat(out,gcvt(-scaling*ent_ptr->ret_y(),precision,tmp_char) ); - strcat(out,")\" >\n"); - - - // Now convert the entities in the block - std::vector< polyline > plines = ents_ptr->ret_plines(); - std::vector< lwpolyline > lwplines = ents_ptr->ret_lwplines(); - std::vector< arc > arcs = ents_ptr->ret_arcs(); - std::vector< circle > circs = ents_ptr->ret_circles(); - std::vector< line > lns = ents_ptr->ret_lines(); - std::vector< text > txts = ents_ptr->ret_texts(); - - - - for(int i = 0; i < plines.size();i++){ - strcat( out,pline2pline(plines[i], units, scaling, plot_info ) ); - strcat( out, "\n" ); - } - for(int i = 0; i < lwplines.size();i++){ - strcat( out,lwpline2path(lwplines[i], units, scaling, plot_info ) ); - strcat( out, "\n" ); - } - for(int i = 0; i < arcs.size();i++){ - strcat( out, arc2path(arcs[i], 6,units, scaling, plot_info, tmp_char ) ); - strcat( out, "\n" ); - } - for(int i = 0; i < circs.size();i++){ - strcat( out, circle2circle(circs[i], 6, units, scaling, plot_info, tmp_char) ); - strcat( out, "\n" ); - } - for(int i = 0; i < lns.size();i++){ - strcat( out, line2line(lns[i], 6, units, scaling, plot_info, tmp_char) ); - strcat( out, "\n" ); - } - for(int i = 0; i < txts.size();i++){ - strcat( out, text2text(txts[i], 6, units, scaling, plot_info, tmp_char) ); - strcat( out, "\n" ); - } - // End the group - strcat(out,"</g>"); - - out_ptr = out; - return out_ptr; -} - - - -char* write_by_layer(int output_type, entities &ents, tables &tbls, blocks &blks, double scaling, char * units, char * layer, char * out){ - // output_type = 0 is to std:out - // output_type = 1 is to the input filename but with .dxf on the end - - // For now everything will go to stdout later may directed to other places - - // Get the various file informations as dependent on the layer type - std::vector< polyline > plines = ents.ret_plines(layer); - std::vector< lwpolyline > lwplines = ents.ret_lwplines(layer); - std::vector< arc > arcs = ents.ret_arcs(layer); - std::vector< circle > circs = ents.ret_circles(layer); - std::vector< line > lns = ents.ret_lines(layer); - std::vector< text > txts = ents.ret_texts(layer); - std::vector< insert > ins = ents.ret_inserts(layer); - - // It would be better to redirect stdout to different places. That would make the code cleaner but I don't think it will work better - char tmp_char[100000]; - for(int i = 0; i < plines.size();i++){ - if (output_type == 0){ - std::cout << "\t" << pline2path(plines[i], NULL, scaling, tbls ) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << pline2path(plines[i], NULL, scaling, tbls ) << std::endl; - } - } - for(int i = 0; i < lwplines.size();i++){ - if (output_type == 0){ - std::cout << "\t" << lwpline2path(lwplines[i], units, scaling, tbls ) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << lwpline2path(lwplines[i], units, scaling, tbls ) << std::endl; - } - } - for(int i = 0; i < arcs.size();i++){ - if (output_type == 0){ - std::cout << "\t" << arc2path(arcs[i], 6,units, scaling, tbls, tmp_char ) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << arc2path(arcs[i], 6,units, scaling, tbls, tmp_char ) << std::endl; - } - } - for(int i = 0; i < circs.size();i++){ - if (output_type == 0){ - std::cout << "\t" << circle2circle(circs[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << circle2circle(circs[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - } - for(int i = 0; i < lns.size();i++){ - if (output_type == 0){ - std::cout << "\t" << line2line(lns[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << line2line(lns[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - } - for(int i = 0; i < txts.size();i++){ - if (output_type == 0){ - std::cout << "\t" << text2text(txts[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << text2text(txts[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - } - for(int i = 0; i < ins.size();i++){ - if (output_type == 0){ - std::cout << "\t" << insert2group(ins[i], 6, units, scaling, tbls, blks, tmp_char) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << insert2group(ins[i], 6, units, scaling, tbls, blks, tmp_char) << std::endl; - } - } -} - - - -char* write_all(int output_type, entities &ents, tables &tbls, blocks &blks, double scaling, char * units, char * out){ - // output_type = 0 is to std:out - // output_type = 1 is to the input filename but with .dxf on the end - - // For now everything will go to stdout later may directed to other places - - // Get the various file informations as dependent on the layer type - std::vector< polyline > plines = ents.ret_plines(); - std::vector< lwpolyline > lwplines = ents.ret_lwplines(); - std::vector< arc > arcs = ents.ret_arcs(); - std::vector< circle > circs = ents.ret_circles(); - std::vector< line > lns = ents.ret_lines(); - std::vector< text > txts = ents.ret_texts(); - std::vector< insert > ins = ents.ret_inserts(); - - // It would be better to redirect stdout to different places. That would make the code cleaner but I don't think it will work better - char tmp_char[100000]; - for(int i = 0; i < plines.size();i++){ - if (output_type == 0){ - std::cout << "\t" << pline2path(plines[i], NULL, scaling, tbls ) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << pline2path(plines[i], NULL, scaling, tbls ) << std::endl; - } - } - for(int i = 0; i < lwplines.size();i++){ - if (output_type == 0){ - std::cout << "\t" << lwpline2path(lwplines[i], units, scaling, tbls ) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << lwpline2path(lwplines[i], units, scaling, tbls ) << std::endl; - } - } - for(int i = 0; i < arcs.size();i++){ - if (output_type == 0){ - std::cout << "\t" << arc2path(arcs[i], 6,units, scaling, tbls, tmp_char ) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << arc2path(arcs[i], 6,units, scaling, tbls, tmp_char ) << std::endl; - } - } - for(int i = 0; i < circs.size();i++){ - if (output_type == 0){ - std::cout << "\t" << circle2circle(circs[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << circle2circle(circs[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - } - for(int i = 0; i < lns.size();i++){ - if (output_type == 0){ - std::cout << "\t" << line2line(lns[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << line2line(lns[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - } - for(int i = 0; i < txts.size();i++){ - if (output_type == 0){ - std::cout << "\t" << text2text(txts[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << text2text(txts[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - } - for(int i = 0; i < ins.size();i++){ - if (output_type == 0){ - std::cout << "\t" << insert2group(ins[i], 6, units, scaling, tbls, blks, tmp_char) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << insert2group(ins[i], 6, units, scaling, tbls, blks, tmp_char) << std::endl; - } - } -} - - - diff --git a/src/extension/dxf2svg/entities2elements.h b/src/extension/dxf2svg/entities2elements.h deleted file mode 100644 index cceefcf15..000000000 --- a/src/extension/dxf2svg/entities2elements.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Method for converting dxf entities to SVG elements -There are multiple ways for converting different items - -If possible most DXF enetities will be converted to paths because that is the most flexable object - -Matt Squires -SoC 2005 - -*/ - -#include"entities.h" -#include"tables.h" -#include"blocks.h" - -// The names indicate the DXF entitiy first and the SVG element last - -// Common elements -char* to_arc(double bulge, double r, double start_ang, double end_ang, int precision,char* delim, char * units, double scaling, char *out); // This is used for arcs, polylines, and lwpolylines - -// DXF Polyline -> SVG - -char* pline2path(polyline pline, char * units, double scaling, tables plot_info); // Convert a dxf polyline to a SVG path. This is the closest conversion of the DXF polyline to an SVG element -char* pline2pline(polyline pline, char * units, double scaling, tables plot_info); // Convert a dxf polyline to a SVG polyline. The conversion is not 1:1 because the SVG pline doesn't support closed objects or curves -char* pline2polygon(polyline pline, char * units, double scaling, tables plot_info); // Convert a dxf polyline to a SVG polygon. The conversion is not 1:1 because the SVG polygone assumes a closed path. If the pline is not closed it will be forced closed - -// DXF LWPolyline -> SVG -char* lwpline2path(lwpolyline pline, char * units, double scaling, tables plot_info); // Convert a dxf polyline to a SVG path. This is the closest conversion of the DXF polyline to an SVG element - -// DXF ARC -> SVG -char* arc2path(arc a, int precision, char * units, double scaling, tables plot_info, char *out); // So far this appears to be the only way to convert arcs into something recognized by SVG - - -// DXF Circle -> SVG -char* circle2circle(circle circ, int precision, char * units, double scaling, tables plot_info, char *out); // Direct conversion of DXF circle to SVG circle -char* circle2path(circle circ, int precision, char * units, double scaling, tables plot_info, char *out); // Conversion of DXF circle to SVG circle assuming the path will represent the circle - - -// DXF Line -> SVG -char* line2line(line ln, int precision, char * units, double scaling, tables plot_info, char *out); // Directly convert DXF to SVG because it works -char* line2path(line ln, int precision, char * units, double scaling, tables plot_info, char *out); // Convert DXF line to SVG path - -// DXF Text -> SVG -char* text2text(text txt, int precision, char * units, double scaling, tables plot_info, char *out); // Directly convert DXF to SVF assuming VERANDA font - -// DXF Insert -> SVG -char* insert2group(insert in, int precision, char * units, double scaling, tables plot_info, blocks blks, char *out); - -// Write all of the possible enties with a variety of options - -char* write_by_layer(int output_type, entities &ents, tables &tbls, blocks &blks, double scaling, char * units, char * layer, char * out); // Write out the entities by layer designation -char* write_all(int output_type, entities &ents, tables &tbls, blocks &blks, double scaling, char * units, char * out); - - diff --git a/src/extension/dxf2svg/read_dxf.cpp b/src/extension/dxf2svg/read_dxf.cpp deleted file mode 100644 index 1a4eefbc9..000000000 --- a/src/extension/dxf2svg/read_dxf.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/* - * For reading and slight parsing of dxf files - * - * Author: - * Matt Squires <squiresm@colorado.edu> - * - * Copyright (C) 2005 Matt Squires - * - * Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details - */ - - - -#include <fstream> -#include <string> -#include "read_dxf.h" - -#include <iostream> -#include <string.h> -#include <stdlib.h> -using namespace std; - - -int MAX_STR_LN = 10000; - -int section(char* value){ - if ( strncmp(value,"HEADER",6) == 0 ) return 0; - if ( strncmp(value,"CLASSES",7) == 0 ) return 1; - if ( strncmp(value,"TABLES",6) == 0 ) return 2; - if ( strncmp(value,"BLOCKS",6) == 0 ) return 3; - if ( strncmp(value,"ENTITIES",8) == 0 ) return 4; - if ( strncmp(value,"OBJECTS",7) == 0 ) return 5; - if ( strncmp(value,"THUMBNAILIMAGE",14) == 0 ) return 6; -} - - -dxfpair::dxfpair(int gcode, char val[10000]){ - group_code = gcode; - // Dynamically save the strings, otherwise the memory uses is bad - - for (int i = 0; i < strlen(val); i++){ - value.push_back(val[i]); - } -} - - -dxfpair::~dxfpair(){ - //delete [] value; -} - -char * dxfpair::value_char(char *string){ - int size = value.size(); - while( ( size > 0 ) && int(value[size-1]) < 33){ - // Strip off any control characters and spaces off the end of the string - size--; - } - for(int i = 0; i < size; i++){ - string[i] = value[i]; - } - string[size]=0; -} - -std::vector< std::vector< dxfpair > > dxf_get_sections(char* filename){ - // In the dxf format information is paired into group codes that indicate the information that follows on the next line. The information on the next line is called the value - - int n =0; - - int group_code; - char value[MAX_STR_LN]; - - int section_num; - - - - - std::vector< std::vector< dxfpair > > out; - - std::vector< dxfpair > header; - std::vector< dxfpair > classes; - std::vector< dxfpair > tables; - std::vector< dxfpair > blocks; - std::vector< dxfpair > entities; - std::vector< dxfpair > objects; - std::vector< dxfpair > thumbnailimage; - - header.clear(); - classes.clear(); - tables.clear(); - blocks.clear(); - entities.clear(); - objects.clear(); - thumbnailimage.clear(); - - - // Open dxf file for reading - std::ifstream file(filename); - - if (!file.is_open()){ - exit (1); // Change this to an exception - } - - // Find the first SECTION header - - while ( (!file.eof()) ){ - n++; - - // get the first group code and value - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - - do{ - - // TO DO set all the chars to be caps for later comparison - - // Find the SECTION codes - if ( (group_code == 0 ) && ( strncmp(value,"SECTION",7) == 0 ) ){ - // Directly after a section value is the type of section ( e.g. HEADER, TABLES ) - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - section_num = section( value ); - if ( group_code == 2 ){ - // Make sure the the group code is 2 for the SECTION name - // This is a big block of mostly repetitive code, it will result in larger code, but would be faster than putting the switch in another while loop. If I still live in a time when file size mattered alot I would change it - //std::cout << "section_num = " << section_num << std::endl; - switch ( section_num ){ - case 0: - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - do{ - header.push_back( dxfpair( group_code, value ) ); - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - }while( ( (group_code != 0) || strncmp(value,"ENDSEC",6) != 0 ) && (!file.eof()) ); // I put in the (group_code != 0) in the hope that it will be a faster bool compare than the string compare. Test this later - break; - case 1: - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - if ( (group_code != 0) || (strncmp(value,"ENDSEC",6) != 0) ){ - // Some dxf files have blank sections. These are not handled by the do/while loop so break about if needed - do{ - classes.push_back( dxfpair( group_code, value ) ); - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - }while( ( (group_code != 0) || strncmp(value,"ENDSEC",6) != 0 ) && (!file.eof()) ); // I put in the (group_code != 0) in the hope that it will be a faster bool compare than the string compare. Test this later - } - break; - case 2: - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - do{ - tables.push_back( dxfpair( group_code, value ) ); - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - }while( ( (group_code != 0) || strncmp(value,"ENDSEC",6) != 0 ) && (!file.eof()) ); - break; - case 3: - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - do{ - blocks.push_back( dxfpair( group_code, value ) ); - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - }while( ( (group_code != 0) || strncmp(value,"ENDSEC",6) != 0 ) && (!file.eof()) ); // I put in the (group_code != 0) in the hope that it will be a faster bool compare than the string compare. Test this later - break; - case 4: - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - do{ - entities.push_back( dxfpair( group_code, value ) ); - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - }while( ( (group_code != 0) || strncmp(value,"ENDSEC",6) != 0 ) && (!file.eof()) ); // I put in the (group_code != 0) in the hope that it will be a faster bool compare than the string compare. Test this later - break; - case 5: - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - do{ - objects.push_back( dxfpair( group_code, value ) ); - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - }while( ( (group_code != 0) || strncmp(value,"ENDSEC",6) != 0 ) && (!file.eof()) ); // I put in the (group_code != 0) in the hope that it will be a faster bool compare than the string compare. Test this later - break; - case 6: - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - do{ - thumbnailimage.push_back( dxfpair( group_code, value ) ); - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - }while( ( (group_code != 0) || strncmp(value,"ENDSEC",6) != 0 ) && (!file.eof()) ); // I put in the (group_code != 0) in the hope that it will be a faster bool compare than the string compare. Test this later - break; - default: - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - } - } - } - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - - n++; - }while( ( strncmp(value,"EOF",3) != 0 ) && (!file.eof()) ); - } - - out.push_back(header); - out.push_back(classes); - out.push_back(tables); - out.push_back(blocks); - out.push_back(entities); - out.push_back(objects); - out.push_back(thumbnailimage); - - return out; -} - - -std::vector< std::vector< dxfpair > > separate_parts( std::vector< dxfpair > section){ - //std::cout << "1" << std::endl; - //std::cout << "section.size() = " << section.size() << std::endl; - // Find where the major sections are and break into smaller parts - // Major section is defined as anything beween group_code 0 to 0 - std::vector< dxfpair > inner; - std::vector< std::vector< dxfpair > > outer; - //std::cout << "2" << std::endl; - for (int i = 0; i < section.size(); i++){ - //std::cout << "i = " << i << std::endl; - //std::cout << "section[i].value.size() = " << section[i].value.size() << std::endl; - - // Make sure no control codes like LF or CR are making it past this section - if ( (section[i].value.size() > 0) && int(section[i].value.back()) < 32 ){ - section[i].value.pop_back(); - } - //for(int j = 0;j < section[i].value.size();j++ ) std::cout << section[i].value[j]; - //std::cout << std::endl; - - inner.push_back( section[i] ); - - // If the next group code is 0 then push the previously found info on outer and start looking for data again - if (section[i+1].group_code == 0){ - //std::cout << "inner.push_back" << std::endl; - outer.push_back( inner ); - inner.clear(); - } - } - // Because putting the data on outer depends on find a GC=0 the last bit of data may be left behind so it inner has data in it put it on outer - if (!inner.empty()){ - outer.push_back( inner ); - inner.clear(); - } - //std::cout << "3" << std::endl; - if (section.back().group_code == 0){ - //outer.push_back( inner ); // Put the last part on if there is information, but I don't think it needs to. - } - - return outer; -} - diff --git a/src/extension/dxf2svg/read_dxf.h b/src/extension/dxf2svg/read_dxf.h deleted file mode 100644 index 7e008b4e0..000000000 --- a/src/extension/dxf2svg/read_dxf.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Header file for reading dxf information and basic parsing. Interprting information is found in other files -*/ - -#ifndef READ_DXF_H -#define READ_DXF_H - -#include<vector> - - - -class dxfpair{ -public: - dxfpair(int gcode, char val[10000]); - virtual ~dxfpair(); - - char * value_char(char *string); - - // Leave this data public - int group_code; - std::vector< char > value; -}; - - - - -int section(char* value); // Convert the section titles into integers - -std::vector< std::vector< dxfpair > > dxf_get_sections(char* filename); - -std::vector< std::vector< dxfpair > > separate_parts( std::vector< dxfpair > section ); // Find where the major sections are and break into smaller parts - -#endif diff --git a/src/extension/dxf2svg/tables.cpp b/src/extension/dxf2svg/tables.cpp deleted file mode 100644 index fcaff33c0..000000000 --- a/src/extension/dxf2svg/tables.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Code for the conversion of DXF information in the TABLES section - * - * Author: - * Matt Squires <squiresm@colorado.edu> - * - * Copyright (C) 2005 Matt Squires - * - * Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details - */ - -#include"tables.h" -#include<iostream> - - - - -int determine_table(char* value){ - // Common Elements as far as I am concerend - if ( strncmp(value,"LAYER",5) == 0 ) return 0; - if ( strncmp(value,"LTYPE",5) == 0 ) return 1; - if ( strncmp(value,"STYLE",5) == 0 ) return 2; - if ( strncmp(value,"UCS",3) == 0 ) return 3; - if ( strncmp(value,"VIEW",4) == 0 ) return 4; - if ( strncmp(value,"VPORT",4) == 0 ) return 5; - if ( strncmp(value,"APPID",5) == 0 ) return 6; - if ( strncmp(value,"BLOCK_RECORD",12) == 0 ) return 7; - else return -1; -} - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// TABLE -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -int table::ret_maxN(){ - return max_number; -} - - - - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// LAYER -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -layer::layer( std::vector< dxfpair > info){ - // Get the vertex information - - //basic_entity( info ); - //static char string[10000]; - char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 2: - info[i].value_char(layer_name); - break; - case 6: - info[i].value_char(ltype_name); - break; - - case 62: - info[i].value_char(string); - color_number = atoi(string); - //std::cout << "I found a color and its number = " << color_number << std::endl; - break; - case 290: - info[i].value_char(string); - plotting_flag = atoi(string); - break; - } - } -} - -void layer::display(){ - std::cout << "LAYER\n"; - //std::cout << "\tx = " << x << "\ty = " << y << "\tz = " << z << "\tbulge = " << bulge << std::flush; -} - -char* layer::name(char* string){ - return( strcpy(string,layer_name) ); -} - - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// LTYPE -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -ltype::ltype( std::vector< dxfpair > info){ - // Get the linetype information - - //static char string[10000]; - char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 2: - info[i].value_char(ltype_name); - break; - case 3: - info[i].value_char(descriptive_txt); - break; - case 73: - info[i].value_char(string); - num_elements = atoi(string); - break; - case 40: - info[i].value_char(string); - pattern_length = atof(string); - break; - case 49: - info[i].value_char(string); - pattern.push_back( atof(string) ); - break; - } - } -} - - - -char* ltype::name(char* string){ - return( strcpy(string,ltype_name) ); -} - - -std::vector< double > ltype::ret_pattern(){ - return pattern; -} - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// tables -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - -tables::tables(std::vector< std::vector< dxfpair > > sections){ - // Read the main information about the entities section and then put it in the enetites class - int value; - char string[10000]; - - for(int i = 0; i < sections.size(); i++){ - //std::cout << "start" << std::endl; - sections[i][0].value_char(string); - value = determine_table(string); - //std::cout << "sections.size() = " << sections.size() << std::endl << "i = " << i << std::endl << "string = " << string << std::endl; - switch( value ){ - case 0: - // LAYER - //std::cout << "tables start layer " << std::endl; - tables_layer.push_back( layer( sections[i] ) ); - //std::cout << "tables end layer " << std::endl; - break; - - case 1: - // LTYPE - //std::cout << "tables start ltype " << std::endl; - tables_ltype.push_back( ltype( sections[i] ) ); - //std::cout << "tables end ltype " << std::endl; - break; - - //case 3: - // break; - - default: - break; - // Nothing here - } - - } - -} - - - - -ltype tables::ret_ltype(char ltype_name[10000], char layer_name[10000]){ - int string_len = 0; - char name[10000]; - char temp[10000]; - // The ltype information may be given in the entitity or in the layer information - // Assume that if there is a name defined in the linetype that it trumps any other layer information - if ( strlen(ltype_name) > 0 ) strcpy(name,ltype_name); - else strcpy(name,layer_name); - for (int i = 0; i < tables_ltype.size();i++){ - string_len = strlen(tables_ltype[i].name(temp)); - if (strncmp(tables_ltype[i].name(temp),name,string_len) == 0 ) return tables_ltype[i]; - } - return tables_ltype[0]; -} - - -layer tables::ret_layer(char layer_name[10000]){ - int string_len = 0; - char temp[10000]; - - for (int i = 0; i < tables_layer.size();i++){ - string_len = strlen(tables_layer[i].name(temp)); - if (strncmp(tables_layer[i].name(temp),layer_name,string_len) == 0 ) return tables_layer[i]; - } - return tables_layer[0]; -} - - -std::vector< layer > tables::ret_layers(){ - return tables_layer; -} diff --git a/src/extension/dxf2svg/tables.h b/src/extension/dxf2svg/tables.h deleted file mode 100644 index f63122eaf..000000000 --- a/src/extension/dxf2svg/tables.h +++ /dev/null @@ -1,71 +0,0 @@ -/* Code for the conversion of DXF information in the TABLES section -Matt Squires -SoC -2005*/ - -#ifndef DXF_TABLES_H -#define DXF_TABLES_H - -#include<vector> -#include"read_dxf.h" - -class table{ - public: - int ret_maxN(); - private: - int max_number; -}; - - -class layer : public table{ - public: - layer( std::vector< dxfpair > info); - void display(); - char* name(char* string); - private: - char layer_name[10000]; - char ltype_name[10000]; // The layer may also hold the ltype infomation - int color_number; - int plotting_flag; - -}; - - -class ltype : public table{ - public: - ltype( std::vector< dxfpair > info); - char* name(char* string); - std::vector< double > ret_pattern(); - private: - char ltype_name[10000]; - char descriptive_txt[10000]; - int num_elements; - double pattern_length; - std::vector< double > pattern; - -}; - - -class tables{ - // Well I said that I would only use STL containers internally, but I would have to use a dynamically linked list, and I haven't done for a long time soo STL is my crutch. - public: - tables(std::vector< std::vector< dxfpair > > sections); // Put the various entities into their respective vectors - void display_all(); - - ltype ret_ltype(char ltype_name[10000], char layer_name[10000]); - layer ret_layer(char layer_name[10000]); - - std::vector< layer > ret_layers(); - - - private: - //void add_dimstyle(polyline pline); - void add_layer(layer layr); - void add_ltype(ltype line_type); - - std::vector< layer > tables_layer; - std::vector< ltype > tables_ltype; -}; - - -#endif diff --git a/src/extension/dxf2svg/tables2svg_info.cpp b/src/extension/dxf2svg/tables2svg_info.cpp deleted file mode 100644 index c59060306..000000000 --- a/src/extension/dxf2svg/tables2svg_info.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Convert DXF table information to a format that is recognized by SVG - * - * Author: - * Matt Squires <squiresm@colorado.edu> - * - * Copyright (C) 2005 Matt Squires - * - * Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details - */ - - -#include "tables2svg_info.h" -#include <math.h> -#include <iostream> -#include <stdlib.h> -#include <string.h> - -char* pattern2dasharray(ltype info, int precision, double scaling, char* out){ - std::vector< double > pattern = info.ret_pattern(); - char temp[50]; - char *out_ptr; - - - if (!pattern.empty()){ - strcat(out," stroke-dasharray=\""); - for(int i = 0; i < pattern.size()-1;i++){ - strcat(out,gcvt(scaling*sqrt(pow(pattern[i],2)),precision,temp) ); - strcat(out,","); - } - strcat( out,gcvt(scaling*sqrt(pow(pattern[pattern.size()-1],2)),precision,temp) ); - strcat(out,"\" "); - } - - out_ptr = out; - return out_ptr; -} diff --git a/src/extension/dxf2svg/tables2svg_info.h b/src/extension/dxf2svg/tables2svg_info.h deleted file mode 100644 index 2c99f034e..000000000 --- a/src/extension/dxf2svg/tables2svg_info.h +++ /dev/null @@ -1,9 +0,0 @@ -/* Convert DXF table information to a format that is recognized by SVG -Matt Squires -SOC 2005 -*/ - - -#include"tables.h" - -char* pattern2dasharray(ltype info, int precision, double scaling, char* temp); diff --git a/src/extension/dxf2svg/test_dxf.cpp b/src/extension/dxf2svg/test_dxf.cpp deleted file mode 100644 index c3bbdc141..000000000 --- a/src/extension/dxf2svg/test_dxf.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* test read_dxf */ -#include"read_dxf.h" -#include"entities.h" -#include"blocks.h" -#include"tables.h" -#include<iostream> -#include"entities2elements.h" - -using namespace std; - -int main(){ - std::vector< std::vector< dxfpair > > output, entities_info, blocks_info, tables_info; - //output = dxf_get_sections("circ_sqr.dxf"); - //output = dxf_get_sections("Labjack.dxf"); - //output = dxf_get_sections("mini_post.dxf"); - //output = dxf_get_sections("../8599-E0W.dxf"); - //output = dxf_get_sections("../bulged_lwpoly.dxf"); - //output = dxf_get_sections("../aspheric_lens.dxf"); - output = dxf_get_sections("../layers_colors.dxf"); - /*std::vector< dxfpair > header; - std::vector< dxfpair > classes; - std::vector< dxfpair > tables; - std::vector< dxfpair > blocks; - std::vector< dxfpair > entities; - std::vector< dxfpair > objects; - std::vector< dxfpair > thumbnailimage; - */ - - - //dxf_get_sections("circ_sqr.dxf",header,classes,tables,blocks,entities,objects,thumbnailimage); - //dxf_get_sections("mini_post.dxf",header,classes,tables,blocks,entities,objects,thumbnailimage); - - //cout << entities.size() << endl; - for (int i=0;i<output.size();i++) cout << "output[i].size()" << i << " = " << output[i].size() << endl; - //cout << endl; - //for (int i=0;i<output[0].size();i++) cout << output[0][i].group_code << "\t" << output[0][i].value << endl; - //cout << endl; - //for (int i=0;i<output[4].size();i++) cout << output[4][i].group_code << "\t" << output[4][i].value << endl; - - // Now display the different parts of the entities section - //cout << endl; - for (int i=0;i < output[4].size();i++){ - //cout << output[4][i].group_code << " " << output[4][i].value[0] << output[4][i].value[1] << endl; - } - cout << endl; - entities_info = separate_parts(output[4]); - cout << "entities_info.size() = " << entities_info.size() << endl; - - for (int i=0;i < entities_info.size();i++){ - //for (int j=0;j < entities_info[i].size();j++) cout << entities_info[i][j].group_code << " " << entities_info[i][j].value[0] << entities_info[i][j].value[1] << entities_info[i][j].value[2] << entities_info[i][j].value[3] << entities_info[i][j].value[4] << "\n"; - //cout << endl << endl << endl; - } - - cout << "blocks separate parts" << endl; - blocks_info = separate_parts(output[3]); // Tables is the 4th part of a dxf file. - cout << "sort separated parts" << endl; - blocks blks(blocks_info); // Sort the information in the tables - cout << "blocks_info.size() = " << blocks_info.size() << endl; - - for (int i=0;i < blocks_info.size();i++){ - //for (int j=0;j < blocks_info[i].size();j++) cout << blocks_info[i][j].group_code << " " << blocks_info[i][j].value[0] << blocks_info[i][j].value[1] << blocks_info[i][j].value[2] << blocks_info[i][j].value[3] << blocks_info[i][j].value[4] << "\n"; - //cout << endl << endl << endl; - } - - - tables_info = separate_parts(output[2]); // Tables is the 3rd part of a dxf file. - cout << "tables_info.size() = " << tables_info.size() << endl; - for (int i=0;i < tables_info.size();i++){ - //for (int j=0;j < tables_info[i].size();j++) cout << tables_info[i][j].group_code << " " << tables_info[i][j].value[0] << tables_info[i][j].value[1] << tables_info[i][j].value[2] << tables_info[i][j].value[3] << tables_info[i][j].value[4] << "\n"; - //cout << "i = " << i << endl << endl; - } - tables tbls(tables_info); // Sort the information in the tables - - - - cout << "This should change \n"; - - cout << "\n\nNow display all parsed info \n"; - entities ents(entities_info); - ents.display_all(); - - //char units[5] = "in"; - // char units[5] = ""; - - cout << "\nNow for the begining of the SVG...\n\n"; - - cout << "Polyline conversion\n"; - //std::vector< polyline > pl_tmp= ents.ret_plines(); - //cout << "pline2pline\n" << pline2pline(pl_tmp[0], units ) << endl; - //cout << "pline2pline\n" << pline2pline(ents.ret_plines()[0], units ) << endl; - //cout << "pline2path\n" << pline2path(ents.ret_plines()[0], units ); - - // char tmp_char[10000]; - - cout << "\nCircle conversion\n"; - //cout << "circle2circle\n" << circle2circle(ents.ret_circles()[0], 3, units, tmp_char) << endl; - - return 0; -} diff --git a/src/extension/extension.h b/src/extension/extension.h index e0b643b6d..78999631a 100644 --- a/src/extension/extension.h +++ b/src/extension/extension.h @@ -19,6 +19,7 @@ #include <vector> #include <glibmm/ustring.h> #include "xml/repr.h" +#include <sigc++/signal.h> namespace Gtk { class Table; diff --git a/src/extension/init.cpp b/src/extension/init.cpp index 6e35ca9d1..9b65ce1f8 100644 --- a/src/extension/init.cpp +++ b/src/extension/init.cpp @@ -54,6 +54,9 @@ #ifdef WITH_LIBVISIO #include "internal/vsd-input.h" #endif +#ifdef WITH_LIBCDR +#include "internal/cdr-input.h" +#endif #include "preferences.h" #include "io/sys.h" #ifdef WITH_DBUS @@ -187,6 +190,9 @@ init() #ifdef WITH_LIBVISIO Internal::VsdInput::init(); #endif +#ifdef WITH_LIBCDR + Internal::CdrInput::init(); +#endif /* Effects */ Internal::BlurEdge::init(); diff --git a/src/extension/internal/Makefile_insert b/src/extension/internal/Makefile_insert index 12556fbcc..7f5e975d4 100644 --- a/src/extension/internal/Makefile_insert +++ b/src/extension/internal/Makefile_insert @@ -12,6 +12,12 @@ ink_common_sources += \ extension/internal/vsd-input.h endif +if WITH_LIBCDR +ink_common_sources += \ + extension/internal/cdr-input.cpp \ + extension/internal/cdr-input.h +endif + if USE_IMAGE_MAGICK ink_common_sources += \ extension/internal/bitmap/imagemagick.cpp \ diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp new file mode 100644 index 000000000..e6c400fb5 --- /dev/null +++ b/src/extension/internal/cdr-input.cpp @@ -0,0 +1,332 @@ +/* + * This file came from libwpg as a source, their utility wpg2svg + * specifically. It has been modified to work as an Inkscape extension. + * The Inkscape extension code is covered by this copyright, but the + * rest is covered by the one bellow. + * + * Authors: + * Fridrich Strba (fridrich.strba@bluewin.ch) + * + * Copyright (C) 2012 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + * + */ + +#include <stdio.h> +#include "config.h" + +#include "cdr-input.h" + +#ifdef WITH_LIBCDR + +#include <string> +#include <cstring> + +#include <libcdr/libcdr.h> +#include <libwpd-stream/libwpd-stream.h> + +#include <gtkmm/alignment.h> +#include <gtkmm/comboboxtext.h> +#include <gtkmm/drawingarea.h> +#include <gtkmm/frame.h> +#include <gtkmm/scale.h> + +#include "extension/system.h" +#include "extension/input.h" +#include "document.h" + +#include "document-private.h" +#include "document-undo.h" +#include "inkscape.h" + +#include "dialogs/dialog-events.h" +#include <gtk/gtk.h> +#include "ui/widget/spinbutton.h" +#include "ui/widget/frame.h" +#include <glibmm/i18n.h> + +#include <gdkmm/general.h> + +#include "svg-view.h" +#include "svg-view-widget.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { + + +class CdrImportDialog : public Gtk::Dialog { +public: + CdrImportDialog(const std::vector<WPXString> &vec); + virtual ~CdrImportDialog(); + + bool showDialog(); + unsigned getSelectedPage(); + void getImportSettings(Inkscape::XML::Node *prefs); + +private: + void _setPreviewPage(unsigned page); + + // Signal handlers +#if !WITH_GTKMM_3_0 + bool _onExposePreview(GdkEventExpose *event); +#endif + + void _onPageNumberChanged(); + + class Gtk::Button * cancelbutton; + class Gtk::Button * okbutton; + class Gtk::Label * _labelSelect; + class Inkscape::UI::Widget::SpinButton * _pageNumberSpin; + class Gtk::Label * _labelTotalPages; + class Gtk::VBox * vbox1; + class Gtk::VBox * vbox2; + class Gtk::Widget * _previewArea; + + const std::vector<WPXString> &_vec; // Document to be imported + unsigned _current_page; // Current selected page + int _preview_width, _preview_height; // Size of the preview area +}; + +CdrImportDialog::CdrImportDialog(const std::vector<WPXString> &vec) + : _vec(vec), _current_page(1) +{ + int num_pages = _vec.size(); + if ( num_pages <= 1 ) + return; + cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel"))); + okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))); + _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:"))); + + // Page number +#if WITH_GTKMM_3_0 + Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0); + _pageNumberSpin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(_pageNumberSpin_adj, 1, 1)); +#else + Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage( + new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0)); + _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1)); +#endif + _labelTotalPages = Gtk::manage(new class Gtk::Label()); + gchar *label_text = g_strdup_printf(_("out of %i"), num_pages); + _labelTotalPages->set_label(label_text); + g_free(label_text); + + vbox1 = Gtk::manage(new class Gtk::VBox(false, 4)); + SPDocument *doc = SPDocument::createNewDocFromMem(_vec[0].cstr(), strlen(_vec[0].cstr()), 0); + _previewArea = Glib::wrap(sp_svg_view_widget_new(doc)); + + vbox2 = Gtk::manage(new class Gtk::VBox(false, 4)); + cancelbutton->set_can_focus(); + cancelbutton->set_can_default(); + cancelbutton->set_relief(Gtk::RELIEF_NORMAL); + okbutton->set_can_focus(); + okbutton->set_can_default(); + okbutton->set_relief(Gtk::RELIEF_NORMAL); + this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END); + _labelSelect->set_line_wrap(false); + _labelSelect->set_use_markup(false); + _labelSelect->set_selectable(false); + _pageNumberSpin->set_can_focus(); + _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS); + _pageNumberSpin->set_numeric(true); + _pageNumberSpin->set_digits(0); + _pageNumberSpin->set_wrap(false); + _labelTotalPages->set_line_wrap(false); + _labelTotalPages->set_use_markup(false); + _labelTotalPages->set_selectable(false); + vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0); + this->get_vbox()->set_homogeneous(false); + this->get_vbox()->set_spacing(0); + this->get_vbox()->pack_start(*vbox2); + this->set_title(_("Page Selector")); + this->set_modal(true); + sp_transientize(GTK_WIDGET(this->gobj())); //Make transient + this->property_window_position().set_value(Gtk::WIN_POS_NONE); + this->set_resizable(true); + this->property_destroy_with_parent().set_value(false); + this->get_action_area()->add(*_labelSelect); + this->add_action_widget(*_pageNumberSpin, -7); + this->get_action_area()->add(*_labelTotalPages); + this->add_action_widget(*cancelbutton, -6); + this->add_action_widget(*okbutton, -5); + cancelbutton->show(); + okbutton->show(); + _labelSelect->show(); + _pageNumberSpin->show(); + _labelTotalPages->show(); + vbox1->show(); + _previewArea->show(); + vbox2->show(); + + // Connect signals + _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &CdrImportDialog::_onPageNumberChanged)); +} + +CdrImportDialog::~CdrImportDialog() {} + +bool CdrImportDialog::showDialog() +{ + show(); + gint b = run(); + hide(); + if ( b == Gtk::RESPONSE_OK ) { + return TRUE; + } else { + return FALSE; + } +} + +unsigned CdrImportDialog::getSelectedPage() +{ + return _current_page; +} + +void CdrImportDialog::_onPageNumberChanged() +{ + unsigned page = static_cast<unsigned>(_pageNumberSpin->get_value_as_int()); + _current_page = CLAMP(page, 1U, _vec.size()); + _setPreviewPage(_current_page); +} + +/** + * \brief Renders the given page's thumbnail + */ +void CdrImportDialog::_setPreviewPage(unsigned page) +{ + SPDocument *doc = SPDocument::createNewDocFromMem(_vec[page-1].cstr(), strlen(_vec[page-1].cstr()), 0); + Gtk::Widget * tmpPreviewArea = Glib::wrap(sp_svg_view_widget_new(doc)); + std::swap(_previewArea, tmpPreviewArea); + if (tmpPreviewArea) { + _previewArea->set_size_request( tmpPreviewArea->get_width(), tmpPreviewArea->get_height() ); + delete tmpPreviewArea; + } + vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0); + _previewArea->show_now(); +} + +SPDocument *CdrInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri) +{ + WPXFileStream input(uri); + + if (!libcdr::CDRDocument::isSupported(&input)) { + return NULL; + } + + libcdr::CDRStringVector output; + if (!libcdr::CDRDocument::generateSVG(&input, output)) { + return NULL; + } + + if (output.empty()) { + return NULL; + } + + std::vector<WPXString> tmpSVGOutput; + for (unsigned i=0; i<output.size(); ++i) { + WPXString tmpString("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"); + tmpString.append(output[i]); + tmpSVGOutput.push_back(tmpString); + } + + unsigned page_num = 1; + + // If only one page is present, import that one without bothering user + if (tmpSVGOutput.size() > 1) { + CdrImportDialog *dlg = 0; + if (inkscape_use_gui()) { + dlg = new CdrImportDialog(tmpSVGOutput); + if (!dlg->showDialog()) { + delete dlg; + return NULL; + } + } + + // Get needed page + if (dlg) { + page_num = dlg->getSelectedPage(); + if (page_num < 1) + page_num = 1; + if (page_num > tmpSVGOutput.size()) + page_num = tmpSVGOutput.size(); + } + } + + SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE); + return doc; +} + +#include "clear-n_.h" + +void CdrInput::init(void) +{ + /* CDR */ + Inkscape::Extension::build_from_mem( + "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" + "<name>" N_("Corel DRAW Input") "</name>\n" + "<id>org.inkscape.input.cdr</id>\n" + "<input>\n" + "<extension>.cdr</extension>\n" + "<mimetype>image/x-xcdr</mimetype>\n" + "<filetypename>" N_("Corel DRAW 7-X4 files (*.cdr)") "</filetypename>\n" + "<filetypetooltip>" N_("Open files saved in Corel DRAW 7-X4") "</filetypetooltip>\n" + "</input>\n" + "</inkscape-extension>", new CdrInput()); + + /* CDT */ + Inkscape::Extension::build_from_mem( + "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" + "<name>" N_("Corel DRAW templates input") "</name>\n" + "<id>org.inkscape.input.cdt</id>\n" + "<input>\n" + "<extension>.cdt</extension>\n" + "<mimetype>application/x-xcdt</mimetype>\n" + "<filetypename>" N_("Corel DRAW 7-13 template files (*.cdt)") "</filetypename>\n" + "<filetypetooltip>" N_("Open files saved in Corel DRAW 7-13") "</filetypetooltip>\n" + "</input>\n" + "</inkscape-extension>", new CdrInput()); + + /* CCX */ + Inkscape::Extension::build_from_mem( + "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" + "<name>" N_("Corel DRAW Compressed Exchange files input") "</name>\n" + "<id>org.inkscape.input.ccx</id>\n" + "<input>\n" + "<extension>.ccx</extension>\n" + "<mimetype>application/x-xccx</mimetype>\n" + "<filetypename>" N_("Corel DRAW Compressed Exchange files (*.ccx)") "</filetypename>\n" + "<filetypetooltip>" N_("Open compressed exchange files saved in Corel DRAW") "</filetypetooltip>\n" + "</input>\n" + "</inkscape-extension>", new CdrInput()); + + /* CMX */ + Inkscape::Extension::build_from_mem( + "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" + "<name>" N_("Corel DRAW Presentation Exchange files input") "</name>\n" + "<id>org.inkscape.input.cmx</id>\n" + "<input>\n" + "<extension>.cmx</extension>\n" + "<mimetype>application/x-xcmx</mimetype>\n" + "<filetypename>" N_("Corel DRAW Presentation Exchange files (*.cmx)") "</filetypename>\n" + "<filetypetooltip>" N_("Open presentation exchange files saved in Corel DRAW") "</filetypetooltip>\n" + "</input>\n" + "</inkscape-extension>", new CdrInput()); + + return; + +} // init + +} } } /* namespace Inkscape, Extension, Implementation */ +#endif /* WITH_LIBCDR */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/internal/cdr-input.h b/src/extension/internal/cdr-input.h new file mode 100644 index 000000000..10af41d5a --- /dev/null +++ b/src/extension/internal/cdr-input.h @@ -0,0 +1,54 @@ +/* + * This code abstracts the libwpg interfaces into the Inkscape + * input extension interface. + * + * Authors: + * Fridrich Strba (fridrich.strba@bluewin.ch) + * + * Copyright (C) 2012 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef __EXTENSION_INTERNAL_CDROUTPUT_H__ +#define __EXTENSION_INTERNAL_CDROUTPUT_H__ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#ifdef WITH_LIBCDR + +#include <gtkmm/dialog.h> + +#include "../implementation/implementation.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { + +class CdrInput : public Inkscape::Extension::Implementation::Implementation { + CdrInput () { }; +public: + SPDocument *open( Inkscape::Extension::Input *mod, + const gchar *uri ); + static void init( void ); + +}; + +} } } /* namespace Inkscape, Extension, Implementation */ + +#endif /* WITH_LIBCDR */ +#endif /* __EXTENSION_INTERNAL_CDROUTPUT_H__ */ + + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index 8db6c67d2..f0c4c16aa 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -167,9 +167,6 @@ Bump::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream lightOptions; std::ostringstream lightEnd; - std::ostringstream lightRed; - std::ostringstream lightGreen; - std::ostringstream lightBlue; std::ostringstream floodRed; std::ostringstream floodGreen; std::ostringstream floodBlue; diff --git a/src/extension/internal/filter/filter-file.cpp b/src/extension/internal/filter/filter-file.cpp index d129f590c..d569c6438 100644 --- a/src/extension/internal/filter/filter-file.cpp +++ b/src/extension/internal/filter/filter-file.cpp @@ -20,6 +20,7 @@ /* System includes */ #include <glibmm/i18n.h> +#include <glibmm/fileutils.h> namespace Inkscape { namespace Extension { diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp index af597685b..9f7a45f7f 100644 --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@ -172,7 +172,7 @@ void Filter::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::Vie // no filter if (filternode == NULL) { - g_warning("no assoziating filter found!"); + g_warning("no assigned filter found!"); continue; } diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h index d76358a96..415776607 100644 --- a/src/extension/internal/filter/shadows.h +++ b/src/extension/internal/filter/shadows.h @@ -3,7 +3,7 @@ /* Change the 'SHADOWS' above to be your file name */ /* - * Copyright (C) 2011 Authors: + * Copyright (C) 2013 Authors: * Ivan Louette (filters) * Nicolas Dufour (UI) <nicoduf@yahoo.fr> * @@ -39,6 +39,7 @@ namespace Filter { inner = composite1 (operator="out"), composite2 (operator="atop", in1="offset", in2="SourceGraphic") innercut = composite1 (operator="in"), composite2 (operator="out", in1="offset", in2="SourceGraphic") outercut = composite1 (operator="out"), composite2 (operator="in", in1="SourceGraphic", in2="offset") + shadow = composite1 (operator="out"), composite2 (operator="atop", in1="offset", in2="offset") * Color (guint, default 0,0,0,127) -> flood (flood-opacity, flood-color) * Use object's color (boolean, default false) -> composite1 (in1, in2) */ @@ -60,11 +61,12 @@ public: "<param name=\"blur\" gui-text=\"" N_("Blur radius (px):") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"200.0\">3.0</param>\n" "<param name=\"xoffset\" gui-text=\"" N_("Horizontal offset (px):") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n" "<param name=\"yoffset\" gui-text=\"" N_("Vertical offset (px):") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n" - "<param name=\"type\" gui-text=\"" N_("Blur type:") "\" type=\"enum\" >\n" + "<param name=\"type\" gui-text=\"" N_("Shadow type:") "\" type=\"enum\" >\n" "<_item value=\"outer\">" N_("Outer") "</_item>\n" "<_item value=\"inner\">" N_("Inner") "</_item>\n" "<_item value=\"outercut\">" N_("Outer cutout") "</_item>\n" "<_item value=\"innercut\">" N_("Inner cutout") "</_item>\n" + "<_item value=\"shadow\">" N_("Shadow only") "</_item>\n" "</param>\n" "</page>\n" "<page name=\"coltab\" _gui-text=\"" N_("Blur color") "\">\n" @@ -151,11 +153,16 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) comp2op << "out"; comp2in1 << "offset"; comp2in2 << "SourceGraphic"; - } else { //innercut + } else if ((g_ascii_strcasecmp("innercut", type) == 0)){ comp1op << "out"; comp1in1 << "flood"; comp1in2 << "SourceGraphic"; comp2op << "in"; + } else { //shadow + comp1op << "in"; + comp2op << "atop"; + comp2in1 << "offset"; + comp2in2 << "offset"; } _filter = g_strdup_printf( diff --git a/src/extension/internal/image-resolution.cpp b/src/extension/internal/image-resolution.cpp index a17a2bb30..3b3b85d06 100644 --- a/src/extension/internal/image-resolution.cpp +++ b/src/extension/internal/image-resolution.cpp @@ -286,13 +286,10 @@ void ImageResolution::readjfif(char const *fn) { struct jpeg_decompress_struct cinfo; jmp_buf jbuf; struct jpeg_error_mgr jerr; - bool constr = false; if (setjmp(jbuf)) { fclose(ifd); - if (constr) { - jpeg_destroy_decompress(&cinfo); - } + jpeg_destroy_decompress(&cinfo); return; } @@ -305,8 +302,6 @@ void ImageResolution::readjfif(char const *fn) { jerr.reset_error_mgr = &irjfif_reset; cinfo.client_data = (void*)&jbuf; - constr = true; - jpeg_stdio_src(&cinfo, ifd); jpeg_read_header(&cinfo, TRUE); @@ -321,7 +316,6 @@ void ImageResolution::readjfif(char const *fn) { ok_ = true; } } - constr = false; jpeg_destroy_decompress(&cinfo); fclose(ifd); } diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index 67c0fae66..035a6f0aa 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -20,6 +20,8 @@ #ifdef HAVE_CONFIG_H # include <config.h> #endif + +#include <glibmm/miscutils.h> #include "javafx-out.h" #include <inkscape.h> #include <inkscape-version.h> diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index f0de3b709..75849f6cc 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -629,7 +629,6 @@ gchar *SvgBuilder::_createPattern(GfxPattern *pattern, GfxState *state, bool is_ if ( pattern->getType() == 2 ) { // Shading pattern GfxShadingPattern *shading_pattern = static_cast<GfxShadingPattern *>(pattern); double *ptm; - double ittm[6]; // invert ttm double m[6] = {1, 0, 0, 1, 0, 0}; double det; @@ -638,6 +637,7 @@ gchar *SvgBuilder::_createPattern(GfxPattern *pattern, GfxState *state, bool is_ ptm = shading_pattern->getMatrix(); det = ttm[0] * ttm[3] - ttm[1] * ttm[2]; if (det) { + double ittm[6]; // invert ttm ittm[0] = ttm[3] / det; ittm[1] = -ttm[1] / det; ittm[2] = -ttm[2] / det; @@ -1208,7 +1208,7 @@ void SvgBuilder::updateTextMatrix(GfxState *state) { */ void SvgBuilder::_flushText() { // Ignore empty strings - if ( _glyphs.size() < 1 ) { + if ( _glyphs.empty()) { _glyphs.clear(); return; } diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp index 187318417..12e5150cb 100644 --- a/src/extension/internal/vsd-input.cpp +++ b/src/extension/internal/vsd-input.cpp @@ -185,8 +185,8 @@ unsigned VsdImportDialog::getSelectedPage() void VsdImportDialog::_onPageNumberChanged() { - int page = _pageNumberSpin->get_value_as_int(); - _current_page = CLAMP(page, 1, _vec.size()); + unsigned page = static_cast<unsigned>(_pageNumberSpin->get_value_as_int()); + _current_page = CLAMP(page, 1U, _vec.size()); _setPreviewPage(_current_page); } diff --git a/src/extension/system.cpp b/src/extension/system.cpp index 7fb6e1591..60cd21d71 100644 --- a/src/extension/system.cpp +++ b/src/extension/system.cpp @@ -21,6 +21,7 @@ #endif #include <interface.h> +#include <unistd.h> #include "system.h" #include "preferences.h" diff --git a/src/extension/timer.cpp b/src/extension/timer.cpp index 3941ddcfc..e4e8632d2 100644 --- a/src/extension/timer.cpp +++ b/src/extension/timer.cpp @@ -10,7 +10,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ - +#include <glibmm/main.h> #include "extension.h" #include "timer.h" diff --git a/src/file.cpp b/src/file.cpp index 14f70fc8c..468d02eba 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -62,6 +62,7 @@ #include "ui/view/view-widget.h" #include "uri.h" #include "xml/rebase-hrefs.h" +#include "xml/sp-css-attr.h" #include "verbs.h" #include "event-log.h" #include "ui/dialog/font-substitution.h" diff --git a/src/filters/blend.cpp b/src/filters/blend.cpp index 809bd6c00..a43927e81 100644 --- a/src/filters/blend.cpp +++ b/src/filters/blend.cpp @@ -31,10 +31,6 @@ #include "display/nr-filter-types.h" /* FeBlend base class */ - -static void sp_feBlend_class_init(SPFeBlendClass *klass); -static void sp_feBlend_init(SPFeBlend *feBlend); - static void sp_feBlend_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feBlend_release(SPObject *object); static void sp_feBlend_set(SPObject *object, unsigned int key, gchar const *value); @@ -42,28 +38,7 @@ static void sp_feBlend_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feBlend_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_feBlend_build_renderer(SPFilterPrimitive *sp_prim, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *feBlend_parent_class; - -GType -sp_feBlend_get_type() -{ - static GType feBlend_type = 0; - - if (!feBlend_type) { - GTypeInfo feBlend_info = { - sizeof(SPFeBlendClass), - NULL, NULL, - (GClassInitFunc) sp_feBlend_class_init, - NULL, NULL, - sizeof(SPFeBlend), - 16, - (GInstanceInitFunc) sp_feBlend_init, - NULL, /* value_table */ - }; - feBlend_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeBlend", &feBlend_info, (GTypeFlags)0); - } - return feBlend_type; -} +G_DEFINE_TYPE(SPFeBlend, sp_feBlend, SP_TYPE_FILTER_PRIMITIVE); static void sp_feBlend_class_init(SPFeBlendClass *klass) @@ -71,8 +46,6 @@ sp_feBlend_class_init(SPFeBlendClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feBlend_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feBlend_build; sp_object_class->release = sp_feBlend_release; sp_object_class->write = sp_feBlend_write; @@ -98,8 +71,8 @@ sp_feBlend_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *re { SPFeBlend *blend = SP_FEBLEND(object); - if (((SPObjectClass *) feBlend_parent_class)->build) { - ((SPObjectClass *) feBlend_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feBlend_parent_class)->build) { + ((SPObjectClass *) sp_feBlend_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -123,8 +96,8 @@ sp_feBlend_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *re static void sp_feBlend_release(SPObject *object) { - if (((SPObjectClass *) feBlend_parent_class)->release) - ((SPObjectClass *) feBlend_parent_class)->release(object); + if (((SPObjectClass *) sp_feBlend_parent_class)->release) + ((SPObjectClass *) sp_feBlend_parent_class)->release(object); } static Inkscape::Filters::FilterBlendMode sp_feBlend_readmode(gchar const *value) @@ -186,8 +159,8 @@ sp_feBlend_set(SPObject *object, unsigned int key, gchar const *value) } break; default: - if (((SPObjectClass *) feBlend_parent_class)->set) - ((SPObjectClass *) feBlend_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feBlend_parent_class)->set) + ((SPObjectClass *) sp_feBlend_parent_class)->set(object, key, value); break; } @@ -218,8 +191,8 @@ sp_feBlend_update(SPObject *object, SPCtx *ctx, guint flags) object->getRepr()->setAttribute("in2", sp_filter_name_for_image(parent, blend->in2)); } - if (((SPObjectClass *) feBlend_parent_class)->update) { - ((SPObjectClass *) feBlend_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feBlend_parent_class)->update) { + ((SPObjectClass *) sp_feBlend_parent_class)->update(object, ctx, flags); } } @@ -267,8 +240,8 @@ sp_feBlend_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML:: } repr->setAttribute("mode", mode); - if (((SPObjectClass *) feBlend_parent_class)->write) { - ((SPObjectClass *) feBlend_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feBlend_parent_class)->write) { + ((SPObjectClass *) sp_feBlend_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/colormatrix.cpp b/src/filters/colormatrix.cpp index b88b84037..aaf1c2986 100644 --- a/src/filters/colormatrix.cpp +++ b/src/filters/colormatrix.cpp @@ -30,10 +30,6 @@ #include "display/nr-filter-colormatrix.h" /* FeColorMatrix base class */ - -static void sp_feColorMatrix_class_init(SPFeColorMatrixClass *klass); -static void sp_feColorMatrix_init(SPFeColorMatrix *feColorMatrix); - static void sp_feColorMatrix_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feColorMatrix_release(SPObject *object); static void sp_feColorMatrix_set(SPObject *object, unsigned int key, gchar const *value); @@ -41,28 +37,7 @@ static void sp_feColorMatrix_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feColorMatrix_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_feColorMatrix_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *feColorMatrix_parent_class; - -GType -sp_feColorMatrix_get_type() -{ - static GType feColorMatrix_type = 0; - - if (!feColorMatrix_type) { - GTypeInfo feColorMatrix_info = { - sizeof(SPFeColorMatrixClass), - NULL, NULL, - (GClassInitFunc) sp_feColorMatrix_class_init, - NULL, NULL, - sizeof(SPFeColorMatrix), - 16, - (GInstanceInitFunc) sp_feColorMatrix_init, - NULL, /* value_table */ - }; - feColorMatrix_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeColorMatrix", &feColorMatrix_info, (GTypeFlags)0); - } - return feColorMatrix_type; -} +G_DEFINE_TYPE(SPFeColorMatrix, sp_feColorMatrix, SP_TYPE_FILTER_PRIMITIVE); static void sp_feColorMatrix_class_init(SPFeColorMatrixClass *klass) @@ -70,8 +45,6 @@ sp_feColorMatrix_class_init(SPFeColorMatrixClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feColorMatrix_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feColorMatrix_build; sp_object_class->release = sp_feColorMatrix_release; sp_object_class->write = sp_feColorMatrix_write; @@ -93,8 +66,8 @@ sp_feColorMatrix_init(SPFeColorMatrix */*feColorMatrix*/) static void sp_feColorMatrix_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feColorMatrix_parent_class)->build) { - ((SPObjectClass *) feColorMatrix_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feColorMatrix_parent_class)->build) { + ((SPObjectClass *) sp_feColorMatrix_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -108,8 +81,8 @@ sp_feColorMatrix_build(SPObject *object, SPDocument *document, Inkscape::XML::No static void sp_feColorMatrix_release(SPObject *object) { - if (((SPObjectClass *) feColorMatrix_parent_class)->release) - ((SPObjectClass *) feColorMatrix_parent_class)->release(object); + if (((SPObjectClass *) sp_feColorMatrix_parent_class)->release) + ((SPObjectClass *) sp_feColorMatrix_parent_class)->release(object); } static Inkscape::Filters::FilterColorMatrixType sp_feColorMatrix_read_type(gchar const *value){ @@ -158,8 +131,8 @@ sp_feColorMatrix_set(SPObject *object, unsigned int key, gchar const *str) } break; default: - if (((SPObjectClass *) feColorMatrix_parent_class)->set) - ((SPObjectClass *) feColorMatrix_parent_class)->set(object, key, str); + if (((SPObjectClass *) sp_feColorMatrix_parent_class)->set) + ((SPObjectClass *) sp_feColorMatrix_parent_class)->set(object, key, str); break; } } @@ -177,8 +150,8 @@ sp_feColorMatrix_update(SPObject *object, SPCtx *ctx, guint flags) } - if (((SPObjectClass *) feColorMatrix_parent_class)->update) { - ((SPObjectClass *) feColorMatrix_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feColorMatrix_parent_class)->update) { + ((SPObjectClass *) sp_feColorMatrix_parent_class)->update(object, ctx, flags); } } @@ -194,8 +167,8 @@ sp_feColorMatrix_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape: repr = object->getRepr()->duplicate(doc); } - if (((SPObjectClass *) feColorMatrix_parent_class)->write) { - ((SPObjectClass *) feColorMatrix_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feColorMatrix_parent_class)->write) { + ((SPObjectClass *) sp_feColorMatrix_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/componenttransfer.cpp b/src/filters/componenttransfer.cpp index 8cc388dd0..71e1ffe8e 100644 --- a/src/filters/componenttransfer.cpp +++ b/src/filters/componenttransfer.cpp @@ -28,10 +28,6 @@ #include "display/nr-filter-component-transfer.h" /* FeComponentTransfer base class */ - -static void sp_feComponentTransfer_class_init(SPFeComponentTransferClass *klass); -static void sp_feComponentTransfer_init(SPFeComponentTransfer *feComponentTransfer); - static void sp_feComponentTransfer_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feComponentTransfer_release(SPObject *object); static void sp_feComponentTransfer_set(SPObject *object, unsigned int key, gchar const *value); @@ -40,35 +36,14 @@ static void sp_feComponentTransfer_build_renderer(SPFilterPrimitive *primitive, static void sp_feComponentTransfer_remove_child(SPObject *object, Inkscape::XML::Node *child); static void sp_feComponentTransfer_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); static Inkscape::XML::Node *sp_feComponentTransfer_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPFilterPrimitiveClass *feComponentTransfer_parent_class; -GType -sp_feComponentTransfer_get_type() -{ - static GType feComponentTransfer_type = 0; - - if (!feComponentTransfer_type) { - GTypeInfo feComponentTransfer_info = { - sizeof(SPFeComponentTransferClass), - NULL, NULL, - (GClassInitFunc) sp_feComponentTransfer_class_init, - NULL, NULL, - sizeof(SPFeComponentTransfer), - 16, - (GInstanceInitFunc) sp_feComponentTransfer_init, - NULL, /* value_table */ - }; - feComponentTransfer_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeComponentTransfer", &feComponentTransfer_info, (GTypeFlags)0); - } - return feComponentTransfer_type; -} +G_DEFINE_TYPE(SPFeComponentTransfer, sp_feComponentTransfer, SP_TYPE_FILTER_PRIMITIVE); static void sp_feComponentTransfer_class_init(SPFeComponentTransferClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feComponentTransfer_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); sp_object_class->build = sp_feComponentTransfer_build; sp_object_class->release = sp_feComponentTransfer_release; @@ -93,8 +68,8 @@ sp_feComponentTransfer_init(SPFeComponentTransfer */*feComponentTransfer*/) static void sp_feComponentTransfer_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feComponentTransfer_parent_class)->build) { - ((SPObjectClass *) feComponentTransfer_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feComponentTransfer_parent_class)->build) { + ((SPObjectClass *) sp_feComponentTransfer_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -144,8 +119,8 @@ sp_feComponentTransfer_child_added(SPObject *object, Inkscape::XML::Node *child, { SPFeComponentTransfer *f = SP_FECOMPONENTTRANSFER(object); - if (((SPObjectClass *) feComponentTransfer_parent_class)->child_added) - (* ((SPObjectClass *) feComponentTransfer_parent_class)->child_added)(object, child, ref); + if (((SPObjectClass *) sp_feComponentTransfer_parent_class)->child_added) + (* ((SPObjectClass *) sp_feComponentTransfer_parent_class)->child_added)(object, child, ref); sp_feComponentTransfer_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -160,8 +135,8 @@ sp_feComponentTransfer_remove_child(SPObject *object, Inkscape::XML::Node *child { SPFeComponentTransfer *f = SP_FECOMPONENTTRANSFER(object); - if (((SPObjectClass *) feComponentTransfer_parent_class)->remove_child) - (* ((SPObjectClass *) feComponentTransfer_parent_class)->remove_child)(object, child); + if (((SPObjectClass *) sp_feComponentTransfer_parent_class)->remove_child) + (* ((SPObjectClass *) sp_feComponentTransfer_parent_class)->remove_child)(object, child); sp_feComponentTransfer_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -173,8 +148,8 @@ sp_feComponentTransfer_remove_child(SPObject *object, Inkscape::XML::Node *child static void sp_feComponentTransfer_release(SPObject *object) { - if (((SPObjectClass *) feComponentTransfer_parent_class)->release) - ((SPObjectClass *) feComponentTransfer_parent_class)->release(object); + if (((SPObjectClass *) sp_feComponentTransfer_parent_class)->release) + ((SPObjectClass *) sp_feComponentTransfer_parent_class)->release(object); } /** @@ -189,8 +164,8 @@ sp_feComponentTransfer_set(SPObject *object, unsigned int key, gchar const *valu switch(key) { /*DEAL WITH SETTING ATTRIBUTES HERE*/ default: - if (((SPObjectClass *) feComponentTransfer_parent_class)->set) - ((SPObjectClass *) feComponentTransfer_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feComponentTransfer_parent_class)->set) + ((SPObjectClass *) sp_feComponentTransfer_parent_class)->set(object, key, value); break; } } @@ -208,8 +183,8 @@ sp_feComponentTransfer_update(SPObject *object, SPCtx *ctx, guint flags) } - if (((SPObjectClass *) feComponentTransfer_parent_class)->update) { - ((SPObjectClass *) feComponentTransfer_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feComponentTransfer_parent_class)->update) { + ((SPObjectClass *) sp_feComponentTransfer_parent_class)->update(object, ctx, flags); } } @@ -225,8 +200,8 @@ sp_feComponentTransfer_write(SPObject *object, Inkscape::XML::Document *doc, Ink repr = object->getRepr()->duplicate(doc); } - if (((SPObjectClass *) feComponentTransfer_parent_class)->write) { - ((SPObjectClass *) feComponentTransfer_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feComponentTransfer_parent_class)->write) { + ((SPObjectClass *) sp_feComponentTransfer_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/composite.cpp b/src/filters/composite.cpp index 66e8e3415..d490f336c 100644 --- a/src/filters/composite.cpp +++ b/src/filters/composite.cpp @@ -26,10 +26,6 @@ #include "sp-filter.h" /* FeComposite base class */ - -static void sp_feComposite_class_init(SPFeCompositeClass *klass); -static void sp_feComposite_init(SPFeComposite *feComposite); - static void sp_feComposite_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feComposite_release(SPObject *object); static void sp_feComposite_set(SPObject *object, unsigned int key, gchar const *value); @@ -37,28 +33,7 @@ static void sp_feComposite_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feComposite_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_feComposite_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *feComposite_parent_class; - -GType -sp_feComposite_get_type() -{ - static GType feComposite_type = 0; - - if (!feComposite_type) { - GTypeInfo feComposite_info = { - sizeof(SPFeCompositeClass), - NULL, NULL, - (GClassInitFunc) sp_feComposite_class_init, - NULL, NULL, - sizeof(SPFeComposite), - 16, - (GInstanceInitFunc) sp_feComposite_init, - NULL, /* value_table */ - }; - feComposite_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeComposite", &feComposite_info, (GTypeFlags)0); - } - return feComposite_type; -} +G_DEFINE_TYPE(SPFeComposite, sp_feComposite, SP_TYPE_FILTER_PRIMITIVE); static void sp_feComposite_class_init(SPFeCompositeClass *klass) @@ -66,8 +41,6 @@ sp_feComposite_class_init(SPFeCompositeClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feComposite_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feComposite_build; sp_object_class->release = sp_feComposite_release; sp_object_class->write = sp_feComposite_write; @@ -96,8 +69,8 @@ sp_feComposite_init(SPFeComposite *feComposite) static void sp_feComposite_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feComposite_parent_class)->build) { - ((SPObjectClass *) feComposite_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feComposite_parent_class)->build) { + ((SPObjectClass *) sp_feComposite_parent_class)->build(object, document, repr); } SPFeComposite *comp = SP_FECOMPOSITE(object); @@ -128,8 +101,8 @@ sp_feComposite_build(SPObject *object, SPDocument *document, Inkscape::XML::Node static void sp_feComposite_release(SPObject *object) { - if (((SPObjectClass *) feComposite_parent_class)->release) - ((SPObjectClass *) feComposite_parent_class)->release(object); + if (((SPObjectClass *) sp_feComposite_parent_class)->release) + ((SPObjectClass *) sp_feComposite_parent_class)->release(object); } static FeCompositeOperator @@ -212,8 +185,8 @@ sp_feComposite_set(SPObject *object, unsigned int key, gchar const *value) break; default: - if (((SPObjectClass *) feComposite_parent_class)->set) - ((SPObjectClass *) feComposite_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feComposite_parent_class)->set) + ((SPObjectClass *) sp_feComposite_parent_class)->set(object, key, value); break; } @@ -246,8 +219,8 @@ sp_feComposite_update(SPObject *object, SPCtx *ctx, guint flags) object->getRepr()->setAttribute("in2", sp_filter_name_for_image(parent, comp->in2)); } - if (((SPObjectClass *) feComposite_parent_class)->update) { - ((SPObjectClass *) feComposite_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feComposite_parent_class)->update) { + ((SPObjectClass *) sp_feComposite_parent_class)->update(object, ctx, flags); } } @@ -309,8 +282,8 @@ sp_feComposite_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::X repr->setAttribute("k4", 0); } - if (((SPObjectClass *) feComposite_parent_class)->write) { - ((SPObjectClass *) feComposite_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feComposite_parent_class)->write) { + ((SPObjectClass *) sp_feComposite_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/convolvematrix.cpp b/src/filters/convolvematrix.cpp index 470bfb64a..d002ef731 100644 --- a/src/filters/convolvematrix.cpp +++ b/src/filters/convolvematrix.cpp @@ -29,10 +29,6 @@ #include "display/nr-filter-convolve-matrix.h" /* FeConvolveMatrix base class */ - -static void sp_feConvolveMatrix_class_init(SPFeConvolveMatrixClass *klass); -static void sp_feConvolveMatrix_init(SPFeConvolveMatrix *feConvolveMatrix); - static void sp_feConvolveMatrix_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feConvolveMatrix_release(SPObject *object); static void sp_feConvolveMatrix_set(SPObject *object, unsigned int key, gchar const *value); @@ -40,28 +36,7 @@ static void sp_feConvolveMatrix_update(SPObject *object, SPCtx *ctx, guint flags static Inkscape::XML::Node *sp_feConvolveMatrix_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_feConvolveMatrix_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *feConvolveMatrix_parent_class; - -GType -sp_feConvolveMatrix_get_type() -{ - static GType feConvolveMatrix_type = 0; - - if (!feConvolveMatrix_type) { - GTypeInfo feConvolveMatrix_info = { - sizeof(SPFeConvolveMatrixClass), - NULL, NULL, - (GClassInitFunc) sp_feConvolveMatrix_class_init, - NULL, NULL, - sizeof(SPFeConvolveMatrix), - 16, - (GInstanceInitFunc) sp_feConvolveMatrix_init, - NULL, /* value_table */ - }; - feConvolveMatrix_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeConvolveMatrix", &feConvolveMatrix_info, (GTypeFlags)0); - } - return feConvolveMatrix_type; -} +G_DEFINE_TYPE(SPFeConvolveMatrix, sp_feConvolveMatrix, SP_TYPE_FILTER_PRIMITIVE); static void sp_feConvolveMatrix_class_init(SPFeConvolveMatrixClass *klass) @@ -69,8 +44,6 @@ sp_feConvolveMatrix_class_init(SPFeConvolveMatrixClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feConvolveMatrix_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feConvolveMatrix_build; sp_object_class->release = sp_feConvolveMatrix_release; sp_object_class->write = sp_feConvolveMatrix_write; @@ -104,8 +77,8 @@ sp_feConvolveMatrix_init(SPFeConvolveMatrix *feConvolveMatrix) static void sp_feConvolveMatrix_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feConvolveMatrix_parent_class)->build) { - ((SPObjectClass *) feConvolveMatrix_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feConvolveMatrix_parent_class)->build) { + ((SPObjectClass *) sp_feConvolveMatrix_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -126,8 +99,8 @@ sp_feConvolveMatrix_build(SPObject *object, SPDocument *document, Inkscape::XML: static void sp_feConvolveMatrix_release(SPObject *object) { - if (((SPObjectClass *) feConvolveMatrix_parent_class)->release) - ((SPObjectClass *) feConvolveMatrix_parent_class)->release(object); + if (((SPObjectClass *) sp_feConvolveMatrix_parent_class)->release) + ((SPObjectClass *) sp_feConvolveMatrix_parent_class)->release(object); } static Inkscape::Filters::FilterConvolveMatrixEdgeMode sp_feConvolveMatrix_read_edgeMode(gchar const *value){ @@ -265,8 +238,8 @@ sp_feConvolveMatrix_set(SPObject *object, unsigned int key, gchar const *value) } break; default: - if (((SPObjectClass *) feConvolveMatrix_parent_class)->set) - ((SPObjectClass *) feConvolveMatrix_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feConvolveMatrix_parent_class)->set) + ((SPObjectClass *) sp_feConvolveMatrix_parent_class)->set(object, key, value); break; } @@ -285,8 +258,8 @@ sp_feConvolveMatrix_update(SPObject *object, SPCtx *ctx, guint flags) } - if (((SPObjectClass *) feConvolveMatrix_parent_class)->update) { - ((SPObjectClass *) feConvolveMatrix_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feConvolveMatrix_parent_class)->update) { + ((SPObjectClass *) sp_feConvolveMatrix_parent_class)->update(object, ctx, flags); } } @@ -303,8 +276,8 @@ sp_feConvolveMatrix_write(SPObject *object, Inkscape::XML::Document *doc, Inksca } - if (((SPObjectClass *) feConvolveMatrix_parent_class)->write) { - ((SPObjectClass *) feConvolveMatrix_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feConvolveMatrix_parent_class)->write) { + ((SPObjectClass *) sp_feConvolveMatrix_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/diffuselighting.cpp b/src/filters/diffuselighting.cpp index 0f2f29d67..66dd825f6 100644 --- a/src/filters/diffuselighting.cpp +++ b/src/filters/diffuselighting.cpp @@ -18,10 +18,13 @@ # include "config.h" #endif +#include "strneq.h" + #include "attributes.h" #include "svg/svg.h" #include "sp-object.h" #include "svg/svg-color.h" +#include "svg/svg-icc-color.h" #include "filters/diffuselighting.h" #include "filters/distantlight.h" #include "filters/pointlight.h" @@ -31,10 +34,6 @@ #include "display/nr-filter-diffuselighting.h" /* FeDiffuseLighting base class */ - -static void sp_feDiffuseLighting_class_init(SPFeDiffuseLightingClass *klass); -static void sp_feDiffuseLighting_init(SPFeDiffuseLighting *feDiffuseLighting); - static void sp_feDiffuseLighting_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feDiffuseLighting_release(SPObject *object); static void sp_feDiffuseLighting_set(SPObject *object, unsigned int key, gchar const *value); @@ -52,35 +51,13 @@ static Inkscape::XML::Node *sp_feDiffuseLighting_write(SPObject *object, Inkscap static void sp_feDiffuseLighting_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); static void sp_feDiffuseLighting_children_modified(SPFeDiffuseLighting *sp_diffuselighting); -static SPFilterPrimitiveClass *feDiffuseLighting_parent_class; - -GType -sp_feDiffuseLighting_get_type() -{ - static GType feDiffuseLighting_type = 0; - - if (!feDiffuseLighting_type) { - GTypeInfo feDiffuseLighting_info = { - sizeof(SPFeDiffuseLightingClass), - NULL, NULL, - (GClassInitFunc) sp_feDiffuseLighting_class_init, - NULL, NULL, - sizeof(SPFeDiffuseLighting), - 16, - (GInstanceInitFunc) sp_feDiffuseLighting_init, - NULL, /* value_table */ - }; - feDiffuseLighting_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeDiffuseLighting", &feDiffuseLighting_info, (GTypeFlags)0); - } - return feDiffuseLighting_type; -} +G_DEFINE_TYPE(SPFeDiffuseLighting, sp_feDiffuseLighting, SP_TYPE_FILTER_PRIMITIVE); static void sp_feDiffuseLighting_class_init(SPFeDiffuseLightingClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feDiffuseLighting_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); sp_object_class->build = sp_feDiffuseLighting_build; sp_object_class->release = sp_feDiffuseLighting_release; @@ -100,6 +77,8 @@ sp_feDiffuseLighting_init(SPFeDiffuseLighting *feDiffuseLighting) feDiffuseLighting->surfaceScale = 1; feDiffuseLighting->diffuseConstant = 1; feDiffuseLighting->lighting_color = 0xffffffff; + feDiffuseLighting->icc = NULL; + //TODO kernelUnit feDiffuseLighting->renderer = NULL; @@ -116,8 +95,8 @@ sp_feDiffuseLighting_init(SPFeDiffuseLighting *feDiffuseLighting) static void sp_feDiffuseLighting_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feDiffuseLighting_parent_class)->build) { - ((SPObjectClass *) feDiffuseLighting_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feDiffuseLighting_parent_class)->build) { + ((SPObjectClass *) sp_feDiffuseLighting_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -134,8 +113,8 @@ sp_feDiffuseLighting_build(SPObject *object, SPDocument *document, Inkscape::XML static void sp_feDiffuseLighting_release(SPObject *object) { - if (((SPObjectClass *) feDiffuseLighting_parent_class)->release) - ((SPObjectClass *) feDiffuseLighting_parent_class)->release(object); + if (((SPObjectClass *) sp_feDiffuseLighting_parent_class)->release) + ((SPObjectClass *) sp_feDiffuseLighting_parent_class)->release(object); } /** @@ -202,6 +181,16 @@ sp_feDiffuseLighting_set(SPObject *object, unsigned int key, gchar const *value) feDiffuseLighting->lighting_color = sp_svg_read_color(value, &cend_ptr, 0xffffffff); //if a value was read if (cend_ptr) { + while (g_ascii_isspace(*cend_ptr)) { + ++cend_ptr; + } + if (strneq(cend_ptr, "icc-color(", 10)) { + if (!feDiffuseLighting->icc) feDiffuseLighting->icc = new SVGICCColor(); + if ( ! sp_svg_read_icc_color( cend_ptr, feDiffuseLighting->icc ) ) { + delete feDiffuseLighting->icc; + feDiffuseLighting->icc = NULL; + } + } feDiffuseLighting->lighting_color_set = TRUE; } else { //lighting_color already contains the default value @@ -213,8 +202,8 @@ sp_feDiffuseLighting_set(SPObject *object, unsigned int key, gchar const *value) object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) feDiffuseLighting_parent_class)->set) - ((SPObjectClass *) feDiffuseLighting_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feDiffuseLighting_parent_class)->set) + ((SPObjectClass *) sp_feDiffuseLighting_parent_class)->set(object, key, value); break; } @@ -233,8 +222,8 @@ sp_feDiffuseLighting_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "lighting-color" ); } - if (((SPObjectClass *) feDiffuseLighting_parent_class)->update) { - ((SPObjectClass *) feDiffuseLighting_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feDiffuseLighting_parent_class)->update) { + ((SPObjectClass *) sp_feDiffuseLighting_parent_class)->update(object, ctx, flags); } } @@ -269,8 +258,8 @@ sp_feDiffuseLighting_write(SPObject *object, Inkscape::XML::Document *doc, Inksc } else repr->setAttribute("lighting-color", NULL); - if (((SPObjectClass *) feDiffuseLighting_parent_class)->write) { - ((SPObjectClass *) feDiffuseLighting_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feDiffuseLighting_parent_class)->write) { + ((SPObjectClass *) sp_feDiffuseLighting_parent_class)->write(object, doc, repr, flags); } return repr; @@ -284,8 +273,8 @@ sp_feDiffuseLighting_child_added(SPObject *object, Inkscape::XML::Node *child, I { SPFeDiffuseLighting *f = SP_FEDIFFUSELIGHTING(object); - if (((SPObjectClass *) feDiffuseLighting_parent_class)->child_added) - (* ((SPObjectClass *) feDiffuseLighting_parent_class)->child_added)(object, child, ref); + if (((SPObjectClass *) sp_feDiffuseLighting_parent_class)->child_added) + (* ((SPObjectClass *) sp_feDiffuseLighting_parent_class)->child_added)(object, child, ref); sp_feDiffuseLighting_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -300,8 +289,8 @@ sp_feDiffuseLighting_remove_child(SPObject *object, Inkscape::XML::Node *child) { SPFeDiffuseLighting *f = SP_FEDIFFUSELIGHTING(object); - if (((SPObjectClass *) feDiffuseLighting_parent_class)->remove_child) - (* ((SPObjectClass *) feDiffuseLighting_parent_class)->remove_child)(object, child); + if (((SPObjectClass *) sp_feDiffuseLighting_parent_class)->remove_child) + (* ((SPObjectClass *) sp_feDiffuseLighting_parent_class)->remove_child)(object, child); sp_feDiffuseLighting_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -311,8 +300,8 @@ static void sp_feDiffuseLighting_order_changed (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref) { SPFeDiffuseLighting *f = SP_FEDIFFUSELIGHTING(object); - if (((SPObjectClass *) (feDiffuseLighting_parent_class))->order_changed) - (* ((SPObjectClass *) (feDiffuseLighting_parent_class))->order_changed) (object, child, old_ref, new_ref); + if (((SPObjectClass *) (sp_feDiffuseLighting_parent_class))->order_changed) + (* ((SPObjectClass *) (sp_feDiffuseLighting_parent_class))->order_changed) (object, child, old_ref, new_ref); sp_feDiffuseLighting_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -354,6 +343,8 @@ static void sp_feDiffuseLighting_build_renderer(SPFilterPrimitive *primitive, In nr_diffuselighting->diffuseConstant = sp_diffuselighting->diffuseConstant; nr_diffuselighting->surfaceScale = sp_diffuselighting->surfaceScale; nr_diffuselighting->lighting_color = sp_diffuselighting->lighting_color; + nr_diffuselighting->set_icc(sp_diffuselighting->icc); + //We assume there is at most one child nr_diffuselighting->light_type = Inkscape::Filters::NO_LIGHT; if (SP_IS_FEDISTANTLIGHT(primitive->children)) { diff --git a/src/filters/diffuselighting.h b/src/filters/diffuselighting.h index a23346622..99dccb394 100644 --- a/src/filters/diffuselighting.h +++ b/src/filters/diffuselighting.h @@ -15,17 +15,14 @@ #include "sp-filter-primitive.h" #include "number-opt-number.h" -namespace Inkscape { -namespace Filters { -class FilterDiffuseLighting; -} } - #define SP_TYPE_FEDIFFUSELIGHTING (sp_feDiffuseLighting_get_type()) #define SP_FEDIFFUSELIGHTING(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEDIFFUSELIGHTING, SPFeDiffuseLighting)) #define SP_FEDIFFUSELIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEDIFFUSELIGHTING, SPFeDiffuseLightingClass)) #define SP_IS_FEDIFFUSELIGHTING(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEDIFFUSELIGHTING)) #define SP_IS_FEDIFFUSELIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEDIFFUSELIGHTING)) +class SVGICCColor; + namespace Inkscape { namespace Filters { class FilterDiffuseLighting; @@ -42,6 +39,7 @@ struct SPFeDiffuseLighting : public SPFilterPrimitive { guint32 lighting_color; guint lighting_color_set : 1; Inkscape::Filters::FilterDiffuseLighting *renderer; + SVGICCColor *icc; }; struct SPFeDiffuseLightingClass { diff --git a/src/filters/displacementmap.cpp b/src/filters/displacementmap.cpp index 69a678c26..408ffce9e 100644 --- a/src/filters/displacementmap.cpp +++ b/src/filters/displacementmap.cpp @@ -26,10 +26,6 @@ #include "display/nr-filter-displacement-map.h" /* FeDisplacementMap base class */ - -static void sp_feDisplacementMap_class_init(SPFeDisplacementMapClass *klass); -static void sp_feDisplacementMap_init(SPFeDisplacementMap *feDisplacementMap); - static void sp_feDisplacementMap_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feDisplacementMap_release(SPObject *object); static void sp_feDisplacementMap_set(SPObject *object, unsigned int key, gchar const *value); @@ -37,28 +33,7 @@ static void sp_feDisplacementMap_update(SPObject *object, SPCtx *ctx, guint flag static void sp_feDisplacementMap_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); static Inkscape::XML::Node *sp_feDisplacementMap_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPFilterPrimitiveClass *feDisplacementMap_parent_class; - -GType -sp_feDisplacementMap_get_type() -{ - static GType feDisplacementMap_type = 0; - - if (!feDisplacementMap_type) { - GTypeInfo feDisplacementMap_info = { - sizeof(SPFeDisplacementMapClass), - NULL, NULL, - (GClassInitFunc) sp_feDisplacementMap_class_init, - NULL, NULL, - sizeof(SPFeDisplacementMap), - 16, - (GInstanceInitFunc) sp_feDisplacementMap_init, - NULL, /* value_table */ - }; - feDisplacementMap_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeDisplacementMap", &feDisplacementMap_info, (GTypeFlags)0); - } - return feDisplacementMap_type; -} +G_DEFINE_TYPE(SPFeDisplacementMap, sp_feDisplacementMap, SP_TYPE_FILTER_PRIMITIVE); static void sp_feDisplacementMap_class_init(SPFeDisplacementMapClass *klass) @@ -66,8 +41,6 @@ sp_feDisplacementMap_class_init(SPFeDisplacementMapClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feDisplacementMap_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feDisplacementMap_build; sp_object_class->release = sp_feDisplacementMap_release; sp_object_class->write = sp_feDisplacementMap_write; @@ -93,8 +66,8 @@ sp_feDisplacementMap_init(SPFeDisplacementMap *feDisplacementMap) static void sp_feDisplacementMap_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feDisplacementMap_parent_class)->build) { - ((SPObjectClass *) feDisplacementMap_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feDisplacementMap_parent_class)->build) { + ((SPObjectClass *) sp_feDisplacementMap_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -121,8 +94,8 @@ sp_feDisplacementMap_build(SPObject *object, SPDocument *document, Inkscape::XML static void sp_feDisplacementMap_release(SPObject *object) { - if (((SPObjectClass *) feDisplacementMap_parent_class)->release) - ((SPObjectClass *) feDisplacementMap_parent_class)->release(object); + if (((SPObjectClass *) sp_feDisplacementMap_parent_class)->release) + ((SPObjectClass *) sp_feDisplacementMap_parent_class)->release(object); } static FilterDisplacementMapChannelSelector sp_feDisplacementMap_readChannelSelector(gchar const *value) @@ -191,8 +164,8 @@ sp_feDisplacementMap_set(SPObject *object, unsigned int key, gchar const *value) } break; default: - if (((SPObjectClass *) feDisplacementMap_parent_class)->set) - ((SPObjectClass *) feDisplacementMap_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feDisplacementMap_parent_class)->set) + ((SPObjectClass *) sp_feDisplacementMap_parent_class)->set(object, key, value); break; } @@ -224,8 +197,8 @@ sp_feDisplacementMap_update(SPObject *object, SPCtx *ctx, guint flags) object->getRepr()->setAttribute("in2", sp_filter_name_for_image(parent, disp->in2)); } - if (((SPObjectClass *) feDisplacementMap_parent_class)->update) { - ((SPObjectClass *) feDisplacementMap_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feDisplacementMap_parent_class)->update) { + ((SPObjectClass *) sp_feDisplacementMap_parent_class)->update(object, ctx, flags); } } @@ -277,8 +250,8 @@ sp_feDisplacementMap_write(SPObject *object, Inkscape::XML::Document *doc, Inksc repr->setAttribute("yChannelSelector", get_channelselector_name(disp->yChannelSelector)); - if (((SPObjectClass *) feDisplacementMap_parent_class)->write) { - ((SPObjectClass *) feDisplacementMap_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feDisplacementMap_parent_class)->write) { + ((SPObjectClass *) sp_feDisplacementMap_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/distantlight.cpp b/src/filters/distantlight.cpp index 891049415..5e1c35a95 100644 --- a/src/filters/distantlight.cpp +++ b/src/filters/distantlight.cpp @@ -30,47 +30,19 @@ #include "macros.h" /* FeDistantLight class */ - -static void sp_fedistantlight_class_init(SPFeDistantLightClass *klass); -static void sp_fedistantlight_init(SPFeDistantLight *fedistantlight); - static void sp_fedistantlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_fedistantlight_release(SPObject *object); static void sp_fedistantlight_set(SPObject *object, unsigned int key, gchar const *value); static void sp_fedistantlight_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_fedistantlight_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPObjectClass *feDistantLight_parent_class; - -GType -sp_fedistantlight_get_type() -{ - static GType fedistantlight_type = 0; - - if (!fedistantlight_type) { - GTypeInfo fedistantlight_info = { - sizeof(SPFeDistantLightClass), - NULL, NULL, - (GClassInitFunc) sp_fedistantlight_class_init, - NULL, NULL, - sizeof(SPFeDistantLight), - 16, - (GInstanceInitFunc) sp_fedistantlight_init, - NULL, /* value_table */ - }; - fedistantlight_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeDistantLight", &fedistantlight_info, (GTypeFlags)0); - } - return fedistantlight_type; -} +G_DEFINE_TYPE(SPFeDistantLight, sp_fedistantlight, SP_TYPE_OBJECT); static void sp_fedistantlight_class_init(SPFeDistantLightClass *klass) { - SPObjectClass *sp_object_class = (SPObjectClass *)klass; - feDistantLight_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_fedistantlight_build; sp_object_class->release = sp_fedistantlight_release; sp_object_class->write = sp_fedistantlight_write; @@ -95,8 +67,8 @@ sp_fedistantlight_init(SPFeDistantLight *fedistantlight) static void sp_fedistantlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feDistantLight_parent_class)->build) { - ((SPObjectClass *) feDistantLight_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_fedistantlight_parent_class)->build) { + ((SPObjectClass *) sp_fedistantlight_parent_class)->build(object, document, repr); } //Read values of key attributes from XML nodes into object. @@ -170,8 +142,8 @@ sp_fedistantlight_set(SPObject *object, unsigned int key, gchar const *value) break; default: // See if any parents need this value. - if (((SPObjectClass *) feDistantLight_parent_class)->set) { - ((SPObjectClass *) feDistantLight_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_fedistantlight_parent_class)->set) { + ((SPObjectClass *) sp_fedistantlight_parent_class)->set(object, key, value); } break; } @@ -192,8 +164,8 @@ sp_fedistantlight_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "elevation" ); } - if (((SPObjectClass *) feDistantLight_parent_class)->update) { - ((SPObjectClass *) feDistantLight_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_fedistantlight_parent_class)->update) { + ((SPObjectClass *) sp_fedistantlight_parent_class)->update(object, ctx, flags); } } @@ -214,8 +186,8 @@ sp_fedistantlight_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape if (fedistantlight->elevation_set) sp_repr_set_css_double(repr, "elevation", fedistantlight->elevation); - if (((SPObjectClass *) feDistantLight_parent_class)->write) { - ((SPObjectClass *) feDistantLight_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_fedistantlight_parent_class)->write) { + ((SPObjectClass *) sp_fedistantlight_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/gaussian-blur.cpp b/src/filters/gaussian-blur.cpp index ee1af8904..ca93cf6d8 100644 --- a/src/filters/gaussian-blur.cpp +++ b/src/filters/gaussian-blur.cpp @@ -31,10 +31,6 @@ //#include "macros.h" /* GaussianBlur base class */ - -static void sp_gaussianBlur_class_init(SPGaussianBlurClass *klass); -static void sp_gaussianBlur_init(SPGaussianBlur *gaussianBlur); - static void sp_gaussianBlur_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_gaussianBlur_release(SPObject *object); static void sp_gaussianBlur_set(SPObject *object, unsigned int key, gchar const *value); @@ -42,28 +38,7 @@ static void sp_gaussianBlur_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_gaussianBlur_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_gaussianBlur_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *gaussianBlur_parent_class; - -GType -sp_gaussianBlur_get_type() -{ - static GType gaussianBlur_type = 0; - - if (!gaussianBlur_type) { - GTypeInfo gaussianBlur_info = { - sizeof(SPGaussianBlurClass), - NULL, NULL, - (GClassInitFunc) sp_gaussianBlur_class_init, - NULL, NULL, - sizeof(SPGaussianBlur), - 16, - (GInstanceInitFunc) sp_gaussianBlur_init, - NULL, /* value_table */ - }; - gaussianBlur_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPGaussianBlur", &gaussianBlur_info, (GTypeFlags)0); - } - return gaussianBlur_type; -} +G_DEFINE_TYPE(SPGaussianBlur, sp_gaussianBlur, SP_TYPE_FILTER_PRIMITIVE); static void sp_gaussianBlur_class_init(SPGaussianBlurClass *klass) @@ -71,8 +46,6 @@ sp_gaussianBlur_class_init(SPGaussianBlurClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - gaussianBlur_parent_class = (SPFilterPrimitiveClass *)g_type_class_peek_parent(klass); - sp_object_class->build = sp_gaussianBlur_build; sp_object_class->release = sp_gaussianBlur_release; sp_object_class->write = sp_gaussianBlur_write; @@ -95,8 +68,8 @@ sp_gaussianBlur_init(SPGaussianBlur */*gaussianBlur*/) static void sp_gaussianBlur_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) gaussianBlur_parent_class)->build) { - ((SPObjectClass *) gaussianBlur_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_gaussianBlur_parent_class)->build) { + ((SPObjectClass *) sp_gaussianBlur_parent_class)->build(object, document, repr); } object->readAttr( "stdDeviation" ); @@ -110,8 +83,8 @@ static void sp_gaussianBlur_release(SPObject *object) { - if (((SPObjectClass *) gaussianBlur_parent_class)->release) - ((SPObjectClass *) gaussianBlur_parent_class)->release(object); + if (((SPObjectClass *) sp_gaussianBlur_parent_class)->release) + ((SPObjectClass *) sp_gaussianBlur_parent_class)->release(object); } /** @@ -128,8 +101,8 @@ sp_gaussianBlur_set(SPObject *object, unsigned int key, gchar const *value) object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) gaussianBlur_parent_class)->set) - ((SPObjectClass *) gaussianBlur_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_gaussianBlur_parent_class)->set) + ((SPObjectClass *) sp_gaussianBlur_parent_class)->set(object, key, value); break; } @@ -145,8 +118,8 @@ sp_gaussianBlur_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "stdDeviation" ); } - if (((SPObjectClass *) gaussianBlur_parent_class)->update) { - ((SPObjectClass *) gaussianBlur_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_gaussianBlur_parent_class)->update) { + ((SPObjectClass *) sp_gaussianBlur_parent_class)->update(object, ctx, flags); } } @@ -162,8 +135,8 @@ sp_gaussianBlur_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape:: repr = object->getRepr()->duplicate(doc); } - if (((SPObjectClass *) gaussianBlur_parent_class)->write) { - ((SPObjectClass *) gaussianBlur_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_gaussianBlur_parent_class)->write) { + ((SPObjectClass *) sp_gaussianBlur_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/image.cpp b/src/filters/image.cpp index f6ef310f7..ec31e59a7 100644 --- a/src/filters/image.cpp +++ b/src/filters/image.cpp @@ -30,10 +30,6 @@ #include "display/nr-filter-image.h" /* FeImage base class */ - -static void sp_feImage_class_init(SPFeImageClass *klass); -static void sp_feImage_init(SPFeImage *feImage); - static void sp_feImage_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feImage_release(SPObject *object); static void sp_feImage_set(SPObject *object, unsigned int key, gchar const *value); @@ -41,35 +37,13 @@ static void sp_feImage_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feImage_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_feImage_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *feImage_parent_class; - -GType sp_feImage_get_type() -{ - static GType feImage_type = 0; - - if (!feImage_type) { - GTypeInfo feImage_info = { - sizeof(SPFeImageClass), - NULL, NULL, - (GClassInitFunc) sp_feImage_class_init, - NULL, NULL, - sizeof(SPFeImage), - 16, - (GInstanceInitFunc) sp_feImage_init, - NULL, /* value_table */ - }; - feImage_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeImage", &feImage_info, (GTypeFlags)0); - } - return feImage_type; -} +G_DEFINE_TYPE(SPFeImage, sp_feImage, SP_TYPE_FILTER_PRIMITIVE); static void sp_feImage_class_init(SPFeImageClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass * sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feImage_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feImage_build; sp_object_class->release = sp_feImage_release; sp_object_class->write = sp_feImage_write; @@ -96,8 +70,8 @@ static void sp_feImage_build(SPObject *object, SPDocument *document, Inkscape::X SPFeImage *feImage = SP_FEIMAGE(object); feImage->document = document; - if (((SPObjectClass *) feImage_parent_class)->build) { - ((SPObjectClass *) feImage_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feImage_parent_class)->build) { + ((SPObjectClass *) sp_feImage_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -117,8 +91,8 @@ static void sp_feImage_release(SPObject *object) feImage->_href_modified_connection.disconnect(); if (feImage->SVGElemRef) delete feImage->SVGElemRef; - if (((SPObjectClass *) feImage_parent_class)->release) - ((SPObjectClass *) feImage_parent_class)->release(object); + if (((SPObjectClass *) sp_feImage_parent_class)->release) + ((SPObjectClass *) sp_feImage_parent_class)->release(object); } static void sp_feImage_elem_modified(SPObject* /*href*/, guint /*flags*/, SPObject* obj) @@ -247,8 +221,8 @@ static void sp_feImage_set(SPObject *object, unsigned int key, gchar const *valu break; default: - if (((SPObjectClass *) feImage_parent_class)->set) - ((SPObjectClass *) feImage_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feImage_parent_class)->set) + ((SPObjectClass *) sp_feImage_parent_class)->set(object, key, value); break; } @@ -266,8 +240,8 @@ static void sp_feImage_update(SPObject *object, SPCtx *ctx, guint flags) /* do something to trigger redisplay, updates? */ } - if (((SPObjectClass *) feImage_parent_class)->update) { - ((SPObjectClass *) feImage_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feImage_parent_class)->update) { + ((SPObjectClass *) sp_feImage_parent_class)->update(object, ctx, flags); } } @@ -282,8 +256,8 @@ static Inkscape::XML::Node * sp_feImage_write(SPObject *object, Inkscape::XML::D repr = object->getRepr()->duplicate(doc); } - if (((SPObjectClass *) feImage_parent_class)->write) { - ((SPObjectClass *) feImage_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feImage_parent_class)->write) { + ((SPObjectClass *) sp_feImage_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/merge.cpp b/src/filters/merge.cpp index b5a6d7dad..7346a0892 100644 --- a/src/filters/merge.cpp +++ b/src/filters/merge.cpp @@ -25,10 +25,6 @@ #include "display/nr-filter-merge.h" /* FeMerge base class */ - -static void sp_feMerge_class_init(SPFeMergeClass *klass); -static void sp_feMerge_init(SPFeMerge *feMerge); - static void sp_feMerge_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feMerge_release(SPObject *object); static void sp_feMerge_set(SPObject *object, unsigned int key, gchar const *value); @@ -36,28 +32,7 @@ static void sp_feMerge_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feMerge_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_feMerge_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *feMerge_parent_class; - -GType -sp_feMerge_get_type() -{ - static GType feMerge_type = 0; - - if (!feMerge_type) { - GTypeInfo feMerge_info = { - sizeof(SPFeMergeClass), - NULL, NULL, - (GClassInitFunc) sp_feMerge_class_init, - NULL, NULL, - sizeof(SPFeMerge), - 16, - (GInstanceInitFunc) sp_feMerge_init, - NULL, /* value_table */ - }; - feMerge_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeMerge", &feMerge_info, (GTypeFlags)0); - } - return feMerge_type; -} +G_DEFINE_TYPE(SPFeMerge, sp_feMerge, SP_TYPE_FILTER_PRIMITIVE); static void sp_feMerge_class_init(SPFeMergeClass *klass) @@ -65,8 +40,6 @@ sp_feMerge_class_init(SPFeMergeClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feMerge_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feMerge_build; sp_object_class->release = sp_feMerge_release; sp_object_class->write = sp_feMerge_write; @@ -89,8 +62,8 @@ sp_feMerge_init(SPFeMerge */*feMerge*/) static void sp_feMerge_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feMerge_parent_class)->build) { - ((SPObjectClass *) feMerge_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feMerge_parent_class)->build) { + ((SPObjectClass *) sp_feMerge_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -102,8 +75,8 @@ sp_feMerge_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *re static void sp_feMerge_release(SPObject *object) { - if (((SPObjectClass *) feMerge_parent_class)->release) - ((SPObjectClass *) feMerge_parent_class)->release(object); + if (((SPObjectClass *) sp_feMerge_parent_class)->release) + ((SPObjectClass *) sp_feMerge_parent_class)->release(object); } /** @@ -118,8 +91,8 @@ sp_feMerge_set(SPObject *object, unsigned int key, gchar const *value) switch(key) { /*DEAL WITH SETTING ATTRIBUTES HERE*/ default: - if (((SPObjectClass *) feMerge_parent_class)->set) - ((SPObjectClass *) feMerge_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feMerge_parent_class)->set) + ((SPObjectClass *) sp_feMerge_parent_class)->set(object, key, value); break; } @@ -135,8 +108,8 @@ sp_feMerge_update(SPObject *object, SPCtx *ctx, guint flags) object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); } - if (((SPObjectClass *) feMerge_parent_class)->update) { - ((SPObjectClass *) feMerge_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feMerge_parent_class)->update) { + ((SPObjectClass *) sp_feMerge_parent_class)->update(object, ctx, flags); } } @@ -153,8 +126,8 @@ sp_feMerge_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML:: } - if (((SPObjectClass *) feMerge_parent_class)->write) { - ((SPObjectClass *) feMerge_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feMerge_parent_class)->write) { + ((SPObjectClass *) sp_feMerge_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/mergenode.cpp b/src/filters/mergenode.cpp index 639928305..fa193ad77 100644 --- a/src/filters/mergenode.cpp +++ b/src/filters/mergenode.cpp @@ -23,46 +23,19 @@ #include "filters/merge.h" #include "display/nr-filter-types.h" -static void sp_feMergeNode_class_init(SPFeMergeNodeClass *klass); -static void sp_feMergeNode_init(SPFeMergeNode *skeleton); - static void sp_feMergeNode_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feMergeNode_release(SPObject *object); static void sp_feMergeNode_set(SPObject *object, unsigned int key, gchar const *value); static void sp_feMergeNode_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feMergeNode_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPObjectClass *feMergeNode_parent_class; - -GType -sp_feMergeNode_get_type() -{ - static GType feMergeNode_type = 0; - - if (!feMergeNode_type) { - GTypeInfo feMergeNode_info = { - sizeof(SPFeMergeNodeClass), - NULL, NULL, - (GClassInitFunc) sp_feMergeNode_class_init, - NULL, NULL, - sizeof(SPFeMergeNode), - 16, - (GInstanceInitFunc) sp_feMergeNode_init, - NULL, /* value_table */ - }; - feMergeNode_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeMergeNode", &feMergeNode_info, (GTypeFlags)0); - } - return feMergeNode_type; -} +G_DEFINE_TYPE(SPFeMergeNode, sp_feMergeNode, SP_TYPE_OBJECT); static void sp_feMergeNode_class_init(SPFeMergeNodeClass *klass) { - //GObjectClass *gobject_class = (GObjectClass *)klass; SPObjectClass *sp_object_class = (SPObjectClass *)klass; - feMergeNode_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feMergeNode_build; sp_object_class->release = sp_feMergeNode_release; sp_object_class->write = sp_feMergeNode_write; @@ -95,8 +68,8 @@ sp_feMergeNode_release(SPObject *object) { /* deal with our children and our selves here */ - if (((SPObjectClass *) feMergeNode_parent_class)->release) - ((SPObjectClass *) feMergeNode_parent_class)->release(object); + if (((SPObjectClass *) sp_feMergeNode_parent_class)->release) + ((SPObjectClass *) sp_feMergeNode_parent_class)->release(object); } /** @@ -117,8 +90,8 @@ sp_feMergeNode_set(SPObject *object, unsigned int key, gchar const *value) } /* See if any parents need this value. */ - if (((SPObjectClass *) feMergeNode_parent_class)->set) { - ((SPObjectClass *) feMergeNode_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feMergeNode_parent_class)->set) { + ((SPObjectClass *) sp_feMergeNode_parent_class)->set(object, key, value); } } @@ -134,8 +107,8 @@ sp_feMergeNode_update(SPObject *object, SPCtx *ctx, guint flags) object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); } - if (((SPObjectClass *) feMergeNode_parent_class)->update) { - ((SPObjectClass *) feMergeNode_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feMergeNode_parent_class)->update) { + ((SPObjectClass *) sp_feMergeNode_parent_class)->update(object, ctx, flags); } } @@ -157,8 +130,8 @@ sp_feMergeNode_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::X } } - if (((SPObjectClass *) feMergeNode_parent_class)->write) { - ((SPObjectClass *) feMergeNode_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feMergeNode_parent_class)->write) { + ((SPObjectClass *) sp_feMergeNode_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/morphology.cpp b/src/filters/morphology.cpp index 42327d59f..886a10311 100644 --- a/src/filters/morphology.cpp +++ b/src/filters/morphology.cpp @@ -27,10 +27,6 @@ #include "display/nr-filter-morphology.h" /* FeMorphology base class */ - -static void sp_feMorphology_class_init(SPFeMorphologyClass *klass); -static void sp_feMorphology_init(SPFeMorphology *feMorphology); - static void sp_feMorphology_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feMorphology_release(SPObject *object); static void sp_feMorphology_set(SPObject *object, unsigned int key, gchar const *value); @@ -38,36 +34,13 @@ static void sp_feMorphology_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feMorphology_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_feMorphology_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *feMorphology_parent_class; - -GType -sp_feMorphology_get_type() -{ - static GType feMorphology_type = 0; - - if (!feMorphology_type) { - GTypeInfo feMorphology_info = { - sizeof(SPFeMorphologyClass), - NULL, NULL, - (GClassInitFunc) sp_feMorphology_class_init, - NULL, NULL, - sizeof(SPFeMorphology), - 16, - (GInstanceInitFunc) sp_feMorphology_init, - NULL, /* value_table */ - }; - feMorphology_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeMorphology", &feMorphology_info, (GTypeFlags)0); - } - return feMorphology_type; -} +G_DEFINE_TYPE(SPFeMorphology, sp_feMorphology, SP_TYPE_FILTER_PRIMITIVE); static void sp_feMorphology_class_init(SPFeMorphologyClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - - feMorphology_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); sp_object_class->build = sp_feMorphology_build; sp_object_class->release = sp_feMorphology_release; @@ -92,8 +65,8 @@ sp_feMorphology_init(SPFeMorphology *feMorphology) static void sp_feMorphology_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feMorphology_parent_class)->build) { - ((SPObjectClass *) feMorphology_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feMorphology_parent_class)->build) { + ((SPObjectClass *) sp_feMorphology_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -107,8 +80,8 @@ sp_feMorphology_build(SPObject *object, SPDocument *document, Inkscape::XML::Nod static void sp_feMorphology_release(SPObject *object) { - if (((SPObjectClass *) feMorphology_parent_class)->release) - ((SPObjectClass *) feMorphology_parent_class)->release(object); + if (((SPObjectClass *) sp_feMorphology_parent_class)->release) + ((SPObjectClass *) sp_feMorphology_parent_class)->release(object); } static Inkscape::Filters::FilterMorphologyOperator sp_feMorphology_read_operator(gchar const *value){ @@ -151,8 +124,8 @@ sp_feMorphology_set(SPObject *object, unsigned int key, gchar const *value) object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) feMorphology_parent_class)->set) - ((SPObjectClass *) feMorphology_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feMorphology_parent_class)->set) + ((SPObjectClass *) sp_feMorphology_parent_class)->set(object, key, value); break; } @@ -171,8 +144,8 @@ sp_feMorphology_update(SPObject *object, SPCtx *ctx, guint flags) } - if (((SPObjectClass *) feMorphology_parent_class)->update) { - ((SPObjectClass *) feMorphology_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feMorphology_parent_class)->update) { + ((SPObjectClass *) sp_feMorphology_parent_class)->update(object, ctx, flags); } } @@ -188,8 +161,8 @@ sp_feMorphology_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape:: repr = object->getRepr()->duplicate(doc); } - if (((SPObjectClass *) feMorphology_parent_class)->write) { - ((SPObjectClass *) feMorphology_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feMorphology_parent_class)->write) { + ((SPObjectClass *) sp_feMorphology_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/offset.cpp b/src/filters/offset.cpp index f45169aba..2851f4f7d 100644 --- a/src/filters/offset.cpp +++ b/src/filters/offset.cpp @@ -26,10 +26,6 @@ #include "display/nr-filter-offset.h" /* FeOffset base class */ - -static void sp_feOffset_class_init(SPFeOffsetClass *klass); -static void sp_feOffset_init(SPFeOffset *feOffset); - static void sp_feOffset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feOffset_release(SPObject *object); static void sp_feOffset_set(SPObject *object, unsigned int key, gchar const *value); @@ -37,28 +33,7 @@ static void sp_feOffset_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feOffset_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_feOffset_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *feOffset_parent_class; - -GType -sp_feOffset_get_type() -{ - static GType feOffset_type = 0; - - if (!feOffset_type) { - GTypeInfo feOffset_info = { - sizeof(SPFeOffsetClass), - NULL, NULL, - (GClassInitFunc) sp_feOffset_class_init, - NULL, NULL, - sizeof(SPFeOffset), - 16, - (GInstanceInitFunc) sp_feOffset_init, - NULL, /* value_table */ - }; - feOffset_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeOffset", &feOffset_info, (GTypeFlags)0); - } - return feOffset_type; -} +G_DEFINE_TYPE(SPFeOffset, sp_feOffset, SP_TYPE_FILTER_PRIMITIVE); static void sp_feOffset_class_init(SPFeOffsetClass *klass) @@ -66,8 +41,6 @@ sp_feOffset_class_init(SPFeOffsetClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feOffset_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feOffset_build; sp_object_class->release = sp_feOffset_release; sp_object_class->write = sp_feOffset_write; @@ -92,8 +65,8 @@ sp_feOffset_init(SPFeOffset *feOffset) static void sp_feOffset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feOffset_parent_class)->build) { - ((SPObjectClass *) feOffset_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feOffset_parent_class)->build) { + ((SPObjectClass *) sp_feOffset_parent_class)->build(object, document, repr); } object->readAttr( "dx" ); @@ -106,8 +79,8 @@ sp_feOffset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *r static void sp_feOffset_release(SPObject *object) { - if (((SPObjectClass *) feOffset_parent_class)->release) - ((SPObjectClass *) feOffset_parent_class)->release(object); + if (((SPObjectClass *) sp_feOffset_parent_class)->release) + ((SPObjectClass *) sp_feOffset_parent_class)->release(object); } /** @@ -137,8 +110,8 @@ sp_feOffset_set(SPObject *object, unsigned int key, gchar const *value) /*DEAL WITH SETTING ATTRIBUTES HERE*/ default: - if (((SPObjectClass *) feOffset_parent_class)->set) - ((SPObjectClass *) feOffset_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feOffset_parent_class)->set) + ((SPObjectClass *) sp_feOffset_parent_class)->set(object, key, value); break; } @@ -155,8 +128,8 @@ sp_feOffset_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "dy" ); } - if (((SPObjectClass *) feOffset_parent_class)->update) { - ((SPObjectClass *) feOffset_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feOffset_parent_class)->update) { + ((SPObjectClass *) sp_feOffset_parent_class)->update(object, ctx, flags); } } @@ -172,8 +145,8 @@ sp_feOffset_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML: repr = object->getRepr()->duplicate(doc); } - if (((SPObjectClass *) feOffset_parent_class)->write) { - ((SPObjectClass *) feOffset_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feOffset_parent_class)->write) { + ((SPObjectClass *) sp_feOffset_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/pointlight.cpp b/src/filters/pointlight.cpp index ee6824d00..a512172d1 100644 --- a/src/filters/pointlight.cpp +++ b/src/filters/pointlight.cpp @@ -30,47 +30,19 @@ #include "macros.h" /* FePointLight class */ - -static void sp_fepointlight_class_init(SPFePointLightClass *klass); -static void sp_fepointlight_init(SPFePointLight *fepointlight); - static void sp_fepointlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_fepointlight_release(SPObject *object); static void sp_fepointlight_set(SPObject *object, unsigned int key, gchar const *value); static void sp_fepointlight_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_fepointlight_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPObjectClass *fePointLight_parent_class; - -GType -sp_fepointlight_get_type() -{ - static GType fepointlight_type = 0; - - if (!fepointlight_type) { - GTypeInfo fepointlight_info = { - sizeof(SPFePointLightClass), - NULL, NULL, - (GClassInitFunc) sp_fepointlight_class_init, - NULL, NULL, - sizeof(SPFePointLight), - 16, - (GInstanceInitFunc) sp_fepointlight_init, - NULL, /* value_table */ - }; - fepointlight_type = g_type_register_static(SP_TYPE_OBJECT, "SPFePointLight", &fepointlight_info, (GTypeFlags)0); - } - return fepointlight_type; -} +G_DEFINE_TYPE(SPFePointLight, sp_fepointlight, SP_TYPE_OBJECT); static void sp_fepointlight_class_init(SPFePointLightClass *klass) { - SPObjectClass *sp_object_class = (SPObjectClass *)klass; - fePointLight_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_fepointlight_build; sp_object_class->release = sp_fepointlight_release; sp_object_class->write = sp_fepointlight_write; @@ -98,8 +70,8 @@ sp_fepointlight_init(SPFePointLight *fepointlight) static void sp_fepointlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) fePointLight_parent_class)->build) { - ((SPObjectClass *) fePointLight_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_fepointlight_parent_class)->build) { + ((SPObjectClass *) sp_fepointlight_parent_class)->build(object, document, repr); } //Read values of key attributes from XML nodes into object. @@ -192,8 +164,8 @@ sp_fepointlight_set(SPObject *object, unsigned int key, gchar const *value) break; default: // See if any parents need this value. - if (((SPObjectClass *) fePointLight_parent_class)->set) { - ((SPObjectClass *) fePointLight_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_fepointlight_parent_class)->set) { + ((SPObjectClass *) sp_fepointlight_parent_class)->set(object, key, value); } break; } @@ -215,8 +187,8 @@ sp_fepointlight_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "z" ); } - if (((SPObjectClass *) fePointLight_parent_class)->update) { - ((SPObjectClass *) fePointLight_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_fepointlight_parent_class)->update) { + ((SPObjectClass *) sp_fepointlight_parent_class)->update(object, ctx, flags); } } @@ -239,8 +211,8 @@ sp_fepointlight_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape:: if (fepointlight->z_set) sp_repr_set_css_double(repr, "z", fepointlight->z); - if (((SPObjectClass *) fePointLight_parent_class)->write) { - ((SPObjectClass *) fePointLight_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_fepointlight_parent_class)->write) { + ((SPObjectClass *) sp_fepointlight_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/specularlighting.cpp b/src/filters/specularlighting.cpp index 71a705c94..a7a19e11d 100644 --- a/src/filters/specularlighting.cpp +++ b/src/filters/specularlighting.cpp @@ -18,10 +18,13 @@ # include "config.h" #endif +#include "strneq.h" + #include "attributes.h" #include "svg/svg.h" #include "sp-object.h" #include "svg/svg-color.h" +#include "svg/svg-icc-color.h" #include "filters/specularlighting.h" #include "filters/distantlight.h" #include "filters/pointlight.h" @@ -31,10 +34,6 @@ #include "display/nr-filter-specularlighting.h" /* FeSpecularLighting base class */ - -static void sp_feSpecularLighting_class_init(SPFeSpecularLightingClass *klass); -static void sp_feSpecularLighting_init(SPFeSpecularLighting *feSpecularLighting); - static void sp_feSpecularLighting_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feSpecularLighting_release(SPObject *object); static void sp_feSpecularLighting_set(SPObject *object, unsigned int key, gchar const *value); @@ -52,35 +51,13 @@ static Inkscape::XML::Node *sp_feSpecularLighting_write(SPObject *object, Inksca static void sp_feSpecularLighting_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); static void sp_feSpecularLighting_children_modified(SPFeSpecularLighting *sp_specularlighting); -static SPFilterPrimitiveClass *feSpecularLighting_parent_class; - -GType -sp_feSpecularLighting_get_type() -{ - static GType feSpecularLighting_type = 0; - - if (!feSpecularLighting_type) { - GTypeInfo feSpecularLighting_info = { - sizeof(SPFeSpecularLightingClass), - NULL, NULL, - (GClassInitFunc) sp_feSpecularLighting_class_init, - NULL, NULL, - sizeof(SPFeSpecularLighting), - 16, - (GInstanceInitFunc) sp_feSpecularLighting_init, - NULL, /* value_table */ - }; - feSpecularLighting_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeSpecularLighting", &feSpecularLighting_info, (GTypeFlags)0); - } - return feSpecularLighting_type; -} +G_DEFINE_TYPE(SPFeSpecularLighting, sp_feSpecularLighting, SP_TYPE_FILTER_PRIMITIVE); static void sp_feSpecularLighting_class_init(SPFeSpecularLightingClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feSpecularLighting_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); sp_object_class->build = sp_feSpecularLighting_build; sp_object_class->release = sp_feSpecularLighting_release; @@ -101,6 +78,8 @@ sp_feSpecularLighting_init(SPFeSpecularLighting *feSpecularLighting) feSpecularLighting->specularConstant = 1; feSpecularLighting->specularExponent = 1; feSpecularLighting->lighting_color = 0xffffffff; + feSpecularLighting->icc = NULL; + //TODO kernelUnit feSpecularLighting->renderer = NULL; @@ -118,8 +97,8 @@ sp_feSpecularLighting_init(SPFeSpecularLighting *feSpecularLighting) static void sp_feSpecularLighting_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feSpecularLighting_parent_class)->build) { - ((SPObjectClass *) feSpecularLighting_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feSpecularLighting_parent_class)->build) { + ((SPObjectClass *) sp_feSpecularLighting_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -137,8 +116,8 @@ sp_feSpecularLighting_build(SPObject *object, SPDocument *document, Inkscape::XM static void sp_feSpecularLighting_release(SPObject *object) { - if (((SPObjectClass *) feSpecularLighting_parent_class)->release) - ((SPObjectClass *) feSpecularLighting_parent_class)->release(object); + if (((SPObjectClass *) sp_feSpecularLighting_parent_class)->release) + ((SPObjectClass *) sp_feSpecularLighting_parent_class)->release(object); } /** @@ -228,6 +207,16 @@ sp_feSpecularLighting_set(SPObject *object, unsigned int key, gchar const *value feSpecularLighting->lighting_color = sp_svg_read_color(value, &cend_ptr, 0xffffffff); //if a value was read if (cend_ptr) { + while (g_ascii_isspace(*cend_ptr)) { + ++cend_ptr; + } + if (strneq(cend_ptr, "icc-color(", 10)) { + if (!feSpecularLighting->icc) feSpecularLighting->icc = new SVGICCColor(); + if ( ! sp_svg_read_icc_color( cend_ptr, feSpecularLighting->icc ) ) { + delete feSpecularLighting->icc; + feSpecularLighting->icc = NULL; + } + } feSpecularLighting->lighting_color_set = TRUE; } else { //lighting_color already contains the default value @@ -239,8 +228,8 @@ sp_feSpecularLighting_set(SPObject *object, unsigned int key, gchar const *value object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) feSpecularLighting_parent_class)->set) - ((SPObjectClass *) feSpecularLighting_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feSpecularLighting_parent_class)->set) + ((SPObjectClass *) sp_feSpecularLighting_parent_class)->set(object, key, value); break; } @@ -260,8 +249,8 @@ sp_feSpecularLighting_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "lighting-color" ); } - if (((SPObjectClass *) feSpecularLighting_parent_class)->update) { - ((SPObjectClass *) feSpecularLighting_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feSpecularLighting_parent_class)->update) { + ((SPObjectClass *) sp_feSpecularLighting_parent_class)->update(object, ctx, flags); } } @@ -292,8 +281,8 @@ sp_feSpecularLighting_write(SPObject *object, Inkscape::XML::Document *doc, Inks sp_svg_write_color(c, sizeof(c), fespecularlighting->lighting_color); repr->setAttribute("lighting-color", c); } - if (((SPObjectClass *) feSpecularLighting_parent_class)->write) { - ((SPObjectClass *) feSpecularLighting_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feSpecularLighting_parent_class)->write) { + ((SPObjectClass *) sp_feSpecularLighting_parent_class)->write(object, doc, repr, flags); } return repr; @@ -307,8 +296,8 @@ sp_feSpecularLighting_child_added(SPObject *object, Inkscape::XML::Node *child, { SPFeSpecularLighting *f = SP_FESPECULARLIGHTING(object); - if (((SPObjectClass *) feSpecularLighting_parent_class)->child_added) - (* ((SPObjectClass *) feSpecularLighting_parent_class)->child_added)(object, child, ref); + if (((SPObjectClass *) sp_feSpecularLighting_parent_class)->child_added) + (* ((SPObjectClass *) sp_feSpecularLighting_parent_class)->child_added)(object, child, ref); sp_feSpecularLighting_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -323,8 +312,8 @@ sp_feSpecularLighting_remove_child(SPObject *object, Inkscape::XML::Node *child) { SPFeSpecularLighting *f = SP_FESPECULARLIGHTING(object); - if (((SPObjectClass *) feSpecularLighting_parent_class)->remove_child) - (* ((SPObjectClass *) feSpecularLighting_parent_class)->remove_child)(object, child); + if (((SPObjectClass *) sp_feSpecularLighting_parent_class)->remove_child) + (* ((SPObjectClass *) sp_feSpecularLighting_parent_class)->remove_child)(object, child); sp_feSpecularLighting_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -334,8 +323,8 @@ static void sp_feSpecularLighting_order_changed (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref) { SPFeSpecularLighting *f = SP_FESPECULARLIGHTING(object); - if (((SPObjectClass *) (feSpecularLighting_parent_class))->order_changed) - (* ((SPObjectClass *) (feSpecularLighting_parent_class))->order_changed) (object, child, old_ref, new_ref); + if (((SPObjectClass *) (sp_feSpecularLighting_parent_class))->order_changed) + (* ((SPObjectClass *) (sp_feSpecularLighting_parent_class))->order_changed) (object, child, old_ref, new_ref); sp_feSpecularLighting_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -378,6 +367,8 @@ static void sp_feSpecularLighting_build_renderer(SPFilterPrimitive *primitive, I nr_specularlighting->specularExponent = sp_specularlighting->specularExponent; nr_specularlighting->surfaceScale = sp_specularlighting->surfaceScale; nr_specularlighting->lighting_color = sp_specularlighting->lighting_color; + nr_specularlighting->set_icc(sp_specularlighting->icc); + //We assume there is at most one child nr_specularlighting->light_type = Inkscape::Filters::NO_LIGHT; if (SP_IS_FEDISTANTLIGHT(primitive->children)) { diff --git a/src/filters/specularlighting.h b/src/filters/specularlighting.h index 90d1f9f62..44bd98c6c 100644 --- a/src/filters/specularlighting.h +++ b/src/filters/specularlighting.h @@ -23,6 +23,8 @@ #define SP_IS_FESPECULARLIGHTING(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FESPECULARLIGHTING)) #define SP_IS_FESPECULARLIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FESPECULARLIGHTING)) +class SVGICCColor; + namespace Inkscape { namespace Filters { class FilterSpecularLighting; @@ -41,6 +43,7 @@ struct SPFeSpecularLighting : public SPFilterPrimitive { NumberOptNumber kernelUnitLength; guint32 lighting_color; guint lighting_color_set : 1; + SVGICCColor *icc; Inkscape::Filters::FilterSpecularLighting *renderer; }; diff --git a/src/filters/spotlight.cpp b/src/filters/spotlight.cpp index 7be83ed00..181e39990 100644 --- a/src/filters/spotlight.cpp +++ b/src/filters/spotlight.cpp @@ -30,47 +30,19 @@ #include "macros.h" /* FeSpotLight class */ - -static void sp_fespotlight_class_init(SPFeSpotLightClass *klass); -static void sp_fespotlight_init(SPFeSpotLight *fespotlight); - static void sp_fespotlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_fespotlight_release(SPObject *object); static void sp_fespotlight_set(SPObject *object, unsigned int key, gchar const *value); static void sp_fespotlight_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_fespotlight_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPObjectClass *feSpotLight_parent_class; - -GType -sp_fespotlight_get_type() -{ - static GType fespotlight_type = 0; - - if (!fespotlight_type) { - GTypeInfo fespotlight_info = { - sizeof(SPFeSpotLightClass), - NULL, NULL, - (GClassInitFunc) sp_fespotlight_class_init, - NULL, NULL, - sizeof(SPFeSpotLight), - 16, - (GInstanceInitFunc) sp_fespotlight_init, - NULL, /* value_table */ - }; - fespotlight_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeSpotLight", &fespotlight_info, (GTypeFlags)0); - } - return fespotlight_type; -} +G_DEFINE_TYPE(SPFeSpotLight, sp_fespotlight, SP_TYPE_OBJECT); static void sp_fespotlight_class_init(SPFeSpotLightClass *klass) { - SPObjectClass *sp_object_class = (SPObjectClass *)klass; - feSpotLight_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_fespotlight_build; sp_object_class->release = sp_fespotlight_release; sp_object_class->write = sp_fespotlight_write; @@ -108,8 +80,8 @@ sp_fespotlight_init(SPFeSpotLight *fespotlight) static void sp_fespotlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feSpotLight_parent_class)->build) { - ((SPObjectClass *) feSpotLight_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_fespotlight_parent_class)->build) { + ((SPObjectClass *) sp_fespotlight_parent_class)->build(object, document, repr); } //Read values of key attributes from XML nodes into object. @@ -290,8 +262,8 @@ sp_fespotlight_set(SPObject *object, unsigned int key, gchar const *value) break; default: // See if any parents need this value. - if (((SPObjectClass *) feSpotLight_parent_class)->set) { - ((SPObjectClass *) feSpotLight_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_fespotlight_parent_class)->set) { + ((SPObjectClass *) sp_fespotlight_parent_class)->set(object, key, value); } break; } @@ -318,8 +290,8 @@ sp_fespotlight_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "limitingConeAngle" ); } - if (((SPObjectClass *) feSpotLight_parent_class)->update) { - ((SPObjectClass *) feSpotLight_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_fespotlight_parent_class)->update) { + ((SPObjectClass *) sp_fespotlight_parent_class)->update(object, ctx, flags); } } @@ -352,8 +324,8 @@ sp_fespotlight_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::X if (fespotlight->limitingConeAngle_set) sp_repr_set_css_double(repr, "limitingConeAngle", fespotlight->limitingConeAngle); - if (((SPObjectClass *) feSpotLight_parent_class)->write) { - ((SPObjectClass *) feSpotLight_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_fespotlight_parent_class)->write) { + ((SPObjectClass *) sp_fespotlight_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/tile.cpp b/src/filters/tile.cpp index 42a59ede8..d2725f50c 100644 --- a/src/filters/tile.cpp +++ b/src/filters/tile.cpp @@ -23,10 +23,6 @@ #include "display/nr-filter-tile.h" /* FeTile base class */ - -static void sp_feTile_class_init(SPFeTileClass *klass); -static void sp_feTile_init(SPFeTile *feTile); - static void sp_feTile_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feTile_release(SPObject *object); static void sp_feTile_set(SPObject *object, unsigned int key, gchar const *value); @@ -34,28 +30,7 @@ static void sp_feTile_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feTile_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_feTile_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *feTile_parent_class; - -GType -sp_feTile_get_type() -{ - static GType feTile_type = 0; - - if (!feTile_type) { - GTypeInfo feTile_info = { - sizeof(SPFeTileClass), - NULL, NULL, - (GClassInitFunc) sp_feTile_class_init, - NULL, NULL, - sizeof(SPFeTile), - 16, - (GInstanceInitFunc) sp_feTile_init, - NULL, /* value_table */ - }; - feTile_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeTile", &feTile_info, (GTypeFlags)0); - } - return feTile_type; -} +G_DEFINE_TYPE(SPFeTile, sp_feTile, SP_TYPE_FILTER_PRIMITIVE); static void sp_feTile_class_init(SPFeTileClass *klass) @@ -63,8 +38,6 @@ sp_feTile_class_init(SPFeTileClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feTile_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feTile_build; sp_object_class->release = sp_feTile_release; sp_object_class->write = sp_feTile_write; @@ -86,8 +59,8 @@ sp_feTile_init(SPFeTile */*feTile*/) static void sp_feTile_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feTile_parent_class)->build) { - ((SPObjectClass *) feTile_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feTile_parent_class)->build) { + ((SPObjectClass *) sp_feTile_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -99,8 +72,8 @@ sp_feTile_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep static void sp_feTile_release(SPObject *object) { - if (((SPObjectClass *) feTile_parent_class)->release) - ((SPObjectClass *) feTile_parent_class)->release(object); + if (((SPObjectClass *) sp_feTile_parent_class)->release) + ((SPObjectClass *) sp_feTile_parent_class)->release(object); } /** @@ -115,8 +88,8 @@ sp_feTile_set(SPObject *object, unsigned int key, gchar const *value) switch(key) { /*DEAL WITH SETTING ATTRIBUTES HERE*/ default: - if (((SPObjectClass *) feTile_parent_class)->set) - ((SPObjectClass *) feTile_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feTile_parent_class)->set) + ((SPObjectClass *) sp_feTile_parent_class)->set(object, key, value); break; } @@ -135,8 +108,8 @@ sp_feTile_update(SPObject *object, SPCtx *ctx, guint flags) } - if (((SPObjectClass *) feTile_parent_class)->update) { - ((SPObjectClass *) feTile_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feTile_parent_class)->update) { + ((SPObjectClass *) sp_feTile_parent_class)->update(object, ctx, flags); } } @@ -152,8 +125,8 @@ sp_feTile_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::N repr = object->getRepr()->duplicate(doc); } - if (((SPObjectClass *) feTile_parent_class)->write) { - ((SPObjectClass *) feTile_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feTile_parent_class)->write) { + ((SPObjectClass *) sp_feTile_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/turbulence.cpp b/src/filters/turbulence.cpp index 9d1448c70..c4d4ca4ae 100644 --- a/src/filters/turbulence.cpp +++ b/src/filters/turbulence.cpp @@ -29,10 +29,6 @@ #include "display/nr-filter-turbulence.h" /* FeTurbulence base class */ - -static void sp_feTurbulence_class_init(SPFeTurbulenceClass *klass); -static void sp_feTurbulence_init(SPFeTurbulence *feTurbulence); - static void sp_feTurbulence_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feTurbulence_release(SPObject *object); static void sp_feTurbulence_set(SPObject *object, unsigned int key, gchar const *value); @@ -40,28 +36,7 @@ static void sp_feTurbulence_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feTurbulence_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_feTurbulence_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *feTurbulence_parent_class; - -GType -sp_feTurbulence_get_type() -{ - static GType feTurbulence_type = 0; - - if (!feTurbulence_type) { - GTypeInfo feTurbulence_info = { - sizeof(SPFeTurbulenceClass), - NULL, NULL, - (GClassInitFunc) sp_feTurbulence_class_init, - NULL, NULL, - sizeof(SPFeTurbulence), - 16, - (GInstanceInitFunc) sp_feTurbulence_init, - NULL, /* value_table */ - }; - feTurbulence_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeTurbulence", &feTurbulence_info, (GTypeFlags)0); - } - return feTurbulence_type; -} +G_DEFINE_TYPE(SPFeTurbulence, sp_feTurbulence, SP_TYPE_FILTER_PRIMITIVE); static void sp_feTurbulence_class_init(SPFeTurbulenceClass *klass) @@ -69,8 +44,6 @@ sp_feTurbulence_class_init(SPFeTurbulenceClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass * sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feTurbulence_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feTurbulence_build; sp_object_class->release = sp_feTurbulence_release; sp_object_class->write = sp_feTurbulence_write; @@ -94,8 +67,8 @@ sp_feTurbulence_init(SPFeTurbulence *feTurbulence) static void sp_feTurbulence_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feTurbulence_parent_class)->build) { - ((SPObjectClass *) feTurbulence_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feTurbulence_parent_class)->build) { + ((SPObjectClass *) sp_feTurbulence_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -112,8 +85,8 @@ sp_feTurbulence_build(SPObject *object, SPDocument *document, Inkscape::XML::Nod static void sp_feTurbulence_release(SPObject *object) { - if (((SPObjectClass *) feTurbulence_parent_class)->release) - ((SPObjectClass *) feTurbulence_parent_class)->release(object); + if (((SPObjectClass *) sp_feTurbulence_parent_class)->release) + ((SPObjectClass *) sp_feTurbulence_parent_class)->release(object); } static bool sp_feTurbulence_read_stitchTiles(gchar const *value){ @@ -200,8 +173,8 @@ sp_feTurbulence_set(SPObject *object, unsigned int key, gchar const *value) } break; default: - if (((SPObjectClass *) feTurbulence_parent_class)->set) - ((SPObjectClass *) feTurbulence_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feTurbulence_parent_class)->set) + ((SPObjectClass *) sp_feTurbulence_parent_class)->set(object, key, value); break; } @@ -220,8 +193,8 @@ sp_feTurbulence_update(SPObject *object, SPCtx *ctx, guint flags) } - if (((SPObjectClass *) feTurbulence_parent_class)->update) { - ((SPObjectClass *) feTurbulence_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feTurbulence_parent_class)->update) { + ((SPObjectClass *) sp_feTurbulence_parent_class)->update(object, ctx, flags); } } @@ -237,8 +210,8 @@ sp_feTurbulence_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape:: repr = object->getRepr()->duplicate(doc); } - if (((SPObjectClass *) feTurbulence_parent_class)->write) { - ((SPObjectClass *) feTurbulence_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feTurbulence_parent_class)->write) { + ((SPObjectClass *) sp_feTurbulence_parent_class)->write(object, doc, repr, flags); } /* turbulence doesn't take input */ diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index 231490771..8fd002d70 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -51,8 +51,6 @@ using Inkscape::DocumentUndo; -static void sp_gradient_context_class_init(SPGradientContextClass *klass); -static void sp_gradient_context_init(SPGradientContext *gr_context); static void sp_gradient_context_dispose(GObject *object); static void sp_gradient_context_setup(SPEventContext *ec); @@ -61,35 +59,13 @@ static gint sp_gradient_context_root_handler(SPEventContext *event_context, GdkE static void sp_gradient_drag(SPGradientContext &rc, Geom::Point const pt, guint state, guint32 etime); -static SPEventContextClass *parent_class; - - -GType sp_gradient_context_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPGradientContextClass), - NULL, NULL, - (GClassInitFunc) sp_gradient_context_class_init, - NULL, NULL, - sizeof(SPGradientContext), - 4, - (GInstanceInitFunc) sp_gradient_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPGradientContext", &info, (GTypeFlags) 0); - } - return type; -} +G_DEFINE_TYPE(SPGradientContext, sp_gradient_context, SP_TYPE_EVENT_CONTEXT); static void sp_gradient_context_class_init(SPGradientContextClass *klass) { GObjectClass *object_class = (GObjectClass *) klass; SPEventContextClass *event_context_class = (SPEventContextClass *) klass; - parent_class = (SPEventContextClass *) g_type_class_peek_parent(klass); - object_class->dispose = sp_gradient_context_dispose; event_context_class->setup = sp_gradient_context_setup; @@ -127,7 +103,7 @@ static void sp_gradient_context_dispose(GObject *object) rc->subselcon->disconnect(); delete rc->subselcon; - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_gradient_context_parent_class)->dispose(object); } const gchar *gr_handle_descr [] = { @@ -204,8 +180,8 @@ static void sp_gradient_context_setup(SPEventContext *ec) { SPGradientContext *rc = SP_GRADIENT_CONTEXT(ec); - if (((SPEventContextClass *) parent_class)->setup) { - ((SPEventContextClass *) parent_class)->setup(ec); + if (((SPEventContextClass *) sp_gradient_context_parent_class)->setup) { + ((SPEventContextClass *) sp_gradient_context_parent_class)->setup(ec); } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -879,8 +855,8 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) } if (!ret) { - if (((SPEventContextClass *) parent_class)->root_handler) { - ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event); + if (((SPEventContextClass *) sp_gradient_context_parent_class)->root_handler) { + ret = ((SPEventContextClass *) sp_gradient_context_parent_class)->root_handler(event_context, event); } } diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 904c3b349..65b26937b 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -34,6 +34,7 @@ #include "display/sp-ctrlcurve.h" #include "display/sp-canvas-util.h" #include "xml/repr.h" +#include "xml/sp-css-attr.h" #include "svg/css-ostringstream.h" #include "svg/svg.h" #include "preferences.h" diff --git a/src/helper/action.cpp b/src/helper/action.cpp index 4fafa191e..0e9957ca3 100644 --- a/src/helper/action.cpp +++ b/src/helper/action.cpp @@ -19,34 +19,9 @@ #include "document.h" #include "helper/action.h" -static void sp_action_class_init (SPActionClass *klass); -static void sp_action_init (SPAction *action); static void sp_action_finalize (GObject *object); -static GObjectClass *parent_class; - -/** - * Register SPAction class and return its type. - */ -GType -sp_action_get_type (void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPActionClass), - NULL, NULL, - (GClassInitFunc) sp_action_class_init, - NULL, NULL, - sizeof(SPAction), - 0, - (GInstanceInitFunc) sp_action_init, - NULL - }; - type = g_type_register_static(G_TYPE_OBJECT, "SPAction", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPAction, sp_action, G_TYPE_OBJECT); /** * SPAction vtable initialization. @@ -54,8 +29,6 @@ sp_action_get_type (void) static void sp_action_class_init (SPActionClass *klass) { - parent_class = (GObjectClass*) g_type_class_ref(G_TYPE_OBJECT); - GObjectClass *object_class = (GObjectClass *) klass; object_class->finalize = sp_action_finalize; } @@ -84,19 +57,19 @@ sp_action_init (SPAction *action) static void sp_action_finalize (GObject *object) { - SPAction *action = SP_ACTION(object); + SPAction *action = SP_ACTION(object); - g_free (action->image); - g_free (action->tip); - g_free (action->name); - g_free (action->id); + g_free (action->image); + g_free (action->tip); + g_free (action->name); + g_free (action->id); action->signal_perform.~signal(); action->signal_set_sensitive.~signal(); action->signal_set_active.~signal(); action->signal_set_name.~signal(); - parent_class->finalize (object); + G_OBJECT_CLASS(sp_action_parent_class)->finalize (object); } /** diff --git a/src/helper/unit-menu.cpp b/src/helper/unit-menu.cpp index bb2254a1b..af07c03c1 100644 --- a/src/helper/unit-menu.cpp +++ b/src/helper/unit-menu.cpp @@ -52,39 +52,16 @@ struct SPUnitSelectorClass { enum {SET_UNIT, LAST_SIGNAL}; -static void sp_unit_selector_class_init(SPUnitSelectorClass *klass); -static void sp_unit_selector_init(SPUnitSelector *selector); static void sp_unit_selector_finalize(GObject *object); -static GtkHBoxClass *unit_selector_parent_class; static guint signals[LAST_SIGNAL] = {0}; -GType sp_unit_selector_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPUnitSelectorClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_unit_selector_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPUnitSelector), - 0, // n_preallocs - (GInstanceInitFunc)sp_unit_selector_init, - 0 // value_table - }; - type = g_type_register_static(GTK_TYPE_HBOX, "SPUnitSelector", &info, static_cast<GTypeFlags>(0)); - } - return type; -} +G_DEFINE_TYPE(SPUnitSelector, sp_unit_selector, GTK_TYPE_HBOX); static void sp_unit_selector_class_init(SPUnitSelectorClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); - unit_selector_parent_class = GTK_HBOX_CLASS(g_type_class_peek_parent(klass)); signals[SET_UNIT] = g_signal_new("set_unit", G_TYPE_FROM_CLASS(klass), @@ -142,7 +119,7 @@ sp_unit_selector_finalize(GObject *object) selector->unit = NULL; - G_OBJECT_CLASS(unit_selector_parent_class)->finalize(object); + G_OBJECT_CLASS(sp_unit_selector_parent_class)->finalize(object); } GtkWidget * diff --git a/src/ink-comboboxentry-action.cpp b/src/ink-comboboxentry-action.cpp index d9b1b0965..fd146926f 100644 --- a/src/ink-comboboxentry-action.cpp +++ b/src/ink-comboboxentry-action.cpp @@ -25,6 +25,7 @@ #include <iostream> #include <string.h> +#include <glibmm/ustring.h> #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> @@ -36,8 +37,8 @@ static GtkWidget* create_tool_item( GtkAction* action ); static GtkWidget* create_menu_item( GtkAction* action ); // Internal -static gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, const gchar* target_text ); -static gint check_comma_separated_text( Ink_ComboBoxEntry_Action* action ); +static gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, const gchar* target_text, gboolean exclude = false ); +static Glib::ustring check_comma_separated_text( Ink_ComboBoxEntry_Action* action ); // Callbacks static void combo_box_changed_cb( GtkComboBox* widget, gpointer data ); @@ -52,6 +53,7 @@ enum { PROP_ENTRY_WIDTH, PROP_EXTRA_WIDTH, PROP_CELL_DATA_FUNC, + PROP_SEPARATOR_FUNC, PROP_POPUP, PROP_FOCUS_WIDGET }; @@ -63,9 +65,13 @@ enum { }; static guint signals[N_SIGNALS] = {0}; -static GtkActionClass *ink_comboboxentry_action_parent_class = NULL; static GQuark gDataName = 0; +static void ink_comboboxentry_action_init (Ink_ComboBoxEntry_Action *action); +static void ink_comboboxentry_action_class_init (Ink_ComboBoxEntry_ActionClass *klass); + +G_DEFINE_TYPE(Ink_ComboBoxEntry_Action, ink_comboboxentry_action, GTK_TYPE_ACTION); + static void ink_comboboxentry_action_finalize (GObject *object) { // Free any allocated resources. @@ -104,6 +110,10 @@ static void ink_comboboxentry_action_set_property (GObject *object, guint proper action->cell_data_func = g_value_get_pointer( value ); break; + case PROP_SEPARATOR_FUNC: + action->separator_func = g_value_get_pointer( value ); + break; + case PROP_POPUP: action->popup = g_value_get_boolean( value ); break; @@ -149,6 +159,10 @@ static void ink_comboboxentry_action_get_property (GObject *object, guint proper g_value_set_pointer (value, action->cell_data_func); break; + case PROP_SEPARATOR_FUNC: + g_value_set_pointer (value, action->separator_func); + break; + case PROP_POPUP: g_value_set_boolean (value, action->popup); break; @@ -174,8 +188,8 @@ ink_comboboxentry_action_connect_proxy (GtkAction *action, GTK_ACTION_CLASS (ink_comboboxentry_action_parent_class)->connect_proxy (action, proxy); } - -static void ink_comboboxentry_action_class_init (Ink_ComboBoxEntry_ActionClass *klass) +static void +ink_comboboxentry_action_class_init (Ink_ComboBoxEntry_ActionClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); @@ -192,8 +206,6 @@ static void ink_comboboxentry_action_class_init (Ink_ComboBoxEntry_ActionClass * klass->parent_class.create_tool_item = create_tool_item; klass->parent_class.create_menu_item = create_menu_item; - ink_comboboxentry_action_parent_class = GTK_ACTION_CLASS(g_type_class_peek_parent (klass) ); - g_object_class_install_property ( gobject_class, PROP_MODEL, @@ -246,6 +258,14 @@ static void ink_comboboxentry_action_class_init (Ink_ComboBoxEntry_ActionClass * g_object_class_install_property ( gobject_class, + PROP_SEPARATOR_FUNC, + g_param_spec_pointer ("separator_func", + "Separator Func", + "Separator Function", + (GParamFlags)G_PARAM_READWRITE)); + + g_object_class_install_property ( + gobject_class, PROP_POPUP, g_param_spec_boolean ("popup", "Entry Popup", @@ -292,34 +312,6 @@ static void ink_comboboxentry_action_init (Ink_ComboBoxEntry_Action *action) action->focusWidget = NULL; } -GType ink_comboboxentry_action_get_type () -{ - static GType ink_comboboxentry_action_type = 0; - - if (!ink_comboboxentry_action_type) { - static const GTypeInfo ink_comboboxentry_action_info = { - sizeof(Ink_ComboBoxEntry_ActionClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) ink_comboboxentry_action_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(Ink_ComboBoxEntry_Action), - 0, /* n_preallocs */ - (GInstanceInitFunc)ink_comboboxentry_action_init, /* instance_init */ - NULL /* value_table */ - }; - - ink_comboboxentry_action_type = g_type_register_static (GTK_TYPE_ACTION, - "Ink_ComboBoxEntry_Action", - &ink_comboboxentry_action_info, - (GTypeFlags)0 ); - } - - return ink_comboboxentry_action_type; -} - - Ink_ComboBoxEntry_Action *ink_comboboxentry_action_new (const gchar *name, const gchar *label, const gchar *tooltip, @@ -328,6 +320,7 @@ Ink_ComboBoxEntry_Action *ink_comboboxentry_action_new (const gchar *name, gint entry_width, gint extra_width, void *cell_data_func, + void *separator_func, GtkWidget *focusWidget) { g_return_val_if_fail (name != NULL, NULL); @@ -341,6 +334,7 @@ Ink_ComboBoxEntry_Action *ink_comboboxentry_action_new (const gchar *name, "entry_width", entry_width, "extra_width", extra_width, "cell_data_func", cell_data_func, + "separator_func", separator_func, "focus-widget", focusWidget, NULL); } @@ -390,6 +384,13 @@ GtkWidget* create_tool_item( GtkAction* action ) NULL, NULL ); } + // Optionally add separator function... + if( ink_comboboxentry_action->separator_func != NULL ) { + gtk_combo_box_set_row_separator_func( ink_comboboxentry_action->combobox, + GtkTreeViewRowSeparatorFunc (ink_comboboxentry_action->separator_func), + NULL, NULL ); + } + // Optionally widen the combobox width... which widens the drop-down list in list mode. if( ink_comboboxentry_action->extra_width > 0 ) { GtkRequisition req; @@ -439,7 +440,7 @@ GtkWidget* create_tool_item( GtkAction* action ) } else { - item = ink_comboboxentry_action_parent_class->create_tool_item( action ); + item = GTK_ACTION_CLASS(ink_comboboxentry_action_parent_class)->create_tool_item( action ); } @@ -451,7 +452,7 @@ GtkWidget* create_menu_item( GtkAction* action ) { GtkWidget* item = 0; - item = ink_comboboxentry_action_parent_class->create_menu_item( action ); + item = GTK_ACTION_CLASS(ink_comboboxentry_action_parent_class)->create_menu_item( action ); g_warning( "ink_comboboxentry_action: create_menu_item not implemented" ); // One can easily modify ege-select-one-action routine to implement this. return item; @@ -494,11 +495,13 @@ gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* ink // Explicitly set text in GtkEntry box (won't be set if text not in list). gtk_entry_set_text( ink_comboboxentry_action->entry, text ); - // Show or hide warning - if( ink_comboboxentry_action->active == -1 && - ink_comboboxentry_action->warning != NULL && - check_comma_separated_text( ink_comboboxentry_action ) ) { - { + // Show or hide warning -- this might be better moved to text-toolbox.cpp + bool clear = true; + + if( ink_comboboxentry_action->warning != NULL ) { + Glib::ustring missing = check_comma_separated_text( ink_comboboxentry_action ); + if( !missing.empty() ) { + GtkStockItem item; gboolean isStock = gtk_stock_lookup( GTK_STOCK_DIALOG_WARNING, &item ); if (isStock) { @@ -510,15 +513,21 @@ gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* ink GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_DIALOG_WARNING ); } + // Can't add tooltip until icon set + Glib::ustring warning = ink_comboboxentry_action->warning; + warning += ": "; + warning += missing; + gtk_entry_set_icon_tooltip_text( ink_comboboxentry_action->entry, + GTK_ENTRY_ICON_SECONDARY, + warning.c_str() ); + clear = false; } - // Can't add tooltip until icon set - gtk_entry_set_icon_tooltip_text( ink_comboboxentry_action->entry, - GTK_ENTRY_ICON_SECONDARY, - ink_comboboxentry_action->warning ); - } else { + } + + if( clear ) { gtk_entry_set_icon_from_icon_name( GTK_ENTRY(ink_comboboxentry_action->entry), - GTK_ENTRY_ICON_SECONDARY, - NULL ); + GTK_ENTRY_ICON_SECONDARY, + NULL ); gtk_entry_set_icon_from_stock( GTK_ENTRY(ink_comboboxentry_action->entry), GTK_ENTRY_ICON_SECONDARY, NULL ); @@ -628,8 +637,11 @@ void ink_comboboxentry_action_set_altx_name( Ink_ComboBoxEntry_Action* actio // Internal --------------------------------------------------- -// Return row of active text or -1 if not found. -gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, const gchar* target_text ) { +// Return row of active text or -1 if not found. If exclude is true, +// use 3d colunm if available to exclude row from checking (useful to +// skip rows added for font-families included in doc and not on +// system) +gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, const gchar* target_text, gboolean exclude ) { // Check if text in list gint row = 0; @@ -638,15 +650,24 @@ gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, const gchar* ta gboolean valid = gtk_tree_model_get_iter_first( action->model, &iter ); while ( valid ) { - // Get text from list entry - gchar* text = 0; - gtk_tree_model_get( action->model, &iter, 0, &text, -1 ); // Column 0 + // See if we should exclude a row + gboolean check = true; // If true, font-family is on system. + if( exclude && gtk_tree_model_get_n_columns( action->model ) > 2 ) { + gtk_tree_model_get( action->model, &iter, 2, &check, -1 ); + } + + if( check ) { + // Get text from list entry + gchar* text = 0; + gtk_tree_model_get( action->model, &iter, 0, &text, -1 ); // Column 0 - // Check for match - if( strcmp( target_text, text ) == 0 ){ - found = true; - break; + // Check for match + if( strcmp( target_text, text ) == 0 ){ + found = true; + break; + } } + ++row; valid = gtk_tree_model_iter_next( action->model, &iter ); } @@ -657,18 +678,21 @@ gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, const gchar* ta } -// Checks if all comma separated text fragments are in the list. +// Checks if all comma separated text fragments are in the list and +// returns a ustring with a list of missing fragments. // This is useful for checking if all fonts in a font-family fallback // list are available on the system. -// The return value is set to the number of missing text fragments. +// // This routine could also create a Pango Markup string to show which -// fragments are invalid. -// It is envisioned that one can construct a Pango Markup String here -// so that individual text fragments can be flagged as not being in the -// list. -static gint check_comma_separated_text( Ink_ComboBoxEntry_Action* action ) { +// fragments are invalid in the entry box itself. See: +// http://developer.gnome.org/pango/stable/PangoMarkupFormat.html +// However... it appears that while one can retrieve the PangoLayout +// for a GtkEntry box, it is only a copy and changing it has no effect. +// PangoLayout * pl = gtk_entry_get_layout( entry ); +// pango_layout_set_markup( pl, "NEW STRING", -1 ); // DOESN'T WORK +static Glib::ustring check_comma_separated_text( Ink_ComboBoxEntry_Action* action ) { - gint ret_val = 0; + Glib::ustring missing; // Parse fallback_list using a comma as deliminator gchar** tokens = g_strsplit( action->text, ",", 0 ); @@ -679,22 +703,19 @@ static gint check_comma_separated_text( Ink_ComboBoxEntry_Action* action ) { // Remove any surrounding white space. g_strstrip( tokens[i] ); - if( get_active_row_from_text( action, tokens[i] ) == -1 ) { - ret_val += 1; + if( get_active_row_from_text( action, tokens[i], true ) == -1 ) { + missing += tokens[i]; + missing += ", "; } ++i; } g_strfreev( tokens ); - // Pango Markup notes: - // GString* Pango_Markup = g_string_new(""); - // if not present: - // g_string_sprintfa( Pango_Markup, "<span strikethrough=\"true\" strikethrough_color=\"#880000\">%s</span>", tokens[i] ); - // PangoLayout * pl = gtk_entry_get_layout( entry ); - // pango_layout_set_markup( pl, Pango_Markup->str, -1 ); - // g_string_free( Pango_Markup, TRUE ); - - return ret_val; + // Remove extra comma and space from end. + if( missing.size() >= 2 ) { + missing.resize( missing.size()-2 ); + } + return missing; } // Callbacks --------------------------------------------------- diff --git a/src/ink-comboboxentry-action.h b/src/ink-comboboxentry-action.h index 7d4093f4e..f0dc0ee7e 100644 --- a/src/ink-comboboxentry-action.h +++ b/src/ink-comboboxentry-action.h @@ -51,6 +51,7 @@ struct _Ink_ComboBoxEntry_Action { GtkWidget *indicator; gpointer cell_data_func; // drop-down menu format + gpointer separator_func; gint active; // Index of active menu item (-1 if not in list). gchar *text; // Text of active menu item or entry box. @@ -76,6 +77,7 @@ Ink_ComboBoxEntry_Action *ink_comboboxentry_action_new ( const gchar *name, gint entry_width = -1, gint extra_width = -1, gpointer cell_data_func = NULL, + gpointer separator_func = NULL, GtkWidget* focusWidget = NULL); GtkTreeModel *ink_comboboxentry_action_get_model( Ink_ComboBoxEntry_Action* action ); diff --git a/src/io/base64stream.cpp b/src/io/base64stream.cpp index 0a28a8cc3..667487c35 100644 --- a/src/io/base64stream.cpp +++ b/src/io/base64stream.cpp @@ -5,18 +5,35 @@ * of Base64 data with a stream interface, hiding * the implementation from the user. * + * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html + * * Authors: - * Bob Jamison <rjamison@titan.com> + + * Bob Jamison + * + * Copyright (C) 2006 Bob Jamison * - * Copyright (C) 2004 Inkscape.org + + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * Released under GNU GPL, read the file 'COPYING' for more information + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "base64stream.h" + namespace Inkscape { namespace IO diff --git a/src/io/gzipstream.cpp b/src/io/gzipstream.cpp index cbe29a41e..f9e30de91 100644 --- a/src/io/gzipstream.cpp +++ b/src/io/gzipstream.cpp @@ -8,13 +8,27 @@ * Authors: * Bob Jamison <rjamison@titan.com> * - * Copyright (C) 2004 Inkscape.org + * Copyright (C) 2004 * - * Released under GNU GPL, read the file 'COPYING' for more information + + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "gzipstream.h" #include <cstdio> +#include <cstdlib> #include <cstring> #include <string> diff --git a/src/io/gzipstream.h b/src/io/gzipstream.h index 4debbfca9..89c5f64f3 100644 --- a/src/io/gzipstream.h +++ b/src/io/gzipstream.h @@ -17,7 +17,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ - +#include <vector> #include "inkscapestream.h" #include <zlib.h> diff --git a/src/io/inkscapestream.cpp b/src/io/inkscapestream.cpp index da7870add..65f24cf59 100644 --- a/src/io/inkscapestream.cpp +++ b/src/io/inkscapestream.cpp @@ -11,7 +11,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ - +#include <cstdlib> #include "inkscapestream.h" namespace Inkscape diff --git a/src/io/inkscapestream.h b/src/io/inkscapestream.h index a766e16e0..37c41552f 100644 --- a/src/io/inkscapestream.h +++ b/src/io/inkscapestream.h @@ -9,9 +9,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ - #include <cstdio> -#include <glibmm.h> +#include <glibmm/ustring.h> namespace Inkscape { diff --git a/src/io/sys.cpp b/src/io/sys.cpp index 26c1993a7..60e850c96 100644 --- a/src/io/sys.cpp +++ b/src/io/sys.cpp @@ -15,6 +15,7 @@ # include "config.h" #endif +#include <fstream> #include <glib.h> #include <glib/gstdio.h> #include <glibmm/fileutils.h> diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 98904a47a..a9220d867 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -28,7 +28,7 @@ typedef INK_UNORDERED_MAP<PangoFontDescription*, font_instance*, font_descr_hash size_t font_descr_hash::operator()( PangoFontDescription *const &x) const { int h = 0; h *= 1128467; - char const *theF = pango_font_description_get_family(x); + char const *theF = sp_font_description_get_family(x); h += (theF)?g_str_hash(theF):0; h *= 1128467; h += (int)pango_font_description_get_style(x); @@ -42,8 +42,8 @@ size_t font_descr_hash::operator()( PangoFontDescription *const &x) const { } bool font_descr_equal::operator()( PangoFontDescription *const&a, PangoFontDescription *const &b) const { //if ( pango_font_description_equal(a,b) ) return true; - char const *fa = pango_font_description_get_family(a); - char const *fb = pango_font_description_get_family(b); + char const *fa = sp_font_description_get_family(a); + char const *fb = sp_font_description_get_family(b); if ( ( fa && fb == NULL ) || ( fb && fa == NULL ) ) return false; if ( fa && fb && strcmp(fa,fb) != 0 ) return false; if ( pango_font_description_get_style(a) != pango_font_description_get_style(b) ) return false; @@ -395,6 +395,33 @@ Glib::ustring font_factory::ConstructFontSpecification(font_instance *font) return pangoString; } +/* + * Wrap calls to pango_font_description_get_family + * and replace some of the pango font names with generic css names + * http://www.w3.org/TR/2008/REC-CSS2-20080411/fonts.html#generic-font-families + * + * This function should be called in place of pango_font_description_get_family() + */ +const char *sp_font_description_get_family(PangoFontDescription const *fontDescr) { + + static std::map<Glib::ustring, Glib::ustring> fontNameMap; + std::map<Glib::ustring, Glib::ustring>::iterator it; + + if (fontNameMap.empty()) { + fontNameMap.insert(std::make_pair("Sans", "sans-serif")); + fontNameMap.insert(std::make_pair("Serif", "serif")); + fontNameMap.insert(std::make_pair("Monospace", "monospace")); + } + + const char *pangoFamily = pango_font_description_get_family(fontDescr); + + if (pangoFamily && ((it = fontNameMap.find(pangoFamily)) != fontNameMap.end())) { + return ((Glib::ustring)it->second).c_str(); + } + + return pangoFamily; +} + Glib::ustring font_factory::GetUIFamilyString(PangoFontDescription const *fontDescr) { Glib::ustring family; @@ -403,7 +430,8 @@ Glib::ustring font_factory::GetUIFamilyString(PangoFontDescription const *fontDe if (fontDescr) { // For now, keep it as family name taken from pango - const char *pangoFamily = pango_font_description_get_family(fontDescr); + const char *pangoFamily = sp_font_description_get_family(fontDescr); + if( pangoFamily ) { family = pangoFamily; } @@ -454,7 +482,7 @@ Glib::ustring font_factory::ReplaceFontSpecificationFamily(const Glib::ustring & // what constitutes a "family" in our own UI may be different from how Pango // sees it. - // Find the PangoFontDescription associated with the font specification string. + // Find the PangoFontDescription associated with the old font specification string. PangoStringToDescrMap::iterator it = fontInstanceMap.find(fontSpec); @@ -464,15 +492,23 @@ Glib::ustring font_factory::ReplaceFontSpecificationFamily(const Glib::ustring & // Make copy PangoFontDescription *descr = pango_font_description_copy((*it).second); - // Grab the UI Family string from the descr + // Grab the old UI Family string from the descr Glib::ustring uiFamily = GetUIFamilyString(descr); // Replace the UI Family name with the new family name std::size_t found = fontSpec.find(uiFamily); if (found != Glib::ustring::npos) { + + // Add comma to end of newFamily... commas at end don't hurt but are + // required if the last part of a family name is a valid font style + // (e.g. "Arial Black"). + Glib::ustring newFamilyComma = newFamily; + if( *newFamilyComma.rbegin() != ',' ) { + newFamilyComma += ","; + } newFontSpec = fontSpec; newFontSpec.erase(found, uiFamily.size()); - newFontSpec.insert(found, newFamily); + newFontSpec.insert(found, newFamilyComma); // If the new font specification does not exist in the reference maps, // search for the next best match for the faces in that style @@ -711,11 +747,13 @@ void font_factory::GetUIFamiliesAndStyles(FamilyToStylesMap *map) Glib::ustring styleUIName = GetUIStyleString(faceDescr); if (!familyUIName.empty() && !styleUIName.empty()) { + // Find the right place to put the style information, adding // a map entry for the family name if it doesn't yet exist FamilyToStylesMap::iterator iter = map->find(familyUIName); + // Insert new family if (iter == map->end()) { map->insert(std::make_pair(familyUIName, std::list<Glib::ustring>())); } @@ -745,6 +783,7 @@ void font_factory::GetUIFamiliesAndStyles(FamilyToStylesMap *map) ConstructFontSpecification(faceDescr))); fontInstanceMap.insert( std::make_pair(ConstructFontSpecification(faceDescr), faceDescr)); + } else { pango_font_description_free(faceDescr); } @@ -815,7 +854,14 @@ font_instance* font_factory::FaceFromUIStrings(char const *uiFamily, char const g_assert(uiFamily && uiStyle); if (uiFamily && uiStyle) { - Glib::ustring uiString = Glib::ustring(uiFamily) + Glib::ustring(uiStyle); + + // If font list, take only first font in list + gchar** tokens = g_strsplit( uiFamily, ",", 0 ); + g_strstrip( tokens[0] ); + + Glib::ustring uiString = Glib::ustring(tokens[0]) + Glib::ustring(uiStyle); + + g_strfreev( tokens ); UIStringToPangoStringMap::iterator uiToPangoIter = fontStringMap.find(uiString); @@ -854,7 +900,7 @@ font_instance* font_factory::FaceFromPangoString(char const *pangoString) descr = pango_font_description_from_string(pangoString); } - if (descr && (pango_font_description_get_family(descr) != NULL)) { + if (descr && (sp_font_description_get_family(descr) != NULL)) { fontInstance = Face(descr); } @@ -902,7 +948,7 @@ font_instance *font_factory::Face(PangoFontDescription *descr, bool canFail) // workaround for bug #1025565. // fonts without families blow up Pango. - if (pango_font_description_get_family(descr) != NULL) { + if (sp_font_description_get_family(descr) != NULL) { nFace = pango_font_map_load_font(fontServer,fontContext,descr); } else { diff --git a/src/libnrtype/FontFactory.h b/src/libnrtype/FontFactory.h index 42f975ab7..12046079e 100644 --- a/src/libnrtype/FontFactory.h +++ b/src/libnrtype/FontFactory.h @@ -54,6 +54,9 @@ struct font_descr_equal : public std::binary_function<PangoFontDescription*, Pan int style_name_compare(char const *aa, char const *bb); int family_name_compare(char const *a, char const *b); +// Wraps calls to pango_font_description_get_family with some name substitution +const char *sp_font_description_get_family(PangoFontDescription const *fontDescr); + // Map type for gathering UI family and style strings typedef std::map<Glib::ustring, std::list<Glib::ustring> > FamilyToStylesMap; diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index f26b157da..61225ad0c 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -285,14 +285,14 @@ unsigned int font_instance::Attribute(const gchar *key, gchar *str, unsigned int bool b = (weight >= PANGO_WEIGHT_BOLD); res = g_strdup_printf ("%s%s%s%s", - pango_font_description_get_family(descr), + sp_font_description_get_family(descr), (b || i || o) ? "-" : "", (b) ? "Bold" : "", (i) ? "Italic" : ((o) ? "Oblique" : "") ); free_res = true; } } else if ( strcmp(key,"family") == 0 ) { - res=(char*)pango_font_description_get_family(descr); + res=(char*)sp_font_description_get_family(descr); free_res=false; } else if ( strcmp(key,"style") == 0 ) { PangoStyle v=pango_font_description_get_style(descr); diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index 9e75473ce..e97884f40 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -424,7 +424,7 @@ Glib::ustring Layout::getFontFamily(unsigned span_index) const return ""; if (_spans[span_index].font) { - return pango_font_description_get_family(_spans[span_index].font->descr); + return sp_font_description_get_family(_spans[span_index].font->descr); } return ""; @@ -452,7 +452,7 @@ Glib::ustring Layout::dumpAsText() const snprintf(line, sizeof(line), " in chunk %d (x=%f, baselineshift=%f)\n", _spans[span_index].in_chunk, _chunks[_spans[span_index].in_chunk].left_x, _spans[span_index].baseline_shift); result += line; if (_spans[span_index].font) { - snprintf(line, sizeof(line), " font '%s' %f %s %s\n", pango_font_description_get_family(_spans[span_index].font->descr), _spans[span_index].font_size, style_to_text(pango_font_description_get_style(_spans[span_index].font->descr)), weight_to_text(pango_font_description_get_weight(_spans[span_index].font->descr))); + snprintf(line, sizeof(line), " font '%s' %f %s %s\n", sp_font_description_get_family(_spans[span_index].font->descr), _spans[span_index].font_size, style_to_text(pango_font_description_get_style(_spans[span_index].font->descr)), weight_to_text(pango_font_description_get_weight(_spans[span_index].font->descr))); result += line; } snprintf(line, sizeof(line), " x_start = %f, x_end = %f\n", _spans[span_index].x_start, _spans[span_index].x_end); diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 710e0b84f..04859185c 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -14,12 +14,19 @@ #include "font-lister.h" #include "FontFactory.h" +#include "sp-object.h" +#include "sp-root.h" +#include "document.h" +#include "xml/repr.h" +#include "preferences.h" + namespace Inkscape { FontLister::FontLister () { font_list_store = Gtk::ListStore::create (FontList); - + font_list_store->freeze_notify(); + FamilyToStylesMap familyStyleMap; font_factory::Default()->GetUIFamiliesAndStyles(&familyStyleMap); @@ -52,10 +59,156 @@ namespace Inkscape } (*treeModelIter)[FontList.styles] = styles; - - font_list_store_iter_map.insert(std::make_pair(familyName, Gtk::TreePath(treeModelIter))); + (*treeModelIter)[FontList.onSystem] = true; } } + font_list_store->thaw_notify(); + } + + // Example of how to use "foreach_iter" + // bool + // FontLister::print_document_font( const Gtk::TreeModel::iterator &iter ) { + // Gtk::TreeModel::Row row = *iter; + // if( !row[FontList.onSystem] ) { + // std::cout << " Not on system: " << row[FontList.font] << std::endl; + // return false; + // } + // return true; + // } + // font_list_store->foreach_iter( sigc::mem_fun(*this, &FontLister::print_document_font )); + + void + FontLister::update_font_list( SPDocument* document ) { + + SPObject *r = document->getRoot(); + if( !r ) { + return; + } + + font_list_store->freeze_notify(); + + /* Clear all old document font-family entries */ + Gtk::TreeModel::iterator iter = font_list_store->get_iter( "0" ); + while( iter != font_list_store->children().end() ) { + Gtk::TreeModel::Row row = *iter; + if( !row[FontList.onSystem] ) { + // std::cout << " Not on system: " << row[FontList.font] << std::endl; + iter = font_list_store->erase( iter ); + } else { + // std::cout << " First on system: " << row[FontList.font] << std::endl; + break; + } + } + + /* Create default styles for use when font-family is unknown on system. */ + static GList *default_styles = NULL; + if( default_styles == NULL ) { + default_styles = g_list_append( default_styles, g_strdup("Normal") ); + default_styles = g_list_append( default_styles, g_strdup("Italic") ); + default_styles = g_list_append( default_styles, g_strdup("Bold") ); + default_styles = g_list_append( default_styles, g_strdup("Bold Italic") ); + } + + /* Get "font-family"s used in document. */ + std::list<Glib::ustring> fontfamilies; + update_font_list_recursive( r, &fontfamilies ); + + fontfamilies.sort(); + fontfamilies.unique(); + fontfamilies.reverse(); + + /* Insert separator */ + if( !fontfamilies.empty() ) { + Gtk::TreeModel::iterator treeModelIter = font_list_store->prepend(); + (*treeModelIter)[FontList.font] = "#"; + (*treeModelIter)[FontList.onSystem] = false; + } + + /* Insert font-family's in document. */ + std::list<Glib::ustring>::iterator i; + for( i = fontfamilies.begin(); i != fontfamilies.end(); ++i) { + + GList *styles = default_styles; + + /* See if font-family (or first in fallback list) is on system. If so, get styles. */ + std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(",", *i ); + if( !tokens[0].empty() ) { + + Gtk::TreeModel::iterator iter2 = font_list_store->get_iter( "0" ); + while( iter2 != font_list_store->children().end() ) { + Gtk::TreeModel::Row row = *iter2; + if( row[FontList.onSystem] && tokens[0].compare( row[FontList.font] ) == 0 ) { + styles = row[FontList.styles]; + break; + } + ++iter2; + } + } + + Gtk::TreeModel::iterator treeModelIter = font_list_store->prepend(); + (*treeModelIter)[FontList.font] = reinterpret_cast<const char*>(g_strdup((*i).c_str())); + (*treeModelIter)[FontList.styles] = styles; + (*treeModelIter)[FontList.onSystem] = false; + } + + font_list_store->thaw_notify(); + } + + void + FontLister::update_font_list_recursive( SPObject *r, std::list<Glib::ustring> *l ) { + + const gchar *style = r->getRepr()->attribute("style"); + if( style != NULL ) { + + std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(";", style ); + for( size_t i=0; i < tokens.size(); ++i ) { + + Glib::ustring token = tokens[i]; + size_t found = token.find("font-family:"); + + if( found != Glib::ustring::npos ) { + + // Remove "font-family:" + token.erase(found,12); + + // Remove any leading single or double quote + if( token[0] == '\'' || token[0] == '"' ) { + token.erase(0,1); + } + + // Remove any trailing single or double quote + if( token[token.length()-1] == '\'' || token[token.length()-1] == '"' ) { + token.erase(token.length()-1); + } + + l->push_back( token ); + } + } + } + + for (SPObject *child = r->firstChild(); child; child = child->getNext()) { + update_font_list_recursive( child, l ); + } + } + + Gtk::TreePath + FontLister::get_row_for_font (Glib::ustring family) + { + Gtk::TreePath path; + + Gtk::TreeModel::iterator iter = font_list_store->get_iter( "0" ); + while( iter != font_list_store->children().end() ) { + + Gtk::TreeModel::Row row = *iter; + + if( family.compare( row[FontList.font] ) == 0 ) { + return font_list_store->get_path( iter ); + } + + ++iter; + } + + throw FAMILY_NOT_FOUND; } FontLister::~FontLister () @@ -69,6 +222,77 @@ namespace Inkscape } } +// Helper functions +void font_lister_cell_data_func(GtkCellLayout */*cell_layout*/, + GtkCellRenderer *cell, + GtkTreeModel *model, + GtkTreeIter *iter, + gpointer /*data*/) +{ + gchar *family; + gboolean onSystem = false; + gtk_tree_model_get(model, iter, 0, &family, 2, &onSystem, -1); + Glib::ustring family_escaped = g_markup_escape_text(family, -1); + //g_free(family); + Glib::ustring markup; + + if( !onSystem ) { + markup = "<span foreground='darkblue'>"; + /* See if font-family on system */ + std::vector<Glib::ustring> tokens = Glib::Regex::split_simple("\\s*,\\s*", family_escaped ); + for( size_t i=0; i < tokens.size(); ++i ) { + Glib::ustring token = tokens[i]; + GtkTreeIter iter; + gboolean valid; + gchar *family = 0; + gboolean onSystem = true; + gboolean found = false; + for( valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL(model), &iter ); + valid; + valid = gtk_tree_model_iter_next( GTK_TREE_MODEL(model), &iter ) ) { + + gtk_tree_model_get(model, &iter, 0, &family, 2, &onSystem, -1); + if( onSystem && token.compare( family ) == 0 ) { + found = true; + break; + } + } + if( found ) { + markup += g_markup_escape_text(token.c_str(), -1); + markup += ", "; + } else { + markup += "<span strikethrough=\"true\" strikethrough_color=\"red\">"; + markup += g_markup_escape_text(token.c_str(), -1); + markup += "</span>"; + markup += ", "; + } + } + // Remove extra comma and space from end. + if( markup.size() >= 2 ) { + markup.resize( markup.size()-2 ); + } + markup += "</span>"; + // std::cout << markup << std::endl; + } else { + markup = family_escaped; + } + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int show_sample = prefs->getInt("/tools/text/show_sample_in_list", 1); + if (show_sample) { + + Glib::ustring sample = prefs->getString("/tools/text/font_sample"); + Glib::ustring sample_escaped = g_markup_escape_text(sample.data(), -1); + + markup += " <span foreground='gray' font_family='"; + markup += family_escaped; + markup += "'>"; + markup += sample_escaped; + markup += "</span>"; + } + + g_object_set (G_OBJECT (cell), "markup", markup.c_str(), NULL); +} diff --git a/src/libnrtype/font-lister.h b/src/libnrtype/font-lister.h index c9ab7b21d..751350407 100644 --- a/src/libnrtype/font-lister.h +++ b/src/libnrtype/font-lister.h @@ -7,9 +7,11 @@ * Authors: * Chris Lahey <clahey@ximian.com> * Lauris Kaplinski <lauris@kaplinski.com> + * Tavmjong Bah <tavmjong@free.fr> * * Copyright (C) 1999-2001 Ximian, Inc. * Copyright (C) 2002 Lauris Kaplinski + * Copyright (C) 2013 Tavmjong Bah * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -21,6 +23,9 @@ #include <glibmm/ustring.h> #include "nr-type-primitives.h" +class SPObject; +class SPDocument; + namespace Inkscape { /** @@ -54,29 +59,19 @@ namespace Inkscape */ Gtk::TreeModelColumn<GList*> styles; + /** Column containing flag if font is on system + */ + Gtk::TreeModelColumn<gboolean> onSystem; + FontListClass () { add (font); add (styles); + add (onSystem); } }; - /* Case-insensitive < compare for standard strings */ - class StringLessThan - { - public: - bool operator () (std::string str1, std::string str2) const - { - std::string s1=str1; // Can't transform the originals! - std::string s2=str2; - std::transform(s1.begin(), s1.end(), s1.begin(), (int(*)(int)) toupper); - std::transform(s2.begin(), s2.end(), s2.begin(), (int(*)(int)) toupper); - return s1<s2; - } - }; - FontListClass FontList; - typedef std::map<Glib::ustring, Gtk::TreePath, StringLessThan> IterMapType; /** Returns the ListStore with the font names * @@ -87,6 +82,17 @@ namespace Inkscape const Glib::RefPtr<Gtk::ListStore> get_font_list () const; + /** Updates font list to include fonts in document + * + */ + void + update_font_list ( SPDocument* document); + + private: + void + update_font_list_recursive( SPObject *r, std::list<Glib::ustring> *l ); + + public: static Inkscape::FontLister* get_instance () { @@ -95,12 +101,7 @@ namespace Inkscape } Gtk::TreePath - get_row_for_font (Glib::ustring family) - { - IterMapType::iterator iter = font_list_store_iter_map.find (family); - if (iter == font_list_store_iter_map.end ()) throw FAMILY_NOT_FOUND; - return (*iter).second; - } + get_row_for_font (Glib::ustring family); const NRNameList get_name_list () const @@ -108,7 +109,6 @@ namespace Inkscape return families; } - private: FontLister (); @@ -116,11 +116,25 @@ namespace Inkscape NRNameList families; Glib::RefPtr<Gtk::ListStore> font_list_store; - IterMapType font_list_store_iter_map; }; } +// Helper functions +// Separator function (if true, a separator will be drawn) +static gboolean font_lister_separator_func(GtkTreeModel *model, GtkTreeIter *iter, gpointer /*data*/) +{ + gchar* text = 0; + gtk_tree_model_get(model, iter, 0, &text, -1 ); // Column 0: FontList.font + return (text && strcmp(text,"#") == 0); +} + +void font_lister_cell_data_func(GtkCellLayout */*cell_layout*/, + GtkCellRenderer *cell, + GtkTreeModel *model, + GtkTreeIter *iter, + gpointer /*data*/); + #endif /* diff --git a/src/livarot/Path.h b/src/livarot/Path.h index 1f0e7a244..cd939bf7d 100644 --- a/src/livarot/Path.h +++ b/src/livarot/Path.h @@ -335,7 +335,7 @@ public: PathDescrBezierTo & fin, bool before, Geom::Point & pos, Geom::Point & tgt, double &len, double &rad); static void OutlineJoin (Path * dest, Geom::Point pos, Geom::Point stNor, Geom::Point enNor, - double width, JoinType join, double miter); + double width, JoinType join, double miter, int nType); static bool IsNulCurve (std::vector<PathDescr*> const &cmd, int curD, Geom::Point const &curX); diff --git a/src/livarot/PathOutline.cpp b/src/livarot/PathOutline.cpp index f00798c8a..7f8853e31 100644 --- a/src/livarot/PathOutline.cpp +++ b/src/livarot/PathOutline.cpp @@ -387,7 +387,7 @@ void Path::SubContractOutline(int off, int num_pd, if (closeIfNeeded) { if ( Geom::LInfty (curX- firstP) < 0.0001 ) { OutlineJoin (dest, firstP, curT, firstT, width, join, - miter); + miter, nType); dest->Close (); } else { PathDescrLineTo temp(firstP); @@ -404,7 +404,7 @@ void Path::SubContractOutline(int off, int num_pd, Geom::Point pos; pos = curX; OutlineJoin (dest, pos, curT, stNor, width, join, - miter); + miter, nType); } dest->LineTo (enPos+width*enNor); @@ -413,7 +413,7 @@ void Path::SubContractOutline(int off, int num_pd, Geom::Point pos; pos = firstP; OutlineJoin (dest, enPos, enNor, firstT, width, join, - miter); + miter, nType); dest->Close (); } } @@ -429,7 +429,7 @@ void Path::SubContractOutline(int off, int num_pd, if (Geom::LInfty (curX - firstP) < 0.0001) { OutlineJoin (dest, firstP, curT, firstT, width, join, - miter); + miter, nType); dest->Close (); } else @@ -445,7 +445,7 @@ void Path::SubContractOutline(int off, int num_pd, // jointure { OutlineJoin (dest, stPos, curT, stNor, width, join, - miter); + miter, nType); } dest->LineTo (enPos+width*enNor); @@ -453,7 +453,7 @@ void Path::SubContractOutline(int off, int num_pd, // jointure { OutlineJoin (dest, enPos, enNor, firstT, width, join, - miter); + miter, nType); dest->Close (); } } @@ -497,7 +497,7 @@ void Path::SubContractOutline(int off, int num_pd, // jointure Geom::Point pos; pos = curX; - OutlineJoin (dest, pos, curT, stNor, width, join, miter); + OutlineJoin (dest, pos, curT, stNor, width, join, miter, nType); } int n_d = dest->LineTo (nextX+width*enNor); @@ -547,7 +547,7 @@ void Path::SubContractOutline(int off, int num_pd, // jointure Geom::Point pos; pos = curX; - OutlineJoin (dest, pos, curT, stNor, width, join, miter); + OutlineJoin (dest, pos, curT, stNor, width, join, miter, nType); } callsData.piece = curP; @@ -603,7 +603,7 @@ void Path::SubContractOutline(int off, int num_pd, // jointure Geom::Point pos; pos = curX; - OutlineJoin (dest, pos, curT, stNor, width, join, miter); + OutlineJoin (dest, pos, curT, stNor, width, join, miter, nType); } callsData.piece = curP; @@ -661,7 +661,7 @@ void Path::SubContractOutline(int off, int num_pd, // jointure Geom::Point pos; pos = curX; - if (stTle > 0) OutlineJoin (dest, pos, curT, stNor, width, join, miter); + if (stTle > 0) OutlineJoin (dest, pos, curT, stNor, width, join, miter, nType); } int n_d = dest->LineTo (nextX+width*enNor); if (n_d >= 0) { @@ -692,7 +692,7 @@ void Path::SubContractOutline(int off, int num_pd, // jointure Geom::Point pos; pos = curX; - OutlineJoin (dest, pos, curT, stNor, width, join, miter); + OutlineJoin (dest, pos, curT, stNor, width, join, miter, nType); } callsData.piece = curP; @@ -729,7 +729,7 @@ void Path::SubContractOutline(int off, int num_pd, } else { // jointure Geom::Point pos=curX; - OutlineJoin (dest, pos, stTgt, stNor, width, join, miter); + OutlineJoin (dest, pos, stTgt, stNor, width, join, miter, nType); // dest->LineTo(curX+width*stNor.x,curY+width*stNor.y); } } @@ -1164,7 +1164,7 @@ Path::TangentOnBezAt (double at, Geom::Point const &iS, void Path::OutlineJoin (Path * dest, Geom::Point pos, Geom::Point stNor, Geom::Point enNor, double width, - JoinType join, double miter) + JoinType join, double miter, int nType) { /* Arbitrarily decide if we're on the inside or outside of a half turn. @@ -1188,8 +1188,20 @@ Path::OutlineJoin (Path * dest, Geom::Point pos, Geom::Point stNor, Geom::Point } else { if ((angSi > 0 && width >= 0) || (angSi < 0 && width < 0)) { // This is an inside join -> join is independent of chosen JoinType. - dest->LineTo (pos); - dest->LineTo (pos + width*enNor); + if ((dest->descr_cmd[dest->descr_cmd.size() - 1]->getType() == descr_lineto) && (nType == descr_lineto)) { + Geom::Point const biss = unit_vector(Geom::rot90( stNor - enNor )); + double c2 = Geom::dot (biss, enNor); + if (fabs(c2) > 0.707107) { // apply only to obtuse angles + double l = width / c2; + PathDescrLineTo* nLine = dynamic_cast<PathDescrLineTo*>(dest->descr_cmd[dest->descr_cmd.size() - 1]); + nLine->p = pos + l*biss; // relocate to bisector + } else { + dest->LineTo (pos + width*enNor); + } + } else { +// dest->LineTo (pos); // redundant + dest->LineTo (pos + width*enNor); + } } else if (angSi == 0 && TurnInside) { // Half turn (180 degrees) ... inside (see above). dest->LineTo (pos + width*enNor); } else { // This is an outside join -> chosen JoinType should be applied. @@ -1241,8 +1253,14 @@ Path::OutlineJoin (Path * dest, Geom::Point pos, Geom::Point stNor, Geom::Point if ( fabs(l) > miter) { dest->LineTo (pos + width*enNor); } else { - dest->LineTo (pos+l*biss); - dest->LineTo (pos+width*enNor); + if (dest->descr_cmd[dest->descr_cmd.size() - 1]->getType() == descr_lineto) { + PathDescrLineTo* nLine = dynamic_cast<PathDescrLineTo*>(dest->descr_cmd[dest->descr_cmd.size() - 1]); + nLine->p = pos+l*biss; // relocate to bisector + } else { + dest->LineTo (pos+l*biss); + } + if (nType != descr_lineto) + dest->LineTo (pos+width*enNor); } } else { // Bevel join dest->LineTo (pos + width*enNor); diff --git a/src/lpe-tool-context.cpp b/src/lpe-tool-context.cpp index fc755b9dc..feabfa02d 100644 --- a/src/lpe-tool-context.cpp +++ b/src/lpe-tool-context.cpp @@ -41,8 +41,6 @@ #include "lpe-tool-context.h" -static void sp_lpetool_context_class_init(SPLPEToolContextClass *klass); -static void sp_lpetool_context_init(SPLPEToolContext *erc); static void sp_lpetool_context_dispose(GObject *object); static void sp_lpetool_context_setup(SPEventContext *ec); @@ -66,28 +64,7 @@ SubtoolEntry lpesubtools[] = { {Inkscape::LivePathEffect::MIRROR_SYMMETRY, "draw-geometry-mirror"} }; -static SPPenContextClass *lpetool_parent_class = 0; - -GType sp_lpetool_context_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPLPEToolContextClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_lpetool_context_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPLPEToolContext), - 0, // n_preallocs - (GInstanceInitFunc)sp_lpetool_context_init, - 0 // value_table - }; - type = g_type_register_static(SP_TYPE_PEN_CONTEXT, "SPLPEToolContext", &info, static_cast<GTypeFlags>(0)); - } - return type; -} +G_DEFINE_TYPE(SPLPEToolContext, sp_lpetool_context, SP_TYPE_PEN_CONTEXT); static void sp_lpetool_context_class_init(SPLPEToolContextClass *klass) @@ -95,8 +72,6 @@ sp_lpetool_context_class_init(SPLPEToolContextClass *klass) GObjectClass *object_class = (GObjectClass *) klass; SPEventContextClass *event_context_class = (SPEventContextClass *) klass; - lpetool_parent_class = (SPPenContextClass*)g_type_class_peek_parent(klass); - object_class->dispose = sp_lpetool_context_dispose; event_context_class->setup = sp_lpetool_context_setup; @@ -140,7 +115,7 @@ sp_lpetool_context_dispose(GObject *object) delete lc->_lpetool_message_context; } - G_OBJECT_CLASS(lpetool_parent_class)->dispose(object); + G_OBJECT_CLASS(sp_lpetool_context_parent_class)->dispose(object); } static void @@ -148,8 +123,8 @@ sp_lpetool_context_setup(SPEventContext *ec) { SPLPEToolContext *lc = SP_LPETOOL_CONTEXT(ec); - if (((SPEventContextClass *) lpetool_parent_class)->setup) - ((SPEventContextClass *) lpetool_parent_class)->setup(ec); + if (((SPEventContextClass *) sp_lpetool_context_parent_class)->setup) + ((SPEventContextClass *) sp_lpetool_context_parent_class)->setup(ec); Inkscape::Selection *selection = sp_desktop_selection (ec->desktop); SPItem *item = selection->singleItem(); @@ -204,8 +179,8 @@ sp_lpetool_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val) /* //pass on up to parent class to handle common attributes. - if ( lpetool_parent_class->set ) { - lpetool_parent_class->set(ec, key, val); + if ( sp_lpetool_context_parent_class->set ) { + sp_lpetool_context_parent_class->set(ec, key, val); } */ } @@ -234,8 +209,8 @@ sp_lpetool_context_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *even } if (!ret) { - if (((SPEventContextClass *) lpetool_parent_class)->item_handler) - ret = ((SPEventContextClass *) lpetool_parent_class)->item_handler(ec, item, event); + if (((SPEventContextClass *) sp_lpetool_context_parent_class)->item_handler) + ret = ((SPEventContextClass *) sp_lpetool_context_parent_class)->item_handler(ec, item, event); } return ret; @@ -252,7 +227,7 @@ sp_lpetool_context_root_handler(SPEventContext *event_context, GdkEvent *event) if (sp_pen_context_has_waiting_LPE(lc)) { // quit when we are waiting for a LPE to be applied - ret = ((SPEventContextClass *) lpetool_parent_class)->root_handler(event_context, event); + ret = ((SPEventContextClass *) sp_lpetool_context_parent_class)->root_handler(event_context, event); return ret; } @@ -284,7 +259,7 @@ sp_lpetool_context_root_handler(SPEventContext *event_context, GdkEvent *event) sp_pen_context_wait_for_LPE_mouse_clicks(lc, type, Inkscape::LivePathEffect::Effect::acceptsNumClicks(type)); // we pass the mouse click on to pen tool as the first click which it should collect - ret = ((SPEventContextClass *) lpetool_parent_class)->root_handler(event_context, event); + ret = ((SPEventContextClass *) sp_lpetool_context_parent_class)->root_handler(event_context, event); } break; @@ -320,8 +295,8 @@ sp_lpetool_context_root_handler(SPEventContext *event_context, GdkEvent *event) } if (!ret) { - if (((SPEventContextClass *) lpetool_parent_class)->root_handler) { - ret = ((SPEventContextClass *) lpetool_parent_class)->root_handler(event_context, event); + if (((SPEventContextClass *) sp_lpetool_context_parent_class)->root_handler) { + ret = ((SPEventContextClass *) sp_lpetool_context_parent_class)->root_handler(event_context, event); } } diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 7a04b9915..dc23cf5c6 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -47,16 +47,12 @@ using Inkscape::ControlManager; using Inkscape::CTLINE_SECONDARY; -static void sp_measure_context_class_init(SPMeasureContextClass *klass); -static void sp_measure_context_init(SPMeasureContext *measure_context); static void sp_measure_context_setup(SPEventContext *ec); static void sp_measure_context_finish(SPEventContext *ec); static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEvent *event); static gint sp_measure_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event); -static SPEventContextClass *parent_class; - static gint xp = 0; // where drag started static gint yp = 0; static gint tolerance = 0; @@ -68,26 +64,7 @@ boost::optional<Geom::Point> lastEnd; std::vector<Inkscape::Display::TemporaryItem*> measure_tmp_items; -GType sp_measure_context_get_type(void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof(SPMeasureContextClass), - NULL, NULL, - reinterpret_cast<GClassInitFunc>(sp_measure_context_class_init), // TODO needs two params? - NULL, NULL, - sizeof(SPMeasureContext), - 4, - reinterpret_cast<GInstanceInitFunc>(sp_measure_context_init), // TODO needs two params? - NULL, // value_table - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPMeasureContext", &info, static_cast<GTypeFlags>(0)); - } - - return type; -} +G_DEFINE_TYPE(SPMeasureContext, sp_measure_context, SP_TYPE_EVENT_CONTEXT); namespace { @@ -258,8 +235,6 @@ static void sp_measure_context_class_init(SPMeasureContextClass *klass) { SPEventContextClass *event_context_class = reinterpret_cast<SPEventContextClass *>(klass); - parent_class = static_cast<SPEventContextClass*>(g_type_class_peek_parent(klass)); - event_context_class->setup = sp_measure_context_setup; event_context_class->finish = sp_measure_context_finish; @@ -290,8 +265,8 @@ static void sp_measure_context_finish(SPEventContext *ec) static void sp_measure_context_setup(SPEventContext *ec) { - if (parent_class->setup) { - parent_class->setup(ec); + if (SP_EVENT_CONTEXT_CLASS(sp_measure_context_parent_class)->setup) { + SP_EVENT_CONTEXT_CLASS(sp_measure_context_parent_class)->setup(ec); } } @@ -299,8 +274,8 @@ static gint sp_measure_context_item_handler(SPEventContext *event_context, SPIte { gint ret = FALSE; - if (parent_class->item_handler) { - ret = parent_class->item_handler(event_context, item, event); + if (SP_EVENT_CONTEXT_CLASS(sp_measure_context_parent_class)->item_handler) { + ret = SP_EVENT_CONTEXT_CLASS(sp_measure_context_parent_class)->item_handler(event_context, item, event); } return ret; @@ -789,8 +764,8 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv } if (!ret) { - if (parent_class->root_handler) { - ret = parent_class->root_handler(event_context, event); + if (SP_EVENT_CONTEXT_CLASS(sp_measure_context_parent_class)->root_handler) { + ret = SP_EVENT_CONTEXT_CLASS(sp_measure_context_parent_class)->root_handler(event_context, event); } } diff --git a/src/mesh-context.cpp b/src/mesh-context.cpp index 8fd016702..36712d15d 100644 --- a/src/mesh-context.cpp +++ b/src/mesh-context.cpp @@ -53,8 +53,6 @@ using Inkscape::DocumentUndo; -static void sp_mesh_context_class_init(SPMeshContextClass *klass); -static void sp_mesh_context_init(SPMeshContext *gr_context); static void sp_mesh_context_dispose(GObject *object); static void sp_mesh_context_setup(SPEventContext *ec); @@ -63,35 +61,13 @@ static gint sp_mesh_context_root_handler(SPEventContext *event_context, GdkEvent static void sp_mesh_drag(SPMeshContext &rc, Geom::Point const pt, guint state, guint32 etime); -static SPEventContextClass *parent_class; - - -GType sp_mesh_context_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPMeshContextClass), - NULL, NULL, - (GClassInitFunc) sp_mesh_context_class_init, - NULL, NULL, - sizeof(SPMeshContext), - 4, - (GInstanceInitFunc) sp_mesh_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPMeshContext", &info, (GTypeFlags) 0); - } - return type; -} +G_DEFINE_TYPE(SPMeshContext, sp_mesh_context, SP_TYPE_EVENT_CONTEXT); static void sp_mesh_context_class_init(SPMeshContextClass *klass) { GObjectClass *object_class = (GObjectClass *) klass; SPEventContextClass *event_context_class = (SPEventContextClass *) klass; - parent_class = (SPEventContextClass *) g_type_class_peek_parent(klass); - object_class->dispose = sp_mesh_context_dispose; event_context_class->setup = sp_mesh_context_setup; @@ -129,7 +105,7 @@ static void sp_mesh_context_dispose(GObject *object) rc->subselcon->disconnect(); delete rc->subselcon; - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_mesh_context_parent_class)->dispose(object); } const gchar *ms_handle_descr [] = { @@ -270,8 +246,8 @@ static void sp_mesh_context_setup(SPEventContext *ec) { SPMeshContext *rc = SP_MESH_CONTEXT(ec); - if (((SPEventContextClass *) parent_class)->setup) { - ((SPEventContextClass *) parent_class)->setup(ec); + if (((SPEventContextClass *) sp_mesh_context_parent_class)->setup) { + ((SPEventContextClass *) sp_mesh_context_parent_class)->setup(ec); } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -948,8 +924,8 @@ sp_mesh_context_root_handler(SPEventContext *event_context, GdkEvent *event) } if (!ret) { - if (((SPEventContextClass *) parent_class)->root_handler) { - ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event); + if (((SPEventContextClass *) sp_mesh_context_parent_class)->root_handler) { + ret = ((SPEventContextClass *) sp_mesh_context_parent_class)->root_handler(event_context, event); } } diff --git a/src/pen-context.cpp b/src/pen-context.cpp index cb20eb3eb..6e3ed201e 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -47,9 +47,6 @@ using Inkscape::ControlManager; - -static void sp_pen_context_class_init(SPPenContextClass *klass); -static void sp_pen_context_init(SPPenContext *pc); static void sp_pen_context_dispose(GObject *object); static void sp_pen_context_setup(SPEventContext *ec); @@ -78,35 +75,12 @@ static void pen_enable_events(SPPenContext *const pc); static Geom::Point pen_drag_origin_w(0, 0); static bool pen_within_tolerance = false; -static SPDrawContextClass *pen_parent_class; - static int pen_next_paraxial_direction(const SPPenContext *const pc, Geom::Point const &pt, Geom::Point const &origin, guint state); static void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, Geom::Point &pt, guint const state, bool snap); static int pen_last_paraxial_dir = 0; // last used direction in horizontal/vertical mode; 0 = horizontal, 1 = vertical - -/** - * Register SPPenContext with Gdk and return its type. - */ -GType sp_pen_context_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPPenContextClass), - NULL, NULL, - (GClassInitFunc) sp_pen_context_class_init, - NULL, NULL, - sizeof(SPPenContext), - 4, - (GInstanceInitFunc) sp_pen_context_init, - NULL, // value_table - }; - type = g_type_register_static(SP_TYPE_DRAW_CONTEXT, "SPPenContext", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPPenContext, sp_pen_context, SP_TYPE_DRAW_CONTEXT); /** * Initialize the SPPenContext vtable. @@ -119,8 +93,6 @@ static void sp_pen_context_class_init(SPPenContextClass *klass) object_class = (GObjectClass *) klass; event_context_class = (SPEventContextClass *) klass; - pen_parent_class = (SPDrawContextClass*)g_type_class_peek_parent(klass); - object_class->dispose = sp_pen_context_dispose; event_context_class->setup = sp_pen_context_setup; @@ -181,7 +153,7 @@ static void sp_pen_context_dispose(GObject *object) pc->cl1 = NULL; } - G_OBJECT_CLASS(pen_parent_class)->dispose(object); + G_OBJECT_CLASS(sp_pen_context_parent_class)->dispose(object); if (pc->expecting_clicks_for_LPE > 0) { // we received too few clicks to sanely set the parameter path so we remove the LPE from the item @@ -203,8 +175,8 @@ static void sp_pen_context_setup(SPEventContext *ec) { SPPenContext *pc = SP_PEN_CONTEXT(ec); - if (((SPEventContextClass *) pen_parent_class)->setup) { - ((SPEventContextClass *) pen_parent_class)->setup(ec); + if (((SPEventContextClass *) sp_pen_context_parent_class)->setup) { + ((SPEventContextClass *) sp_pen_context_parent_class)->setup(ec); } ControlManager &mgr = ControlManager::getManager(); @@ -265,8 +237,8 @@ static void sp_pen_context_finish(SPEventContext *ec) pen_cancel (pc); } - if (((SPEventContextClass *) pen_parent_class)->finish) { - ((SPEventContextClass *) pen_parent_class)->finish(ec); + if (((SPEventContextClass *) sp_pen_context_parent_class)->finish) { + ((SPEventContextClass *) sp_pen_context_parent_class)->finish(ec); } } @@ -347,8 +319,8 @@ static gint sp_pen_context_item_handler(SPEventContext *ec, SPItem *item, GdkEve } if (!ret) { - if (((SPEventContextClass *) pen_parent_class)->item_handler) - ret = ((SPEventContextClass *) pen_parent_class)->item_handler(ec, item, event); + if (((SPEventContextClass *) sp_pen_context_parent_class)->item_handler) + ret = ((SPEventContextClass *) sp_pen_context_parent_class)->item_handler(ec, item, event); } return ret; @@ -390,7 +362,7 @@ static gint sp_pen_context_root_handler(SPEventContext *ec, GdkEvent *event) if (!ret) { gint (*const parent_root_handler)(SPEventContext *, GdkEvent *) - = ((SPEventContextClass *) pen_parent_class)->root_handler; + = ((SPEventContextClass *) sp_pen_context_parent_class)->root_handler; if (parent_root_handler) { ret = parent_root_handler(ec, event); } diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index 19a040b24..090a43a25 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -45,9 +45,6 @@ #include "display/curve.h" #include "livarot/Path.h" - -static void sp_pencil_context_class_init(SPPencilContextClass *klass); -static void sp_pencil_context_init(SPPencilContext *pc); static void sp_pencil_context_setup(SPEventContext *ec); static void sp_pencil_context_dispose(GObject *object); @@ -66,34 +63,12 @@ static void fit_and_split(SPPencilContext *pc); static void interpolate(SPPencilContext *pc); static void sketch_interpolate(SPPencilContext *pc); -static SPDrawContextClass *pencil_parent_class; static Geom::Point pencil_drag_origin_w(0, 0); static bool pencil_within_tolerance = false; static bool in_svg_plane(Geom::Point const &p) { return Geom::LInfty(p) < 1e18; } -/** - * Register SPPencilContext class with Gdk and return its type number. - */ -GType -sp_pencil_context_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPPencilContextClass), - NULL, NULL, - (GClassInitFunc) sp_pencil_context_class_init, - NULL, NULL, - sizeof(SPPencilContext), - 4, - (GInstanceInitFunc) sp_pencil_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_DRAW_CONTEXT, "SPPencilContext", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPPencilContext, sp_pencil_context, SP_TYPE_DRAW_CONTEXT); /** * Initialize SPPencilContext vtable. @@ -107,8 +82,6 @@ sp_pencil_context_class_init(SPPencilContextClass *klass) object_class = (GObjectClass *) klass; event_context_class = (SPEventContextClass *) klass; - pencil_parent_class = (SPDrawContextClass*)g_type_class_peek_parent(klass); - object_class->dispose = sp_pencil_context_dispose; event_context_class->setup = sp_pencil_context_setup; @@ -147,8 +120,8 @@ sp_pencil_context_setup(SPEventContext *ec) ec->enableSelectionCue(); } - if (((SPEventContextClass *) pencil_parent_class)->setup) { - ((SPEventContextClass *) pencil_parent_class)->setup(ec); + if (((SPEventContextClass *) sp_pencil_context_parent_class)->setup) { + ((SPEventContextClass *) sp_pencil_context_parent_class)->setup(ec); } SPPencilContext *const pc = SP_PENCIL_CONTEXT(ec); @@ -160,7 +133,7 @@ sp_pencil_context_setup(SPEventContext *ec) static void sp_pencil_context_dispose(GObject *object) { - G_OBJECT_CLASS(pencil_parent_class)->dispose(object); + G_OBJECT_CLASS(sp_pencil_context_parent_class)->dispose(object); } /** Snaps new node relative to the previous node. */ @@ -218,7 +191,7 @@ sp_pencil_context_root_handler(SPEventContext *const ec, GdkEvent *event) if (!ret) { gint (*const parent_root_handler)(SPEventContext *, GdkEvent *) - = ((SPEventContextClass *) pencil_parent_class)->root_handler; + = ((SPEventContextClass *) sp_pencil_context_parent_class)->root_handler; if (parent_root_handler) { ret = parent_root_handler(ec, event); } diff --git a/src/persp3d.cpp b/src/persp3d.cpp index a20537d95..2744efb75 100644 --- a/src/persp3d.cpp +++ b/src/persp3d.cpp @@ -27,9 +27,6 @@ using Inkscape::DocumentUndo; -static void persp3d_class_init(Persp3DClass *klass); -static void persp3d_init(Persp3D *persp); - static void persp3d_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void persp3d_release(SPObject *object); static void persp3d_set(SPObject *object, unsigned key, gchar const *value); @@ -41,8 +38,6 @@ static void persp3d_on_repr_attr_changed (Inkscape::XML::Node * repr, const gcha static void persp3d_update_with_point (Persp3DImpl *persp_impl, Proj::Axis const axis, Proj::Pt2 const &new_image); static gchar * persp3d_pt_to_str (Persp3DImpl *persp_impl, Proj::Axis const axis); -static SPObjectClass *persp3d_parent_class; - static int global_counter = 0; /* Constructor/destructor for the internal class */ @@ -54,28 +49,7 @@ Persp3DImpl::Persp3DImpl() { my_counter = global_counter++; } -/** - * Registers Persp3d class and returns its type. - */ -GType -persp3d_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(Persp3DClass), - NULL, NULL, - (GClassInitFunc) persp3d_class_init, - NULL, NULL, - sizeof(Persp3D), - 16, - (GInstanceInitFunc) persp3d_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_OBJECT, "Persp3D", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(Persp3D, persp3d, SP_TYPE_OBJECT); static Inkscape::XML::NodeEventVector const persp3d_repr_events = { NULL, /* child_added */ @@ -92,8 +66,6 @@ static void persp3d_class_init(Persp3DClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *) klass; - persp3d_parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT); - sp_object_class->build = persp3d_build; sp_object_class->release = persp3d_release; sp_object_class->set = persp3d_set; diff --git a/src/preferences.cpp b/src/preferences.cpp index 3f12c4f64..1d7009a99 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -13,6 +13,7 @@ #include <cstring> #include <sstream> #include <glibmm/fileutils.h> +#include <glibmm/convert.h> #include <glibmm/i18n.h> #include <glib.h> #include <glib/gstdio.h> diff --git a/src/rect-context.cpp b/src/rect-context.cpp index 33ccee93c..040127ae3 100644 --- a/src/rect-context.cpp +++ b/src/rect-context.cpp @@ -49,8 +49,6 @@ using Inkscape::DocumentUndo; //static const double goldenratio = 1.61803398874989484820; // golden ratio -static void sp_rect_context_class_init(SPRectContextClass *klass); -static void sp_rect_context_init(SPRectContext *rect_context); static void sp_rect_context_dispose(GObject *object); static void sp_rect_context_setup(SPEventContext *ec); @@ -64,35 +62,13 @@ static void sp_rect_drag(SPRectContext &rc, Geom::Point const pt, guint state); static void sp_rect_finish(SPRectContext *rc); static void sp_rect_cancel(SPRectContext *rc); -static SPEventContextClass *parent_class; - - -GType sp_rect_context_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPRectContextClass), - NULL, NULL, - (GClassInitFunc) sp_rect_context_class_init, - NULL, NULL, - sizeof(SPRectContext), - 4, - (GInstanceInitFunc) sp_rect_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPRectContext", &info, (GTypeFlags) 0); - } - return type; -} +G_DEFINE_TYPE(SPRectContext, sp_rect_context, SP_TYPE_EVENT_CONTEXT); static void sp_rect_context_class_init(SPRectContextClass *klass) { GObjectClass *object_class = (GObjectClass *) klass; SPEventContextClass *event_context_class = (SPEventContextClass *) klass; - parent_class = (SPEventContextClass *) g_type_class_peek_parent(klass); - object_class->dispose = sp_rect_context_dispose; event_context_class->setup = sp_rect_context_setup; @@ -133,8 +109,8 @@ static void sp_rect_context_finish(SPEventContext *ec) sp_rect_finish(rc); rc->sel_changed_connection.disconnect(); - if (((SPEventContextClass *) parent_class)->finish) { - ((SPEventContextClass *) parent_class)->finish(ec); + if (((SPEventContextClass *) sp_rect_context_parent_class)->finish) { + ((SPEventContextClass *) sp_rect_context_parent_class)->finish(ec); } } @@ -161,7 +137,7 @@ static void sp_rect_context_dispose(GObject *object) delete rc->_message_context; } - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_rect_context_parent_class)->dispose(object); } /** @@ -182,8 +158,8 @@ static void sp_rect_context_setup(SPEventContext *ec) { SPRectContext *rc = SP_RECT_CONTEXT(ec); - if (((SPEventContextClass *) parent_class)->setup) { - ((SPEventContextClass *) parent_class)->setup(ec); + if (((SPEventContextClass *) sp_rect_context_parent_class)->setup) { + ((SPEventContextClass *) sp_rect_context_parent_class)->setup(ec); } ec->shape_editor = new ShapeEditor(ec->desktop); @@ -245,8 +221,8 @@ static gint sp_rect_context_item_handler(SPEventContext *event_context, SPItem * break; } - if (((SPEventContextClass *) parent_class)->item_handler) { - ret = ((SPEventContextClass *) parent_class)->item_handler(event_context, item, event); + if (((SPEventContextClass *) sp_rect_context_parent_class)->item_handler) { + ret = ((SPEventContextClass *) sp_rect_context_parent_class)->item_handler(event_context, item, event); } return ret; @@ -458,8 +434,8 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent } if (!ret) { - if (((SPEventContextClass *) parent_class)->root_handler) { - ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event); + if (((SPEventContextClass *) sp_rect_context_parent_class)->root_handler) { + ret = ((SPEventContextClass *) sp_rect_context_parent_class)->root_handler(event_context, event); } } diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 64bb95508..b6c6baaf7 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -813,8 +813,6 @@ gboolean Inkscape::SelTrans::handleRequest(SPKnot *knot, Geom::Point *position, return TRUE; } - knot->desktop->setPosition(*position); - // When holding shift while rotating or skewing, the transformation will be // relative to the point opposite of the handle; otherwise it will be relative // to the center as set for the selection diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index c7dce3850..bce86c465 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -22,6 +22,7 @@ using std::map; using std::pair; +#include <glibmm/stringutils.h> #include "attributes.h" #include "document.h" #include "sp-filter.h" @@ -38,10 +39,6 @@ using std::pair; #include "display/nr-filter.h" /* Filter base class */ - -static void sp_filter_class_init(SPFilterClass *klass); -static void sp_filter_init(SPFilter *filter); - static void sp_filter_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_filter_release(SPObject *object); static void sp_filter_set(SPObject *object, unsigned int key, gchar const *value); @@ -55,37 +52,13 @@ static Inkscape::XML::Node *sp_filter_write(SPObject *object, Inkscape::XML::Doc static void filter_ref_changed(SPObject *old_ref, SPObject *ref, SPFilter *filter); static void filter_ref_modified(SPObject *href, guint flags, SPFilter *filter); -static SPObjectClass *filter_parent_class; - -GType -sp_filter_get_type() -{ - static GType filter_type = 0; - - if (!filter_type) { - GTypeInfo filter_info = { - sizeof(SPFilterClass), - NULL, NULL, - (GClassInitFunc) sp_filter_class_init, - NULL, NULL, - sizeof(SPFilter), - 16, - (GInstanceInitFunc) sp_filter_init, - NULL, /* value_table */ - }; - filter_type = g_type_register_static(SP_TYPE_OBJECT, "SPFilter", &filter_info, (GTypeFlags)0); - } - return filter_type; -} +G_DEFINE_TYPE(SPFilter, sp_filter, SP_TYPE_OBJECT); static void sp_filter_class_init(SPFilterClass *klass) { - SPObjectClass *sp_object_class = (SPObjectClass *)klass; - filter_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_filter_build; sp_object_class->release = sp_filter_release; sp_object_class->write = sp_filter_write; @@ -141,8 +114,8 @@ sp_filter_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep object->readAttr( "filterRes" ); object->readAttr( "xlink:href" ); - if (((SPObjectClass *) filter_parent_class)->build) { - ((SPObjectClass *) filter_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_filter_parent_class)->build) { + ((SPObjectClass *) sp_filter_parent_class)->build(object, document, repr); } //is this necessary? @@ -174,8 +147,8 @@ static void sp_filter_release(SPObject *object) filter->modified_connection.~connection(); delete filter->_image_name; - if (((SPObjectClass *) filter_parent_class)->release) - ((SPObjectClass *) filter_parent_class)->release(object); + if (((SPObjectClass *) sp_filter_parent_class)->release) + ((SPObjectClass *) sp_filter_parent_class)->release(object); } /** @@ -249,8 +222,8 @@ sp_filter_set(SPObject *object, unsigned int key, gchar const *value) break; default: // See if any parents need this value. - if (((SPObjectClass *) filter_parent_class)->set) { - ((SPObjectClass *) filter_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_filter_parent_class)->set) { + ((SPObjectClass *) sp_filter_parent_class)->set(object, key, value); } break; } @@ -271,8 +244,8 @@ sp_filter_update(SPObject *object, SPCtx *ctx, guint flags) } - if (((SPObjectClass *) filter_parent_class)->update) { - ((SPObjectClass *) filter_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_filter_parent_class)->update) { + ((SPObjectClass *) sp_filter_parent_class)->update(object, ctx, flags); } } @@ -367,8 +340,8 @@ sp_filter_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::N g_free(uri_string); } - if (((SPObjectClass *) filter_parent_class)->write) { - ((SPObjectClass *) filter_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_filter_parent_class)->write) { + ((SPObjectClass *) sp_filter_parent_class)->write(object, doc, repr, flags); } return repr; @@ -407,8 +380,8 @@ sp_filter_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XM { //SPFilter *f = SP_FILTER(object); - if (((SPObjectClass *) filter_parent_class)->child_added) - (* ((SPObjectClass *) filter_parent_class)->child_added)(object, child, ref); + if (((SPObjectClass *) sp_filter_parent_class)->child_added) + (* ((SPObjectClass *) sp_filter_parent_class)->child_added)(object, child, ref); object->requestModified(SP_OBJECT_MODIFIED_FLAG); } @@ -421,8 +394,8 @@ sp_filter_remove_child(SPObject *object, Inkscape::XML::Node *child) { // SPFilter *f = SP_FILTER(object); - if (((SPObjectClass *) filter_parent_class)->remove_child) - (* ((SPObjectClass *) filter_parent_class)->remove_child)(object, child); + if (((SPObjectClass *) sp_filter_parent_class)->remove_child) + (* ((SPObjectClass *) sp_filter_parent_class)->remove_child)(object, child); object->requestModified(SP_OBJECT_MODIFIED_FLAG); } diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index dc5b1d8bd..1d95c2f8a 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -34,8 +34,6 @@ #include "display/drawing-text.h" -static void sp_flowtext_class_init(SPFlowtextClass *klass); -static void sp_flowtext_init(SPFlowtext *group); static void sp_flowtext_dispose(GObject *object); static void sp_flowtext_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); @@ -53,29 +51,7 @@ static void sp_flowtext_snappoints(SPItem const *item, std::vector<Inkscape::Sna static Inkscape::DrawingItem *sp_flowtext_show(SPItem *item, Inkscape::Drawing &drawing, unsigned key, unsigned flags); static void sp_flowtext_hide(SPItem *item, unsigned key); -static SPItemClass *parent_class; - -GType -sp_flowtext_get_type(void) -{ - static GType group_type = 0; - if (!group_type) { - GTypeInfo group_info = { - sizeof(SPFlowtextClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_flowtext_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPFlowtext), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_flowtext_init, - NULL, /* value_table */ - }; - group_type = g_type_register_static(SP_TYPE_ITEM, "SPFlowtext", &group_info, (GTypeFlags)0); - } - return group_type; -} +G_DEFINE_TYPE(SPFlowtext, sp_flowtext, SP_TYPE_ITEM); static void sp_flowtext_class_init(SPFlowtextClass *klass) @@ -84,8 +60,6 @@ sp_flowtext_class_init(SPFlowtextClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *) klass; SPItemClass *item_class = (SPItemClass *) klass; - parent_class = (SPItemClass *)g_type_class_ref(SP_TYPE_ITEM); - object_class->dispose = sp_flowtext_dispose; sp_object_class->child_added = sp_flowtext_child_added; @@ -122,8 +96,8 @@ sp_flowtext_dispose(GObject *object) static void sp_flowtext_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - if (((SPObjectClass *) (parent_class))->child_added) - (* ((SPObjectClass *) (parent_class))->child_added)(object, child, ref); + if (((SPObjectClass *) (sp_flowtext_parent_class))->child_added) + (* ((SPObjectClass *) (sp_flowtext_parent_class))->child_added)(object, child, ref); object->requestModified(SP_OBJECT_MODIFIED_FLAG); } @@ -133,8 +107,8 @@ sp_flowtext_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape:: static void sp_flowtext_remove_child(SPObject *object, Inkscape::XML::Node *child) { - if (((SPObjectClass *) (parent_class))->remove_child) - (* ((SPObjectClass *) (parent_class))->remove_child)(object, child); + if (((SPObjectClass *) (sp_flowtext_parent_class))->remove_child) + (* ((SPObjectClass *) (sp_flowtext_parent_class))->remove_child)(object, child); object->requestModified(SP_OBJECT_MODIFIED_FLAG); } @@ -145,8 +119,8 @@ static void sp_flowtext_update(SPObject *object, SPCtx *ctx, unsigned flags) SPItemCtx *ictx = (SPItemCtx *) ctx; SPItemCtx cctx = *ictx; - if (((SPObjectClass *) (parent_class))->update) { - ((SPObjectClass *) (parent_class))->update(object, ctx, flags); + if (((SPObjectClass *) (sp_flowtext_parent_class))->update) { + ((SPObjectClass *) (sp_flowtext_parent_class))->update(object, ctx, flags); } if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -225,8 +199,8 @@ sp_flowtext_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *r { object->_requireSVGVersion(Inkscape::Version(1, 2)); - if (((SPObjectClass *) (parent_class))->build) { - (* ((SPObjectClass *) (parent_class))->build)(object, document, repr); + if (((SPObjectClass *) (sp_flowtext_parent_class))->build) { + (* ((SPObjectClass *) (sp_flowtext_parent_class))->build)(object, document, repr); } object->readAttr( "inkscape:layoutOptions" ); // must happen after css has been read @@ -284,8 +258,8 @@ sp_flowtext_set(SPObject *object, unsigned key, gchar const *value) break; } default: - if (((SPObjectClass *) (parent_class))->set) { - (* ((SPObjectClass *) (parent_class))->set)(object, key, value); + if (((SPObjectClass *) (sp_flowtext_parent_class))->set) { + (* ((SPObjectClass *) (sp_flowtext_parent_class))->set)(object, key, value); } break; } @@ -320,8 +294,8 @@ static Inkscape::XML::Node *sp_flowtext_write(SPObject *object, Inkscape::XML::D } } - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_flowtext_parent_class))->write) { + ((SPObjectClass *) (sp_flowtext_parent_class))->write(object, xml_doc, repr, flags); } return repr; @@ -404,8 +378,8 @@ sp_flowtext_show(SPItem *item, Inkscape::Drawing &drawing, unsigned/* key*/, uns static void sp_flowtext_hide(SPItem *item, unsigned int key) { - if (((SPItemClass *) parent_class)->hide) - ((SPItemClass *) parent_class)->hide(item, key); + if (((SPItemClass *) sp_flowtext_parent_class)->hide) + ((SPItemClass *) sp_flowtext_parent_class)->hide(item, key); } diff --git a/src/sp-font-face.h b/src/sp-font-face.h index 691c1f883..57702b683 100644 --- a/src/sp-font-face.h +++ b/src/sp-font-face.h @@ -6,6 +6,8 @@ #ifndef __SP_FONTFACE_H__ #define __SP_FONTFACE_H__ +#include <vector> + /* * SVG <font-face> element implementation * diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp index 719375688..e14ef8667 100644 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@ -23,46 +23,18 @@ #include "document.h" #include <cstring> -static void sp_glyph_class_init(SPGlyphClass *gc); -static void sp_glyph_init(SPGlyph *glyph); - static void sp_glyph_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_glyph_release(SPObject *object); static void sp_glyph_set(SPObject *object, unsigned int key, const gchar *value); static Inkscape::XML::Node *sp_glyph_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_glyph_update(SPObject *object, SPCtx *ctx, guint flags); -static SPObjectClass *parent_class; - -GType sp_glyph_get_type(void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof(SPGlyphClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_glyph_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPGlyph), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_glyph_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_OBJECT, "SPGlyph", &info, (GTypeFlags) 0); - } - - return type; -} +G_DEFINE_TYPE(SPGlyph, sp_glyph, SP_TYPE_OBJECT); static void sp_glyph_class_init(SPGlyphClass *gc) { SPObjectClass *sp_object_class = (SPObjectClass *) gc; - parent_class = (SPObjectClass*)g_type_class_peek_parent(gc); - sp_object_class->build = sp_glyph_build; sp_object_class->release = sp_glyph_release; sp_object_class->set = sp_glyph_set; @@ -88,8 +60,8 @@ static void sp_glyph_init(SPGlyph *glyph) static void sp_glyph_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) (parent_class))->build) { - ((SPObjectClass *) (parent_class))->build(object, document, repr); + if (((SPObjectClass *) (sp_glyph_parent_class))->build) { + ((SPObjectClass *) (sp_glyph_parent_class))->build(object, document, repr); } object->readAttr( "unicode" ); @@ -108,8 +80,8 @@ static void sp_glyph_release(SPObject *object) { //SPGlyph *glyph = SP_GLYPH(object); - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release(object); + if (((SPObjectClass *) sp_glyph_parent_class)->release) { + ((SPObjectClass *) sp_glyph_parent_class)->release(object); } } @@ -233,8 +205,8 @@ static void sp_glyph_set(SPObject *object, unsigned int key, const gchar *value) } default: { - if (((SPObjectClass *) (parent_class))->set) { - ((SPObjectClass *) (parent_class))->set(object, key, value); + if (((SPObjectClass *) (sp_glyph_parent_class))->set) { + ((SPObjectClass *) (sp_glyph_parent_class))->set(object, key, value); } break; } @@ -264,8 +236,8 @@ sp_glyph_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "vert-adv-y" ); } - if (((SPObjectClass *) parent_class)->update) { - ((SPObjectClass *) parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_glyph_parent_class)->update) { + ((SPObjectClass *) sp_glyph_parent_class)->update(object, ctx, flags); } } @@ -306,8 +278,8 @@ static Inkscape::XML::Node *sp_glyph_write(SPObject *object, Inkscape::XML::Docu COPY_ATTR(repr, object->getRepr(), "vert-adv-y"); } - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_glyph_parent_class))->write) { + ((SPObjectClass *) (sp_glyph_parent_class))->write(object, xml_doc, repr, flags); } return repr; diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index 3b8999eda..e8629ff70 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -39,9 +39,6 @@ #include <algorithm> /* LPEItem base class */ - -static void sp_lpe_item_class_init(SPLPEItemClass *klass); -static void sp_lpe_item_init(SPLPEItem *lpe_item); static void sp_lpe_item_finalize(GObject *object); static void sp_lpe_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); @@ -64,34 +61,12 @@ typedef std::list<std::string> HRefList; static std::string patheffectlist_write_svg(PathEffectList const & list); static std::string hreflist_write_svg(HRefList const & list); -static SPItemClass *parent_class; - -GType -sp_lpe_item_get_type() -{ - static GType lpe_item_type = 0; - - if (!lpe_item_type) { - GTypeInfo lpe_item_info = { - sizeof(SPLPEItemClass), - NULL, NULL, - (GClassInitFunc) sp_lpe_item_class_init, - NULL, NULL, - sizeof(SPLPEItem), - 16, - (GInstanceInitFunc) sp_lpe_item_init, - NULL, /* value_table */ - }; - lpe_item_type = g_type_register_static(SP_TYPE_ITEM, "SPLPEItem", &lpe_item_info, (GTypeFlags)0); - } - return lpe_item_type; -} +G_DEFINE_TYPE(SPLPEItem, sp_lpe_item, SP_TYPE_ITEM); static void sp_lpe_item_class_init(SPLPEItemClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); SPObjectClass *sp_object_class = SP_OBJECT_CLASS(klass); - parent_class = SP_ITEM_CLASS(g_type_class_peek_parent(klass)); gobject_class->finalize = sp_lpe_item_finalize; sp_object_class->build = sp_lpe_item_build; @@ -119,8 +94,8 @@ sp_lpe_item_init(SPLPEItem *lpeitem) static void sp_lpe_item_finalize(GObject *object) { - if (((GObjectClass *) (parent_class))->finalize) { - (* ((GObjectClass *) (parent_class))->finalize)(object); + if (((GObjectClass *) (sp_lpe_item_parent_class))->finalize) { + (* ((GObjectClass *) (sp_lpe_item_parent_class))->finalize)(object); } } @@ -133,8 +108,8 @@ static void sp_lpe_item_build(SPObject *object, SPDocument *document, Inkscape:: { object->readAttr( "inkscape:path-effect" ); - if ((SP_OBJECT_CLASS(parent_class))->build) { - (SP_OBJECT_CLASS(parent_class))->build(object, document, repr); + if ((SP_OBJECT_CLASS(sp_lpe_item_parent_class))->build) { + (SP_OBJECT_CLASS(sp_lpe_item_parent_class))->build(object, document, repr); } } @@ -165,8 +140,8 @@ static void sp_lpe_item_release(SPObject *object) delete lpeitem->path_effect_list; lpeitem->path_effect_list = NULL; - if ((SP_OBJECT_CLASS(parent_class))->release) - (SP_OBJECT_CLASS(parent_class))->release(object); + if ((SP_OBJECT_CLASS(sp_lpe_item_parent_class))->release) + (SP_OBJECT_CLASS(sp_lpe_item_parent_class))->release(object); } /** @@ -234,8 +209,8 @@ static void sp_lpe_item_set(SPObject *object, unsigned int key, gchar const *val } break; default: - if ((SP_OBJECT_CLASS(parent_class))->set) { - (SP_OBJECT_CLASS(parent_class))->set(object, key, value); + if ((SP_OBJECT_CLASS(sp_lpe_item_parent_class))->set) { + (SP_OBJECT_CLASS(sp_lpe_item_parent_class))->set(object, key, value); } break; } @@ -247,8 +222,8 @@ static void sp_lpe_item_set(SPObject *object, unsigned int key, gchar const *val static void sp_lpe_item_update(SPObject *object, SPCtx *ctx, guint flags) { - if ((SP_OBJECT_CLASS(parent_class))->update) { - (SP_OBJECT_CLASS(parent_class))->update(object, ctx, flags); + if ((SP_OBJECT_CLASS(sp_lpe_item_parent_class))->update) { + (SP_OBJECT_CLASS(sp_lpe_item_parent_class))->update(object, ctx, flags); } // update the helperpaths of all LPEs applied to the item @@ -264,8 +239,8 @@ static void sp_lpe_item_modified (SPObject *object, unsigned int flags) sp_lpe_item_update_patheffect(SP_LPE_ITEM(object), true, true); } - if ((SP_OBJECT_CLASS(parent_class))->modified) { - (* (SP_OBJECT_CLASS(parent_class))->modified) (object, flags); + if ((SP_OBJECT_CLASS(sp_lpe_item_parent_class))->modified) { + (* (SP_OBJECT_CLASS(sp_lpe_item_parent_class))->modified) (object, flags); } } @@ -285,8 +260,8 @@ static Inkscape::XML::Node * sp_lpe_item_write(SPObject *object, Inkscape::XML:: } } - if ((SP_OBJECT_CLASS(parent_class))->write) { - (SP_OBJECT_CLASS(parent_class))->write(object, xml_doc, repr, flags); + if ((SP_OBJECT_CLASS(sp_lpe_item_parent_class))->write) { + (SP_OBJECT_CLASS(sp_lpe_item_parent_class))->write(object, xml_doc, repr, flags); } return repr; @@ -666,8 +641,8 @@ void sp_lpe_item_edit_next_param_oncanvas(SPLPEItem *lpeitem, SPDesktop *dt) static void sp_lpe_item_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - if ((SP_OBJECT_CLASS(parent_class))->child_added) - (* (SP_OBJECT_CLASS(parent_class))->child_added) (object, child, ref); + if ((SP_OBJECT_CLASS(sp_lpe_item_parent_class))->child_added) + (* (SP_OBJECT_CLASS(sp_lpe_item_parent_class))->child_added) (object, child, ref); if (SP_IS_LPE_ITEM(object) && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(object))) { SPObject *ochild = object->get_child_by_repr(child); @@ -686,8 +661,8 @@ static void sp_lpe_item_remove_child(SPObject * object, Inkscape::XML::Node * ch } } - if ((SP_OBJECT_CLASS(parent_class))->remove_child) - (* (SP_OBJECT_CLASS(parent_class))->remove_child) (object, child); + if ((SP_OBJECT_CLASS(sp_lpe_item_parent_class))->remove_child) + (* (SP_OBJECT_CLASS(sp_lpe_item_parent_class))->remove_child) (object, child); } static std::string patheffectlist_write_svg(PathEffectList const & list) diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index 785a626f8..4243c9811 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -34,9 +34,6 @@ struct SPMaskView { Geom::OptRect bbox; }; -static void sp_mask_class_init (SPMaskClass *klass); -static void sp_mask_init (SPMask *mask); - static void sp_mask_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_mask_release (SPObject * object); static void sp_mask_set (SPObject *object, unsigned int key, const gchar *value); @@ -48,33 +45,11 @@ static Inkscape::XML::Node *sp_mask_write (SPObject *object, Inkscape::XML::Docu SPMaskView *sp_mask_view_new_prepend (SPMaskView *list, unsigned int key, Inkscape::DrawingItem *arenaitem); SPMaskView *sp_mask_view_list_remove (SPMaskView *list, SPMaskView *view); -static SPObjectGroupClass *parent_class; - -GType -sp_mask_get_type (void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof (SPMaskClass), - NULL, NULL, - (GClassInitFunc) sp_mask_class_init, - NULL, NULL, - sizeof (SPMask), - 16, - (GInstanceInitFunc) sp_mask_init, - NULL, /* value_table */ - }; - type = g_type_register_static (SP_TYPE_OBJECTGROUP, "SPMask", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPMask, sp_mask, SP_TYPE_OBJECTGROUP); static void sp_mask_class_init (SPMaskClass *klass) { - parent_class = SP_OBJECTGROUP_CLASS(g_type_class_ref(SP_TYPE_OBJECTGROUP)); - SPObjectClass *sp_object_class = (SPObjectClass *) klass; sp_object_class->build = sp_mask_build; sp_object_class->release = sp_mask_release; @@ -100,8 +75,8 @@ sp_mask_init (SPMask *mask) static void sp_mask_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) parent_class)->build) { - ((SPObjectClass *) parent_class)->build (object, document, repr); + if (((SPObjectClass *) sp_mask_parent_class)->build) { + ((SPObjectClass *) sp_mask_parent_class)->build (object, document, repr); } object->readAttr( "maskUnits" ); @@ -124,8 +99,8 @@ static void sp_mask_release (SPObject * object) cp->display = sp_mask_view_list_remove (cp->display, cp->display); } - if (((SPObjectClass *) (parent_class))->release) { - ((SPObjectClass *) parent_class)->release (object); + if (((SPObjectClass *) (sp_mask_parent_class))->release) { + ((SPObjectClass *) sp_mask_parent_class)->release (object); } } @@ -162,8 +137,8 @@ sp_mask_set (SPObject *object, unsigned int key, const gchar *value) object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set (object, key, value); + if (((SPObjectClass *) sp_mask_parent_class)->set) + ((SPObjectClass *) sp_mask_parent_class)->set (object, key, value); break; } } @@ -172,7 +147,7 @@ static void sp_mask_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { /* Invoke SPObjectGroup implementation */ - ((SPObjectClass *) (parent_class))->child_added (object, child, ref); + ((SPObjectClass *) (sp_mask_parent_class))->child_added (object, child, ref); /* Show new object */ SPObject *ochild = object->document->getObjectByRepr(child); @@ -258,8 +233,8 @@ sp_mask_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML repr = xml_doc->createElement("svg:mask"); } - if (((SPObjectClass *) (parent_class))->write) - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_mask_parent_class))->write) + ((SPObjectClass *) (sp_mask_parent_class))->write (object, xml_doc, repr, flags); return repr; } diff --git a/src/sp-metadata.cpp b/src/sp-metadata.cpp index 831bb5a70..9978d0a3a 100644 --- a/src/sp-metadata.cpp +++ b/src/sp-metadata.cpp @@ -33,46 +33,19 @@ /* Metadata base class */ -static void sp_metadata_class_init (SPMetadataClass *klass); -static void sp_metadata_init (SPMetadata *metadata); - static void sp_metadata_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); static void sp_metadata_release (SPObject *object); static void sp_metadata_set (SPObject *object, unsigned int key, const gchar *value); static void sp_metadata_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_metadata_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPObjectClass *metadata_parent_class; - -GType -sp_metadata_get_type (void) -{ - static GType metadata_type = 0; - - if (!metadata_type) { - GTypeInfo metadata_info = { - sizeof (SPMetadataClass), - NULL, NULL, - (GClassInitFunc) sp_metadata_class_init, - NULL, NULL, - sizeof (SPMetadata), - 16, - (GInstanceInitFunc) sp_metadata_init, - NULL, /* value_table */ - }; - metadata_type = g_type_register_static (SP_TYPE_OBJECT, "SPMetadata", &metadata_info, (GTypeFlags)0); - } - return metadata_type; -} +G_DEFINE_TYPE(SPMetadata, sp_metadata, SP_TYPE_OBJECT); static void sp_metadata_class_init (SPMetadataClass *klass) { - //GObjectClass *gobject_class = (GObjectClass *)klass; SPObjectClass *sp_object_class = (SPObjectClass *)klass; - metadata_parent_class = (SPObjectClass*)g_type_class_peek_parent (klass); - sp_object_class->build = sp_metadata_build; sp_object_class->release = sp_metadata_release; sp_object_class->write = sp_metadata_write; @@ -123,8 +96,8 @@ static void sp_metadata_build(SPObject *object, SPDocument *document, Inkscape:: } } - if (((SPObjectClass *) metadata_parent_class)->build) - ((SPObjectClass *) metadata_parent_class)->build (object, document, repr); + if (((SPObjectClass *) sp_metadata_parent_class)->build) + ((SPObjectClass *) sp_metadata_parent_class)->build (object, document, repr); } /** @@ -136,8 +109,8 @@ static void sp_metadata_release(SPObject *object) // handle ourself - if (((SPObjectClass *) metadata_parent_class)->release) - ((SPObjectClass *) metadata_parent_class)->release (object); + if (((SPObjectClass *) sp_metadata_parent_class)->release) + ((SPObjectClass *) sp_metadata_parent_class)->release (object); } /** @@ -150,8 +123,8 @@ static void sp_metadata_set(SPObject *object, unsigned int key, const gchar *val SP_METADATA(object); // ensures the object is of the proper type. // see if any parents need this value - if (reinterpret_cast<SPObjectClass *>(metadata_parent_class)->set) { - reinterpret_cast<SPObjectClass *>(metadata_parent_class)->set(object, key, value); + if (reinterpret_cast<SPObjectClass *>(sp_metadata_parent_class)->set) { + reinterpret_cast<SPObjectClass *>(sp_metadata_parent_class)->set(object, key, value); } } @@ -170,8 +143,8 @@ static void sp_metadata_update(SPObject *object, SPCtx *ctx, guint flags) } - if (((SPObjectClass *) metadata_parent_class)->update) - ((SPObjectClass *) metadata_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_metadata_parent_class)->update) + ((SPObjectClass *) sp_metadata_parent_class)->update(object, ctx, flags); } /** @@ -190,8 +163,8 @@ static Inkscape::XML::Node *sp_metadata_write(SPObject *object, Inkscape::XML::D } } - if (((SPObjectClass *) metadata_parent_class)->write) { - ((SPObjectClass *) metadata_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_metadata_parent_class)->write) { + ((SPObjectClass *) sp_metadata_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/sp-missing-glyph.cpp b/src/sp-missing-glyph.cpp index fdf75253e..bdf993e5b 100644 --- a/src/sp-missing-glyph.cpp +++ b/src/sp-missing-glyph.cpp @@ -21,45 +21,17 @@ #include "sp-missing-glyph.h" #include "document.h" -static void sp_missing_glyph_class_init(SPMissingGlyphClass *gc); -static void sp_missing_glyph_init(SPMissingGlyph *glyph); - static void sp_missing_glyph_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_missing_glyph_release(SPObject *object); static void sp_missing_glyph_set(SPObject *object, unsigned int key, const gchar *value); static Inkscape::XML::Node *sp_missing_glyph_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPObjectClass *parent_class; - -GType sp_missing_glyph_get_type(void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof(SPMissingGlyphClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_missing_glyph_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPMissingGlyph), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_missing_glyph_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_OBJECT, "SPMissingGlyph", &info, (GTypeFlags) 0); - } - - return type; -} +G_DEFINE_TYPE(SPMissingGlyph, sp_missing_glyph, SP_TYPE_OBJECT); static void sp_missing_glyph_class_init(SPMissingGlyphClass *gc) { SPObjectClass *sp_object_class = (SPObjectClass *) gc; - parent_class = (SPObjectClass*)g_type_class_peek_parent(gc); - sp_object_class->build = sp_missing_glyph_build; sp_object_class->release = sp_missing_glyph_release; sp_object_class->set = sp_missing_glyph_set; @@ -78,8 +50,8 @@ static void sp_missing_glyph_init(SPMissingGlyph *glyph) static void sp_missing_glyph_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) (parent_class))->build) { - ((SPObjectClass *) (parent_class))->build(object, document, repr); + if (((SPObjectClass *) (sp_missing_glyph_parent_class))->build) { + ((SPObjectClass *) (sp_missing_glyph_parent_class))->build(object, document, repr); } object->readAttr( "d" ); @@ -93,8 +65,8 @@ static void sp_missing_glyph_release(SPObject *object) { //SPMissingGlyph *glyph = SP_MISSING_GLYPH(object); - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release(object); + if (((SPObjectClass *) sp_missing_glyph_parent_class)->release) { + ((SPObjectClass *) sp_missing_glyph_parent_class)->release(object); } } @@ -150,8 +122,8 @@ static void sp_missing_glyph_set(SPObject *object, unsigned int key, const gchar } default: { - if (((SPObjectClass *) (parent_class))->set) { - ((SPObjectClass *) (parent_class))->set(object, key, value); + if (((SPObjectClass *) (sp_missing_glyph_parent_class))->set) { + ((SPObjectClass *) (sp_missing_glyph_parent_class))->set(object, key, value); } break; } @@ -186,8 +158,8 @@ static Inkscape::XML::Node *sp_missing_glyph_write(SPObject *object, Inkscape::X COPY_ATTR(repr, object->getRepr(), "vert-adv-y"); } - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_missing_glyph_parent_class))->write) { + ((SPObjectClass *) (sp_missing_glyph_parent_class))->write(object, xml_doc, repr, flags); } return repr; diff --git a/src/sp-object.h b/src/sp-object.h index b3f3e6c2f..5828eda13 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -800,10 +800,7 @@ private: public: - /** - * Registers the SPObject class with Gdk and returns its type number. - */ - static GType get_type(); + static GType get_type() {return sp_object_get_type();} /** * Callback for attr_changed node event. diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index bc8a46252..95511aea3 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -68,8 +68,6 @@ class SPDocument; * radius (look in object-edit). */ -static void sp_offset_class_init (SPOffsetClass * klass); -static void sp_offset_init (SPOffset * offset); static void sp_offset_finalize(GObject *obj); static void sp_offset_build (SPObject * object, SPDocument * document, @@ -102,38 +100,7 @@ static void sp_offset_source_modified (SPObject *iSource, guint flags, SPItem *i // reappearing in offset when the radius becomes too large static bool use_slow_but_correct_offset_method=false; - -// nothing special here, same for every class in sodipodi/inkscape -static SPShapeClass *parent_class; - -/** - * Register SPOffset class and return its type number. - */ -GType -sp_offset_get_type (void) -{ - static GType offset_type = 0; - - if (!offset_type) - { - GTypeInfo offset_info = { - sizeof (SPOffsetClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_offset_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (SPOffset), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_offset_init, - NULL, /* value_table */ - }; - offset_type = - g_type_register_static (SP_TYPE_SHAPE, "SPOffset", &offset_info, - (GTypeFlags) 0); - } - return offset_type; -} +G_DEFINE_TYPE(SPOffset, sp_offset, SP_TYPE_SHAPE); /** * SPOffset vtable initialization. @@ -146,8 +113,6 @@ sp_offset_class_init(SPOffsetClass *klass) SPItemClass *item_class = (SPItemClass *) klass; SPShapeClass *shape_class = (SPShapeClass *) klass; - parent_class = (SPShapeClass *) g_type_class_ref (SP_TYPE_SHAPE); - gobject_class->finalize = sp_offset_finalize; sp_object_class->build = sp_offset_build; @@ -213,8 +178,8 @@ sp_offset_finalize(GObject *obj) static void sp_offset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) parent_class)->build) - ((SPObjectClass *) parent_class)->build (object, document, repr); + if (((SPObjectClass *) sp_offset_parent_class)->build) + ((SPObjectClass *) sp_offset_parent_class)->build (object, document, repr); //XML Tree being used directly here while it shouldn't be. if (object->getRepr()->attribute("inkscape:radius")) { @@ -290,8 +255,8 @@ sp_offset_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XM repr->setAttribute("d", d); g_free (d); - if (((SPObjectClass *) (parent_class))->write) - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, + if (((SPObjectClass *) (sp_offset_parent_class))->write) + ((SPObjectClass *) (sp_offset_parent_class))->write (object, xml_doc, repr, flags | SP_SHAPE_WRITE_PATH); return repr; @@ -317,8 +282,8 @@ sp_offset_release(SPObject *object) offset->sourceHref = NULL; offset->sourceRef->detach(); - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release (object); + if (((SPObjectClass *) sp_offset_parent_class)->release) { + ((SPObjectClass *) sp_offset_parent_class)->release (object); } } @@ -389,8 +354,8 @@ sp_offset_set(SPObject *object, unsigned key, gchar const *value) } break; default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set (object, key, value); + if (((SPObjectClass *) sp_offset_parent_class)->set) + ((SPObjectClass *) sp_offset_parent_class)->set (object, key, value); break; } } @@ -411,8 +376,8 @@ sp_offset_update(SPObject *object, SPCtx *ctx, guint flags) } offset->isUpdating=false; - if (((SPObjectClass *) parent_class)->update) - ((SPObjectClass *) parent_class)->update (object, ctx, flags); + if (((SPObjectClass *) sp_offset_parent_class)->update) + ((SPObjectClass *) sp_offset_parent_class)->update (object, ctx, flags); } /** @@ -725,8 +690,8 @@ sp_offset_set_shape(SPShape *shape) */ static void sp_offset_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) { - if (((SPItemClass *) parent_class)->snappoints) { - ((SPItemClass *) parent_class)->snappoints (item, p, snapprefs); + if (((SPItemClass *) sp_offset_parent_class)->snappoints) { + ((SPItemClass *) sp_offset_parent_class)->snappoints (item, p, snapprefs); } } diff --git a/src/sp-paint-server.cpp b/src/sp-paint-server.cpp index ae4a60ba6..298b39117 100644 --- a/src/sp-paint-server.cpp +++ b/src/sp-paint-server.cpp @@ -20,12 +20,8 @@ #include "sp-gradient.h" #include "xml/node.h" -static void sp_paint_server_class_init(SPPaintServerClass *psc); - static cairo_pattern_t *sp_paint_server_create_dummy_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity); -static SPObjectClass *parent_class; - SPPaintServer *SPPaintServerReference::getObject() const { return static_cast<SPPaintServer *>(URIReference::getObject()); @@ -36,35 +32,15 @@ bool SPPaintServerReference::_acceptObject(SPObject *obj) const return SP_IS_PAINT_SERVER(obj); } -GType SPPaintServer::get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPPaintServerClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_paint_server_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPPaintServer), - 16, /* n_preallocs */ - (GInstanceInitFunc) SPPaintServer::init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_OBJECT, "SPPaintServer", &info, (GTypeFlags) 0); - } - return type; -} +G_DEFINE_TYPE(SPPaintServer, sp_paint_server, SP_TYPE_OBJECT); static void sp_paint_server_class_init(SPPaintServerClass *psc) { psc->pattern_new = sp_paint_server_create_dummy_pattern; - - parent_class = static_cast<SPObjectClass *>(g_type_class_ref(SP_TYPE_OBJECT)); } -void SPPaintServer::init(SPPaintServer * /*ps*/) +static void +sp_paint_server_init(SPPaintServer * /*ps*/) { } diff --git a/src/sp-paint-server.h b/src/sp-paint-server.h index a266ee5a5..f4948dfdb 100644 --- a/src/sp-paint-server.h +++ b/src/sp-paint-server.h @@ -20,24 +20,21 @@ #include "sp-object.h" #include "uri-references.h" -#define SP_TYPE_PAINT_SERVER (SPPaintServer::get_type()) +#define SP_TYPE_PAINT_SERVER (sp_paint_server_get_type()) #define SP_PAINT_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_PAINT_SERVER, SPPaintServer)) #define SP_PAINT_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_PAINT_SERVER, SPPaintServerClass)) #define SP_IS_PAINT_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_PAINT_SERVER)) #define SP_IS_PAINT_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_PAINT_SERVER)) +GType sp_paint_server_get_type(void) G_GNUC_CONST; + struct SPPaintServer : public SPObject { protected: bool swatch; public: - static GType get_type(void); - bool isSwatch() const; bool isSolid() const; - -private: - static void init(SPPaintServer *ps); }; struct SPPaintServerClass { diff --git a/src/sp-path.cpp b/src/sp-path.cpp index 107ceac16..478a689e3 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -51,8 +51,6 @@ #define noPATH_VERBOSE -static void sp_path_class_init(SPPathClass *klass); -static void sp_path_init(SPPath *path); static void sp_path_finalize(GObject *obj); static void sp_path_release(SPObject *object); @@ -67,31 +65,7 @@ static void sp_path_convert_to_guides(SPItem *item); static void sp_path_update(SPObject *object, SPCtx *ctx, guint flags); static void sp_path_update_patheffect(SPLPEItem *lpeitem, bool write); -static SPShapeClass *parent_class; - -/** - * Gets the GType object for SPPathClass - */ -GType -sp_path_get_type(void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof(SPPathClass), - NULL, NULL, - (GClassInitFunc) sp_path_class_init, - NULL, NULL, - sizeof(SPPath), - 16, - (GInstanceInitFunc) sp_path_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_SHAPE, "SPPath", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPPath, sp_path, SP_TYPE_SHAPE); /** * Does the object-oriented work of initializing the class structure @@ -106,8 +80,6 @@ sp_path_class_init(SPPathClass * klass) SPItemClass *item_class = (SPItemClass *) klass; SPLPEItemClass *lpe_item_class = (SPLPEItemClass *) klass; - parent_class = (SPShapeClass *)g_type_class_peek_parent(klass); - gobject_class->finalize = sp_path_finalize; sp_object_class->build = sp_path_build; @@ -216,8 +188,8 @@ sp_path_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) sp_conn_end_pair_build(object); - if (((SPObjectClass *) parent_class)->build) { - ((SPObjectClass *) parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_path_parent_class)->build) { + ((SPObjectClass *) sp_path_parent_class)->build(object, document, repr); } object->readAttr( "inkscape:original-d" ); @@ -237,8 +209,8 @@ sp_path_release(SPObject *object) path->connEndPair.release(); - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release(object); + if (((SPObjectClass *) sp_path_parent_class)->release) { + ((SPObjectClass *) sp_path_parent_class)->release(object); } } @@ -294,8 +266,8 @@ sp_path_set(SPObject *object, unsigned int key, gchar const *value) path->connEndPair.setAttr(key, value); break; default: - if (((SPObjectClass *) parent_class)->set) { - ((SPObjectClass *) parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_path_parent_class)->set) { + ((SPObjectClass *) sp_path_parent_class)->set(object, key, value); } break; } @@ -337,8 +309,8 @@ g_message("sp_path_write writes 'd' attribute"); SP_PATH(shape)->connEndPair.writeRepr(repr); - if (((SPObjectClass *)(parent_class))->write) { - ((SPObjectClass *)(parent_class))->write(object, xml_doc, repr, flags); + if (((SPObjectClass *)(sp_path_parent_class))->write) { + ((SPObjectClass *)(sp_path_parent_class))->write(object, xml_doc, repr, flags); } return repr; @@ -351,8 +323,8 @@ sp_path_update(SPObject *object, SPCtx *ctx, guint flags) flags &= ~SP_OBJECT_USER_MODIFIED_FLAG_B; // since we change the description, it's not a "just translation" anymore } - if (((SPObjectClass *) parent_class)->update) { - ((SPObjectClass *) parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_path_parent_class)->update) { + ((SPObjectClass *) sp_path_parent_class)->update(object, ctx, flags); } SPPath *path = SP_PATH(object); diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index f18199e96..754a75e87 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -40,10 +40,6 @@ /* * Pattern */ - -static void sp_pattern_class_init (SPPatternClass *klass); -static void sp_pattern_init (SPPattern *gr); - static void sp_pattern_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_pattern_release (SPObject *object); static void sp_pattern_set (SPObject *object, unsigned int key, const gchar *value); @@ -55,29 +51,7 @@ static void pattern_ref_modified (SPObject *ref, guint flags, SPPattern *pattern static cairo_pattern_t *sp_pattern_create_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity); -static SPPaintServerClass * pattern_parent_class; - -GType -sp_pattern_get_type (void) -{ - static GType pattern_type = 0; - if (!pattern_type) { - GTypeInfo pattern_info = { - sizeof (SPPatternClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_pattern_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (SPPattern), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_pattern_init, - NULL, /* value_table */ - }; - pattern_type = g_type_register_static (SP_TYPE_PAINT_SERVER, "SPPattern", &pattern_info, (GTypeFlags)0); - } - return pattern_type; -} +G_DEFINE_TYPE(SPPattern, sp_pattern, SP_TYPE_PAINT_SERVER); static void sp_pattern_class_init (SPPatternClass *klass) @@ -88,8 +62,6 @@ sp_pattern_class_init (SPPatternClass *klass) sp_object_class = (SPObjectClass *) klass; ps_class = (SPPaintServerClass *) klass; - pattern_parent_class = (SPPaintServerClass*)g_type_class_ref (SP_TYPE_PAINT_SERVER); - sp_object_class->build = sp_pattern_build; sp_object_class->release = sp_pattern_release; sp_object_class->set = sp_pattern_set; @@ -129,8 +101,8 @@ sp_pattern_init (SPPattern *pat) static void sp_pattern_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) pattern_parent_class)->build) - (* ((SPObjectClass *) pattern_parent_class)->build) (object, document, repr); + if (((SPObjectClass *) sp_pattern_parent_class)->build) + (* ((SPObjectClass *) sp_pattern_parent_class)->build) (object, document, repr); object->readAttr( "patternUnits" ); object->readAttr( "patternContentUnits" ); @@ -164,8 +136,8 @@ static void sp_pattern_release(SPObject *object) pat->modified_connection.~connection(); - if (((SPObjectClass *) pattern_parent_class)->release) { - ((SPObjectClass *) pattern_parent_class)->release (object); + if (((SPObjectClass *) sp_pattern_parent_class)->release) { + ((SPObjectClass *) sp_pattern_parent_class)->release (object); } } @@ -280,8 +252,8 @@ sp_pattern_set (SPObject *object, unsigned int key, const gchar *value) } break; default: - if (((SPObjectClass *) pattern_parent_class)->set) - ((SPObjectClass *) pattern_parent_class)->set (object, key, value); + if (((SPObjectClass *) sp_pattern_parent_class)->set) + ((SPObjectClass *) sp_pattern_parent_class)->set (object, key, value); break; } } diff --git a/src/sp-style-elem.cpp b/src/sp-style-elem.cpp index 2e14ae5ff..da7a575b7 100644 --- a/src/sp-style-elem.cpp +++ b/src/sp-style-elem.cpp @@ -7,42 +7,16 @@ #include "style.h" using Inkscape::XML::TEXT_NODE; -static void sp_style_elem_init(SPStyleElem *style_elem); -static void sp_style_elem_class_init(SPStyleElemClass *klass); static void sp_style_elem_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr); static void sp_style_elem_set(SPObject *object, unsigned const key, gchar const *const value); static void sp_style_elem_read_content(SPObject *); static Inkscape::XML::Node *sp_style_elem_write(SPObject *, Inkscape::XML::Document *, Inkscape::XML::Node *, guint flags); -static SPObjectClass *parent_class; - -GType -sp_style_elem_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPStyleElemClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_style_elem_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPStyleElem), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_style_elem_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_OBJECT, "SPStyleElem", &info, (GTypeFlags) 0); - } - - return type; -} +G_DEFINE_TYPE(SPStyleElem, sp_style_elem, SP_TYPE_OBJECT); static void sp_style_elem_class_init(SPStyleElemClass *klass) { - parent_class = (SPObjectClass *)g_type_class_ref(SP_TYPE_OBJECT); /* FIXME */ klass->build = sp_style_elem_build; @@ -89,8 +63,8 @@ sp_style_elem_set(SPObject *object, unsigned const key, gchar const *const value /* title is ignored. */ default: { - if (parent_class->set) { - parent_class->set(object, key, value); + if (SP_OBJECT_CLASS(sp_style_elem_parent_class)->set) { + SP_OBJECT_CLASS(sp_style_elem_parent_class)->set(object, key, value); } break; } @@ -138,8 +112,8 @@ sp_style_elem_write(SPObject *const object, Inkscape::XML::Document *xml_doc, In } /* todo: media */ - if (((SPObjectClass *) parent_class)->write) - ((SPObjectClass *) parent_class)->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) sp_style_elem_parent_class)->write) + ((SPObjectClass *) sp_style_elem_parent_class)->write(object, xml_doc, repr, flags); return repr; } @@ -402,8 +376,8 @@ sp_style_elem_build(SPObject *object, SPDocument *document, Inkscape::XML::Node }; rec_add_listener(*repr, &nodeEventVector, object); - if (((SPObjectClass *) parent_class)->build) { - ((SPObjectClass *) parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_style_elem_parent_class)->build) { + ((SPObjectClass *) sp_style_elem_parent_class)->build(object, document, repr); } } diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 56f862bf3..d4db403e3 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -26,9 +26,6 @@ #include "sp-symbol.h" #include "document.h" -static void sp_symbol_class_init (SPSymbolClass *klass); -static void sp_symbol_init (SPSymbol *symbol); - static void sp_symbol_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_symbol_release (SPObject *object); static void sp_symbol_set (SPObject *object, unsigned int key, const gchar *value); @@ -42,35 +39,13 @@ static void sp_symbol_hide (SPItem *item, unsigned int key); static Geom::OptRect sp_symbol_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type); static void sp_symbol_print (SPItem *item, SPPrintContext *ctx); -static SPGroupClass *parent_class; - -GType -sp_symbol_get_type (void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof (SPSymbolClass), - NULL, NULL, - (GClassInitFunc) sp_symbol_class_init, - NULL, NULL, - sizeof (SPSymbol), - 16, - (GInstanceInitFunc) sp_symbol_init, - NULL, /* value_table */ - }; - type = g_type_register_static (SP_TYPE_GROUP, "SPSymbol", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPSymbol, sp_symbol, SP_TYPE_GROUP); static void sp_symbol_class_init(SPSymbolClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *) klass; SPItemClass *sp_item_class = (SPItemClass *) klass; - parent_class = (SPGroupClass *)g_type_class_ref (SP_TYPE_GROUP); - sp_object_class->build = sp_symbol_build; sp_object_class->release = sp_symbol_release; sp_object_class->set = sp_symbol_set; @@ -97,15 +72,15 @@ static void sp_symbol_build(SPObject *object, SPDocument *document, Inkscape::XM object->readAttr( "viewBox" ); object->readAttr( "preserveAspectRatio" ); - if (((SPObjectClass *) parent_class)->build) { - ((SPObjectClass *) parent_class)->build (object, document, repr); + if (((SPObjectClass *) sp_symbol_parent_class)->build) { + ((SPObjectClass *) sp_symbol_parent_class)->build (object, document, repr); } } static void sp_symbol_release(SPObject *object) { - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release (object); + if (((SPObjectClass *) sp_symbol_parent_class)->release) { + ((SPObjectClass *) sp_symbol_parent_class)->release (object); } } @@ -202,16 +177,16 @@ static void sp_symbol_set(SPObject *object, unsigned int key, const gchar *value } break; default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set (object, key, value); + if (((SPObjectClass *) sp_symbol_parent_class)->set) + ((SPObjectClass *) sp_symbol_parent_class)->set (object, key, value); break; } } static void sp_symbol_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - if (((SPObjectClass *) (parent_class))->child_added) { - ((SPObjectClass *) (parent_class))->child_added (object, child, ref); + if (((SPObjectClass *) (sp_symbol_parent_class))->child_added) { + ((SPObjectClass *) (sp_symbol_parent_class))->child_added (object, child, ref); } } @@ -315,8 +290,8 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) } // And invoke parent method - if (((SPObjectClass *) (parent_class))->update) { - ((SPObjectClass *) (parent_class))->update (object, (SPCtx *) &rctx, flags); + if (((SPObjectClass *) (sp_symbol_parent_class))->update) { + ((SPObjectClass *) (sp_symbol_parent_class))->update (object, (SPCtx *) &rctx, flags); } // As last step set additional transform of drawing group @@ -326,8 +301,8 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) } } else { // No-op - if (((SPObjectClass *) (parent_class))->update) { - ((SPObjectClass *) (parent_class))->update (object, ctx, flags); + if (((SPObjectClass *) (sp_symbol_parent_class))->update) { + ((SPObjectClass *) (sp_symbol_parent_class))->update (object, ctx, flags); } } } @@ -336,8 +311,8 @@ static void sp_symbol_modified(SPObject *object, guint flags) { SP_SYMBOL(object); - if (((SPObjectClass *) (parent_class))->modified) { - (* ((SPObjectClass *) (parent_class))->modified) (object, flags); + if (((SPObjectClass *) (sp_symbol_parent_class))->modified) { + (* ((SPObjectClass *) (sp_symbol_parent_class))->modified) (object, flags); } } @@ -355,8 +330,8 @@ static Inkscape::XML::Node *sp_symbol_write(SPObject *object, Inkscape::XML::Doc //XML Tree being used directly here while it shouldn't be. repr->setAttribute("preserveAspectRatio", object->getRepr()->attribute("preserveAspectRatio")); - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_symbol_parent_class))->write) { + ((SPObjectClass *) (sp_symbol_parent_class))->write (object, xml_doc, repr, flags); } return repr; @@ -369,8 +344,8 @@ static Inkscape::DrawingItem *sp_symbol_show(SPItem *item, Inkscape::Drawing &dr if (symbol->cloned) { // Cloned <symbol> is actually renderable - if (((SPItemClass *) (parent_class))->show) { - ai = ((SPItemClass *) (parent_class))->show (item, drawing, key, flags); + if (((SPItemClass *) (sp_symbol_parent_class))->show) { + ai = ((SPItemClass *) (sp_symbol_parent_class))->show (item, drawing, key, flags); Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(ai); if (g) { g->setChildTransform(symbol->c2p); @@ -387,8 +362,8 @@ static void sp_symbol_hide(SPItem *item, unsigned int key) if (symbol->cloned) { /* Cloned <symbol> is actually renderable */ - if (((SPItemClass *) (parent_class))->hide) { - ((SPItemClass *) (parent_class))->hide (item, key); + if (((SPItemClass *) (sp_symbol_parent_class))->hide) { + ((SPItemClass *) (sp_symbol_parent_class))->hide (item, key); } } } @@ -401,15 +376,15 @@ static Geom::OptRect sp_symbol_bbox(SPItem const *item, Geom::Affine const &tran if (symbol->cloned) { // Cloned <symbol> is actually renderable - if (((SPItemClass *) (parent_class))->bbox) { + if (((SPItemClass *) (sp_symbol_parent_class))->bbox) { Geom::Affine const a( symbol->c2p * transform ); - bbox = ((SPItemClass *) (parent_class))->bbox(item, a, type); + bbox = ((SPItemClass *) (sp_symbol_parent_class))->bbox(item, a, type); } } else { // Need bounding box for Symbols dialog Geom::Affine const a; - bbox = ((SPItemClass *) (parent_class))->bbox(item, a, type); + bbox = ((SPItemClass *) (sp_symbol_parent_class))->bbox(item, a, type); } return bbox; } @@ -422,8 +397,8 @@ static void sp_symbol_print(SPItem *item, SPPrintContext *ctx) sp_print_bind(ctx, symbol->c2p, 1.0); - if (((SPItemClass *) (parent_class))->print) { - ((SPItemClass *) (parent_class))->print (item, ctx); + if (((SPItemClass *) (sp_symbol_parent_class))->print) { + ((SPItemClass *) (sp_symbol_parent_class))->print (item, ctx); } sp_print_release (ctx); diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 1b4246483..8d42b7d59 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -384,7 +384,7 @@ static char * sp_text_description(SPItem *item) char name_buf[256]; char *n; if (tf) { - tf->Name(name_buf, sizeof(name_buf)); + tf->Family(name_buf, sizeof(name_buf)); n = xml_quote_strdup(name_buf); tf->Unref(); } else { diff --git a/src/sp-title.cpp b/src/sp-title.cpp index ddeccede2..489a6f448 100644 --- a/src/sp-title.cpp +++ b/src/sp-title.cpp @@ -16,38 +16,14 @@ #include "sp-title.h" #include "xml/repr.h" -static void sp_title_class_init(SPTitleClass *klass); -static void sp_title_init(SPTitle *rect); static Inkscape::XML::Node *sp_title_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPObjectClass *title_parent_class; - -GType -sp_title_get_type (void) -{ - static GType title_type = 0; - - if (!title_type) { - GTypeInfo title_info = { - sizeof (SPTitleClass), - NULL, NULL, - (GClassInitFunc) sp_title_class_init, - NULL, NULL, - sizeof (SPTitle), - 16, - (GInstanceInitFunc) sp_title_init, - NULL, /* value_table */ - }; - title_type = g_type_register_static (SP_TYPE_OBJECT, "SPTitle", &title_info, (GTypeFlags)0); - } - return title_type; -} +G_DEFINE_TYPE(SPTitle, sp_title, SP_TYPE_OBJECT); static void sp_title_class_init(SPTitleClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *) klass; - title_parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT); sp_object_class->write = sp_title_write; } @@ -66,8 +42,8 @@ static Inkscape::XML::Node *sp_title_write(SPObject *object, Inkscape::XML::Docu repr = object->getRepr()->duplicate(doc); } - if (((SPObjectClass *) title_parent_class)->write) { - ((SPObjectClass *) title_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_title_parent_class)->write) { + ((SPObjectClass *) sp_title_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/splivarot.cpp b/src/splivarot.cpp index f4e4ff4e8..c3243930d 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1201,8 +1201,8 @@ sp_selected_path_outline(SPDesktop *desktop) break; } - if (o_width < 0.1) - o_width = 0.1; + if (o_width < 0.032) + o_width = 0.032; o_miter = i_style->stroke_miterlimit.value * o_width; } diff --git a/src/text-context.cpp b/src/text-context.cpp index 90715b805..1ee21e732 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -57,8 +57,6 @@ using Inkscape::ControlManager; using Inkscape::DocumentUndo; -static void sp_text_context_class_init(SPTextContextClass *klass); -static void sp_text_context_init(SPTextContext *text_context); static void sp_text_context_dispose(GObject *obj); static void sp_text_context_setup(SPEventContext *ec); @@ -81,34 +79,13 @@ static gint sptc_focus_in(GtkWidget *widget, GdkEventFocus *event, SPTextContext static gint sptc_focus_out(GtkWidget *widget, GdkEventFocus *event, SPTextContext *tc); static void sptc_commit(GtkIMContext *imc, gchar *string, SPTextContext *tc); -static SPEventContextClass *parent_class; - -GType sp_text_context_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPTextContextClass), - NULL, NULL, - (GClassInitFunc) sp_text_context_class_init, - NULL, NULL, - sizeof(SPTextContext), - 4, - (GInstanceInitFunc) sp_text_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPTextContext", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPTextContext, sp_text_context, SP_TYPE_EVENT_CONTEXT); static void sp_text_context_class_init(SPTextContextClass *klass) { GObjectClass *object_class=G_OBJECT_CLASS(klass); SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass); - parent_class = SP_EVENT_CONTEXT_CLASS(g_type_class_peek_parent(klass)); - object_class->dispose = sp_text_context_dispose; event_context_class->setup = sp_text_context_setup; @@ -173,8 +150,8 @@ static void sp_text_context_dispose(GObject *obj) tc->text_sel_end.~iterator(); tc->text_sel_start.~iterator(); tc->text_selection_quads.~vector(); - if (G_OBJECT_CLASS(parent_class)->dispose) { - G_OBJECT_CLASS(parent_class)->dispose(obj); + if (G_OBJECT_CLASS(sp_text_context_parent_class)->dispose) { + G_OBJECT_CLASS(sp_text_context_parent_class)->dispose(obj); } if (tc->grabbed) { sp_canvas_item_ungrab(tc->grabbed, GDK_CURRENT_TIME); @@ -236,8 +213,8 @@ static void sp_text_context_setup(SPEventContext *ec) } } - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->setup) - (SP_EVENT_CONTEXT_CLASS(parent_class))->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_text_context_parent_class))->setup) + (SP_EVENT_CONTEXT_CLASS(sp_text_context_parent_class))->setup(ec); ec->shape_editor = new ShapeEditor(ec->desktop); @@ -455,8 +432,8 @@ static gint sp_text_context_item_handler(SPEventContext *event_context, SPItem * } if (!ret) { - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->item_handler) - ret = (SP_EVENT_CONTEXT_CLASS(parent_class))->item_handler(event_context, item, event); + if ((SP_EVENT_CONTEXT_CLASS(sp_text_context_parent_class))->item_handler) + ret = (SP_EVENT_CONTEXT_CLASS(sp_text_context_parent_class))->item_handler(event_context, item, event); } return ret; @@ -1324,8 +1301,8 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd } // if nobody consumed it so far - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler) { // and there's a handler in parent context, - return (SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler(event_context, event); // send event to parent + if ((SP_EVENT_CONTEXT_CLASS(sp_text_context_parent_class))->root_handler) { // and there's a handler in parent context, + return (SP_EVENT_CONTEXT_CLASS(sp_text_context_parent_class))->root_handler(event_context, event); // send event to parent } else { return FALSE; // return "I did nothing" value so that global shortcuts can be activated } diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 44b323989..47b4d35ac 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -29,6 +29,7 @@ #include "document.h" #include "xml/repr.h" #include "xml/attribute-record.h" +#include "xml/sp-css-attr.h" #include "sp-textpath.h" #include "sp-flowtext.h" diff --git a/src/trace/filterset.cpp b/src/trace/filterset.cpp index 908985225..f6c025956 100644 --- a/src/trace/filterset.cpp +++ b/src/trace/filterset.cpp @@ -365,41 +365,6 @@ grayMapCanny(GrayMap *gm, double lowThreshold, double highThreshold) - - - - -/** - * - */ -GdkPixbuf * -gdkCanny(GdkPixbuf *img, double lowThreshold, double highThreshold) -{ - if (!img) - return NULL; - - - GrayMap *grayMap = gdkPixbufToGrayMap(img); - if (!grayMap) - return NULL; - - /*grayMap->writePPM(grayMap, "gbefore.ppm");*/ - - GrayMap *cannyGm = grayMapCanny(grayMap,lowThreshold, highThreshold); - - grayMap->destroy(grayMap); - - if (!cannyGm) - return NULL; - - /*grayMap->writePPM(grayMap, "gafter.ppm");*/ - - GdkPixbuf *newImg = grayMapToGdkPixbuf(cannyGm); - - - return newImg; -} - /*######################################################################### ### Q U A N T I Z A T I O N #########################################################################*/ diff --git a/src/trace/filterset.h b/src/trace/filterset.h index eeafc079f..820d225c3 100644 --- a/src/trace/filterset.h +++ b/src/trace/filterset.h @@ -40,12 +40,6 @@ GrayMap *grayMapCanny(GrayMap *gmap, /** * */ -GdkPixbuf *gdkCanny(GdkPixbuf *img, - double lowThreshold, double highThreshold); - -/** - * - */ GrayMap *quantizeBand(RgbMap *rgbmap, int nrColors); diff --git a/src/trace/imagemap-gdk.cpp b/src/trace/imagemap-gdk.cpp index 06f355de7..7c7139002 100644 --- a/src/trace/imagemap-gdk.cpp +++ b/src/trace/imagemap-gdk.cpp @@ -122,44 +122,6 @@ PackedPixelMap *gdkPixbufToPackedPixelMap(GdkPixbuf *buf) return ppMap; } -/*GdkPixbuf *packedPixelMapToGdkPixbuf(PackedPixelMap *ppMap) -{ - if (!ppMap) - return NULL; - - guchar *pixdata = (guchar *) - malloc(sizeof(guchar) * ppMap->width * ppMap->height * 3); - if (!pixdata) - return NULL; - - int n_channels = 3; - int rowstride = ppMap->width * 3; - - GdkPixbuf *buf = gdk_pixbuf_new_from_data(pixdata, GDK_COLORSPACE_RGB, - 0, 8, ppMap->width, ppMap->height, - rowstride, NULL, NULL); //first NULL: replace by (GdkPixbufDestroyNotify)g_free ?? - - //### Fill in the cells with RGB values - int x,y; - int row = 0; - for (y=0 ; y<ppMap->height ; y++) - { - guchar *p = pixdata + row; - for (x=0 ; x<ppMap->width ; x++) - { - unsigned long rgb = ppMap->getPixel(ppMap, x, y); - p[0] = (rgb >> 16) & 0xff; - p[1] = (rgb >> 8) & 0xff; - p[2] = (rgb ) & 0xff; - p += n_channels; - } - row += rowstride; - } - - return buf; -} -*/ - /*######################################################################### ## R G B M A P @@ -203,44 +165,7 @@ RgbMap *gdkPixbufToRgbMap(GdkPixbuf *buf) return rgbMap; } -/* -GdkPixbuf *rgbMapToGdkPixbuf(RgbMap *rgbMap) -{ - if (!rgbMap) - return NULL; - - guchar *pixdata = (guchar *) - malloc(sizeof(guchar) * rgbMap->width * rgbMap->height * 3); - if (!pixdata) - return NULL; - - int n_channels = 3; - int rowstride = rgbMap->width * 3; - - GdkPixbuf *buf = gdk_pixbuf_new_from_data(pixdata, GDK_COLORSPACE_RGB, - 0, 8, rgbMap->width, rgbMap->height, - rowstride, NULL, NULL); //first NULL: replace by (GdkPixbufDestroyNotify)g_free ?? - - //### Fill in the cells with RGB values - int x,y; - int row = 0; - for (y=0 ; y<rgbMap->height ; y++) - { - guchar *p = pixdata + row; - for (x=0 ; x<rgbMap->width ; x++) - { - RGB rgb = rgbMap->getPixel(rgbMap, x, y); - p[0] = rgb.r & 0xff; - p[1] = rgb.g & 0xff; - p[2] = rgb.b & 0xff; - p += n_channels; - } - row += rowstride; - } - return buf; -} -*/ /*######################################################################### ## I N D E X E D M A P diff --git a/src/trace/imagemap-gdk.h b/src/trace/imagemap-gdk.h index 3b4631f50..63281658a 100644 --- a/src/trace/imagemap-gdk.h +++ b/src/trace/imagemap-gdk.h @@ -24,17 +24,9 @@ extern "C" { #endif GrayMap *gdkPixbufToGrayMap(GdkPixbuf *buf); - GdkPixbuf *grayMapToGdkPixbuf(GrayMap *grayMap); - PackedPixelMap *gdkPixbufToPackedPixelMap(GdkPixbuf *buf); - -//GdkPixbuf *packedPixelMapToGdkPixbuf(PackedPixelMap *ppMap); - RgbMap *gdkPixbufToRgbMap(GdkPixbuf *buf); - -//GdkPixbuf *rgbMapToGdkPixbuf(RgbMap *rgbMap); - GdkPixbuf *indexedMapToGdkPixbuf(IndexedMap *iMap); diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index 870b9cce1..28e4c1629 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -81,35 +81,13 @@ using Inkscape::DocumentUndo; #define DYNA_MIN_WIDTH 1.0e-6 -static void sp_tweak_context_class_init(SPTweakContextClass *klass); -static void sp_tweak_context_init(SPTweakContext *ddc); static void sp_tweak_context_dispose(GObject *object); static void sp_tweak_context_setup(SPEventContext *ec); static void sp_tweak_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val); static gint sp_tweak_context_root_handler(SPEventContext *ec, GdkEvent *event); -static SPEventContextClass *parent_class; - -GType -sp_tweak_context_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPTweakContextClass), - NULL, NULL, - (GClassInitFunc) sp_tweak_context_class_init, - NULL, NULL, - sizeof(SPTweakContext), - 4, - (GInstanceInitFunc) sp_tweak_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPTweakContext", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPTweakContext, sp_tweak_context, SP_TYPE_EVENT_CONTEXT); static void sp_tweak_context_class_init(SPTweakContextClass *klass) @@ -117,8 +95,6 @@ sp_tweak_context_class_init(SPTweakContextClass *klass) GObjectClass *object_class = G_OBJECT_CLASS(klass); SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass); - parent_class = SP_EVENT_CONTEXT_CLASS(g_type_class_peek_parent(klass)); - object_class->dispose = sp_tweak_context_dispose; event_context_class->setup = sp_tweak_context_setup; @@ -173,7 +149,7 @@ sp_tweak_context_dispose(GObject *object) delete tc->_message_context; } - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_tweak_context_parent_class)->dispose(object); } static bool is_transform_mode (gint mode) @@ -290,8 +266,8 @@ sp_tweak_context_setup(SPEventContext *ec) { SPTweakContext *tc = SP_TWEAK_CONTEXT(ec); - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->setup) { - (SP_EVENT_CONTEXT_CLASS(parent_class))->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_tweak_context_parent_class))->setup) { + (SP_EVENT_CONTEXT_CLASS(sp_tweak_context_parent_class))->setup(ec); } { @@ -1535,8 +1511,8 @@ sp_tweak_context_root_handler(SPEventContext *event_context, } if (!ret) { - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler) { - ret = (SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler(event_context, event); + if ((SP_EVENT_CONTEXT_CLASS(sp_tweak_context_parent_class))->root_handler) { + ret = (SP_EVENT_CONTEXT_CLASS(sp_tweak_context_parent_class))->root_handler(event_context, event); } } diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index f267c5ae9..ecdfd3346 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -63,7 +63,12 @@ #include "helper/png-write.h" +#if WITH_EXT_GDL +#include <gdl/gdl-dock-item.h> +#else #include "libgdl/gdl-dock-item.h" +#endif + // required to set status message after export #include "desktop.h" diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 6425d9fee..496836c4d 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -26,6 +26,9 @@ #include <gdk/gdkwin32.h> #include <glib/gstdio.h> #include <glibmm/i18n.h> +#if GLIB_CHECK_VERSION(2,32,0) +#include <glibmm/thread.h> +#endif #include <gtkmm/window.h> //Inkscape includes @@ -133,7 +136,11 @@ FileDialogBaseWin32::FileDialogBaseWin32(Gtk::Window &parent, Glib::RefPtr<const Gdk::Window> parentWindow = parent.get_window(); g_assert(parentWindow->gobj() != NULL); +#if WITH_GTKMM_3_0 + _ownerHwnd = (HWND)gdk_win32_window_get_handle((GdkWindow*)parentWindow->gobj()); +#else _ownerHwnd = (HWND)gdk_win32_drawable_get_handle((GdkDrawable*)parentWindow->gobj()); +#endif } FileDialogBaseWin32::~FileDialogBaseWin32() @@ -1576,16 +1583,23 @@ FileOpenDialogImplWin32::show() // We can only run one worker thread at a time if(_mutex != NULL) return false; +#if !GLIB_CHECK_VERSION(2,32,0) if(!Glib::thread_supported()) Glib::thread_init(); +#endif _result = false; _finished = false; _file_selected = false; - _mutex = new Glib::Mutex(); _main_loop = g_main_loop_new(g_main_context_default(), FALSE); +#if GLIB_CHECK_VERSION(2,32,0) + _mutex = new Glib::Threads::Mutex(); + if(Glib::Threads::Thread::create(sigc::mem_fun(*this, &FileOpenDialogImplWin32::GetOpenFileName_thread))) +#else + _mutex = new Glib::Mutex(); if(Glib::Thread::create(sigc::mem_fun(*this, &FileOpenDialogImplWin32::GetOpenFileName_thread), true)) +#endif { while(1) { @@ -1870,15 +1884,21 @@ void FileSaveDialogImplWin32::GetSaveFileName_thread() bool FileSaveDialogImplWin32::show() { +#if !GLIB_CHECK_VERSION(2,32,0) if(!Glib::thread_supported()) Glib::thread_init(); +#endif _result = false; _main_loop = g_main_loop_new(g_main_context_default(), FALSE); if(_main_loop != NULL) { +#if GLIB_CHECK_VERSION(2,32,0) + if(Glib::Threads::Thread::create(sigc::mem_fun(*this, &FileSaveDialogImplWin32::GetSaveFileName_thread))) +#else if(Glib::Thread::create(sigc::mem_fun(*this, &FileSaveDialogImplWin32::GetSaveFileName_thread), true)) +#endif g_main_loop_run(_main_loop); if(_result && _extension) diff --git a/src/ui/dialog/filedialogimpl-win32.h b/src/ui/dialog/filedialogimpl-win32.h index 15953f9d8..e9d8829f7 100644 --- a/src/ui/dialog/filedialogimpl-win32.h +++ b/src/ui/dialog/filedialogimpl-win32.h @@ -226,7 +226,11 @@ private: /// This mutex is used to ensure that the worker thread /// that calls GetOpenFileName cannot collide with the /// main Inkscape thread +#if GLIB_CHECK_VERSION(2,32,0) + Glib::Threads::Mutex *_mutex; +#else Glib::Mutex *_mutex; +#endif /// The controller function for the thread which calls diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 418132abb..50f30e8f4 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1730,8 +1730,6 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair (bg_color_active.green + fg_color_active.green)/2.0, (bg_color_active.blue + fg_color_active.blue)/2.0, (bg_color_active.alpha + fg_color_active.alpha)/2.0}; - - GdkRGBA black = {0,0,0,1}; #else GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(gobj())); #endif @@ -1902,11 +1900,7 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair // Draw drag connection if(row_prim == prim && _in_drag) { cr->save(); -#if GTK_CHECK_VERSION(3,0,0) - gdk_cairo_set_source_rgba(cr->cobj(), &black); -#else - gdk_cairo_set_source_color(cr->cobj(), &(style->black)); -#endif + cr->set_source_rgb(0.0, 0.0, 0.0); cr->move_to(outline_x, con_drag_y); cr->line_to(mx, con_drag_y); cr->line_to(mx, my); @@ -1936,8 +1930,6 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Cairo::RefPtr<Cai (bg_color.green + fg_color.green)/2.0, (bg_color.blue + fg_color.blue)/2.0, (bg_color.alpha + fg_color.alpha)/2.0}; - - GdkRGBA black = {0,0,0,1}; #else GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(gobj())); #endif @@ -1955,17 +1947,14 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Cairo::RefPtr<Cai const int tw = get_input_type_width(); gint end_x = text_start_x + tw * src_id + (int)(tw * 0.5f) + 1; -#if GTK_CHECK_VERSION(3,0,0) if(use_default && is_first) - gdk_cairo_set_source_rgba(cr->cobj(), &mid_color); - else - gdk_cairo_set_source_rgba(cr->cobj(), &black); +#if GTK_CHECK_VERSION(3,0,0) + gdk_cairo_set_source_rgba(cr->cobj(), &mid_color); #else - if(use_default && is_first) - gdk_cairo_set_source_color(cr->cobj(), &(style->dark[GTK_STATE_NORMAL])); - else - gdk_cairo_set_source_color(cr->cobj(), &(style->black)); + gdk_cairo_set_source_color(cr->cobj(), &(style->dark[GTK_STATE_NORMAL])); #endif + else + cr->set_source_rgb(0.0, 0.0, 0.0); cr->rectangle(end_x-2, y1-2, 5, 5); cr->fill_preserve(); @@ -1993,11 +1982,7 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Cairo::RefPtr<Cai const int y2 = rct.get_y() + rct.get_height(); // Draw a bevelled 'L'-shaped connection -#if GTK_CHECK_VERSION(3,0,0) - gdk_cairo_set_source_rgba(cr->cobj(), &black); -#else - gdk_cairo_set_source_color(cr->cobj(), &(style->black)); -#endif + cr->set_source_rgb(0.0, 0.0, 0.0); cr->move_to(x1, y1); cr->line_to(x2-fheight/4, y1); cr->line_to(x2, y1-fheight/4); diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp index 24588946e..07e73cec8 100644 --- a/src/ui/dialog/font-substitution.cpp +++ b/src/ui/dialog/font-substitution.cpp @@ -260,7 +260,7 @@ Glib::ustring FontSubstitution::getSubstituteFontName (Glib::ustring font) font_instance *res = (font_factory::Default())->Face(descr); if (res->pFont) { PangoFontDescription *nFaceDesc = pango_font_describe(res->pFont); - out = pango_font_description_get_family(nFaceDesc); + out = sp_font_description_get_family(nFaceDesc); } pango_font_description_free(descr); diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index d963e0c7f..57f815730 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -601,6 +601,24 @@ void InkscapePreferences::initPageUI() _page_ui.add_line(false, "", _show_filters_info_box, "", _("Show icons and descriptions for the filter primitives available at the filter effects dialog")); + { + Glib::ustring dockbarstyleLabels[] = {_("Icons only"), _("Text only"), _("Icons and text")}; + int dockbarstyleValues[] = {0, 1, 2}; + + /* dockbar style */ + _dockbar_style.init( "/options/dock/dockbarstyle", dockbarstyleLabels, dockbarstyleValues, G_N_ELEMENTS(dockbarstyleLabels), 0); + _page_ui.add_line(false, _("Dockbar style (requires restart):"), _dockbar_style, "", + _("Selects whether the vertical bars on the dockbar will show text labels, icons, or both"), false); + + Glib::ustring switcherstyleLabels[] = {_("Text only"), _("Icons only"), _("Icons and text")}; /* see bug #1098437 */ + int switcherstyleValues[] = {0, 1, 2}; + + /* switcher style */ + _switcher_style.init( "/options/dock/switcherstyle", switcherstyleLabels, switcherstyleValues, G_N_ELEMENTS(switcherstyleLabels), 0); + _page_ui.add_line(false, _("Switcher style (requires restart):"), _switcher_style, "", + _("Selects whether the dockbar switcher will show text labels, icons, or both"), false); + } + // Windows _win_save_geom.init ( _("Save and restore window geometry for each document"), "/options/savewindowgeometry/value", 1, true, 0); _win_save_geom_prefs.init ( _("Remember and use last window's geometry"), "/options/savewindowgeometry/value", 2, false, &_win_save_geom); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index 690016556..b21ab0128 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -274,6 +274,8 @@ protected: UI::Widget::PrefRadioButton _filter_quality_worse; UI::Widget::PrefRadioButton _filter_quality_worst; UI::Widget::PrefCheckButton _show_filters_info_box; + UI::Widget::PrefCombo _dockbar_style; + UI::Widget::PrefCombo _switcher_style; UI::Widget::PrefSpinButton _rendering_cache_size; UI::Widget::PrefSpinButton _filter_multi_threaded; diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index 7b6502ec3..e743e0efc 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -107,8 +107,6 @@ using Inkscape::ControlManager; namespace { SPCanvasGroup *create_control_group(SPDesktop *d); -void ink_node_tool_class_init(InkNodeToolClass *klass); -void ink_node_tool_init(InkNodeTool *node_context); void ink_node_tool_dispose(GObject *object); void ink_node_tool_setup(SPEventContext *ec); @@ -126,39 +124,10 @@ void handleControlUiStyleChange(InkNodeTool *nt); } // anonymous namespace -GType ink_node_tool_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(InkNodeToolClass), - NULL, NULL, - (GClassInitFunc) ink_node_tool_class_init, - NULL, NULL, - sizeof(InkNodeTool), - 4, - (GInstanceInitFunc) ink_node_tool_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "InkNodeTool", &info, (GTypeFlags)0); - } - return type; -} - -namespace { - -SPCanvasGroup *create_control_group(SPDesktop *d) -{ - return reinterpret_cast<SPCanvasGroup*>(sp_canvas_item_new( - sp_desktop_controls(d), SP_TYPE_CANVAS_GROUP, NULL)); -} - -void destroy_group(SPCanvasGroup *g) -{ - sp_canvas_item_destroy(SP_CANVAS_ITEM(g)); -} +G_DEFINE_TYPE(InkNodeTool, ink_node_tool, SP_TYPE_EVENT_CONTEXT); -void ink_node_tool_class_init(InkNodeToolClass *klass) +static void +ink_node_tool_class_init(InkNodeToolClass *klass) { GObjectClass *object_class = (GObjectClass *) klass; SPEventContextClass *event_context_class = (SPEventContextClass *) klass; @@ -171,7 +140,8 @@ void ink_node_tool_class_init(InkNodeToolClass *klass) event_context_class->item_handler = ink_node_tool_item_handler; } -void ink_node_tool_init(InkNodeTool *nt) +static void +ink_node_tool_init(InkNodeTool *nt) { SPEventContext *event_context = SP_EVENT_CONTEXT(nt); @@ -191,6 +161,19 @@ void ink_node_tool_init(InkNodeTool *nt) new (&nt->_shape_editors) ShapeEditors(); } +namespace { + +SPCanvasGroup *create_control_group(SPDesktop *d) +{ + return reinterpret_cast<SPCanvasGroup*>(sp_canvas_item_new( + sp_desktop_controls(d), SP_TYPE_CANVAS_GROUP, NULL)); +} + +void destroy_group(SPCanvasGroup *g) +{ + sp_canvas_item_destroy(SP_CANVAS_ITEM(g)); +} + void ink_node_tool_dispose(GObject *object) { InkNodeTool *nt = INK_NODE_TOOL(object); @@ -228,15 +211,15 @@ void ink_node_tool_dispose(GObject *object) delete nt->_node_message_context; } - G_OBJECT_CLASS(g_type_class_peek(g_type_parent(INK_TYPE_NODE_TOOL)))->dispose(object); + G_OBJECT_CLASS(ink_node_tool_parent_class)->dispose(object); } void ink_node_tool_setup(SPEventContext *ec) { InkNodeTool *nt = INK_NODE_TOOL(ec); - SPEventContextClass *parent = (SPEventContextClass *) g_type_class_peek(g_type_parent(INK_TYPE_NODE_TOOL)); - if (parent->setup) parent->setup(ec); + if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->setup) + SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->setup(ec); nt->_node_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack()); @@ -372,10 +355,8 @@ void ink_node_tool_set(SPEventContext *ec, Inkscape::Preferences::Entry *value) nt->edit_masks = value->getBool(); ink_node_tool_selection_changed(nt, nt->desktop->selection); } else { - SPEventContextClass *parent_class = - (SPEventContextClass *) g_type_class_peek(g_type_parent(INK_TYPE_NODE_TOOL)); - if (parent_class->set) - parent_class->set(ec, value); + if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->set) + SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->set(ec, value); } } @@ -556,9 +537,9 @@ gint ink_node_tool_root_handler(SPEventContext *event_context, GdkEvent *event) default: break; } - SPEventContextClass *parent_class = (SPEventContextClass *) g_type_class_peek(g_type_parent(INK_TYPE_NODE_TOOL)); - if (parent_class->root_handler) - return parent_class->root_handler(event_context, event); + if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->root_handler) + return SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->root_handler(event_context, event); + return FALSE; } @@ -622,10 +603,9 @@ void ink_node_tool_update_tip(InkNodeTool *nt, GdkEvent *event) gint ink_node_tool_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event) { - SPEventContextClass *parent_class = - (SPEventContextClass *) g_type_class_peek(g_type_parent(INK_TYPE_NODE_TOOL)); - if (parent_class->item_handler) - return parent_class->item_handler(event_context, item, event); + if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->item_handler) + return SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->item_handler(event_context, item, event); + return FALSE; } diff --git a/src/ui/view/edit-widget-interface.h b/src/ui/view/edit-widget-interface.h index 412c7ff8c..26e47abbb 100644 --- a/src/ui/view/edit-widget-interface.h +++ b/src/ui/view/edit-widget-interface.h @@ -101,9 +101,6 @@ struct EditWidgetInterface /// Update the "inactive desktop" indicator virtual void deactivateDesktop() = 0; - /// Set rulers to position - virtual void viewSetPosition (Geom::Point p) = 0; - /// Update rulers from current values virtual void updateRulers() = 0; diff --git a/src/ui/view/view.cpp b/src/ui/view/view.cpp index e13976cc4..72548e213 100644 --- a/src/ui/view/view.cpp +++ b/src/ui/view/view.cpp @@ -27,12 +27,6 @@ namespace UI { namespace View { static void -_onPositionSet (double x, double y, View* v) -{ - v->onPositionSet (x,y); -} - -static void _onResized (double x, double y, View* v) { v->onResized (x,y); @@ -69,7 +63,6 @@ View::View() _message_stack = GC::release(new Inkscape::MessageStack()); _tips_message_context = new Inkscape::MessageContext(_message_stack); - _position_set_connection = _position_set_signal.connect (sigc::bind (sigc::ptr_fun (&_onPositionSet), this)); _resized_connection = _resized_signal.connect (sigc::bind (sigc::ptr_fun (&_onResized), this)); _redraw_requested_connection = _redraw_requested_signal.connect (sigc::bind (sigc::ptr_fun (&_onRedrawRequested), this)); @@ -102,16 +95,6 @@ void View::_close() { Inkscape::Verb::delete_all_view (this); } -void View::setPosition (double x, double y) -{ - _position_set_signal.emit (x,y); -} - -void View::setPosition(Geom::Point const &p) -{ - setPosition (double(p[Geom::X]), double(p[Geom::Y])); -} - void View::emitResized (double width, double height) { _resized_signal.emit (width, height); diff --git a/src/ui/view/view.h b/src/ui/view/view.h index 6ed9f476c..48f4d2549 100644 --- a/src/ui/view/view.h +++ b/src/ui/view/view.h @@ -90,8 +90,6 @@ public: Inkscape::MessageContext *tipsMessageContext() const { return _tips_message_context; } - void setPosition(gdouble x, gdouble y); - void setPosition(Geom::Point const &p); void emitResized(gdouble width, gdouble height); void requestRedraw(); @@ -101,7 +99,6 @@ public: virtual void mouseover() = 0; virtual void mouseout() = 0; - virtual void onPositionSet (double, double) = 0; virtual void onResized (double, double) = 0; virtual void onRedrawRequested() = 0; virtual void onStatusMessage (Inkscape::MessageType type, gchar const *message) = 0; @@ -126,13 +123,11 @@ protected: */ virtual void setDocument(SPDocument *doc); - sigc::signal<void,double,double> _position_set_signal; sigc::signal<void,double,double> _resized_signal; sigc::signal<void,gchar const*> _document_uri_set_signal; sigc::signal<void> _redraw_requested_signal; private: - sigc::connection _position_set_connection; sigc::connection _resized_connection; sigc::connection _redraw_requested_connection; sigc::connection _message_changed_connection; // foreign diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp index 60d5f6ecc..44bceb826 100644 --- a/src/ui/widget/style-swatch.cpp +++ b/src/ui/widget/style-swatch.cpp @@ -28,6 +28,7 @@ #include "sp-radial-gradient-fns.h" #include "sp-pattern.h" #include "xml/repr.h" +#include "xml/sp-css-attr.h" #include "widgets/widget-sizes.h" #include "helper/units.h" #include "helper/action.h" diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index d7be6c9f0..467f0d70e 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -25,8 +25,6 @@ #include "button.h" -static void sp_button_class_init (SPButtonClass *klass); -static void sp_button_init (SPButton *button); static void sp_button_dispose(GObject *object); #if GTK_CHECK_VERSION(3,0,0) @@ -50,28 +48,7 @@ static void sp_button_set_doubleclick_action (SPButton *button, SPAction *action static void sp_button_action_set_active (SPButton *button, bool active); static void sp_button_set_composed_tooltip (GtkWidget *widget, SPAction *action); -static GtkToggleButtonClass *parent_class; - -GType sp_button_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPButtonClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_button_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPButton), - 0, // n_preallocs - (GInstanceInitFunc)sp_button_init, - 0 // value_table - }; - type = g_type_register_static(GTK_TYPE_TOGGLE_BUTTON, "SPButton", &info, static_cast<GTypeFlags>(0)); - } - return type; -} +G_DEFINE_TYPE(SPButton, sp_button, GTK_TYPE_TOGGLE_BUTTON); static void sp_button_class_init (SPButtonClass *klass) @@ -80,8 +57,6 @@ sp_button_class_init (SPButtonClass *klass) GtkWidgetClass *widget_class=GTK_WIDGET_CLASS(klass); GtkButtonClass *button_class=GTK_BUTTON_CLASS(klass); - parent_class = GTK_TOGGLE_BUTTON_CLASS(g_type_class_peek_parent(klass)); - object_class->dispose = sp_button_dispose; #if GTK_CHECK_VERSION(3,0,0) widget_class->get_preferred_width = sp_button_get_preferred_width; @@ -120,10 +95,10 @@ static void sp_button_dispose(GObject *object) sp_button_set_doubleclick_action (button, NULL); } - button->c_set_active.~connection(); - button->c_set_sensitive.~connection(); + button->c_set_active.~connection(); + button->c_set_sensitive.~connection(); - (G_OBJECT_CLASS(parent_class))->dispose(object); + (G_OBJECT_CLASS(sp_button_parent_class))->dispose(object); } @@ -185,7 +160,7 @@ sp_button_clicked (GtkButton *button) SPButton *sp_button=SP_BUTTON (button); if (sp_button->type == SP_BUTTON_TYPE_TOGGLE) { - (GTK_BUTTON_CLASS(parent_class))->clicked (button); + (GTK_BUTTON_CLASS(sp_button_parent_class))->clicked (button); } } @@ -340,3 +315,13 @@ sp_button_new_from_data( Inkscape::IconSize size, return button; } +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index a7432c32a..9e078cabb 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -313,6 +313,22 @@ sp_desktop_widget_class_init (SPDesktopWidgetClass *klass) } /** + * Callback for changes in size of the canvas table (i.e. the container for + * the canvas, the rulers etc). + * + * This adjusts the range of the rulers when the dock container is adjusted + * (fixes lp:950552) + */ +static void +canvas_tbl_size_allocate(GtkWidget *widget, + GdkRectangle *allocation, + gpointer data) +{ + SPDesktopWidget *dtw = SP_DESKTOP_WIDGET(data); + sp_desktop_widget_update_rulers (dtw); +} + +/** * Callback for SPDesktopWidget object initialization. */ void SPDesktopWidget::init( SPDesktopWidget *dtw ) @@ -385,14 +401,14 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) #if GTK_CHECK_VERSION(3,0,0) GtkWidget *tbl = gtk_grid_new(); - GtkWidget *canvas_tbl = gtk_grid_new(); + dtw->canvas_tbl = gtk_grid_new(); - gtk_grid_attach(GTK_GRID(canvas_tbl), eventbox, 1, 0, 1, 1); + gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), eventbox, 1, 0, 1, 1); #else GtkWidget *tbl = gtk_table_new(2, 3, FALSE); - GtkWidget *canvas_tbl = gtk_table_new(3, 3, FALSE); + dtw->canvas_tbl = gtk_table_new(3, 3, FALSE); - gtk_table_attach(GTK_TABLE(canvas_tbl), + gtk_table_attach(GTK_TABLE(dtw->canvas_tbl), eventbox, 1, 2, 0, 1, GTK_FILL, GTK_FILL, @@ -410,9 +426,9 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_container_add (GTK_CONTAINER (eventbox), GTK_WIDGET (dtw->vruler)); #if GTK_CHECK_VERSION(3,0,0) - gtk_grid_attach(GTK_GRID(canvas_tbl), eventbox, 0, 1, 1, 1); + gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), eventbox, 0, 1, 1, 1); #else - gtk_table_attach(GTK_TABLE (canvas_tbl), + gtk_table_attach(GTK_TABLE (dtw->canvas_tbl), eventbox, 0, 1, 1, 2, GTK_FILL, GTK_FILL, @@ -428,11 +444,11 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) #if GTK_CHECK_VERSION(3,0,0) dtw->hscrollbar = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT (dtw->hadj)); - gtk_grid_attach(GTK_GRID(canvas_tbl), dtw->hscrollbar, 1, 2, 1, 1); + gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), dtw->hscrollbar, 1, 2, 1, 1); dtw->vscrollbar_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); #else dtw->hscrollbar = gtk_hscrollbar_new (GTK_ADJUSTMENT (dtw->hadj)); - gtk_table_attach(GTK_TABLE (canvas_tbl), dtw->hscrollbar, 1, 2, 2, 3, + gtk_table_attach(GTK_TABLE (dtw->canvas_tbl), dtw->hscrollbar, 1, 2, 2, 3, GTK_FILL, GTK_SHRINK, 0, 0); dtw->vscrollbar_box = gtk_vbox_new (FALSE, 0); @@ -460,9 +476,9 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_box_pack_start (GTK_BOX (dtw->vscrollbar_box), dtw->vscrollbar, TRUE, TRUE, 0); #if GTK_CHECK_VERSION(3,0,0) - gtk_grid_attach(GTK_GRID(canvas_tbl), dtw->vscrollbar_box, 2, 0, 1, 2); + gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), dtw->vscrollbar_box, 2, 0, 1, 2); #else - gtk_table_attach(GTK_TABLE(canvas_tbl), dtw->vscrollbar_box, 2, 3, 0, 2, + gtk_table_attach(GTK_TABLE(dtw->canvas_tbl), dtw->vscrollbar_box, 2, 3, 0, 2, GTK_SHRINK, GTK_FILL, 0, 0); #endif @@ -498,9 +514,9 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) #if GTK_CHECK_VERSION(3,0,0) - gtk_grid_attach( GTK_GRID(canvas_tbl), dtw->cms_adjust, 2, 2, 1, 1); + gtk_grid_attach( GTK_GRID(dtw->canvas_tbl), dtw->cms_adjust, 2, 2, 1, 1); #else - gtk_table_attach( GTK_TABLE(canvas_tbl), dtw->cms_adjust, 2, 3, 2, 3, + gtk_table_attach( GTK_TABLE(dtw->canvas_tbl), dtw->cms_adjust, 2, 3, 2, 3, (GtkAttachOptions)(GTK_SHRINK), (GtkAttachOptions)(GTK_SHRINK), 0, 0); @@ -520,6 +536,9 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) gtk_widget_set_can_focus (GTK_WIDGET (dtw->canvas), TRUE); + sp_ruler_add_track_widget (SP_RULER(dtw->hruler), GTK_WIDGET(dtw->canvas)); + sp_ruler_add_track_widget (SP_RULER(dtw->vruler), GTK_WIDGET(dtw->canvas)); + #if GTK_CHECK_VERSION(3,0,0) GdkRGBA white = {1,1,1,1}; gtk_widget_override_background_color(GTK_WIDGET(dtw->canvas), @@ -541,9 +560,9 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) #if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_hexpand(GTK_WIDGET(dtw->canvas), TRUE); gtk_widget_set_vexpand(GTK_WIDGET(dtw->canvas), TRUE); - gtk_grid_attach(GTK_GRID(canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 1, 1, 1); + gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 1, 1, 1); #else - gtk_table_attach (GTK_TABLE (canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 2, 1, 2, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), 0, 0); + gtk_table_attach (GTK_TABLE (dtw->canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 2, 1, 2, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), 0, 0); #endif /* Dock */ @@ -560,7 +579,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) Gtk::HPaned *paned = new Gtk::HPaned(); #endif - paned->pack1(*Glib::wrap(canvas_tbl)); + paned->pack1(*Glib::wrap(dtw->canvas_tbl)); paned->pack2(dtw->dock->getWidget(), Gtk::FILL); /* Prevent the paned from catching F6 and F8 by unsetting the default callbacks */ @@ -580,11 +599,11 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) } else { #if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_hexpand(GTK_WIDGET(canvas_tbl), TRUE); - gtk_widget_set_vexpand(GTK_WIDGET(canvas_tbl), TRUE); - gtk_grid_attach(GTK_GRID(tbl), GTK_WIDGET (canvas_tbl), 1, 1, 1, 1); + gtk_widget_set_hexpand(GTK_WIDGET(dtw->canvas_tbl), TRUE); + gtk_widget_set_vexpand(GTK_WIDGET(dtw->canvas_tbl), TRUE); + gtk_grid_attach(GTK_GRID(tbl), GTK_WIDGET (dtw->canvas_tbl), 1, 1, 1, 1); #else - gtk_table_attach (GTK_TABLE (tbl), GTK_WIDGET (canvas_tbl), 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), + gtk_table_attach (GTK_TABLE (tbl), GTK_WIDGET (dtw->canvas_tbl), 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0); #endif } @@ -740,6 +759,13 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) } overallTimer = 0; } + + // Ensure that ruler ranges are updated correctly whenever the canvas table + // is resized + g_signal_connect (G_OBJECT (dtw->canvas_tbl), + "size-allocate", + G_CALLBACK (canvas_tbl_size_allocate), + dtw); } /** @@ -761,6 +787,8 @@ static void sp_desktop_widget_dispose(GObject *object) g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->zoom_status), (gpointer) G_CALLBACK (sp_dtw_zoom_value_changed), dtw); g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->zoom_status), (gpointer) G_CALLBACK (sp_dtw_zoom_populate_popup), dtw); g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->canvas), (gpointer) G_CALLBACK (sp_desktop_widget_event), dtw); + g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->canvas_tbl), (gpointer) G_CALLBACK (canvas_tbl_size_allocate), dtw); + dtw->layer_selector->setDesktop(NULL); dtw->layer_selector->unreference(); @@ -970,12 +998,13 @@ sp_desktop_widget_event (GtkWidget *widget, GdkEvent *event, SPDesktopWidget *dt if (GTK_WIDGET_CLASS (dtw_parent_class)->event) { return (* GTK_WIDGET_CLASS (dtw_parent_class)->event) (widget, event); } else { - // The keypress events need to be passed to desktop handler explicitly, - // because otherwise the event contexts only receive keypresses when the mouse cursor - // is over the canvas. This redirection is only done for keypresses and only if there's no + // The key press/release events need to be passed to desktop handler explicitly, + // because otherwise the event contexts only receive key events when the mouse cursor + // is over the canvas. This redirection is only done for key events and only if there's no // current item on the canvas, because item events and all mouse events are caught // and passed on by the canvas acetate (I think). --bb - if (event->type == GDK_KEY_PRESS && !dtw->canvas->current_item) { + if ((event->type == GDK_KEY_PRESS || event->type == GDK_KEY_RELEASE) + && !dtw->canvas->current_item) { return sp_desktop_root_handler (NULL, event, dtw->desktop); } } @@ -1685,13 +1714,6 @@ SPDesktopWidget* SPDesktopWidget::createInstance(SPNamedView *namedview) return dtw; } -void -SPDesktopWidget::viewSetPosition (Geom::Point p) -{ - Geom::Point const origin = ( p - ruler_origin ); - sp_ruler_set_position(SP_RULER(hruler), origin[Geom::X]); - sp_ruler_set_position(SP_RULER(vruler), origin[Geom::Y]); -} void sp_desktop_widget_update_rulers (SPDesktopWidget *dtw) diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index 73194304f..0ffedd112 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -105,7 +105,11 @@ struct SPDesktopWidget { unsigned int _interaction_disabled_counter; - SPCanvas *canvas; + SPCanvas *canvas; + + /** A table for displaying the canvas, rulers etc */ + GtkWidget *canvas_tbl; + Geom::Point ruler_origin; double dt2r; @@ -168,8 +172,6 @@ struct SPDesktopWidget { { sp_dtw_desktop_activate (_dtw); } virtual void deactivateDesktop() { sp_dtw_desktop_deactivate (_dtw); } - virtual void viewSetPosition (Geom::Point p) - { _dtw->viewSetPosition (p); } virtual void updateRulers() { sp_desktop_widget_update_rulers (_dtw); } virtual void updateScrollbars (double scale) diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index b17dcf470..013ad9e94 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -162,8 +162,21 @@ static void sp_font_selector_init(SPFontSelector *fsel) GtkCellRenderer *cell = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, cell, FALSE); gtk_tree_view_column_set_attributes (column, cell, "text", 0, NULL); + gtk_tree_view_column_set_cell_data_func (column, cell, + GtkTreeCellDataFunc (font_lister_cell_data_func), + NULL, NULL ); gtk_tree_view_append_column (GTK_TREE_VIEW(fsel->family_treeview), column); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(fsel->family_treeview), FALSE); + gtk_tree_view_set_row_separator_func( GTK_TREE_VIEW(fsel->family_treeview), + GtkTreeViewRowSeparatorFunc ((gpointer)font_lister_separator_func), + NULL, NULL ); + + /* Muck with style, see text-toolbar.cpp */ + gtk_widget_set_name( GTK_WIDGET(fsel->family_treeview), "font_selector_family" ); + gtk_rc_parse_string ( + "widget \"*font_selector_family\" style \"fontfamily-separator-style\""); + + Glib::RefPtr<Gtk::ListStore> store = fontlister->get_font_list(); gtk_tree_view_set_model (GTK_TREE_VIEW(fsel->family_treeview), GTK_TREE_MODEL (Glib::unwrap (store))); gtk_container_add(GTK_CONTAINER(sw), fsel->family_treeview); @@ -442,6 +455,10 @@ GtkWidget *sp_font_selector_new() */ unsigned int sp_font_selector_get_best_style (font_instance *font, GList *list) { + if ( !font || !list) { + return 0; + } + font_instance *tempFont = NULL; unsigned int currentStyleNumber = 0; unsigned int bestStyleNumber = 0; @@ -462,7 +479,9 @@ unsigned int sp_font_selector_get_best_style (font_instance *font, GList *list) tempFont = NULL; } - pango_font_description_unset_fields(bestMatchForFont, PANGO_FONT_MASK_SIZE); + if( bestMatchForFont != NULL ) { + pango_font_description_unset_fields(bestMatchForFont, PANGO_FONT_MASK_SIZE); + } list = list->next; diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 7866989b1..8470e93db 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -41,9 +41,6 @@ #include "icon.h" struct IconImpl { - static void classInit(SPIconClass *klass); - static void init(SPIcon *icon); - static GtkWidget *newFull( Inkscape::IconSize lsize, gchar const *name ); static void dispose(GObject *object); @@ -104,12 +101,10 @@ struct IconImpl { private: static const std::string magicNumber; - static GtkWidgetClass *parent_class; static std::map<Glib::ustring, Glib::ustring> legacyNames; }; const std::string IconImpl::magicNumber = "1.0"; -GtkWidgetClass *IconImpl::parent_class = 0; std::map<Glib::ustring, Glib::ustring> IconImpl::legacyNames; @@ -141,34 +136,14 @@ public: static std::map<Glib::ustring, std::vector<IconCacheItem> > iconSetCache; static std::set<Glib::ustring> internalNames; -GType SPIcon::getType() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPIconClass), - NULL, - NULL, - reinterpret_cast<GClassInitFunc>(IconImpl::classInit), - NULL, - NULL, - sizeof(SPIcon), - 0, - reinterpret_cast<GInstanceInitFunc>(IconImpl::init), - NULL - }; - type = g_type_register_static(GTK_TYPE_WIDGET, "SPIcon", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPIcon, sp_icon, GTK_TYPE_WIDGET); -void IconImpl::classInit(SPIconClass *klass) +static void +sp_icon_class_init(SPIconClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); - parent_class = GTK_WIDGET_CLASS(g_type_class_peek_parent(klass)); - object_class->dispose = IconImpl::dispose; #if GTK_CHECK_VERSION(3,0,0) @@ -184,7 +159,8 @@ void IconImpl::classInit(SPIconClass *klass) widget_class->style_set = IconImpl::styleSet; } -void IconImpl::init(SPIcon *icon) +static void +sp_icon_init(SPIcon *icon) { gtk_widget_set_has_window (GTK_WIDGET (icon), FALSE); icon->lsize = Inkscape::ICON_SIZE_BUTTON; @@ -202,7 +178,7 @@ void IconImpl::dispose(GObject *object) icon->name = 0; } - (G_OBJECT_CLASS(parent_class))->dispose(object); + (G_OBJECT_CLASS(sp_icon_parent_class))->dispose(object); } void IconImpl::reset( SPIcon *icon ) @@ -375,8 +351,8 @@ GdkPixbuf* IconImpl::renderup( gchar const* name, Inkscape::IconSize lsize, unsi void IconImpl::screenChanged( GtkWidget *widget, GdkScreen *previous_screen ) { - if ( GTK_WIDGET_CLASS( parent_class )->screen_changed ) { - GTK_WIDGET_CLASS( parent_class )->screen_changed( widget, previous_screen ); + if ( GTK_WIDGET_CLASS( sp_icon_parent_class )->screen_changed ) { + GTK_WIDGET_CLASS( sp_icon_parent_class )->screen_changed( widget, previous_screen ); } SPIcon *icon = SP_ICON(widget); themeChanged(icon); @@ -384,8 +360,8 @@ void IconImpl::screenChanged( GtkWidget *widget, GdkScreen *previous_screen ) void IconImpl::styleSet( GtkWidget *widget, GtkStyle *previous_style ) { - if ( GTK_WIDGET_CLASS( parent_class )->style_set ) { - GTK_WIDGET_CLASS( parent_class )->style_set( widget, previous_style ); + if ( GTK_WIDGET_CLASS( sp_icon_parent_class )->style_set ) { + GTK_WIDGET_CLASS( sp_icon_parent_class )->style_set( widget, previous_style ); } SPIcon *icon = SP_ICON(widget); themeChanged(icon); diff --git a/src/widgets/icon.h b/src/widgets/icon.h index 3f6aa2455..6bce2e330 100644 --- a/src/widgets/icon.h +++ b/src/widgets/icon.h @@ -17,7 +17,7 @@ #include <gtkmm/widget.h> #include "icon-size.h" -#define SP_TYPE_ICON SPIcon::getType() +#define SP_TYPE_ICON sp_icon_get_type() #define SP_ICON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_ICON, SPIcon)) #define SP_IS_ICON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_ICON)) @@ -29,6 +29,8 @@ struct SPIconClass { GtkWidgetClass parent_class; }; +GType sp_icon_get_type() G_GNUC_CONST; + struct SPIcon { GtkWidget widget; @@ -38,8 +40,6 @@ struct SPIcon { GdkPixbuf *pb; - static GType getType(void); - friend class SPIconImpl; }; diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index 37cccda9f..471ee3852 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -642,49 +642,26 @@ static gboolean sp_color_slider_draw(GtkWidget *widget, cairo_t *cr) gint x = (int)(slider->value * (carea.width - 1) - ARROW_SIZE / 2 + carea.x); gint y1 = carea.y; gint y2 = carea.y + carea.height - 1; - gint w = ARROW_SIZE; cairo_set_line_width(cr, 1.0); -#if GTK_CHECK_VERSION(3,0,0) - GdkRGBA white = {1,1,1,1}; - GdkRGBA black = {0,0,0,1}; -#else - GdkColor white, black; - gdk_color_parse("#fff", &white); - gdk_color_parse("#000", &black); -#endif - - while ( w > 0 ) - { -#if GTK_CHECK_VERSION(3,0,0) - gdk_cairo_set_source_rgba(cr, &white); -#else - gdk_cairo_set_source_color(cr, &white); -#endif - cairo_move_to(cr, x - 0.5, y1 + 0.5); - cairo_line_to(cr, x + w - 1 + 0.5, y1 + 0.5); - cairo_move_to(cr, x - 0.5, y2 + 0.5); - cairo_line_to(cr, x + w - 1 + 0.5, y2 + 0.5); - cairo_stroke(cr); - w -=2; - x++; - if ( w > 0 ) - { -#if GTK_CHECK_VERSION(3,0,0) - gdk_cairo_set_source_rgba(cr, &black); -#else - gdk_cairo_set_source_color(cr, &black); -#endif - cairo_move_to(cr, x - 0.5, y1 + 0.5); - cairo_line_to(cr, x + w - 1 + 0.5, y1 + 0.5); - cairo_move_to(cr, x - 0.5, y2 + 0.5); - cairo_line_to(cr, x + w - 1 + 0.5, y2 + 0.5); - cairo_stroke(cr); - } - y1++; - y2--; - } - + // Define top arrow + cairo_move_to(cr, x - 0.5, y1 + 0.5); + cairo_line_to(cr, x + ARROW_SIZE - 0.5, y1 + 0.5); + cairo_line_to(cr, x + (ARROW_SIZE-1)/2.0, y1 + ARROW_SIZE/2.0 + 0.5); + cairo_line_to(cr, x - 0.5, y1 + 0.5); + + // Define bottom arrow + cairo_move_to(cr, x - 0.5, y2 + 0.5); + cairo_line_to(cr, x + ARROW_SIZE - 0.5, y2 + 0.5); + cairo_line_to(cr, x + (ARROW_SIZE-1)/2.0, y2 - ARROW_SIZE/2.0 + 0.5); + cairo_line_to(cr, x - 0.5, y2 + 0.5); + + // Render both arrows + cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); + cairo_stroke_preserve(cr); + cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); + cairo_fill(cr); + return FALSE; } diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 6c22c81e3..a01f950a6 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -18,7 +18,7 @@ * * Copyright (C) 2004 David Turner * Copyright (C) 2003 MenTaLguY - * Copyright (C) 1999-2011 authors + * Copyright (C) 1999-2013 authors * Copyright (C) 2001-2002 Ximian, Inc. * * Released under GNU GPL, read the file 'COPYING' for more information @@ -39,6 +39,7 @@ #include "../desktop-handles.h" #include "../desktop-style.h" #include "document-undo.h" +#include "../sp-root.h" #include "../verbs.h" #include "../inkscape.h" #include "../connection-pool.h" @@ -105,6 +106,10 @@ static void sp_print_font( SPStyle *query ) { << " FontSpec: " << (query->text->font_specification.value ? query->text->font_specification.value : "No value") << std::endl; + std::cout << " LineHeight: " << query->line_height.computed + << " WordSpacing: " << query->word_spacing.computed + << " LetterSpacing: " << query->letter_spacing.computed + << std::endl; } static void sp_print_fontweight( SPStyle *query ) { @@ -128,42 +133,6 @@ static void sp_print_fontstyle( SPStyle *query ) { } #endif -// Format family drop-down menu. -static void cell_data_func(GtkCellLayout * /*cell_layout*/, - GtkCellRenderer *cell, - GtkTreeModel *tree_model, - GtkTreeIter *iter, - gpointer /*data*/) -{ - gchar *family; - gtk_tree_model_get(tree_model, iter, 0, &family, -1); - gchar *const family_escaped = g_markup_escape_text(family, -1); - - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - int show_sample = prefs->getInt("/tools/text/show_sample_in_list", 1); - if (show_sample) { - - Glib::ustring sample = prefs->getString("/tools/text/font_sample"); - gchar *const sample_escaped = g_markup_escape_text(sample.data(), -1); - - std::stringstream markup; - markup << family_escaped << " <span foreground='gray' font_family='" - << family_escaped << "'>" << sample_escaped << "</span>"; - g_object_set (G_OBJECT (cell), "markup", markup.str().c_str(), NULL); - - g_free(sample_escaped); - } else { - g_object_set (G_OBJECT (cell), "markup", family_escaped, NULL); - } - // This doesn't work for two reasons... it set both selected and not selected backgrounds - // to white.. which means that white foreground text is invisible. It also only effects - // the text region, leaving the padding untouched. - // g_object_set (G_OBJECT (cell), "cell-background", "white", "cell-background-set", true, NULL); - - g_free(family); - g_free(family_escaped); -} - /* * Fill the font style combobox with the available font styles for the selected font family * Set the selected style to that in font @@ -178,6 +147,11 @@ static void sp_text_fontstyle_populate(GObject *tbl, font_instance *font=NULL) return; } + // If font list, take only first font in list + gchar** tokens = g_strsplit( current_font, ",", 0 ); + g_strstrip( tokens[0] ); + current_font = tokens[0]; + // Get an iter to the selected font from the model data // We cant get it from the combo, cause it might not have been created yet gboolean found = false; @@ -197,13 +171,7 @@ static void sp_text_fontstyle_populate(GObject *tbl, font_instance *font=NULL) valid = gtk_tree_model_iter_next( model, &iter ); } - if (!found) { - return; - } - - // Get the list of styles from the selected font - GList *list = NULL; - gtk_tree_model_get (model, &iter, 1, &list, -1); + g_strfreev( tokens ); Ink_ComboBoxEntry_Action* fontStyleAction = INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontStyleAction" ) ); @@ -212,7 +180,27 @@ static void sp_text_fontstyle_populate(GObject *tbl, font_instance *font=NULL) GtkListStore *store = GTK_LIST_STORE( ink_comboboxentry_action_get_model( fontStyleAction ) ); gtk_list_store_clear ( store ); - // Add list of styles to the style combo + // Get the list of styles from the selected font. + GList *list = NULL; + + if (found) { + + // Use precompiled list if font-family on system. + gtk_tree_model_get (model, &iter, 1, &list, -1); + + } else { + + // Use generic list if font-family not on system. + static GList *glist = NULL; + if( glist == NULL ) { + glist = g_list_append (glist, (void*)"Normal"); + glist = g_list_append (glist, (void*)"Italic"); + glist = g_list_append (glist, (void*)"Bold"); + glist = g_list_append (glist, (void*)"Bold Italic"); + } + list = glist; + } + for (GList *l=list; l; l = l->next) { gtk_list_store_append (store, &iter); @@ -220,7 +208,7 @@ static void sp_text_fontstyle_populate(GObject *tbl, font_instance *font=NULL) } // Select the style in the combo that best matches font - if (font) { + if (font && list) { unsigned int index = sp_font_selector_get_best_style(font, list); @@ -237,7 +225,6 @@ static void sp_text_fontstyle_populate(GObject *tbl, font_instance *font=NULL) } else if (current_style) { ink_comboboxentry_action_set_active_text( fontStyleAction, current_style ); } - } // Font family @@ -519,7 +506,7 @@ static void sp_text_fontstyle_value_changed( Ink_ComboBoxEntry_Action *act, GObj SPCSSAttr *css = sp_repr_css_attr_new (); - gchar *current_style = ink_comboboxentry_action_get_active_text( act ); + Glib::ustring current_style = ink_comboboxentry_action_get_active_text( act ); Glib::ustring fontFamily = ""; if (query->text->font_family.set) { @@ -530,9 +517,10 @@ static void sp_text_fontstyle_value_changed( Ink_ComboBoxEntry_Action *act, GObj fontFamily = ink_comboboxentry_action_get_active_text( act ); } - font_instance *font = (font_factory::Default())->FaceFromUIStrings (fontFamily.c_str(), current_style); + font_instance *font = (font_factory::Default())->FaceFromUIStrings (fontFamily.c_str(), current_style.c_str()); if (font) { + gchar c[256]; font->Attribute( "weight", c, 256); @@ -549,6 +537,19 @@ static void sp_text_fontstyle_value_changed( Ink_ComboBoxEntry_Action *act, GObj font->Unref(); font = NULL; + + } else { + + // Font not found on system, blindly update style + // Options match choices in sp_text_fontstyle_populate + sp_repr_css_set_property (css, "font-weight", "normal"); + sp_repr_css_set_property (css, "font-style", "normal" ); + if( current_style.find("Bold") != Glib::ustring::npos ) { + sp_repr_css_set_property (css, "font-weight", "bold"); + } + if( current_style.find("Italic") != Glib::ustring::npos ) { + sp_repr_css_set_property (css, "font-style", "italic"); + } } // If querying returned nothing, update default style. @@ -1151,6 +1152,15 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ } g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) ); + // Update font list, but only if widget already created. + Ink_ComboBoxEntry_Action* fontFamilyAction = + INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontFamilyAction" ) ); + if( fontFamilyAction->combobox != NULL ) { + Inkscape::FontLister* fontlister = Inkscape::FontLister::get_instance(); + fontlister->update_font_list( sp_desktop_document( SP_ACTIVE_DESKTOP )); + } + + // Only flowed text can be justified, only normal text can be kerned... // Find out if we have flowed text now so we can use it several places gboolean isFlow = false; @@ -1203,7 +1213,11 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ return; } - g_object_set_data(tbl, "text_style_from_prefs", GINT_TO_POINTER(TRUE)); + // To ensure the value of the combobox is properly set on start-up, only mark + // the prefs set if the combobox has already been constructed. + if( fontFamilyAction->combobox != NULL ) { + g_object_set_data(tbl, "text_style_from_prefs", GINT_TO_POINTER(TRUE)); + } } else { g_object_set_data(tbl, "text_style_from_prefs", GINT_TO_POINTER(FALSE)); } @@ -1443,6 +1457,44 @@ sp_text_toolbox_subselection_changed (gpointer /*tc*/, GObject *tbl) sp_text_toolbox_selection_changed (NULL, tbl); } + +/* Recursively extract all "font-family" attributes from a document. */ +void +sp_text_toolbox_get_font_list_in_doc_recursive (SPObject *r, std::list<Glib::ustring> *l) +{ + if (!r) { + return; + } + + const gchar *style = r->getRepr()->attribute("style"); + if( style != NULL ) { + //std::cout << style << std::endl; + std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(";", style ); + for( size_t i=0; i < tokens.size(); ++i ) { + Glib::ustring token = tokens[i]; + size_t found = token.find("font-family:"); + if( found != Glib::ustring::npos ) { + // Remove "font-family:" + token.erase(found,12); + // Remove any leading single or double quote + if( token[0] == '\'' || token[0] == '"' ) { + token.erase(0,1); + } + // Remove any trailing single or double quote + if( token[token.length()-1] == '\'' || token[token.length()-1] == '"' ) { + token.erase(token.length()-1); + } + l->push_back( token ); + } + } + } + + for (SPObject *child = r->firstChild(); child; child = child->getNext()) { + sp_text_toolbox_get_font_list_in_doc_recursive( child, l ); + } +} + + // Define all the "widgets" in the toolbar. void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder) { @@ -1457,18 +1509,22 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje /* Font family */ { // Font list - Glib::RefPtr<Gtk::ListStore> store = Inkscape::FontLister::get_instance()->get_font_list(); + Inkscape::FontLister* fontlister = Inkscape::FontLister::get_instance(); + fontlister->update_font_list( sp_desktop_document( SP_ACTIVE_DESKTOP )); + Glib::RefPtr<Gtk::ListStore> store = fontlister->get_font_list(); GtkListStore* model = store->gobj(); - Ink_ComboBoxEntry_Action* act = ink_comboboxentry_action_new( "TextFontFamilyAction", - _("Font Family"), - _("Select Font Family (Alt-X to access)"), - NULL, - GTK_TREE_MODEL(model), - -1, // Entry width - 50, // Extra list width - (gpointer)cell_data_func,// Cell layout - GTK_WIDGET(desktop->canvas)); // Focus widget + Ink_ComboBoxEntry_Action* act = + ink_comboboxentry_action_new( "TextFontFamilyAction", + _("Font Family"), + _("Select Font Family (Alt-X to access)"), + NULL, + GTK_TREE_MODEL(model), + -1, // Entry width + 50, // Extra list width + (gpointer)font_lister_cell_data_func, // Cell layout + (gpointer)font_lister_separator_func, + GTK_WIDGET(desktop->canvas)); // Focus widget ink_comboboxentry_action_popup_enable( act ); // Enable entry completion gchar *const warning = _("Font not found on system"); ink_comboboxentry_action_set_warning( act, warning ); // Show icon with tooltip if missing font @@ -1483,7 +1539,13 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje "{\n" " GtkComboBox::appears-as-list = 1\n" "}\n" - "widget \"*.TextFontFamilyAction_combobox\" style \"dropdown-as-list-style\""); + "widget \"*.TextFontFamilyAction_combobox\" style \"dropdown-as-list-style\"" + "style \"fontfamily-separator-style\"\n" + "{\n" + " GtkWidget::wide-separators = 1\n" + " GtkWidget::separator-height = 6\n" + "}\n" + "widget \"*gtk-combobox-popup-window.GtkScrolledWindow.GtkTreeView\" style \"fontfamily-separator-style\""); } /* Font size */ @@ -1505,6 +1567,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje 4, // Width in characters 0, // Extra list width NULL, // Cell layout + NULL, // Separator GTK_WIDGET(desktop->canvas)); // Focus widget g_signal_connect( G_OBJECT(act), "changed", G_CALLBACK(sp_text_fontsize_value_changed), holder ); @@ -1524,6 +1587,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje 12, // Width in characters 0, // Extra list width NULL, // Cell layout + NULL, // Separator GTK_WIDGET(desktop->canvas)); // Focus widget g_signal_connect( G_OBJECT(act), "changed", G_CALLBACK(sp_text_fontstyle_value_changed), holder ); diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp index 4c339ad5a..24e2db9e1 100644 --- a/src/xml/repr-css.cpp +++ b/src/xml/repr-css.cpp @@ -27,6 +27,7 @@ #include "xml/repr.h" #include "xml/simple-document.h" #include "xml/simple-node.h" +#include "xml/sp-css-attr.h" #include "style.h" #include "libcroco/cr-sel-eng.h" diff --git a/src/xml/repr.h b/src/xml/repr.h index debd0f489..52f07d11f 100644 --- a/src/xml/repr.h +++ b/src/xml/repr.h @@ -14,16 +14,11 @@ #ifndef SEEN_SP_REPR_H #define SEEN_SP_REPR_H -#include <stdio.h> #include <glib.h> -#include "gc-anchored.h" +#include <glibmm/quark.h> #include "xml/node.h" #include "xml/document.h" -#include "xml/sp-css-attr.h" -#include "io/inkscapestream.h" - -#include <2geom/forward.h> #define SP_SODIPODI_NS_URI "http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" #define SP_BROKEN_SODIPODI_NS_URI "http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd" @@ -35,6 +30,18 @@ #define SP_OLD_CC_NS_URI "http://web.resource.org/cc/" #define SP_DC_NS_URI "http://purl.org/dc/elements/1.1/" +class SPCSSAttr; + +namespace Inkscape { +namespace IO { +class Writer; +} // namespace IO +} // namespace Inkscape + +namespace Geom { +class Point; +} + /* SPXMLNs */ char const *sp_xml_ns_uri_prefix(gchar const *uri, gchar const *suggested); char const *sp_xml_ns_prefix_uri(gchar const *prefix); diff --git a/src/zoom-context.cpp b/src/zoom-context.cpp index 9311901d3..7a5e4f90e 100644 --- a/src/zoom-context.cpp +++ b/src/zoom-context.cpp @@ -26,48 +26,23 @@ #include "zoom-context.h" -static void sp_zoom_context_class_init(SPZoomContextClass *klass); -static void sp_zoom_context_init(SPZoomContext *zoom_context); static void sp_zoom_context_setup(SPEventContext *ec); static void sp_zoom_context_finish (SPEventContext *ec); static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent *event); static gint sp_zoom_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event); -static SPEventContextClass *parent_class; - static gint xp = 0, yp = 0; // where drag started static gint tolerance = 0; static bool within_tolerance = false; static bool escaped; -GType sp_zoom_context_get_type(void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof(SPZoomContextClass), - NULL, NULL, - (GClassInitFunc) sp_zoom_context_class_init, - NULL, NULL, - sizeof(SPZoomContext), - 4, - (GInstanceInitFunc) sp_zoom_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPZoomContext", &info, (GTypeFlags) 0); - } - - return type; -} +G_DEFINE_TYPE(SPZoomContext, sp_zoom_context, SP_TYPE_EVENT_CONTEXT); static void sp_zoom_context_class_init(SPZoomContextClass *klass) { SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass); - parent_class = SP_EVENT_CONTEXT_CLASS(g_type_class_peek_parent(klass)); - event_context_class->setup = sp_zoom_context_setup; event_context_class->finish = sp_zoom_context_finish; @@ -107,8 +82,8 @@ static void sp_zoom_context_setup(SPEventContext *ec) ec->enableGrDrag(); } - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->setup) { - (SP_EVENT_CONTEXT_CLASS(parent_class))->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_zoom_context_parent_class))->setup) { + (SP_EVENT_CONTEXT_CLASS(sp_zoom_context_parent_class))->setup(ec); } } @@ -116,8 +91,8 @@ static gint sp_zoom_context_item_handler(SPEventContext *event_context, SPItem * { gint ret = FALSE; - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->item_handler) { - ret = (SP_EVENT_CONTEXT_CLASS(parent_class))->item_handler (event_context, item, event); + if ((SP_EVENT_CONTEXT_CLASS(sp_zoom_context_parent_class))->item_handler) { + ret = (SP_EVENT_CONTEXT_CLASS(sp_zoom_context_parent_class))->item_handler (event_context, item, event); } return ret; @@ -264,8 +239,8 @@ static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent } if (!ret) { - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler) { - ret = (SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler(event_context, event); + if ((SP_EVENT_CONTEXT_CLASS(sp_zoom_context_parent_class))->root_handler) { + ret = (SP_EVENT_CONTEXT_CLASS(sp_zoom_context_parent_class))->root_handler(event_context, event); } } |
