1 /* This file is part of the KDE project
3 * Copyright (C) 2004 Leo Savernik <l.savernik@aon.at>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 #ifndef EDIT_COMMAND_H
22 #define EDIT_COMMAND_H
24 #include "misc/shared.h"
33 //------------------------------------------------------------------------------------------
41 EditCommandID
, // leave the base class first, others in alpha order
44 CompositeEditCommandID
,
45 DeleteCollapsibleWhitespaceCommandID
,
46 DeleteSelectionCommandID
,
48 InputNewlineCommandID
,
50 InsertNodeBeforeCommandID
,
52 JoinTextNodesCommandID
,
53 MoveSelectionCommandID
,
54 ReplaceSelectionCommandID
,
55 RemoveCSSPropertyCommandID
,
56 RemoveNodeAttributeCommandID
,
58 RemoveNodeAndPruneCommandID
,
59 RemoveNodePreservingChildrenCommandID
,
60 SetNodeAttributeCommandID
,
61 SplitTextNodeCommandID
,
65 //------------------------------------------------------------------------------------------
69 class EditCommandImpl
;
71 class SharedCommandImpl
: public Shared
<SharedCommandImpl
>
74 SharedCommandImpl() {}
75 virtual ~SharedCommandImpl() {}
77 virtual int commandID() const = 0;
78 virtual bool isCompositeStep() const = 0;
80 virtual void apply() = 0;
81 virtual void unapply() = 0;
82 virtual void reapply() = 0;
84 virtual DOM::DocumentImpl
* document() const = 0;
86 virtual DOM::Selection
startingSelection() const = 0;
87 virtual DOM::Selection
endingSelection() const = 0;
89 virtual void setStartingSelection(const DOM::Selection
&s
) = 0;
90 virtual void setEndingSelection(const DOM::Selection
&s
) = 0;
92 virtual EditCommandImpl
* parent() const = 0;
93 virtual void setParent(EditCommandImpl
*) = 0;
96 //------------------------------------------------------------------------------------------
99 class EditCommand
: public SharedPtr
<SharedCommandImpl
>
103 EditCommand(EditCommandImpl
*);
104 EditCommand(const EditCommand
&);
107 int commandID() const;
108 bool isCompositeStep() const;
110 bool notNull() const;
116 DOM::DocumentImpl
* document() const;
118 DOM::Selection
startingSelection() const;
119 DOM::Selection
endingSelection() const;
121 void setStartingSelection(const DOM::Selection
&s
);
122 void setEndingSelection(const DOM::Selection
&s
);
124 EditCommand
parent() const;
126 EditCommandImpl
*handle() const;
128 static EditCommand
&emptyCommand();