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
00022
00023 #ifndef PP_ATTRPROP_H
00024 #define PP_ATTRPROP_H
00025
00026 #include <memory>
00027 #include <unordered_map>
00028 #include <utility>
00029
00030 #include "ut_types.h"
00031 #include "ut_vector.h"
00032 #include "ut_xml.h"
00033 #include "pp_Property.h"
00034 #include "pt_Types.h"
00035
00036 class PD_Document;
00037
00038
00039
00040 class ABI_EXPORT PP_RevisionState
00041 {
00042 public:
00043 PP_RevisionState()
00044 :m_iId(0),
00045 m_bShow(false),
00046 m_bMark(false)
00047 {
00048 }
00049
00050 bool operator == (const PP_RevisionState & rs) const
00051 {
00052 if(rs.m_iId == m_iId && rs.m_bShow == m_bShow && rs.m_bMark == m_bMark)
00053 return true;
00054 return false;
00055 }
00056
00057 bool isEqual(UT_uint32 iId, bool bShow, bool bMark) const
00058 {
00059 if(m_iId == iId && m_bShow == bShow && m_bMark == bMark)
00060 return true;
00061 return false;
00062 }
00063
00064 UT_uint32 m_iId;
00065 bool m_bShow;
00066 bool m_bMark;
00067 };
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 class ABI_EXPORT PP_AttrProp
00081 {
00082 public:
00083 typedef std::unordered_map<std::string, std::string> attributes_t;
00084 typedef std::unordered_map<std::string, std::string> properties_t;
00085
00086 PP_AttrProp();
00087 virtual ~PP_AttrProp();
00088
00089 bool setAttributes(const PP_PropertyVector & attributes);
00090 bool setProperties(const PP_PropertyVector & properties);
00091
00092 PP_PropertyVector getAttributes () const;
00093 PP_PropertyVector getProperties () const;
00094
00095 bool setAttribute(const gchar * szName, const gchar * szValue);
00096 bool setProperty(const std::string &name, const std::string &value);
00097
00098 bool getNthAttribute(int ndx, const gchar *& szName, const gchar *& szValue) const;
00099 bool getNthProperty(int ndx, const gchar *& szName, const gchar *& szValue) const;
00100
00101 bool getAttribute(const std::string & name, const gchar *& szValue) const;
00102 bool getProperty(const std::string & name, const gchar *& szValue) const;
00103
00104 std::unique_ptr<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 PP_PropertyVector & attributes,
00111 const PP_PropertyVector & properties) const;
00112 bool areAnyOfTheseNamesPresent(const PP_PropertyVector & attributes,
00113 const PP_PropertyVector & properties) const;
00114 bool isExactMatch(const PP_AttrProp & pMatch) const;
00115 bool isEquivalent(const PP_AttrProp * pAP2) const;
00116 bool isEquivalent(const PP_PropertyVector & attrs,
00117 const PP_PropertyVector & props) const;
00118
00119 static PP_AttrProp * createExactly(const PP_PropertyVector & attributes,
00120 const PP_PropertyVector & properties);
00121
00122
00123 PP_AttrProp * cloneWithReplacements(const PP_PropertyVector & attributes,
00124 const PP_PropertyVector & properties,
00125 bool bClearProps) const;
00126 PP_AttrProp * cloneWithElimination(const PP_PropertyVector & attributes,
00127 const PP_PropertyVector & properties) const;
00128 PP_AttrProp * cloneWithEliminationIfEqual(const PP_PropertyVector & attributes,
00129 const PP_PropertyVector & properties) const;
00130
00131 void markReadOnly(void);
00132 UT_uint32 getCheckSum(void) const;
00133
00134 PP_AttrProp & operator=(const PP_AttrProp &Other);
00135 UT_uint32 getIndex(void) const;
00136 void setIndex(UT_uint32 i);
00137
00138
00139
00140
00141
00142 PT_AttrPropIndex getRevisedIndex() const {return m_iRevisedIndex;}
00143 PP_RevisionState & getRevisionState() const {return m_RevisionState;}
00144
00145 void setRevisedIndex (PT_AttrPropIndex i, UT_uint32 iId, bool bShow, bool bMark, bool bHidden) const
00146 {
00147 m_iRevisedIndex = i; m_RevisionState.m_iId = iId;
00148 m_RevisionState.m_bShow = bShow; m_RevisionState.m_bMark = bMark;
00149 m_bRevisionHidden = bHidden;
00150 }
00151
00152 bool getRevisionHidden() const {return m_bRevisionHidden;}
00153
00154 void prune();
00155 bool explodeStyle(const PD_Document * pDoc, bool bOverwrite = false);
00156
00157 void miniDump(const PD_Document * pDoc) const;
00158
00159 protected:
00160 void _computeCheckSum(void);
00161 void _clearEmptyProperties();
00162 void _clearEmptyAttributes();
00163
00164 attributes_t m_attributes;
00165 properties_t m_properties;
00166
00167 bool m_bIsReadOnly;
00168 UT_uint32 m_checkSum;
00169 UT_uint32 m_index;
00170
00171 mutable PT_AttrPropIndex m_iRevisedIndex;
00172 mutable PP_RevisionState m_RevisionState;
00173 mutable bool m_bRevisionHidden;
00174 };
00175
00176
00177
00180 std::string PP_makePropString(const PP_PropertyVector & props);
00181
00182
00183
00184
00185 PP_PropertyVector PP_std_setPropsToNothing(const PP_PropertyVector & props);
00186
00187
00188 ABI_EXPORT PP_PropertyVector PP_std_copyProps(const gchar ** props);
00189
00190 PP_PropertyVector PP_std_setPropsToValue(const PP_PropertyVector & props,
00191 const gchar * value);
00192
00194 PP_PropertyVector PP_cloneAndDecodeAttributes (const gchar ** attrs);
00195
00196
00198 ABI_EXPORT bool PP_hasAttribute(const char* name, const PP_PropertyVector & atts);
00199
00200
00201 ABI_EXPORT const std::string & PP_getAttribute(const char* name, const PP_PropertyVector & atts);
00202
00203
00206 bool PP_setAttribute(const char* name, const std::string & value, PP_PropertyVector & atts);
00207
00208
00210 void PP_addOrSetAttribute(const char* name, const std::string & value, PP_PropertyVector & atts);
00211
00212
00213 bool PP_removeAttribute(const char* name, PP_PropertyVector & atts);
00214
00215 #endif