summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7dc9c1d)
raw | patch | inline | side by side (parent: 7dc9c1d)
author | joncruz <joncruz@users.sourceforge.net> | |
Sun, 2 Apr 2006 20:54:27 +0000 (20:54 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Sun, 2 Apr 2006 20:54:27 +0000 (20:54 +0000) |
ChangeLog | patch | blob | history | |
src/Makefile_insert | patch | blob | history | |
src/attributes.cpp | patch | blob | history | |
src/attributes.h | patch | blob | history | |
src/color-profile-fns.h | [new file with mode: 0644] | patch | blob |
src/color-profile.cpp | [new file with mode: 0644] | patch | blob |
src/color-profile.h | [new file with mode: 0644] | patch | blob |
src/sp-object-repr.cpp | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index 48aac83a61c42bb3be1995098894c893edc3da76..78687b96053e0f40579f6f419c68bf97e199235b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2005-04-02 Jon A. Cruz <jon@joncruz.org>
+
+ * src/color-profile.h, src/color-profile.cpp,
+ src/color-profile-fns.h, src/Makefile_insert, src/attributes.cpp,
+ src/attributes.h, src/sp-object-repr.cpp:
+
+ Adding support for <color-profile> element.
+
2005-04-02 Jon A. Cruz <jon@joncruz.org>
* src/knot.h: Fixed warning messages.
diff --git a/src/Makefile_insert b/src/Makefile_insert
index 22c1a2209ca217eedb34819455cec68019a0281a..c552f34018e9f069d04762487c80e8a3318012d5 100644 (file)
--- a/src/Makefile_insert
+++ b/src/Makefile_insert
bad-uri-exception.h \
brokenimage.xpm \
color-rgba.h \
+ color-profile.cpp color-profile.h \
+ color-profile-fns.h \
conn-avoid-ref.cpp conn-avoid-ref.h \
connector-context.cpp connector-context.h \
context-fns.cpp context-fns.h \
diff --git a/src/attributes.cpp b/src/attributes.cpp
index 10b33e178c19f1780e96c9e7b9201522bda2d895..39163c010f812a79671134f64fa9757bd7d0da25 100644 (file)
--- a/src/attributes.cpp
+++ b/src/attributes.cpp
{SP_ATTR_INKSCAPE_CURRENT_LAYER, "inkscape:current-layer"},
{SP_ATTR_INKSCAPE_DOCUMENT_UNITS, "inkscape:document-units"},
{SP_ATTR_INKSCAPE_CONNECTOR_SPACING, "inkscape:connector-spacing"},
+ /* SPColorProfile */
+ {SP_ATTR_LOCAL, "local"},
+ {SP_ATTR_NAME, "name"},
+ {SP_ATTR_RENDERING_INTENT, "rendering-intent"},
/* SPGuide */
{SP_ATTR_ORIENTATION, "orientation"},
{SP_ATTR_POSITION, "position"},
diff --git a/src/attributes.h b/src/attributes.h
index b36cf255717234adaab53aa030403f726f262512..897656845779ab8a356efba6c144005a3e63d08d 100644 (file)
--- a/src/attributes.h
+++ b/src/attributes.h
SP_ATTR_INKSCAPE_CURRENT_LAYER,
SP_ATTR_INKSCAPE_DOCUMENT_UNITS,
SP_ATTR_INKSCAPE_CONNECTOR_SPACING,
+ /* SPColorProfile */
+ SP_ATTR_LOCAL,
+ SP_ATTR_NAME,
+ SP_ATTR_RENDERING_INTENT,
/* SPGuide */
SP_ATTR_ORIENTATION,
SP_ATTR_POSITION,
diff --git a/src/color-profile-fns.h b/src/color-profile-fns.h
--- /dev/null
+++ b/src/color-profile-fns.h
@@ -0,0 +1,40 @@
+#ifndef SEEN_COLOR_PROFILE_FNS_H
+#define SEEN_COLOR_PROFILE_FNS_H
+
+/** \file
+ * Macros and fn declarations related to linear gradients.
+ */
+
+#include <glib-object.h>
+#include <glib/gtypes.h>
+
+namespace Inkscape {
+namespace XML {
+class Node;
+} // namespace XML
+
+class ColorProfile;
+
+GType colorprofile_get_type();
+
+} // namespace Inkscape
+
+#define COLORPROFILE_TYPE (Inkscape::colorprofile_get_type())
+#define COLORPROFILE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), COLORPROFILE_TYPE, Inkscape::ColorProfile))
+#define COLORPROFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), COLORPROFILE_TYPE, Inkscape::ColorProfileClass))
+#define IS_COLORPROFILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), COLORPROFILE_TYPE))
+#define IS_COLORPROFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), COLORPROFILE_TYPE))
+
+
+#endif // !SEEN_COLOR_PROFILE_FNS_H
+
+/*
+ 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:encoding=utf-8:textwidth=99 :
diff --git a/src/color-profile.cpp b/src/color-profile.cpp
--- /dev/null
+++ b/src/color-profile.cpp
@@ -0,0 +1,219 @@
+
+
+#include "xml/repr.h"
+#include "color-profile.h"
+#include "color-profile-fns.h"
+#include "attributes.h"
+
+using Inkscape::ColorProfile;
+using Inkscape::ColorProfileClass;
+
+static void colorprofile_class_init( ColorProfileClass *klass );
+static void colorprofile_init( ColorProfile *cprof );
+
+static void colorprofile_release( SPObject *object );
+static void colorprofile_build( SPObject *object, SPDocument *document, Inkscape::XML::Node *repr );
+static void colorprofile_set( SPObject *object, unsigned key, gchar const *value );
+static Inkscape::XML::Node *colorprofile_write( SPObject *object, Inkscape::XML::Node *repr, guint flags );
+
+static SPObject *cprof_parent_class;
+
+/**
+ * Register ColorProfile class and return its type.
+ */
+GType Inkscape::colorprofile_get_type()
+{
+ static GType type = 0;
+ if (!type) {
+ GTypeInfo info = {
+ sizeof(ColorProfileClass),
+ NULL, NULL,
+ (GClassInitFunc) colorprofile_class_init,
+ NULL, NULL,
+ sizeof(ColorProfile),
+ 16,
+ (GInstanceInitFunc) colorprofile_init,
+ NULL, /* value_table */
+ };
+ type = g_type_register_static( SP_TYPE_OBJECT, "ColorProfile", &info, static_cast<GTypeFlags>(0) );
+ }
+ return type;
+}
+
+/**
+ * ColorProfile vtable initialization.
+ */
+static void colorprofile_class_init( ColorProfileClass *klass )
+{
+ SPObjectClass *sp_object_class = reinterpret_cast<SPObjectClass *>(klass);
+
+ cprof_parent_class = static_cast<SPObject*>(g_type_class_ref(SP_TYPE_OBJECT));
+
+ sp_object_class->release = colorprofile_release;
+ sp_object_class->build = colorprofile_build;
+ sp_object_class->set = colorprofile_set;
+ sp_object_class->write = colorprofile_write;
+}
+
+/**
+ * Callback for ColorProfile object initialization.
+ */
+static void colorprofile_init( ColorProfile *cprof )
+{
+ cprof->href = 0;
+ cprof->local = 0;
+ cprof->name = 0;
+ cprof->rendering_intent = 0;
+#if ENABLE_LCMS
+ cprof->profHandle = 0;
+#endif // ENABLE_LCMS
+}
+
+/**
+ * Callback: free object
+ */
+static void colorprofile_release( SPObject *object )
+{
+ ColorProfile *cprof = COLORPROFILE(object);
+ if ( cprof->href ) {
+ g_free( cprof->href );
+ cprof->href = 0;
+ }
+
+ if ( cprof->local ) {
+ g_free( cprof->local );
+ cprof->local = 0;
+ }
+
+ if ( cprof->name ) {
+ g_free( cprof->name );
+ cprof->name = 0;
+ }
+
+#if ENABLE_LCMS
+ if ( cprof->profHandle ) {
+ cmsCloseProfile( cprof->profHandle );
+ cprof->profHandle = 0;
+ }
+#endif // ENABLE_LCMS
+}
+
+/**
+ * Callback: set attributes from associated repr.
+ */
+static void colorprofile_build( SPObject *object, SPDocument *document, Inkscape::XML::Node *repr )
+{
+ ColorProfile *cprof = COLORPROFILE(object);
+ g_assert(cprof->href == 0);
+ g_assert(cprof->local == 0);
+ g_assert(cprof->name == 0);
+
+ if (((SPObjectClass *) cprof_parent_class)->build) {
+ (* ((SPObjectClass *) cprof_parent_class)->build)(object, document, repr);
+ }
+ sp_object_read_attr( object, "xlink:href" );
+ sp_object_read_attr( object, "local" );
+ sp_object_read_attr( object, "name" );
+ sp_object_read_attr( object, "rendering-intent" );
+}
+
+/**
+ * Callback: set attribute.
+ */
+static void colorprofile_set( SPObject *object, unsigned key, gchar const *value )
+{
+ ColorProfile *cprof = COLORPROFILE(object);
+
+ switch (key) {
+ case SP_ATTR_XLINK_HREF:
+ if ( value ) {
+ cprof->href = g_strdup( value );
+ object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ if ( *cprof->href ) {
+#if ENABLE_LCMS
+ cmsErrorAction( LCMS_ERROR_SHOW );
+
+ // TODO open filename and URIs properly
+ //FILE* fp = fopen_utf8name( filename, "r" );
+ //LCMSAPI cmsHPROFILE LCMSEXPORT cmsOpenProfileFromMem(LPVOID MemPtr, DWORD dwSize);
+ cprof->profHandle = cmsOpenProfileFromFile( value, "r" );
+#endif // ENABLE_LCMS
+ }
+ }
+ break;
+
+ case SP_ATTR_LOCAL:
+ if ( value ) {
+ cprof->local = g_strdup( value );
+ object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ }
+ break;
+
+ case SP_ATTR_NAME:
+ if ( value ) {
+ cprof->name = g_strdup( value );
+ object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ }
+ break;
+
+ case SP_ATTR_RENDERING_INTENT:
+ if ( value ) {
+// auto | perceptual | relative-colorimetric | saturation | absolute-colorimetric
+ //cprof->name = g_strdup( value );
+ //object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ }
+ break;
+
+ default:
+ if (((SPObjectClass *) cprof_parent_class)->set) {
+ (* ((SPObjectClass *) cprof_parent_class)->set)(object, key, value);
+ }
+ break;
+ }
+}
+
+/**
+ * Callback: write attributes to associated repr.
+ */
+static Inkscape::XML::Node* colorprofile_write( SPObject *object, Inkscape::XML::Node *repr, guint flags )
+{
+ ColorProfile *cprof = COLORPROFILE(object);
+
+ if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
+ repr = sp_repr_new("svg:color-profile");
+ }
+
+ if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->href ) {
+ repr->setAttribute( "xlink:href", cprof->name );
+ }
+
+ if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->href ) {
+ repr->setAttribute( "local", cprof->name );
+ }
+
+ if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->href ) {
+ repr->setAttribute( "name", cprof->name );
+ }
+
+ if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->href ) {
+// repr->setAttribute( "rendering-intent", cprof->name );
+ }
+
+ if (((SPObjectClass *) cprof_parent_class)->write) {
+ (* ((SPObjectClass *) cprof_parent_class)->write)(object, repr, flags);
+ }
+
+ return repr;
+}
+
+
+/*
+ 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:encoding=utf-8:textwidth=99 :
diff --git a/src/color-profile.h b/src/color-profile.h
--- /dev/null
+++ b/src/color-profile.h
@@ -0,0 +1,46 @@
+#ifndef SEEN_COLOR_PROFILE_H
+#define SEEN_COLOR_PROFILE_H
+
+/** \file
+ * SPColorProfile: SVG <color-profile> implementation
+ */
+
+#include <glib/gtypes.h>
+#include <sp-object.h>
+#include "color-profile-fns.h"
+#if ENABLE_LCMS
+#include <lcms.h>
+#endif // ENABLE_LCMS
+
+namespace Inkscape {
+
+/** Color Profile. */
+struct ColorProfile : public SPObject {
+ gchar* href;
+ gchar* local;
+ gchar* name;
+ guint rendering_intent;
+#if ENABLE_LCMS
+ cmsHPROFILE profHandle;
+#endif // ENABLE_LCMS
+};
+
+/// The SPColorProfile vtable.
+struct ColorProfileClass {
+ SPObjectClass parent_class;
+};
+
+} // namespace Inkscape
+
+#endif // !SEEN_COLOR_PROFILE_H
+
+/*
+ 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:encoding=utf-8:textwidth=99 :
diff --git a/src/sp-object-repr.cpp b/src/sp-object-repr.cpp
index 4b631f3d57664cad90e944b32c8b054aa5e6e825..3987dbcbb99aa54edd291845317aec98aa1cd6ff 100644 (file)
--- a/src/sp-object-repr.cpp
+++ b/src/sp-object-repr.cpp
#include "sp-flowregion.h"
#include "sp-flowtext.h"
#include "sp-style-elem.h"
+#include "color-profile-fns.h"
#include "xml/repr.h"
enum NameType { REPR_NAME, SODIPODI_TYPE };
{ "svg:a", SP_TYPE_ANCHOR },
//{ "svg:animate", SP_TYPE_ANIMATE },
{ "svg:circle", SP_TYPE_CIRCLE },
+ { "svg:color-profile", COLORPROFILE_TYPE },
{ "svg:clipPath", SP_TYPE_CLIPPATH },
{ "svg:defs", SP_TYPE_DEFS },
{ "svg:ellipse", SP_TYPE_ELLIPSE },