| |
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| |
2 * |
| |
3 * This Source Code Form is subject to the terms of the Mozilla Public |
| |
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
| |
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 #ifndef nsComposerCommandsUpdater_h__ |
| |
11 #define nsComposerCommandsUpdater_h__ |
| |
12 |
| |
13 #include "nsCOMPtr.h" // for already_AddRefed, nsCOMPtr |
| |
14 #include "nsIDocumentStateListener.h" |
| |
15 #include "nsISelectionListener.h" |
| |
16 #include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS |
| |
17 #include "nsITimer.h" // for NS_DECL_NSITIMERCALLBACK, etc |
| |
18 #include "nsITransactionListener.h" // for nsITransactionListener |
| |
19 #include "nsIWeakReferenceUtils.h" // for nsWeakPtr |
| |
20 #include "nscore.h" // for NS_IMETHOD, nsresult, etc |
| |
21 |
| |
22 class nsIDOMWindow; |
| |
23 class nsITransaction; |
| |
24 class nsITransactionManager; |
| |
25 class nsPICommandUpdater; |
| |
26 |
| |
27 class nsComposerCommandsUpdater : public nsISelectionListener, |
| |
28 public nsIDocumentStateListener, |
| |
29 public nsITransactionListener, |
| |
30 public nsITimerCallback |
| |
31 { |
| |
32 public: |
| |
33 |
| |
34 nsComposerCommandsUpdater(); |
| |
35 virtual ~nsComposerCommandsUpdater(); |
| |
36 |
| |
37 // nsISupports |
| |
38 NS_DECL_ISUPPORTS |
| |
39 |
| |
40 // nsISelectionListener |
| |
41 NS_DECL_NSISELECTIONLISTENER |
| |
42 |
| |
43 // nsIDocumentStateListener |
| |
44 NS_DECL_NSIDOCUMENTSTATELISTENER |
| |
45 |
| |
46 // nsITimerCallback interfaces |
| |
47 NS_DECL_NSITIMERCALLBACK |
| |
48 |
| |
49 /** nsITransactionListener interfaces |
| |
50 */ |
| |
51 NS_IMETHOD WillDo(nsITransactionManager *aManager, nsITransaction *aTransaction, bool *aInterrupt); |
| |
52 NS_IMETHOD DidDo(nsITransactionManager *aManager, nsITransaction *aTransaction, nsresult aDoResult); |
| |
53 NS_IMETHOD WillUndo(nsITransactionManager *aManager, nsITransaction *aTransaction, bool *aInterrupt); |
| |
54 NS_IMETHOD DidUndo(nsITransactionManager *aManager, nsITransaction *aTransaction, nsresult aUndoResult); |
| |
55 NS_IMETHOD WillRedo(nsITransactionManager *aManager, nsITransaction *aTransaction, bool *aInterrupt); |
| |
56 NS_IMETHOD DidRedo(nsITransactionManager *aManager, nsITransaction *aTransaction, nsresult aRedoResult); |
| |
57 NS_IMETHOD WillBeginBatch(nsITransactionManager *aManager, bool *aInterrupt); |
| |
58 NS_IMETHOD DidBeginBatch(nsITransactionManager *aManager, nsresult aResult); |
| |
59 NS_IMETHOD WillEndBatch(nsITransactionManager *aManager, bool *aInterrupt); |
| |
60 NS_IMETHOD DidEndBatch(nsITransactionManager *aManager, nsresult aResult); |
| |
61 NS_IMETHOD WillMerge(nsITransactionManager *aManager, nsITransaction *aTopTransaction, |
| |
62 nsITransaction *aTransactionToMerge, bool *aInterrupt); |
| |
63 NS_IMETHOD DidMerge(nsITransactionManager *aManager, nsITransaction *aTopTransaction, |
| |
64 nsITransaction *aTransactionToMerge, |
| |
65 bool aDidMerge, nsresult aMergeResult); |
| |
66 |
| |
67 |
| |
68 nsresult Init(nsIDOMWindow* aDOMWindow); |
| |
69 |
| |
70 protected: |
| |
71 |
| |
72 enum { |
| |
73 eStateUninitialized = -1, |
| |
74 eStateOff = false, |
| |
75 eStateOn = true |
| |
76 }; |
| |
77 |
| |
78 bool SelectionIsCollapsed(); |
| |
79 nsresult UpdateDirtyState(bool aNowDirty); |
| |
80 nsresult UpdateOneCommand(const char* aCommand); |
| |
81 nsresult UpdateCommandGroup(const nsAString& aCommandGroup); |
| |
82 |
| |
83 already_AddRefed<nsPICommandUpdater> GetCommandUpdater(); |
| |
84 |
| |
85 nsresult PrimeUpdateTimer(); |
| |
86 void TimerCallback(); |
| |
87 nsCOMPtr<nsITimer> mUpdateTimer; |
| |
88 |
| |
89 nsWeakPtr mDOMWindow; |
| |
90 nsWeakPtr mDocShell; |
| |
91 int8_t mDirtyState; |
| |
92 int8_t mSelectionCollapsed; |
| |
93 bool mFirstDoOfFirstUndo; |
| |
94 |
| |
95 |
| |
96 }; |
| |
97 |
| |
98 extern "C" nsresult NS_NewComposerCommandsUpdater(nsISelectionListener** aInstancePtrResult); |
| |
99 |
| |
100 |
| |
101 #endif // nsComposerCommandsUpdater_h__ |