Added Begin/End batch changes, renamed setAttribute to SetTextProperty, added RemoveTextProperty.

This commit is contained in:
sfraser%netscape.com 1999-04-03 01:48:12 +00:00
Родитель bf80a314de
Коммит 64eb0ac1da
3 изменённых файлов: 186 добавлений и 14 удалений

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

@ -9,7 +9,11 @@ interface EditorAppCore : BaseAppCore
void EditorAppCore();
void setEditorType(in wstring editorType);
void setAttribute(in wstring attr, in wstring value);
void setTextProperty(in wstring attr);
void removeTextProperty(in wstring attr);
void getTextProperty(in wstring attr, out boolean anyHas, out boolean allHas);
void undo();
void redo();
@ -19,6 +23,9 @@ interface EditorAppCore : BaseAppCore
void selectAll();
void beginBatchChanges();
void endBatchChanges();
void showClipboard();
void insertText(in wstring textToInsert);

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

@ -41,7 +41,11 @@ public:
NS_IMETHOD SetEditorType(const nsString& aEditorType)=0;
NS_IMETHOD SetAttribute(const nsString& aAttr, const nsString& aValue)=0;
NS_IMETHOD SetTextProperty(const nsString& aAttr)=0;
NS_IMETHOD RemoveTextProperty(const nsString& aAttr)=0;
NS_IMETHOD GetTextProperty(const nsString& aAttr, PRBool* aAnyHas, PRBool* aAllHas)=0;
NS_IMETHOD Undo()=0;
@ -55,6 +59,10 @@ public:
NS_IMETHOD SelectAll()=0;
NS_IMETHOD BeginBatchChanges()=0;
NS_IMETHOD EndBatchChanges()=0;
NS_IMETHOD ShowClipboard()=0;
NS_IMETHOD InsertText(const nsString& aTextToInsert)=0;
@ -77,13 +85,17 @@ public:
NS_IMETHOD GetContentsAsText(nsString& aContentsAsText); \
NS_IMETHOD GetContentsAsHTML(nsString& aContentsAsHTML); \
NS_IMETHOD SetEditorType(const nsString& aEditorType); \
NS_IMETHOD SetAttribute(const nsString& aAttr, const nsString& aValue); \
NS_IMETHOD SetTextProperty(const nsString& aAttr); \
NS_IMETHOD RemoveTextProperty(const nsString& aAttr); \
NS_IMETHOD GetTextProperty(const nsString& aAttr, PRBool* aAnyHas, PRBool* aAllHas); \
NS_IMETHOD Undo(); \
NS_IMETHOD Redo(); \
NS_IMETHOD Cut(); \
NS_IMETHOD Copy(); \
NS_IMETHOD Paste(); \
NS_IMETHOD SelectAll(); \
NS_IMETHOD BeginBatchChanges(); \
NS_IMETHOD EndBatchChanges(); \
NS_IMETHOD ShowClipboard(); \
NS_IMETHOD InsertText(const nsString& aTextToInsert); \
NS_IMETHOD InsertLink(); \
@ -99,13 +111,17 @@ public:
NS_IMETHOD GetContentsAsText(nsString& aContentsAsText) { return _to##GetContentsAsText(aContentsAsText); } \
NS_IMETHOD GetContentsAsHTML(nsString& aContentsAsHTML) { return _to##GetContentsAsHTML(aContentsAsHTML); } \
NS_IMETHOD SetEditorType(const nsString& aEditorType) { return _to##SetEditorType(aEditorType); } \
NS_IMETHOD SetAttribute(const nsString& aAttr, const nsString& aValue) { return _to##SetAttribute(aAttr, aValue); } \
NS_IMETHOD SetTextProperty(const nsString& aAttr) { return _to##SetTextProperty(aAttr); } \
NS_IMETHOD RemoveTextProperty(const nsString& aAttr) { return _to##RemoveTextProperty(aAttr); } \
NS_IMETHOD GetTextProperty(const nsString& aAttr, PRBool* aAnyHas, PRBool* aAllHas) { return _to##GetTextProperty(aAttr, aAnyHas, aAllHas); } \
NS_IMETHOD Undo() { return _to##Undo(); } \
NS_IMETHOD Redo() { return _to##Redo(); } \
NS_IMETHOD Cut() { return _to##Cut(); } \
NS_IMETHOD Copy() { return _to##Copy(); } \
NS_IMETHOD Paste() { return _to##Paste(); } \
NS_IMETHOD SelectAll() { return _to##SelectAll(); } \
NS_IMETHOD BeginBatchChanges() { return _to##BeginBatchChanges(); } \
NS_IMETHOD EndBatchChanges() { return _to##EndBatchChanges(); } \
NS_IMETHOD ShowClipboard() { return _to##ShowClipboard(); } \
NS_IMETHOD InsertText(const nsString& aTextToInsert) { return _to##InsertText(aTextToInsert); } \
NS_IMETHOD InsertLink() { return _to##InsertLink(); } \

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

@ -195,15 +195,14 @@ EditorAppCoreSetEditorType(JSContext *cx, JSObject *obj, uintN argc, jsval *argv
//
// Native method SetAttribute
// Native method SetTextProperty
//
PR_STATIC_CALLBACK(JSBool)
EditorAppCoreSetAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
EditorAppCoreSetTextProperty(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;
@ -212,20 +211,100 @@ EditorAppCoreSetAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
return JS_TRUE;
}
if (argc >= 2) {
if (argc >= 1) {
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
if (NS_OK != nativeThis->SetAttribute(b0, b1)) {
if (NS_OK != nativeThis->SetTextProperty(b0)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function setAttribute requires 2 parameters");
JS_ReportError(cx, "Function setTextProperty requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method RemoveTextProperty
//
PR_STATIC_CALLBACK(JSBool)
EditorAppCoreRemoveTextProperty(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->RemoveTextProperty(b0)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function removeTextProperty requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method GetTextProperty
//
PR_STATIC_CALLBACK(JSBool)
EditorAppCoreGetTextProperty(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMEditorAppCore *nativeThis = (nsIDOMEditorAppCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsAutoString b0;
PRBool b1;
PRBool b2;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 3) {
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
if (!nsJSUtils::nsConvertJSValToBool(&b1, cx, argv[1])) {
return JS_FALSE;
}
if (!nsJSUtils::nsConvertJSValToBool(&b2, cx, argv[2])) {
return JS_FALSE;
}
if (NS_OK != nativeThis->GetTextProperty(b0, &b1, &b2)) { // idlc bug
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function getTextProperty requires 3 parameters");
return JS_FALSE;
}
@ -431,6 +510,72 @@ EditorAppCoreSelectAll(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
}
//
// Native method BeginBatchChanges
//
PR_STATIC_CALLBACK(JSBool)
EditorAppCoreBeginBatchChanges(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->BeginBatchChanges()) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function beginBatchChanges requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method EndBatchChanges
//
PR_STATIC_CALLBACK(JSBool)
EditorAppCoreEndBatchChanges(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->EndBatchChanges()) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function endBatchChanges requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method ShowClipboard
//
@ -760,13 +905,17 @@ static JSPropertySpec EditorAppCoreProperties[] =
static JSFunctionSpec EditorAppCoreMethods[] =
{
{"setEditorType", EditorAppCoreSetEditorType, 1},
{"setAttribute", EditorAppCoreSetAttribute, 2},
{"setTextProperty", EditorAppCoreSetTextProperty, 1},
{"removeTextProperty", EditorAppCoreRemoveTextProperty, 1},
{"getTextProperty", EditorAppCoreGetTextProperty, 3},
{"undo", EditorAppCoreUndo, 0},
{"redo", EditorAppCoreRedo, 0},
{"cut", EditorAppCoreCut, 0},
{"copy", EditorAppCoreCopy, 0},
{"paste", EditorAppCorePaste, 0},
{"selectAll", EditorAppCoreSelectAll, 0},
{"beginBatchChanges", EditorAppCoreBeginBatchChanges, 0},
{"endBatchChanges", EditorAppCoreEndBatchChanges, 0},
{"showClipboard", EditorAppCoreShowClipboard, 0},
{"insertText", EditorAppCoreInsertText, 1},
{"insertLink", EditorAppCoreInsertLink, 0},