Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef PP_ATTRPROP_H
00022 #define PP_ATTRPROP_H
00023
00024 #include <utility>
00025
00026 #include "ut_types.h"
00027 #include "ut_hash.h"
00028 #include "ut_vector.h"
00029 #include "ut_xml.h"
00030 #include "pp_Property.h"
00031 #include "pt_Types.h"
00032
00033 class PD_Document;
00034
00035
00036
00037 class ABI_EXPORT PP_RevisionState
00038 {
00039 public:
00040 PP_RevisionState()
00041 :m_iId(0),
00042 m_bShow(false),
00043 m_bMark(false)
00044 {
00045 }
00046
00047 bool operator == (const PP_RevisionState & rs) const
00048 {
00049 if(rs.m_iId == m_iId && rs.m_bShow == m_bShow && rs.m_bMark == m_bMark)
00050 return true;
00051 return false;
00052 }
00053
00054 bool isEqual(UT_uint32 iId, bool bShow, bool bMark) const
00055 {
00056 if(m_iId == iId && m_bShow == bShow && m_bMark == bMark)
00057 return true;
00058 return false;
00059 }
00060
00061 UT_uint32 m_iId;
00062 bool m_bShow;
00063 bool m_bMark;
00064 };
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 class ABI_EXPORT PP_AttrProp
00078 {
00079 public:
00080 PP_AttrProp();
00081 virtual ~PP_AttrProp();
00082
00083
00084
00085
00086
00087
00088 bool setAttributes(const gchar ** attributes);
00089 bool setAttributes(const UT_GenericVector<const gchar*> * pVector);
00090 bool setProperties(const gchar ** properties);
00091 bool setProperties(const UT_GenericVector<gchar*> * pVector);
00092
00093 const gchar ** getAttributes () const { return m_pAttributes ? m_pAttributes->list () : 0; }
00094 const gchar ** getProperties () const;
00095
00096 bool setAttribute(const gchar * szName, const gchar * szValue);
00097 bool setProperty(const gchar * szName, const gchar * szValue);
00098
00099 bool getNthAttribute(int ndx, const gchar *& szName, const gchar *& szValue) const;
00100 bool getNthProperty(int ndx, const gchar *& szName, const gchar *& szValue) const;
00101
00102 bool getAttribute(const gchar * szName, const gchar *& szValue) const;
00103 bool getProperty(const gchar * szName, const gchar *& szValue) const;
00104 const PP_PropertyType *getPropertyType(const gchar * szName, tProperty_type Type) const;
00105
00106 bool hasProperties(void) const;
00107 bool hasAttributes(void) const;
00108 size_t getPropertyCount (void) const;
00109 size_t getAttributeCount (void) const;
00110 bool areAlreadyPresent(const gchar ** attributes, const gchar ** properties) const;
00111 bool areAnyOfTheseNamesPresent(const gchar ** attributes, const gchar ** properties) const;
00112 bool isExactMatch(const PP_AttrProp * pMatch) const;
00113 bool isEquivalent(const PP_AttrProp * pAP2) const;
00114 bool isEquivalent(const gchar ** attrs, const gchar ** props) const;
00115
00116 PP_AttrProp * createExactly(const gchar ** attributes,
00117 const gchar ** properties) const;
00118
00119 PP_AttrProp * cloneWithReplacements(const gchar ** attributes,
00120 const gchar ** properties,
00121 bool bClearProps) const;
00122 PP_AttrProp * cloneWithElimination(const gchar ** attributes,
00123 const gchar ** properties) const;
00124 PP_AttrProp * cloneWithEliminationIfEqual(const gchar ** attributes,
00125 const gchar ** properties) const;
00126
00127 void markReadOnly(void);
00128 UT_uint32 getCheckSum(void) const;
00129
00130 void operator = (const PP_AttrProp &Other);
00131 UT_uint32 getIndex(void) const;
00132 void setIndex(UT_uint32 i);
00133
00134
00135
00136
00137
00138 PT_AttrPropIndex getRevisedIndex() const {return m_iRevisedIndex;}
00139 PP_RevisionState & getRevisionState() const {return m_RevisionState;}
00140
00141 void setRevisedIndex (PT_AttrPropIndex i, UT_uint32 iId, bool bShow, bool bMark, bool bHidden) const
00142 {
00143 m_iRevisedIndex = i; m_RevisionState.m_iId = iId;
00144 m_RevisionState.m_bShow = bShow; m_RevisionState.m_bMark = bMark;
00145 m_bRevisionHidden = bHidden;
00146 }
00147
00148 bool getRevisionHidden() const {return m_bRevisionHidden;}
00149
00150 void prune();
00151 bool explodeStyle(const PD_Document * pDoc, bool bOverwrite = false);
00152
00153 void miniDump(const PD_Document * pDoc) const;
00154
00155 protected:
00156 void _computeCheckSum(void);
00157 void _clearEmptyProperties();
00158 void _clearEmptyAttributes();
00159
00160
00161 typedef std::pair<const gchar*,const PP_PropertyType *> PropertyPair;
00162
00163 UT_GenericStringMap<gchar*> * m_pAttributes;
00164 UT_GenericStringMap<PropertyPair*> * m_pProperties;
00165
00166 bool m_bIsReadOnly;
00167 UT_uint32 m_checkSum;
00168 UT_uint32 m_index;
00169 mutable const gchar ** m_szProperties;
00170
00171 mutable PT_AttrPropIndex m_iRevisedIndex;
00172 mutable PP_RevisionState m_RevisionState;
00173 mutable bool m_bRevisionHidden;
00174 };
00175
00176 #endif