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 PT_VARSET_H
00022 #define PT_VARSET_H
00023
00024 #include "ut_types.h"
00025 #include "ut_growbuf.h"
00026 #include "pt_Types.h"
00027 #include "pp_TableAttrProp.h"
00028
00029 class PD_Document;
00030
00031 class ABI_EXPORT pt_VarSet
00032 {
00033 public:
00034 pt_VarSet();
00035 ~pt_VarSet();
00036
00037 void setPieceTableState(PTState pts);
00038 bool appendBuf(const UT_UCSChar * pBuf, UT_uint32 length, PT_BufIndex * pbi);
00039 bool storeAP(const gchar ** attributes, PT_AttrPropIndex * papi);
00040 bool storeAP(const UT_GenericVector<const gchar*>* pVecAttributes, PT_AttrPropIndex * papi);
00041 inline const UT_UCSChar *getPointer(PT_BufIndex bi) const { return (UT_UCSChar *)m_buffer[_varsetFromBufIndex(bi)].getPointer(_subscriptFromBufIndex(bi)); }
00042 inline PT_BufIndex getBufIndex(PT_BufIndex bi, UT_uint32 offset) const
00043 { return _makeBufIndex(_varsetFromBufIndex(bi),
00044 _subscriptFromBufIndex(bi)+offset);
00045 }
00046
00047 bool isContiguous(PT_BufIndex bi, UT_uint32 length, PT_BufIndex bi2) const;
00048 inline const PP_AttrProp *getAP(PT_AttrPropIndex api) const
00049 {
00050 return m_tableAttrProp[_varsetFromAPIndex(api)].getAP(_subscriptFromAPIndex(api));
00051 }
00052 bool mergeAP(PTChangeFmt ptc,PT_AttrPropIndex apiOld,
00053 const gchar ** attributes, const gchar ** properties,
00054 PT_AttrPropIndex * papiNew, PD_Document * pDoc);
00055 bool addIfUniqueAP(PP_AttrProp * pAP, PT_AttrPropIndex * papi);
00056 bool overwriteBuf(UT_UCSChar * pBuf, UT_uint32 length, PT_BufIndex * pbi);
00057
00058 private:
00059 inline UT_uint32 _subscriptFromBufIndex(PT_BufIndex bi) const
00060 {
00061 return (bi & 0x7fffffff);
00062 }
00063 inline UT_uint32 _subscriptFromAPIndex(PT_AttrPropIndex api) const
00064 {
00065 return (api & 0x7fffffff);
00066 }
00067
00068 inline UT_uint32 _varsetFromBufIndex(PT_BufIndex bi) const
00069 {
00070 return (bi >> 31);
00071 }
00072
00073 inline UT_uint32 _varsetFromAPIndex(PT_AttrPropIndex api) const
00074 {
00075 return (api >> 31);
00076 }
00077
00078 inline PT_BufIndex _makeBufIndex(UT_uint32 varset, UT_uint32 subscript) const
00079 {
00080 return ((varset<<31)|subscript);
00081 }
00082
00083 inline PT_AttrPropIndex _makeAPIndex(UT_uint32 varset, UT_uint32 subscript) const
00084 {
00085 return ((varset<<31)|subscript);
00086 }
00087
00088 bool _finishConstruction(void);
00089
00090 bool m_bInitialized;
00091 UT_uint32 m_currentVarSet;
00092
00093 UT_GrowBuf m_buffer[2];
00094 pp_TableAttrProp m_tableAttrProp[2];
00095 };
00096
00097
00098 #endif