1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 
6 #ifndef nsIEditRules_h
7 #define nsIEditRules_h
8 
9 #define NS_IEDITRULES_IID \
10 { 0x3836386d, 0x806a, 0x488d, \
11   { 0x8b, 0xab, 0xaf, 0x42, 0xbb, 0x4c, 0x90, 0x66 } }
12 
13 #include "mozilla/EditorBase.h" // for EditAction enum
14 
15 namespace mozilla {
16 
17 class TextEditor;
18 namespace dom {
19 class Selection;
20 } // namespace dom
21 
22 /**
23  * Base for an object to encapsulate any additional info needed to be passed
24  * to rules system by the editor.
25  */
26 class RulesInfo
27 {
28 public:
RulesInfo(EditAction aAction)29   explicit RulesInfo(EditAction aAction)
30     : action(aAction)
31   {}
~RulesInfo()32   virtual ~RulesInfo() {}
33 
34   EditAction action;
35 };
36 
37 } // namespace mozilla
38 
39 /**
40  * Interface of editing rules.
41  */
42 class nsIEditRules : public nsISupports
43 {
44 public:
45   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IEDITRULES_IID)
46 
47 //Interfaces for addref and release and queryinterface
48 //NOTE: Use   NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsIEditRules
49 
50   NS_IMETHOD Init(mozilla::TextEditor* aTextEditor) = 0;
51   NS_IMETHOD SetInitialValue(const nsAString& aValue) = 0;
52   NS_IMETHOD DetachEditor() = 0;
53   NS_IMETHOD BeforeEdit(EditAction action,
54                         nsIEditor::EDirection aDirection) = 0;
55   NS_IMETHOD AfterEdit(EditAction action,
56                        nsIEditor::EDirection aDirection) = 0;
57   NS_IMETHOD WillDoAction(mozilla::dom::Selection* aSelection,
58                           mozilla::RulesInfo* aInfo, bool* aCancel,
59                           bool* aHandled) = 0;
60   NS_IMETHOD DidDoAction(mozilla::dom::Selection* aSelection,
61                          mozilla::RulesInfo* aInfo, nsresult aResult) = 0;
62   NS_IMETHOD DocumentIsEmpty(bool* aDocumentIsEmpty) = 0;
63   NS_IMETHOD DocumentModified() = 0;
64 };
65 
66 NS_DEFINE_STATIC_IID_ACCESSOR(nsIEditRules, NS_IEDITRULES_IID)
67 
68 #endif // #ifndef nsIEditRules_h
69