2 * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef __composite_edit_command_h__
27 #define __composite_edit_command_h__
29 #include "edit_command.h"
30 #include "qvaluelist.h"
33 class CSSStyleDeclarationImpl;
40 class CompositeEditCommand : public EditCommand
43 CompositeEditCommand(DOM::DocumentImpl *);
45 virtual void doUnapply();
46 virtual void doReapply();
50 // sugary-sweet convenience functions to help create and apply edit commands in composite commands
52 void appendNode(DOM::NodeImpl *appendChild, DOM::NodeImpl *parentNode);
53 void applyCommandToComposite(EditCommandPtr &);
54 void applyStyle(DOM::CSSStyleDeclarationImpl *style, EditAction editingAction=EditActionChangeAttributes);
55 void deleteKeyPressed();
56 void deleteSelection(bool smartDelete=false, bool mergeBlocksAfterDelete=true);
57 void deleteSelection(const Selection &selection, bool smartDelete=false, bool mergeBlocksAfterDelete=true);
58 void deleteTextFromNode(DOM::TextImpl *node, long offset, long count);
59 void inputText(const DOM::DOMString &text, bool selectInsertedText = false);
60 void insertNodeAfter(DOM::NodeImpl *insertChild, DOM::NodeImpl *refChild);
61 void insertNodeAt(DOM::NodeImpl *insertChild, DOM::NodeImpl *refChild, long offset);
62 void insertNodeBefore(DOM::NodeImpl *insertChild, DOM::NodeImpl *refChild);
63 void insertParagraphSeparator();
64 void insertTextIntoNode(DOM::TextImpl *node, long offset, const DOM::DOMString &text);
65 void joinTextNodes(DOM::TextImpl *text1, DOM::TextImpl *text2);
66 void rebalanceWhitespace();
67 void removeCSSProperty(DOM::CSSStyleDeclarationImpl *, int property);
68 void removeFullySelectedNode(DOM::NodeImpl *node);
69 void removeNodeAttribute(DOM::ElementImpl *, int attribute);
70 void removeChildrenInRange(DOM::NodeImpl *node, int from, int to);
71 void removeNode(DOM::NodeImpl *removeChild);
72 void removeNodePreservingChildren(DOM::NodeImpl *node);
73 void replaceTextInNode(DOM::TextImpl *node, long offset, long count, const DOM::DOMString &replacementText);
74 void setNodeAttribute(DOM::ElementImpl *, int attribute, const DOM::DOMString &);
75 void splitTextNode(DOM::TextImpl *text, long offset);
76 void splitElement(DOM::ElementImpl *element, DOM::NodeImpl *atChild);
77 void mergeIdenticalElements(DOM::ElementImpl *first, DOM::ElementImpl *second);
78 void wrapContentsInDummySpan(DOM::ElementImpl *element);
79 void splitTextNodeContainingElement(DOM::TextImpl *text, long offset);
81 void deleteInsignificantText(DOM::TextImpl *, int start, int end);
82 void deleteInsignificantText(const DOM::Position &start, const DOM::Position &end);
83 void deleteInsignificantTextDownstream(const DOM::Position &);
85 DOM::NodeImpl *appendBlockPlaceholder(DOM::NodeImpl *);
86 DOM::NodeImpl *insertBlockPlaceholder(const DOM::Position &pos);
87 DOM::NodeImpl *addBlockPlaceholderIfNeeded(DOM::NodeImpl *);
88 bool removeBlockPlaceholder(DOM::NodeImpl *);
89 DOM::NodeImpl *findBlockPlaceholder(DOM::NodeImpl *);
91 void moveParagraphContentsToNewBlockIfNecessary(const DOM::Position &);
93 QValueList<EditCommandPtr> m_cmds;
98 #endif // __composite_edit_command_h__