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 #ifndef PT_REVISION_H
00021 #define PT_REVISION_H
00022
00023 #include "ut_types.h"
00024 #include "ut_string_class.h"
00025 #include "ut_vector.h"
00026 #include "pp_AttrProp.h"
00027
00028 class PD_Document;
00029
00030 ABI_EXPORT const char* UT_getAttribute( const PP_AttrProp* pAP, const char* name, const char* def = 0 );
00035 ABI_EXPORT std::string UT_getLatestAttribute( const PP_AttrProp* pAP,
00036 const char* name,
00037 const char* def );
00038
00039
00040 typedef enum {
00041 PP_REVISION_NONE = 0,
00042 PP_REVISION_ADDITION = 0x01,
00043 PP_REVISION_DELETION = 0x02,
00044 PP_REVISION_FMT_CHANGE = 0x04,
00045 PP_REVISION_ADDITION_AND_FMT = 0x05
00046 } PP_RevisionType;
00047
00053 class ABI_EXPORT PP_Revision: public PP_AttrProp
00054 {
00055 public:
00056 PP_Revision(UT_uint32 Id,
00057 PP_RevisionType eType,
00058 const gchar * props,
00059 const gchar * attrs);
00060
00061 PP_Revision(UT_uint32 Id,
00062 PP_RevisionType eType,
00063 const gchar ** props,
00064 const gchar ** attrs);
00065
00066 virtual ~PP_Revision(){};
00067
00068 UT_uint32 getId() const {return m_iID;}
00069 void setId(UT_uint32 iId) {UT_ASSERT_HARMLESS( iId >= m_iID); m_iID = iId;}
00070
00071 PP_RevisionType getType() const {return m_eType;}
00072 void setType(PP_RevisionType t) {m_eType = t; m_bDirty = true;}
00073
00074 const gchar * getPropsString() const;
00075 const gchar * getAttrsString() const;
00076
00077
00078 bool setAttributes(const gchar ** attributes);
00079
00080 bool operator == (const PP_Revision &op2) const;
00081
00082
00083
00084 std::string toString() const;
00085 bool onlyContainsAbiwordChangeTrackingMarkup() const;
00086
00087 private:
00088 void _refreshString() const;
00089 bool _handleNestedRevAttr();
00090
00091 UT_uint32 m_iID;
00092 PP_RevisionType m_eType;
00093
00094 mutable UT_String m_sXMLProps;
00095 mutable UT_String m_sXMLAttrs;
00096 mutable bool m_bDirty;
00097 };
00098
00099
00100
00133 class ABI_EXPORT PP_RevisionAttr
00134 {
00135 public:
00136 PP_RevisionAttr()
00137 :m_vRev(),m_sXMLstring(),m_bDirty(true),m_iSuperfluous(0),m_pLastRevision(NULL)
00138 {};
00139 PP_RevisionAttr(const gchar * r);
00140
00141
00142 PP_RevisionAttr(UT_uint32 iId, PP_RevisionType eType, const gchar ** pAttrs, const gchar ** pProps);
00143
00144 ~PP_RevisionAttr();
00145
00146 void setRevision(const gchar * r);
00147 void setRevision(std::string& r);
00148
00149 void addRevision(UT_uint32 iId,
00150 PP_RevisionType eType,
00151 const gchar ** pAttrs,
00152 const gchar ** pProps);
00153 void addRevision(UT_uint32 iId, PP_RevisionType eType );
00154
00155 void addRevision( const PP_Revision* r );
00156
00157 bool changeRevisionType(UT_uint32 iId, PP_RevisionType eType);
00158 bool changeRevisionId(UT_uint32 iOldId, UT_uint32 iNewId);
00159
00160 void removeRevisionIdWithType(UT_uint32 iId, PP_RevisionType eType);
00161 void removeRevisionIdTypeless(UT_uint32 iId);
00162 void removeAllLesserOrEqualIds(UT_uint32 id);
00163 void removeAllHigherOrEqualIds(UT_uint32 id);
00164 void removeRevision(const PP_Revision * pRev);
00165
00166 const PP_Revision * getGreatestLesserOrEqualRevision(UT_uint32 id,
00167 const PP_Revision ** ppR) const;
00168 const PP_Revision * getLowestGreaterOrEqualRevision(UT_uint32 id) const;
00169
00170 const PP_Revision * getLastRevision() const;
00171 const PP_Revision * getRevisionWithId(UT_uint32 iId, UT_uint32 & iMinId) const;
00172 UT_uint32 getHighestId() const;
00173
00174 UT_uint32 getRevisionsCount() const {return m_vRev.getItemCount();}
00175 bool empty() const { return !getRevisionsCount(); }
00176 const PP_Revision * getNthRevision(UT_uint32 n) const {return (const PP_Revision*)m_vRev.getNthItem(n);}
00177
00178 void pruneForCumulativeResult(PD_Document * pDoc);
00179
00185 bool isVisible(UT_uint32 id) const;
00186 bool hasProperty(UT_uint32 iId, const gchar * pName, const gchar * &pValue) const;
00187 bool hasProperty(const gchar * pName, const gchar * &pValue) const;
00188 PP_RevisionType getType(UT_uint32 iId) const;
00189 PP_RevisionType getType() const;
00190 UT_uint32 getHighestRevisionNumberWithAttribute( const gchar * pName ) const;
00191 #if 0
00192 const UT_Vector * getProps(UT_uint32 iId);
00193 const UT_Vector * getProps();
00194 #endif
00195 const gchar * getXMLstring() const;
00196 std::string getXMLstringUpTo( UT_uint32 iId ) const;
00197 void forceDirty() {m_bDirty = true;}
00198 bool isFragmentSuperfluous() const;
00199
00200 bool operator== (const PP_RevisionAttr &op2) const;
00201
00202
00203
00204
00205 void mergeAll( const PP_RevisionAttr& ra );
00206 void mergeAttr( UT_uint32 iId, PP_RevisionType t,
00207 const gchar* pzName, const gchar* pzValue );
00208 void mergeAttrIfNotAlreadyThere( UT_uint32 iId, PP_RevisionType t,
00209 const gchar* pzName, const gchar* pzValue );
00210
00211 const PP_Revision * getLowestDeletionRevision() const;
00212
00213
00214 private:
00215 void _init(const gchar *r);
00216 void _clear();
00217 void _refreshString() const;
00218
00219 UT_Vector m_vRev;
00220
00221 mutable UT_String m_sXMLstring;
00222 mutable bool m_bDirty;
00223
00224 UT_uint32 m_iSuperfluous;
00225
00226 mutable const PP_Revision * m_pLastRevision;
00227 };
00228
00229 #endif // #ifndef PT_REVISION_H