~ubuntu-branches/ubuntu/maverick/freecad/maverick

« back to all changes in this revision

Viewing changes to src/App/Property.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Teemu Ikonen
  • Date: 2009-07-16 18:37:41 UTC
  • Revision ID: james.westby@ubuntu.com-20090716183741-oww9kcxqrk991i1n
Tags: upstream-0.8.2237
Import upstream version 0.8.2237

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (c) J�rgen Riegel          (juergen.riegel@web.de) 2002     *
 
3
 *                                                                         *
 
4
 *   This file is part of the FreeCAD CAx development system.              *
 
5
 *                                                                         *
 
6
 *   This library is free software; you can redistribute it and/or         *
 
7
 *   modify it under the terms of the GNU Library General Public           *
 
8
 *   License as published by the Free Software Foundation; either          *
 
9
 *   version 2 of the License, or (at your option) any later version.      *
 
10
 *                                                                         *
 
11
 *   This library  is distributed in the hope that it will be useful,      *
 
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
14
 *   GNU Library General Public License for more details.                  *
 
15
 *                                                                         *
 
16
 *   You should have received a copy of the GNU Library General Public     *
 
17
 *   License along with this library; see the file COPYING.LIB. If not,    *
 
18
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
 
19
 *   Suite 330, Boston, MA  02111-1307, USA                                *
 
20
 *                                                                         *
 
21
 ***************************************************************************/
 
22
 
 
23
 
 
24
#include "PreCompiled.h"
 
25
 
 
26
#ifndef _PreComp_
 
27
#       include <cassert>
 
28
#endif
 
29
 
 
30
/// Here the FreeCAD includes sorted by Base,App,Gui......
 
31
#include "Property.h"
 
32
#include "PropertyContainer.h"
 
33
 
 
34
using namespace App;
 
35
 
 
36
 
 
37
//**************************************************************************
 
38
//**************************************************************************
 
39
// Property
 
40
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
41
 
 
42
TYPESYSTEM_SOURCE_ABSTRACT(App::Property , Base::Persistence);
 
43
 
 
44
//**************************************************************************
 
45
// Construction/Destruction
 
46
 
 
47
// here the implemataion! description should take place in the header file!
 
48
Property::Property()
 
49
  :father(0)
 
50
{
 
51
 
 
52
}
 
53
 
 
54
Property::~Property()
 
55
{
 
56
 
 
57
}
 
58
 
 
59
const char* Property::getName(void) const
 
60
{
 
61
    return father->getName(this);
 
62
}
 
63
 
 
64
short Property::getType(void) const
 
65
{
 
66
    return father->getPropertyType(this);
 
67
}
 
68
 
 
69
const char* Property::getGroup(void) const
 
70
{
 
71
    return father->getPropertyGroup(this);
 
72
}
 
73
 
 
74
const char* Property::getDocumentation(void) const
 
75
{
 
76
    return father->getPropertyDocumentation(this);
 
77
}
 
78
 
 
79
void Property::setContainer(PropertyContainer *Father)
 
80
{
 
81
    father = Father;
 
82
}
 
83
 
 
84
void Property::touch()
 
85
{
 
86
    if (father)
 
87
        father->onChanged(this);
 
88
    StatusBits.set(0);
 
89
}
 
90
 
 
91
void Property::hasSetValue(void)
 
92
{
 
93
    if (father)
 
94
        father->onChanged(this);
 
95
    StatusBits.set(0);
 
96
}
 
97
 
 
98
void Property::aboutToSetValue(void)
 
99
{
 
100
    if (father)
 
101
        father->onBeforeChange(this);
 
102
}
 
103
 
 
104
Property *Property::Copy(void) const 
 
105
{
 
106
    // have to be reimplemented by a subclass!
 
107
    assert(0);
 
108
    return 0;
 
109
}
 
110
 
 
111
void Property::Paste(const Property& /*from*/)
 
112
{
 
113
    // have to be reimplemented by a subclass!
 
114
    assert(0);
 
115
}
 
116
 
 
117
std::string Property::encodeAttribute(const std::string& str) const
 
118
{
 
119
    std::string tmp;
 
120
    for (std::string::const_iterator it = str.begin(); it != str.end(); ++it) {
 
121
        if (*it == '<')
 
122
            tmp += "&lt;";
 
123
        else if (*it == '"')
 
124
            tmp += "&quot;";
 
125
        else if (*it == '&')
 
126
            tmp += "&amp;";
 
127
        else if (*it == '>')
 
128
            tmp += "&gt";
 
129
        else if (*it == '\n')
 
130
            tmp += " ";
 
131
        else
 
132
            tmp += *it;
 
133
    }
 
134
 
 
135
    return tmp;
 
136
}
 
137
 
 
138
//**************************************************************************
 
139
//**************************************************************************
 
140
// PropertyLists
 
141
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
142
 
 
143
TYPESYSTEM_SOURCE_ABSTRACT(App::PropertyLists , App::Property);