00001 /*************************************************************************** 00002 * Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2002 * 00003 * * 00004 * This file is part of the FreeCAD CAx development system. * 00005 * * 00006 * This library is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Library General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00014 * GNU Library General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Library General Public * 00017 * License along with this library; see the file COPYING.LIB. If not, * 00018 * write to the Free Software Foundation, Inc., 59 Temple Place, * 00019 * Suite 330, Boston, MA 02111-1307, USA * 00020 * * 00021 ***************************************************************************/ 00022 00023 00024 #include "PreCompiled.h" 00025 00026 #ifndef _PreComp_ 00027 # include <cassert> 00028 #endif 00029 00031 #include "Property.h" 00032 #include "PropertyContainer.h" 00033 00034 using namespace App; 00035 00036 00037 //************************************************************************** 00038 //************************************************************************** 00039 // Property 00040 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00041 00042 TYPESYSTEM_SOURCE_ABSTRACT(App::Property , Base::Persistence); 00043 00044 //************************************************************************** 00045 // Construction/Destruction 00046 00047 // here the implemataion! description should take place in the header file! 00048 Property::Property() 00049 :father(0) 00050 { 00051 00052 } 00053 00054 Property::~Property() 00055 { 00056 00057 } 00058 00059 const char* Property::getName(void) const 00060 { 00061 return father->getName(this); 00062 } 00063 00064 short Property::getType(void) const 00065 { 00066 return father->getPropertyType(this); 00067 } 00068 00069 const char* Property::getGroup(void) const 00070 { 00071 return father->getPropertyGroup(this); 00072 } 00073 00074 const char* Property::getDocumentation(void) const 00075 { 00076 return father->getPropertyDocumentation(this); 00077 } 00078 00079 void Property::setContainer(PropertyContainer *Father) 00080 { 00081 father = Father; 00082 } 00083 00084 void Property::touch() 00085 { 00086 if (father) 00087 father->onChanged(this); 00088 StatusBits.set(0); 00089 } 00090 00091 void Property::hasSetValue(void) 00092 { 00093 if (father) 00094 father->onChanged(this); 00095 StatusBits.set(0); 00096 } 00097 00098 void Property::aboutToSetValue(void) 00099 { 00100 if (father) 00101 father->onBeforeChange(this); 00102 } 00103 00104 Property *Property::Copy(void) const 00105 { 00106 // have to be reimplemented by a subclass! 00107 assert(0); 00108 return 0; 00109 } 00110 00111 void Property::Paste(const Property& /*from*/) 00112 { 00113 // have to be reimplemented by a subclass! 00114 assert(0); 00115 } 00116 00117 std::string Property::encodeAttribute(const std::string& str) const 00118 { 00119 std::string tmp; 00120 for (std::string::const_iterator it = str.begin(); it != str.end(); ++it) { 00121 if (*it == '<') 00122 tmp += "<"; 00123 else if (*it == '"') 00124 tmp += """; 00125 else if (*it == '&') 00126 tmp += "&"; 00127 else if (*it == '>') 00128 tmp += ">"; 00129 else if (*it == '\n') 00130 tmp += " "; 00131 else 00132 tmp += *it; 00133 } 00134 00135 return tmp; 00136 } 00137 00138 //************************************************************************** 00139 //************************************************************************** 00140 // PropertyLists 00141 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00142 00143 TYPESYSTEM_SOURCE_ABSTRACT(App::PropertyLists , App::Property);