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"
24
#include "diagramviewer.h"
26
#include "replacetextcmd.h"
28
ReplaceTextCmd::ReplaceTextCmd(ShapeView *v, const string *p, const string *o,
29
bool c, bool s, bool n):
30
Command(v->GetViewer()->GetDiagram(), v->GetViewer()) {
32
diagram = v->GetViewer()->GetDiagram();
33
pattern = new string(*p);
34
replace = new string(*o);
38
oldSelection = new List<GShape *> (*view->GetSelection());
39
textShapes = new List<TextShape *>;
40
oldStrings = new List<string *>;
41
oldSizes = new List<Point *>;
44
ReplaceTextCmd::~ReplaceTextCmd() {
55
void ReplaceTextCmd::UnExecute() {
56
for (unsigned i=0; i<textShapes->count(); i++) {
57
TextShape *s = (*textShapes)[i];
58
if (diagram->SetText(s, ((*oldStrings)[i]))) {
59
if (GetViewer()->IsAutoResize()) {
60
GShape *parent = (GShape *)s->GetParent();
61
int oldWidth = (*oldSizes)[i]->x;
62
int oldHeight = (*oldSizes)[i]->y;
63
if (parent->GetWidth() != oldWidth ||
64
parent->GetHeight() != oldHeight) {
65
parent->UpdateSize(oldWidth, oldHeight);
67
ShapePositionUpdate(parent);
73
for (oldSelection->first(); !oldSelection->done(); oldSelection->next())
75
GShape *shape = oldSelection->cur();
76
view->SelectShape(shape);
81
void ReplaceTextCmd::ReExecute() {