1
////////////////////////////////////////////////////////////////////////////////
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
4
// (c) copyright 1997, Vrije Universiteit Amsterdam.
5
// Author: Frank Dehne (frank@cs.vu.nl).
7
// TCM is free software; you can redistribute it and/or modify
8
// it under the terms of the GNU General Public License as published by
9
// the Free Software Foundation; either version 2 of the License, or
10
// (at your option) any later version.
12
// TCM is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License for more details.
17
// You should have received a copy of the GNU General Public License
18
// along with TCM; if not, write to the Free Software
19
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21
////////////////////////////////////////////////////////////////////////////////
23
#include "shapeview.h"
25
#include "messagedialog.h"
26
#include "replacealltextscmd.h"
28
ReplaceAllTextsCmd::ReplaceAllTextsCmd(ShapeView *v, const string *p,
29
const string *o, bool c, bool s, bool n):
30
ReplaceTextCmd(v, p, o, c, s, n) {}
32
void ReplaceAllTextsCmd::Execute() {
36
if (*pattern == *replace) {
37
MessageDialog *d = new MessageDialog(
38
GetMainWindow()->GetWidget(), MessageDialog::ERROR);
40
"Replace all: find and replace text are identical");
41
GetMainWindow()->SetStatus(
42
"aborted: identical find and replace");
46
List<GShape *> shapes2(*view->GetShapes());
48
for (shapes2.first(); !shapes2.done(); shapes2.next()) {
50
Shape *shape = (Shape *)shapes2.cur();
52
if (shape->HasNameString(pattern, caseSensitive,
55
if (shape->IsTextShape())
56
ts = ((GShape *)shape)->GetName();
58
ts = (TextShape *)shape;
60
Point *pt = new Point(
61
shape->GetWidth(), shape->GetHeight());
63
const string *name = ts->GetString();
65
oldStrings->add(new string(copy));
66
if (!error && (substring || *pattern == copy)) {
67
r = copy.replace(*pattern, *replace,
78
List<TextShape *> tshapes;
79
if (shape->HasString(pattern, caseSensitive,
80
substring, &tshapes)) {
81
for (tshapes.first(); !tshapes.done();
83
TextShape *ts = tshapes.cur();
85
Point *pt = new Point(shape->GetWidth(),
89
string(*(ts->GetString())));
90
const string *name = ts->GetString();
92
if (!error & (substring ||
94
r = copy.replace(*pattern,
110
view->SelectShape(shapes2.cur());
114
MessageDialog *d = new MessageDialog(
115
GetMainWindow()->GetWidget(),
116
MessageDialog::WARNING);
117
d->SetCenteredOnPointer(False);
119
"Replace all is aborted after\n"
120
"the first encountered error");
123
GetMainWindow()->SetStatus("replace all: pattern not found");
125
string txt = "replace all: ";
127
txt += " shapes found, made ";
129
txt += " replacements";
130
GetDocument()->IncChanges();
132
GetMainWindow()->SetStatus(&txt);