1999-06-10 19:52:49 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
#include "domstubs.idl"
|
1999-06-22 21:36:45 +00:00
|
|
|
#include "nsIFileSpec.idl"
|
1999-07-19 22:36:12 +00:00
|
|
|
#include "nsISupportsArray.idl"
|
1999-08-03 00:47:40 +00:00
|
|
|
#include "nsIDocumentStateListener.idl"
|
1999-06-10 19:52:49 +00:00
|
|
|
|
|
|
|
%{C++
|
|
|
|
|
|
|
|
class nsIDOMWindow;
|
|
|
|
class nsIDOMDocument;
|
|
|
|
class nsIDOMSelection;
|
|
|
|
class nsIDOMElement;
|
1999-07-27 23:59:22 +00:00
|
|
|
class nsIDOMNode;
|
1999-06-10 19:52:49 +00:00
|
|
|
%}
|
|
|
|
|
1999-06-22 03:47:00 +00:00
|
|
|
interface nsIFileSpec;
|
1999-06-10 19:52:49 +00:00
|
|
|
|
|
|
|
[scriptable, uuid(9afff72b-ca9a-11d2-96c9-0060b0fb9956)]
|
|
|
|
interface nsIEditorShell : nsISupports
|
|
|
|
{
|
|
|
|
readonly attribute nsIDOMDocument editorDocument;
|
|
|
|
readonly attribute nsIDOMSelection editorSelection;
|
|
|
|
|
1999-07-14 22:30:55 +00:00
|
|
|
%{C++
|
|
|
|
|
|
|
|
enum {
|
|
|
|
eDocumentStatusUnmodified,
|
|
|
|
eDocumentStatusModified
|
|
|
|
};
|
|
|
|
%}
|
1999-07-28 02:53:48 +00:00
|
|
|
readonly attribute boolean documentModified;
|
1999-07-14 22:30:55 +00:00
|
|
|
|
1999-06-10 19:52:49 +00:00
|
|
|
attribute wstring paragraphFormat;
|
|
|
|
attribute long wrapColumn;
|
|
|
|
|
|
|
|
/* Setup */
|
|
|
|
void SetEditorType(in wstring editorType);
|
|
|
|
|
|
|
|
void SetToolbarWindow(in nsIDOMWindow win);
|
|
|
|
void SetContentWindow(in nsIDOMWindow win);
|
|
|
|
void SetWebShellWindow(in nsIDOMWindow win);
|
|
|
|
void LoadUrl(in wstring url);
|
|
|
|
|
1999-08-21 08:54:47 +00:00
|
|
|
/** Register a doc state listener. This gets added to a list of listeners
|
1999-08-03 00:47:40 +00:00
|
|
|
which are registered with the editor when that gets instantiated.
|
|
|
|
If the LoadUrl fails, this listener will not receive any notifcations.
|
|
|
|
If you call this after the editor has been instantiated, it calls through
|
|
|
|
to editor::AddDocumentStateListener().
|
|
|
|
*/
|
|
|
|
void RegisterDocumentStateListener(in nsIDocumentStateListener docListener);
|
1999-08-21 08:54:47 +00:00
|
|
|
/** Unregister a listener.
|
1999-08-03 00:47:40 +00:00
|
|
|
If you call this after the editor has been instantiated, it calls through
|
|
|
|
to editor::RemoveDocumentStateListener().
|
|
|
|
*/
|
|
|
|
void UnregisterDocumentStateListener(in nsIDocumentStateListener docListener);
|
|
|
|
|
1999-06-10 19:52:49 +00:00
|
|
|
void Init();
|
|
|
|
|
|
|
|
/* Commands */
|
|
|
|
void NewWindow();
|
|
|
|
void Open();
|
1999-08-28 02:40:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param saveAs false to try to save to existing file
|
|
|
|
* If document is not already saved, it is treated as true
|
|
|
|
* so filename is prompted.
|
|
|
|
* @param saveCopy
|
|
|
|
* true if we are saving off a copy of the document
|
|
|
|
* without changing the disk file associated with the doc.
|
|
|
|
* This would correspond to a 'Save Copy As' menu command
|
|
|
|
* (currently not in our UI)
|
1999-08-31 00:51:23 +00:00
|
|
|
* return value
|
|
|
|
* true if file was really saved.
|
|
|
|
* false if there is some problem with saving or user
|
|
|
|
* executed "Cancel" when prompted for a filename to save
|
1999-08-28 02:40:18 +00:00
|
|
|
*/
|
1999-08-31 01:13:54 +00:00
|
|
|
boolean SaveDocument(in boolean saveAs, in boolean saveCopy);
|
1999-08-31 00:51:23 +00:00
|
|
|
|
|
|
|
/** These are for simpler access and we ignore if user Cancels*/
|
1999-08-28 02:40:18 +00:00
|
|
|
/** This is SaveDocument(false, false) */
|
1999-06-10 19:52:49 +00:00
|
|
|
void Save();
|
1999-08-28 02:40:18 +00:00
|
|
|
/** This is SaveDocument(true, false) */
|
1999-06-10 19:52:49 +00:00
|
|
|
void SaveAs();
|
1999-08-31 00:51:23 +00:00
|
|
|
/** Check if current document has changes and prompt to save if it does.
|
|
|
|
* return value:
|
|
|
|
* false ONLY if user executed "Cancel" in the SaveAs dialog
|
|
|
|
* true if no changes in doc, or file was saved successfully
|
|
|
|
*/
|
1999-08-31 01:13:54 +00:00
|
|
|
boolean CheckAndSaveDocument();
|
1999-08-28 02:40:18 +00:00
|
|
|
|
1999-06-10 19:52:49 +00:00
|
|
|
void CloseWindow();
|
|
|
|
void Print();
|
|
|
|
void Exit();
|
|
|
|
|
|
|
|
void Undo();
|
|
|
|
void Redo();
|
|
|
|
|
|
|
|
void Cut();
|
|
|
|
void Copy();
|
|
|
|
void Paste();
|
|
|
|
void PasteAsQuotation();
|
|
|
|
void PasteAsCitedQuotation(in wstring cite);
|
|
|
|
|
|
|
|
void InsertAsQuotation(in wstring quotedText);
|
|
|
|
void InsertAsCitedQuotation(in wstring quotedText, in wstring cite);
|
|
|
|
|
|
|
|
void SelectAll();
|
1999-06-14 20:02:46 +00:00
|
|
|
void DeleteSelection(in PRInt32 action);
|
1999-06-10 19:52:49 +00:00
|
|
|
|
|
|
|
void Find();
|
|
|
|
void FindNext();
|
1999-08-13 22:26:50 +00:00
|
|
|
|
1999-08-28 02:40:18 +00:00
|
|
|
/* General Utilities */
|
|
|
|
/* Get string from the Editor's localized string bundle */
|
|
|
|
wstring GetString(in wstring name);
|
|
|
|
|
1999-08-13 22:26:50 +00:00
|
|
|
/* Charset Menu */
|
|
|
|
wstring GetDocumentCharacterSet();
|
|
|
|
void SetDocumentCharacterSet(in wstring characterSet);
|
1999-06-10 19:52:49 +00:00
|
|
|
|
|
|
|
/* Structure change */
|
|
|
|
void InsertText(in wstring textToInsert);
|
1999-06-30 19:26:08 +00:00
|
|
|
void InsertSource(in wstring textToInsert);
|
1999-06-10 19:52:49 +00:00
|
|
|
void InsertBreak();
|
|
|
|
|
|
|
|
void InsertList(in wstring listType);
|
|
|
|
void Indent(in wstring indent);
|
|
|
|
void Align(in wstring align);
|
|
|
|
|
1999-08-21 08:54:47 +00:00
|
|
|
/** Element insert and property editing */
|
1999-09-01 01:22:37 +00:00
|
|
|
|
|
|
|
/** Return an element only if it is the only node selected,
|
|
|
|
* such as an image, horizontal rule, etc.
|
|
|
|
* The exception is a link, which is more like a text attribute:
|
|
|
|
* The Anchor tag is returned if the selection is within the textnode(s)
|
|
|
|
* that are children of the "A" node.
|
|
|
|
* This could be a collapsed selection, i.e., a caret within the link text.
|
|
|
|
*
|
|
|
|
* tagName: The HTML tagname or and empty string
|
|
|
|
* to get any element (but only if it is the only element selected)
|
|
|
|
* Special input values for Links and Named anchors:
|
|
|
|
* Use "href" to get a link node
|
|
|
|
* (an "A" tag with the "href" attribute set)
|
|
|
|
* Use "anchor" or "namedanchor" to get a named anchor node
|
|
|
|
* (an "A" tag with the "name" attribute set)
|
|
|
|
*/
|
1999-06-10 19:52:49 +00:00
|
|
|
nsIDOMElement GetSelectedElement(in wstring tagName);
|
1999-09-01 01:22:37 +00:00
|
|
|
|
|
|
|
/** Return the input node or a parent matching the given aTagName,
|
|
|
|
* starting the search at the supplied node.
|
|
|
|
* An example of use is for testing if a node is in a table cell
|
|
|
|
* given a selection anchor node.
|
|
|
|
*
|
|
|
|
* tagName: The HTML tagname
|
|
|
|
* Special input values for Links and Named anchors:
|
|
|
|
* Use "href" to get a link node
|
|
|
|
* (an "A" tag with the "href" attribute set)
|
|
|
|
* Use "anchor" or "namedanchor" to get a named anchor node
|
|
|
|
* (an "A" tag with the "name" attribute set)
|
|
|
|
*
|
|
|
|
* node: The node in the document to start the search
|
|
|
|
* If it is null, the anchor node of the current selection is used
|
|
|
|
*/
|
1999-07-27 23:59:22 +00:00
|
|
|
nsIDOMElement GetElementOrParentByTagName(in wstring tagName, in nsIDOMNode node);
|
1999-09-01 01:22:37 +00:00
|
|
|
|
|
|
|
/** Return a new element with default attribute values
|
|
|
|
*
|
|
|
|
* This does not rely on the selection, and is not sensitive to context.
|
|
|
|
*
|
|
|
|
* Used primarily to supply new element for various insert element dialogs
|
|
|
|
* (Image, Link, NamedAnchor, Table, and HorizontalRule
|
|
|
|
* are the only returned elements as of 7/25/99)
|
|
|
|
*
|
|
|
|
* tagName: The HTML tagname
|
|
|
|
* Special input values for Links and Named anchors:
|
|
|
|
* Use "href" to get a link node
|
|
|
|
* (an "A" tag with the "href" attribute set)
|
|
|
|
* Use "anchor" or "namedanchor" to get a named anchor node
|
|
|
|
* (an "A" tag with the "name" attribute set)
|
|
|
|
*/
|
1999-06-10 19:52:49 +00:00
|
|
|
nsIDOMElement CreateElementWithDefaults(in wstring tagName);
|
1999-09-01 01:22:37 +00:00
|
|
|
|
|
|
|
/** Insert an element, which may have child nodes, at the selection
|
|
|
|
* Used primarily to insert a new element for various insert element dialogs,
|
|
|
|
* but it enforces the HTML 4.0 DTD "CanContain" rules, so it should
|
|
|
|
* be useful for other elements.
|
|
|
|
*
|
|
|
|
* element: The element to insert
|
|
|
|
* deleteSelection: Delete the selection before inserting
|
|
|
|
* If deleteSelection is PR_FALSE, then the element is inserted
|
|
|
|
* after the end of the selection for all element except
|
|
|
|
* Named Anchors, which insert before the selection
|
|
|
|
*/
|
1999-08-01 22:37:58 +00:00
|
|
|
void InsertElement(in nsIDOMElement element, in boolean deleteSelection);
|
1999-09-01 01:22:37 +00:00
|
|
|
|
|
|
|
/** Insert an link element as the parent of the current selection
|
|
|
|
*
|
|
|
|
* element An "A" element with a non-empty "href" attribute
|
|
|
|
*/
|
1999-08-01 22:37:58 +00:00
|
|
|
void InsertLinkAroundSelection(in nsIDOMElement anchorElement);
|
|
|
|
void SelectElement(in nsIDOMElement element);
|
|
|
|
void SetSelectionAfterElement(in nsIDOMElement element);
|
1999-06-10 19:52:49 +00:00
|
|
|
|
1999-08-21 08:54:47 +00:00
|
|
|
/** Table insert and delete methods. Done relative to selected cell or
|
|
|
|
* cell containing the selection anchor.
|
|
|
|
*/
|
1999-08-31 01:13:54 +00:00
|
|
|
void InsertTableCell(in PRInt32 number, in boolean after);
|
|
|
|
void InsertTableRow(in PRInt32 number, in boolean after);
|
|
|
|
void InsertTableColumn(in PRInt32 number, in boolean after);
|
1999-08-04 02:06:03 +00:00
|
|
|
void DeleteTable();
|
|
|
|
void DeleteTableCell(in PRInt32 number);
|
|
|
|
void DeleteTableRow(in PRInt32 number);
|
|
|
|
void DeleteTableColumn(in PRInt32 number);
|
|
|
|
void JoinTableCells();
|
|
|
|
|
|
|
|
/** Scan through all rows and add cells as needed so
|
|
|
|
* all locations in the cellmap are occupied.
|
|
|
|
* Used after inserting single cells or pasting
|
|
|
|
* a collection of cells that extend past the
|
|
|
|
* previous size of the table
|
|
|
|
* If aTable is null, it uses table enclosing the selection anchor
|
|
|
|
*/
|
|
|
|
void NormalizeTable(in nsIDOMElement tableElement);
|
1999-08-01 22:37:58 +00:00
|
|
|
|
1999-08-21 08:54:47 +00:00
|
|
|
/** Get the indexes from layout's cellmap */
|
1999-07-27 23:59:22 +00:00
|
|
|
PRInt32 GetRowIndex(in nsIDOMElement cellElement);
|
|
|
|
PRInt32 GetColumnIndex(in nsIDOMElement cellElement);
|
1999-08-01 22:37:58 +00:00
|
|
|
|
|
|
|
/** Get the number of rows in a table from the layout's cellmap
|
|
|
|
* If tableElement is null, it will try to find enclosing table of selection anchor
|
|
|
|
*/
|
|
|
|
PRInt32 GetTableRowCount(in nsIDOMElement tableElement);
|
|
|
|
|
|
|
|
/* Get the number of columns in a table from the layout's cellmap
|
|
|
|
* If tableElement is null, it will try to find enclosing table of selection anchor
|
|
|
|
*/
|
|
|
|
PRInt32 GetTableColumnCount(in nsIDOMElement tableElement);
|
|
|
|
|
|
|
|
/* Get cell at a location in the layout's cellmap
|
|
|
|
returns null when past last cell in a row or column */
|
1999-08-21 08:54:47 +00:00
|
|
|
/* Get a cell and associated data from the layout frame based on cell map coordinates (0 index) */
|
1999-07-27 23:59:22 +00:00
|
|
|
nsIDOMElement GetCellAt(in nsIDOMElement tableElement, in PRInt32 rowIndex, in PRInt32 colIndex);
|
1999-08-01 22:37:58 +00:00
|
|
|
/* Get cell at a location in the layout's cellmap with associated data
|
|
|
|
returns null when past last cell in a row or column */
|
|
|
|
nsIDOMElement GetCellDataAt(in nsIDOMElement tableElement, in PRInt32 rowIndex, in PRInt32 colIndex,
|
|
|
|
out PRInt32 startRowIndex, out PRInt32 startColIndex,
|
|
|
|
out PRInt32 rowSpan, out PRInt32 colSpan, out boolean isSelected);
|
1999-07-27 23:59:22 +00:00
|
|
|
|
1999-08-01 22:37:58 +00:00
|
|
|
/**** end of table editing *****/
|
|
|
|
|
1999-07-19 22:36:12 +00:00
|
|
|
/* Get list of embedded objects, e.g. for mail compose */
|
|
|
|
nsISupportsArray GetEmbeddedObjects();
|
|
|
|
|
1999-06-10 19:52:49 +00:00
|
|
|
/* Formatting */
|
|
|
|
void SetTextProperty(in wstring prop, in wstring attr, in wstring value);
|
|
|
|
void RemoveTextProperty(in wstring prop, in wstring attr);
|
1999-08-01 22:37:58 +00:00
|
|
|
void GetTextProperty(in wstring prop, in wstring attr, in wstring value, out boolean firstHas, out boolean anyHas, out boolean allHas);
|
1999-06-10 19:52:49 +00:00
|
|
|
void SetBodyAttribute(in wstring attr, in wstring value);
|
|
|
|
void SetBackgroundColor(in wstring color);
|
1999-07-01 19:32:35 +00:00
|
|
|
|
|
|
|
void ApplyStyleSheet(in wstring url);
|
1999-06-10 19:52:49 +00:00
|
|
|
|
1999-07-14 18:54:29 +00:00
|
|
|
/* Output.
|
|
|
|
* format is mime type, e.g. text/html;
|
|
|
|
* See nsIEditor.h for legal flag values.
|
|
|
|
*/
|
1999-08-21 08:54:47 +00:00
|
|
|
/* Get the contents, for output or other uses */
|
1999-07-14 18:54:29 +00:00
|
|
|
wstring GetContentsAs(in wstring format, in PRUint32 flags);
|
1999-08-21 08:54:47 +00:00
|
|
|
|
|
|
|
/* Debugging: dump content tree to stdout */
|
1999-07-14 18:54:29 +00:00
|
|
|
void DumpContentTree();
|
|
|
|
|
1999-06-10 19:52:49 +00:00
|
|
|
/* Utility */
|
|
|
|
wstring GetLocalFileURL(in nsIDOMWindow parent, in wstring filterType);
|
|
|
|
|
1999-09-01 01:22:37 +00:00
|
|
|
/**
|
|
|
|
* Tests if a node is a BLOCK element according the the HTML 4.0 DTD
|
|
|
|
* This does NOT consider CSS effect on display type
|
|
|
|
*/
|
1999-09-01 19:58:25 +00:00
|
|
|
boolean NodeIsBlock(in nsIDOMNode node);
|
1999-09-01 01:22:37 +00:00
|
|
|
|
1999-09-02 01:47:18 +00:00
|
|
|
/**
|
|
|
|
* This is similar to nsIDOMNode::cloneNode(),
|
|
|
|
* it assures the attribute nodes of the destination are identical with the source node
|
|
|
|
* by copying all existing attributes from the source and deleting those not in the source.
|
|
|
|
* This is used when the destination node (element) already exists
|
|
|
|
*
|
|
|
|
* The supplied nodes MUST BE ELEMENTS (most callers are working with nodes)
|
|
|
|
* destNode the destination element to operate on
|
|
|
|
* sourceNode the source element to copy attributes from
|
|
|
|
*/
|
|
|
|
void CloneAttributes(in nsIDOMNode destNode, in nsIDOMNode sourceNode);
|
|
|
|
|
1999-06-10 19:52:49 +00:00
|
|
|
void BeginBatchChanges();
|
|
|
|
void EndBatchChanges();
|
|
|
|
void RunUnitTests();
|
1999-06-14 20:02:46 +00:00
|
|
|
|
|
|
|
void StartLogging(in nsIFileSpec logFile);
|
|
|
|
void StopLogging();
|
1999-06-10 19:52:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
%{C++
|
|
|
|
extern nsresult
|
|
|
|
NS_NewEditorShell(nsIEditorShell** aEditorShell);
|
|
|
|
%}
|
|
|
|
|