Add GetEmbeddedObjects API to editor shell
git-svn-id: svn://10.0.0.236/trunk@40174 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
e89333b098
commit
3f8e57acfe
@ -2026,6 +2026,30 @@ nsEditorShell::SetSelectionAfterElement(nsIDOMElement* aElement)
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::GetEmbeddedObjects(nsISupportsArray **aObjectArray)
|
||||
{
|
||||
if (!aObjectArray)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult result;
|
||||
|
||||
switch (mEditorType)
|
||||
{
|
||||
case eHTMLTextEditorType:
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
result = htmlEditor->GetEmbeddedObjects(aObjectArray);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
result = NS_NOINTERFACE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::StartSpellChecking(PRUnichar **aFirstMisspelledWord)
|
||||
{
|
||||
|
||||
@ -52,7 +52,7 @@ class nsIPresShell;
|
||||
class nsIHTMLEditor;
|
||||
class nsITextEditor;
|
||||
class nsIOutputStream;
|
||||
|
||||
class nsISupportsArray;
|
||||
|
||||
|
||||
#define NS_EDITORAPPCORE_CID \
|
||||
@ -147,7 +147,10 @@ class nsEditorShell : public nsIEditorShell,
|
||||
NS_IMETHOD SelectElement(nsIDOMElement *element);
|
||||
NS_IMETHOD SetSelectionAfterElement(nsIDOMElement *element);
|
||||
|
||||
/* void SetParagraphFormat (in string value); */
|
||||
/* Get list of embedded objects, e.g. for mail compose */
|
||||
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray **aObjectArray);
|
||||
|
||||
/* void SetParagraphFormat (in string value); */
|
||||
NS_IMETHOD SetParagraphFormat(PRUnichar *value);
|
||||
NS_IMETHOD GetParagraphFormat(PRUnichar * *aParagraphFormat);
|
||||
|
||||
@ -249,12 +252,12 @@ class nsEditorShell : public nsIEditorShell,
|
||||
#endif // NECKO
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsISpellChecker> mSpellChecker;
|
||||
nsStringArray mSuggestedWordList;
|
||||
PRInt32 mSuggestedWordIndex;
|
||||
NS_IMETHOD DeleteSuggestedWordList();
|
||||
nsStringArray mDictionaryList;
|
||||
PRInt32 mDictionaryIndex;
|
||||
nsIDOMWindow *mToolbarWindow; // weak reference
|
||||
nsIDOMWindow *mContentWindow; // weak reference
|
||||
|
||||
nsIWebShellWindow *mWebShellWin; // weak reference
|
||||
nsIWebShell *mWebShell; // weak reference
|
||||
nsIWebShell *mContentAreaWebShell; // weak reference
|
||||
|
||||
typedef enum {
|
||||
eUninitializedEditorType = 0,
|
||||
@ -278,13 +281,6 @@ class nsEditorShell : public nsIEditorShell,
|
||||
nsString mEnableScript;
|
||||
nsString mDisableScript;
|
||||
|
||||
nsIDOMWindow *mToolbarWindow; // weak reference
|
||||
nsIDOMWindow *mContentWindow; // weak reference
|
||||
|
||||
nsIWebShellWindow *mWebShellWin; // weak reference
|
||||
nsIWebShell *mWebShell; // weak reference
|
||||
nsIWebShell *mContentAreaWebShell; // weak reference
|
||||
|
||||
EEditorType mEditorType;
|
||||
nsString mEditorTypeString; // string which describes which editor type will be instantiated (lowercased)
|
||||
nsCOMPtr<nsISupports> mEditor; // this can be either an HTML or plain text (or other?) editor
|
||||
@ -296,6 +292,13 @@ class nsEditorShell : public nsIEditorShell,
|
||||
#endif
|
||||
|
||||
PRInt32 mWrapColumn; // can't actually set this 'til the editor is created, so we may have to hold on to it for a while
|
||||
|
||||
nsCOMPtr<nsISpellChecker> mSpellChecker;
|
||||
nsStringArray mSuggestedWordList;
|
||||
PRInt32 mSuggestedWordIndex;
|
||||
NS_IMETHOD DeleteSuggestedWordList();
|
||||
nsStringArray mDictionaryList;
|
||||
PRInt32 mDictionaryIndex;
|
||||
};
|
||||
|
||||
#endif // nsEditorAppCore_h___
|
||||
|
||||
@ -2685,7 +2685,7 @@ nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray* aNodeList)
|
||||
nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
|
||||
{
|
||||
if (!aNodeList)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
@ -2695,9 +2695,10 @@ nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray* aNodeList)
|
||||
#else
|
||||
nsresult res;
|
||||
|
||||
res = NS_NewISupportsArray(&aNodeList);
|
||||
if (NS_FAILED(res))
|
||||
res = NS_NewISupportsArray(aNodeList);
|
||||
if (NS_FAILED(res) || !*aNodeList)
|
||||
return res;
|
||||
//NS_ADDREF(*aNodeList);
|
||||
|
||||
nsCOMPtr<nsIContentIterator> iter;
|
||||
res = nsComponentManager::CreateInstance(kCContentIteratorCID, nsnull,
|
||||
@ -2722,11 +2723,12 @@ nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray* aNodeList)
|
||||
iter->Init(rootContent);
|
||||
|
||||
// loop through the content iterator for each content node
|
||||
nsCOMPtr<nsIContent> content;
|
||||
res = iter->CurrentNode(getter_AddRefs(content));
|
||||
|
||||
while (NS_COMFALSE == iter->IsDone())
|
||||
{
|
||||
nsCOMPtr<nsIContent> content;
|
||||
res = iter->CurrentNode(getter_AddRefs(content));
|
||||
if (NS_FAILED(res))
|
||||
break;
|
||||
nsCOMPtr<nsIDOMNode> node (do_QueryInterface(content));
|
||||
if (node)
|
||||
{
|
||||
@ -2736,7 +2738,11 @@ nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray* aNodeList)
|
||||
|
||||
// See if it's an image or an embed
|
||||
if (tagName == "img" || tagName == "embed")
|
||||
aNodeList->AppendElement(node);
|
||||
(*aNodeList)->AppendElement(node);
|
||||
else if (tagName == "a")
|
||||
{
|
||||
// XXX Only include links if they're links to file: URLs
|
||||
}
|
||||
}
|
||||
iter->Next();
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ public:
|
||||
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement);
|
||||
|
||||
// MHTML helper methods
|
||||
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray* aNodeList);
|
||||
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList);
|
||||
|
||||
// Table Editing (implemented in EditTable.cpp)
|
||||
NS_IMETHOD CreateTxnForInsertTable(const nsIDOMElement *aTableNode, InsertTableTxn ** aTxn);
|
||||
|
||||
@ -761,7 +761,7 @@ nsJSEditorLog::SetCaretAfterElement(nsIDOMElement* aElement)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJSEditorLog::GetEmbeddedObjects(nsISupportsArray* aNodeList)
|
||||
nsJSEditorLog::GetEmbeddedObjects(nsISupportsArray** aNodeList)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ public:
|
||||
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
|
||||
NS_IMETHOD SelectElement(nsIDOMElement* aElement);
|
||||
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement);
|
||||
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray* aNodeList);
|
||||
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList);
|
||||
NS_IMETHOD InsertTable();
|
||||
NS_IMETHOD InsertTableCell(PRInt32 aNumber, PRBool aAfter);
|
||||
NS_IMETHOD InsertTableColumn(PRInt32 aNumber, PRBool aAfter);
|
||||
|
||||
@ -2026,6 +2026,30 @@ nsEditorShell::SetSelectionAfterElement(nsIDOMElement* aElement)
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::GetEmbeddedObjects(nsISupportsArray **aObjectArray)
|
||||
{
|
||||
if (!aObjectArray)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult result;
|
||||
|
||||
switch (mEditorType)
|
||||
{
|
||||
case eHTMLTextEditorType:
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
result = htmlEditor->GetEmbeddedObjects(aObjectArray);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
result = NS_NOINTERFACE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::StartSpellChecking(PRUnichar **aFirstMisspelledWord)
|
||||
{
|
||||
|
||||
@ -52,7 +52,7 @@ class nsIPresShell;
|
||||
class nsIHTMLEditor;
|
||||
class nsITextEditor;
|
||||
class nsIOutputStream;
|
||||
|
||||
class nsISupportsArray;
|
||||
|
||||
|
||||
#define NS_EDITORAPPCORE_CID \
|
||||
@ -147,7 +147,10 @@ class nsEditorShell : public nsIEditorShell,
|
||||
NS_IMETHOD SelectElement(nsIDOMElement *element);
|
||||
NS_IMETHOD SetSelectionAfterElement(nsIDOMElement *element);
|
||||
|
||||
/* void SetParagraphFormat (in string value); */
|
||||
/* Get list of embedded objects, e.g. for mail compose */
|
||||
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray **aObjectArray);
|
||||
|
||||
/* void SetParagraphFormat (in string value); */
|
||||
NS_IMETHOD SetParagraphFormat(PRUnichar *value);
|
||||
NS_IMETHOD GetParagraphFormat(PRUnichar * *aParagraphFormat);
|
||||
|
||||
@ -249,12 +252,12 @@ class nsEditorShell : public nsIEditorShell,
|
||||
#endif // NECKO
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsISpellChecker> mSpellChecker;
|
||||
nsStringArray mSuggestedWordList;
|
||||
PRInt32 mSuggestedWordIndex;
|
||||
NS_IMETHOD DeleteSuggestedWordList();
|
||||
nsStringArray mDictionaryList;
|
||||
PRInt32 mDictionaryIndex;
|
||||
nsIDOMWindow *mToolbarWindow; // weak reference
|
||||
nsIDOMWindow *mContentWindow; // weak reference
|
||||
|
||||
nsIWebShellWindow *mWebShellWin; // weak reference
|
||||
nsIWebShell *mWebShell; // weak reference
|
||||
nsIWebShell *mContentAreaWebShell; // weak reference
|
||||
|
||||
typedef enum {
|
||||
eUninitializedEditorType = 0,
|
||||
@ -278,13 +281,6 @@ class nsEditorShell : public nsIEditorShell,
|
||||
nsString mEnableScript;
|
||||
nsString mDisableScript;
|
||||
|
||||
nsIDOMWindow *mToolbarWindow; // weak reference
|
||||
nsIDOMWindow *mContentWindow; // weak reference
|
||||
|
||||
nsIWebShellWindow *mWebShellWin; // weak reference
|
||||
nsIWebShell *mWebShell; // weak reference
|
||||
nsIWebShell *mContentAreaWebShell; // weak reference
|
||||
|
||||
EEditorType mEditorType;
|
||||
nsString mEditorTypeString; // string which describes which editor type will be instantiated (lowercased)
|
||||
nsCOMPtr<nsISupports> mEditor; // this can be either an HTML or plain text (or other?) editor
|
||||
@ -296,6 +292,13 @@ class nsEditorShell : public nsIEditorShell,
|
||||
#endif
|
||||
|
||||
PRInt32 mWrapColumn; // can't actually set this 'til the editor is created, so we may have to hold on to it for a while
|
||||
|
||||
nsCOMPtr<nsISpellChecker> mSpellChecker;
|
||||
nsStringArray mSuggestedWordList;
|
||||
PRInt32 mSuggestedWordIndex;
|
||||
NS_IMETHOD DeleteSuggestedWordList();
|
||||
nsStringArray mDictionaryList;
|
||||
PRInt32 mDictionaryIndex;
|
||||
};
|
||||
|
||||
#endif // nsEditorAppCore_h___
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include "nsISupports.idl"
|
||||
#include "domstubs.idl"
|
||||
#include "nsIFileSpec.idl"
|
||||
#include "nsISupportsArray.idl"
|
||||
|
||||
%{C++
|
||||
|
||||
@ -104,6 +105,9 @@ interface nsIEditorShell : nsISupports
|
||||
void SelectElement(in nsIDOMElement element);
|
||||
void SetSelectionAfterElement(in nsIDOMElement element);
|
||||
|
||||
/* Get list of embedded objects, e.g. for mail compose */
|
||||
nsISupportsArray GetEmbeddedObjects();
|
||||
|
||||
/* Formatting */
|
||||
void SetTextProperty(in wstring prop, in wstring attr, in wstring value);
|
||||
void RemoveTextProperty(in wstring prop, in wstring attr);
|
||||
|
||||
@ -2685,7 +2685,7 @@ nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray* aNodeList)
|
||||
nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
|
||||
{
|
||||
if (!aNodeList)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
@ -2695,9 +2695,10 @@ nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray* aNodeList)
|
||||
#else
|
||||
nsresult res;
|
||||
|
||||
res = NS_NewISupportsArray(&aNodeList);
|
||||
if (NS_FAILED(res))
|
||||
res = NS_NewISupportsArray(aNodeList);
|
||||
if (NS_FAILED(res) || !*aNodeList)
|
||||
return res;
|
||||
//NS_ADDREF(*aNodeList);
|
||||
|
||||
nsCOMPtr<nsIContentIterator> iter;
|
||||
res = nsComponentManager::CreateInstance(kCContentIteratorCID, nsnull,
|
||||
@ -2722,11 +2723,12 @@ nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray* aNodeList)
|
||||
iter->Init(rootContent);
|
||||
|
||||
// loop through the content iterator for each content node
|
||||
nsCOMPtr<nsIContent> content;
|
||||
res = iter->CurrentNode(getter_AddRefs(content));
|
||||
|
||||
while (NS_COMFALSE == iter->IsDone())
|
||||
{
|
||||
nsCOMPtr<nsIContent> content;
|
||||
res = iter->CurrentNode(getter_AddRefs(content));
|
||||
if (NS_FAILED(res))
|
||||
break;
|
||||
nsCOMPtr<nsIDOMNode> node (do_QueryInterface(content));
|
||||
if (node)
|
||||
{
|
||||
@ -2736,7 +2738,11 @@ nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray* aNodeList)
|
||||
|
||||
// See if it's an image or an embed
|
||||
if (tagName == "img" || tagName == "embed")
|
||||
aNodeList->AppendElement(node);
|
||||
(*aNodeList)->AppendElement(node);
|
||||
else if (tagName == "a")
|
||||
{
|
||||
// XXX Only include links if they're links to file: URLs
|
||||
}
|
||||
}
|
||||
iter->Next();
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ public:
|
||||
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement);
|
||||
|
||||
// MHTML helper methods
|
||||
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray* aNodeList);
|
||||
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList);
|
||||
|
||||
// Table Editing (implemented in EditTable.cpp)
|
||||
NS_IMETHOD CreateTxnForInsertTable(const nsIDOMElement *aTableNode, InsertTableTxn ** aTxn);
|
||||
|
||||
@ -187,7 +187,7 @@ public:
|
||||
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement)=0;
|
||||
|
||||
// MHTML helper methods
|
||||
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray* aNodeList)=0;
|
||||
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList)=0;
|
||||
|
||||
// Table editing Methods
|
||||
NS_IMETHOD InsertTable()=0;
|
||||
|
||||
@ -190,6 +190,7 @@
|
||||
<!ENTITY outputXIFCmd.label "Output XIF">
|
||||
<!ENTITY insertTextCmd.label "Insert Text">
|
||||
<!ENTITY testSelectionCmd.label "Test Selection">
|
||||
<!ENTITY showEmbeddedCmd.label "Show Embedded Objects">
|
||||
<!ENTITY dumpContentCmd.label "Dump Content Tree">
|
||||
<!ENTITY testDocumentCmd.label "Test Document">
|
||||
<!ENTITY runUnitTestsCmd.label "Run Unit Tests">
|
||||
@ -481,6 +482,7 @@
|
||||
<menuitem name="&insertTextCmd.label;" onclick="EditorInsertText('All good things come to those who wait. ')"/>
|
||||
<separator />
|
||||
<menuitem name="&testSelectionCmd.label;" onclick="EditorTestSelection()"/>
|
||||
<menuitem name="&showEmbeddedCmd.label;" onclick="EditorShowEmbeddedObjects()"/>
|
||||
<menuitem name="&dumpContentCmd.label;" onclick="EditorDumpContent()"/>
|
||||
<menuitem name="&testDocumentCmd.label;" onclick="EditorTestDocument()"/>
|
||||
<menuitem name="&runUnitTestsCmd.label;" onclick="EditorUnitTests()"/>
|
||||
|
||||
@ -718,6 +718,13 @@ function EditorTestSelection()
|
||||
dump(output + "\n\n");
|
||||
}
|
||||
|
||||
function EditorShowEmbeddedObjects()
|
||||
{
|
||||
dump("\nEmbedded Objects:\n");
|
||||
var objectArray = editorShell.GetEmbeddedObjects();
|
||||
dump(objectArray.length + " embedded objects\n");
|
||||
}
|
||||
|
||||
function EditorUnitTests()
|
||||
{
|
||||
dump("Running Unit Tests\n");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user