00001 /* AbiWord 00002 * Copyright (C) 1998 AbiSource, Inc. 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00017 * 02111-1307, USA. 00018 */ 00019 00020 00021 #ifndef PF_FRAG_H 00022 #define PF_FRAG_H 00023 00024 #include <stdio.h> 00025 #include "ut_types.h" 00026 #include "pt_Types.h" 00027 class pt_PieceTable; 00028 class PX_ChangeRecord; 00029 class fd_Field; 00030 00042 class ABI_EXPORT pf_Frag 00043 { 00044 public: 00045 typedef enum _PFType { PFT_Text = 0, PFT_Object, PFT_Strux, PFT_EndOfDoc, PFT_FmtMark } PFType; 00046 00047 pf_Frag(pt_PieceTable * pPT, PFType type, UT_uint32 length); 00048 virtual ~pf_Frag(); 00049 00050 inline PFType getType(void) const { return m_type; } 00051 inline pf_Frag * getNext(void) const { return m_next; } 00052 inline pf_Frag * getPrev(void) const { return m_prev; } 00053 00054 pf_Frag * setNext(pf_Frag * pNext); 00055 pf_Frag * setPrev(pf_Frag * pPrev); 00056 00057 inline UT_uint32 getLength(void) const { return m_length; } 00058 pt_PieceTable * getPieceTable(void) { return m_pPieceTable;} 00059 fd_Field * getField(void); 00060 PT_DocPosition getPos(void) const { return m_docPos;} 00061 void setPos(PT_DocPosition pos) const { m_docPos = pos;} 00062 00063 inline PT_AttrPropIndex getIndexAP(void) const {return m_indexAP;} 00064 virtual void setIndexAP(PT_AttrPropIndex indexNewAP) {m_indexAP = indexNewAP;} 00065 00066 // createSpecialChangeRecord() constructs a change 00067 // record which describes the fragment itself and 00068 // not an actual change (editing) operation. the 00069 // is used to initialize the listeners. 00070 virtual bool createSpecialChangeRecord(PX_ChangeRecord ** ppcr, 00071 PT_DocPosition dpos) const; 00072 00073 // compare contents of two fragments, ignoring format 00074 bool isContentEqual(const pf_Frag & f2) const; 00075 00076 UT_uint32 getXID() const {return m_iXID;} 00077 void setXID(UT_uint32 xid) {m_iXID = xid;} 00078 00079 // I would much prefer if this was a pure vitual, but we do not have Eod frag 00080 virtual bool usesXID() const {return false;} 00081 00082 // compare contents and format of two fragments 00083 bool operator == (const pf_Frag & f2) const; 00084 00085 #ifdef PT_TEST 00086 virtual void __dump(FILE * fp) const; 00087 #endif 00088 00089 protected: 00111 virtual bool _isContentEqual(const pf_Frag & /*f2*/) const {return true;} 00112 00113 PFType m_type; 00114 UT_uint32 m_length; /* in PT_DocPosition-space */ 00115 pf_Frag * m_next; 00116 pf_Frag * m_prev; 00117 00118 fd_Field * m_pField; 00119 pt_PieceTable * m_pPieceTable; 00120 PT_AttrPropIndex m_indexAP; 00121 00122 private: 00123 mutable PT_DocPosition m_docPos; 00124 UT_uint32 m_iXID; 00125 }; 00126 00127 #endif /* PF_FRAG_H */
1.5.5