зеркало из https://github.com/mozilla/pjs.git
groundwork for 44684: adding a "GetAlignment" call to the editor so that ui can reflect alignment of selection
This commit is contained in:
Родитель
feb7dd02ea
Коммит
008d4be4c9
|
@ -1233,6 +1233,34 @@ nsEditorShell::GetListItemState(PRBool *aMixed, PRUnichar **_retval)
|
||||||
return err;
|
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<nsIHTMLEditor> 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
|
NS_IMETHODIMP
|
||||||
nsEditorShell::ApplyStyleSheet(const PRUnichar *url)
|
nsEditorShell::ApplyStyleSheet(const PRUnichar *url)
|
||||||
{
|
{
|
||||||
|
|
|
@ -455,6 +455,11 @@ nsHTMLEditRules::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBo
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
|
||||||
|
{
|
||||||
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsHTMLEditRules::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
|
nsHTMLEditRules::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
|
||||||
|
|
|
@ -56,6 +56,7 @@ public:
|
||||||
NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL);
|
NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL);
|
||||||
NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD);
|
NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD);
|
||||||
NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent);
|
NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent);
|
||||||
|
NS_IMETHOD GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign);
|
||||||
NS_IMETHOD GetParagraphState(PRBool &aMixed, nsString &outFormat);
|
NS_IMETHOD GetParagraphState(PRBool &aMixed, nsString &outFormat);
|
||||||
|
|
||||||
// nsIEditActionListener methods
|
// nsIEditActionListener methods
|
||||||
|
|
|
@ -3082,6 +3082,18 @@ nsHTMLEditor::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool
|
||||||
return htmlRules->GetListItemState(aMixed, aLI, aDT, aDD);
|
return htmlRules->GetListItemState(aMixed, aLI, aDT, aDD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsHTMLEditor::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
|
||||||
|
{
|
||||||
|
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
|
||||||
|
|
||||||
|
nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules);
|
||||||
|
if (!htmlRules) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
return htmlRules->GetAlignment(aMixed, aAlign);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsHTMLEditor::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
|
nsHTMLEditor::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -138,6 +138,7 @@ public:
|
||||||
NS_IMETHOD GetFontFaceState(PRBool &aMixed, nsString &outFace);
|
NS_IMETHOD GetFontFaceState(PRBool &aMixed, nsString &outFace);
|
||||||
NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL);
|
NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL);
|
||||||
NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD);
|
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 GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent);
|
||||||
|
|
||||||
NS_IMETHOD MakeOrChangeList(const nsString& aListType);
|
NS_IMETHOD MakeOrChangeList(const nsString& aListType);
|
||||||
|
|
|
@ -36,6 +36,7 @@ public:
|
||||||
NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL)=0;
|
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 GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD)=0;
|
||||||
NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)=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;
|
NS_IMETHOD GetParagraphState(PRBool &aMixed, nsString &outFormat)=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1233,6 +1233,34 @@ nsEditorShell::GetListItemState(PRBool *aMixed, PRUnichar **_retval)
|
||||||
return err;
|
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<nsIHTMLEditor> 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
|
NS_IMETHODIMP
|
||||||
nsEditorShell::ApplyStyleSheet(const PRUnichar *url)
|
nsEditorShell::ApplyStyleSheet(const PRUnichar *url)
|
||||||
{
|
{
|
||||||
|
|
|
@ -531,6 +531,8 @@ interface nsIEditorShell : nsISupports
|
||||||
wstring GetListState(out boolean mixed);
|
wstring GetListState(out boolean mixed);
|
||||||
/* Returns "li", "dt", or "dd" */
|
/* Returns "li", "dt", or "dd" */
|
||||||
wstring GetListItemState(out boolean mixed);
|
wstring GetListItemState(out boolean mixed);
|
||||||
|
/* Returns "left", "center", or "right" */
|
||||||
|
wstring GetAlignment(out boolean mixed);
|
||||||
|
|
||||||
void ApplyStyleSheet(in wstring url);
|
void ApplyStyleSheet(in wstring url);
|
||||||
|
|
||||||
|
|
|
@ -455,6 +455,11 @@ nsHTMLEditRules::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBo
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
|
||||||
|
{
|
||||||
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsHTMLEditRules::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
|
nsHTMLEditRules::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
|
||||||
|
|
|
@ -56,6 +56,7 @@ public:
|
||||||
NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL);
|
NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL);
|
||||||
NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD);
|
NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD);
|
||||||
NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent);
|
NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent);
|
||||||
|
NS_IMETHOD GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign);
|
||||||
NS_IMETHOD GetParagraphState(PRBool &aMixed, nsString &outFormat);
|
NS_IMETHOD GetParagraphState(PRBool &aMixed, nsString &outFormat);
|
||||||
|
|
||||||
// nsIEditActionListener methods
|
// nsIEditActionListener methods
|
||||||
|
|
|
@ -3082,6 +3082,18 @@ nsHTMLEditor::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool
|
||||||
return htmlRules->GetListItemState(aMixed, aLI, aDT, aDD);
|
return htmlRules->GetListItemState(aMixed, aLI, aDT, aDD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsHTMLEditor::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
|
||||||
|
{
|
||||||
|
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
|
||||||
|
|
||||||
|
nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules);
|
||||||
|
if (!htmlRules) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
return htmlRules->GetAlignment(aMixed, aAlign);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsHTMLEditor::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
|
nsHTMLEditor::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -138,6 +138,7 @@ public:
|
||||||
NS_IMETHOD GetFontFaceState(PRBool &aMixed, nsString &outFace);
|
NS_IMETHOD GetFontFaceState(PRBool &aMixed, nsString &outFace);
|
||||||
NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL);
|
NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL);
|
||||||
NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD);
|
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 GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent);
|
||||||
|
|
||||||
NS_IMETHOD MakeOrChangeList(const nsString& aListType);
|
NS_IMETHOD MakeOrChangeList(const nsString& aListType);
|
||||||
|
|
|
@ -36,6 +36,7 @@ public:
|
||||||
NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL)=0;
|
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 GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD)=0;
|
||||||
NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)=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;
|
NS_IMETHOD GetParagraphState(PRBool &aMixed, nsString &outFormat)=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,13 @@ public:
|
||||||
eTypedBreak // user typed enter
|
eTypedBreak // user typed enter
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// used by GetAlignment()
|
||||||
|
typedef enum {
|
||||||
|
eLeft,
|
||||||
|
eCenter,
|
||||||
|
eRight
|
||||||
|
} EAlignment;
|
||||||
|
|
||||||
/* ------------ Document info methods -------------- */
|
/* ------------ Document info methods -------------- */
|
||||||
|
|
||||||
/** get the length of the document in characters */
|
/** 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;
|
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!
|
* Document me!
|
||||||
*
|
*
|
||||||
|
|
Загрузка…
Ссылка в новой задаче