/*
* Authors:
* Bryce W. Harrington <bryce@bryceharrington.org>
* Johan Engelen <goejendaagh@zonnet.nl>
* Jon A. Cruz <jon@joncruz.org>
* Abhishek Sharma
*
* Copyright (C) 2004-2006 Authors
*
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "find.h"
#include "verbs.h"
#include "message-stack.h"
#include "macros.h"
#include "inkscape.h"
#include "desktop.h"
#include "document.h"
#include "document-undo.h"
#include "selection.h"
#include "ui/dialog-events.h"
#include "verbs.h"
#include "ui/interface.h"
#include "preferences.h"
#include "sp-text.h"
#include "sp-flowtext.h"
#include "sp-flowdiv.h"
#include "text-editing.h"
#include "sp-tspan.h"
#include "sp-tref.h"
#include "selection-chemistry.h"
#include "sp-defs.h"
#include "sp-rect.h"
#include "sp-ellipse.h"
#include "sp-star.h"
#include "sp-spiral.h"
#include "sp-path.h"
#include "sp-line.h"
#include "sp-polyline.h"
#include "sp-item-group.h"
#include "sp-use.h"
#include "sp-image.h"
#include "sp-offset.h"
#include "sp-root.h"
#include "xml/node-iterators.h"
#include "xml/attribute-record.h"
namespace Inkscape {
namespace UI {
namespace Dialog {
check_searchin_property(_("_Properties"), _("Search in object properties, styles, attributes and IDs")),
vbox_searchin(0, false),
frame_searchin(_("Search in")),
frame_scope(_("Scope")),
expander_options(_("Options")),
frame_options(_("General")),
frame_properties(_("Properties")),
//TRANSLATORS: "Clones" is a noun indicating type of object to find
frame_types(_("Object types")),
status(""),
_action_replace(false),
blocked(false),
{
hbox_properties1.set_homogeneous(false);
hbox_properties2.set_homogeneous(false);
// set signals to handle clicks
expander_options.property_expanded().signal_changed().connect(sigc::mem_fun(*this, &Find::onExpander));
}
}
desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &Find::setTargetDesktop) );
if (item) {
}
}
//button_find.grab_default(); // activatable by Enter
}
{
}
{
}
{
if (this->desktop) {
}
selectChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(*this, &Find::onSelectionChange)));
}
}
}
{
if (!blocked) {
}
}
/*########################################################################
# FIND helper functions
########################################################################*/
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;
}
} else {
}
return pos;
}
{
}
bool Find::item_text_match (SPItem *item, const gchar *find, bool exact, bool casematch, bool replace/*=false*/)
{
return false;
}
return false;
}
if (!casematch) {
}
if (!layout) {
return found;
}
}
}
return found;
}
return false;
}
bool Find::item_id_match (SPItem *item, const gchar *id, bool exact, bool casematch, bool replace/*=false*/)
{
return false;
}
if (dynamic_cast<SPString *>(item)) { // SPStrings have "on demand" ids which are useless for searching
return false;
}
return false;
}
if (new_item_style != item_id) {
}
}
return found;
}
bool Find::item_style_match (SPItem *item, const gchar *text, bool exact, bool casematch, bool replace/*=false*/)
{
return false;
}
if (item_style == NULL) {
return false;
}
Glib::ustring new_item_style = find_replace(item_style, text, replace_text , exact, casematch, true);
if (new_item_style != item_style) {
}
}
return found;
}
bool Find::item_attr_match(SPItem *item, const gchar *text, bool exact, bool /*casematch*/, bool replace/*=false*/)
{
bool found = false;
return false;
}
if (exact) {
} else {
}
// TODO - Rename attribute name ?
found = false;
}
return found;
}
bool Find::item_attrvalue_match(SPItem *item, const gchar *text, bool exact, bool casematch, bool replace/*=false*/)
{
bool ret = false;
return false;
}
if (found) {
ret = true;
}
Glib::ustring new_item_style = find_replace(attr_value, text, replace_text , exact, casematch, true);
if (new_item_style != attr_value) {
}
}
}
return ret;
}
bool Find::item_font_match(SPItem *item, const gchar *text, bool exact, bool casematch, bool /*replace*/ /*=false*/)
{
bool ret = false;
return false;
}
if (item_style == NULL) {
return 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);
if (new_item_style != orig_str) {
}
}
}
}
}
}
if (ret && _action_replace) {
}
}
return ret;
}
{
return l;
}
if (check_searchin_text.get_active()) {
if (_action_replace) {
}
}
}
}
}
else if (check_searchin_property.get_active()) {
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 (dynamic_cast<SPGenericEllipse *>(item)) {
} else if (dynamic_cast<SPPath *>(item) || dynamic_cast<SPLine *>(item) || dynamic_cast<SPPolyLine *>(item)) {
}
return false;
}
{
if (item_type_match(item)) {
n.push_back(*i);
}
}
return n;
}
{
l = filter_types (l);
return l;
}
std::vector<SPItem*> &Find::all_items (SPObject *r, std::vector<SPItem*> &l, bool hidden, bool locked)
{
if (dynamic_cast<SPDefs *>(r)) {
return l; // we're not interested in items in defs
}
return l; // we're not interested in metadata
}
}
}
}
return l;
}
std::vector<SPItem*> &Find::all_selection_items (Inkscape::Selection *s, std::vector<SPItem*> &l, SPObject *ancestor, bool hidden, bool locked)
{
l.push_back(*i);
}
}
}
}
}
return l;
}
/*########################################################################
# BUTTON CLICK HANDLERS (callbacks)
########################################################################*/
{
_action_replace = false;
onAction();
// Return focus to the find entry
}
{
return;
}
_action_replace = true;
onAction();
// Return focus to the find entry
}
{
blocked = true;
if (check_scope_selection.get_active()) {
if (check_scope_layer.get_active()) {
} else {
}
} else {
if (check_scope_layer.get_active()) {
} else {
}
}
if (!n.empty()) {
// TRANSLATORS: "%s" is replaced with "exact" or "partial" when this string is displayed
ngettext("<b>%d</b> object found (out of <b>%d</b>), %s match.",
"<b>%d</b> objects found (out of <b>%d</b>), %s match.",
count),
if (_action_replace){
// TRANSLATORS: "%1" is replaced with the number of matches
status.set_text(Glib::ustring::compose(ngettext("%1 match replaced","%1 matches replaced",count), count));
}
else {
// TRANSLATORS: "%1" is replaced with the number of matches
status.set_text(Glib::ustring::compose(ngettext("%1 object found","%1 objects found",count), count));
}
if (_action_replace) {
}
} else {
if (!check_scope_selection.get_active()) {
}
}
blocked = false;
}
{
bool objectok = false;
if (check_alltypes.get_active()) {
objectok = true;
}
for(int i = 0; i < 11; i++) {
if (checkTypes[i]->get_active()) {
objectok = true;
}
}
if (!objectok) {
}
bool propertyok = false;
if (!check_searchin_property.get_active()) {
propertyok = true;
} else {
if (checkProperties[i]->get_active()) {
propertyok = true;
}
}
}
if (!propertyok) {
}
// Can't replace attribute names
// bool attributenameyok = !check_attributename.get_active();
// button_replace.set_sensitive(objectok && propertyok && attributenameyok);
button_replace.set_sensitive(false);
}
{
}
}
{
searchinToggle(false);
}
{
searchinToggle(true);
}
{
}
}
{
if (!expander_options.get_expanded())
}
/*########################################################################
# UTILITY
########################################################################*/
{
// TODO: resize dialog window when the expander is closed
// set_size_request(-1, -1);
}
} // namespace Dialog
} // namespace UI
} // namespace Inkscape
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :