1 /* AbiWord 2 * Copyright (C) 1998 AbiSource, Inc. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 17 * 02110-1301 USA. 18 */ 19 20 21 #ifndef PX_CHANGERECORD_SPAN_H 22 #define PX_CHANGERECORD_SPAN_H 23 24 #include "ut_types.h" 25 #include "px_ChangeRecord.h" 26 27 class fd_Field; 28 29 // PX_ChangeRecord_Span describes an insertSpan or 30 // deleteSpan change made to the document. 31 // This description should be sufficient to allow undo to 32 // work and sufficient to allow the formatter to do a 33 // partial format and screen update (if appropriate). 34 // The change record must be free of pointers, since it 35 // represents what was done to the document -- and not 36 // how it was done (that is, not what was done to various 37 // intermediate data structures). this also lets it be 38 // cached to disk (for autosave and maybe multi-session 39 // undo). 40 // 41 // m_position contains the absolute document position of 42 // the text span at the time the change was made. 43 // m_bufIndex,m_length describe the actual contents 44 // of the text span. 45 46 47 class ABI_EXPORT PX_ChangeRecord_Span : public PX_ChangeRecord 48 { 49 public: 50 PX_ChangeRecord_Span(PXType type, 51 PT_DocPosition position, 52 PT_AttrPropIndex indexAP, 53 PT_BufIndex bufIndex, 54 UT_uint32 length, 55 PT_BlockOffset blockOffset, 56 fd_Field * pField); 57 58 ~PX_ChangeRecord_Span(); 59 60 virtual PX_ChangeRecord * reverse(void) const; 61 62 UT_uint32 getLength(void) const; 63 PT_BufIndex getBufIndex(void) const; 64 void coalesce(const PX_ChangeRecord_Span * pcr); 65 PT_BlockOffset getBlockOffset(void) const; getField(void)66 fd_Field * getField(void) const {return m_pField;}; AdjustBlockOffset(PT_BlockOffset iBlk)67 void AdjustBlockOffset(PT_BlockOffset iBlk) const 68 { m_blockOffset = iBlk;} 69 70 #ifdef PT_TEST 71 virtual void __dump(FILE * fp) const; 72 #endif 73 74 protected: 75 PT_BufIndex m_bufIndex; /* bufIndex to our text */ 76 UT_uint32 m_length; /* length of our text */ 77 mutable PT_BlockOffset m_blockOffset; /* offset of span from beginning of paragraph */ 78 fd_Field * m_pField; 79 }; 80 81 #endif /* PX_CHANGERECORD_SPAN_H */ 82