• 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; indent-tabs-mode: t -*- */
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., 51 Franklin Street, Fifth Floor, Boston, MA
00019  * 02110-1301 USA.
00020  */
00021 
00022 
00023 
00024 #ifndef PP_PROPERTY_H
00025 #define PP_PROPERTY_H
00026 
00027 #include <memory>
00028 #include <string>
00029 #include <vector>
00030 
00031 // make sure we don't get caught in a BASEDON loop
00032 #define pp_BASEDON_DEPTH_LIMIT  10
00033 
00034 #include "ut_types.h"
00035 #include "ut_misc.h"
00036 #include "ut_units.h"
00037 
00038 #include "pp_PropertyMap.h"
00039 
00040 class PP_AttrProp;
00041 class PD_Document;
00042 
00045 typedef std::vector<std::string> PP_PropertyVector;
00046 
00047 namespace {
00048 const PP_PropertyVector PP_NOPROPS;
00049 }
00050 
00051 #define ASSERT_PV_SIZE(x) \
00052     UT_ASSERT(x.size() % 2 == 0)
00053 
00054 // PP_Property captures knowledge of the various CSS properties,
00055 // such as their initial/default values and whether they are
00056 // inherited.
00057 
00058 typedef enum {
00059     Property_type_bool,
00060     Property_type_int,
00061     Property_type_size,
00062     Property_type_color
00063     } tProperty_type;
00064 
00065 
00066 class ABI_EXPORT PP_PropertyType
00067 {
00068 public:
00069     PP_PropertyType() {};
00070     virtual ~PP_PropertyType() {};
00071 
00072 public:
00073     virtual tProperty_type getType() const = 0;
00074 
00075     static std::unique_ptr<PP_PropertyType> createPropertyType(tProperty_type Type, const gchar *p_init);
00076 };
00077 
00078 class ABI_EXPORT PP_PropertyTypeBool : public PP_PropertyType
00079 {
00080 
00081 public:
00082     PP_PropertyTypeBool(const gchar *p_init);
00083 
00084     tProperty_type getType() const {return Property_type_bool;}
00085 
00086     bool getState() const {return State;}
00087 
00088 
00089 private:
00090 
00091     bool State;
00092 };
00093 
00094 class ABI_EXPORT PP_PropertyTypeInt : public PP_PropertyType
00095 {
00096 
00097 public:
00098     PP_PropertyTypeInt(const gchar *p_init);
00099 
00100     tProperty_type getType() const {return Property_type_int;}
00101 
00102     int getValue() const {return Value;}
00103 
00104 
00105 private:
00106 
00107     int Value;
00108 };
00109 
00110 class ABI_EXPORT PP_PropertyTypeSize : public PP_PropertyType
00111 {
00112 
00113 public:
00114     PP_PropertyTypeSize(const gchar *p_init);
00115 
00116     tProperty_type getType() const {return Property_type_size;}
00117 
00118     double getValue() const {return Value;}
00119     UT_Dimension getDim() const {return Dim;}
00120 
00121 
00122 private:
00123 
00124     double Value;
00125     UT_Dimension Dim;
00126 };
00127 
00128 class ABI_EXPORT PP_PropertyTypeColor : public PP_PropertyType
00129 {
00130 
00131 public:
00132     PP_PropertyTypeColor(const gchar *p_init);
00133 
00134     tProperty_type getType() const {return Property_type_color;}
00135 
00136     const UT_RGBColor &getColor() const {return Color;}
00137 
00138 
00139 private:
00140 
00141     UT_RGBColor Color;
00142 };
00143 
00144 
00145 
00146 typedef unsigned int tPropLevel;
00147 
00148 // the m_iLevel member of PP_Property should be set by or-ing the
00149 // following constants
00150 #define PP_LEVEL_CHAR  0x00000001
00151 #define PP_LEVEL_BLOCK 0x00000002
00152 #define PP_LEVEL_SECT  0x00000004
00153 #define PP_LEVEL_DOC   0x00000008
00154 #define PP_LEVEL_TABLE 0x00000010
00155 #define PP_LEVEL_OBJ   0x00000020
00156 #define PP_LEVEL_IMG   0x00000040
00157 #define PP_LEVEL_FIELD 0x00000080
00158 #define PP_LEVEL_FRAME 0x00000100
00159 
00160 class ABI_EXPORT PP_Property
00161 {
00162 public:
00163     const gchar *           m_pszName;
00164     const gchar *           m_pszInitial;
00165     bool                m_bInherit;
00166     tPropLevel          m_iLevel;
00167     ~PP_Property();
00168 
00169     inline const gchar *    getName() const {return m_pszName;}
00170     inline const gchar *    getInitial() const {return m_pszInitial;}
00171     std::unique_ptr<PP_PropertyType>    getInitialType (tProperty_type Type) const;
00172     inline bool             canInherit() const {return m_bInherit;}
00173     inline tPropLevel       getLevel() const {return m_iLevel;}
00174 };
00175 
00176 ABI_EXPORT const PP_Property * PP_lookupProperty(const gchar * pszName);
00177 
00178 ABI_EXPORT void PP_resetInitialBiDiValues(const gchar * pszValue);
00179 
00180 ABI_EXPORT void PP_setDefaultFontFamily(const char* pszFamily);
00181 
00182 ABI_EXPORT const gchar * PP_evalProperty(const gchar * pszName,
00183                                  const PP_AttrProp * pSpanAttrProp,
00184                                  const PP_AttrProp * pBlockAttrProp,
00185                                  const PP_AttrProp * pSectionAttrProp,
00186                                  const PD_Document * pDoc,
00187                                  bool bExpandStyles=false);
00188 
00189 
00190 ABI_EXPORT std::unique_ptr<PP_PropertyType> PP_evalPropertyType(const gchar * pszName,
00191                                  const PP_AttrProp * pSpanAttrProp,
00192                                  const PP_AttrProp * pBlockAttrProp,
00193                                  const PP_AttrProp * pSectionAttrProp,
00194                                  tProperty_type Type,
00195                                  const PD_Document * pDoc=NULL,
00196                                  bool bExpandStyles=false);
00197 
00198 ABI_EXPORT UT_uint32        PP_getPropertyCount();
00199 ABI_EXPORT const gchar * PP_getNthPropertyName(UT_uint32 n);
00200 ABI_EXPORT tPropLevel       PP_getNthPropertyLevel(UT_uint32 n);
00201 #endif /* PP_PROPERTY_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1