• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

pp_Property.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 
00003 /* AbiWord
00004  * Copyright (C) 1998-2000 AbiSource, Inc.
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program 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 General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00019  * 02111-1307, USA.
00020  */
00021 
00022 
00023 
00024 #ifndef PP_PROPERTY_H
00025 #define PP_PROPERTY_H
00026 
00027 // make sure we don't get caught in a BASEDON loop
00028 #define pp_BASEDON_DEPTH_LIMIT  10
00029 
00030 #include "ut_types.h"
00031 #include "ut_misc.h"
00032 #include "ut_units.h"
00033 
00034 #include "pp_PropertyMap.h"
00035 
00036 class PP_AttrProp;
00037 class PD_Document;
00038 
00039 // PP_Property captures knowledge of the various CSS properties,
00040 // such as their initial/default values and whether they are
00041 // inherited.
00042 
00043 typedef enum {
00044     Property_type_bool,
00045     Property_type_int,
00046     Property_type_size,
00047     Property_type_color
00048     } tProperty_type;
00049 
00050 
00051 class ABI_EXPORT PP_PropertyType
00052 {
00053 public:
00054     PP_PropertyType() {};
00055     virtual ~PP_PropertyType() {};
00056 
00057 public:
00058     virtual tProperty_type getType() const = 0;
00059 
00060     static PP_PropertyType *createPropertyType(tProperty_type Type, const gchar *p_init);
00061 };
00062 
00063 class ABI_EXPORT PP_PropertyTypeBool : public PP_PropertyType
00064 {
00065 
00066 public:
00067     PP_PropertyTypeBool(const gchar *p_init);
00068 
00069     tProperty_type getType() const {return Property_type_bool;}
00070 
00071     bool getState() const {return State;}
00072 
00073 
00074 private:
00075 
00076     bool State;
00077 };
00078 
00079 class ABI_EXPORT PP_PropertyTypeInt : public PP_PropertyType
00080 {
00081 
00082 public:
00083     PP_PropertyTypeInt(const gchar *p_init);
00084 
00085     tProperty_type getType() const {return Property_type_int;}
00086 
00087     int getValue() const {return Value;}
00088 
00089 
00090 private:
00091 
00092     int Value;
00093 };
00094 
00095 class ABI_EXPORT PP_PropertyTypeSize : public PP_PropertyType
00096 {
00097 
00098 public:
00099     PP_PropertyTypeSize(const gchar *p_init);
00100 
00101     tProperty_type getType() const {return Property_type_size;}
00102 
00103     double getValue() const {return Value;}
00104     UT_Dimension getDim() const {return Dim;}
00105 
00106 
00107 private:
00108 
00109     double Value;
00110     UT_Dimension Dim;
00111 };
00112 
00113 class ABI_EXPORT PP_PropertyTypeColor : public PP_PropertyType
00114 {
00115 
00116 public:
00117     PP_PropertyTypeColor(const gchar *p_init);
00118 
00119     tProperty_type getType() const {return Property_type_color;}
00120 
00121     const UT_RGBColor &getColor() const {return Color;}
00122 
00123 
00124 private:
00125 
00126     UT_RGBColor Color;
00127 };
00128 
00129 
00130 
00131 typedef unsigned int tPropLevel;
00132 
00133 // the m_iLevel member of PP_Property should be set by or-ing the
00134 // following constants
00135 #define PP_LEVEL_CHAR  0x00000001
00136 #define PP_LEVEL_BLOCK 0x00000002
00137 #define PP_LEVEL_SECT  0x00000004
00138 #define PP_LEVEL_DOC   0x00000008
00139 #define PP_LEVEL_TABLE 0x00000010
00140 #define PP_LEVEL_OBJ   0x00000020
00141 #define PP_LEVEL_IMG   0x00000040
00142 #define PP_LEVEL_FIELD 0x00000080
00143 #define PP_LEVEL_FRAME 0x00000100
00144 
00145 class ABI_EXPORT PP_Property
00146 {
00147 public:
00148     const gchar *           m_pszName;
00149     const gchar *           m_pszInitial;
00150     bool                m_bInherit;
00151     PP_PropertyType *   m_pProperty;
00152     tPropLevel          m_iLevel;
00153     ~PP_Property();
00154 
00155     inline const gchar *    getName() const {return m_pszName;}
00156     inline const gchar *    getInitial() const {return m_pszInitial;}
00157     const PP_PropertyType * getInitialType (tProperty_type Type) const;
00158     inline bool             canInherit() const {return m_bInherit;}
00159     inline tPropLevel       getLevel() const {return m_iLevel;}
00160 };
00161 
00162 ABI_EXPORT const PP_Property * PP_lookupProperty(const gchar * pszName);
00163 
00164 ABI_EXPORT void PP_resetInitialBiDiValues(const gchar * pszValue);
00165 
00166 ABI_EXPORT void PP_setDefaultFontFamily(const char* pszFamily);
00167 
00168 ABI_EXPORT const gchar * PP_evalProperty(const gchar * pszName,
00169                                  const PP_AttrProp * pSpanAttrProp,
00170                                  const PP_AttrProp * pBlockAttrProp,
00171                                  const PP_AttrProp * pSectionAttrProp,
00172                                  const PD_Document * pDoc,
00173                                  bool bExpandStyles=false);
00174 
00175 
00176 ABI_EXPORT const PP_PropertyType * PP_evalPropertyType(const gchar * pszName,
00177                                  const PP_AttrProp * pSpanAttrProp,
00178                                  const PP_AttrProp * pBlockAttrProp,
00179                                  const PP_AttrProp * pSectionAttrProp,
00180                                  tProperty_type Type,
00181                                  const PD_Document * pDoc=NULL,
00182                                  bool bExpandStyles=false);
00183 
00184 ABI_EXPORT UT_uint32        PP_getPropertyCount();
00185 ABI_EXPORT const gchar * PP_getNthPropertyName(UT_uint32 n);
00186 ABI_EXPORT tPropLevel       PP_getNthPropertyLevel(UT_uint32 n);
00187 #endif /* PP_PROPERTY_H */

Generated on Mon May 28 2012 for AbiWord by  doxygen 1.7.1