1 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */ 2 3 /* AbiWord 4 * Copyright (C) 1998-2000 AbiSource, Inc. 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * 11 * This program 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 General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 * 02110-1301 USA. 20 */ 21 22 23 24 #ifndef PP_PROPERTY_H 25 #define PP_PROPERTY_H 26 27 // make sure we don't get caught in a BASEDON loop 28 #define pp_BASEDON_DEPTH_LIMIT 10 29 30 #include "ut_types.h" 31 #include "ut_misc.h" 32 #include "ut_units.h" 33 34 #include "pp_PropertyMap.h" 35 36 class PP_AttrProp; 37 class PD_Document; 38 39 // PP_Property captures knowledge of the various CSS properties, 40 // such as their initial/default values and whether they are 41 // inherited. 42 43 typedef enum { 44 Property_type_bool, 45 Property_type_int, 46 Property_type_size, 47 Property_type_color 48 } tProperty_type; 49 50 51 class ABI_EXPORT PP_PropertyType 52 { 53 public: PP_PropertyType()54 PP_PropertyType() {}; ~PP_PropertyType()55 virtual ~PP_PropertyType() {}; 56 57 public: 58 virtual tProperty_type getType() const = 0; 59 60 static PP_PropertyType *createPropertyType(tProperty_type Type, const gchar *p_init); 61 }; 62 63 class ABI_EXPORT PP_PropertyTypeBool : public PP_PropertyType 64 { 65 66 public: 67 PP_PropertyTypeBool(const gchar *p_init); 68 getType()69 tProperty_type getType() const {return Property_type_bool;} 70 getState()71 bool getState() const {return State;} 72 73 74 private: 75 76 bool State; 77 }; 78 79 class ABI_EXPORT PP_PropertyTypeInt : public PP_PropertyType 80 { 81 82 public: 83 PP_PropertyTypeInt(const gchar *p_init); 84 getType()85 tProperty_type getType() const {return Property_type_int;} 86 getValue()87 int getValue() const {return Value;} 88 89 90 private: 91 92 int Value; 93 }; 94 95 class ABI_EXPORT PP_PropertyTypeSize : public PP_PropertyType 96 { 97 98 public: 99 PP_PropertyTypeSize(const gchar *p_init); 100 getType()101 tProperty_type getType() const {return Property_type_size;} 102 getValue()103 double getValue() const {return Value;} getDim()104 UT_Dimension getDim() const {return Dim;} 105 106 107 private: 108 109 double Value; 110 UT_Dimension Dim; 111 }; 112 113 class ABI_EXPORT PP_PropertyTypeColor : public PP_PropertyType 114 { 115 116 public: 117 PP_PropertyTypeColor(const gchar *p_init); 118 getType()119 tProperty_type getType() const {return Property_type_color;} 120 getColor()121 const UT_RGBColor &getColor() const {return Color;} 122 123 124 private: 125 126 UT_RGBColor Color; 127 }; 128 129 130 131 typedef unsigned int tPropLevel; 132 133 // the m_iLevel member of PP_Property should be set by or-ing the 134 // following constants 135 #define PP_LEVEL_CHAR 0x00000001 136 #define PP_LEVEL_BLOCK 0x00000002 137 #define PP_LEVEL_SECT 0x00000004 138 #define PP_LEVEL_DOC 0x00000008 139 #define PP_LEVEL_TABLE 0x00000010 140 #define PP_LEVEL_OBJ 0x00000020 141 #define PP_LEVEL_IMG 0x00000040 142 #define PP_LEVEL_FIELD 0x00000080 143 #define PP_LEVEL_FRAME 0x00000100 144 145 class ABI_EXPORT PP_Property 146 { 147 public: 148 const gchar * m_pszName; 149 const gchar * m_pszInitial; 150 bool m_bInherit; 151 PP_PropertyType * m_pProperty; 152 tPropLevel m_iLevel; 153 ~PP_Property(); 154 getName()155 inline const gchar * getName() const {return m_pszName;} getInitial()156 inline const gchar * getInitial() const {return m_pszInitial;} 157 const PP_PropertyType * getInitialType (tProperty_type Type) const; canInherit()158 inline bool canInherit() const {return m_bInherit;} getLevel()159 inline tPropLevel getLevel() const {return m_iLevel;} 160 }; 161 162 ABI_EXPORT const PP_Property * PP_lookupProperty(const gchar * pszName); 163 164 ABI_EXPORT void PP_resetInitialBiDiValues(const gchar * pszValue); 165 166 ABI_EXPORT void PP_setDefaultFontFamily(const char* pszFamily); 167 168 ABI_EXPORT const gchar * PP_evalProperty(const gchar * pszName, 169 const PP_AttrProp * pSpanAttrProp, 170 const PP_AttrProp * pBlockAttrProp, 171 const PP_AttrProp * pSectionAttrProp, 172 const PD_Document * pDoc, 173 bool bExpandStyles=false); 174 175 176 ABI_EXPORT const PP_PropertyType * PP_evalPropertyType(const gchar * pszName, 177 const PP_AttrProp * pSpanAttrProp, 178 const PP_AttrProp * pBlockAttrProp, 179 const PP_AttrProp * pSectionAttrProp, 180 tProperty_type Type, 181 const PD_Document * pDoc=NULL, 182 bool bExpandStyles=false); 183 184 ABI_EXPORT UT_uint32 PP_getPropertyCount(); 185 ABI_EXPORT const gchar * PP_getNthPropertyName(UT_uint32 n); 186 ABI_EXPORT tPropLevel PP_getNthPropertyLevel(UT_uint32 n); 187 #endif /* PP_PROPERTY_H */ 188