Added editor methods for setting body attributes and background color. Removed getFirstMisspelled word - not needed

This commit is contained in:
cmanske%netscape.com 1999-05-26 21:40:34 +00:00
Родитель a0d6c05b37
Коммит 1047dca72f
5 изменённых файлов: 412 добавлений и 116 удалений

Просмотреть файл

@ -19,7 +19,11 @@ interface EditorAppCore : BaseAppCore
void setTextProperty(in DOMString prop, in DOMString attr, in DOMString value);
void removeTextProperty(in DOMString prop, in DOMString attr);
void getTextProperty(in DOMString prop, in DOMString attr, in DOMString value, out DOMString firstHas, out DOMString anyHas, out DOMString allHas);
void setBodyAttribute(in DOMString attr, in DOMString value);
void setBackgroundColor(in DOMString color);
DOMString getLocalFileURL(in Window parent, in DOMString filterType);
void setParagraphFormat(in DOMString value);
void loadUrl(in DOMString url);
@ -58,13 +62,14 @@ interface EditorAppCore : BaseAppCore
Element createElementWithDefaults(in DOMString tagName);
Element insertElement(in Element element, in boolean deleteSelection);
void insertLinkAroundSelection(in Element anchorElement);
void selectElement(in Element element);
void setCaretAfterElement(in Element element);
void setToolbarWindow(in Window win);
void setContentWindow(in Window win);
void setWebShellWindow(in Window win);
DOMString startSpellChecking();
DOMString getFirstMisspelledWord();
DOMString getNextMisspelledWord();
DOMString getSuggestedWord();
boolean checkCurrentWord(in DOMString suggestedWord);

Просмотреть файл

@ -59,6 +59,12 @@ public:
NS_IMETHOD GetTextProperty(const nsString& aProp, const nsString& aAttr, const nsString& aValue, nsString& aFirstHas, nsString& aAnyHas, nsString& aAllHas)=0;
NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue)=0;
NS_IMETHOD SetBackgroundColor(const nsString& aColor)=0;
NS_IMETHOD GetLocalFileURL(nsIDOMWindow* aParent, const nsString& aFilterType, nsString& aReturn)=0;
NS_IMETHOD SetParagraphFormat(const nsString& aValue)=0;
NS_IMETHOD LoadUrl(const nsString& aUrl)=0;
@ -115,6 +121,10 @@ public:
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)=0;
NS_IMETHOD SelectElement(nsIDOMElement* aElement)=0;
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement)=0;
NS_IMETHOD SetToolbarWindow(nsIDOMWindow* aWin)=0;
NS_IMETHOD SetContentWindow(nsIDOMWindow* aWin)=0;
@ -123,8 +133,6 @@ public:
NS_IMETHOD StartSpellChecking(nsString& aReturn)=0;
NS_IMETHOD GetFirstMisspelledWord(nsString& aReturn)=0;
NS_IMETHOD GetNextMisspelledWord(nsString& aReturn)=0;
NS_IMETHOD GetSuggestedWord(nsString& aReturn)=0;
@ -157,6 +165,9 @@ public:
NS_IMETHOD SetTextProperty(const nsString& aProp, const nsString& aAttr, const nsString& aValue); \
NS_IMETHOD RemoveTextProperty(const nsString& aProp, const nsString& aAttr); \
NS_IMETHOD GetTextProperty(const nsString& aProp, const nsString& aAttr, const nsString& aValue, nsString& aFirstHas, nsString& aAnyHas, nsString& aAllHas); \
NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue); \
NS_IMETHOD SetBackgroundColor(const nsString& aColor); \
NS_IMETHOD GetLocalFileURL(nsIDOMWindow* aParent, const nsString& aFilterType, nsString& aReturn); \
NS_IMETHOD SetParagraphFormat(const nsString& aValue); \
NS_IMETHOD LoadUrl(const nsString& aUrl); \
NS_IMETHOD NewWindow(); \
@ -185,11 +196,12 @@ public:
NS_IMETHOD CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement** aReturn); \
NS_IMETHOD InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection, nsIDOMElement** aReturn); \
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement); \
NS_IMETHOD SelectElement(nsIDOMElement* aElement); \
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement); \
NS_IMETHOD SetToolbarWindow(nsIDOMWindow* aWin); \
NS_IMETHOD SetContentWindow(nsIDOMWindow* aWin); \
NS_IMETHOD SetWebShellWindow(nsIDOMWindow* aWin); \
NS_IMETHOD StartSpellChecking(nsString& aReturn); \
NS_IMETHOD GetFirstMisspelledWord(nsString& aReturn); \
NS_IMETHOD GetNextMisspelledWord(nsString& aReturn); \
NS_IMETHOD GetSuggestedWord(nsString& aReturn); \
NS_IMETHOD CheckCurrentWord(const nsString& aSuggestedWord, PRBool* aReturn); \
@ -214,6 +226,9 @@ public:
NS_IMETHOD SetTextProperty(const nsString& aProp, const nsString& aAttr, const nsString& aValue) { return _to SetTextProperty(aProp, aAttr, aValue); } \
NS_IMETHOD RemoveTextProperty(const nsString& aProp, const nsString& aAttr) { return _to RemoveTextProperty(aProp, aAttr); } \
NS_IMETHOD GetTextProperty(const nsString& aProp, const nsString& aAttr, const nsString& aValue, nsString& aFirstHas, nsString& aAnyHas, nsString& aAllHas) { return _to GetTextProperty(aProp, aAttr, aValue, aFirstHas, aAnyHas, aAllHas); } \
NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue) { return _to SetBodyAttribute(aAttr, aValue); } \
NS_IMETHOD SetBackgroundColor(const nsString& aColor) { return _to SetBackgroundColor(aColor); } \
NS_IMETHOD GetLocalFileURL(nsIDOMWindow* aParent, const nsString& aFilterType, nsString& aReturn) { return _to GetLocalFileURL(aParent, aFilterType, aReturn); } \
NS_IMETHOD SetParagraphFormat(const nsString& aValue) { return _to SetParagraphFormat(aValue); } \
NS_IMETHOD LoadUrl(const nsString& aUrl) { return _to LoadUrl(aUrl); } \
NS_IMETHOD NewWindow() { return _to NewWindow(); } \
@ -242,11 +257,12 @@ public:
NS_IMETHOD CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement** aReturn) { return _to CreateElementWithDefaults(aTagName, aReturn); } \
NS_IMETHOD InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection, nsIDOMElement** aReturn) { return _to InsertElement(aElement, aDeleteSelection, aReturn); } \
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement) { return _to InsertLinkAroundSelection(aAnchorElement); } \
NS_IMETHOD SelectElement(nsIDOMElement* aElement) { return _to SelectElement(aElement); } \
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement) { return _to SetCaretAfterElement(aElement); } \
NS_IMETHOD SetToolbarWindow(nsIDOMWindow* aWin) { return _to SetToolbarWindow(aWin); } \
NS_IMETHOD SetContentWindow(nsIDOMWindow* aWin) { return _to SetContentWindow(aWin); } \
NS_IMETHOD SetWebShellWindow(nsIDOMWindow* aWin) { return _to SetWebShellWindow(aWin); } \
NS_IMETHOD StartSpellChecking(nsString& aReturn) { return _to StartSpellChecking(aReturn); } \
NS_IMETHOD GetFirstMisspelledWord(nsString& aReturn) { return _to GetFirstMisspelledWord(aReturn); } \
NS_IMETHOD GetNextMisspelledWord(nsString& aReturn) { return _to GetNextMisspelledWord(aReturn); } \
NS_IMETHOD GetSuggestedWord(nsString& aReturn) { return _to GetSuggestedWord(aReturn); } \
NS_IMETHOD CheckCurrentWord(const nsString& aSuggestedWord, PRBool* aReturn) { return _to CheckCurrentWord(aSuggestedWord, aReturn); } \

Просмотреть файл

@ -575,6 +575,45 @@ nsEditorAppCore::GetTextProperty(const nsString& aProp, const nsString& aAttr, c
return err;
}
NS_IMETHODIMP nsEditorAppCore::SetBackgroundColor(const nsString& aColor)
{
nsresult result = NS_NOINTERFACE;
switch (mEditorType)
{
case eHTMLTextEditorType:
{
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
if (htmlEditor)
result = htmlEditor->SetBackgroundColor(aColor);
break;
}
default:
result = NS_ERROR_NOT_IMPLEMENTED;
}
return result;
}
NS_IMETHODIMP nsEditorAppCore::SetBodyAttribute(const nsString& aAttr, const nsString& aValue)
{
nsresult result = NS_NOINTERFACE;
switch (mEditorType)
{
case eHTMLTextEditorType:
{
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
if (htmlEditor)
result = htmlEditor->SetBodyAttribute(aAttr, aValue);
break;
}
default:
result = NS_ERROR_NOT_IMPLEMENTED;
}
return result;
}
NS_IMETHODIMP
nsEditorAppCore::Back()
{
@ -775,51 +814,60 @@ nsEditorAppCore::NewWindow()
NS_IMETHODIMP
nsEditorAppCore::Open()
{
nsresult rv;
nsFileSpec docFileSpec;
nsresult result;
// GetLocalFileURL will do all the nsFileSpec/nsFileURL conversions,
// and return a "file:///" string
nsString fileURLString;
nsCOMPtr<nsIFileWidget> fileWidget;
static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);
rv = nsComponentManager::CreateInstance(kCFileWidgetCID, nsnull, nsIFileWidget::GetIID(), getter_AddRefs(fileWidget));
if (NS_FAILED(rv) || !fileWidget)
return rv;
result = nsComponentManager::CreateInstance(kCFileWidgetCID, nsnull, nsIFileWidget::GetIID(), getter_AddRefs(fileWidget));
if (NS_FAILED(result) || !fileWidget)
return result;
nsAutoString promptString("Open document to edit"); // XXX i18n, l10n
nsAutoString titles[] = {"HTML Files"};
nsAutoString filters[] = {"*.htm; *.html"};
fileWidget->SetFilterList(1, titles, filters);
nsFileDlgResults dialogResult;
dialogResult = fileWidget->GetFile(nsnull, promptString, docFileSpec);
if (dialogResult == nsFileDlgResults_Cancel)
return NS_OK;
// stolen from browser app core.
nsFileURL fileURL(docFileSpec);
//char buffer[1024];
//const nsAutoCString cstr(fileURL.GetAsString());
//PR_snprintf( buffer, sizeof buffer, "OpenFile(\"%s\")", (const char*)cstr);
//ExecuteScript( mToolbarScriptContext, buffer );
// all I want to do is call a method on nsToolkitCore that would normally
// be static. But I have to go through all this crap. XPCOM sucks so bad.
static NS_DEFINE_IID(kToolkitCoreCID, NS_TOOLKITCORE_CID);
nsCOMPtr<nsIDOMToolkitCore> toolkitCore;
rv = nsComponentManager::CreateInstance(kToolkitCoreCID,
nsnull,
nsIDOMToolkitCore::GetIID(),
getter_AddRefs(toolkitCore));
if (NS_SUCCEEDED(rv) && toolkitCore)
{
// at some point we need to be passing nsFileSpecs around. When nsIUrl is fileSpec-
// savvy, we should use that.
rv = toolkitCore->ShowWindowWithArgs("chrome://editor/content", nsnull, fileURL.GetAsString());
}
result = NS_NOINTERFACE;
return rv;
switch (mEditorType)
{
case eHTMLTextEditorType:
{
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
if (htmlEditor)
{
// This was written for all local file getting
// TODO: NEED TO GET PROPER PARENT WINDOW
result = htmlEditor->GetLocalFileURL(nsnull, "html", fileURLString);
if (NS_FAILED(result) || fileURLString == "")
return result;
// all I want to do is call a method on nsToolkitCore that would normally
// be static. But I have to go through all this crap. XPCOM sucks so bad.
static NS_DEFINE_IID(kToolkitCoreCID, NS_TOOLKITCORE_CID);
nsCOMPtr<nsIDOMToolkitCore> toolkitCore;
result = nsComponentManager::CreateInstance(kToolkitCoreCID,
nsnull,
nsIDOMToolkitCore::GetIID(),
getter_AddRefs(toolkitCore));
if (NS_SUCCEEDED(result) && toolkitCore)
{
// at some point we need to be passing nsFileSpecs around. When nsIUrl is fileSpec-
// savvy, we should use that.
result = toolkitCore->ShowWindowWithArgs("chrome://editor/content", nsnull, fileURLString/*fileURL.GetAsString()*/);
}
}
break;
}
default:
result = NS_ERROR_NOT_IMPLEMENTED;
}
return result;
}
NS_IMETHODIMP
@ -934,6 +982,26 @@ nsEditorAppCore::Exit()
return NS_OK;
}
NS_IMETHODIMP
nsEditorAppCore::GetLocalFileURL(nsIDOMWindow* aParent, const nsString& aFilterType, nsString& aReturn)
{
nsresult result = NS_NOINTERFACE;
switch (mEditorType)
{
case eHTMLTextEditorType:
{
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
if (htmlEditor)
result = htmlEditor->GetLocalFileURL(aParent, aFilterType, aReturn);
break;
}
default:
result = NS_ERROR_NOT_IMPLEMENTED;
}
return result;
}
NS_IMETHODIMP
nsEditorAppCore::Undo()
@ -1478,7 +1546,7 @@ nsEditorAppCore::InsertImage()
nsString alt ("[pen splat]");
nsString align ("left");
switch (mEditorType)
switch (mEditorType)
{
case eHTMLTextEditorType:
{
@ -1501,7 +1569,7 @@ nsEditorAppCore::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aR
if (!aReturn)
return NS_ERROR_NULL_POINTER;
nsresult err = NS_NOINTERFACE;
nsresult result = NS_NOINTERFACE;
switch (mEditorType)
{
case eHTMLTextEditorType:
@ -1513,10 +1581,10 @@ nsEditorAppCore::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aR
break;
case ePlainTextEditorType:
default:
err = NS_ERROR_NOT_IMPLEMENTED;
result = NS_ERROR_NOT_IMPLEMENTED;
}
return err;
return result;
}
NS_IMETHODIMP
@ -1525,8 +1593,8 @@ nsEditorAppCore::CreateElementWithDefaults(const nsString& aTagName, nsIDOMEleme
if (!aReturn)
return NS_ERROR_NULL_POINTER;
nsresult err = NS_NOINTERFACE;
switch (mEditorType)
nsresult result = NS_NOINTERFACE;
switch (mEditorType)
{
case eHTMLTextEditorType:
{
@ -1537,10 +1605,10 @@ nsEditorAppCore::CreateElementWithDefaults(const nsString& aTagName, nsIDOMEleme
break;
case ePlainTextEditorType:
default:
err = NS_ERROR_NOT_IMPLEMENTED;
result = NS_ERROR_NOT_IMPLEMENTED;
}
return err;
return result;
}
@ -1550,29 +1618,28 @@ nsEditorAppCore::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection,
if (!aElement || !aReturn)
return NS_ERROR_NULL_POINTER;
nsresult err = NS_NOINTERFACE;
nsresult result = NS_NOINTERFACE;
switch (mEditorType)
{
case eHTMLTextEditorType:
{
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
if (htmlEditor)
err = htmlEditor->InsertElement(aElement, aDeleteSelection, aReturn);
result = htmlEditor->InsertElement(aElement, aDeleteSelection, aReturn);
}
break;
case ePlainTextEditorType:
default:
err = NS_ERROR_NOT_IMPLEMENTED;
result = NS_ERROR_NOT_IMPLEMENTED;
}
return err;
return result;
}
NS_IMETHODIMP
nsEditorAppCore::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
{
nsresult err = NS_NOINTERFACE;
switch (mEditorType)
nsresult result = NS_NOINTERFACE;
switch (mEditorType)
{
case eHTMLTextEditorType:
{
@ -1582,9 +1649,55 @@ nsEditorAppCore::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
}
break;
default:
err = NS_ERROR_NOT_IMPLEMENTED;
result = NS_ERROR_NOT_IMPLEMENTED;
}
return err;
return result;
}
NS_IMETHODIMP
nsEditorAppCore::SelectElement(nsIDOMElement* aElement)
{
if (!aElement)
return NS_ERROR_NULL_POINTER;
nsresult result = NS_NOINTERFACE;
switch (mEditorType)
{
case eHTMLTextEditorType:
{
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
if (htmlEditor)
result = htmlEditor->SelectElement(aElement);
}
break;
default:
result = NS_ERROR_NOT_IMPLEMENTED;
}
return result;
}
NS_IMETHODIMP
nsEditorAppCore::SetCaretAfterElement(nsIDOMElement* aElement)
{
if (!aElement)
return NS_ERROR_NULL_POINTER;
nsresult result = NS_NOINTERFACE;
switch (mEditorType)
{
case eHTMLTextEditorType:
{
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
if (htmlEditor)
result = htmlEditor->SetCaretAfterElement(aElement);
}
break;
default:
result = NS_ERROR_NOT_IMPLEMENTED;
}
return result;
}
NS_IMETHODIMP
@ -1637,23 +1750,6 @@ nsEditorAppCore::StartSpellChecking(nsString& aFirstMisspelledWord)
DeleteSuggestedWordList();
// Return the first misspelled word and initialize the suggested list
result = mSpellChecker->NextMisspelledWord(&aFirstMisspelledWord, &mSuggestedWordList);
// Save the first word for GetFirstMisspelled word
// We wouldn't have to do this if we could pass > 1 parameter during dialog creation
mFirstMisspelledWord = aFirstMisspelledWord;
}
return result;
}
NS_IMETHODIMP
nsEditorAppCore::GetFirstMisspelledWord(nsString& aFirstMisspelledWord)
{
nsresult result = NS_NOINTERFACE;
// We can spell check with any editor type
if (mEditor && mSpellChecker)
{
mSuggestedWordIndex = 0;
aFirstMisspelledWord = mFirstMisspelledWord;
result = NS_OK;
}
return result;
}

Просмотреть файл

@ -71,6 +71,9 @@ class nsEditorAppCore : public nsBaseAppCore,
NS_IMETHOD CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement** aReturn);
NS_IMETHOD InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection, nsIDOMElement** aReturn);
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
NS_IMETHOD SelectElement(nsIDOMElement* aElement);
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement);
NS_IMETHOD SetEditorType(const nsString& aEditorType);
NS_IMETHOD SetTextProperty(const nsString& aProp,
const nsString& aAttr,
@ -84,6 +87,8 @@ class nsEditorAppCore : public nsBaseAppCore,
nsString& aAnyHas,
nsString& aAllHas);
NS_IMETHOD SetBackgroundColor(const nsString& aColor);
NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue);
NS_IMETHOD GetParagraphFormat(nsString& aParagraphFormat);
NS_IMETHOD SetParagraphFormat(const nsString& aParagraphFormat);
@ -106,6 +111,7 @@ class nsEditorAppCore : public nsBaseAppCore,
NS_IMETHOD PrintPreview();
NS_IMETHOD Print();
NS_IMETHOD Exit();
NS_IMETHOD GetLocalFileURL(nsIDOMWindow* aParent, const nsString& aFilterType, nsString& aReturn);
NS_IMETHOD Undo();
NS_IMETHOD Redo();
@ -136,7 +142,6 @@ class nsEditorAppCore : public nsBaseAppCore,
NS_IMETHOD Align(const nsString& aAlign);
NS_IMETHOD StartSpellChecking(nsString& aFirstMisspelledWord);
NS_IMETHOD GetFirstMisspelledWord(nsString& aFirstMisspelledWord);
NS_IMETHOD GetNextMisspelledWord(nsString& aNextMisspelledWord);
NS_IMETHOD GetSuggestedWord(nsString& aSuggestedWord);
NS_IMETHOD CheckCurrentWord(const nsString& aSuggestedWord, PRBool* aIsMisspelled);
@ -165,7 +170,6 @@ class nsEditorAppCore : public nsBaseAppCore,
const char *aCommand );
protected:
nsCOMPtr<nsISpellChecker> mSpellChecker;
nsString mFirstMisspelledWord;
nsStringArray mSuggestedWordList;
PRInt32 mSuggestedWordIndex;
NS_IMETHOD DeleteSuggestedWordList();

Просмотреть файл

@ -401,6 +401,127 @@ EditorAppCoreGetTextProperty(JSContext *cx, JSObject *obj, uintN argc, jsval *ar
}
//
// Native method SetBodyAttribute
//
PR_STATIC_CALLBACK(JSBool)
EditorAppCoreSetBodyAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMEditorAppCore *nativeThis = (nsIDOMEditorAppCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsAutoString b0;
nsAutoString b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 2) {
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
if (NS_OK != nativeThis->SetBodyAttribute(b0, b1)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function setBodyAttribute requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method SetBackgroundColor
//
PR_STATIC_CALLBACK(JSBool)
EditorAppCoreSetBackgroundColor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMEditorAppCore *nativeThis = (nsIDOMEditorAppCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
if (NS_OK != nativeThis->SetBackgroundColor(b0)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function setBackgroundColor requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method GetLocalFileURL
//
PR_STATIC_CALLBACK(JSBool)
EditorAppCoreGetLocalFileURL(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMEditorAppCore *nativeThis = (nsIDOMEditorAppCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsAutoString nativeRet;
nsIDOMWindowPtr b0;
nsAutoString b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 2) {
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
kIWindowIID,
"Window",
cx,
argv[0])) {
return JS_FALSE;
}
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
if (NS_OK != nativeThis->GetLocalFileURL(b0, b1, nativeRet)) {
return JS_FALSE;
}
nsJSUtils::nsConvertStringToJSVal(nativeRet, cx, rval);
}
else {
JS_ReportError(cx, "Function getLocalFileURL requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method SetParagraphFormat
//
@ -1388,6 +1509,90 @@ EditorAppCoreInsertLinkAroundSelection(JSContext *cx, JSObject *obj, uintN argc,
}
//
// Native method SelectElement
//
PR_STATIC_CALLBACK(JSBool)
EditorAppCoreSelectElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMEditorAppCore *nativeThis = (nsIDOMEditorAppCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMElementPtr b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
kIElementIID,
"Element",
cx,
argv[0])) {
return JS_FALSE;
}
if (NS_OK != nativeThis->SelectElement(b0)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function selectElement requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method SetCaretAfterElement
//
PR_STATIC_CALLBACK(JSBool)
EditorAppCoreSetCaretAfterElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMEditorAppCore *nativeThis = (nsIDOMEditorAppCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMElementPtr b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
kIElementIID,
"Element",
cx,
argv[0])) {
return JS_FALSE;
}
if (NS_OK != nativeThis->SetCaretAfterElement(b0)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function setCaretAfterElement requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method SetToolbarWindow
//
@ -1548,40 +1753,6 @@ EditorAppCoreStartSpellChecking(JSContext *cx, JSObject *obj, uintN argc, jsval
}
//
// Native method GetFirstMisspelledWord
//
PR_STATIC_CALLBACK(JSBool)
EditorAppCoreGetFirstMisspelledWord(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMEditorAppCore *nativeThis = (nsIDOMEditorAppCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsAutoString nativeRet;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 0) {
if (NS_OK != nativeThis->GetFirstMisspelledWord(nativeRet)) {
return JS_FALSE;
}
nsJSUtils::nsConvertStringToJSVal(nativeRet, cx, rval);
}
else {
JS_ReportError(cx, "Function getFirstMisspelledWord requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method GetNextMisspelledWord
//
@ -1912,7 +2083,7 @@ EditorAppCoreCloseSpellChecking(JSContext *cx, JSObject *obj, uintN argc, jsval
//
JSClass EditorAppCoreClass = {
"EditorAppCore",
JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS,
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
GetEditorAppCoreProperty,
@ -1948,6 +2119,9 @@ static JSFunctionSpec EditorAppCoreMethods[] =
{"setTextProperty", EditorAppCoreSetTextProperty, 3},
{"removeTextProperty", EditorAppCoreRemoveTextProperty, 2},
{"getTextProperty", EditorAppCoreGetTextProperty, 6},
{"setBodyAttribute", EditorAppCoreSetBodyAttribute, 2},
{"setBackgroundColor", EditorAppCoreSetBackgroundColor, 1},
{"getLocalFileURL", EditorAppCoreGetLocalFileURL, 2},
{"setParagraphFormat", EditorAppCoreSetParagraphFormat, 1},
{"loadUrl", EditorAppCoreLoadUrl, 1},
{"newWindow", EditorAppCoreNewWindow, 0},
@ -1976,11 +2150,12 @@ static JSFunctionSpec EditorAppCoreMethods[] =
{"createElementWithDefaults", EditorAppCoreCreateElementWithDefaults, 1},
{"insertElement", EditorAppCoreInsertElement, 2},
{"insertLinkAroundSelection", EditorAppCoreInsertLinkAroundSelection, 1},
{"selectElement", EditorAppCoreSelectElement, 1},
{"setCaretAfterElement", EditorAppCoreSetCaretAfterElement, 1},
{"setToolbarWindow", EditorAppCoreSetToolbarWindow, 1},
{"setContentWindow", EditorAppCoreSetContentWindow, 1},
{"setWebShellWindow", EditorAppCoreSetWebShellWindow, 1},
{"startSpellChecking", EditorAppCoreStartSpellChecking, 0},
{"getFirstMisspelledWord", EditorAppCoreGetFirstMisspelledWord, 0},
{"getNextMisspelledWord", EditorAppCoreGetNextMisspelledWord, 0},
{"getSuggestedWord", EditorAppCoreGetSuggestedWord, 0},
{"checkCurrentWord", EditorAppCoreCheckCurrentWord, 1},