01: /*
02: * (C) Copyright IBM Corp. 1998-2004. All Rights Reserved.
03: *
04: * The program is provided "as is" without any warranty express or
05: * implied, including the warranty of non-infringement and the implied
06: * warranties of merchantibility and fitness for a particular purpose.
07: * IBM will not be liable for any damages suffered by you as a result
08: * of using the Program. In no event will IBM be liable for any
09: * special, indirect or consequential damages or lost profits even if
10: * IBM has been advised of the possibility of their occurrence. IBM
11: * will not be liable for any third party claims against you.
12: */
13: package com.ibm.richtext.textpanel;
14:
15: import com.ibm.richtext.styledtext.MText;
16: import com.ibm.richtext.textformat.TextOffset;
17:
18: abstract class TextCommand extends Command {
19: static final String COPYRIGHT = "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
20: protected TextEditBehavior fBehavior;
21: protected MText fOriginalText;
22: protected int fAffectedRangeStart;
23: protected TextOffset fSelStartBefore;
24: protected TextOffset fSelEndBefore;
25:
26: public TextCommand(TextEditBehavior behavior, MText originalText,
27: int affectedRangeStart, TextOffset selStartBefore,
28: TextOffset selEndBefore) {
29:
30: fBehavior = behavior;
31: fOriginalText = originalText;
32: fAffectedRangeStart = affectedRangeStart;
33: fSelStartBefore = new TextOffset();
34: fSelStartBefore.assign(selStartBefore);
35: fSelEndBefore = new TextOffset();
36: fSelEndBefore.assign(selEndBefore);
37: }
38:
39: public abstract int affectedRangeEnd();
40:
41: public void undo() {
42: fBehavior.doReplaceText(fAffectedRangeStart,
43: affectedRangeEnd(), fOriginalText, fSelStartBefore,
44: fSelEndBefore);
45: }
46: }
|