diff options
Diffstat (limited to 'src')
49 files changed, 196 insertions, 183 deletions
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/marker.cpp b/src/marker.cpp index 50e7c970f..b38138f8c 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -503,7 +503,7 @@ 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(); } 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/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..0331df312 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) 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-image.cpp b/src/sp-image.cpp index 86668d9ed..1032b6d93 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) { @@ -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..d32fbdef6 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); } @@ -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. @@ -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()); } /** @@ -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-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 b327f0b83..af3e2bfb4 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -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-shape.cpp b/src/sp-shape.cpp index 913e208aa..3cc7ea1ce 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) { @@ -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..911357660 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -71,11 +71,11 @@ 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); 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..11d0e1a6c 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 @@ -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(); |
