diff --git a/src/color-profile.cpp b/src/color-profile.cpp
index 7b03c77736d7ea540c088e034a1c4d77ff836496..059d476f102571718de6e48622f569db9b43ffb6 100644 (file)
--- a/src/color-profile.cpp
+++ b/src/color-profile.cpp
#include "color-profile.h"
#include "color-profile-fns.h"
#include "attributes.h"
#include "color-profile.h"
#include "color-profile-fns.h"
#include "attributes.h"
+#include "inkscape.h"
#include "document.h"
#include "document.h"
+#include "dom/uri.h"
+
+//#define DEBUG_LCMS
+
+#ifdef DEBUG_LCMS
+#include "prefs-utils.h"
+#include <gtk/gtkmessagedialog.h>
+#endif // DEBUG_LCMS
+
using Inkscape::ColorProfile;
using Inkscape::ColorProfileClass;
using Inkscape::ColorProfile;
using Inkscape::ColorProfileClass;
static Inkscape::XML::Node *colorprofile_write( SPObject *object, Inkscape::XML::Node *repr, guint flags );
}
static Inkscape::XML::Node *colorprofile_write( SPObject *object, Inkscape::XML::Node *repr, guint flags );
}
+#ifdef DEBUG_LCMS
+extern guint update_in_progress;
+#define DEBUG_MESSAGE(key, ...) \
+{\
+ gint dump = prefs_get_int_attribute_limited("options.scislac", #key, 0, 0, 1);\
+ gint dumpD = prefs_get_int_attribute_limited("options.scislac", #key"D", 0, 0, 1);\
+ gint dumpD2 = prefs_get_int_attribute_limited("options.scislac", #key"D2", 0, 0, 1);\
+ dumpD &= ( (update_in_progress == 0) || dumpD2 );\
+ if ( dump )\
+ {\
+ g_message( __VA_ARGS__ );\
+\
+ }\
+ if ( dumpD )\
+ {\
+ GtkWidget *dialog = gtk_message_dialog_new(NULL,\
+ GTK_DIALOG_DESTROY_WITH_PARENT, \
+ GTK_MESSAGE_INFO, \
+ GTK_BUTTONS_OK, \
+ __VA_ARGS__ \
+ );\
+ g_signal_connect_swapped(dialog, "response",\
+ G_CALLBACK(gtk_widget_destroy), \
+ dialog); \
+ gtk_widget_show_all( dialog );\
+ }\
+}
+#endif // DEBUG_LCMS
+
static SPObject *cprof_parent_class;
/**
static SPObject *cprof_parent_class;
/**
@@ -151,17 +190,31 @@ static void Inkscape::colorprofile_set( SPObject *object, unsigned key, gchar co
//FILE* fp = fopen_utf8name( filename, "r" );
//LCMSAPI cmsHPROFILE LCMSEXPORT cmsOpenProfileFromMem(LPVOID MemPtr, DWORD dwSize);
//FILE* fp = fopen_utf8name( filename, "r" );
//LCMSAPI cmsHPROFILE LCMSEXPORT cmsOpenProfileFromMem(LPVOID MemPtr, DWORD dwSize);
- if ( !g_path_is_absolute(cprof->href) ) {
- // Try to open relative
- gchar* docbase = SP_DOCUMENT_BASE( SP_OBJECT_DOCUMENT(object) );
- gchar* fullname = g_build_filename( docbase ? docbase : ".", cprof->href, NULL );
-
- cprof->profHandle = cmsOpenProfileFromFile( fullname, "r" );
-
- g_free (fullname);
- } else {
- cprof->profHandle = cmsOpenProfileFromFile( cprof->href, "r" );
+ // Try to open relative
+ SPDocument *doc = SP_OBJECT_DOCUMENT(object);
+ if (!doc) {
+ doc = SP_ACTIVE_DOCUMENT;
+ g_warning("object has no document. using active");
}
}
+ //# 1. Get complete URI of document
+ gchar* docbase = SP_DOCUMENT_URI( doc );
+ if (!docbase)
+ {
+ g_warning("null docbase");
+ docbase = "";
+ }
+ //g_message("docbase:%s\n", docbase);
+ org::w3c::dom::URI docUri(docbase);
+ //# 2. Get href of icc file. we don't care if it's rel or abs
+ org::w3c::dom::URI hrefUri(cprof->href);
+ //# 3. Resolve the href according the docBase. This follows
+ // the w3c specs. All absolute and relative issues are considered
+ org::w3c::dom::URI cprofUri = docUri.resolve(hrefUri);
+ gchar* fullname = (gchar *)cprofUri.getNativePath().c_str();
+ cprof->profHandle = cmsOpenProfileFromFile( fullname, "r" );
+#ifdef DEBUG_LCMS
+ DEBUG_MESSAGE( lcmsOne, "cmsOpenProfileFromFile( '%s'...) = %p", fullname, (void*)cprof->profHandle );
+#endif // DEBUG_LCMS
#endif // ENABLE_LCMS
}
#endif // ENABLE_LCMS
}
@@ -184,6 +237,9 @@ static void Inkscape::colorprofile_set( SPObject *object, unsigned key, gchar co
cprof->name = 0;
}
cprof->name = g_strdup( value );
cprof->name = 0;
}
cprof->name = g_strdup( value );
+#ifdef DEBUG_LCMS
+ DEBUG_MESSAGE( lcmsTwo, "<color-profile> name set to '%s'", cprof->name );
+#endif // DEBUG_LCMS
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
@@ -232,7 +288,8 @@ static Inkscape::XML::Node* Inkscape::colorprofile_write( SPObject *object, Inks
ColorProfile *cprof = COLORPROFILE(object);
if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
ColorProfile *cprof = COLORPROFILE(object);
if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
- repr = sp_repr_new("svg:color-profile");
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object));
+ repr = xml_doc->createElement("svg:color-profile");
}
if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->href ) {
}
if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->href ) {
@@ -304,6 +361,10 @@ cmsHPROFILE Inkscape::colorprofile_get_handle( SPDocument* document, guint* inte
*intent = thing ? COLORPROFILE(thing)->rendering_intent : (guint)RENDERING_INTENT_UNKNOWN;
}
*intent = thing ? COLORPROFILE(thing)->rendering_intent : (guint)RENDERING_INTENT_UNKNOWN;
}
+#ifdef DEBUG_LCMS
+ DEBUG_MESSAGE( lcmsThree, "<color-profile> queried for profile of '%s'. Returning %p with intent of %d", name, prof, (intent? *intent:0) );
+#endif // DEBUG_LCMS
+
return prof;
}
#endif // ENABLE_LCMS
return prof;
}
#endif // ENABLE_LCMS