Add new methods to the editor app core to allow opening editor windows from local files.

This commit is contained in:
sfraser%netscape.com 1999-05-12 22:24:05 +00:00
Родитель ddccc52490
Коммит 8c99f95608
5 изменённых файлов: 455 добавлений и 121 удалений

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

@ -20,10 +20,15 @@ interface EditorAppCore : BaseAppCore
void setParagraphFormat(in DOMString value);
void loadUrl(in DOMString url);
void newWindow();
void open();
void save();
void saveAs();
void closeWindow();
void print();
void exit();
void undo();
void redo();
@ -49,8 +54,6 @@ interface EditorAppCore : BaseAppCore
Element insertElement(in Element element, in boolean deleteSelection);
void insertLinkAroundSelection(in Element anchorElement);
void exit();
void setToolbarWindow(in Window win);
void setContentWindow(in Window win);
void setWebShellWindow(in Window win);

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

@ -58,12 +58,22 @@ public:
NS_IMETHOD SetParagraphFormat(const nsString& aValue)=0;
NS_IMETHOD LoadUrl(const nsString& aUrl)=0;
NS_IMETHOD NewWindow()=0;
NS_IMETHOD Open()=0;
NS_IMETHOD Save()=0;
NS_IMETHOD SaveAs()=0;
NS_IMETHOD CloseWindow()=0;
NS_IMETHOD Print()=0;
NS_IMETHOD Exit()=0;
NS_IMETHOD Undo()=0;
NS_IMETHOD Redo()=0;
@ -96,8 +106,6 @@ public:
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)=0;
NS_IMETHOD Exit()=0;
NS_IMETHOD SetToolbarWindow(nsIDOMWindow* aWin)=0;
NS_IMETHOD SetContentWindow(nsIDOMWindow* aWin)=0;
@ -117,9 +125,14 @@ public:
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 SetParagraphFormat(const nsString& aValue); \
NS_IMETHOD LoadUrl(const nsString& aUrl); \
NS_IMETHOD NewWindow(); \
NS_IMETHOD Open(); \
NS_IMETHOD Save(); \
NS_IMETHOD SaveAs(); \
NS_IMETHOD CloseWindow(); \
NS_IMETHOD Print(); \
NS_IMETHOD Exit(); \
NS_IMETHOD Undo(); \
NS_IMETHOD Redo(); \
NS_IMETHOD Cut(); \
@ -129,7 +142,6 @@ public:
NS_IMETHOD Find(const nsString& aSearchTerm, PRBool aMatchCase, PRBool aSearchDown); \
NS_IMETHOD BeginBatchChanges(); \
NS_IMETHOD EndBatchChanges(); \
NS_IMETHOD ShowClipboard(); \
NS_IMETHOD InsertText(const nsString& aTextToInsert); \
NS_IMETHOD InsertLink(); \
NS_IMETHOD InsertImage(); \
@ -137,7 +149,6 @@ 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 Exit(); \
NS_IMETHOD SetToolbarWindow(nsIDOMWindow* aWin); \
NS_IMETHOD SetContentWindow(nsIDOMWindow* aWin); \
NS_IMETHOD SetWebShellWindow(nsIDOMWindow* aWin); \
@ -155,9 +166,14 @@ public:
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 SetParagraphFormat(const nsString& aValue) { return _to SetParagraphFormat(aValue); } \
NS_IMETHOD LoadUrl(const nsString& aUrl) { return _to LoadUrl(aUrl); } \
NS_IMETHOD NewWindow() { return _to NewWindow(); } \
NS_IMETHOD Open() { return _to Open(); } \
NS_IMETHOD Save() { return _to Save(); } \
NS_IMETHOD SaveAs() { return _to SaveAs(); } \
NS_IMETHOD CloseWindow() { return _to CloseWindow(); } \
NS_IMETHOD Print() { return _to Print(); } \
NS_IMETHOD Exit() { return _to Exit(); } \
NS_IMETHOD Undo() { return _to Undo(); } \
NS_IMETHOD Redo() { return _to Redo(); } \
NS_IMETHOD Cut() { return _to Cut(); } \
@ -174,7 +190,6 @@ 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 Exit() { return _to Exit(); } \
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); } \

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

@ -22,6 +22,7 @@
#include "nsIBrowserWindow.h"
#include "nsIWebShell.h"
#include "pratom.h"
#include "prprf.h"
#include "nsIComponentManager.h"
#include "nsAppCores.h"
#include "nsAppCoresCIDs.h"
@ -31,6 +32,7 @@
#include "nsIScriptContextOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDOMDocument.h"
#include "nsIDiskDocument.h"
#include "nsIDocument.h"
#include "nsIDOMWindow.h"
@ -140,8 +142,6 @@ nsEditorAppCore::nsEditorAppCore()
mContentScriptContext = nsnull;
mWebShellWin = nsnull;
mWebShell = nsnull;
//mCurrentNode = nsnull;
//mDomDoc = nsnull;
mEditor = nsnull;
IncInstanceCount();
@ -295,8 +295,11 @@ nsEditorAppCore::InstantiateEditor(nsIDOMDocument *aDoc, nsIPresShell *aPresShel
{
NS_PRECONDITION(aDoc && aPresShell, "null ptr");
if (!aDoc || !aPresShell)
return NS_ERROR_NULL_POINTER;
return NS_ERROR_NULL_POINTER;
if (mEditor)
return NS_ERROR_ALREADY_INITIALIZED;
nsresult err = NS_OK;
if (mEditorTypeString == "text")
@ -357,7 +360,7 @@ nsEditorAppCore::DoEditorMode(nsIWebShell *aWebShell)
{
nsresult err = NS_OK;
NS_PRECONDITION(aWebShell, "null ptr");
NS_PRECONDITION(aWebShell, "Need a webshell here");
if (!aWebShell)
return NS_ERROR_NULL_POINTER;
@ -375,12 +378,11 @@ nsEditorAppCore::DoEditorMode(nsIWebShell *aWebShell)
nsCOMPtr<nsIDOMDocument> aDOMDoc;
if (NS_SUCCEEDED(aDoc->QueryInterface(kIDOMDocumentIID, (void**)getter_AddRefs(aDOMDoc))))
{
nsIPresShell* presShell = GetPresShellFor(aWebShell);
nsCOMPtr<nsIPresShell> presShell = do_QueryInterface(GetPresShellFor(aWebShell));
if( presShell )
{
err = InstantiateEditor(aDOMDoc, presShell);
}
NS_IF_RELEASE(presShell);
}
}
}
@ -605,9 +607,46 @@ nsEditorAppCore::SetEnableCallback(const nsString& aScript)
NS_IMETHODIMP
nsEditorAppCore::LoadUrl(const nsString& aUrl)
{
char *urlstr = aUrl.ToNewCString();
if (!urlstr)
return NS_OK;
nsCOMPtr<nsIScriptGlobalObject> globalObj( do_QueryInterface(mContentWindow) );
if (globalObj)
{
nsCOMPtr<nsIWebShell> webShell;
globalObj->GetWebShell(getter_AddRefs(webShell));
if (webShell)
webShell->LoadURL(nsString(urlstr).GetUnicode());
}
delete[] urlstr;
return NS_OK;
}
NS_IMETHODIMP
nsEditorAppCore::MakeEditor()
{
NS_PRECONDITION(mContentWindow, "Content window not set yet");
if (!mContentWindow)
return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIScriptGlobalObject> globalObj( do_QueryInterface(mContentWindow) );
if (!globalObj) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIWebShell> webShell;
globalObj->GetWebShell(getter_AddRefs(webShell));
if (webShell) {
DoEditorMode(webShell);
}
return NS_OK;
}
NS_IMETHODIMP
nsEditorAppCore::SetToolbarWindow(nsIDOMWindow* aWin)
{
@ -632,16 +671,16 @@ nsEditorAppCore::SetContentWindow(nsIDOMWindow* aWin)
mContentWindow = aWin;
NS_ADDREF(aWin);
mContentScriptContext = GetScriptContext(aWin);
nsCOMPtr<nsIScriptGlobalObject> globalObj( do_QueryInterface(mContentWindow) );
if (!globalObj) {
return NS_ERROR_FAILURE;
}
nsIWebShell * webShell;
globalObj->GetWebShell(&webShell);
if (nsnull != webShell) {
DoEditorMode(webShell);
NS_RELEASE(webShell);
nsCOMPtr<nsIScriptGlobalObject> globalObj( do_QueryInterface(mContentWindow) );
if (!globalObj)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIWebShell> webShell;
globalObj->GetWebShell(getter_AddRefs(webShell));
if (webShell)
{
webShell->SetDocLoaderObserver((nsIDocumentLoaderObserver *)this);
}
return NS_OK;
@ -690,13 +729,83 @@ nsEditorAppCore::SetWebShellWindow(nsIDOMWindow* aWin)
return NS_OK;
}
NS_IMETHODIMP
nsEditorAppCore::NewWindow()
{
return NS_ERROR_NOT_IMPLEMENTED;
NS_IMETHODIMP
nsEditorAppCore::CreateWindowWithURL(const char* urlStr)
{
nsresult rv = NS_OK;
/*
* Create the Application Shell instance...
*/
nsIAppShellService* appShell = nsnull;
rv = nsServiceManager::GetService(kAppShellServiceCID,
kIAppShellServiceIID,
(nsISupports**)&appShell);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIURL> url = nsnull;
nsIWebShellWindow* newWindow = nsnull;
rv = NS_NewURL(getter_AddRefs(url), urlStr);
if (NS_FAILED(rv) || !url)
goto done;
appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, newWindow,
nsnull, nsnull, 615, 480);
done:
/* Release the shell... */
if (nsnull != appShell) {
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
}
return rv;
}
NS_IMETHODIMP
nsEditorAppCore::NewWindow()
{
return CreateWindowWithURL("chrome://editor/content/");
}
NS_IMETHODIMP
nsEditorAppCore::Open()
{
nsresult rv;
nsFileSpec docFileSpec;
nsCOMPtr<nsIFileWidget> fileWidget;
static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);
static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID);
rv = nsComponentManager::CreateInstance(kCFileWidgetCID, nsnull, kIFileWidgetIID, getter_AddRefs(fileWidget));
if (NS_FAILED(rv) || !fileWidget)
return rv;
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 );
return rv;
}
NS_IMETHODIMP
nsEditorAppCore::Save()
{
nsresult err = NS_NOINTERFACE;
@ -755,9 +864,60 @@ nsEditorAppCore::SaveAs()
NS_IMETHODIMP
nsEditorAppCore::CloseWindow()
{
return NS_ERROR_NOT_IMPLEMENTED;
nsresult rv = NS_OK;
nsCOMPtr<nsIDOMDocument> theDoc;
if (NS_SUCCEEDED(GetEditorDocument(getter_AddRefs(theDoc))) && theDoc)
{
nsCOMPtr<nsIDiskDocument> diskDoc = do_QueryInterface(theDoc);
if (diskDoc)
{
PRInt32 modCount = 0;
diskDoc->GetModCount(&modCount);
if (modCount > 0)
{
// Show the Save/Dont save dialog, somehow.
}
}
}
return rv;
}
NS_IMETHODIMP
nsEditorAppCore::Print()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsEditorAppCore::PrintPreview()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsEditorAppCore::Exit()
{
nsIAppShellService* appShell = nsnull;
/*
* Create the Application Shell instance...
*/
nsresult rv = nsServiceManager::GetService(kAppShellServiceCID,
kIAppShellServiceIID,
(nsISupports**)&appShell);
if (NS_SUCCEEDED(rv)) {
appShell->Shutdown();
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
}
return NS_OK;
}
NS_IMETHODIMP
nsEditorAppCore::Undo()
{
@ -1417,39 +1577,6 @@ void nsEditorAppCore::SetButtonImage(nsIDOMNode * aParentNode, PRInt32 aBtnNum,
}
NS_IMETHODIMP
nsEditorAppCore::PrintPreview()
{
return NS_OK;
}
NS_IMETHODIMP
nsEditorAppCore::Close()
{
return NS_OK;
}
NS_IMETHODIMP
nsEditorAppCore::Exit()
{
nsIAppShellService* appShell = nsnull;
/*
* Create the Application Shell instance...
*/
nsresult rv = nsServiceManager::GetService(kAppShellServiceCID,
kIAppShellServiceIID,
(nsISupports**)&appShell);
if (NS_SUCCEEDED(rv)) {
appShell->Shutdown();
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
}
return NS_OK;
}
NS_IMETHODIMP
nsEditorAppCore::ExecuteScript(nsIScriptContext * aContext, const nsString& aScript)
{
@ -1469,24 +1596,59 @@ nsEditorAppCore::ExecuteScript(nsIScriptContext * aContext, const nsString& aScr
return NS_OK;
}
//static nsIDOMDocument* mDomDoc;
//static nsIDOMNode* mCurrentNode;
//static nsIEditor *gEditor;
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
static NS_DEFINE_IID(kIEditorIID, NS_IEDITOR_IID);
static NS_DEFINE_CID(kEditorCID, NS_EDITOR_CID);
#ifdef XP_PC
#define EDITOR_DLL "ender.dll"
#else
#ifdef XP_MAC
#define EDITOR_DLL "ENDER_DLL"
#else // XP_UNIX
#define EDITOR_DLL "libender.so"
#endif
#pragma mark -
#endif
// nsIDocumentLoaderObserver methods
NS_IMETHODIMP
nsEditorAppCore::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURL* aURL, const char* aCommand)
{
return NS_OK;
}
NS_IMETHODIMP
nsEditorAppCore::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIURL *aUrl, PRInt32 aStatus)
{
return MakeEditor();
}
NS_IMETHODIMP
nsEditorAppCore::OnStartURLLoad(nsIDocumentLoader* loader,
nsIURL* aURL, const char* aContentType,
nsIContentViewer* aViewer)
{
return NS_OK;
}
NS_IMETHODIMP
nsEditorAppCore::OnProgressURLLoad(nsIDocumentLoader* loader,
nsIURL* aURL, PRUint32 aProgress,
PRUint32 aProgressMax)
{
return NS_OK;
}
NS_IMETHODIMP
nsEditorAppCore::OnStatusURLLoad(nsIDocumentLoader* loader,
nsIURL* aURL, nsString& aMsg)
{
return NS_OK;
}
NS_IMETHODIMP
nsEditorAppCore::OnEndURLLoad(nsIDocumentLoader* loader,
nsIURL* aURL, PRInt32 aStatus)
{
return NS_OK;
}
NS_IMETHODIMP
nsEditorAppCore::HandleUnknownContentType(nsIDocumentLoader* loader,
nsIURL *aURL,
const char *aContentType,
const char *aCommand )
{
return NS_OK;
}

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

@ -25,6 +25,7 @@
#include "nsISupports.h"
#include "nsIDOMEditorAppCore.h"
#include "nsIDocumentLoaderObserver.h"
#include "nsBaseAppCore.h"
#include "nsINetSupport.h"
#include "nsIStreamObserver.h"
@ -47,7 +48,8 @@ class nsIOutputStream;
////////////////////////////////////////////////////////////////////////////////
class nsEditorAppCore : public nsBaseAppCore,
public nsIDOMEditorAppCore
public nsIDOMEditorAppCore,
public nsIDocumentLoaderObserver
{
public:
@ -89,9 +91,14 @@ class nsEditorAppCore : public nsBaseAppCore,
NS_IMETHOD GetEditorSelection(nsIDOMSelection** aEditorSelection);
NS_IMETHOD NewWindow();
NS_IMETHOD Open();
NS_IMETHOD Save();
NS_IMETHOD SaveAs();
NS_IMETHOD CloseWindow();
NS_IMETHOD PrintPreview();
NS_IMETHOD Print();
NS_IMETHOD Exit();
NS_IMETHOD Undo();
NS_IMETHOD Redo();
@ -121,12 +128,19 @@ class nsEditorAppCore : public nsBaseAppCore,
NS_IMETHOD BeginBatchChanges();
NS_IMETHOD EndBatchChanges();
NS_IMETHOD NewWindow();
NS_IMETHOD PrintPreview();
NS_IMETHOD Close();
NS_IMETHOD Exit();
// nsIDocumentLoaderObserver
NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURL* aURL, const char* aCommand);
NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader, nsIURL *aUrl, PRInt32 aStatus);
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIURL* aURL, const char* aContentType,
nsIContentViewer* aViewer);
NS_IMETHOD OnProgressURLLoad(nsIDocumentLoader* loader, nsIURL* aURL, PRUint32 aProgress,
PRUint32 aProgressMax);
NS_IMETHOD OnStatusURLLoad(nsIDocumentLoader* loader, nsIURL* aURL, nsString& aMsg);
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader, nsIURL* aURL, PRInt32 aStatus);
NS_IMETHOD HandleUnknownContentType(nsIDocumentLoader* loader,
nsIURL *aURL,
const char *aContentType,
const char *aCommand );
protected:
typedef enum {
@ -140,6 +154,8 @@ class nsEditorAppCore : public nsBaseAppCore,
NS_IMETHOD InstantiateEditor(nsIDOMDocument *aDoc, nsIPresShell *aPresShell);
NS_IMETHOD RemoveOneProperty(const nsString& aProp, const nsString& aAttr);
void SetButtonImage(nsIDOMNode * aParentNode, PRInt32 aBtnNum, const nsString &aResName);
NS_IMETHOD CreateWindowWithURL(const char* urlStr);
NS_IMETHOD MakeEditor();
nsString mEnableScript;
nsString mDisableScript;

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

@ -410,6 +410,108 @@ EditorAppCoreSetParagraphFormat(JSContext *cx, JSObject *obj, uintN argc, jsval
}
//
// Native method LoadUrl
//
PR_STATIC_CALLBACK(JSBool)
EditorAppCoreLoadUrl(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->LoadUrl(b0)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function loadUrl requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method NewWindow
//
PR_STATIC_CALLBACK(JSBool)
EditorAppCoreNewWindow(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMEditorAppCore *nativeThis = (nsIDOMEditorAppCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
*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->NewWindow()) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function newWindow requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method Open
//
PR_STATIC_CALLBACK(JSBool)
EditorAppCoreOpen(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMEditorAppCore *nativeThis = (nsIDOMEditorAppCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
*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->Open()) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function open requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method Save
//
@ -509,6 +611,72 @@ EditorAppCoreCloseWindow(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
}
//
// Native method Print
//
PR_STATIC_CALLBACK(JSBool)
EditorAppCorePrint(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMEditorAppCore *nativeThis = (nsIDOMEditorAppCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
*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->Print()) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function print requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method Exit
//
PR_STATIC_CALLBACK(JSBool)
EditorAppCoreExit(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMEditorAppCore *nativeThis = (nsIDOMEditorAppCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
*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->Exit()) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function exit requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method Undo
//
@ -819,7 +987,6 @@ EditorAppCoreEndBatchChanges(JSContext *cx, JSObject *obj, uintN argc, jsval *ar
}
//
// Native method InsertText
//
@ -1086,39 +1253,6 @@ EditorAppCoreInsertLinkAroundSelection(JSContext *cx, JSObject *obj, uintN argc,
}
//
// Native method Exit
//
PR_STATIC_CALLBACK(JSBool)
EditorAppCoreExit(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMEditorAppCore *nativeThis = (nsIDOMEditorAppCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
*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->Exit()) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function exit requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method SetToolbarWindow
//
@ -1287,9 +1421,14 @@ static JSFunctionSpec EditorAppCoreMethods[] =
{"removeTextProperty", EditorAppCoreRemoveTextProperty, 2},
{"getTextProperty", EditorAppCoreGetTextProperty, 6},
{"setParagraphFormat", EditorAppCoreSetParagraphFormat, 1},
{"loadUrl", EditorAppCoreLoadUrl, 1},
{"newWindow", EditorAppCoreNewWindow, 0},
{"open", EditorAppCoreOpen, 0},
{"save", EditorAppCoreSave, 0},
{"saveAs", EditorAppCoreSaveAs, 0},
{"closeWindow", EditorAppCoreCloseWindow, 0},
{"print", EditorAppCorePrint, 0},
{"exit", EditorAppCoreExit, 0},
{"undo", EditorAppCoreUndo, 0},
{"redo", EditorAppCoreRedo, 0},
{"cut", EditorAppCoreCut, 0},
@ -1306,7 +1445,6 @@ static JSFunctionSpec EditorAppCoreMethods[] =
{"createElementWithDefaults", EditorAppCoreCreateElementWithDefaults, 1},
{"insertElement", EditorAppCoreInsertElement, 2},
{"insertLinkAroundSelection", EditorAppCoreInsertLinkAroundSelection, 1},
{"exit", EditorAppCoreExit, 0},
{"setToolbarWindow", EditorAppCoreSetToolbarWindow, 1},
{"setContentWindow", EditorAppCoreSetContentWindow, 1},
{"setWebShellWindow", EditorAppCoreSetWebShellWindow, 1},