From 008d4be4c956c22665dd2e4ed92387897fa156de Mon Sep 17 00:00:00 2001 From: "jfrancis%netscape.com" Date: Mon, 14 Aug 2000 12:07:10 +0000 Subject: [PATCH] groundwork for 44684: adding a "GetAlignment" call to the editor so that ui can reflect alignment of selection --- editor/base/nsEditorShell.cpp | 28 +++++++++++++ editor/base/nsEditorShell.h | 50 +++++++++++------------ editor/base/nsHTMLEditRules.cpp | 5 +++ editor/base/nsHTMLEditRules.h | 1 + editor/base/nsHTMLEditor.cpp | 12 ++++++ editor/base/nsHTMLEditor.h | 1 + editor/base/nsIHTMLEditRules.h | 1 + editor/composer/src/nsEditorShell.cpp | 28 +++++++++++++ editor/composer/src/nsEditorShell.h | 50 +++++++++++------------ editor/idl/nsIEditorShell.idl | 2 + editor/libeditor/html/nsHTMLEditRules.cpp | 5 +++ editor/libeditor/html/nsHTMLEditRules.h | 1 + editor/libeditor/html/nsHTMLEditor.cpp | 12 ++++++ editor/libeditor/html/nsHTMLEditor.h | 1 + editor/libeditor/html/nsIHTMLEditRules.h | 1 + editor/public/nsIHTMLEditor.h | 15 +++++++ 16 files changed, 163 insertions(+), 50 deletions(-) diff --git a/editor/base/nsEditorShell.cpp b/editor/base/nsEditorShell.cpp index b43c2942f1b..fe7279e3cff 100644 --- a/editor/base/nsEditorShell.cpp +++ b/editor/base/nsEditorShell.cpp @@ -1233,6 +1233,34 @@ nsEditorShell::GetListItemState(PRBool *aMixed, PRUnichar **_retval) return err; } +NS_IMETHODIMP +nsEditorShell::GetAlignment(PRBool *aMixed, PRUnichar **_retval) +{ + if (!aMixed || !_retval) return NS_ERROR_NULL_POINTER; + *_retval = nsnull; + *aMixed = PR_FALSE; + + nsresult err = NS_NOINTERFACE; + nsCOMPtr htmlEditor = do_QueryInterface(mEditor); + if (htmlEditor) + { + nsIHTMLEditor::EAlignment firstAlign; + err = htmlEditor->GetAlignment(*aMixed, firstAlign); + if (NS_SUCCEEDED(err)) + { + nsAutoString tagStr; + if (firstAlign == nsIHTMLEditor::eLeft) + tagStr.AssignWithConversion("left"); + else if (firstAlign == nsIHTMLEditor::eCenter) + tagStr.AssignWithConversion("center"); + else if (firstAlign == nsIHTMLEditor::eRight) + tagStr.AssignWithConversion("right"); + *_retval = tagStr.ToNewUnicode(); + } + } + return err; +} + NS_IMETHODIMP nsEditorShell::ApplyStyleSheet(const PRUnichar *url) { diff --git a/editor/base/nsEditorShell.h b/editor/base/nsEditorShell.h index 00278221a41..bf52d1fe596 100644 --- a/editor/base/nsEditorShell.h +++ b/editor/base/nsEditorShell.h @@ -80,7 +80,7 @@ class nsEditorShell : public nsIEditorShell, { public: - // These must map onto the button-order for nsICommonDialog::Confirm results + // These must map onto the button-order for nsICommonDialog::Confirm results // which are rather ugly right now (Cancel in the middle!) typedef enum {eYes = 0, eCancel = 1, eNo = 2 } EConfirmResult; @@ -100,30 +100,30 @@ class nsEditorShell : public nsIEditorShell, protected: - typedef enum { - eUninitializedEditorType = 0, - ePlainTextEditorType = 1, - eHTMLTextEditorType = 2 - } EEditorType; + typedef enum { + eUninitializedEditorType = 0, + ePlainTextEditorType = 1, + eHTMLTextEditorType = 2 + } EEditorType; - typedef enum { + typedef enum { eCantEditNoReason = 0, eCantEditFramesets = 1, eCantEditMimeType = 2, eCantEditOther = 3 - } ECantEditReason; - - nsresult DoEditorMode(nsIDocShell *aDocShell); + } ECantEditReason; + + nsresult DoEditorMode(nsIDocShell *aDocShell); // nuke any existing editor in the editorShell, thus preparing it to edit // a(nother) document. nsresult ResetEditingState(); - nsresult InstantiateEditor(nsIDOMDocument *aDoc, nsIPresShell *aPresShell); - nsresult PrepareDocumentForEditing(nsIDocumentLoader* aLoader, nsIURI *aUrl); - nsresult ScrollSelectionIntoView(); + nsresult InstantiateEditor(nsIDOMDocument *aDoc, nsIPresShell *aPresShell); + nsresult PrepareDocumentForEditing(nsIDocumentLoader* aLoader, nsIURI *aUrl); + nsresult ScrollSelectionIntoView(); nsresult TransferDocumentStateListeners(); - nsresult RemoveOneProperty(const nsString& aProp, const nsString& aAttr); - nsresult DoFind(PRBool aFindNext); + nsresult RemoveOneProperty(const nsString& aProp, const nsString& aAttr); + nsresult DoFind(PRBool aFindNext); // To allow executing JavaScript commands from C++ via nsIEditorControler interface nsresult DoControllerCommand(nsString& aCommand); @@ -136,8 +136,8 @@ class nsEditorShell : public nsIEditorShell, EConfirmResult ConfirmWithCancel(const nsString& aTitle, const nsString& aQuestion, const nsString *aYesString, const nsString *aNoString); - // this returns an AddReffed nsIScriptContext. You must relase it. - nsIScriptContext* GetScriptContext(nsIDOMWindow * aWin); + // this returns an AddReffed nsIScriptContext. You must relase it. + nsIScriptContext* GetScriptContext(nsIDOMWindow * aWin); // Get a string from the string bundle file void GetBundleString(const nsString& name, nsString &outString); @@ -161,7 +161,7 @@ class nsEditorShell : public nsIEditorShell, // fix rowspan, colspan, and missing cells problems nsresult CheckPrefAndNormalizeTable(); - nsCOMPtr mEditor; // this can be either an HTML or plain text (or other?) editor + nsCOMPtr mEditor; // this can be either an HTML or plain text (or other?) editor nsCOMPtr mSearchContext; // context used for search and replace. Owned by the appshell. nsCOMPtr mSpellChecker; @@ -176,7 +176,7 @@ class nsEditorShell : public nsIEditorShell, // These doc listeners are registered with the editor when that gets // created. We also keep them in this list so we can register if we have // to blow away the editor (e.g. URL reload) - nsCOMPtr mDocStateListeners; // contents are nsISupports + nsCOMPtr mDocStateListeners; // contents are nsISupports // Pointer to localized strings used for UI nsCOMPtr mStringBundle; @@ -197,26 +197,26 @@ class nsEditorShell : public nsIEditorShell, // so we need to track it separately PRBool mHTMLSourceMode; - nsIDOMWindow *mWebShellWindow; // weak reference - //nsIDOMWindow *mContentWindow; // weak reference + nsIDOMWindow *mWebShellWindow; // weak reference + //nsIDOMWindow *mContentWindow; // weak reference nsWeakPtr mContentWindow; // weak reference nsEditorParserObserver *mParserObserver; // we hold the owning ref to this. nsInterfaceState *mStateMaintainer; // we hold the owning ref to this. nsIEditorController *mEditorController; // temporary weak ref to the editor controller - nsIDocShell *mDocShell; // weak reference + nsIDocShell *mDocShell; // weak reference // The webshell that contains the document being edited. // Don't assume that webshell directly contains the document being edited; // if we are in a frameset, this assumption is false. - nsIDocShell *mContentAreaDocShell; // weak reference + nsIDocShell *mContentAreaDocShell; // weak reference PRPackedBool mCloseWindowWhenLoaded; // error on load. Close window when loaded ECantEditReason mCantEditReason; - EEditorType mEditorType; - nsString mEditorTypeString; // string which describes which editor type will be instantiated (lowercased) + EEditorType mEditorType; + nsString mEditorTypeString; // string which describes which editor type will be instantiated (lowercased) PRInt32 mWrapColumn; // can't actually set this 'til the editor is created, so we may have to hold on to it for a while nsStringArray mSuggestedWordList; diff --git a/editor/base/nsHTMLEditRules.cpp b/editor/base/nsHTMLEditRules.cpp index b5874f53585..c68b659cf7d 100644 --- a/editor/base/nsHTMLEditRules.cpp +++ b/editor/base/nsHTMLEditRules.cpp @@ -455,6 +455,11 @@ nsHTMLEditRules::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBo return res; } +NS_IMETHODIMP +nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} NS_IMETHODIMP nsHTMLEditRules::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent) diff --git a/editor/base/nsHTMLEditRules.h b/editor/base/nsHTMLEditRules.h index af551bb2ea4..e651bb6b281 100644 --- a/editor/base/nsHTMLEditRules.h +++ b/editor/base/nsHTMLEditRules.h @@ -56,6 +56,7 @@ public: NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL); NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD); NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent); + NS_IMETHOD GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign); NS_IMETHOD GetParagraphState(PRBool &aMixed, nsString &outFormat); // nsIEditActionListener methods diff --git a/editor/base/nsHTMLEditor.cpp b/editor/base/nsHTMLEditor.cpp index 67554518b3d..98290817290 100644 --- a/editor/base/nsHTMLEditor.cpp +++ b/editor/base/nsHTMLEditor.cpp @@ -3082,6 +3082,18 @@ nsHTMLEditor::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool return htmlRules->GetListItemState(aMixed, aLI, aDT, aDD); } +NS_IMETHODIMP +nsHTMLEditor::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign) +{ + if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } + + nsCOMPtr htmlRules = do_QueryInterface(mRules); + if (!htmlRules) return NS_ERROR_FAILURE; + + return htmlRules->GetAlignment(aMixed, aAlign); +} + + NS_IMETHODIMP nsHTMLEditor::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent) { diff --git a/editor/base/nsHTMLEditor.h b/editor/base/nsHTMLEditor.h index cd5fc5913a3..eb245fcb50f 100644 --- a/editor/base/nsHTMLEditor.h +++ b/editor/base/nsHTMLEditor.h @@ -138,6 +138,7 @@ public: NS_IMETHOD GetFontFaceState(PRBool &aMixed, nsString &outFace); NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL); NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD); + NS_IMETHOD GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign); NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent); NS_IMETHOD MakeOrChangeList(const nsString& aListType); diff --git a/editor/base/nsIHTMLEditRules.h b/editor/base/nsIHTMLEditRules.h index 092a8dfe127..f01abd3b109 100644 --- a/editor/base/nsIHTMLEditRules.h +++ b/editor/base/nsIHTMLEditRules.h @@ -36,6 +36,7 @@ public: NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL)=0; NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD)=0; NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)=0; + NS_IMETHOD GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)=0; NS_IMETHOD GetParagraphState(PRBool &aMixed, nsString &outFormat)=0; }; diff --git a/editor/composer/src/nsEditorShell.cpp b/editor/composer/src/nsEditorShell.cpp index b43c2942f1b..fe7279e3cff 100644 --- a/editor/composer/src/nsEditorShell.cpp +++ b/editor/composer/src/nsEditorShell.cpp @@ -1233,6 +1233,34 @@ nsEditorShell::GetListItemState(PRBool *aMixed, PRUnichar **_retval) return err; } +NS_IMETHODIMP +nsEditorShell::GetAlignment(PRBool *aMixed, PRUnichar **_retval) +{ + if (!aMixed || !_retval) return NS_ERROR_NULL_POINTER; + *_retval = nsnull; + *aMixed = PR_FALSE; + + nsresult err = NS_NOINTERFACE; + nsCOMPtr htmlEditor = do_QueryInterface(mEditor); + if (htmlEditor) + { + nsIHTMLEditor::EAlignment firstAlign; + err = htmlEditor->GetAlignment(*aMixed, firstAlign); + if (NS_SUCCEEDED(err)) + { + nsAutoString tagStr; + if (firstAlign == nsIHTMLEditor::eLeft) + tagStr.AssignWithConversion("left"); + else if (firstAlign == nsIHTMLEditor::eCenter) + tagStr.AssignWithConversion("center"); + else if (firstAlign == nsIHTMLEditor::eRight) + tagStr.AssignWithConversion("right"); + *_retval = tagStr.ToNewUnicode(); + } + } + return err; +} + NS_IMETHODIMP nsEditorShell::ApplyStyleSheet(const PRUnichar *url) { diff --git a/editor/composer/src/nsEditorShell.h b/editor/composer/src/nsEditorShell.h index 00278221a41..bf52d1fe596 100644 --- a/editor/composer/src/nsEditorShell.h +++ b/editor/composer/src/nsEditorShell.h @@ -80,7 +80,7 @@ class nsEditorShell : public nsIEditorShell, { public: - // These must map onto the button-order for nsICommonDialog::Confirm results + // These must map onto the button-order for nsICommonDialog::Confirm results // which are rather ugly right now (Cancel in the middle!) typedef enum {eYes = 0, eCancel = 1, eNo = 2 } EConfirmResult; @@ -100,30 +100,30 @@ class nsEditorShell : public nsIEditorShell, protected: - typedef enum { - eUninitializedEditorType = 0, - ePlainTextEditorType = 1, - eHTMLTextEditorType = 2 - } EEditorType; + typedef enum { + eUninitializedEditorType = 0, + ePlainTextEditorType = 1, + eHTMLTextEditorType = 2 + } EEditorType; - typedef enum { + typedef enum { eCantEditNoReason = 0, eCantEditFramesets = 1, eCantEditMimeType = 2, eCantEditOther = 3 - } ECantEditReason; - - nsresult DoEditorMode(nsIDocShell *aDocShell); + } ECantEditReason; + + nsresult DoEditorMode(nsIDocShell *aDocShell); // nuke any existing editor in the editorShell, thus preparing it to edit // a(nother) document. nsresult ResetEditingState(); - nsresult InstantiateEditor(nsIDOMDocument *aDoc, nsIPresShell *aPresShell); - nsresult PrepareDocumentForEditing(nsIDocumentLoader* aLoader, nsIURI *aUrl); - nsresult ScrollSelectionIntoView(); + nsresult InstantiateEditor(nsIDOMDocument *aDoc, nsIPresShell *aPresShell); + nsresult PrepareDocumentForEditing(nsIDocumentLoader* aLoader, nsIURI *aUrl); + nsresult ScrollSelectionIntoView(); nsresult TransferDocumentStateListeners(); - nsresult RemoveOneProperty(const nsString& aProp, const nsString& aAttr); - nsresult DoFind(PRBool aFindNext); + nsresult RemoveOneProperty(const nsString& aProp, const nsString& aAttr); + nsresult DoFind(PRBool aFindNext); // To allow executing JavaScript commands from C++ via nsIEditorControler interface nsresult DoControllerCommand(nsString& aCommand); @@ -136,8 +136,8 @@ class nsEditorShell : public nsIEditorShell, EConfirmResult ConfirmWithCancel(const nsString& aTitle, const nsString& aQuestion, const nsString *aYesString, const nsString *aNoString); - // this returns an AddReffed nsIScriptContext. You must relase it. - nsIScriptContext* GetScriptContext(nsIDOMWindow * aWin); + // this returns an AddReffed nsIScriptContext. You must relase it. + nsIScriptContext* GetScriptContext(nsIDOMWindow * aWin); // Get a string from the string bundle file void GetBundleString(const nsString& name, nsString &outString); @@ -161,7 +161,7 @@ class nsEditorShell : public nsIEditorShell, // fix rowspan, colspan, and missing cells problems nsresult CheckPrefAndNormalizeTable(); - nsCOMPtr mEditor; // this can be either an HTML or plain text (or other?) editor + nsCOMPtr mEditor; // this can be either an HTML or plain text (or other?) editor nsCOMPtr mSearchContext; // context used for search and replace. Owned by the appshell. nsCOMPtr mSpellChecker; @@ -176,7 +176,7 @@ class nsEditorShell : public nsIEditorShell, // These doc listeners are registered with the editor when that gets // created. We also keep them in this list so we can register if we have // to blow away the editor (e.g. URL reload) - nsCOMPtr mDocStateListeners; // contents are nsISupports + nsCOMPtr mDocStateListeners; // contents are nsISupports // Pointer to localized strings used for UI nsCOMPtr mStringBundle; @@ -197,26 +197,26 @@ class nsEditorShell : public nsIEditorShell, // so we need to track it separately PRBool mHTMLSourceMode; - nsIDOMWindow *mWebShellWindow; // weak reference - //nsIDOMWindow *mContentWindow; // weak reference + nsIDOMWindow *mWebShellWindow; // weak reference + //nsIDOMWindow *mContentWindow; // weak reference nsWeakPtr mContentWindow; // weak reference nsEditorParserObserver *mParserObserver; // we hold the owning ref to this. nsInterfaceState *mStateMaintainer; // we hold the owning ref to this. nsIEditorController *mEditorController; // temporary weak ref to the editor controller - nsIDocShell *mDocShell; // weak reference + nsIDocShell *mDocShell; // weak reference // The webshell that contains the document being edited. // Don't assume that webshell directly contains the document being edited; // if we are in a frameset, this assumption is false. - nsIDocShell *mContentAreaDocShell; // weak reference + nsIDocShell *mContentAreaDocShell; // weak reference PRPackedBool mCloseWindowWhenLoaded; // error on load. Close window when loaded ECantEditReason mCantEditReason; - EEditorType mEditorType; - nsString mEditorTypeString; // string which describes which editor type will be instantiated (lowercased) + EEditorType mEditorType; + nsString mEditorTypeString; // string which describes which editor type will be instantiated (lowercased) PRInt32 mWrapColumn; // can't actually set this 'til the editor is created, so we may have to hold on to it for a while nsStringArray mSuggestedWordList; diff --git a/editor/idl/nsIEditorShell.idl b/editor/idl/nsIEditorShell.idl index a4472f0ad4e..b9d419074f1 100644 --- a/editor/idl/nsIEditorShell.idl +++ b/editor/idl/nsIEditorShell.idl @@ -531,6 +531,8 @@ interface nsIEditorShell : nsISupports wstring GetListState(out boolean mixed); /* Returns "li", "dt", or "dd" */ wstring GetListItemState(out boolean mixed); + /* Returns "left", "center", or "right" */ + wstring GetAlignment(out boolean mixed); void ApplyStyleSheet(in wstring url); diff --git a/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp index b5874f53585..c68b659cf7d 100644 --- a/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/editor/libeditor/html/nsHTMLEditRules.cpp @@ -455,6 +455,11 @@ nsHTMLEditRules::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBo return res; } +NS_IMETHODIMP +nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} NS_IMETHODIMP nsHTMLEditRules::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent) diff --git a/editor/libeditor/html/nsHTMLEditRules.h b/editor/libeditor/html/nsHTMLEditRules.h index af551bb2ea4..e651bb6b281 100644 --- a/editor/libeditor/html/nsHTMLEditRules.h +++ b/editor/libeditor/html/nsHTMLEditRules.h @@ -56,6 +56,7 @@ public: NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL); NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD); NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent); + NS_IMETHOD GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign); NS_IMETHOD GetParagraphState(PRBool &aMixed, nsString &outFormat); // nsIEditActionListener methods diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp index 67554518b3d..98290817290 100644 --- a/editor/libeditor/html/nsHTMLEditor.cpp +++ b/editor/libeditor/html/nsHTMLEditor.cpp @@ -3082,6 +3082,18 @@ nsHTMLEditor::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool return htmlRules->GetListItemState(aMixed, aLI, aDT, aDD); } +NS_IMETHODIMP +nsHTMLEditor::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign) +{ + if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } + + nsCOMPtr htmlRules = do_QueryInterface(mRules); + if (!htmlRules) return NS_ERROR_FAILURE; + + return htmlRules->GetAlignment(aMixed, aAlign); +} + + NS_IMETHODIMP nsHTMLEditor::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent) { diff --git a/editor/libeditor/html/nsHTMLEditor.h b/editor/libeditor/html/nsHTMLEditor.h index cd5fc5913a3..eb245fcb50f 100644 --- a/editor/libeditor/html/nsHTMLEditor.h +++ b/editor/libeditor/html/nsHTMLEditor.h @@ -138,6 +138,7 @@ public: NS_IMETHOD GetFontFaceState(PRBool &aMixed, nsString &outFace); NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL); NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD); + NS_IMETHOD GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign); NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent); NS_IMETHOD MakeOrChangeList(const nsString& aListType); diff --git a/editor/libeditor/html/nsIHTMLEditRules.h b/editor/libeditor/html/nsIHTMLEditRules.h index 092a8dfe127..f01abd3b109 100644 --- a/editor/libeditor/html/nsIHTMLEditRules.h +++ b/editor/libeditor/html/nsIHTMLEditRules.h @@ -36,6 +36,7 @@ public: NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL)=0; NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD)=0; NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)=0; + NS_IMETHOD GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)=0; NS_IMETHOD GetParagraphState(PRBool &aMixed, nsString &outFormat)=0; }; diff --git a/editor/public/nsIHTMLEditor.h b/editor/public/nsIHTMLEditor.h index d6c61488848..32ea84bb721 100644 --- a/editor/public/nsIHTMLEditor.h +++ b/editor/public/nsIHTMLEditor.h @@ -83,6 +83,13 @@ public: eTypedBreak // user typed enter }; + // used by GetAlignment() + typedef enum { + eLeft, + eCenter, + eRight + } EAlignment; + /* ------------ Document info methods -------------- */ /** get the length of the document in characters */ @@ -334,6 +341,14 @@ public: */ NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD)=0; + /** + * GetAlignment returns what alignment is in the selection. + * @param aMixed True if there is more than one type of list item, or + * if there is some list and non-list + * @param aAlign enum value for first encountered alignment (left/center/right) + */ + NS_IMETHOD GetAlignment(PRBool &aMixed, EAlignment &aAlign)=0; + /** * Document me! *