From a0a8d020201e0e38a63d9aa3dce228d7d9e6fb35 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Thu, 14 Mar 2013 12:42:39 +0100 Subject: Various changes. (bzr r11608.1.48) --- src/color-profile.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/color-profile.cpp') diff --git a/src/color-profile.cpp b/src/color-profile.cpp index a1e9dd0f1..c9af64723 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -219,7 +219,7 @@ void ColorProfile::classInit( ColorProfileClass *klass ) cprof_parent_class = static_cast(g_type_class_ref(SP_TYPE_OBJECT)); sp_object_class->release = ColorProfile::release; - sp_object_class->build = ColorProfile::build; + //sp_object_class->build = ColorProfile::build; sp_object_class->set = ColorProfile::set; sp_object_class->write = ColorProfile::write; } @@ -312,9 +312,11 @@ void ColorProfile::build( SPObject *object, SPDocument *document, Inkscape::XML: g_assert(cprof->name == 0); g_assert(cprof->intentStr == 0); - if (cprof_parent_class->build) { - (* cprof_parent_class->build)(object, document, repr); - } +// if (cprof_parent_class->build) { +// (* cprof_parent_class->build)(object, document, repr); +// } + // CPPIFY: todo + object->readAttr( "xlink:href" ); object->readAttr( "local" ); object->readAttr( "name" ); -- cgit v1.2.3 From 732214b111f2e830a8a0b654a88b087766be9067 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 30 Mar 2013 00:46:09 +0100 Subject: Added "virtual pads" for - ColorProfile - LivePathEffectObject - Persp3D (bzr r11608.1.51) --- src/color-profile.cpp | 245 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 237 insertions(+), 8 deletions(-) (limited to 'src/color-profile.cpp') diff --git a/src/color-profile.cpp b/src/color-profile.cpp index c9af64723..ac341dfe5 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -51,6 +51,8 @@ using Inkscape::ColorProfile; using Inkscape::ColorProfileClass; using Inkscape::ColorProfileImpl; +using Inkscape::CColorProfile; + namespace { #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -224,11 +226,21 @@ void ColorProfile::classInit( ColorProfileClass *klass ) sp_object_class->write = ColorProfile::write; } +CColorProfile::CColorProfile(ColorProfile* cp) : CObject(cp) { + this->colorprofile = cp; +} + +CColorProfile::~CColorProfile() { +} + /** * Callback for ColorProfile object initialization. */ void ColorProfile::init( ColorProfile *cprof ) { + cprof->ccolorprofile = new CColorProfile(cprof); + cprof->cobject = cprof->ccolorprofile; + cprof->impl = new ColorProfileImpl(); cprof->href = 0; @@ -243,6 +255,44 @@ void ColorProfile::init( ColorProfile *cprof ) */ void ColorProfile::release( SPObject *object ) { +// // Unregister ourselves +// if ( object->document ) { +// object->document->removeResource("iccprofile", 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 ( cprof->intentStr ) { +// g_free( cprof->intentStr ); +// cprof->intentStr = 0; +// } +// +//#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +// cprof->impl->_clearProfile(); +//#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +// +// delete cprof->impl; +// cprof->impl = 0; + ((ColorProfile*)object)->ccolorprofile->onRelease(); +} + +void CColorProfile::onRelease() { + ColorProfile* object = this->colorprofile; + // Unregister ourselves if ( object->document ) { object->document->removeResource("iccprofile", object); @@ -306,6 +356,31 @@ void ColorProfileImpl::_clearProfile() */ 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); +// g_assert(cprof->intentStr == 0); +// +//// if (cprof_parent_class->build) { +//// (* cprof_parent_class->build)(object, document, repr); +//// } +// +// object->readAttr( "xlink:href" ); +// object->readAttr( "local" ); +// object->readAttr( "name" ); +// object->readAttr( "rendering-intent" ); +// +// // Register +// if ( document ) { +// document->addResource( "iccprofile", object ); +// } + ((ColorProfile*)object)->ccolorprofile->onBuild(document, repr); +} + +void CColorProfile::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { + ColorProfile* object = this->colorprofile; + ColorProfile *cprof = COLORPROFILE(object); g_assert(cprof->href == 0); g_assert(cprof->local == 0); @@ -315,7 +390,7 @@ void ColorProfile::build( SPObject *object, SPDocument *document, Inkscape::XML: // if (cprof_parent_class->build) { // (* cprof_parent_class->build)(object, document, repr); // } - // CPPIFY: todo + CObject::onBuild(document, repr); object->readAttr( "xlink:href" ); object->readAttr( "local" ); @@ -328,11 +403,131 @@ void ColorProfile::build( SPObject *object, SPDocument *document, Inkscape::XML: } } + /** * Callback: set attribute. */ void ColorProfile::set( SPObject *object, unsigned key, gchar const *value ) { +// ColorProfile *cprof = COLORPROFILE(object); +// +// switch (key) { +// case SP_ATTR_XLINK_HREF: +// if ( cprof->href ) { +// g_free( cprof->href ); +// cprof->href = 0; +// } +// if ( value ) { +// cprof->href = g_strdup( value ); +// if ( *cprof->href ) { +//#if HAVE_LIBLCMS1 +// cmsErrorAction( LCMS_ERROR_SHOW ); +//#endif +//#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +// +// // TODO open filename and URIs properly +// //FILE* fp = fopen_utf8name( filename, "r" ); +// //LCMSAPI cmsHPROFILE LCMSEXPORT cmsOpenProfileFromMem(LPVOID MemPtr, cmsUInt32Number dwSize); +// +// // Try to open relative +// SPDocument *doc = object->document; +// if (!doc) { +// doc = SP_ACTIVE_DOCUMENT; +// g_warning("object has no document. using active"); +// } +// //# 1. Get complete URI of document +// gchar const *docbase = doc->getURI(); +// if (!docbase) +// { +// // Normal for files that have not yet been saved. +// docbase = ""; +// } +// +// gchar* escaped = g_uri_escape_string(cprof->href, "!*'();:@=+$,/?#[]", TRUE); +// +// //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(escaped); +// //# 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 = g_uri_unescape_string(cprofUri.getNativePath().c_str(), ""); +// cprof->impl->_clearProfile(); +// cprof->impl->_profHandle = cmsOpenProfileFromFile( fullname, "r" ); +// if ( cprof->impl->_profHandle ) { +// cprof->impl->_profileSpace = cmsGetColorSpace( cprof->impl->_profHandle ); +// cprof->impl->_profileClass = cmsGetDeviceClass( cprof->impl->_profHandle ); +// } +// DEBUG_MESSAGE( lcmsOne, "cmsOpenProfileFromFile( '%s'...) = %p", fullname, (void*)cprof->impl->_profHandle ); +// g_free(escaped); +// escaped = 0; +// g_free(fullname); +//#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +// } +// } +// object->requestModified(SP_OBJECT_MODIFIED_FLAG); +// break; +// +// case SP_ATTR_LOCAL: +// if ( cprof->local ) { +// g_free( cprof->local ); +// cprof->local = 0; +// } +// cprof->local = g_strdup( value ); +// object->requestModified(SP_OBJECT_MODIFIED_FLAG); +// break; +// +// case SP_ATTR_NAME: +// if ( cprof->name ) { +// g_free( cprof->name ); +// cprof->name = 0; +// } +// cprof->name = g_strdup( value ); +// DEBUG_MESSAGE( lcmsTwo, " name set to '%s'", cprof->name ); +// object->requestModified(SP_OBJECT_MODIFIED_FLAG); +// break; +// +// case SP_ATTR_RENDERING_INTENT: +// if ( cprof->intentStr ) { +// g_free( cprof->intentStr ); +// cprof->intentStr = 0; +// } +// cprof->intentStr = g_strdup( value ); +// +// if ( value ) { +// if ( strcmp( value, "auto" ) == 0 ) { +// cprof->rendering_intent = RENDERING_INTENT_AUTO; +// } else if ( strcmp( value, "perceptual" ) == 0 ) { +// cprof->rendering_intent = RENDERING_INTENT_PERCEPTUAL; +// } else if ( strcmp( value, "relative-colorimetric" ) == 0 ) { +// cprof->rendering_intent = RENDERING_INTENT_RELATIVE_COLORIMETRIC; +// } else if ( strcmp( value, "saturation" ) == 0 ) { +// cprof->rendering_intent = RENDERING_INTENT_SATURATION; +// } else if ( strcmp( value, "absolute-colorimetric" ) == 0 ) { +// cprof->rendering_intent = RENDERING_INTENT_ABSOLUTE_COLORIMETRIC; +// } else { +// cprof->rendering_intent = RENDERING_INTENT_UNKNOWN; +// } +// } else { +// cprof->rendering_intent = RENDERING_INTENT_UNKNOWN; +// } +// +// object->requestModified(SP_OBJECT_MODIFIED_FLAG); +// break; +// +// default: +// if (cprof_parent_class->set) { +// (* cprof_parent_class->set)(object, key, value); +// } +// break; +// } + ((ColorProfile*)object)->ccolorprofile->onSet(key, value); +} + +void CColorProfile::onSet(unsigned key, gchar const *value) { + ColorProfile* object = this->colorprofile; + ColorProfile *cprof = COLORPROFILE(object); switch (key) { @@ -441,12 +636,12 @@ void ColorProfile::set( SPObject *object, unsigned key, gchar const *value ) break; default: - if (cprof_parent_class->set) { - (* cprof_parent_class->set)(object, key, value); - } +// if (cprof_parent_class->set) { +// (* cprof_parent_class->set)(object, key, value); +// } + CObject::onSet(key, value); break; } - } /** @@ -454,6 +649,39 @@ void ColorProfile::set( SPObject *object, unsigned key, gchar const *value ) */ Inkscape::XML::Node* ColorProfile::write( SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags ) { +// ColorProfile *cprof = COLORPROFILE(object); +// +// if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { +// repr = xml_doc->createElement("svg:color-profile"); +// } +// +// if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->href ) { +// repr->setAttribute( "xlink:href", cprof->href ); +// } +// +// if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->local ) { +// repr->setAttribute( "local", cprof->local ); +// } +// +// if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->name ) { +// repr->setAttribute( "name", cprof->name ); +// } +// +// if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->intentStr ) { +// repr->setAttribute( "rendering-intent", cprof->intentStr ); +// } +// +// if (cprof_parent_class->write) { +// (* cprof_parent_class->write)(object, xml_doc, repr, flags); +// } +// +// return repr; + return ((ColorProfile*)object)->ccolorprofile->onWrite(xml_doc, repr, flags); +} + +Inkscape::XML::Node* CColorProfile::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + ColorProfile* object = this->colorprofile; + ColorProfile *cprof = COLORPROFILE(object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { @@ -476,9 +704,10 @@ Inkscape::XML::Node* ColorProfile::write( SPObject *object, Inkscape::XML::Docum repr->setAttribute( "rendering-intent", cprof->intentStr ); } - if (cprof_parent_class->write) { - (* cprof_parent_class->write)(object, xml_doc, repr, flags); - } +// if (cprof_parent_class->write) { +// (* cprof_parent_class->write)(object, xml_doc, repr, flags); +// } + CObject::onWrite(xml_doc, repr, flags); return repr; } -- cgit v1.2.3 From 957c3e4b7909d42c5a13f1b1dd583f877fc32259 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 30 Mar 2013 00:46:57 +0100 Subject: Removed function pointers from SPObject and subclasses. Added some missing virtual pads for classes that were hidden by preprocessor macros. (bzr r11608.1.55) --- src/color-profile.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/color-profile.cpp') diff --git a/src/color-profile.cpp b/src/color-profile.cpp index ac341dfe5..9be2ea335 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -220,10 +220,10 @@ void ColorProfile::classInit( ColorProfileClass *klass ) cprof_parent_class = static_cast(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; +// sp_object_class->release = ColorProfile::release; +// //sp_object_class->build = ColorProfile::build; +// sp_object_class->set = ColorProfile::set; +// sp_object_class->write = ColorProfile::write; } CColorProfile::CColorProfile(ColorProfile* cp) : CObject(cp) { -- cgit v1.2.3 From 7df6616da5ea2debb86838366ddf746841549cdb Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 30 Mar 2013 00:56:13 +0100 Subject: Renamed virtual function names. (bzr r11608.1.57) --- src/color-profile.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/color-profile.cpp') diff --git a/src/color-profile.cpp b/src/color-profile.cpp index ca44ad49f..a2810d22c 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -250,7 +250,7 @@ void ColorProfile::init( ColorProfile *cprof ) /** * Callback: free object */ -void CColorProfile::onRelease() { +void CColorProfile::release() { ColorProfile* object = this->colorprofile; // Unregister ourselves @@ -314,7 +314,7 @@ void ColorProfileImpl::_clearProfile() /** * Callback: set attributes from associated repr. */ -void CColorProfile::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { +void CColorProfile::build(SPDocument *document, Inkscape::XML::Node *repr) { ColorProfile* object = this->colorprofile; ColorProfile *cprof = COLORPROFILE(object); @@ -323,7 +323,7 @@ void CColorProfile::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { g_assert(cprof->name == 0); g_assert(cprof->intentStr == 0); - CObject::onBuild(document, repr); + CObject::build(document, repr); object->readAttr( "xlink:href" ); object->readAttr( "local" ); @@ -340,7 +340,7 @@ void CColorProfile::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { /** * Callback: set attribute. */ -void CColorProfile::onSet(unsigned key, gchar const *value) { +void CColorProfile::set(unsigned key, gchar const *value) { ColorProfile* object = this->colorprofile; ColorProfile *cprof = COLORPROFILE(object); @@ -451,7 +451,7 @@ void CColorProfile::onSet(unsigned key, gchar const *value) { break; default: - CObject::onSet(key, value); + CObject::set(key, value); break; } } @@ -459,7 +459,7 @@ void CColorProfile::onSet(unsigned key, gchar const *value) { /** * Callback: write attributes to associated repr. */ -Inkscape::XML::Node* CColorProfile::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { +Inkscape::XML::Node* CColorProfile::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { ColorProfile* object = this->colorprofile; ColorProfile *cprof = COLORPROFILE(object); @@ -484,7 +484,7 @@ Inkscape::XML::Node* CColorProfile::onWrite(Inkscape::XML::Document *xml_doc, In repr->setAttribute( "rendering-intent", cprof->intentStr ); } - CObject::onWrite(xml_doc, repr, flags); + CObject::write(xml_doc, repr, flags); return repr; } -- cgit v1.2.3 From a5d6e692d661f0bf7648e64e8fcb04588bb8f3ab Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Mon, 1 Apr 2013 00:07:00 +0200 Subject: Prepared exchange of casting macros. (bzr r11608.1.63) --- src/color-profile.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/color-profile.cpp') diff --git a/src/color-profile.cpp b/src/color-profile.cpp index a2810d22c..ae647944b 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -234,6 +234,7 @@ CColorProfile::~CColorProfile() { void ColorProfile::init( ColorProfile *cprof ) { cprof->ccolorprofile = new CColorProfile(cprof); + cprof->typeHierarchy.insert(typeid(ColorProfile)); delete cprof->cobject; cprof->cobject = cprof->ccolorprofile; -- cgit v1.2.3 From 69f3b6f1abb2bb422935d43262e1e99aab359954 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 2 Apr 2013 01:41:30 +0200 Subject: Added constructors to SP classes. (bzr r11608.1.67) --- src/color-profile.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/color-profile.cpp') diff --git a/src/color-profile.cpp b/src/color-profile.cpp index ae647944b..63cb3addc 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -199,14 +199,14 @@ GType ColorProfile::getType() GTypeInfo info = { sizeof(ColorProfileClass), NULL, NULL, - (GClassInitFunc) ColorProfile::classInit, + 0, //(GClassInitFunc) ColorProfile::classInit, NULL, NULL, sizeof(ColorProfile), 16, (GInstanceInitFunc) ColorProfile::init, NULL, /* value_table */ }; - type = g_type_register_static( SP_TYPE_OBJECT, "ColorProfile", &info, static_cast(0) ); + type = g_type_register_static( G_TYPE_OBJECT, "ColorProfile", &info, static_cast(0) ); } return type; } @@ -228,11 +228,9 @@ CColorProfile::CColorProfile(ColorProfile* cp) : CObject(cp) { CColorProfile::~CColorProfile() { } -/** - * Callback for ColorProfile object initialization. - */ -void ColorProfile::init( ColorProfile *cprof ) -{ +ColorProfile::ColorProfile() : SPObject() { + ColorProfile* cprof = this; + cprof->ccolorprofile = new CColorProfile(cprof); cprof->typeHierarchy.insert(typeid(ColorProfile)); @@ -248,6 +246,14 @@ void ColorProfile::init( ColorProfile *cprof ) cprof->rendering_intent = Inkscape::RENDERING_INTENT_UNKNOWN; } +/** + * Callback for ColorProfile object initialization. + */ +void ColorProfile::init( ColorProfile *cprof ) +{ + new (cprof) ColorProfile(); +} + /** * Callback: free object */ -- cgit v1.2.3 From d1af3566872dfff2aeec84859c87f1f8d13f79df Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 2 Apr 2013 19:14:36 +0200 Subject: Registered classes with new factory. Hkern, Vkern and FeFuncX have to be rewritten, as they aren't real classes. (bzr r11608.1.69) --- src/color-profile.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/color-profile.cpp') diff --git a/src/color-profile.cpp b/src/color-profile.cpp index 63cb3addc..f1d89111d 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -184,6 +184,18 @@ cmsHPROFILE ColorProfileImpl::getNULLProfile() { #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + +#include "sp-factory.h" + +namespace { + SPObject* createColorProfile() { + return new Inkscape::ColorProfile(); + } + + bool rectRegistered = SPFactory::instance().registerObject("svg:color-profile", createColorProfile); +} + + /** * Register ColorProfile class and return its type. */ -- cgit v1.2.3 From 7b7e0294b0c06a8d3ec19b73486a91e12cf67adf Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 6 Apr 2013 22:16:05 +0200 Subject: Merged more classes. (bzr r11608.1.84) --- src/color-profile.cpp | 96 ++++++++++----------------------------------------- 1 file changed, 18 insertions(+), 78 deletions(-) (limited to 'src/color-profile.cpp') diff --git a/src/color-profile.cpp b/src/color-profile.cpp index f1d89111d..0373ab317 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -50,11 +50,8 @@ #include using Inkscape::ColorProfile; -using Inkscape::ColorProfileClass; using Inkscape::ColorProfileImpl; -using Inkscape::CColorProfile; - namespace { #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -105,8 +102,6 @@ extern guint update_in_progress; #define DEBUG_MESSAGE(key, ...) #endif // DEBUG_LCMS -static SPObjectClass *cprof_parent_class; - namespace Inkscape { class ColorProfileImpl { @@ -195,82 +190,27 @@ namespace { bool rectRegistered = SPFactory::instance().registerObject("svg:color-profile", createColorProfile); } +ColorProfile::ColorProfile() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; -/** - * Register ColorProfile class and return its type. - */ -GType Inkscape::colorprofile_get_type() -{ - return ColorProfile::getType(); -} - -GType ColorProfile::getType() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(ColorProfileClass), - NULL, NULL, - 0, //(GClassInitFunc) ColorProfile::classInit, - NULL, NULL, - sizeof(ColorProfile), - 16, - (GInstanceInitFunc) ColorProfile::init, - NULL, /* value_table */ - }; - type = g_type_register_static( G_TYPE_OBJECT, "ColorProfile", &info, static_cast(0) ); - } - return type; -} - -/** - * ColorProfile vtable initialization. - */ -void ColorProfile::classInit( ColorProfileClass *klass ) -{ - SPObjectClass *sp_object_class = reinterpret_cast(klass); + this->impl = new ColorProfileImpl(); - cprof_parent_class = static_cast(g_type_class_ref(SP_TYPE_OBJECT)); + this->href = 0; + this->local = 0; + this->name = 0; + this->intentStr = 0; + this->rendering_intent = Inkscape::RENDERING_INTENT_UNKNOWN; } -CColorProfile::CColorProfile(ColorProfile* cp) : CObject(cp) { - this->colorprofile = cp; -} - -CColorProfile::~CColorProfile() { -} - -ColorProfile::ColorProfile() : SPObject() { - ColorProfile* cprof = this; - - cprof->ccolorprofile = new CColorProfile(cprof); - cprof->typeHierarchy.insert(typeid(ColorProfile)); - - delete cprof->cobject; - cprof->cobject = cprof->ccolorprofile; - - cprof->impl = new ColorProfileImpl(); - - cprof->href = 0; - cprof->local = 0; - cprof->name = 0; - cprof->intentStr = 0; - cprof->rendering_intent = Inkscape::RENDERING_INTENT_UNKNOWN; -} - -/** - * Callback for ColorProfile object initialization. - */ -void ColorProfile::init( ColorProfile *cprof ) -{ - new (cprof) ColorProfile(); +ColorProfile::~ColorProfile() { } /** * Callback: free object */ -void CColorProfile::release() { - ColorProfile* object = this->colorprofile; +void ColorProfile::release() { + ColorProfile* object = this; // Unregister ourselves if ( object->document ) { @@ -333,8 +273,8 @@ void ColorProfileImpl::_clearProfile() /** * Callback: set attributes from associated repr. */ -void CColorProfile::build(SPDocument *document, Inkscape::XML::Node *repr) { - ColorProfile* object = this->colorprofile; +void ColorProfile::build(SPDocument *document, Inkscape::XML::Node *repr) { + ColorProfile* object = this; ColorProfile *cprof = COLORPROFILE(object); g_assert(cprof->href == 0); @@ -359,8 +299,8 @@ void CColorProfile::build(SPDocument *document, Inkscape::XML::Node *repr) { /** * Callback: set attribute. */ -void CColorProfile::set(unsigned key, gchar const *value) { - ColorProfile* object = this->colorprofile; +void ColorProfile::set(unsigned key, gchar const *value) { + ColorProfile* object = this; ColorProfile *cprof = COLORPROFILE(object); @@ -478,8 +418,8 @@ void CColorProfile::set(unsigned key, gchar const *value) { /** * Callback: write attributes to associated repr. */ -Inkscape::XML::Node* CColorProfile::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - ColorProfile* object = this->colorprofile; +Inkscape::XML::Node* ColorProfile::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + ColorProfile* object = this; ColorProfile *cprof = COLORPROFILE(object); -- cgit v1.2.3 From 27e2102f96a5554bcd5310ec11435d155773b279 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 7 Apr 2013 18:28:22 +0200 Subject: Merge Object and subclasses. Merging of SP- and C-classes complete. (bzr r11608.1.86) --- src/color-profile.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/color-profile.cpp') diff --git a/src/color-profile.cpp b/src/color-profile.cpp index 0373ab317..6e9414074 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -190,10 +190,7 @@ namespace { bool rectRegistered = SPFactory::instance().registerObject("svg:color-profile", createColorProfile); } -ColorProfile::ColorProfile() : SPObject(), CObject(this) { - delete this->cobject; - this->cobject = this; - +ColorProfile::ColorProfile() : SPObject() { this->impl = new ColorProfileImpl(); this->href = 0; @@ -282,7 +279,7 @@ void ColorProfile::build(SPDocument *document, Inkscape::XML::Node *repr) { g_assert(cprof->name == 0); g_assert(cprof->intentStr == 0); - CObject::build(document, repr); + SPObject::build(document, repr); object->readAttr( "xlink:href" ); object->readAttr( "local" ); @@ -410,7 +407,7 @@ void ColorProfile::set(unsigned key, gchar const *value) { break; default: - CObject::set(key, value); + SPObject::set(key, value); break; } } @@ -443,7 +440,7 @@ Inkscape::XML::Node* ColorProfile::write(Inkscape::XML::Document *xml_doc, Inksc repr->setAttribute( "rendering-intent", cprof->intentStr ); } - CObject::write(xml_doc, repr, flags); + SPObject::write(xml_doc, repr, flags); return repr; } -- cgit v1.2.3 From beecbea1b415d5b9536f2309c4f30fc258e346f5 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Wed, 31 Jul 2013 22:51:23 +0200 Subject: Cleaned up a bit; fixed struct vs. class forward declarations. (bzr r11608.1.111) --- src/color-profile.cpp | 158 +++++++++++++++++++++++--------------------------- 1 file changed, 72 insertions(+), 86 deletions(-) (limited to 'src/color-profile.cpp') diff --git a/src/color-profile.cpp b/src/color-profile.cpp index 8e51ea6de..61442b11a 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -207,40 +207,37 @@ ColorProfile::~ColorProfile() { * Callback: free object */ void ColorProfile::release() { - ColorProfile* object = this; - // Unregister ourselves - if ( object->document ) { - object->document->removeResource("iccprofile", object); + if ( this->document ) { + this->document->removeResource("iccprofile", this); } - ColorProfile *cprof = COLORPROFILE(object); - if ( cprof->href ) { - g_free( cprof->href ); - cprof->href = 0; + if ( this->href ) { + g_free( this->href ); + this->href = 0; } - if ( cprof->local ) { - g_free( cprof->local ); - cprof->local = 0; + if ( this->local ) { + g_free( this->local ); + this->local = 0; } - if ( cprof->name ) { - g_free( cprof->name ); - cprof->name = 0; + if ( this->name ) { + g_free( this->name ); + this->name = 0; } - if ( cprof->intentStr ) { - g_free( cprof->intentStr ); - cprof->intentStr = 0; + if ( this->intentStr ) { + g_free( this->intentStr ); + this->intentStr = 0; } #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - cprof->impl->_clearProfile(); + this->impl->_clearProfile(); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - delete cprof->impl; - cprof->impl = 0; + delete this->impl; + this->impl = 0; } #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -271,24 +268,21 @@ void ColorProfileImpl::_clearProfile() * Callback: set attributes from associated repr. */ void ColorProfile::build(SPDocument *document, Inkscape::XML::Node *repr) { - ColorProfile* object = this; - - ColorProfile *cprof = COLORPROFILE(object); - g_assert(cprof->href == 0); - g_assert(cprof->local == 0); - g_assert(cprof->name == 0); - g_assert(cprof->intentStr == 0); + g_assert(this->href == 0); + g_assert(this->local == 0); + g_assert(this->name == 0); + g_assert(this->intentStr == 0); SPObject::build(document, repr); - object->readAttr( "xlink:href" ); - object->readAttr( "local" ); - object->readAttr( "name" ); - object->readAttr( "rendering-intent" ); + this->readAttr( "xlink:href" ); + this->readAttr( "local" ); + this->readAttr( "name" ); + this->readAttr( "rendering-intent" ); // Register if ( document ) { - document->addResource( "iccprofile", object ); + document->addResource( "iccprofile", this ); } } @@ -297,19 +291,15 @@ void ColorProfile::build(SPDocument *document, Inkscape::XML::Node *repr) { * Callback: set attribute. */ void ColorProfile::set(unsigned key, gchar const *value) { - ColorProfile* object = this; - - ColorProfile *cprof = COLORPROFILE(object); - switch (key) { case SP_ATTR_XLINK_HREF: - if ( cprof->href ) { - g_free( cprof->href ); - cprof->href = 0; + if ( this->href ) { + g_free( this->href ); + this->href = 0; } if ( value ) { - cprof->href = g_strdup( value ); - if ( *cprof->href ) { + this->href = g_strdup( value ); + if ( *this->href ) { #if HAVE_LIBLCMS1 cmsErrorAction( LCMS_ERROR_SHOW ); #endif @@ -320,10 +310,10 @@ void ColorProfile::set(unsigned key, gchar const *value) { //LCMSAPI cmsHPROFILE LCMSEXPORT cmsOpenProfileFromMem(LPVOID MemPtr, cmsUInt32Number dwSize); // Try to open relative - SPDocument *doc = object->document; + SPDocument *doc = this->document; if (!doc) { doc = SP_ACTIVE_DOCUMENT; - g_warning("object has no document. using active"); + g_warning("this has no document. using active"); } //# 1. Get complete URI of document gchar const *docbase = doc->getURI(); @@ -333,7 +323,7 @@ void ColorProfile::set(unsigned key, gchar const *value) { docbase = ""; } - gchar* escaped = g_uri_escape_string(cprof->href, "!*'();:@=+$,/?#[]", TRUE); + gchar* escaped = g_uri_escape_string(this->href, "!*'();:@=+$,/?#[]", TRUE); //g_message("docbase:%s\n", docbase); org::w3c::dom::URI docUri(docbase); @@ -343,67 +333,67 @@ void ColorProfile::set(unsigned key, gchar const *value) { // the w3c specs. All absolute and relative issues are considered org::w3c::dom::URI cprofUri = docUri.resolve(hrefUri); gchar* fullname = g_uri_unescape_string(cprofUri.getNativePath().c_str(), ""); - cprof->impl->_clearProfile(); - cprof->impl->_profHandle = cmsOpenProfileFromFile( fullname, "r" ); - if ( cprof->impl->_profHandle ) { - cprof->impl->_profileSpace = cmsGetColorSpace( cprof->impl->_profHandle ); - cprof->impl->_profileClass = cmsGetDeviceClass( cprof->impl->_profHandle ); + this->impl->_clearProfile(); + this->impl->_profHandle = cmsOpenProfileFromFile( fullname, "r" ); + if ( this->impl->_profHandle ) { + this->impl->_profileSpace = cmsGetColorSpace( this->impl->_profHandle ); + this->impl->_profileClass = cmsGetDeviceClass( this->impl->_profHandle ); } - DEBUG_MESSAGE( lcmsOne, "cmsOpenProfileFromFile( '%s'...) = %p", fullname, (void*)cprof->impl->_profHandle ); + DEBUG_MESSAGE( lcmsOne, "cmsOpenProfileFromFile( '%s'...) = %p", fullname, (void*)this->impl->_profHandle ); g_free(escaped); escaped = 0; g_free(fullname); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) } } - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_LOCAL: - if ( cprof->local ) { - g_free( cprof->local ); - cprof->local = 0; + if ( this->local ) { + g_free( this->local ); + this->local = 0; } - cprof->local = g_strdup( value ); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->local = g_strdup( value ); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_NAME: - if ( cprof->name ) { - g_free( cprof->name ); - cprof->name = 0; + if ( this->name ) { + g_free( this->name ); + this->name = 0; } - cprof->name = g_strdup( value ); - DEBUG_MESSAGE( lcmsTwo, " name set to '%s'", cprof->name ); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->name = g_strdup( value ); + DEBUG_MESSAGE( lcmsTwo, " name set to '%s'", this->name ); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_RENDERING_INTENT: - if ( cprof->intentStr ) { - g_free( cprof->intentStr ); - cprof->intentStr = 0; + if ( this->intentStr ) { + g_free( this->intentStr ); + this->intentStr = 0; } - cprof->intentStr = g_strdup( value ); + this->intentStr = g_strdup( value ); if ( value ) { if ( strcmp( value, "auto" ) == 0 ) { - cprof->rendering_intent = RENDERING_INTENT_AUTO; + this->rendering_intent = RENDERING_INTENT_AUTO; } else if ( strcmp( value, "perceptual" ) == 0 ) { - cprof->rendering_intent = RENDERING_INTENT_PERCEPTUAL; + this->rendering_intent = RENDERING_INTENT_PERCEPTUAL; } else if ( strcmp( value, "relative-colorimetric" ) == 0 ) { - cprof->rendering_intent = RENDERING_INTENT_RELATIVE_COLORIMETRIC; + this->rendering_intent = RENDERING_INTENT_RELATIVE_COLORIMETRIC; } else if ( strcmp( value, "saturation" ) == 0 ) { - cprof->rendering_intent = RENDERING_INTENT_SATURATION; + this->rendering_intent = RENDERING_INTENT_SATURATION; } else if ( strcmp( value, "absolute-colorimetric" ) == 0 ) { - cprof->rendering_intent = RENDERING_INTENT_ABSOLUTE_COLORIMETRIC; + this->rendering_intent = RENDERING_INTENT_ABSOLUTE_COLORIMETRIC; } else { - cprof->rendering_intent = RENDERING_INTENT_UNKNOWN; + this->rendering_intent = RENDERING_INTENT_UNKNOWN; } } else { - cprof->rendering_intent = RENDERING_INTENT_UNKNOWN; + this->rendering_intent = RENDERING_INTENT_UNKNOWN; } - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; default: @@ -416,28 +406,24 @@ void ColorProfile::set(unsigned key, gchar const *value) { * Callback: write attributes to associated repr. */ Inkscape::XML::Node* ColorProfile::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - ColorProfile* object = this; - - ColorProfile *cprof = COLORPROFILE(object); - if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:color-profile"); } - if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->href ) { - repr->setAttribute( "xlink:href", cprof->href ); + if ( (flags & SP_OBJECT_WRITE_ALL) || this->href ) { + repr->setAttribute( "xlink:href", this->href ); } - if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->local ) { - repr->setAttribute( "local", cprof->local ); + if ( (flags & SP_OBJECT_WRITE_ALL) || this->local ) { + repr->setAttribute( "local", this->local ); } - if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->name ) { - repr->setAttribute( "name", cprof->name ); + if ( (flags & SP_OBJECT_WRITE_ALL) || this->name ) { + repr->setAttribute( "name", this->name ); } - if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->intentStr ) { - repr->setAttribute( "rendering-intent", cprof->intentStr ); + if ( (flags & SP_OBJECT_WRITE_ALL) || this->intentStr ) { + repr->setAttribute( "rendering-intent", this->intentStr ); } SPObject::write(xml_doc, repr, flags); -- cgit v1.2.3