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