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 typedef enum {
00031 PP_REVISION_NONE = 0,
00032 PP_REVISION_ADDITION = 0x01,
00033 PP_REVISION_DELETION = 0x02,
00034 PP_REVISION_FMT_CHANGE = 0x04,
00035 PP_REVISION_ADDITION_AND_FMT = 0x05
00036 } PP_RevisionType;
00037
00043 class ABI_EXPORT PP_Revision: public PP_AttrProp
00044 {
00045 public:
00046 PP_Revision(UT_uint32 Id,
00047 PP_RevisionType eType,
00048 const gchar * props,
00049 const gchar * attrs);
00050
00051 PP_Revision(UT_uint32 Id,
00052 PP_RevisionType eType,
00053 const gchar ** props,
00054 const gchar ** attrs);
00055
00056 virtual ~PP_Revision(){};
00057
00058 UT_uint32 getId() const {return m_iID;}
00059 void setId(UT_uint32 iId) {UT_ASSERT_HARMLESS( iId >= m_iID); m_iID = iId;}
00060
00061 PP_RevisionType getType() const {return m_eType;}
00062 void setType(PP_RevisionType t) {m_eType = t; m_bDirty = true;}
00063
00064 const gchar * getPropsString();
00065 const gchar * getAttrsString();
00066
00067
00068 bool setAttributes(const gchar ** attributes);
00069
00070 bool operator == (const PP_Revision &op2) const;
00071
00072 private:
00073 void _refreshString();
00074 bool _handleNestedRevAttr();
00075
00076 UT_uint32 m_iID;
00077 PP_RevisionType m_eType;
00078 UT_String m_sXMLProps;
00079 UT_String m_sXMLAttrs;
00080 bool m_bDirty;
00081 };
00082
00083
00084
00117 class ABI_EXPORT PP_RevisionAttr
00118 {
00119 public:
00120 PP_RevisionAttr()
00121 :m_vRev(),m_sXMLstring(),m_bDirty(true),m_iSuperfluous(0),m_pLastRevision(NULL)
00122 {};
00123 PP_RevisionAttr(const gchar * r);
00124
00125
00126 PP_RevisionAttr(UT_uint32 iId, PP_RevisionType eType, const gchar ** pAttrs, const gchar ** pProps);
00127
00128 ~PP_RevisionAttr();
00129
00130 void setRevision(const gchar * r);
00131
00132 void addRevision(UT_uint32 iId,
00133 PP_RevisionType eType,
00134 const gchar ** pAttrs,
00135 const gchar ** pProps);
00136
00137 bool changeRevisionType(UT_uint32 iId, PP_RevisionType eType);
00138 bool changeRevisionId(UT_uint32 iOldId, UT_uint32 iNewId);
00139
00140 void removeRevisionIdWithType(UT_uint32 iId, PP_RevisionType eType);
00141 void removeRevisionIdTypeless(UT_uint32 iId);
00142 void removeAllLesserOrEqualIds(UT_uint32 id);
00143 void removeAllHigherOrEqualIds(UT_uint32 id);
00144 void removeRevision(const PP_Revision * pRev);
00145
00146 const PP_Revision * getGreatestLesserOrEqualRevision(UT_uint32 id,
00147 const PP_Revision ** ppR);
00148 const PP_Revision * getLowestGreaterOrEqualRevision(UT_uint32 id);
00149
00150 const PP_Revision * getLastRevision();
00151 const PP_Revision * getRevisionWithId(UT_uint32 iId, UT_uint32 & iMinId);
00152
00153 UT_uint32 getRevisionsCount() const {return m_vRev.getItemCount();}
00154 const PP_Revision * getNthRevision(UT_uint32 n) const {return (const PP_Revision*)m_vRev.getNthItem(n);}
00155
00156 void pruneForCumulativeResult(PD_Document * pDoc);
00157
00163 bool isVisible(UT_uint32 id);
00164 bool hasProperty(UT_uint32 iId, const gchar * pName, const gchar * &pValue);
00165 bool hasProperty(const gchar * pName, const gchar * &pValue);
00166 PP_RevisionType getType(UT_uint32 iId);
00167 PP_RevisionType getType();
00168 #if 0
00169 const UT_Vector * getProps(UT_uint32 iId);
00170 const UT_Vector * getProps();
00171 #endif
00172 const gchar * getXMLstring();
00173 void forceDirty() {m_bDirty = true;}
00174 bool isFragmentSuperfluous() const;
00175
00176 bool operator == (const PP_RevisionAttr &op2) const;
00177
00178 private:
00179 void _init(const gchar *r);
00180 void _clear();
00181 void _refreshString();
00182
00183 UT_Vector m_vRev;
00184 UT_String m_sXMLstring;
00185 bool m_bDirty;
00186
00187 UT_uint32 m_iSuperfluous;
00188 const PP_Revision * m_pLastRevision;
00189 };
00190
00191 #endif // #ifndef PT_REVISION_H