-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResizeCommand.cpp
More file actions
executable file
·75 lines (67 loc) · 1.9 KB
/
ResizeCommand.cpp
File metadata and controls
executable file
·75 lines (67 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//------------------------------------------------------------------------------
/// Filename: ResizeCommand.cpp
/// Description: Base Class for ResizeCommands
/// Authors:
/// Ralph Ankele(0931953)
/// Tutor: Manuel Weber
/// Group: 24
/// Created: 08.09.2011
/// Last change: 08.09.2011
//------------------------------------------------------------------------------
#include "ResizeCommand.h"
#include "UserInterface.h"
#include "Database.h"
#include "Error.h"
//------------------------------------------------------------------------------
ResizeCommand::ResizeCommand(UserInterface *ui,
Database *db): Command(ui,db)
{
name_.assign("resize");
error_ = new Error();
}
//------------------------------------------------------------------------------
ResizeCommand::~ResizeCommand() throw()
{
delete error_;
}
//------------------------------------------------------------------------------
bool ResizeCommand::execute()
{
signed int int_value, group_id;
std::string id, str_value;
size_t found;
while(true)
{
if(!ui_->getParam(" id? ", false, true, int_value, id, false))
return false;
if(ui_->checkID(id))
{
if(ui_->checkIfIdExists(id))
break;
error_->idDoesnotExist();
}
}
found = id.find("gr-");
if(found != std::string::npos)
{
str_value = id.substr(found+3);
if(!ui_->stringToSignedInt(str_value,group_id))
return false;
for(std::vector<SVGObject*>::iterator it =
db_->getSVGObjectByGrp(group_id).begin();
it != db_->getSVGObjectByGrp(group_id).end(); ++it)
{
if(!(*it)->resize())
return false;
}
}
else
{
signed int id_int;
if(!ui_->stringToSignedInt(id, id_int))
return false;
if(!db_->getSVGObjectByID(id_int)->resize())
return false;
}
return true;
}