find.cpp revision 0ce918f80fe50c422e3cb9918b5fb0c3b4613ab7
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould * Bryce W. Harrington <bryce@bryceharrington.org>
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould * Johan Engelen <goejendaagh@zonnet.nl>
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak * Jon A. Cruz <jon@joncruz.org>
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak * Abhishek Sharma
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak * Copyright (C) 2004-2006 Authors
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak * Released under GNU GPL. Read the file 'COPYING' for more information.
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak : UI::Widget::Panel("", "/dialogs/find", SP_VERB_DIALOG_FIND),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak entry_find(_("F_ind:"), _("Find objects by their content (exact or partial match)")),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak entry_replace(_("Re_place:"), _("Replace found objects with this value ")),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak check_scope_all(_("_All"), _("Search in all layers")),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak check_scope_layer(_("Current _layer"), _("Limit search to the current layer")),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak check_scope_selection(_("S_election"), _("Limit search to the current selection")),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak check_searchin_text(_("Te_xt"), _("Search in text objects")),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak check_searchin_property(_("_Properties"), _("Search in object properties, styles, attributes and IDs")),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak check_case_sensitive(_("Case sensiti_ve"), _("Match upper/lower case"), false),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak check_exact_match(_("E_xact match"), _("Match whole objects only"), false),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak check_include_hidden(_("Include _hidden"), _("Include hidden objects in search"), false),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak check_include_locked(_("Include loc_ked"), _("Include locked objects in search"), false),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak check_attributename(_("Attribute _Name"), _("Search attribute name"), false),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak check_attributevalue(_("Attribute _Value"), _("Search attribute value"), true),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak check_style(_("_Style"), _("Search style"), true),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak check_alltypes(_("All types"), _("Search all object types"), true),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak check_rects(_("Rectangles"), _("Search rectangles"), false),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak check_ellipses(_("Ellipses"), _("Search ellipses, arcs, circles"), false),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak check_stars(_("Stars"), _("Search stars and polygons"), false),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak check_spirals(_("Spirals"), _("Search spirals"), false),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak check_paths(_("Paths"), _("Search paths, lines, polylines"), false),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak check_texts(_("Texts"), _("Search text objects"), false),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak check_groups(_("Groups"), _("Search groups"), false),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak //TRANSLATORS: "Clones" is a noun indicating type of object to find
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak C_("Find dialog", "Clones"), _("Search clones"), false),
e7333a0a54c8d33b7397406dd76938aa430836d5joncruz check_images(_("Images"), _("Search images"), false),
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak check_offsets(_("Offsets"), _("Search offset objects"), false),
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould button_find(_("_Find"), _("Select all objects matching the selected fields ")),
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould button_replace(_("_Replace All"), _("Replace all the matching objects")),
068e269d6d0391bdf69963f651be776f3fcb4dd5gustav_b Gtk::RadioButtonGroup grp_searchin = check_searchin_text.get_group();
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak vbox_searchin.pack_start(check_searchin_text, true, true);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak vbox_searchin.pack_start(check_searchin_property, true, true);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak Gtk::RadioButtonGroup grp_scope = check_scope_all.get_group();
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak vbox_scope.pack_start(check_scope_all, true, true);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak vbox_scope.pack_start(check_scope_layer, true, true);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak vbox_scope.pack_start(check_scope_selection, true, true);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak hbox_searchin.pack_start(frame_searchin, true, true);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak hbox_searchin.pack_start(frame_scope, true, true);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak vbox_options1.pack_start(check_case_sensitive, true, true);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak vbox_options1.pack_start(check_include_hidden, true, true);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak vbox_options2.pack_start(check_exact_match, true, true);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak vbox_options2.pack_start(check_include_locked, true, true);
963f23115db07f460bdd862b957f8bd9dba88b9bgustav_b hbox_options.pack_start(vbox_options1, true, true, 4);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak hbox_options.pack_start(vbox_options2, true, true, 4);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak hbox_properties1.pack_start(check_ids, false, false, 4 );
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak hbox_properties1.pack_start(check_style, false, false, 8);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak hbox_properties1.pack_start(check_font, false, false, 8);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak hbox_properties2.pack_start(check_attributevalue, false, false, 4);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak hbox_properties2.pack_start(check_attributename, false, false, 4);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak vbox_properties.pack_start(hbox_properties1, true, true, 0);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak vbox_properties.pack_start(hbox_properties2, true, true, 2);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak vbox_types1.pack_start(check_alltypes, true, true);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak vbox_types2.pack_start(check_offsets, true, true);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak vbox_types2.pack_start(check_ellipses, true, true);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak vbox_types2.pack_start(check_spirals, true, true);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak hbox_types.pack_start(vbox_types1, true, true, 4);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak hbox_types.pack_start(vbox_types2, true, true, 4);
c57da20fee24a6e5b368730153d72eabe26425b2buliabyak vbox_expander.pack_start(frame_options, true, true, 4);
expander_options.property_expanded().signal_changed().connect(sigc::mem_fun(*this, &Find::onExpander));
desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &Find::setTargetDesktop) );
if (item) {
if (this->desktop) {
selectChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(*this, &Find::onSelectionChange)));
if (!blocked) {
Glib::ustring Find::find_replace(const gchar *str, const gchar *find, const gchar *replace, bool exact, bool casematch, bool replaceall)
if (!casematch) {
if (!replaceall) {
return ustr;
// Start the next search after the last replace character to avoid infinite loops (replace "a" with "aaa" etc)
return ustr;
gsize Find::find_strcmp_pos(const gchar *str, const gchar *find, bool exact, bool casematch, gsize start/*=0*/)
if (!casematch) {
if (exact) {
pos = 0;
return pos;
Find::item_text_match (SPItem *item, const gchar *find, bool exact, bool casematch, bool replace/*=false*/)
if (!casematch) {
if (!layout) {
return found;
return found;
Find::item_id_match (SPItem *item, const gchar *id, bool exact, bool casematch, bool replace/*=false*/)
return found;
Find::item_style_match (SPItem *item, const gchar *text, bool exact, bool casematch, bool replace/*=false*/)
Glib::ustring new_item_style = find_replace(item_style, text, replace_text , exact, casematch, true);
return found;
bool Find::item_attr_match(SPItem *item, const gchar *text, bool exact, bool /*casematch*/, bool replace/*=false*/)
bool found = false;
if (exact) {
found = false;
return found;
bool Find::item_attrvalue_match(SPItem *item, const gchar *text, bool exact, bool casematch, bool replace/*=false*/)
bool ret = false;
if (found) {
ret = true;
Glib::ustring new_item_style = find_replace(attr_value, text, replace_text , exact, casematch, true);
return ret;
bool Find::item_font_match(SPItem *item, const gchar *text, bool exact, bool casematch, bool /*replace*/ /*=false*/)
bool ret = false;
if (found) {
ret = true;
if (_action_replace) {
// Exact match fails since the "font-family:" is in the token, since the find was exact it still works with false below
Glib::ustring new_item_style = find_replace(orig_str, text, replace_text , false /*exact*/, casematch, true);
return ret;
GSList *
if (_action_replace) {
if (ids) {
if (_action_replace) {
if (style) {
if (_action_replace) {
if (attrname) {
if (_action_replace) {
if (attrvalue) {
if (_action_replace) {
if (font) {
if (_action_replace) {
return out;
} else if (SP_IS_GENERICELLIPSE(item) || SP_IS_ELLIPSE(item) || SP_IS_ARC(item) || SP_IS_CIRCLE(item)) {
GSList *
GSList *
l = filter_types (l);
GSList *
if (SP_IS_DEFS(r)) {
GSList *
Find::all_selection_items (Inkscape::Selection *s, GSList *l, SPObject *ancestor, bool hidden, bool locked)
if (SP_IS_ITEM (i->data) && !reinterpret_cast<SPItem *>(i->data)->cloned && !desktop->isLayer(SP_ITEM(i->data))) {
_action_replace = false;
onAction();
_action_replace = true;
onAction();
blocked = true;
if (n != NULL) {
count),
status.set_text(Glib::ustring::compose("%1 %2 %3", count, _("objects"), _action_replace? _("replaced") : _("found") ));
if (_action_replace) {
blocked = false;
bool objectok = false;
objectok = true;
objectok = true;
if (!objectok) {
bool propertyok = false;
propertyok = true;
propertyok = true;
if (!propertyok) {
searchinToggle(false);
searchinToggle(true);