diff options
| author | Sebastian Wüst <sebi@timewaster.de> | 2013-10-28 17:23:42 +0000 |
|---|---|---|
| committer | Sebastian Wüst <sebi@timewaster.de> | 2013-10-28 17:23:42 +0000 |
| commit | c6ad2a34d38795059888d3c900dbf1047bfd5fdd (patch) | |
| tree | 88de58a63003bd2ea6edda9c895d3c0466a38e6b /src | |
| parent | text change (diff) | |
| parent | Fix for bug #1156394 (OCAL dialog: Close button in German localization contai... (diff) | |
| download | inkscape-c6ad2a34d38795059888d3c900dbf1047bfd5fdd.tar.gz inkscape-c6ad2a34d38795059888d3c900dbf1047bfd5fdd.zip | |
mrege from trunk
(bzr r12417.1.31)
Diffstat (limited to 'src')
95 files changed, 424 insertions, 328 deletions
diff --git a/src/2geom/line.h b/src/2geom/line.h index f2d31ecc6..ade67f818 100644 --- a/src/2geom/line.h +++ b/src/2geom/line.h @@ -41,6 +41,7 @@ #include <2geom/crossing.h> #include <2geom/exception.h> #include <2geom/ray.h> +#include <2geom/angle.h> namespace Geom { diff --git a/src/2geom/ray.h b/src/2geom/ray.h index 75cc72005..2fda06ff5 100644 --- a/src/2geom/ray.h +++ b/src/2geom/ray.h @@ -36,6 +36,8 @@ #include <2geom/bezier-curve.h> // for LineSegment #include <2geom/exception.h> #include <2geom/math-utils.h> +#include <2geom/transforms.h> +#include <2geom/angle.h> namespace Geom { @@ -146,17 +148,31 @@ double angle_between(Ray const& r1, Ray const& r2, bool cw = true) { return angle; } +/** + * @brief Returns the angle bisector for the two given rays. + * + * @a r1 is rotated half the way to @a r2 in either clockwise or counter-clockwise direction. + * + * @pre Both passed rays must have the same origin. + * + * @remarks If the versors of both given rays point in the same direction, the direction of the + * angle bisector ray depends on the third parameter: + * - If @a cw is set to @c true, the returned ray will equal the passed rays @a r1 and @a r2. + * - If @a cw is set to @c false, the returned ray will go in the opposite direction. + * + * @throws RangeError if the given rays do not have the same origins + */ inline -Ray make_angle_bisector_ray(Ray const& r1, Ray const& r2) +Ray make_angle_bisector_ray(Ray const& r1, Ray const& r2, bool cw = true) { if ( !are_near(r1.origin(), r2.origin()) ) { - THROW_RANGEERROR("passed rays have not the same origin"); + THROW_RANGEERROR("passed rays do not have the same origin"); } - Point M = middle_point(r1.pointAt(1), r2.pointAt(1) ); - if (angle_between(r1, r2) > M_PI) M = 2 * r1.origin() - M; - return Ray(r1.origin(), M); + Ray bisector(r1.origin(), r1.origin() + r1.versor() * Rotate(angle_between(r1, r2) / 2.0)); + + return (cw ? bisector : bisector.reverse()); } } // end namespace Geom diff --git a/src/2geom/transforms.h b/src/2geom/transforms.h index 869e955c7..7f5635747 100644 --- a/src/2geom/transforms.h +++ b/src/2geom/transforms.h @@ -39,6 +39,7 @@ #include <cmath> #include <2geom/forward.h> #include <2geom/affine.h> +#include <2geom/angle.h> namespace Geom { diff --git a/src/box3d.cpp b/src/box3d.cpp index ff99fccba..32442746d 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -1325,53 +1325,50 @@ SPGroup *box3d_convert_to_group(SPBox3D *box) return SP_GROUP(doc->getObjectByRepr(grepr)); } -const char *SPBox3D::displayName() { +const char *SPBox3D::displayName() const { return _("3D Box"); } -gchar *SPBox3D::description() { +gchar *SPBox3D::description() const { // We could put more details about the 3d box here return g_strdup(""); } static inline void -box3d_push_back_corner_pair(SPBox3D *box, std::list<std::pair<Geom::Point, Geom::Point> > &pts, int c1, int c2) { +box3d_push_back_corner_pair(SPBox3D const *box, std::list<std::pair<Geom::Point, Geom::Point> > &pts, int c1, int c2) { pts.push_back(std::make_pair(box3d_get_corner_screen(box, c1, false), box3d_get_corner_screen(box, c2, false))); } -void SPBox3D::convert_to_guides() { - SPBox3D* item = this; - SPBox3D *box = item; - +void SPBox3D::convert_to_guides() const { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (!prefs->getBool("/tools/shapes/3dbox/convertguides", true)) { - box->convert_to_guides(); + this->convert_to_guides(); return; } std::list<std::pair<Geom::Point, Geom::Point> > pts; /* perspective lines in X direction */ - box3d_push_back_corner_pair(box, pts, 0, 1); - box3d_push_back_corner_pair(box, pts, 2, 3); - box3d_push_back_corner_pair(box, pts, 4, 5); - box3d_push_back_corner_pair(box, pts, 6, 7); + box3d_push_back_corner_pair(this, pts, 0, 1); + box3d_push_back_corner_pair(this, pts, 2, 3); + box3d_push_back_corner_pair(this, pts, 4, 5); + box3d_push_back_corner_pair(this, pts, 6, 7); /* perspective lines in Y direction */ - box3d_push_back_corner_pair(box, pts, 0, 2); - box3d_push_back_corner_pair(box, pts, 1, 3); - box3d_push_back_corner_pair(box, pts, 4, 6); - box3d_push_back_corner_pair(box, pts, 5, 7); + box3d_push_back_corner_pair(this, pts, 0, 2); + box3d_push_back_corner_pair(this, pts, 1, 3); + box3d_push_back_corner_pair(this, pts, 4, 6); + box3d_push_back_corner_pair(this, pts, 5, 7); /* perspective lines in Z direction */ - box3d_push_back_corner_pair(box, pts, 0, 4); - box3d_push_back_corner_pair(box, pts, 1, 5); - box3d_push_back_corner_pair(box, pts, 2, 6); - box3d_push_back_corner_pair(box, pts, 3, 7); + box3d_push_back_corner_pair(this, pts, 0, 4); + box3d_push_back_corner_pair(this, pts, 1, 5); + box3d_push_back_corner_pair(this, pts, 2, 6); + box3d_push_back_corner_pair(this, pts, 3, 7); - sp_guide_pt_pairs_to_guides(item->document, pts); + sp_guide_pt_pairs_to_guides(this->document, pts); } /* diff --git a/src/box3d.h b/src/box3d.h index 1dec1e792..4107d2452 100644 --- a/src/box3d.h +++ b/src/box3d.h @@ -60,9 +60,9 @@ public: virtual const char* display_name(); virtual Geom::Affine set_transform(Geom::Affine const &transform); - virtual void convert_to_guides(); - virtual const char* displayName(); - virtual gchar *description(); + virtual void convert_to_guides() const; + virtual const char* displayName() const; + virtual gchar *description() const; }; void box3d_position_set (SPBox3D *box); diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index c0d05e3c4..cb72f65dc 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -303,23 +303,29 @@ static Avoid::Polygon avoid_item_poly(SPItem const *item) Geom::Line parallel_hull_edge; parallel_hull_edge.setOrigin(hull_edge.origin()+hull_edge.versor().ccw()*spacing); parallel_hull_edge.setVersor(hull_edge.versor()); - + // determine the intersection point - - Geom::OptCrossing int_pt = Geom::intersection(parallel_hull_edge, prev_parallel_hull_edge); - if (int_pt) - { - Avoid::Point avoid_pt((parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X], - (parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::Y]); - poly.ps.push_back(avoid_pt); + try { + Geom::OptCrossing int_pt = Geom::intersection(parallel_hull_edge, prev_parallel_hull_edge); + if (int_pt) + { + Avoid::Point avoid_pt((parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X], + (parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::Y]); + poly.ps.push_back(avoid_pt); + } + else + { + // something went wrong... + std::cout<<"conn-avoid-ref.cpp: avoid_item_poly: Geom:intersection failed."<<std::endl; + } } - else - { - // something went wrong... - std::cout<<"conn-avoid-ref.cpp: avoid_item_poly: Geom:intersection failed."<<std::endl; + catch (Geom::InfiniteSolutions const &e) { + // the parallel_hull_edge and prev_parallel_hull_edge lie on top of each other, hence infinite crossings + g_message("conn-avoid-ref.cpp: trying to get crossings of identical lines"); } prev_parallel_hull_edge = parallel_hull_edge; } + return poly; } diff --git a/src/desktop.cpp b/src/desktop.cpp index f5c35514c..ec446e0f0 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -681,7 +681,6 @@ void SPDesktop::set_event_context2(const std::string& toolName) { SPEventContext* ec_new = ToolFactory::instance().createObject(toolName); ec_new->desktop = this; ec_new->message_context = new Inkscape::MessageContext(this->messageStack()); - ec_new->setup(); event_context = ec_new; @@ -690,6 +689,8 @@ void SPDesktop::set_event_context2(const std::string& toolName) { delete ec_old; } + ec_new->setup(); + sp_event_context_activate(event_context); _event_context_changed_signal.emit(this, event_context); diff --git a/src/document.cpp b/src/document.cpp index 4f57cf080..3433e42ec 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -84,6 +84,7 @@ static gint sp_document_rerouting_handler(gpointer data); gboolean sp_document_resource_list_free(gpointer key, gpointer value, gpointer data); static gint doc_count = 0; +static gint doc_mem_count = 0; static unsigned long next_serial = 0; @@ -500,15 +501,18 @@ SPDocument *SPDocument::createNewDoc(gchar const *uri, unsigned int keepalive, b base = NULL; name = g_strdup(uri); } + if (make_new) { + base = NULL; + uri = NULL; + name = g_strdup_printf(_("New document %d"), ++doc_count); + } g_free(s); } else { - rdoc = sp_repr_document_new("svg:svg"); - } + if (make_new) { + name = g_strdup_printf(_("Memory document %d"), ++doc_mem_count); + } - if (make_new) { - base = NULL; - uri = NULL; - name = g_strdup_printf(_("New document %d"), ++doc_count); + rdoc = sp_repr_document_new("svg:svg"); } //# These should be set by now @@ -534,7 +538,7 @@ SPDocument *SPDocument::createNewDocFromMem(gchar const *buffer, gint length, un // If xml file is not svg, return NULL without warning // TODO fixme: destroy document } else { - Glib::ustring name = Glib::ustring::compose( _("Memory document %1"), ++doc_count ); + Glib::ustring name = Glib::ustring::compose( _("Memory document %1"), ++doc_mem_count ); doc = createDoc(rdoc, NULL, NULL, name.c_str(), keepalive); } } @@ -554,6 +558,13 @@ SPDocument *SPDocument::doUnref() return NULL; } +/// guaranteed not to return nullptr +Inkscape::Util::Unit const* SPDocument::getDefaultUnit() const +{ + SPNamedView const* nv = sp_document_namedview(this, NULL); + return nv ? nv->getDefaultUnit() : unit_table.getUnit("pt"); +} + Inkscape::Util::Quantity SPDocument::getWidth() const { g_return_val_if_fail(this->priv != NULL, Inkscape::Util::Quantity(0.0, unit_table.getUnit(""))); @@ -668,7 +679,7 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) double margin_right = 0.0; double margin_bottom = 0.0; - SPNamedView *nv = sp_document_namedview(this, 0); + SPNamedView *nv = sp_document_namedview(this, NULL); if (with_margins && nv) { if (nv != NULL) { @@ -1471,9 +1482,10 @@ void SPDocument::setModifiedSinceSave(bool modified) { this->modified_since_save = modified; 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() ); + if (parent) { // during load, SP_ACTIVE_DESKTOP may be !nullptr, but parent might still be nullptr + SPDesktopWidget *dtw = static_cast<SPDesktopWidget *>(parent->get_data("desktopwidget")); + dtw->updateTitle( this->getName() ); + } } } diff --git a/src/document.h b/src/document.h index 948b5b867..0977fc7a8 100644 --- a/src/document.h +++ b/src/document.h @@ -47,6 +47,7 @@ namespace Inkscape { class Node; } namespace Util { + class Unit; class Quantity; } } @@ -123,6 +124,7 @@ public: /** Returns our SPRoot */ SPRoot *getRoot() { return root; } + SPRoot const *getRoot() const { return root; } Inkscape::XML::Node *getReprRoot() { return rroot; } @@ -227,6 +229,7 @@ public: SPDocument *doRef(); SPDocument *doUnref(); + Inkscape::Util::Unit const* getDefaultUnit() const; Inkscape::Util::Quantity getWidth() const; Inkscape::Util::Quantity getHeight() const; Geom::Point getDimensions() const; diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 498ff5bfb..365da38ac 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -165,7 +165,7 @@ void SPDrawContext::finish() { spdc_free_colors(this); } -void SPDrawContext::set(const Inkscape::Preferences::Entry& value) { +void SPDrawContext::set(const Inkscape::Preferences::Entry& /*value*/) { } bool SPDrawContext::root_handler(GdkEvent* event) { diff --git a/src/event-context.cpp b/src/event-context.cpp index e5ea85818..398d3b0e3 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -77,7 +77,7 @@ static guint32 scroll_event_time = 0; static gdouble scroll_multiply = 1; static guint scroll_keyval = 0; -void SPEventContext::set(const Inkscape::Preferences::Entry& val) { +void SPEventContext::set(const Inkscape::Preferences::Entry& /*val*/) { } void SPEventContext::activate() { diff --git a/src/extension/dbus/Makefile_insert b/src/extension/dbus/Makefile_insert index a5eb3fdf4..7d851715e 100644 --- a/src/extension/dbus/Makefile_insert +++ b/src/extension/dbus/Makefile_insert @@ -12,7 +12,8 @@ ink_common_sources += \ extension/dbus/application-interface.cpp \ extension/dbus/application-interface.h \ extension/dbus/document-interface.cpp \ - extension/dbus/document-interface.h + extension/dbus/document-interface.h \ + extension/dbus/org.inkscape.service.in ########################### # Build DBus wrapper files diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp index 517d6fb9c..0111ed626 100644 --- a/src/extension/internal/cdr-input.cpp +++ b/src/extension/internal/cdr-input.cpp @@ -256,9 +256,10 @@ SPDocument *CdrInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u } SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE); + // Set viewBox if it doesn't exist - if (!doc->getRoot()->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + if (doc && !doc->getRoot()->viewBox_set) { + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } return doc; } diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp index f1876c687..c8c708051 100644 --- a/src/extension/internal/emf-inout.cpp +++ b/src/extension/internal/emf-inout.cpp @@ -789,8 +789,12 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType) // Assume src color is "white" if(d->dwRop3){ switch(d->dwRop3){ - case U_PATINVERT: // treat all of these as black - case U_SRCINVERT: + case U_PATINVERT: // invert pattern + fill_rgb[0] = 1.0 - fill_rgb[0]; + fill_rgb[1] = 1.0 - fill_rgb[1]; + fill_rgb[2] = 1.0 - fill_rgb[2]; + break; + case U_SRCINVERT: // treat all of these as black case U_DSTINVERT: case U_BLACKNESS: case U_SRCERASE: @@ -799,7 +803,6 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType) break; case U_SRCCOPY: // treat all of these as white case U_NOTSRCERASE: - case U_PATCOPY: case U_WHITENESS: fill_rgb[0]=fill_rgb[1]=fill_rgb[2]=1.0; break; @@ -808,6 +811,7 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType) case U_MERGECOPY: case U_MERGEPAINT: case U_PATPAINT: + case U_PATCOPY: default: break; } @@ -2747,7 +2751,10 @@ std::cout << "BEFORE DRAW" { dbg_str << "<!-- U_EMR_BEGINPATH -->\n"; // The next line should never be needed, should have been handled before main switch - *(d->path) = ""; + // qualifier added because EMF's encountered where moveto preceded beginpath followed by lineto + if(d->mask & U_DRAW_VISIBLE){ + *(d->path) = ""; + } d->mask |= emr_mask; break; } @@ -2859,6 +2866,7 @@ std::cout << "BEFORE DRAW" if (!pEmr->cbBmiSrc) { // should be an application of a DIBPATTERNBRUSHPT, use a solid color instead + if(pEmr->dwRop == U_NOOP)break; /* GDI applications apparently often end with this as a sort of flush(), nothing should be drawn */ int32_t dx = pEmr->Dest.x; int32_t dy = pEmr->Dest.y; int32_t dw = pEmr->cDest.x; @@ -3488,7 +3496,7 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) d.tri = trinfo_release_except_FC(d.tri); // Set viewBox if it doesn't exist - if (!doc->getRoot()->viewBox_set) { + if (doc && !doc->getRoot()->viewBox_set) { bool saved = Inkscape::DocumentUndo::getUndoSensitive(doc); Inkscape::DocumentUndo::setUndoSensitive(doc, false); @@ -3497,20 +3505,20 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) // Set document unit Inkscape::XML::Node *repr = sp_document_namedview(doc, 0)->getRepr(); Inkscape::SVGOStringStream os; - os << doc->getWidth().unit->abbr; + Inkscape::Util::Unit const* doc_unit = doc->getWidth().unit; + os << doc_unit->abbr; repr->setAttribute("inkscape:document-units", os.str().c_str()); - + // Set viewBox - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); - + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc_unit), doc->getHeight().value(doc_unit))); + doc->ensureUpToDate(); + // Scale and translate objects - double scale = Inkscape::Util::Quantity::convert(1, "px", doc->getWidth().unit); + double scale = Inkscape::Util::Quantity::convert(1, "px", doc_unit); ShapeEditor::blockSetItem(true); - doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, SP_ACTIVE_DOCUMENT->getHeight().value("px"))); + doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, doc->getHeight().value("px"))); ShapeEditor::blockSetItem(false); - - doc->ensureUpToDate(); - + Inkscape::DocumentUndo::setUndoSensitive(doc, saved); } diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp index 13267ee2b..6d159d265 100644 --- a/src/extension/internal/gdkpixbuf-input.cpp +++ b/src/extension/internal/gdkpixbuf-input.cpp @@ -105,7 +105,7 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri) // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } // restore undo, as now this document may be shown to the user if a bitmap was opened diff --git a/src/extension/internal/image-resolution.cpp b/src/extension/internal/image-resolution.cpp index b38b0ddc7..865e86698 100644 --- a/src/extension/internal/image-resolution.cpp +++ b/src/extension/internal/image-resolution.cpp @@ -342,9 +342,16 @@ void ImageResolution::readmagick(char const *fn) { image.read(fn); } catch (...) {} Magick::Geometry geo = image.density(); + std::string type = image.magick(); + + if (type == "PNG") { // PNG only supports pixelspercentimeter + x_ = Inkscape::Util::Quantity::convert((double)geo.width(), "in", "cm"); + y_ = Inkscape::Util::Quantity::convert((double)geo.height(), "in", "cm"); + } else { + x_ = (double)geo.width(); + y_ = (double)geo.height(); + } - x_ = Inkscape::Util::Quantity::convert((double)geo.width(), "pt", "px"); - y_ = Inkscape::Util::Quantity::convert((double)geo.height(), "pt", "px"); ok_ = true; } diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp index adac0d6c9..c45367c08 100644 --- a/src/extension/internal/pdf-input-cairo.cpp +++ b/src/extension/internal/pdf-input-cairo.cpp @@ -625,8 +625,8 @@ PdfInputCairo::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri) { SPDocument * doc = SPDocument::createNewDocFromMem(output->c_str(), output->length(), TRUE); // Set viewBox if it doesn't exist - if (!doc->getRoot()->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + if (doc && !doc->getRoot()->viewBox_set) { + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } delete output; diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index 213550688..3155ac098 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -750,7 +750,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } // Restore undo diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp index 42a9e3d41..6fc79237b 100644 --- a/src/extension/internal/vsd-input.cpp +++ b/src/extension/internal/vsd-input.cpp @@ -258,7 +258,7 @@ SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } return doc; diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp index d69d46f20..3f37e4402 100644 --- a/src/extension/internal/wmf-inout.cpp +++ b/src/extension/internal/wmf-inout.cpp @@ -1970,7 +1970,9 @@ std::cout << "BEFORE DRAW" } if (!d->dc[d->level].sizeView.x || !d->dc[d->level].sizeView.y) { - d->dc[d->level].sizeView = d->dc[d->level].sizeWnd; + /* Previously it used sizeWnd, but that always resulted in scale = 1 if no viewport ever appeared, and in most files, it did not */ + d->dc[d->level].sizeView.x = d->PixelsInX - 1; + d->dc[d->level].sizeView.y = d->PixelsInY - 1; } /* scales logical to WMF pixels, transfer a negative sign on Y, if any */ @@ -2284,6 +2286,7 @@ std::cout << "BEFORE DRAW" dbg_str << "<!-- U_WMR_BITBLT -->\n"; nSize = U_WMRBITBLT_get(contents,&Dst,&cwh,&Src,&dwRop3,&Bm16,&px); if(!px){ + if(dwRop3 == U_NOOP)break; /* GDI applications apparently often end with this as a sort of flush(), nothing should be drawn */ int32_t dx = Dst.x; int32_t dy = Dst.y; int32_t dw = cwh.x; @@ -2321,6 +2324,7 @@ std::cout << "BEFORE DRAW" dbg_str << "<!-- U_WMR_STRETCHBLT -->\n"; nSize = U_WMRSTRETCHBLT_get(contents,&Dst,&cDst,&Src,&cSrc,&dwRop3,&Bm16,&px); if(!px){ + if(dwRop3 == U_NOOP)break; /* GDI applications apparently often end with this as a sort of flush(), nothing should be drawn */ int32_t dx = Dst.x; int32_t dy = Dst.y; int32_t dw = cDst.x; @@ -2715,6 +2719,7 @@ std::cout << "BEFORE DRAW" if (!dib) { // should be an application of a DIBPATTERNBRUSHPT, use a solid color instead + if(dwRop3 == U_NOOP)break; /* GDI applications apparently often end with this as a sort of flush(), nothing should be drawn */ int32_t dx = Dst.x; int32_t dy = Dst.y; int32_t dw = cwh.x; @@ -3176,7 +3181,7 @@ Wmf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) d.tri = trinfo_release_except_FC(d.tri); // Set viewBox if it doesn't exist - if (!doc->getRoot()->viewBox_set) { + if (doc && !doc->getRoot()->viewBox_set) { bool saved = Inkscape::DocumentUndo::getUndoSensitive(doc); Inkscape::DocumentUndo::setUndoSensitive(doc, false); @@ -3185,20 +3190,20 @@ Wmf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) // Set document unit Inkscape::XML::Node *repr = sp_document_namedview(doc, 0)->getRepr(); Inkscape::SVGOStringStream os; - os << doc->getWidth().unit->abbr; + Inkscape::Util::Unit const* doc_unit = doc->getWidth().unit; + os << doc_unit->abbr; repr->setAttribute("inkscape:document-units", os.str().c_str()); // Set viewBox - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); - + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc_unit), doc->getHeight().value(doc_unit))); + doc->ensureUpToDate(); + // Scale and translate objects - double scale = Inkscape::Util::Quantity::convert(1, "px", doc->getWidth().unit); + double scale = Inkscape::Util::Quantity::convert(1, "px", doc_unit); ShapeEditor::blockSetItem(true); - doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, SP_ACTIVE_DOCUMENT->getHeight().value("px"))); + doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, doc->getHeight().value("px"))); ShapeEditor::blockSetItem(false); - - doc->ensureUpToDate(); - + Inkscape::DocumentUndo::setUndoSensitive(doc, saved); } diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp index cf0302b38..3bb17146c 100644 --- a/src/extension/internal/wmf-print.cpp +++ b/src/extension/internal/wmf-print.cpp @@ -1120,6 +1120,9 @@ unsigned int PrintWmf::image( Geom::Point pLL(x1, y1); Geom::Point pLL2 = pLL * tf; //location of LL corner in Inkscape coordinates + Geom::Point pWH(dw, dh); + Geom::Point pWH2 = pWH * tf.withoutTranslation(); //adjust scale + char *px; uint32_t cbPx; uint32_t colortype; @@ -1133,7 +1136,7 @@ unsigned int PrintWmf::image( Bmi = bitmapinfo_set(Bmih, ct); U_POINT16 Dest = point16_set(round(pLL2[Geom::X] * PX2WORLD), round(pLL2[Geom::Y] * PX2WORLD)); - U_POINT16 cDest = point16_set(round(dw * PX2WORLD), round(dh * PX2WORLD)); + U_POINT16 cDest = point16_set(round(pWH2[Geom::X] * PX2WORLD), round(pWH2[Geom::Y] * PX2WORLD)); U_POINT16 Src = point16_set(0, 0); U_POINT16 cSrc = point16_set(w, h); rec = U_WMRSTRETCHDIB_set( diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp index ac86a6171..14ff3ec77 100644 --- a/src/extension/internal/wpg-input.cpp +++ b/src/extension/internal/wpg-input.cpp @@ -113,8 +113,8 @@ SPDocument *WpgInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u SPDocument * doc = SPDocument::createNewDocFromMem(output.cstr(), strlen(output.cstr()), TRUE); // Set viewBox if it doesn't exist - if (!doc->getRoot()->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + if (doc && !doc->getRoot()->viewBox_set) { + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } delete input; diff --git a/src/file.cpp b/src/file.cpp index 8a7b177c0..f978ec66e 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -144,7 +144,7 @@ SPDesktop *sp_file_new(const std::string &templ) // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { DocumentUndo::setUndoSensitive(doc, false); - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); DocumentUndo::setUndoSensitive(doc, true); } diff --git a/src/interface.cpp b/src/interface.cpp index e57092e2b..f411989ce 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -324,7 +324,7 @@ sp_ui_close_view(GtkWidget */*widget*/) SPDocument *doc = SPDocument::createNewDoc( templateUri.c_str() , TRUE, true ); // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } dt->change_document(doc); sp_namedview_window_from_document(dt); diff --git a/src/libavoid/connector.cpp b/src/libavoid/connector.cpp index cf8cfa11a..8dcb66f2d 100644 --- a/src/libavoid/connector.cpp +++ b/src/libavoid/connector.cpp @@ -1736,7 +1736,8 @@ CrossingsInfoPair countRealCrossings(Avoid::Polygon& poly, !reversedY); } else - { + { /// \todo FIXME: this whole branch was not doing anything + /* int turnDirA = vecDir(a0, a1, a2); int turnDirB = vecDir(b0, b1, b2); bool reversed = (side1 != -turnDirA); @@ -1761,6 +1762,7 @@ CrossingsInfoPair countRealCrossings(Avoid::Polygon& poly, } VertID vID(b1.id, true, b1.vn); //(*pointOrders)[b1].addPoints(&b1, &a1, reversed); + */ } } } diff --git a/src/libcola/cola.h b/src/libcola/cola.h index e1f19994e..a4b05fd92 100644 --- a/src/libcola/cola.h +++ b/src/libcola/cola.h @@ -120,7 +120,7 @@ public: maxiterations(maxiterations) { reset(); } virtual ~TestConvergence() {} - virtual bool operator()(double new_stress, double* X, double* Y) { + virtual bool operator()(double new_stress, double* /*X*/, double* /*Y*/) { //std::cout<<"iteration="<<iterations<<", new_stress="<<new_stress<<std::endl; if (old_stress == DBL_MAX) { old_stress = new_stress; diff --git a/src/libdepixelize/priv/point.h b/src/libdepixelize/priv/point.h index dc28a2b84..53babd9dc 100644 --- a/src/libdepixelize/priv/point.h +++ b/src/libdepixelize/priv/point.h @@ -30,8 +30,8 @@ namespace Tracer { template<class T> struct Point { - Point() : visible(true) {} - Point(T x, T y) : visible(true), x(x), y(y) {} + Point() : smooth(false), visible(true) {} + Point(T x, T y) : smooth(false), visible(true), x(x), y(y) {} Point(T x, T y, bool smooth) : smooth(smooth), visible(true), x(x), y(y) {} Point operator+(const Point &rhs) const diff --git a/src/libuemf/uemf.h b/src/libuemf/uemf.h index f1211d63d..1ff6ead60 100644 --- a/src/libuemf/uemf.h +++ b/src/libuemf/uemf.h @@ -856,6 +856,7 @@ extern "C" { #define U_DSTINVERT 0x550009 #define U_BLACKNESS 0x000042 #define U_WHITENESS 0xff0062 +#define U_NOOP 0xaa0029 /* Many GDI programs end with a bitblt with this ROP == "D". Seems to work like flush() */ /** @} */ /** \defgroup U_EMRSETROP2_iMode_Qualifiers Binary Raster Operation Enumeration diff --git a/src/libvpsc/solve_VPSC.cpp b/src/libvpsc/solve_VPSC.cpp index f9bed649c..83cb517b6 100644 --- a/src/libvpsc/solve_VPSC.cpp +++ b/src/libvpsc/solve_VPSC.cpp @@ -301,16 +301,16 @@ bool Solver::constraintGraphIsCyclic(const unsigned n, Variable* const vs[]) { varmap[vs[i]]->out.insert(varmap[r]); } } - while(graph.size()>0) { + while(!graph.empty()) { node *u=NULL; vector<node*>::iterator i=graph.begin(); for(;i!=graph.end();++i) { u=*i; - if(u->in.size()==0) { + if(u->in.empty()) { break; } } - if(i==graph.end() && graph.size()>0) { + if(i==graph.end() && !graph.empty()) { //cycle found! return true; } else { @@ -358,16 +358,16 @@ bool Solver::blockGraphIsCyclic() { c=b->findMinOutConstraint(); } } - while(graph.size()>0) { + while(!graph.empty()) { node *u=NULL; vector<node*>::iterator i=graph.begin(); for(;i!=graph.end();++i) { u=*i; - if(u->in.size()==0) { + if(u->in.empty()) { break; } } - if(i==graph.end() && graph.size()>0) { + if(i==graph.end() && !graph.empty()) { //cycle found! return true; } else { diff --git a/src/livarot/ShapeMisc.cpp b/src/livarot/ShapeMisc.cpp index 6fd40790f..e40915cba 100644 --- a/src/livarot/ShapeMisc.cpp +++ b/src/livarot/ShapeMisc.cpp @@ -327,7 +327,7 @@ Shape::ConvertToForme (Path * dest, int nbP, Path * *orig, bool splitWhenForced) MakeSweepDestData (false); } void -Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,int &nbNest,int *&nesting,int *&contStart,bool splitWhenForced) +Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int /*wildPath*/,int &nbNest,int *&nesting,int *&contStart,bool splitWhenForced) { nesting=NULL; contStart=NULL; diff --git a/src/marker.cpp b/src/marker.cpp index 50e7c970f..d145aadaf 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -503,11 +503,11 @@ void SPMarker::hide(unsigned int key) { SPGroup::hide(key); } -Geom::OptRect SPMarker::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { +Geom::OptRect SPMarker::bbox(Geom::Affine const &/*transform*/, SPItem::BBoxType /*type*/) const { return Geom::OptRect(); } -void SPMarker::print(SPPrintContext* ctx) { +void SPMarker::print(SPPrintContext* /*ctx*/) { } diff --git a/src/marker.h b/src/marker.h index aae4e020f..831b298ac 100644 --- a/src/marker.h +++ b/src/marker.h @@ -77,7 +77,7 @@ public: virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void hide(unsigned int key); - virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type); + virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type) const; virtual void print(SPPrintContext *ctx); }; diff --git a/src/mesh-context.cpp b/src/mesh-context.cpp index ecd847fa4..142c3d2b1 100644 --- a/src/mesh-context.cpp +++ b/src/mesh-context.cpp @@ -104,7 +104,7 @@ const gchar *ms_handle_descr [] = { N_("Mesh gradient <b>tensor</b>") }; -void SPMeshContext::selection_changed(Inkscape::Selection* sel) { +void SPMeshContext::selection_changed(Inkscape::Selection* /*sel*/) { GrDrag *drag = this->_grdrag; Inkscape::Selection *selection = sp_desktop_selection(this->desktop); diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index 5dddb0832..4fd920bf8 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -62,7 +62,7 @@ static int count_filtered (GSList *items) int count=0; for (GSList *i = items; i != NULL; i = i->next) { SPItem *item = SP_ITEM(i->data); - count += item->ifilt(); + count += item->isFiltered(); } return count; } diff --git a/src/sp-anchor.cpp b/src/sp-anchor.cpp index a6a41bef3..7b558bf08 100644 --- a/src/sp-anchor.cpp +++ b/src/sp-anchor.cpp @@ -115,11 +115,11 @@ Inkscape::XML::Node* SPAnchor::write(Inkscape::XML::Document *xml_doc, Inkscape: return repr; } -const char* SPAnchor::displayName() { +const char* SPAnchor::displayName() const { return _("Link"); } -gchar* SPAnchor::description() { +gchar* SPAnchor::description() const { if (this->href) { char *quoted_href = xml_quote_strdup(this->href); char *ret = g_strdup_printf(_("to %s"), quoted_href); diff --git a/src/sp-anchor.h b/src/sp-anchor.h index 39f6d0b7a..778640032 100644 --- a/src/sp-anchor.h +++ b/src/sp-anchor.h @@ -30,8 +30,8 @@ public: virtual void set(unsigned int key, gchar const* value); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - virtual const char* displayName(); - virtual gchar* description(); + virtual const char* displayName() const; + virtual gchar* description() const; virtual gint event(SPEvent *event); }; diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index 8a0a8f233..4cf96e432 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -362,7 +362,7 @@ Inkscape::XML::Node *SPGenericEllipse::write(Inkscape::XML::Document *xml_doc, I return repr; } -const char *SPGenericEllipse::displayName() +const char *SPGenericEllipse::displayName() const { switch ( type ) { @@ -560,9 +560,11 @@ Geom::Affine SPGenericEllipse::set_transform(Geom::Affine const &xform) return ret; } -void SPGenericEllipse::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) +void SPGenericEllipse::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const { - this->normalize(); + // CPPIFY: is this call necessary? + const_cast<SPGenericEllipse*>(this)->normalize(); + Geom::Affine const i2dt = this->i2dt_affine(); // Snap to the 4 quadrant points of the ellipse, but only if the arc diff --git a/src/sp-ellipse.h b/src/sp-ellipse.h index 94bddde98..cb988b8bb 100644 --- a/src/sp-ellipse.h +++ b/src/sp-ellipse.h @@ -57,12 +57,12 @@ public: virtual void update(SPCtx *ctx, unsigned int flags); virtual Inkscape::XML::Node *write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - virtual const char *displayName(); + virtual const char *displayName() const; virtual void set_shape(); virtual Geom::Affine set_transform(Geom::Affine const &xform); - virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); + virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const; virtual void modified(unsigned int flags); diff --git a/src/sp-flowregion.cpp b/src/sp-flowregion.cpp index 13ab7bc64..709e9e464 100644 --- a/src/sp-flowregion.cpp +++ b/src/sp-flowregion.cpp @@ -188,7 +188,7 @@ Inkscape::XML::Node *SPFlowregion::write(Inkscape::XML::Document *xml_doc, Inksc return repr; } -const char* SPFlowregion::displayName() { +const char* SPFlowregion::displayName() const { // TRANSLATORS: "Flow region" is an area where text is allowed to flow return _("Flow Region"); } @@ -335,7 +335,7 @@ Inkscape::XML::Node *SPFlowregionExclude::write(Inkscape::XML::Document *xml_doc return repr; } -const char* SPFlowregionExclude::displayName() { +const char* SPFlowregionExclude::displayName() const { /* TRANSLATORS: A region "cut out of" a flow region; text is not allowed to flow inside the * flow excluded region. flowRegionExclude in SVG 1.2: see * http://www.w3.org/TR/2004/WD-SVG12-20041027/flow.html#flowRegion-elem and diff --git a/src/sp-flowregion.h b/src/sp-flowregion.h index 111a32c6c..721eb0432 100644 --- a/src/sp-flowregion.h +++ b/src/sp-flowregion.h @@ -31,7 +31,7 @@ public: virtual void update(SPCtx *ctx, unsigned int flags); virtual void modified(guint flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - virtual const char* displayName(); + virtual const char* displayName() const; }; class SPFlowregionExclude : public SPItem { @@ -48,7 +48,7 @@ public: virtual void update(SPCtx *ctx, unsigned int flags); virtual void modified(guint flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - virtual const char* displayName(); + virtual const char* displayName() const; }; #endif diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index 49360f9d9..fee320e90 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -260,7 +260,7 @@ Inkscape::XML::Node* SPFlowtext::write(Inkscape::XML::Document* doc, Inkscape::X return repr; } -Geom::OptRect SPFlowtext::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { +Geom::OptRect SPFlowtext::bbox(Geom::Affine const &transform, SPItem::BBoxType type) const { Geom::OptRect bbox = this->layout.bounds(transform); // Add stroke width @@ -284,7 +284,7 @@ void SPFlowtext::print(SPPrintContext *ctx) { this->layout.print(ctx, pbox, dbox, bbox, ctm); } -const char* SPFlowtext::displayName() { +const char* SPFlowtext::displayName() const { if (SP_FLOWTEXT(this)->has_internal_frame()) { return _("Flowed Text"); } else { @@ -292,7 +292,7 @@ const char* SPFlowtext::displayName() { } } -gchar* SPFlowtext::description() { +gchar* SPFlowtext::description() const { Inkscape::Text::Layout const &layout = SP_FLOWTEXT(this)->layout; int const nChars = layout.iteratorToCharIndex(layout.end()); char const *trunc = (layout.inputTruncated()) ? _(" [truncated]") : ""; @@ -300,7 +300,7 @@ gchar* SPFlowtext::description() { return g_strdup_printf(ngettext(_("(%d character%s)"), _("(%d characters%s)"), nChars), nChars, trunc); } -void SPFlowtext::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) { +void SPFlowtext::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const { if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_TEXT_BASELINE)) { // Choose a point on the baseline for snapping from or to, with the horizontal position // of this point depending on the text alignment (left vs. right) @@ -316,7 +316,7 @@ void SPFlowtext::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inksca } } -Inkscape::DrawingItem* SPFlowtext::show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { +Inkscape::DrawingItem* SPFlowtext::show(Inkscape::Drawing &drawing, unsigned int /*key*/, unsigned int /*flags*/) { Inkscape::DrawingGroup *flowed = new Inkscape::DrawingGroup(drawing); flowed->setPickChildren(false); flowed->setStyle(this->style); diff --git a/src/sp-flowtext.h b/src/sp-flowtext.h index f56cba3cd..a5b7db22e 100644 --- a/src/sp-flowtext.h +++ b/src/sp-flowtext.h @@ -71,13 +71,13 @@ public: virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type); + virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type) const; virtual void print(SPPrintContext *ctx); - virtual const char* displayName(); - virtual gchar* description(); + virtual const char* displayName() const; + virtual gchar* description() const; virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void hide(unsigned int key); - virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); + virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const; }; SPItem *create_flowtext_with_internal_frame (SPDesktop *desktop, Geom::Point p1, Geom::Point p2); diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index adfff3609..04fb18cf3 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -418,23 +418,28 @@ void SPGradient::remove_child(Inkscape::XML::Node *child) void SPGradient::modified(guint flags) { if (flags & SP_OBJECT_CHILD_MODIFIED_FLAG) { - // CPPIFY + // CPPIFY + // This comparison has never worked (i. e. always evaluated to false), + // the right value would have been SP_TYPE_MESHGRADIENT //if( this->get_type() != SP_GRADIENT_TYPE_MESH ) { - if (!SP_IS_MESHGRADIENT(this)) { - this->invalidateVector(); - } else { - this->invalidateArray(); - } +// if (!SP_IS_MESHGRADIENT(this)) { +// this->invalidateVector(); +// } else { +// this->invalidateArray(); +// } + this->invalidateVector(); } if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { - // CPPIFY + // CPPIFY + // see above //if( this->get_type() != SP_GRADIENT_TYPE_MESH ) { - if (!SP_IS_MESHGRADIENT(this)) { - this->ensureVector(); - } else { - this->ensureArray(); - } +// if (!SP_IS_MESHGRADIENT(this)) { +// this->ensureVector(); +// } else { +// this->ensureArray(); +// } + this->ensureVector(); } if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 86668d9ed..8f7a60ca6 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -555,7 +555,7 @@ Inkscape::XML::Node *SPImage::write(Inkscape::XML::Document *xml_doc, Inkscape:: return repr; } -Geom::OptRect SPImage::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { +Geom::OptRect SPImage::bbox(Geom::Affine const &transform, SPItem::BBoxType /*type*/) const { Geom::OptRect bbox; if ((this->width.computed > 0.0) && (this->height.computed > 0.0)) { @@ -612,11 +612,11 @@ void SPImage::print(SPPrintContext *ctx) { } } -const char* SPImage::displayName() { +const char* SPImage::displayName() const { return _("Image"); } -gchar* SPImage::description() { +gchar* SPImage::description() const { char *href_desc; if (this->href) { @@ -638,7 +638,7 @@ gchar* SPImage::description() { return ret; } -Inkscape::DrawingItem* SPImage::show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { +Inkscape::DrawingItem* SPImage::show(Inkscape::Drawing &drawing, unsigned int /*key*/, unsigned int /*flags*/) { Inkscape::DrawingImage *ai = new Inkscape::DrawingImage(drawing); sp_image_update_arenaitem(this, ai); @@ -748,7 +748,7 @@ static void sp_image_update_canvas_image(SPImage *image) } } -void SPImage::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) { +void SPImage::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const { /* An image doesn't have any nodes to snap, but still we want to be able snap one image to another. Therefore we will create some snappoints at the corner, similar to a rect. If the image is rotated, then the snappoints will rotate with it. Again, just like a rect. diff --git a/src/sp-image.h b/src/sp-image.h index b5834c988..3b7208487 100644 --- a/src/sp-image.h +++ b/src/sp-image.h @@ -62,12 +62,12 @@ public: virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); virtual void modified(unsigned int flags); - virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type); + virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type) const; virtual void print(SPPrintContext *ctx); - virtual const char* displayName(); - virtual gchar* description(); + virtual const char* displayName() const; + virtual gchar* description() const; virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); - virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); + virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const; virtual Geom::Affine set_transform(Geom::Affine const &transform); }; diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index ae974200f..2cfe97db8 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -291,11 +291,12 @@ Inkscape::XML::Node* SPGroup::write(Inkscape::XML::Document *xml_doc, Inkscape:: return repr; } -Geom::OptRect SPGroup::bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) +Geom::OptRect SPGroup::bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) const { Geom::OptRect bbox; - GSList *l = this->childList(false, SPObject::ActionBBox); + // CPPIFY: replace this const_cast later + GSList *l = const_cast<SPGroup*>(this)->childList(false, SPObject::ActionBBox); while (l) { SPObject *o = SP_OBJECT (l->data); @@ -326,11 +327,11 @@ void SPGroup::print(SPPrintContext *ctx) { } } -const char *SPGroup::displayName() { +const char *SPGroup::displayName() const { return _("Group"); } -gchar *SPGroup::description() { +gchar *SPGroup::description() const { gint len = this->getItemCount(); return g_strdup_printf( ngettext(_("of <b>%d</b> object"), _("of <b>%d</b> objects"), len), len); @@ -385,7 +386,7 @@ void SPGroup::hide (unsigned int key) { } -void SPGroup::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) { +void SPGroup::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const { for ( SPObject const *o = this->firstChild(); o; o = o->getNext() ) { if (SP_IS_ITEM(o)) { @@ -720,9 +721,9 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p) } } -gint SPGroup::getItemCount() { +gint SPGroup::getItemCount() const { gint len = 0; - for (SPObject *o = this->firstChild() ; o ; o = o->getNext() ) { + for (SPObject const *o = this->firstChild() ; o ; o = o->getNext() ) { if (SP_IS_ITEM(o)) { len++; } diff --git a/src/sp-item-group.h b/src/sp-item-group.h index 3954a5d21..deb80a641 100644 --- a/src/sp-item-group.h +++ b/src/sp-item-group.h @@ -54,7 +54,7 @@ public: void translateChildItems(Geom::Translate const &tr); void scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p); - gint getItemCount(); + gint getItemCount() const; void _showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags); private: @@ -74,14 +74,14 @@ public: virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype); + virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) const; virtual void print(SPPrintContext *ctx); - virtual const char* displayName(); - virtual gchar *description(); + virtual const char* displayName() const; + virtual gchar *description() const; virtual Inkscape::DrawingItem *show (Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void hide (unsigned int key); - virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); + virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const; virtual void update_patheffect(bool write); }; diff --git a/src/sp-item.cpp b/src/sp-item.cpp index e8338046b..55ff60aeb 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -255,7 +255,7 @@ SPItem::unsetCenter() { transform_center_y = 0; } -bool SPItem::isCenterSet() { +bool SPItem::isCenterSet() const { return (transform_center_x != 0 || transform_center_y != 0); } @@ -562,7 +562,7 @@ void SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) } } -void SPItem::update(SPCtx *ctx, guint flags) { +void SPItem::update(SPCtx* /*ctx*/, guint flags) { SPItem *item = this; SPItem* object = item; @@ -688,7 +688,7 @@ Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::X } // CPPIFY: make pure virtual -Geom::OptRect SPItem::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { +Geom::OptRect SPItem::bbox(Geom::Affine const & /*transform*/, SPItem::BBoxType /*type*/) const { //throw; return Geom::OptRect(); } @@ -848,18 +848,17 @@ Geom::OptRect SPItem::desktopBounds(BBoxType type) const } } -unsigned SPItem::pos_in_parent() -{ +unsigned int SPItem::pos_in_parent() const { g_assert(parent != NULL); g_assert(SP_IS_OBJECT(parent)); - SPObject *object = this; + unsigned int pos = 0; - unsigned pos=0; for ( SPObject *iter = parent->firstChild() ; iter ; iter = iter->next) { - if ( iter == object ) { + if (iter == this) { return pos; } + if (SP_IS_ITEM(iter)) { pos++; } @@ -870,7 +869,7 @@ unsigned SPItem::pos_in_parent() } // CPPIFY: make pure virtual, see below! -void SPItem::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) { +void SPItem::snappoints(std::vector<Inkscape::SnapCandidatePoint> & /*p*/, Inkscape::SnapPreferences const */*snapprefs*/) const { //throw; } /* This will only be called if the derived class doesn't override this. @@ -920,7 +919,7 @@ void SPItem::getSnappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscap } // CPPIFY: make pure virtual -void SPItem::print(SPPrintContext* ctx) { +void SPItem::print(SPPrintContext* /*ctx*/) { //throw; } @@ -937,11 +936,11 @@ void SPItem::invoke_print(SPPrintContext *ctx) } } -const char* SPItem::displayName() { +const char* SPItem::displayName() const { return _("Object"); } -gchar* SPItem::description() { +gchar* SPItem::description() const { return g_strdup(""); } @@ -950,8 +949,7 @@ gchar* SPItem::description() { * * Must be freed by caller. */ -gchar *SPItem::detailedDescription() -{ +gchar *SPItem::detailedDescription() const { gchar* s = g_strdup_printf("<b>%s</b> %s", this->displayName(), this->description()); @@ -985,17 +983,11 @@ gchar *SPItem::detailedDescription() } /** - * Returns 1 if the item is filtered, 0 otherwise. Used with groups/lists to determine how many, or if any, are filtered + * Returns true if the item is filtered, false otherwise. Used with groups/lists to determine how many, or if any, are filtered * */ -int SPItem::ifilt() -{ - int retval=0; - if ( style && style->filter.href && style->filter.href->getObject() ) { - retval=1; - } - - return retval; +bool SPItem::isFiltered() const { + return (style && style->filter.href && style->filter.href->getObject()); } /** @@ -1014,7 +1006,7 @@ unsigned SPItem::display_key_new(unsigned numkeys) } // CPPIFY: make pure virtual -Inkscape::DrawingItem* SPItem::show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { +Inkscape::DrawingItem* SPItem::show(Inkscape::Drawing& /*drawing*/, unsigned int /*key*/, unsigned int /*flags*/) { //throw; return 0; } @@ -1073,7 +1065,7 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned } // CPPIFY: make pure virtual -void SPItem::hide(unsigned int key) { +void SPItem::hide(unsigned int /*key*/) { //throw; } @@ -1419,7 +1411,7 @@ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &tra } // CPPIFY: see below, do not make pure? -gint SPItem::event(SPEvent* event) { +gint SPItem::event(SPEvent* /*event*/) { return FALSE; } @@ -1443,8 +1435,8 @@ void SPItem::set_item_transform(Geom::Affine const &transform_matrix) } } -//void SPItem::convert_to_guides() { -// // CPPIFY: If not overridden, call SPItem::convert_to_guides(), see below! +//void SPItem::convert_to_guides() const { +// // CPPIFY: If not overridden, call SPItem::convert_to_guides() const, see below! // this->convert_to_guides(); //} @@ -1607,7 +1599,7 @@ SPItem *sp_item_first_item_child(SPObject *obj) return child; } -void SPItem::convert_to_guides() { +void SPItem::convert_to_guides() const { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int prefs_bbox = prefs->getInt("/tools/bounding_box", 0); diff --git a/src/sp-item.h b/src/sp-item.h index ce5400e66..d605c99b9 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -157,7 +157,7 @@ public: void setCenter(Geom::Point const &object_centre); void unsetCenter(); - bool isCenterSet(); + bool isCenterSet() const; Geom::Point getCenter() const; bool isVisibleAndUnlocked() const; @@ -187,9 +187,12 @@ public: Geom::OptRect desktopPreferredBounds() const; Geom::OptRect desktopBounds(BBoxType type) const; - unsigned pos_in_parent(); - gchar *detailedDescription(); - int ifilt(); + unsigned int pos_in_parent() const; + + gchar *detailedDescription() const; + + bool isFiltered() const; + void invoke_print(SPPrintContext *ctx); static unsigned int display_key_new(unsigned int numkeys); Inkscape::DrawingItem *invoke_show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); @@ -204,7 +207,6 @@ public: void adjust_livepatheffect(Geom::Affine const &postmul, bool set = false); void doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &transform, Geom::Affine const *adv = NULL, bool compensate = true); void set_item_transform(Geom::Affine const &transform_matrix); - void convert_item_to_guides(); gint emitEvent (SPEvent &event); Inkscape::DrawingItem *get_arenaitem(unsigned int key); @@ -212,7 +214,6 @@ public: Geom::Affine i2dt_affine() const; void set_i2d_affine(Geom::Affine const &transform); Geom::Affine dt2i_affine() const; - //void convert_to_guides(); private: enum EvaluatedStatus @@ -234,15 +235,17 @@ public: virtual void update(SPCtx *ctx, guint flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type); + virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type) const; virtual void print(SPPrintContext *ctx); - virtual const char* displayName(); - virtual gchar* description(); + virtual const char* displayName() const; + virtual gchar* description() const; virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void hide(unsigned int key); - virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); + virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const; virtual Geom::Affine set_transform(Geom::Affine const &transform); - virtual void convert_to_guides(); + + virtual void convert_to_guides() const; + virtual gint event(SPEvent *event); }; diff --git a/src/sp-line.cpp b/src/sp-line.cpp index 6b7df84f6..8af95b4ce 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -122,11 +122,11 @@ Inkscape::XML::Node* SPLine::write(Inkscape::XML::Document *xml_doc, Inkscape::X return repr; } -const char* SPLine::displayName() { +const char* SPLine::displayName() const { return _("Line"); } -void SPLine::convert_to_guides() { +void SPLine::convert_to_guides() const { Geom::Point points[2]; Geom::Affine const i2dt(this->i2dt_affine()); diff --git a/src/sp-line.h b/src/sp-line.h index f76c3449b..c1932d3ee 100644 --- a/src/sp-line.h +++ b/src/sp-line.h @@ -34,9 +34,9 @@ public: virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); virtual void set(unsigned int key, gchar const* value); - virtual const char* displayName(); + virtual const char* displayName() const; virtual Geom::Affine set_transform(Geom::Affine const &transform); - virtual void convert_to_guides(); + virtual void convert_to_guides() const; virtual void update(SPCtx* ctx, guint flags); virtual void set_shape(); diff --git a/src/sp-linear-gradient.cpp b/src/sp-linear-gradient.cpp index 4e7a08f4b..959e8d733 100644 --- a/src/sp-linear-gradient.cpp +++ b/src/sp-linear-gradient.cpp @@ -96,7 +96,7 @@ Inkscape::XML::Node* SPLinearGradient::write(Inkscape::XML::Document *xml_doc, I return repr; } -cairo_pattern_t* SPLinearGradient::pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity) { +cairo_pattern_t* SPLinearGradient::pattern_new(cairo_t * /*ct*/, Geom::OptRect const &bbox, double opacity) { this->ensureVector(); cairo_pattern_t *cp = cairo_pattern_create_linear( diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index 61ba2ae0d..666c79e49 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -258,7 +258,7 @@ bool SPLPEItem::performPathEffect(SPCurve *curve) { } // CPPIFY: make pure virtual -void SPLPEItem::update_patheffect(bool write) { +void SPLPEItem::update_patheffect(bool /*write*/) { //throw; } diff --git a/src/sp-mesh-gradient.cpp b/src/sp-mesh-gradient.cpp index 3fd277f52..eb5ed1bd0 100644 --- a/src/sp-mesh-gradient.cpp +++ b/src/sp-mesh-gradient.cpp @@ -93,7 +93,7 @@ sp_meshgradient_repr_write(SPMeshGradient *mg) } -cairo_pattern_t* SPMeshGradient::pattern_new(cairo_t *ct, +cairo_pattern_t* SPMeshGradient::pattern_new(cairo_t * /*ct*/, #if defined(MESH_DEBUG) || (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 4)) Geom::OptRect const &bbox, double opacity diff --git a/src/sp-mesh-row.cpp b/src/sp-mesh-row.cpp index 04619d6cc..07747f7f5 100644 --- a/src/sp-mesh-row.cpp +++ b/src/sp-mesh-row.cpp @@ -81,7 +81,7 @@ void SPMeshRow::build(SPDocument* doc, Inkscape::XML::Node* repr) { * Virtual build: set meshrow attributes from its associated XML node. */ -void SPMeshRow::set(unsigned int key, const gchar* value) { +void SPMeshRow::set(unsigned int /*key*/, const gchar* /*value*/) { } /** diff --git a/src/sp-metadata.cpp b/src/sp-metadata.cpp index a093107ac..bf4ce27a1 100644 --- a/src/sp-metadata.cpp +++ b/src/sp-metadata.cpp @@ -98,7 +98,7 @@ void SPMetadata::set(unsigned int key, const gchar* value) { SPObject::set(key, value); } -void SPMetadata::update(SPCtx* ctx, unsigned int flags) { +void SPMetadata::update(SPCtx* /*ctx*/, unsigned int flags) { debug("0x%08x",(unsigned int)this); //SPMetadata *metadata = SP_METADATA(object); diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index ad497ff2f..a01ba891e 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -1073,6 +1073,11 @@ SPNamedView *sp_document_namedview(SPDocument *document, const gchar *id) return (SPNamedView *) nv; } +SPNamedView const *sp_document_namedview(SPDocument const *document, const gchar *id) +{ + return sp_document_namedview(const_cast<SPDocument *>(document), id); // use a const_cast here to avoid duplicating code +} + void SPNamedView::setGuides(bool v) { g_assert(this->getRepr() != NULL); diff --git a/src/sp-namedview.h b/src/sp-namedview.h index 00302e9a1..05cbcc398 100644 --- a/src/sp-namedview.h +++ b/src/sp-namedview.h @@ -110,6 +110,7 @@ protected: SPNamedView *sp_document_namedview(SPDocument *document, gchar const *name); +SPNamedView const *sp_document_namedview(SPDocument const *document, gchar const *name); void sp_namedview_window_from_document(SPDesktop *desktop); void sp_namedview_document_from_window(SPDesktop *desktop); diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 8c54caf48..4a32c9470 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -151,11 +151,11 @@ void SPObject::read_content() { //throw; } -void SPObject::update(SPCtx* ctx, unsigned int flags) { +void SPObject::update(SPCtx* /*ctx*/, unsigned int /*flags*/) { //throw; } -void SPObject::modified(unsigned int flags) { +void SPObject::modified(unsigned int /*flags*/) { //throw; } @@ -228,7 +228,7 @@ SPObject *sp_object_unref(SPObject *object, SPObject *owner) //g_object_unref(G_OBJECT(object)); object->refCount--; - if (object->refCount < 0) { + if (object->refCount <= 0) { delete object; } @@ -624,7 +624,7 @@ void SPObject::remove_child(Inkscape::XML::Node* child) { } } -void SPObject::order_changed(Inkscape::XML::Node *child, Inkscape::XML::Node * old_ref, Inkscape::XML::Node *new_ref) { +void SPObject::order_changed(Inkscape::XML::Node *child, Inkscape::XML::Node * /*old_ref*/, Inkscape::XML::Node *new_ref) { SPObject* object = this; SPObject *ochild = object->get_child_by_repr(child); @@ -648,11 +648,6 @@ void SPObject::build(SPDocument *document, Inkscape::XML::Node *repr) { try { const std::string typeString = NodeTraits::get_type_string(*rchild); - // special cases - if (typeString.empty()) continue; // comments, usually - if (typeString == "rdf:RDF") continue; // no SP node yet - if (typeString == "inkscape:clipboard") continue; // SP node not necessary - SPObject* child = SPFactory::instance().createObject(typeString); object->attach(child, object->lastChild()); @@ -663,7 +658,7 @@ void SPObject::build(SPDocument *document, Inkscape::XML::Node *repr) { // corresponding classes in the SPObject tree. // (rdf:RDF, inkscape:clipboard, ...) // Thus, simply ignore this case for now. - return; + continue; } } } diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index f0b152d0e..c5a3557a7 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -339,7 +339,7 @@ void SPOffset::update(SPCtx *ctx, guint flags) { SPShape::update(ctx, flags); } -const char* SPOffset::displayName() { +const char* SPOffset::displayName() const { if ( this->sourceHref ) { return _("Linked Offset"); } else { @@ -347,7 +347,7 @@ const char* SPOffset::displayName() { } } -gchar* SPOffset::description() { +gchar* SPOffset::description() const { // TRANSLATORS COMMENT: %s is either "outset" or "inset" depending on sign return g_strdup_printf(_("%s by %f pt"), (this->rad >= 0) ? _("outset") : _("inset"), fabs (this->rad)); @@ -692,7 +692,7 @@ void SPOffset::set_shape() { } } -void SPOffset::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) { +void SPOffset::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const { SPShape::snappoints(p, snapprefs); } diff --git a/src/sp-offset.h b/src/sp-offset.h index b93a6846b..259a69b78 100644 --- a/src/sp-offset.h +++ b/src/sp-offset.h @@ -81,9 +81,9 @@ public: virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); virtual void release(); - virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); - virtual const char* displayName(); - virtual gchar* description(); + virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const; + virtual const char* displayName() const; + virtual gchar* description() const; virtual void set_shape(); }; diff --git a/src/sp-path.cpp b/src/sp-path.cpp index b225f0735..563c5b326 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -66,11 +66,11 @@ gint SPPath::nodesInPath() const return _curve ? _curve->nodes_in_path() : 0; } -const char* SPPath::displayName() { +const char* SPPath::displayName() const { return _("Path"); } -gchar* SPPath::description() { +gchar* SPPath::description() const { int count = this->nodesInPath(); char *lpe_desc = g_strdup(""); @@ -100,7 +100,7 @@ gchar* SPPath::description() { return ret; } -void SPPath::convert_to_guides() { +void SPPath::convert_to_guides() const { if (!this->_curve) { return; } diff --git a/src/sp-path.h b/src/sp-path.h index 77c64a2cc..5f8a91d98 100644 --- a/src/sp-path.h +++ b/src/sp-path.h @@ -54,10 +54,10 @@ public: virtual void set(unsigned int key, gchar const* value); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - virtual const char* displayName(); - virtual gchar* description(); + virtual const char* displayName() const; + virtual gchar* description() const; virtual Geom::Affine set_transform(Geom::Affine const &transform); - virtual void convert_to_guides(); + virtual void convert_to_guides() const; virtual void update_patheffect(bool write); }; diff --git a/src/sp-polygon.cpp b/src/sp-polygon.cpp index a5ddd653a..10d097e70 100644 --- a/src/sp-polygon.cpp +++ b/src/sp-polygon.cpp @@ -178,7 +178,7 @@ void SPPolygon::set(unsigned int key, const gchar* value) { } } -gchar* SPPolygon::description() { +gchar* SPPolygon::description() const { return g_strdup(_("<b>Polygon</b>")); } diff --git a/src/sp-polygon.h b/src/sp-polygon.h index f9c93ac8f..41ab245bd 100644 --- a/src/sp-polygon.h +++ b/src/sp-polygon.h @@ -27,7 +27,7 @@ public: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); virtual void set(unsigned int key, gchar const* value); - virtual gchar* description(); + virtual gchar* description() const; }; // made 'public' so that SPCurve can set it as friend: diff --git a/src/sp-polyline.cpp b/src/sp-polyline.cpp index 1de5492cd..c80190097 100644 --- a/src/sp-polyline.cpp +++ b/src/sp-polyline.cpp @@ -127,7 +127,7 @@ Inkscape::XML::Node* SPPolyLine::write(Inkscape::XML::Document *xml_doc, Inkscap return repr; } -gchar* SPPolyLine::description() { +gchar* SPPolyLine::description() const { return g_strdup(_("<b>Polyline</b>")); } diff --git a/src/sp-polyline.h b/src/sp-polyline.h index f8b7e9b49..e24ea95c7 100644 --- a/src/sp-polyline.h +++ b/src/sp-polyline.h @@ -15,7 +15,7 @@ public: virtual void set(unsigned int key, gchar const* value); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - virtual gchar* description(); + virtual gchar* description() const; }; #endif // SEEN_SP_POLYLINE_H diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index ff5e81f95..af3e2bfb4 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -113,7 +113,7 @@ void SPRect::set(unsigned key, gchar const *value) { void SPRect::update(SPCtx* ctx, unsigned int flags) { if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { - SPItemCtx const *ictx = (SPItemCtx const *) ctx; + SPItemCtx const *ictx = reinterpret_cast<SPItemCtx const *>(ctx); double const w = ictx->viewport.width(); double const h = ictx->viewport.height(); @@ -159,7 +159,7 @@ Inkscape::XML::Node * SPRect::write(Inkscape::XML::Document *xml_doc, Inkscape:: return repr; } -const char* SPRect::displayName() { +const char* SPRect::displayName() const { return _("Rectangle"); } @@ -484,7 +484,7 @@ gdouble SPRect::getVisibleHeight() const { this->transform); } -void SPRect::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) { +void SPRect::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const { /* This method overrides sp_shape_snappoints, which is the default for any shape. The default method returns all eight points along the path of a rounded rectangle, but not the real corners. Snapping the startpoint and endpoint of each rounded corner is not very useful and really confusing. Instead @@ -518,7 +518,7 @@ void SPRect::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape:: } } -void SPRect::convert_to_guides() { +void SPRect::convert_to_guides() const { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (!prefs->getBool("/tools/shapes/rect/convertguides", true)) { diff --git a/src/sp-rect.h b/src/sp-rect.h index 3219a3ace..aa3f88e42 100644 --- a/src/sp-rect.h +++ b/src/sp-rect.h @@ -55,13 +55,13 @@ public: virtual void update(SPCtx* ctx, unsigned int flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - virtual const char* displayName(); + virtual const char* displayName() const; virtual void set_shape(); virtual Geom::Affine set_transform(Geom::Affine const& xform); - virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); - virtual void convert_to_guides(); + virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const; + virtual void convert_to_guides() const; SVGLength x; SVGLength y; diff --git a/src/sp-root.cpp b/src/sp-root.cpp index c87c8397d..5466649a2 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -62,7 +62,7 @@ SPRoot::SPRoot() : SPGroup() this->width.unset(SVGLength::PERCENT, 1.0, 1.0); this->height.unset(SVGLength::PERCENT, 1.0, 1.0); - this->viewBox_set = FALSE; + this->viewBox_set = false; this->c2p.setIdentity(); diff --git a/src/sp-root.h b/src/sp-root.h index 47a37029d..2931391ff 100644 --- a/src/sp-root.h +++ b/src/sp-root.h @@ -41,7 +41,7 @@ public: SVGLength height; /* viewBox; */ - bool viewBox_set : true; + bool viewBox_set; Geom::Rect viewBox; /* preserveAspectRatio */ diff --git a/src/sp-script.cpp b/src/sp-script.cpp index 158796e51..260b3dcfd 100644 --- a/src/sp-script.cpp +++ b/src/sp-script.cpp @@ -57,11 +57,11 @@ void SPScript::release() { SPObject::release(); } -void SPScript::update(SPCtx* ctx, unsigned int flags) { +void SPScript::update(SPCtx* /*ctx*/, unsigned int /*flags*/) { } -void SPScript::modified(unsigned int flags) { +void SPScript::modified(unsigned int /*flags*/) { } @@ -81,7 +81,7 @@ void SPScript::set(unsigned int key, const gchar* value) { } } -Inkscape::XML::Node* SPScript::write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags) { +Inkscape::XML::Node* SPScript::write(Inkscape::XML::Document* /*doc*/, Inkscape::XML::Node* repr, guint /*flags*/) { return repr; } diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 913e208aa..b3a331cba 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -389,7 +389,7 @@ void SPShape::modified(unsigned int flags) { } } -Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) { +Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) const { Geom::OptRect bbox; if (!this->_curve) { @@ -712,7 +712,7 @@ void SPShape::print(SPPrintContext* ctx) { } } -Inkscape::DrawingItem* SPShape::show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { +Inkscape::DrawingItem* SPShape::show(Inkscape::Drawing &drawing, unsigned int /*key*/, unsigned int /*flags*/) { Inkscape::DrawingShape *s = new Inkscape::DrawingShape(drawing); s->setStyle(this->style); s->setPath(this->_curve); @@ -796,8 +796,7 @@ int SPShape::hasMarkers() const * \param type Marker type (e.g. SP_MARKER_LOC_START) * \return Number of markers that the shape has of this type. */ -int SPShape::numberOfMarkers(int type) -{ +int SPShape::numberOfMarkers(int type) const { Geom::PathVector const & pathv = this->_curve->get_pathvector(); if (pathv.size() == 0) { @@ -1025,7 +1024,7 @@ void SPShape::setCurveInsync(SPCurve *new_curve, unsigned int owner) } } -void SPShape::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) { +void SPShape::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const { if (this->_curve == NULL) { return; } diff --git a/src/sp-shape.h b/src/sp-shape.h index bc51f3d45..f260c1ee6 100644 --- a/src/sp-shape.h +++ b/src/sp-shape.h @@ -44,7 +44,7 @@ public: void setCurveInsync (SPCurve *curve, unsigned int owner); void setCurveBeforeLPE (SPCurve *curve); int hasMarkers () const; - int numberOfMarkers (int type); + int numberOfMarkers (int type) const; public: // temporarily public, until SPPath is properly classed, etc. SPCurve *_curve_before_lpe; @@ -63,13 +63,13 @@ public: virtual void set(unsigned int key, gchar const* value); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype); + virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) const; virtual void print(SPPrintContext* ctx); virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void hide(unsigned int key); - virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); + virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const; virtual void set_shape(); }; diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index 56aca507f..ffb875f2a 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -226,11 +226,11 @@ void SPSpiral::update_patheffect(bool write) { this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } -const char* SPSpiral::displayName() { +const char* SPSpiral::displayName() const { return _("Spiral"); } -gchar* SPSpiral::description() { +gchar* SPSpiral::description() const { // TRANSLATORS: since turn count isn't an integer, please adjust the // string as needed to deal with an localized plural forms. return g_strdup_printf (_("with %3f turns"), this->revo); @@ -413,7 +413,7 @@ void SPSpiral::setPosition(gdouble cx, gdouble cy, gdouble exp, gdouble revo, gd this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } -void SPSpiral::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) { +void SPSpiral::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const { // We will determine the spiral's midpoint ourselves, instead of trusting on the base class // Therefore snapping to object midpoints is temporarily disabled Inkscape::SnapPreferences local_snapprefs = *snapprefs; diff --git a/src/sp-spiral.h b/src/sp-spiral.h index 4e067981b..64b95d951 100644 --- a/src/sp-spiral.h +++ b/src/sp-spiral.h @@ -66,9 +66,9 @@ public: virtual void update(SPCtx *ctx, guint flags); virtual void set(unsigned int key, gchar const* value); - virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); - virtual const char* displayName(); - virtual gchar* description(); + virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const; + virtual const char* displayName() const; + virtual gchar* description() const; virtual void set_shape(); virtual void update_patheffect(bool write); diff --git a/src/sp-star.cpp b/src/sp-star.cpp index e634eccac..da10eeaa3 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -251,13 +251,13 @@ void SPStar::update_patheffect(bool write) { this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } -const char* SPStar::displayName() { +const char* SPStar::displayName() const { if (this->flatsided == false) return _("Star"); return _("Polygon"); } -gchar* SPStar::description() { +gchar* SPStar::description() const { // while there will never be less than 3 vertices, we still need to // make calls to ngettext because the pluralization may be different // for various numbers >=3. The singular form is used as the index. @@ -498,7 +498,7 @@ sp_star_position_set (SPStar *star, gint sides, Geom::Point center, gdouble r1, star->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } -void SPStar::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) { +void SPStar::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const { // We will determine the star's midpoint ourselves, instead of trusting on the base class // Therefore snapping to object midpoints is temporarily disabled Inkscape::SnapPreferences local_snapprefs = *snapprefs; diff --git a/src/sp-star.h b/src/sp-star.h index 799880c42..0070ce685 100644 --- a/src/sp-star.h +++ b/src/sp-star.h @@ -50,9 +50,9 @@ public: virtual void set(unsigned int key, gchar const* value); virtual void update(SPCtx* ctx, guint flags); - virtual const char* displayName(); - virtual gchar* description(); - virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); + virtual const char* displayName() const; + virtual gchar* description() const; + virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const; virtual void update_patheffect(bool write); virtual void set_shape(); diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp index fa97cde91..5c88d7af8 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -71,17 +71,17 @@ GSList *SPSwitch::_childList(bool add_ref, SPObject::Action action) { return g_slist_prepend (NULL, child); } -const char *SPSwitch::displayName() { +const char *SPSwitch::displayName() const { return _("Conditional Group"); } -gchar *SPSwitch::description() { +gchar *SPSwitch::description() const { gint len = this->getItemCount(); return g_strdup_printf( ngettext(_("of <b>%d</b> object"), _("of <b>%d</b> objects"), len), len); } -void SPSwitch::child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref) { +void SPSwitch::child_added(Inkscape::XML::Node* /*child*/, Inkscape::XML::Node* /*ref*/) { this->_reevaluate(true); } diff --git a/src/sp-switch.h b/src/sp-switch.h index e6dc6f01f..3ccc9e3b7 100644 --- a/src/sp-switch.h +++ b/src/sp-switch.h @@ -41,8 +41,8 @@ public: virtual void child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref); virtual void remove_child(Inkscape::XML::Node *child); virtual void order_changed(Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref); - virtual const char* displayName(); - virtual gchar *description(); + virtual const char* displayName() const; + virtual gchar *description() const; }; #endif diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index b2346ac91..8ffc2ab2c 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -363,7 +363,7 @@ void SPSymbol::hide(unsigned int key) { } -Geom::OptRect SPSymbol::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { +Geom::OptRect SPSymbol::bbox(Geom::Affine const &transform, SPItem::BBoxType type) const { Geom::OptRect bbox; // We don't need a bounding box for Symbols dialog when selecting diff --git a/src/sp-symbol.h b/src/sp-symbol.h index 952ba00df..7a43ed658 100644 --- a/src/sp-symbol.h +++ b/src/sp-symbol.h @@ -54,7 +54,7 @@ public: virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void print(SPPrintContext *ctx); - virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type); + virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type) const; virtual void hide (unsigned int key); }; diff --git a/src/sp-text.cpp b/src/sp-text.cpp index de5e63fe6..d2f433eba 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -293,7 +293,7 @@ Inkscape::XML::Node *SPText::write(Inkscape::XML::Document *xml_doc, Inkscape::X return repr; } -Geom::OptRect SPText::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { +Geom::OptRect SPText::bbox(Geom::Affine const &transform, SPItem::BBoxType type) const { Geom::OptRect bbox = SP_TEXT(this)->layout.bounds(transform); // FIXME this code is incorrect @@ -305,7 +305,7 @@ Geom::OptRect SPText::bbox(Geom::Affine const &transform, SPItem::BBoxType type) return bbox; } -Inkscape::DrawingItem* SPText::show(Inkscape::Drawing &drawing, unsigned key, unsigned flags) { +Inkscape::DrawingItem* SPText::show(Inkscape::Drawing &drawing, unsigned /*key*/, unsigned /*flags*/) { Inkscape::DrawingGroup *flowed = new Inkscape::DrawingGroup(drawing); flowed->setPickChildren(false); flowed->setStyle(this->style); @@ -326,11 +326,11 @@ void SPText::hide(unsigned int key) { } } -const char* SPText::displayName() { +const char* SPText::displayName() const { return _("Text"); } -gchar* SPText::description() { +gchar* SPText::description() const { SPStyle *style = this->style; font_instance *tf = font_factory::Default()->FaceFromStyle(style); @@ -364,7 +364,7 @@ gchar* SPText::description() { return ret; } -void SPText::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) { +void SPText::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const { if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_TEXT_BASELINE)) { // Choose a point on the baseline for snapping from or to, with the horizontal position // of this point depending on the text alignment (left vs. right) diff --git a/src/sp-text.h b/src/sp-text.h index a7149159a..f7cf5a3aa 100644 --- a/src/sp-text.h +++ b/src/sp-text.h @@ -82,13 +82,13 @@ public: virtual void modified(unsigned int flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type); + virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type) const; virtual void print(SPPrintContext *ctx); - virtual const char* displayName(); - virtual gchar* description(); + virtual const char* displayName() const; + virtual gchar* description() const; virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void hide(unsigned int key); - virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); + virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const; virtual Geom::Affine set_transform(Geom::Affine const &transform); }; diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 1c0481547..edbb9faa7 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -206,7 +206,7 @@ Inkscape::XML::Node* SPTRef::write(Inkscape::XML::Document *xml_doc, Inkscape::X return repr; } -Geom::OptRect SPTRef::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { +Geom::OptRect SPTRef::bbox(Geom::Affine const &transform, SPItem::BBoxType type) const { Geom::OptRect bbox; // find out the ancestor text which holds our layout SPObject const *parent_text = this; @@ -233,14 +233,14 @@ Geom::OptRect SPTRef::bbox(Geom::Affine const &transform, SPItem::BBoxType type) return bbox; } -const char* SPTRef::displayName() { +const char* SPTRef::displayName() const { return _("Cloned Character Data"); } -gchar* SPTRef::description() { - SPObject *referred = this->getObjectReferredTo(); +gchar* SPTRef::description() const { + SPObject const *referred = this->getObjectReferredTo(); - if (this->getObjectReferredTo()) { + if (referred) { char *child_desc; if (SP_IS_ITEM(referred)) { @@ -313,6 +313,19 @@ SPObject * SPTRef::getObjectReferredTo(void) return referredObject; } +/** + * Return the object referred to via the URI reference + */ +SPObject const *SPTRef::getObjectReferredTo() const { + SPObject *referredObject = NULL; + + if (uriOriginalRef) { + referredObject = uriOriginalRef->getObject(); + } + + return referredObject; +} + /** * Returns true when the given tref is allowed to refer to a particular object diff --git a/src/sp-tref.h b/src/sp-tref.h index 6d43d679d..f5aed9ba6 100644 --- a/src/sp-tref.h +++ b/src/sp-tref.h @@ -49,6 +49,7 @@ public: sigc::connection _changed_connection; SPObject * getObjectReferredTo(); + SPObject const *getObjectReferredTo() const; virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); @@ -57,9 +58,9 @@ public: virtual void modified(unsigned int flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type); - virtual const char* displayName(); - virtual gchar* description(); + virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type) const; + virtual const char* displayName() const; + virtual gchar* description() const; }; void sp_tref_update_text(SPTRef *tref); diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index 20d404130..8c4105777 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -138,7 +138,7 @@ void SPTSpan::modified(unsigned int flags) { } } -Geom::OptRect SPTSpan::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { +Geom::OptRect SPTSpan::bbox(Geom::Affine const &transform, SPItem::BBoxType type) const { Geom::OptRect bbox; // find out the ancestor text which holds our layout SPObject const *parent_text = this; @@ -216,7 +216,7 @@ Inkscape::XML::Node* SPTSpan::write(Inkscape::XML::Document *xml_doc, Inkscape:: return repr; } -const char* SPTSpan::displayName() { +const char* SPTSpan::displayName() const { return _("Text Span"); } diff --git a/src/sp-tspan.h b/src/sp-tspan.h index a7ae563bb..4c23b2eba 100644 --- a/src/sp-tspan.h +++ b/src/sp-tspan.h @@ -33,8 +33,8 @@ public: virtual void modified(unsigned int flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type); - virtual const char* displayName(); + virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type) const; + virtual const char* displayName() const; }; #endif /* !INKSCAPE_SP_TSPAN_H */ diff --git a/src/sp-use.cpp b/src/sp-use.cpp index ec367d786..b2a51b8d9 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -178,7 +178,7 @@ Inkscape::XML::Node* SPUse::write(Inkscape::XML::Document *xml_doc, Inkscape::XM return repr; } -Geom::OptRect SPUse::bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) { +Geom::OptRect SPUse::bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) const { Geom::OptRect bbox; if (this->child) { @@ -208,7 +208,7 @@ void SPUse::print(SPPrintContext* ctx) { } } -const char* SPUse::displayName() { +const char* SPUse::displayName() const { if (this->child && SP_IS_SYMBOL( this->child )) { return _("Symbol"); } @@ -216,7 +216,7 @@ const char* SPUse::displayName() { return _("Clone"); } -gchar* SPUse::description() { +gchar* SPUse::description() const { if (this->child) { if( SP_IS_SYMBOL( this->child ) ) { return g_strdup_printf(_("called %s"), this->child->title()); @@ -295,6 +295,10 @@ SPItem *SPUse::root() { return orig; } +SPItem const *SPUse::root() const { + return const_cast<SPUse*>(this)->root(); +} + /** * Returns the effective transform that goes from the ultimate original to given SPUse, both ends * included. @@ -652,8 +656,8 @@ SPItem *SPUse::get_original() { return ref; } -void SPUse::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) { - SPItem *root = this->root(); +void SPUse::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const { + SPItem const *root = this->root(); if (!root) { return; diff --git a/src/sp-use.h b/src/sp-use.h index 6a83c384f..31a52c1a1 100644 --- a/src/sp-use.h +++ b/src/sp-use.h @@ -56,15 +56,16 @@ public: virtual void update(SPCtx* ctx, unsigned int flags); virtual void modified(unsigned int flags); - virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype); - virtual const char* displayName(); - virtual gchar* description(); + virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) const; + virtual const char* displayName() const; + virtual gchar* description() const; virtual void print(SPPrintContext *ctx); virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void hide(unsigned int key); - virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); + virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const; SPItem *root(); + SPItem const *root() const; SPItem *unlink(); SPItem *get_original(); diff --git a/src/svg/svg-length.cpp b/src/svg/svg-length.cpp index 6f1a88a58..b9e8e6340 100644 --- a/src/svg/svg-length.cpp +++ b/src/svg/svg-length.cpp @@ -65,6 +65,7 @@ unsigned int sp_svg_number_read_d(gchar const *str, double *val) } // TODO must add a buffer length parameter for safety: +// rewrite using std::string? static unsigned int sp_svg_number_write_ui(gchar *buf, unsigned int val) { unsigned int i = 0; @@ -81,6 +82,7 @@ static unsigned int sp_svg_number_write_ui(gchar *buf, unsigned int val) } // TODO unsafe code ingnoring bufLen +// rewrite using std::string? static unsigned int sp_svg_number_write_i(gchar *buf, int bufLen, int val) { int p = 0; @@ -98,6 +100,7 @@ static unsigned int sp_svg_number_write_i(gchar *buf, int bufLen, int val) } // TODO unsafe code ingnoring bufLen +// rewrite using std::string? static unsigned sp_svg_number_write_d(gchar *buf, int bufLen, double val, unsigned int tprec, unsigned int fprec) { /* Process sign */ diff --git a/src/text-editing.cpp b/src/text-editing.cpp index cf1c4811f..cae123616 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -1558,7 +1558,7 @@ static SPObject* ascend_while_first(SPObject *item, Glib::ustring::iterator text /** empty spans: abc<span></span>def -> abcdef */ -static bool tidy_operator_empty_spans(SPObject **item, bool has_text_decoration) +static bool tidy_operator_empty_spans(SPObject **item, bool /*has_text_decoration*/) { bool result = false; if ( !(*item)->hasChildren() @@ -1576,7 +1576,7 @@ static bool tidy_operator_empty_spans(SPObject **item, bool has_text_decoration) /** inexplicable spans: abc<span style="">def</span>ghi -> "abc""def""ghi" the repeated strings will be merged by another operator. */ -static bool tidy_operator_inexplicable_spans(SPObject **item, bool has_text_decoration) +static bool tidy_operator_inexplicable_spans(SPObject **item, bool /*has_text_decoration*/) { //XML Tree being directly used here while it shouldn't be. if (*item && sp_repr_is_meta_element((*item)->getRepr())) { @@ -1611,7 +1611,7 @@ static bool tidy_operator_inexplicable_spans(SPObject **item, bool has_text_deco /** repeated spans: <font a>abc</font><font a>def</font> -> <font a>abcdef</font> */ -static bool tidy_operator_repeated_spans(SPObject **item, bool has_text_decoration) +static bool tidy_operator_repeated_spans(SPObject **item, bool /*has_text_decoration*/) { SPObject *first = *item; SPObject *second = first->getNext(); @@ -1657,7 +1657,7 @@ static bool tidy_operator_repeated_spans(SPObject **item, bool has_text_decorati -> <font b>abc</font> excessive nesting: <font a><size 1>abc</size></font> -> <font a,size 1>abc</font> */ -static bool tidy_operator_excessive_nesting(SPObject **item, bool has_text_decoration) +static bool tidy_operator_excessive_nesting(SPObject **item, bool /*has_text_decoration*/) { if (!(*item)->hasChildren()) { return false; @@ -1735,7 +1735,7 @@ example. You may note that this only does its work when the doubly-nested child is the first or last. The other cases are called 'style inversion' below, and I'm not yet convinced that the result of that operation will be tidier in all cases. */ -static bool tidy_operator_redundant_double_nesting(SPObject **item, bool has_text_decoration) +static bool tidy_operator_redundant_double_nesting(SPObject **item, bool /*has_text_decoration*/) { if (!(*item)->hasChildren()) return false; if ((*item)->firstChild() == (*item)->lastChild()) return false; // this is excessive nesting, done above @@ -1796,7 +1796,7 @@ static bool redundant_semi_nesting_processor(SPObject **item, SPObject *child, b -> <font b>abc</font><font>def</font> test this by applying a colour to a region, then a different colour to a partially-overlapping region. */ -static bool tidy_operator_redundant_semi_nesting(SPObject **item, bool has_text_decoration) +static bool tidy_operator_redundant_semi_nesting(SPObject **item, bool /*has_text_decoration*/) { if (!(*item)->hasChildren()) return false; if ((*item)->firstChild() == (*item)->lastChild()) return false; // this is redundant nesting, done above diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index a6019c55c..79fb953ac 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -173,7 +173,7 @@ DocumentProperties::DocumentProperties() signalDocumentReplaced().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDocumentReplaced)); signalActivateDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleActivateDesktop)); signalDeactiveDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDeactivateDesktop)); - + _rum_deflt._changed_connection.block(); _rum_deflt.getUnitMenu()->signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::onDocUnitChange)); } @@ -1437,8 +1437,9 @@ void DocumentProperties::update() _rcp_bord.setRgba32 (nv->bordercolor); _rcb_shad.setActive (nv->showpageshadow); - if (nv->doc_units) + if (nv->doc_units) { _rum_deflt.setUnit (nv->doc_units->abbr); + } double doc_w = sp_desktop_document(dt)->getRoot()->width.value; Glib::ustring doc_w_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->width.unit)->abbr; @@ -1643,18 +1644,23 @@ void DocumentProperties::onRemoveGrid() void DocumentProperties::onDocUnitChange() { SPDocument *doc = SP_ACTIVE_DOCUMENT; + // Don't execute when change is being undone + if (!DocumentUndo::getUndoSensitive(doc)) { + return; + } + // Don't execute when initializing widgets + if (_wr.isUpdating()) { + return; + } + + Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr(); Inkscape::Util::Unit const *old_doc_unit = unit_table.getUnit("px"); if(repr->attribute("inkscape:document-units")) { old_doc_unit = unit_table.getUnit(repr->attribute("inkscape:document-units")); } Inkscape::Util::Unit const *doc_unit = _rum_deflt.getUnit(); - - // Don't execute when change is being undone - if (!DocumentUndo::getUndoSensitive(doc)) { - return; - } - + // Set document unit Inkscape::SVGOStringStream os; os << doc_unit->abbr; diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index ff527434e..cc7bbb277 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -421,7 +421,7 @@ void PixelArtDialogImpl::processLibdepixelize(SPImage *img) sp_repr_css_attr_unref(css); } - gchar *str = sp_svg_write_path(move(it->pathVector)); + gchar *str = sp_svg_write_path(Dialog::move(it->pathVector)); repr->setAttribute("d", str); g_free(str); diff --git a/src/winmain.cpp b/src/winmain.cpp index 752ab8e6b..607660740 100644 --- a/src/winmain.cpp +++ b/src/winmain.cpp @@ -25,10 +25,10 @@ extern int main (int argc, char **argv); #endif int _stdcall -WinMain (struct HINSTANCE__ *hInstance, - struct HINSTANCE__ *hPrevInstance, - char *lpszCmdLine, - int nCmdShow) +WinMain (struct HINSTANCE__ */*hInstance*/, + struct HINSTANCE__ */*hPrevInstance*/, + char */*lpszCmdLine*/, + int /*nCmdShow*/) { if (fileno (stdout) != -1 && _get_osfhandle (fileno (stdout)) != -1) |
