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(){m_iId = 0; m_bShow = false; m_bMark = false;};
00041
00042 bool operator == (const PP_RevisionState & rs) const
00043 {
00044 if(rs.m_iId == m_iId && rs.m_bShow == m_bShow && rs.m_bMark == m_bMark)
00045 return true;
00046 return false;
00047 }
00048
00049 bool isEqual(UT_uint32 iId, bool bShow, bool bMark) const
00050 {
00051 if(m_iId == iId && m_bShow == bShow && m_bMark == bMark)
00052 return true;
00053 return false;
00054 }
00055
00056 UT_uint32 m_iId;
00057 bool m_bShow;
00058 bool m_bMark;
00059 };
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 class ABI_EXPORT PP_AttrProp
00073 {
00074 public:
00075 PP_AttrProp();
00076 virtual ~PP_AttrProp();
00077
00078
00079
00080
00081
00082
00083 bool setAttributes(const gchar ** attributes);
00084 bool setAttributes(const UT_GenericVector<const gchar*> * pVector);
00085 bool setProperties(const gchar ** properties);
00086 bool setProperties(const UT_GenericVector<gchar*> * pVector);
00087
00088 const gchar ** getAttributes () const { return m_pAttributes ? m_pAttributes->list () : 0; }
00089 const gchar ** getProperties () const;
00090
00091 bool setAttribute(const gchar * szName, const gchar * szValue);
00092 bool setProperty(const gchar * szName, const gchar * szValue);
00093
00094 bool getNthAttribute(int ndx, const gchar *& szName, const gchar *& szValue) const;
00095 bool getNthProperty(int ndx, const gchar *& szName, const gchar *& szValue) const;
00096
00097 bool getAttribute(const gchar * szName, const gchar *& szValue) const;
00098 bool getProperty(const gchar * szName, const gchar *& szValue) const;
00099 const PP_PropertyType *getPropertyType(const gchar * szName, tProperty_type Type) const;
00100
00101 bool hasProperties(void) const;
00102 bool hasAttributes(void) const;
00103 size_t getPropertyCount (void) const;
00104 size_t getAttributeCount (void) const;
00105 bool areAlreadyPresent(const gchar ** attributes, const gchar ** properties) const;
00106 bool areAnyOfTheseNamesPresent(const gchar ** attributes, const gchar ** properties) const;
00107 bool isExactMatch(const PP_AttrProp * pMatch) const;
00108 bool isEquivalent(const PP_AttrProp * pAP2) const;
00109 bool isEquivalent(const gchar ** attrs, const gchar ** props) const;
00110
00111 PP_AttrProp * createExactly(const gchar ** attributes,
00112 const gchar ** properties) const;
00113
00114 PP_AttrProp * cloneWithReplacements(const gchar ** attributes,
00115 const gchar ** properties,
00116 bool bClearProps) const;
00117 PP_AttrProp * cloneWithElimination(const gchar ** attributes,
00118 const gchar ** properties) const;
00119 PP_AttrProp * cloneWithEliminationIfEqual(const gchar ** attributes,
00120 const gchar ** properties) const;
00121
00122 void markReadOnly(void);
00123 UT_uint32 getCheckSum(void) const;
00124
00125 void operator = (const PP_AttrProp &Other);
00126 UT_uint32 getIndex(void);
00127 void setIndex(UT_uint32 i);
00128
00129
00130
00131
00132
00133 PT_AttrPropIndex getRevisedIndex() const {return m_iRevisedIndex;}
00134 PP_RevisionState & getRevisionState() const {return m_RevisionState;}
00135
00136 void setRevisedIndex (PT_AttrPropIndex i, UT_uint32 iId, bool bShow, bool bMark, bool bHidden) const
00137 {
00138 m_iRevisedIndex = i; m_RevisionState.m_iId = iId;
00139 m_RevisionState.m_bShow = bShow; m_RevisionState.m_bMark = bMark;
00140 m_bRevisionHidden = bHidden;
00141 }
00142
00143 bool getRevisionHidden() const {return m_bRevisionHidden;}
00144
00145 void prune();
00146 bool explodeStyle(const PD_Document * pDoc, bool bOverwrite = false);
00147
00148 void miniDump(const PD_Document * pDoc) const;
00149
00150 protected:
00151 void _computeCheckSum(void);
00152 void _clearEmptyProperties();
00153 void _clearEmptyAttributes();
00154
00155
00156 typedef std::pair<const gchar*,const PP_PropertyType *> PropertyPair;
00157
00158 UT_GenericStringMap<gchar*> * m_pAttributes;
00159 UT_GenericStringMap<PropertyPair*> * m_pProperties;
00160
00161 bool m_bIsReadOnly;
00162 UT_uint32 m_checkSum;
00163 UT_uint32 m_index;
00164 mutable const gchar ** m_szProperties;
00165
00166 mutable PT_AttrPropIndex m_iRevisedIndex;
00167 mutable PP_RevisionState m_RevisionState;
00168 mutable bool m_bRevisionHidden;
00169 };
00170
00171 #endif