From 880bb64898f3a368057fb91517a0fff70f7faae7 Mon Sep 17 00:00:00 2001 From: mental Date: Mon, 7 Jul 2008 16:35:28 +0000 Subject: [PATCH] try to use consistent document for creating guides --- src/box3d.cpp | 4 +--- src/sp-guide.cpp | 14 ++++++++------ src/sp-guide.h | 4 ++-- src/sp-item.cpp | 2 +- src/sp-path.cpp | 3 +-- src/sp-rect.cpp | 6 ++---- src/verbs.cpp | 2 +- 7 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/box3d.cpp b/src/box3d.cpp index f0bf4647d..cda482e73 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -1421,8 +1421,6 @@ box3d_convert_to_guides(SPItem *item) { return; } - SPDocument *doc = SP_OBJECT_DOCUMENT(box); - std::list > pts; /* perspective lines in X direction */ @@ -1443,7 +1441,7 @@ box3d_convert_to_guides(SPItem *item) { box3d_push_back_corner_pair(box, pts, 2, 6); box3d_push_back_corner_pair(box, pts, 3, 7); - sp_guide_pt_pairs_to_guides(doc, pts); + sp_guide_pt_pairs_to_guides(inkscape_active_desktop(), pts); } /* diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 2f91a17cf..5375bc442 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -22,6 +22,7 @@ #include #include #include +#include "desktop-handles.h" #include "display/guideline.h" #include "svg/svg.h" #include "svg/stringstream.h" @@ -241,8 +242,8 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value) } SPGuide * -sp_guide_create(SPDocument *doc, Geom::Point const &pt1, Geom::Point const &pt2) { - SPDesktop *desktop = inkscape_active_desktop(); +sp_guide_create(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2) { + SPDocument *doc=sp_desktop_document(desktop); Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); Inkscape::XML::Node *repr = xml_doc->createElement("sodipodi:guide"); @@ -260,14 +261,15 @@ sp_guide_create(SPDocument *doc, Geom::Point const &pt1, Geom::Point const &pt2) } void -sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list > &pts) { +sp_guide_pt_pairs_to_guides(SPDesktop *dt, std::list > &pts) { for (std::list >::iterator i = pts.begin(); i != pts.end(); ++i) { - sp_guide_create(doc, (*i).first, (*i).second); + sp_guide_create(dt, (*i).first, (*i).second); } } void -sp_guide_create_guides_around_page(SPDocument *doc) { +sp_guide_create_guides_around_page(SPDesktop *dt) { + SPDocument *doc=sp_desktop_document(dt); std::list > pts; Geom::Point A(0, 0); @@ -280,7 +282,7 @@ sp_guide_create_guides_around_page(SPDocument *doc) { pts.push_back(std::make_pair(C, D)); pts.push_back(std::make_pair(D, A)); - sp_guide_pt_pairs_to_guides(doc, pts); + sp_guide_pt_pairs_to_guides(dt, pts); sp_document_done (doc, SP_VERB_NONE, _("Guides around page")); } diff --git a/src/sp-guide.h b/src/sp-guide.h index 502cf2c5b..78c795f83 100644 --- a/src/sp-guide.h +++ b/src/sp-guide.h @@ -46,8 +46,8 @@ struct SPGuideClass { GType sp_guide_get_type(); SPGuide *sp_guide_create(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2); -void sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list > &pts); -void sp_guide_create_guides_around_page(SPDocument *doc); +void sp_guide_pt_pairs_to_guides(SPDesktop *dt, std::list > &pts); +void sp_guide_create_guides_around_page(SPDesktop *dt); void sp_guide_show(SPGuide *guide, SPCanvasGroup *group, GCallback handler); void sp_guide_hide(SPGuide *guide, SPCanvas *canvas); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 33f140de2..81e75ad7c 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -1701,7 +1701,7 @@ sp_item_convert_to_guides(SPItem *item) { pts.push_back(std::make_pair(C.to_2geom(), D.to_2geom())); pts.push_back(std::make_pair(D.to_2geom(), A.to_2geom())); - sp_guide_pt_pairs_to_guides(SP_OBJECT_DOCUMENT(item), pts); + sp_guide_pt_pairs_to_guides(dt, pts); } /* diff --git a/src/sp-path.cpp b/src/sp-path.cpp index 8327cb88d..47d63b2b9 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -166,8 +166,7 @@ sp_path_convert_to_guides(SPItem *item) } } - SPDocument *doc = SP_OBJECT_DOCUMENT(path); - sp_guide_pt_pairs_to_guides(doc, pts); + sp_guide_pt_pairs_to_guides(inkscape_active_desktop(), pts); } /** diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index 7d3cd1c0c..e5ffa8b39 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -22,6 +22,7 @@ #include #include +#include "inkscape.h" #include "document.h" #include "attributes.h" #include "style.h" @@ -110,8 +111,6 @@ sp_rect_init(SPRect */*rect*/) static void sp_rect_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - SPRect *rect = SP_RECT(object); - if (((SPObjectClass *) parent_class)->build) ((SPObjectClass *) parent_class)->build(object, document, repr); @@ -578,7 +577,6 @@ sp_rect_convert_to_guides(SPItem *item) { return; } - SPDocument *doc = SP_OBJECT_DOCUMENT(rect); std::list > pts; NR::Matrix const i2d (from_2geom(sp_item_i2d_affine(SP_ITEM(rect)))); @@ -593,7 +591,7 @@ sp_rect_convert_to_guides(SPItem *item) { pts.push_back(std::make_pair(A3.to_2geom(), A4.to_2geom())); pts.push_back(std::make_pair(A4.to_2geom(), A1.to_2geom())); - sp_guide_pt_pairs_to_guides(doc, pts); + sp_guide_pt_pairs_to_guides(inkscape_active_desktop(), pts); } /* diff --git a/src/verbs.cpp b/src/verbs.cpp index b92eb52c0..73612557c 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -977,7 +977,7 @@ EditVerb::perform(SPAction *action, void *data, void */*pdata*/) break; case SP_VERB_EDIT_GUIDES_AROUND_PAGE: - sp_guide_create_guides_around_page(sp_desktop_document(dt)); + sp_guide_create_guides_around_page(dt); break; case SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER: -- 2.30.2