Warning, file /frameworks/khtml/src/editing/editor.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002  *
0003  * Copyright (C) 2004 Leo Savernik <l.savernik@aon.at>
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Library General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Library General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Library General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, write to
0017  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0018  * Boston, MA 02111-1307, USA.
0019  */
0020 
0021 #ifndef __EDITOR_H
0022 #define __EDITOR_H
0023 
0024 #include "editor_command.h"
0025 
0026 #include <khtml_export.h>
0027 
0028 #include <QObject>
0029 
0030 #include "wtf/PassRefPtr.h"
0031 
0032 class QKeyEvent;
0033 
0034 class KHTMLPart;
0035 class KHTMLView;
0036 class KHTMLEditorPart;
0037 
0038 namespace khtml
0039 {
0040 class EditCommandImpl;
0041 struct EditorContext;
0042 }
0043 
0044 namespace DOM
0045 {
0046 
0047 class Range;
0048 class NodeImpl;
0049 class ElementImpl;
0050 class DOMString;
0051 class CSSStyleDeclarationImpl;
0052 class EditorPrivate;
0053 
0054 /**
0055  * This class resembles the editing API when the associated khtml document
0056  * is editable (in design mode), or contains editable elements.
0057  *
0058  * FIXME: document this thoroughly
0059  *
0060  * @short API to Wysiwyg Markup-Editor.
0061  * @author Leo Savernik
0062  */
0063 class KHTML_EXPORT Editor : public QObject
0064 {
0065     Q_OBJECT
0066 
0067     Editor(KHTMLPart *);
0068     virtual ~Editor();
0069 public:
0070 
0071     /**
0072      * Tri-state boolean.
0073      */
0074     enum TriState { FalseTriState, TrueTriState, MixedTriState };
0075 
0076     // == interface to editor commands
0077 
0078     /**
0079      * Executes the given editor command.
0080      * @param command name of command
0081      * @param userInterface whether a user interface should be used to input data. This is command dependent.
0082      * @param value value for command. Its semantic depends on the command.
0083      */
0084     bool execCommand(const DOMString &command, bool userInterface, const DOMString &value);
0085     /** Checks whether the given command is enabled. */
0086     bool queryCommandEnabled(const DOMString &command);
0087     /** Checks whether the given command's style is indeterminate */
0088     bool queryCommandIndeterm(const DOMString &command);
0089     /** Checks whether the given command's style is state */
0090     bool queryCommandState(const DOMString &command);
0091     /** Checks whether the given command is supported in the current context */
0092     bool queryCommandSupported(const DOMString &command);
0093     /** Returns the given command's value */
0094     DOMString queryCommandValue(const DOMString &command);
0095 
0096     /**
0097      * Executes the given built-in editor command.
0098      * @param EditorCommand index of command
0099      * @param userInterface whether a user interface should be used to input data. This is command dependent.
0100      * @param value value for command. Its semantic depends on the command.
0101      */
0102     bool execCommand(EditorCommand, bool userInterface, const DOMString &value);
0103     /** Checks whether the given command is enabled. */
0104     bool queryCommandEnabled(EditorCommand);
0105     /** Checks whether the given command's style is indeterminate */
0106     bool queryCommandIndeterm(EditorCommand);
0107     /** Checks whether the given command's style is state */
0108     bool queryCommandState(EditorCommand);
0109     /** Checks whether the given command is supported in the current context */
0110     bool queryCommandSupported(EditorCommand);
0111     /** Returns the given command's value */
0112     DOMString queryCommandValue(EditorCommand);
0113 
0114     // == direct interface to some built-in commands
0115 
0116     /** copy selection to clipboard */
0117     void copy();
0118     /** cut selection and insert into clipboard */
0119     void cut();
0120     /** paste into current selection from clipboard */
0121     void paste();
0122     /** returns whether clipboard contains data to be pasted */
0123     bool canPaste() const;
0124     /** redo last undone action */
0125     void redo();
0126     /** undo last action */
0127     void undo();
0128     /** returns whether any actions can be redone */
0129     bool canRedo() const;
0130     /** returns whether any actions can be undone */
0131     bool canUndo() const;
0132     /** applies the given style to the current selection */
0133     void applyStyle(DOM::CSSStyleDeclarationImpl *);
0134     /** returns whether the selection has got applied the given style */
0135     TriState selectionHasStyle(DOM::CSSStyleDeclarationImpl *) const;
0136     /** returns whether the selection has got applied the given style */
0137     bool selectionStartHasStyle(DOM::CSSStyleDeclarationImpl *) const;
0138     /** ? */
0139     DOM::DOMString selectionStartStylePropertyValue(int stylePropertyID) const;
0140     /** prints the current document */
0141     void print();
0142     /** computed style of current selection */
0143     DOM::CSSStyleDeclarationImpl *selectionComputedStyle(DOM::NodeImpl *&nodeToRemove) const;
0144 
0145     // == ### more stuff I'm not sure about whether it should be public
0146 
0147     /**
0148      * Returns the most recent edit command applied.
0149      */
0150     WTF::PassRefPtr<khtml::EditCommandImpl> lastEditCommand() const;
0151 
0152     /**
0153      * Called when editing has been applied.
0154      */
0155     void appliedEditing(khtml::EditCommandImpl *);
0156 
0157     /**
0158      * Called when editing has been unapplied.
0159      */
0160     void unappliedEditing(khtml::EditCommandImpl *);
0161 
0162     /**
0163      * Called when editing has been reapplied.
0164      */
0165     void reappliedEditing(khtml::EditCommandImpl *);
0166 
0167     /**
0168      * Returns the typing style for the document.
0169      */
0170     DOM::CSSStyleDeclarationImpl *typingStyle() const;
0171 
0172     /**
0173      * Sets the typing style for the document.
0174      */
0175     void setTypingStyle(DOM::CSSStyleDeclarationImpl *);
0176 
0177     /**
0178      * Clears the typing style for the document.
0179      */
0180     void clearTypingStyle();
0181 
0182     void closeTyping();
0183 
0184     /**
0185      * indent/outdent current selection
0186      */
0187     void indent();
0188     void outdent();
0189 
0190 private:
0191     /** Handles key events. Returns true if event has been handled. */
0192     bool handleKeyEvent(QKeyEvent *);
0193 
0194 private:
0195     EditorPrivate *const d;
0196 
0197     DOM::CSSStyleDeclarationImpl *m_typingStyle;
0198 
0199     KHTMLPart *m_part;
0200 
0201     friend class ::KHTMLPart;
0202     friend class ::KHTMLView;
0203     friend class ::KHTMLEditorPart;
0204     friend struct khtml::EditorContext;
0205     friend class DOM::ElementImpl;
0206 };
0207 
0208 }/*namespace DOM*/
0209 
0210 #endif // __EDITOR_H