fix tricky regression noticed by Vyacheslav Tokarev on Google Reader.
[kdelibs.git] / khtml / editing / edit_command.h
blob9767d7acff7ab484cd81cc921242be033e1c32a1
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"
26 namespace DOM {
27 class DocumentImpl;
28 class Selection;
31 namespace khtml {
33 //------------------------------------------------------------------------------------------
34 // Constants
36 /**
37 * Edit-command IDs.
38 * @internal
40 enum ECommandID {
41 EditCommandID, // leave the base class first, others in alpha order
42 AppendNodeCommandID,
43 ApplyStyleCommandID,
44 CompositeEditCommandID,
45 DeleteCollapsibleWhitespaceCommandID,
46 DeleteSelectionCommandID,
47 DeleteTextCommandID,
48 InputNewlineCommandID,
49 InputTextCommandID,
50 InsertNodeBeforeCommandID,
51 InsertTextCommandID,
52 JoinTextNodesCommandID,
53 MoveSelectionCommandID,
54 ReplaceSelectionCommandID,
55 RemoveCSSPropertyCommandID,
56 RemoveNodeAttributeCommandID,
57 RemoveNodeCommandID,
58 RemoveNodeAndPruneCommandID,
59 RemoveNodePreservingChildrenCommandID,
60 SetNodeAttributeCommandID,
61 SplitTextNodeCommandID,
62 TypingCommandID
65 //------------------------------------------------------------------------------------------
66 // SharedCommandImpl
68 class EditCommand;
69 class EditCommandImpl;
71 class SharedCommandImpl : public Shared<SharedCommandImpl>
73 public:
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 //------------------------------------------------------------------------------------------
97 // EditCommand
99 class EditCommand : public SharedPtr<SharedCommandImpl>
101 public:
102 EditCommand();
103 EditCommand(EditCommandImpl *);
104 EditCommand(const EditCommand &);
105 ~EditCommand();
107 int commandID() const;
108 bool isCompositeStep() const;
109 bool isNull() const;
110 bool notNull() const;
112 void apply();
113 void unapply();
114 void reapply();
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();
131 }/*namespace khtml*/
134 #endif