diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2013-09-19 23:36:51 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2013-09-19 23:36:51 +0000 |
| commit | 9c8cc7b63656f41a087c5d30d500028f8990a192 (patch) | |
| tree | 2685642ec93dc855743dcff21307b1ba5c53b65d /src | |
| parent | Update to trunk (diff) | |
| parent | Fix make check after merge of cppify branch (diff) | |
| download | inkscape-9c8cc7b63656f41a087c5d30d500028f8990a192.tar.gz inkscape-9c8cc7b63656f41a087c5d30d500028f8990a192.zip | |
update to trunk
(bzr r11950.1.142)
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile.am | 3 | ||||
| -rw-r--r-- | src/color-profile-test.h | 16 | ||||
| -rw-r--r-- | src/sp-object.cpp | 9 | ||||
| -rw-r--r-- | src/sp-root.cpp | 490 | ||||
| -rw-r--r-- | src/sp-style-elem-test.h | 33 |
5 files changed, 286 insertions, 265 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index a0c240252..a0c857aa3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -267,7 +267,8 @@ TESTS = $(check_PROGRAMS) ../share/extensions/test/run-all-extension-tests XFAIL_TESTS = $(check_PROGRAMS) # including the the testsuites here ensures that they get distributed -cxxtests_SOURCES = cxxtests.cpp $(CXXTEST_TESTSUITES) +cxxtests_SOURCES = cxxtests.cpp $(CXXTEST_TESTSUITES) $(ink_common_sources) $(win32_sources) +cxxtests_LDFLAGS = -z muldefs cxxtests_LDADD = $(all_libs) cxxtests.cpp: $(CXXTEST_TESTSUITES) $(CXXTEST_TEMPLATE) diff --git a/src/color-profile-test.h b/src/color-profile-test.h index b3ead5d55..4276eb774 100644 --- a/src/color-profile-test.h +++ b/src/color-profile-test.h @@ -31,13 +31,13 @@ public: static void createSuiteSubclass( ColorProfileTest*& dst ) { - Inkscape::ColorProfile *prof = static_cast<Inkscape::ColorProfile *>(g_object_new(COLORPROFILE_TYPE, NULL)); + Inkscape::ColorProfile *prof = new Inkscape::ColorProfile(); if ( prof ) { if ( prof->rendering_intent == (guint)Inkscape::RENDERING_INTENT_UNKNOWN ) { TS_ASSERT_EQUALS( prof->rendering_intent, (guint)Inkscape::RENDERING_INTENT_UNKNOWN ); dst = new ColorProfileTest(); } - g_object_unref(prof); + delete prof; } } @@ -74,7 +74,7 @@ public: {"auto2", (guint)Inkscape::RENDERING_INTENT_UNKNOWN}, }; - Inkscape::ColorProfile *prof = static_cast<Inkscape::ColorProfile *>(g_object_new(COLORPROFILE_TYPE, NULL)); + Inkscape::ColorProfile *prof = new Inkscape::ColorProfile(); TS_ASSERT( prof ); SP_OBJECT(prof)->document = _doc; @@ -84,7 +84,7 @@ public: TSM_ASSERT_EQUALS( descr, prof->rendering_intent, (guint)cases[i].intVal ); } - g_object_unref(prof); + delete prof; } void testSetLocal() @@ -94,7 +94,7 @@ public: "something", }; - Inkscape::ColorProfile *prof = static_cast<Inkscape::ColorProfile *>(g_object_new(COLORPROFILE_TYPE, NULL)); + Inkscape::ColorProfile *prof = new Inkscape::ColorProfile(); TS_ASSERT( prof ); SP_OBJECT(prof)->document = _doc; @@ -108,7 +108,7 @@ public: SP_OBJECT(prof)->setKeyValue( SP_ATTR_LOCAL, NULL); TS_ASSERT_EQUALS( prof->local, (gchar*)0 ); - g_object_unref(prof); + delete prof; } void testSetName() @@ -118,7 +118,7 @@ public: "something", }; - Inkscape::ColorProfile *prof = static_cast<Inkscape::ColorProfile *>(g_object_new(COLORPROFILE_TYPE, NULL)); + Inkscape::ColorProfile *prof = new Inkscape::ColorProfile(); TS_ASSERT( prof ); SP_OBJECT(prof)->document = _doc; @@ -132,7 +132,7 @@ public: SP_OBJECT(prof)->setKeyValue( SP_ATTR_NAME, NULL); TS_ASSERT_EQUALS( prof->name, (gchar*)0 ); - g_object_unref(prof); + delete prof; } }; diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 895b36e1c..1ab3cade8 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -588,9 +588,12 @@ void SPObject::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) ochild->invoke_build(object->document, child, object->cloned); } catch (const FactoryExceptions::TypeNotRegistered& e) { - if (std::string(e.what()) != "rdf:RDF") { // temporary special case - g_warning("TypeNotRegistered exception: %s", e.what()); - } + std::string node = e.what(); + // special cases + if (node == "rdf:RDF") return; // no SP node yet + if (node == "inkscape:clipboard") return; // SP node not necessary + + g_warning("TypeNotRegistered exception: %s", e.what()); } } diff --git a/src/sp-root.cpp b/src/sp-root.cpp index 4faefabef..c87c8397d 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -34,18 +34,20 @@ #include "sp-factory.h" namespace { - SPObject* createRoot() { - return new SPRoot(); - } +SPObject *createRoot() +{ + return new SPRoot(); +} - bool rootRegistered = SPFactory::instance().registerObject("svg:svg", createRoot); +bool rootRegistered = SPFactory::instance().registerObject("svg:svg", createRoot); } -SPRoot::SPRoot() : SPGroup() { - this->aspect_set = 0; - this->aspect_align = 0; - this->onload = NULL; - this->aspect_clip = 0; +SPRoot::SPRoot() : SPGroup() +{ + this->aspect_set = 0; + this->aspect_align = 0; + this->onload = NULL; + this->aspect_clip = 0; static Inkscape::Version const zero_version(0, 0); @@ -67,30 +69,32 @@ SPRoot::SPRoot() : SPGroup() { this->defs = NULL; } -SPRoot::~SPRoot() { +SPRoot::~SPRoot() +{ } -void SPRoot::build(SPDocument *document, Inkscape::XML::Node *repr) { +void SPRoot::build(SPDocument *document, Inkscape::XML::Node *repr) +{ //XML Tree being used directly here while it shouldn't be. - if ( !this->getRepr()->attribute("version") ) { + if (!this->getRepr()->attribute("version")) { repr->setAttribute("version", SVG_VERSION); } - this->readAttr( "version" ); - this->readAttr( "inkscape:version" ); + this->readAttr("version"); + this->readAttr("inkscape:version"); /* It is important to parse these here, so objects will have viewport build-time */ - this->readAttr( "x" ); - this->readAttr( "y" ); - this->readAttr( "width" ); - this->readAttr( "height" ); - this->readAttr( "viewBox" ); - this->readAttr( "preserveAspectRatio" ); - this->readAttr( "onload" ); + this->readAttr("x"); + this->readAttr("y"); + this->readAttr("width"); + this->readAttr("height"); + this->readAttr("viewBox"); + this->readAttr("preserveAspectRatio"); + this->readAttr("onload"); SPGroup::build(document, repr); // Search for first <defs> node - for (SPObject *o = this->firstChild() ; o ; o = o->getNext() ) { + for (SPObject *o = this->firstChild() ; o ; o = o->getNext()) { if (SP_IS_DEFS(o)) { this->defs = SP_DEFS(o); break; @@ -101,232 +105,239 @@ void SPRoot::build(SPDocument *document, Inkscape::XML::Node *repr) { SP_ITEM(this)->transform = Geom::identity(); } -void SPRoot::release() { +void SPRoot::release() +{ this->defs = NULL; SPGroup::release(); } -void SPRoot::set(unsigned int key, const gchar* value) { +void SPRoot::set(unsigned int key, const gchar *value) +{ switch (key) { - case SP_ATTR_VERSION: - if (!sp_version_from_string(value, &this->version.svg)) { - this->version.svg = this->original.svg; - } - break; + case SP_ATTR_VERSION: + if (!sp_version_from_string(value, &this->version.svg)) { + this->version.svg = this->original.svg; + } + break; - case SP_ATTR_INKSCAPE_VERSION: - if (!sp_version_from_string(value, &this->version.inkscape)) { - this->version.inkscape = this->original.inkscape; - } - break; + case SP_ATTR_INKSCAPE_VERSION: + if (!sp_version_from_string(value, &this->version.inkscape)) { + this->version.inkscape = this->original.inkscape; + } + break; - case SP_ATTR_X: - if (!this->x.readAbsolute(value)) { - /* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */ - this->x.unset(); - } + case SP_ATTR_X: + if (!this->x.readAbsolute(value)) { + /* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */ + this->x.unset(); + } - /* fixme: I am almost sure these do not require viewport flag (Lauris) */ - this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); - break; + /* fixme: I am almost sure these do not require viewport flag (Lauris) */ + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); + break; - case SP_ATTR_Y: - if (!this->y.readAbsolute(value)) { - /* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */ - this->y.unset(); - } + case SP_ATTR_Y: + if (!this->y.readAbsolute(value)) { + /* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */ + this->y.unset(); + } - /* fixme: I am almost sure these do not require viewport flag (Lauris) */ - this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); - break; + /* fixme: I am almost sure these do not require viewport flag (Lauris) */ + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); + break; - case SP_ATTR_WIDTH: - if (!this->width.readAbsolute(value) || !(this->width.computed > 0.0)) { - /* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */ - this->width.unset(SVGLength::PERCENT, 1.0, 1.0); - } + case SP_ATTR_WIDTH: + if (!this->width.readAbsolute(value) || !(this->width.computed > 0.0)) { + /* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */ + this->width.unset(SVGLength::PERCENT, 1.0, 1.0); + } - this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); - break; + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); + break; - case SP_ATTR_HEIGHT: - if (!this->height.readAbsolute(value) || !(this->height.computed > 0.0)) { - /* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */ - this->height.unset(SVGLength::PERCENT, 1.0, 1.0); - } + case SP_ATTR_HEIGHT: + if (!this->height.readAbsolute(value) || !(this->height.computed > 0.0)) { + /* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */ + this->height.unset(SVGLength::PERCENT, 1.0, 1.0); + } - this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); - break; + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); + break; - case SP_ATTR_VIEWBOX: - if (value) { - double x, y, width, height; - char *eptr; + case SP_ATTR_VIEWBOX: + if (value) { + double x, y, width, height; + char *eptr; - /* fixme: We have to take original item affine into account */ - /* fixme: Think (Lauris) */ - eptr = (gchar *) value; - x = g_ascii_strtod(eptr, &eptr); + /* fixme: We have to take original item affine into account */ + /* fixme: Think (Lauris) */ + eptr = (gchar *) value; + x = g_ascii_strtod(eptr, &eptr); - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } + while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { + eptr++; + } - y = g_ascii_strtod(eptr, &eptr); + y = g_ascii_strtod(eptr, &eptr); - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } + while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { + eptr++; + } - width = g_ascii_strtod(eptr, &eptr); + width = g_ascii_strtod(eptr, &eptr); - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } + while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { + eptr++; + } - height = g_ascii_strtod(eptr, &eptr); + height = g_ascii_strtod(eptr, &eptr); - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } + while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { + eptr++; + } - if ((width > 0) && (height > 0)) { - /* Set viewbox */ - this->viewBox = Geom::Rect::from_xywh(x, y, width, height); - this->viewBox_set = TRUE; - } else { - this->viewBox_set = FALSE; - } + if ((width > 0) && (height > 0)) { + /* Set viewbox */ + this->viewBox = Geom::Rect::from_xywh(x, y, width, height); + this->viewBox_set = TRUE; } else { this->viewBox_set = FALSE; } + } else { + this->viewBox_set = FALSE; + } - this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); - break; + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); + break; - case SP_ATTR_PRESERVEASPECTRATIO: - /* Do setup before, so we can use break to escape */ - this->aspect_set = FALSE; - this->aspect_align = SP_ASPECT_XMID_YMID; - this->aspect_clip = SP_ASPECT_MEET; + case SP_ATTR_PRESERVEASPECTRATIO: + /* Do setup before, so we can use break to escape */ + this->aspect_set = FALSE; + this->aspect_align = SP_ASPECT_XMID_YMID; + this->aspect_clip = SP_ASPECT_MEET; - this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); - if (value) { - int len; - gchar c[256]; - gchar const *p, *e; - unsigned int align, clip; - p = value; + if (value) { + int len; + gchar c[256]; + gchar const *p, *e; + unsigned int align, clip; + p = value; - while (*p && *p == 32) { - p += 1; - } + while (*p && *p == 32) { + p += 1; + } - if (!*p) { - break; - } + if (!*p) { + break; + } - e = p; + e = p; - while (*e && *e != 32) { - e += 1; - } + while (*e && *e != 32) { + e += 1; + } - len = e - p; + len = e - p; - if (len > 8) { - break; - } + if (len > 8) { + break; + } - memcpy(c, value, len); - - c[len] = 0; - - /* Now the actual part */ - if (!strcmp(c, "none")) { - align = SP_ASPECT_NONE; - } else if (!strcmp(c, "xMinYMin")) { - align = SP_ASPECT_XMIN_YMIN; - } else if (!strcmp(c, "xMidYMin")) { - align = SP_ASPECT_XMID_YMIN; - } else if (!strcmp(c, "xMaxYMin")) { - align = SP_ASPECT_XMAX_YMIN; - } else if (!strcmp(c, "xMinYMid")) { - align = SP_ASPECT_XMIN_YMID; - } else if (!strcmp(c, "xMidYMid")) { - align = SP_ASPECT_XMID_YMID; - } else if (!strcmp(c, "xMaxYMid")) { - align = SP_ASPECT_XMAX_YMID; - } else if (!strcmp(c, "xMinYMax")) { - align = SP_ASPECT_XMIN_YMAX; - } else if (!strcmp(c, "xMidYMax")) { - align = SP_ASPECT_XMID_YMAX; - } else if (!strcmp(c, "xMaxYMax")) { - align = SP_ASPECT_XMAX_YMAX; - } else { - break; - } + memcpy(c, value, len); + + c[len] = 0; + + /* Now the actual part */ + if (!strcmp(c, "none")) { + align = SP_ASPECT_NONE; + } else if (!strcmp(c, "xMinYMin")) { + align = SP_ASPECT_XMIN_YMIN; + } else if (!strcmp(c, "xMidYMin")) { + align = SP_ASPECT_XMID_YMIN; + } else if (!strcmp(c, "xMaxYMin")) { + align = SP_ASPECT_XMAX_YMIN; + } else if (!strcmp(c, "xMinYMid")) { + align = SP_ASPECT_XMIN_YMID; + } else if (!strcmp(c, "xMidYMid")) { + align = SP_ASPECT_XMID_YMID; + } else if (!strcmp(c, "xMaxYMid")) { + align = SP_ASPECT_XMAX_YMID; + } else if (!strcmp(c, "xMinYMax")) { + align = SP_ASPECT_XMIN_YMAX; + } else if (!strcmp(c, "xMidYMax")) { + align = SP_ASPECT_XMID_YMAX; + } else if (!strcmp(c, "xMaxYMax")) { + align = SP_ASPECT_XMAX_YMAX; + } else { + break; + } - clip = SP_ASPECT_MEET; + clip = SP_ASPECT_MEET; - while (*e && *e == 32) { - e += 1; - } + while (*e && *e == 32) { + e += 1; + } - if (*e) { - if (!strcmp(e, "meet")) { - clip = SP_ASPECT_MEET; - } else if (!strcmp(e, "slice")) { - clip = SP_ASPECT_SLICE; - } else { - break; - } + if (*e) { + if (!strcmp(e, "meet")) { + clip = SP_ASPECT_MEET; + } else if (!strcmp(e, "slice")) { + clip = SP_ASPECT_SLICE; + } else { + break; } - - this->aspect_set = TRUE; - this->aspect_align = align; - this->aspect_clip = clip; } - break; - case SP_ATTR_ONLOAD: - this->onload = (char *) value; - break; + this->aspect_set = TRUE; + this->aspect_align = align; + this->aspect_clip = clip; + } + break; - default: - /* Pass the set event to the parent */ - SPGroup::set(key, value); - break; + case SP_ATTR_ONLOAD: + this->onload = (char *) value; + break; + + default: + /* Pass the set event to the parent */ + SPGroup::set(key, value); + break; } } -void SPRoot::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { +void SPRoot::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) +{ SPGroup::child_added(child, ref); SPObject *co = this->document->getObjectByRepr(child); - g_assert (co != NULL || !strcmp("comment", child->name())); // comment repr node has no object + // NOTE: some XML nodes do not have corresponding SP objects, + // for instance inkscape:clipboard used in the clipboard code. + // See LP bug #1227827 + //g_assert (co != NULL || !strcmp("comment", child->name())); // comment repr node has no object if (co && SP_IS_DEFS(co)) { // We search for first <defs> node - it is not beautiful, but works - for (SPObject *c = this->firstChild() ; c ; c = c->getNext() ) { + for (SPObject *c = this->firstChild() ; c ; c = c->getNext()) { if (SP_IS_DEFS(c)) { - this->defs = SP_DEFS(c); + this->defs = SP_DEFS(c); break; } } } } -void SPRoot::remove_child(Inkscape::XML::Node* child) { - if ( this->defs && (this->defs->getRepr() == child) ) { +void SPRoot::remove_child(Inkscape::XML::Node *child) +{ + if (this->defs && (this->defs->getRepr() == child)) { SPObject *iter = 0; // We search for first remaining <defs> node - it is not beautiful, but works - for ( iter = this->firstChild() ; iter ; iter = iter->getNext() ) { - if ( SP_IS_DEFS(iter) && (SPDefs *)iter != this->defs ) { + for (iter = this->firstChild() ; iter ; iter = iter->getNext()) { + if (SP_IS_DEFS(iter) && (SPDefs *)iter != this->defs) { this->defs = (SPDefs *)iter; break; } @@ -341,14 +352,15 @@ void SPRoot::remove_child(Inkscape::XML::Node* child) { SPGroup::remove_child(child); } -void SPRoot::update(SPCtx *ctx, guint flags) { +void SPRoot::update(SPCtx *ctx, guint flags) +{ SPItemCtx *ictx = (SPItemCtx *) ctx; /* fixme: This will be invoked too often (Lauris) */ /* fixme: We should calculate only if parent viewport has changed (Lauris) */ /* If position is specified as percentage, calculate actual values */ if (this->x.unit == SVGLength::PERCENT) { - this->x.computed = this->x.value * ictx->viewport.width(); + this->x.computed = this->x.value * ictx->viewport.width(); } if (this->y.unit == SVGLength::PERCENT) { @@ -377,7 +389,7 @@ void SPRoot::update(SPCtx *ctx, guint flags) { * fixme: height seems natural, as this makes the inner svg element * fixme: self-contained. The spec is vague here. */ - this->c2p = Geom::Affine(Geom::Translate(this->x.computed, this->y.computed)); + this->c2p = Geom::Affine(Geom::Translate(this->x.computed, this->y.computed)); } if (this->viewBox_set) { @@ -401,66 +413,66 @@ void SPRoot::update(SPCtx *ctx, guint flags) { /* todo: Use an array lookup to find the 0.0/0.5/1.0 coefficients, as is done for dialogs/align.cpp. */ switch (this->aspect_align) { - case SP_ASPECT_XMIN_YMIN: - x = 0.0; - y = 0.0; - break; + case SP_ASPECT_XMIN_YMIN: + x = 0.0; + y = 0.0; + break; - case SP_ASPECT_XMID_YMIN: - x = 0.5 * (this->width.computed - width); - y = 0.0; - break; + case SP_ASPECT_XMID_YMIN: + x = 0.5 * (this->width.computed - width); + y = 0.0; + break; - case SP_ASPECT_XMAX_YMIN: - x = 1.0 * (this->width.computed - width); - y = 0.0; - break; + case SP_ASPECT_XMAX_YMIN: + x = 1.0 * (this->width.computed - width); + y = 0.0; + break; - case SP_ASPECT_XMIN_YMID: - x = 0.0; - y = 0.5 * (this->height.computed - height); - break; + case SP_ASPECT_XMIN_YMID: + x = 0.0; + y = 0.5 * (this->height.computed - height); + break; - case SP_ASPECT_XMID_YMID: - x = 0.5 * (this->width.computed - width); - y = 0.5 * (this->height.computed - height); - break; + case SP_ASPECT_XMID_YMID: + x = 0.5 * (this->width.computed - width); + y = 0.5 * (this->height.computed - height); + break; - case SP_ASPECT_XMAX_YMID: - x = 1.0 * (this->width.computed - width); - y = 0.5 * (this->height.computed - height); - break; + case SP_ASPECT_XMAX_YMID: + x = 1.0 * (this->width.computed - width); + y = 0.5 * (this->height.computed - height); + break; - case SP_ASPECT_XMIN_YMAX: - x = 0.0; - y = 1.0 * (this->height.computed - height); - break; + case SP_ASPECT_XMIN_YMAX: + x = 0.0; + y = 1.0 * (this->height.computed - height); + break; - case SP_ASPECT_XMID_YMAX: - x = 0.5 * (this->width.computed - width); - y = 1.0 * (this->height.computed - height); - break; + case SP_ASPECT_XMID_YMAX: + x = 0.5 * (this->width.computed - width); + y = 1.0 * (this->height.computed - height); + break; - case SP_ASPECT_XMAX_YMAX: - x = 1.0 * (this->width.computed - width); - y = 1.0 * (this->height.computed - height); - break; + case SP_ASPECT_XMAX_YMAX: + x = 1.0 * (this->width.computed - width); + y = 1.0 * (this->height.computed - height); + break; - default: - x = 0.0; - y = 0.0; - break; + default: + x = 0.0; + y = 0.0; + break; } } /* Compose additional transformation from scale and position */ - Geom::Scale const viewBox_length( this->viewBox.dimensions() ); + Geom::Scale const viewBox_length(this->viewBox.dimensions()); Geom::Scale const new_length(width, height); /* Append viewbox transformation */ /* TODO: The below looks suspicious to me (pjrm): I wonder whether the RHS expression should have c2p at the beginning rather than at the end. Test it. */ - this->c2p = Geom::Translate(-this->viewBox.min()) * ( new_length * viewBox_length.inverse() ) * Geom::Translate(x, y) * this->c2p; + this->c2p = Geom::Translate(-this->viewBox.min()) * (new_length * viewBox_length.inverse()) * Geom::Translate(x, y) * this->c2p; } rctx.i2doc = this->c2p * rctx.i2doc; @@ -470,7 +482,7 @@ void SPRoot::update(SPCtx *ctx, guint flags) { rctx.viewport = this->viewBox; } else { /* fixme: I wonder whether this logic is correct (Lauris) */ - Geom::Point minp(0,0); + Geom::Point minp(0, 0); if (this->parent) { minp = Geom::Point(this->x.computed, this->y.computed); } @@ -490,17 +502,19 @@ void SPRoot::update(SPCtx *ctx, guint flags) { } } -void SPRoot::modified(unsigned int flags) { +void SPRoot::modified(unsigned int flags) +{ SPGroup::modified(flags); /* fixme: (Lauris) */ if (!this->parent && (flags & SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { - this->document->emitResizedSignal(this->width.computed, this->height.computed); + this->document->emitResizedSignal(this->width.computed, this->height.computed); } } -Inkscape::XML::Node* SPRoot::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { +Inkscape::XML::Node *SPRoot::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +{ if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:svg"); } @@ -509,8 +523,8 @@ Inkscape::XML::Node* SPRoot::write(Inkscape::XML::Document *xml_doc, Inkscape::X repr->setAttribute("inkscape:version", Inkscape::version_string); } - if ( !repr->attribute("version") ) { - gchar* myversion = sp_version_to_string(this->version.svg); + if (!repr->attribute("version")) { + gchar *myversion = sp_version_to_string(this->version.svg); repr->setAttribute("version", myversion); g_free(myversion); } @@ -542,20 +556,22 @@ Inkscape::XML::Node* SPRoot::write(Inkscape::XML::Document *xml_doc, Inkscape::X return repr; } -Inkscape::DrawingItem* SPRoot::show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { +Inkscape::DrawingItem *SPRoot::show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) +{ Inkscape::DrawingItem *ai = 0; ai = SPGroup::show(drawing, key, flags); if (ai) { - Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(ai); - g->setChildTransform(this->c2p); + Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(ai); + g->setChildTransform(this->c2p); } return ai; } -void SPRoot::print(SPPrintContext* ctx) { +void SPRoot::print(SPPrintContext *ctx) +{ sp_print_bind(ctx, this->c2p, 1.0); SPGroup::print(ctx); diff --git a/src/sp-style-elem-test.h b/src/sp-style-elem-test.h index 7021be13d..6f65a48ea 100644 --- a/src/sp-style-elem-test.h +++ b/src/sp-style-elem-test.h @@ -28,12 +28,13 @@ public: static void createSuiteSubclass( SPStyleElemTest *& dst ) { - SPStyleElem *style_elem = static_cast<SPStyleElem *>(g_object_new(SP_TYPE_STYLE_ELEM, NULL)); + SPStyleElem *style_elem = new SPStyleElem(); + if ( style_elem ) { TS_ASSERT(!style_elem->is_css); TS_ASSERT(style_elem->media.print); TS_ASSERT(style_elem->media.screen); - g_object_unref(style_elem); + delete style_elem; dst = new SPStyleElemTest(); } @@ -52,7 +53,7 @@ public: void testSetType() { - SPStyleElem *style_elem = static_cast<SPStyleElem *>(g_object_new(SP_TYPE_STYLE_ELEM, NULL)); + SPStyleElem *style_elem = new SPStyleElem(); SP_OBJECT(style_elem)->document = _doc; SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "something unrecognized"); @@ -67,7 +68,7 @@ public: SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "text/cssx"); TS_ASSERT( !style_elem->is_css ); - g_object_unref(style_elem); + delete style_elem; } void testWrite() @@ -78,7 +79,7 @@ public: return; // evil early return } - SPStyleElem *style_elem = SP_STYLE_ELEM(g_object_new(SP_TYPE_STYLE_ELEM, NULL)); + SPStyleElem *style_elem = new SPStyleElem(); SP_OBJECT(style_elem)->document = _doc; SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "text/css"); @@ -93,7 +94,7 @@ public: } } - g_object_unref(style_elem); + delete style_elem; } void testBuild() @@ -104,13 +105,13 @@ public: return; // evil early return } - SPStyleElem &style_elem = *SP_STYLE_ELEM(g_object_new(SP_TYPE_STYLE_ELEM, NULL)); + SPStyleElem *style_elem = new SPStyleElem(); Inkscape::XML::Node *const repr = _doc->getReprDoc()->createElement("svg:style"); repr->setAttribute("type", "text/css"); - (&style_elem)->invoke_build( _doc, repr, false); - TS_ASSERT( style_elem.is_css ); - TS_ASSERT( style_elem.media.print ); - TS_ASSERT( style_elem.media.screen ); + style_elem->invoke_build( _doc, repr, false); + TS_ASSERT( style_elem->is_css ); + TS_ASSERT( style_elem->media.print ); + TS_ASSERT( style_elem->media.screen ); /* Some checks relevant to the read_content test below. */ { @@ -120,7 +121,7 @@ public: g_assert(stylesheet->statements == NULL); } - g_object_unref(&style_elem); + delete style_elem; Inkscape::GC::release(repr); } @@ -132,19 +133,19 @@ public: return; // evil early return } - SPStyleElem &style_elem = *SP_STYLE_ELEM(g_object_new(SP_TYPE_STYLE_ELEM, NULL)); + SPStyleElem *style_elem = new SPStyleElem(); Inkscape::XML::Node *const repr = _doc->getReprDoc()->createElement("svg:style"); repr->setAttribute("type", "text/css"); Inkscape::XML::Node *const content_repr = _doc->getReprDoc()->createTextNode(".myclass { }"); repr->addChild(content_repr, NULL); - (&style_elem)->invoke_build(_doc, repr, false); - TS_ASSERT( style_elem.is_css ); + style_elem->invoke_build(_doc, repr, false); + TS_ASSERT( style_elem->is_css ); TS_ASSERT( _doc->style_cascade ); CRStyleSheet const *const stylesheet = cr_cascade_get_sheet(_doc->style_cascade, ORIGIN_AUTHOR); TS_ASSERT(stylesheet != NULL); TS_ASSERT(stylesheet->statements != NULL); - g_object_unref(&style_elem); + delete style_elem; Inkscape::GC::release(repr); } |
