gecko-dev/editor/idl/nsIEditorShell.idl
1999-08-04 02:06:03 +00:00

207 lines
6.9 KiB
Plaintext

/* -*- 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"
#include "nsIFileSpec.idl"
#include "nsISupportsArray.idl"
#include "nsIDocumentStateListener.idl"
%{C++
class nsIDOMWindow;
class nsIDOMDocument;
class nsIDOMSelection;
class nsIDOMElement;
class nsIDOMNode;
%}
interface nsIFileSpec;
[scriptable, uuid(9afff72b-ca9a-11d2-96c9-0060b0fb9956)]
interface nsIEditorShell : nsISupports
{
readonly attribute nsIDOMDocument editorDocument;
readonly attribute nsIDOMSelection editorSelection;
%{C++
enum {
eDocumentStatusUnmodified,
eDocumentStatusModified
};
%}
readonly attribute boolean documentModified;
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);
/* Register a doc state listener. This gets added to a list of listeners
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);
/* Unregister a listener.
If you call this after the editor has been instantiated, it calls through
to editor::RemoveDocumentStateListener().
*/
void UnregisterDocumentStateListener(in nsIDocumentStateListener docListener);
void Init();
/* Commands */
void NewWindow();
void Open();
void Save();
void SaveAs();
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();
void DeleteSelection(in PRInt32 action);
void Find();
void FindNext();
/* Structure change */
void InsertText(in wstring textToInsert);
void InsertSource(in wstring textToInsert);
void InsertBreak();
void InsertList(in wstring listType);
void Indent(in wstring indent);
void Align(in wstring align);
/* Element insert and property editing */
nsIDOMElement GetSelectedElement(in wstring tagName);
/* returns the element conversion of supplied node or a parent of required type */
nsIDOMElement GetElementOrParentByTagName(in wstring tagName, in nsIDOMNode node);
nsIDOMElement CreateElementWithDefaults(in wstring tagName);
void InsertElement(in nsIDOMElement element, in boolean deleteSelection);
void SaveHLineSettings(in nsIDOMElement element);
void InsertLinkAroundSelection(in nsIDOMElement anchorElement);
void SelectElement(in nsIDOMElement element);
void SetSelectionAfterElement(in nsIDOMElement element);
/***** Table editing *****/
/* These are done relative to selected cell
or cell contain the selection anchor */
void InsertTableCell(in PRInt32 number, in PRBool after);
void InsertTableRow(in PRInt32 number, in PRBool after);
void InsertTableColumn(in PRInt32 number, in PRBool after);
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);
/* Get the indexes from layout's cellmap */
PRInt32 GetRowIndex(in nsIDOMElement cellElement);
PRInt32 GetColumnIndex(in nsIDOMElement cellElement);
/** 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 */
nsIDOMElement GetCellAt(in nsIDOMElement tableElement, in PRInt32 rowIndex, in PRInt32 colIndex);
/* 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);
/**** end of table editing *****/
/* 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);
void GetTextProperty(in wstring prop, in wstring attr, in wstring value, out boolean firstHas, out boolean anyHas, out boolean allHas);
void SetBodyAttribute(in wstring attr, in wstring value);
void SetBackgroundColor(in wstring color);
void ApplyStyleSheet(in wstring url);
/* Output.
* format is mime type, e.g. text/html;
* See nsIEditor.h for legal flag values.
*/
wstring GetContentsAs(in wstring format, in PRUint32 flags);
/* For debugging, dump the content tree: */
void DumpContentTree();
/* Utility */
wstring GetLocalFileURL(in nsIDOMWindow parent, in wstring filterType);
void BeginBatchChanges();
void EndBatchChanges();
void RunUnitTests();
void StartLogging(in nsIFileSpec logFile);
void StopLogging();
};
%{C++
extern nsresult
NS_NewEditorShell(nsIEditorShell** aEditorShell);
%}