part of big editor checkin for 66318. this is NOT part of build yet but patches for this big change are going around to be approved so these files WILL be looked at. have no fear

This commit is contained in:
mjudge%netscape.com 2001-03-27 23:11:08 +00:00
parent c3982c4c90
commit 8135be47de
8 changed files with 1687 additions and 0 deletions

47
editor/idl/nsICiter.idl Normal file
View File

@ -0,0 +1,47 @@
/* -*- 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.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsICiter_h__
#define nsICiter_h__
#include "nsISupports.idl"
#include "domstubs.idl"
/** Handle plaintext citations, as in mail quoting.
* Used by the editor but not dependant on it.
*/
[scriptable, uuid(a6cf9102-15b3-11d2-932e-00805f8add32)]
interface nsICiter : nsISupports
{
DOMString GetCiteString(in DOMString aInString);
DOMString StripCites(in DOMString aInString);
DOMString Rewrap(in DOMString aInString,
in unsigned long aWrapCol, in unsigned long aFirstLineOffset,
in boolean aRespectNewlines);
};

View File

@ -0,0 +1,215 @@
/* -*- 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.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
#include "domstubs.idl"
#include "nsISelection.idl"
/*
Editor Action Listener interface to outside world
*/
/**
* A generic editor action listener interface.
* <P>
* nsIEditActionListener is the interface used by applications wishing to be notified
* when the editor modifies the DOM tree.
*
* Note: this is the wrong class to implement if you are interested in generic
* change notifications. For generic notifications, you should implement
* nsIDocumentObserver.
*/
[scriptable, uuid(b22907b1-ee93-11d2-8d50-000064657374)]
interface nsIEditActionListener : nsISupports{
/**
* Called before the editor creates a node.
* @param aTag The tag name of the DOM Node to create.
* @param aParent The node to insert the new object into
* @param aPosition The place in aParent to insert the new node
* 0=first child, 1=second child, etc.
* any number > number of current children = last child
*/
void WillCreateNode(in DOMString aTag,
in nsIDOMNode aParent,
in long aPosition);
/**
* Called after the editor creates a node.
* @param aTag The tag name of the DOM Node to create.
* @param aNode The DOM Node that was created.
* @param aParent The node to insert the new object into
* @param aPosition The place in aParent to insert the new node
* 0=first child, 1=second child, etc.
* any number > number of current children = last child
* @param aResult The result of the create node operation.
*/
void DidCreateNode(in DOMString aTag,
in nsIDOMNode aNode,
in nsIDOMNode aParent,
in long aPosition,
in nsresult aResult);
/**
* Called before the editor inserts a node.
* @param aNode The DOM Node to insert.
* @param aParent The node to insert the new object into
* @param aPosition The place in aParent to insert the new node
* 0=first child, 1=second child, etc.
* any number > number of current children = last child
*/
void WillInsertNode(in nsIDOMNode aNode,
in nsIDOMNode aParent,
in long aPosition);
/**
* Called after the editor inserts a node.
* @param aNode The DOM Node to insert.
* @param aParent The node to insert the new object into
* @param aPosition The place in aParent to insert the new node
* 0=first child, 1=second child, etc.
* any number > number of current children = last child
* @param aResult The result of the insert node operation.
*/
void DidInsertNode(in nsIDOMNode aNode,
in nsIDOMNode aParent,
in long aPosition,
in nsresult aResult);
/**
* Called before the editor deletes a node.
* @param aChild The node to delete
*/
void WillDeleteNode(in nsIDOMNode aChild);
/**
* Called after the editor deletes a node.
* @param aChild The node to delete
* @param aResult The result of the delete node operation.
*/
void DidDeleteNode(in nsIDOMNode aChild, in nsresult aResult);
/**
* Called before the editor splits a node.
* @param aExistingRightNode the node to split. It will become the new node's next sibling.
* @param aOffset the offset of aExistingRightNode's content|children to do the split at
* @param aNewLeftNode [OUT] the new node resulting from the split, becomes aExistingRightNode's previous sibling.
*/
void WillSplitNode(in nsIDOMNode aExistingRightNode,
in long aOffset);
/**
* Called after the editor splits a node.
* @param aExistingRightNode the node to split. It will become the new node's next sibling.
* @param aOffset the offset of aExistingRightNode's content|children to do the split at
* @param aNewLeftNode [OUT] the new node resulting from the split, becomes aExistingRightNode's previous sibling.
*/
void DidSplitNode(in nsIDOMNode aExistingRightNode,
in long aOffset,
in nsIDOMNode aNewLeftNode,
in nsresult aResult);
/**
* Called before the editor joins 2 nodes.
* @param aLeftNode This node will be merged into the right node
* @param aRightNode The node that will be merged into.
* There is no requirement that the two nodes be of
* the same type.
* @param aParent The parent of aRightNode
*/
void WillJoinNodes(in nsIDOMNode aLeftNode,
in nsIDOMNode aRightNode,
in nsIDOMNode aParent);
/**
* Called after the editor joins 2 nodes.
* @param aLeftNode This node will be merged into the right node
* @param aRightNode The node that will be merged into.
* There is no requirement that the two nodes be of
* the same type.
* @param aParent The parent of aRightNode
* @param aResult The result of the join operation.
*/
void DidJoinNodes(in nsIDOMNode aLeftNode,
in nsIDOMNode aRightNode,
in nsIDOMNode aParent,
in nsresult aResult);
/**
* Called before the editor inserts text.
* @param aTextNode This node getting inserted text
* @param aOffset The offset in aTextNode to insert at.
* @param aString The string that gets inserted.
*/
void WillInsertText(in nsIDOMCharacterData aTextNode,
in long aOffset,
in DOMString aString);
/**
* Called after the editor inserts text.
* @param aTextNode This node getting inserted text
* @param aOffset The offset in aTextNode to insert at.
* @param aString The string that gets inserted.
* @param aResult The result of the insert text operation.
*/
void DidInsertText(in nsIDOMCharacterData aTextNode,
in long aOffset,
in DOMString aString,
in nsresult aResult);
/**
* Called before the editor deletes text.
* @param aTextNode This node getting text deleted
* @param aOffset The offset in aTextNode to delete at.
* @param aLength The amount of text to delete.
*/
void WillDeleteText(in nsIDOMCharacterData aTextNode,
in long aOffset,
in long aLength);
/**
* Called before the editor deletes text.
* @param aTextNode This node getting text deleted
* @param aOffset The offset in aTextNode to delete at.
* @param aLength The amount of text to delete.
* @param aResult The result of the delete text operation.
*/
void DidDeleteText(in nsIDOMCharacterData aTextNode,
in long aOffset,
in long aLength,
in nsresult aResult);
/**
* Called before the editor deletes the selection.
* @param aSelection The selection to be deleted
*/
void WillDeleteSelection(in nsISelection aSelection);
/**
* Called after the editor deletes the selection.
* @param aSelection The selection, after deletion
*/
void DidDeleteSelection(in nsISelection aSelection);
};

497
editor/idl/nsIEditor.idl Normal file
View File

@ -0,0 +1,497 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is Netscape
* Communications, Inc. Portions created by Netscape are
* Copyright (C) 1999, Mozilla. All Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
#include "domstubs.idl"
#include "nsISelection.idl"
#include "nsISelectionController.idl"
#include "nsIFile.idl"
#include "nsIAtom.idl"
#include "nsIOutputStream.idl"
#include "nsIDocumentStateListener.idl"
%{C++
//class nsIDOMDocument;
//class nsIDOMElement;
//class nsIDOMNode;
class nsIPresShell;
class nsIContent;
class nsITransactionManager;
class nsITransaction;
class nsIEditorObserver;
class nsITransaction;
class nsIEditActionListener;
typedef short EDirection;
%}
/*[ptr] native nsIDOMDocumentPtr(nsIDOMDocument);
[ptr] native nsIDOMElementPtr(nsIDOMElement);
[ptr] native nsIDOMNode(nsIDOMNode);*/
[ptr] native nsIPresShellPtr(nsIPresShell);
[ptr] native nsIContentPtr(nsIContent);
[ptr] native nsITransactionManagerPtr(nsITransactionManager);
[ptr] native nsITransactionPtr(nsITransaction);
/*
[ref] native nsReadStringRef(nsAReadableString);
[ptr] native nsReadStringPtr(nsAReadableString);*/
[ptr] native nsIEditorObserverPtr(nsIEditorObserver);
[ptr] native nsIEditActionListenerPtr(nsIEditActionListener);
[scriptable, uuid(06b979ce-1dd2-11b2-b6c7-a8bc47aa06b6)]
interface nsIEditor : nsISupports
{
%{C++
typedef short EDirection;
%}
const short eNone = 0;
const short eNext = 1;
const short ePrevious = 2;
const short eNextWord = 3;
const short ePreviousWord = 4;
const short eToBeginningOfLine = 5;
const short eToEndOfLine = 6;
/**
* Init is to tell the implementation of nsIEditor to begin its services
* @param aDoc The dom document interface being observed
* @param aPresShell TEMP: The presentation shell displaying the document
* once events can tell us from what pres shell they originated,
* this will no longer be necessary and the editor will no longer be
* linked to a single pres shell.
* @param aRoot This is the root of the editable section of this document. if it is null then we get root from document body.
* @param aSelCon this should be used to get the selection location
* @param aFlags A bitmask of flags for specifying the behavior of the editor.
*/
[noscript] void Init(in nsIDOMDocument doc, in nsIPresShellPtr shell, in nsIContentPtr aRoot, in nsISelectionController aSelCon, in unsigned long aFlags);
/**
* PostCreate should be called after Init, and is the time that the editor tells
* its documentStateObservers that the document has been created.
*/
void PostCreate();
/**
* PreDestroy is called before the editor goes away, and gives the editor a chance
* to tell its documentStateObservers that the document is going away.
*/
void PreDestroy();
/** return the edit flags for this editor */
void GetFlags(out unsigned long flags);
/** set the edit flags for this editor. May be called at any time. */
void SetFlags(in unsigned long aFlags);
/**
* return the DOM Document this editor is associated with
*
* @param aDoc [OUT] the dom interface being observed, refcounted
*/
void GetDocument(out nsIDOMDocument doc);
/** return the body element
* @param aElement return value for the root of the editable document
*/
void GetRootElement(out nsIDOMElement element);
/**
* return the presentation shell this editor is associated with
*
* @param aPS [OUT] the pres shell, refcounted
*/
//NS_IMETHOD GetPresShell(nsIPresShell **aPS);
/**
* return the selection controller for the current presentation
*
* @param aSelCon [OUT] the selection controller, refcounted
*/
void GetSelectionController(out nsISelectionController selectioncontroller);
/**
* return the DOM Selection for the presentation shell that has focus
* (or most recently had focus.)
* @param aSelection [OUT] the dom interface for the selection
*/
void GetSelection(out nsISelection selection);
/* ------------ Selected content removal -------------- */
/**
* DeleteSelection removes all nodes in the current selection.
* @param aDir if eLTR, delete to the right (for example, the DEL key)
* if eRTL, delete to the left (for example, the BACKSPACE key)
*/
void DeleteSelection(in short action);
/* ------------ Document info and file methods -------------- */
/** Returns true if the document has no *meaningful* content */
void GetDocumentIsEmpty(out boolean documentIsEmpty);
/** Returns true if the document is modifed and needs saving */
void GetDocumentModified(out boolean outDocModified);
/** Returns the current 'Save' document character set */
void GetDocumentCharacterSet(out DOMString characterSet);
/** Sets the current 'Save' document character set */
void SetDocumentCharacterSet(in DOMString characterSet);
/** Save document to a file
* Note: No UI is used
* @param aFileSpec
* The file to save to
* @param aReplaceExisting
* true if replacing an existing file, otherwise false.
* If false and aFileSpec exists, SaveFile returns an error.
* @param aSaveCopy
* 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)
* @param aFormat
* Mime type to save (text/plain or text/html)
*/
void SaveFile(in nsIFile fileSpec, in boolean replaceExisting, in boolean saveCopy, in DOMString format);
/* ------------ Transaction methods -------------- */
/** GetTransactionManagerDo() Get the transaction manager
*
* @return aTxnManager the transaction manager that the editor is using
*/
[noscript]void GetTransactionManager(out nsITransactionManagerPtr txnManager);
/** Do() fires a transaction. It is provided here so clients can create their own transactions.
* If a transaction manager is present, it is used.
* Otherwise, the transaction is just executed directly.
*
* @param aTxn the transaction to execute
*/
[noscript]void Do(in nsITransactionPtr txn);
/** turn the undo system on or off
* @param aEnable if PR_TRUE, the undo system is turned on if it is available
* if PR_FALSE the undo system is turned off if it was previously on
* @return if aEnable is PR_TRUE, returns NS_OK if the undo system could be initialized properly
* if aEnable is PR_FALSE, returns NS_OK.
*/
void EnableUndo(in boolean enable);
/** Undo reverses the effects of the last Do operation, if Undo is enabled in the editor.
* It is provided here so clients need no knowledge of whether the editor has a transaction manager or not.
* If a transaction manager is present, it is told to undo and the result of
* that undo is returned.
* Otherwise, the Undo request is ignored and an error NS_ERROR_NOT_AVAILABLE is returned.
*
*/
void Undo(in unsigned long count);
/** returns state information about the undo system.
* @param aIsEnabled [OUT] PR_TRUE if undo is enabled
* @param aCanUndo [OUT] PR_TRUE if at least one transaction is currently ready to be undone.
*/
void CanUndo(out boolean isEnabled, out boolean canUndo);
/** Redo reverses the effects of the last Undo operation
* It is provided here so clients need no knowledge of whether the editor has a transaction manager or not.
* If a transaction manager is present, it is told to redo and the result of the previously undone
* transaction is reapplied to the document.
* If no transaction is available for Redo, or if the document has no transaction manager,
* the Redo request is ignored and an error NS_ERROR_NOT_AVAILABLE is returned.
*
*/
void Redo(in unsigned long count);
/** returns state information about the redo system.
* @param aIsEnabled [OUT] PR_TRUE if redo is enabled
* @param aCanRedo [OUT] PR_TRUE if at least one transaction is currently ready to be redone.
*/
void CanRedo(out boolean isEnabled, out boolean canRedo);
/** BeginTransaction is a signal from the caller to the editor that the caller will execute multiple updates
* to the content tree that should be treated as a single logical operation,
* in the most efficient way possible.<br>
* All transactions executed between a call to BeginTransaction and EndTransaction will be undoable as
* an atomic action.<br>
* EndTransaction must be called after BeginTransaction.<br>
* Calls to BeginTransaction can be nested, as long as EndTransaction is called once per BeginUpdate.
*/
void BeginTransaction();
/** EndTransaction is a signal to the editor that the caller is finished updating the content model.<br>
* BeginUpdate must be called before EndTransaction is called.<br>
* Calls to BeginTransaction can be nested, as long as EndTransaction is called once per BeginTransaction.
*/
void EndTransaction();
void BeginPlaceHolderTransaction(in nsIAtom name);
void EndPlaceHolderTransaction();
void ShouldTxnSetSelection(out boolean result);
/* ------------ Clipboard methods -------------- */
/** cut the currently selected text, putting it into the OS clipboard
* What if no text is selected?
* What about mixed selections?
* What are the clipboard formats?
*/
void Cut();
/** Can we cut? True if the doc is modifiable, and we have a non-
* collapsed selection.
*/
void CanCut(out boolean canCut);
/** copy the currently selected text, putting it into the OS clipboard
* What if no text is selected?
* What about mixed selections?
* What are the clipboard formats?
*/
void Copy();
/** Can we copy? True if we have a non-collapsed selection.
*/
void CanCopy(out boolean aCanCopy);
/** paste the text in the OS clipboard at the cursor position, replacing
* the selected text (if any)
*/
void Paste(in long aSelectionType);
/** Can we paste? True if the doc is modifiable, and we have
* pasteable data in the clipboard.
*/
void CanPaste(in long aSelectionType, out boolean aCanPaste);
/* ------------ Selection methods -------------- */
/** sets the document selection to the entire contents of the document */
void SelectAll();
/** sets the document selection to the beginning of the document */
void BeginningOfDocument();
/** sets the document selection to the end of the document */
void EndOfDocument();
/** Can we paste? True if the doc is modifiable, and we have
* pasteable data in the clipboard.
*/
/* ------------ Drag/Drop methods -------------- */
/**
* CanDrag decides if a drag should be started
* (for example, based on the current selection and mousepoint).
*/
void CanDrag(in nsIDOMEvent aEvent, out boolean aCanDrag);
/**
* DoDrag transfers the relevant data (as appropriate)
* to a transferable so it can later be dropped.
*/
void DoDrag(in nsIDOMEvent aEvent);
/**
* InsertFromDrop looks for a dragsession and inserts the
* relevant data in response to a drop.
*/
void InsertFromDrop(in nsIDOMEvent aEvent);
/* ------------ Node manipulation methods -------------- */
/**
* Tests if a node is a BLOCK element according the the HTML 4.0 DTD
* This does NOT consider CSS effect on display type
*
* @param aNode the node to test
*/
void NodeIsBlock(in nsIDOMNode node, out boolean isBlock);
/**
* SetAttribute() sets the attribute of aElement.
* No checking is done to see if aAttribute is a legal attribute of the node,
* or if aValue is a legal value of aAttribute.
*
* @param aElement the content element to operate on
* @param aAttribute the string representation of the attribute to set
* @param aValue the value to set aAttribute to
*/
void SetAttribute(in nsIDOMElement aElement, in DOMString attributestr, in DOMString attvalue);
/**
* GetAttributeValue() retrieves the attribute's value for aElement.
*
* @param aElement the content element to operate on
* @param aAttribute the string representation of the attribute to get
* @param aResultValue the value of aAttribute. only valid if aResultIsSet is PR_TRUE
* @param aResultIsSet PR_TRUE if aAttribute is set on the current node, PR_FALSE if it is not.
*/
void GetAttributeValue(in nsIDOMElement aElement,
in DOMString attributestr,
out DOMString resultValue,
out boolean resultIsSet);
/**
* RemoveAttribute() deletes aAttribute from the attribute list of aElement.
* If aAttribute is not an attribute of aElement, nothing is done.
*
* @param aElement the content element to operate on
* @param aAttribute the string representation of the attribute to get
*/
void RemoveAttribute(in nsIDOMElement aElement,
in DOMString aAttribute);
/**
* CloneAttributes() 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)
* @param aDestNode the destination element to operate on
* @param aSourceNode the source element to copy attributes from
*/
void CloneAttributes(in nsIDOMNode destNode, in nsIDOMNode sourceNode);
/**
* CreateNode instantiates a new element of type aTag and inserts it into aParent at aPosition.
* @param aTag The type of object to create
* @param aParent The node to insert the new object into
* @param aPosition The place in aParent to insert the new node
* @param aNewNode [OUT] The node created. Caller must release aNewNode.
*/
void CreateNode(in DOMString tag,
in nsIDOMNode parent,
in long position,
out nsIDOMNode newNode);
/**
* InsertNode inserts aNode into aParent at aPosition.
* No checking is done to verify the legality of the insertion. That is the
* responsibility of the caller.
* @param aNode The DOM Node to insert.
* @param aParent The node to insert the new object into
* @param aPosition The place in aParent to insert the new node
* 0=first child, 1=second child, etc.
* any number > number of current children = last child
*/
void InsertNode(in nsIDOMNode vode,
in nsIDOMNode parent,
in long aPosition);
/**
* SplitNode() creates a new node identical to an existing node, and split the contents between the two nodes
* @param aExistingRightNode the node to split. It will become the new node's next sibling.
* @param aOffset the offset of aExistingRightNode's content|children to do the split at
* @param aNewLeftNode [OUT] the new node resulting from the split, becomes aExistingRightNode's previous sibling.
*/
void SplitNode(in nsIDOMNode existingRightNode,
in long offset,
out nsIDOMNode newLeftNode);
/**
* JoinNodes() takes 2 nodes and merge their content|children.
* @param aLeftNode The left node. It will be deleted.
* @param aRightNode The right node. It will remain after the join.
* @param aParent The parent of aExistingRightNode
*
* There is no requirement that the two nodes be of the same type.
* However, a text node can be merged only with another text node.
*/
void JoinNodes(in nsIDOMNode leftNode,
in nsIDOMNode rightNode,
in nsIDOMNode parent);
/**
* DeleteNode removes aChild from aParent.
* @param aChild The node to delete
*/
void DeleteNode(in nsIDOMNode child);
/**
* InsertFormattingForNode() sets a special dirty attribute on the node.
* Usually this will be called immediately after creating a new node.
* @param aNode The node for which to insert formatting.
*/
void MarkNodeDirty(in nsIDOMNode node);
/* ------------ Output methods -------------- */
/**
* Output methods:
* aFormatType is a mime type, like text/plain.
*/
void OutputToString(out DOMString outputString,
[const]in DOMString formatType,
in unsigned long flags);
void OutputToStream(in nsIOutputStream outputStream,
[const] in DOMString formatType,
[const] in DOMString charsetOverride,
in unsigned long flags);
/* ------------ Various listeners methods -------------- */
/** add an EditorObserver to the editors list of observers. */
[noscript]void AddEditorObserver(in nsIEditorObserverPtr observer);
/** Remove an EditorObserver from the editor's list of observers. */
[noscript]void RemoveEditorObserver(in nsIEditorObserverPtr observer);
/** add an EditActionListener to the editors list of listeners. */
[noscript]void AddEditActionListener(in nsIEditActionListenerPtr listener);
/** Remove an EditActionListener from the editor's list of listeners. */
[noscript]void RemoveEditActionListener(in nsIEditActionListenerPtr listener);
/** Add a DocumentStateListener to the editors list of doc state listeners. */
[noscript]void AddDocumentStateListener(in nsIDocumentStateListener listener);
/** Remove a DocumentStateListener to the editors list of doc state listeners. */
[noscript]void RemoveDocumentStateListener(in nsIDocumentStateListener listener);
/* ------------ Debug methods -------------- */
/**
* And a debug method -- show us what the tree looks like right now
*/
void DumpContentTree();
/** Dumps a text representation of the content tree to standard out */
void DebugDumpContent() ;
/* Run unit tests. Noop in optimized builds */
void DebugUnitTests(out long outNumTests, out long outNumTestsFailed);
};

View File

@ -0,0 +1,79 @@
/* -*- 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.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
#include "domstubs.idl"
%{C++
class nsIPrivateTextRangeList;
struct nsTextEventReply;
struct nsReconversionEventReply;
%}
[ptr] native nsIPrivateTextRangeListPtr(nsIPrivateTextRangeList);
[ptr] native nsTextEventReplyPtr(nsTextEventReply);
[ptr] native nsReconversionEventReplyPtr(nsReconversionEventReply);
[scriptable, uuid(4805e680-49b9-11d3-9ce4-ed60bd6cb5bc)]
interface nsIEditorIMESupport : nsISupports
{
/**
* BeginComposition(nsTextEventReply* aReply) Handles the start of inline input composition.
*/
[noscript] void BeginComposition(in nsTextEventReplyPtr aReply);
/**
* SetCompositionString() Sets the inline input composition string.
* BeginComposition must be called prior to this.
*/
[noscript] void SetCompositionString(in DOMString aCompositionString, in nsIPrivateTextRangeListPtr aTextRange, in nsTextEventReplyPtr aReply);
/**
* EndComposition() Handles the end of inline input composition.
*/
[noscript] void EndComposition();
/**
* QueryComposition() Get the composition position
*/
[noscript] void QueryComposition(in nsTextEventReplyPtr aReply);
/**
* ForceCompositionEnd() force the composition end
*/
[noscript] void ForceCompositionEnd();
/**
* GetReconvertionString() Get the reconvertion string
*/
[noscript] void GetReconversionString(in nsReconversionEventReplyPtr aReply);
};
#endif // nsIEditorIMESupport_h__

View File

@ -0,0 +1,43 @@
/* -*- 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.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
/*
Editor Observer interface to outside world
*/
[scriptable, uuid(a6cf9125-15b3-11d2-932e-00805f8add32)]
/**
* A generic editor observer interface.
* <P>
* nsIEditorObserver is the interface used by applications wishing to be notified
* when the editor has completed a user action.
*
*/
interface nsIEditorObserver : nsISupports {
/**
* Called after the editor completes a user action.
*/
void EditAction();
};

View File

@ -0,0 +1,74 @@
/* -*- 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.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
[scriptable, uuid(4805e682-49b9-11d3-9ce4-ed60bd6cb5bc)]
interface nsIEditorStyleSheets : nsISupports
{
/** load and apply the style sheet, specified by aURL, to
* the editor's document. This can involve asynchronous
* network I/O
* @param aURL The style sheet to be loaded and applied.
* @param aStyleSheet Optional: if not null, return the style sheet created from aURL
*/
void ApplyStyleSheet([const]in wstring, out nsICSSStyleSheet **aStyleSheet);
/** load and apply an Override style sheet, specified by aURL, to
* the editor's document.
* IMPORTANT: This is assumed to be synchronous:
* URL is a local file with no @import used
* This action is not undoable.
* It is not intended for use by "user", only editor developers
* to change display behavior for editing (like showing special cursors)
* that will not be affected by loading other "document" style sheets
* loaded using ApplyStyleSheet.
*
* @param aURL The style sheet to be loaded and applied.
* @param aStyleSheet Optional: if not null, return the style sheet created from aURL
*/
NS_IMETHOD ApplyOverrideStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet)=0;
/** Add the given Style Sheet to the editor's document
* This is always synchronous
* @param aSheet The style sheet to be applied.
*/
NS_IMETHOD AddStyleSheet(nsICSSStyleSheet* aSheet)=0;
/** Remove the given Style Sheet from the editor's document
* This is always synchronous
* @param aSheet The style sheet to be removed
*/
NS_IMETHOD RemoveStyleSheet(nsICSSStyleSheet* aSheet)=0;
/** Remove the given Override Style Sheet from the editor's document
* This is always synchronous
* @param aSheet The style sheet to be removed.
*/
NS_IMETHOD RemoveOverrideStyleSheet(nsICSSStyleSheet* aSheet)=0;
};

View File

@ -0,0 +1,401 @@
/* -*- 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.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
#include "domstubs.idl"
#include "nsIAtom.idl"
%{C++
#define NS_EDITOR_ELEMENT_NOT_FOUND \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_EDITOR, 1)
%}
[scriptable, uuid(4b0fd0d0-1dd2-11b2-bf2e-ef20fbca2c88)]
interface nsIHTMLEditor : nsISupports
{
%{C++
typedef short EAlignment;
%}
// used by GetAlignment()
const short eLeft = 0;
const short eCenter = 1;
const short eRight = 2;
const short eJustify = 3;
/* ------------ Inline property methods -------------- */
/**
* SetInlineProperty() sets the aggregate properties on the current selection
*
* @param aProperty the property to set on the selection
* @param aAttribute the attribute of the property, if applicable. May be null.
* Example: aProperty="font", aAttribute="color"
* @param aValue if aAttribute is not null, the value of the attribute. May be null.
* Example: aProperty="font", aAttribute="color", aValue="0x00FFFF"
*/
void SetInlineProperty(in nsIAtom aProperty,
in DOMString aAttribute,
in DOMString aValue);
/**
* GetInlineProperty() gets the aggregate properties of the current selection.
* All object in the current selection are scanned and their attributes are
* represented in a list of Property object.
*
* @param aProperty the property to get on the selection
* @param aAttribute the attribute of the property, if applicable. May be null.
* Example: aProperty="font", aAttribute="color"
* @param aValue if aAttribute is not null, the value of the attribute. May be null.
* Example: aProperty="font", aAttribute="color", aValue="0x00FFFF"
* @param aFirst [OUT] PR_TRUE if the first text node in the selection has the property
* @param aAny [OUT] PR_TRUE if any of the text nodes in the selection have the property
* @param aAll [OUT] PR_TRUE if all of the text nodes in the selection have the property
*/
void GetInlineProperty(in nsIAtom aProperty,
in DOMString aAttribute,
in DOMString aValue,
out boolean aFirst, out boolean aAny, out boolean aAll);
void GetInlinePropertyWithAttrValue(in nsIAtom aProperty,
in DOMString aAttribute,
in DOMString aValue,
out boolean aFirst, out boolean aAny, out boolean aAll,
out DOMString outValue);
/**
* RemoveAllInlineProperties() deletes all the inline properties from all
* text in the current selection.
*/
void RemoveAllInlineProperties();
/**
* RemoveInlineProperty() deletes the properties from all text in the current selection.
* If aProperty is not set on the selection, nothing is done.
*
* @param aProperty the property to remove from the selection
* All atoms are for normal HTML tags (e.g.: nsIEditorProptery::font)
* except when you want to remove just links and not named anchors
* For that, use nsIEditorProperty::href
* @param aAttribute the attribute of the property, if applicable. May be null.
* Example: aProperty=nsIEditorProptery::font, aAttribute="color"
* nsIEditProperty::allAttributes is special. It indicates that
* all content-based text properties are to be removed from the selection.
*/
void RemoveInlineProperty(in nsIAtom aProperty, in DOMString aAttribute);
/**
* Increase font size for text in selection by 1 HTML unit
* All existing text is scanned for existing <FONT SIZE> attributes
* so they will be incremented instead of inserting new <FONT> tag
*/
void IncreaseFontSize();
/**
* Decrease font size for text in selection by 1 HTML unit
* All existing text is scanned for existing <FONT SIZE> attributes
* so they will be decreased instead of inserting new <FONT> tag
*/
void DecreaseFontSize();
/* ------------ Drag/Drop methods -------------- */
/**
* CanDrag decides if a drag should be started
* (for example, based on the current selection and mousepoint).
*/
void CanDrag(in nsIDOMEvent aEvent, out boolean aCanDrag);
/**
* DoDrag transfers the relevant data (as appropriate)
* to a transferable so it can later be dropped.
*/
void DoDrag(in nsIDOMEvent aEvent);
/**
* InsertFromDrop looks for a dragsession and inserts the
* relevant data in response to a drop.
*/
void InsertFromDrop(in nsIDOMEvent aEvent);
/* ------------ HTML content methods -------------- */
/**
* Insert some HTML source at the current location
*
* @param aInputString the string to be inserted
*/
void InsertHTML(in DOMString aInputString);
/** Rebuild the entire document from source HTML
* Needed to be able to edit HEAD and other outside-of-BODY content
*
* @param aSourceString HTML source string of the entire new document
*/
void RebuildDocumentFromSource(in DOMString aSourceString);
/**
* Insert some HTML source, interpreting
* the string argument according to the given charset.
*
* @param aInputString the string to be inserted
* @param aCharset Charset of string
* @param aParentNode Parent to insert under.
* If null, insert at the current location.
*/
void InsertHTMLWithCharset(in DOMString aInputString,
in DOMString aCharset);
/** 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.
*
* @param aElement The element to insert
* @param aDeleteSelection Delete the selection before inserting
* If aDeleteSelection 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
*/
void InsertElementAtSelection(in nsIDOMElement aElement, in boolean aDeleteSelection);
/** Set the documents title.
*/
void SetDocumentTitle(in DOMString aTitle);
/* ------------ Selection manipulation -------------- */
/* Should these be moved to nsISelection? */
/** Set the selection at the suppled element
*
* @param aElement An element in the document
*/
void SelectElement(in nsIDOMElement aElement);
/** Create a collapsed selection just after aElement
*
* XXX could we parameterize SelectElement(before/select/after>?
*
* The selection is set to parent-of-aElement with an
* offset 1 greater than aElement's offset
* but it enforces the HTML 4.0 DTD "CanContain" rules, so it should
* be useful for other elements.
*
* @param aElement An element in the document
*/
void SetCaretAfterElement(in nsIDOMElement aElement);
/**
* SetParagraphFormat Insert a block paragraph tag around selection
* @param aParagraphFormat "p", "h1" to "h6", "address", "pre", or "blockquote"
*/
void SetParagraphFormat(in DOMString aParagraphFormat);
/**
* GetParagraphState returns what block tag paragraph format is in the selection.
* @param aMixed True if there is more than one format
* @param outState Name of block tag. "" is returned for none.
*/
void GetParagraphState(out boolean aMixed,out DOMString outState);
/**
* GetFontFaceState returns what font face is in the selection.
* @param aMixed True if there is more than one font face
* @param outFace Name of face. Note: "tt" is returned for
* tt tag. "" is returned for none.
*/
void GetFontFaceState(out boolean aMixed,out DOMString outFont);
/**
* GetFontColorState returns what font face is in the selection.
* @param aMixed True if there is more than one font color
* @param outColor Color string. "" is returned for none.
*/
void GetFontColorState(out boolean aMixed,out DOMString outColor);
/**
* GetFontColorState returns what font face is in the selection.
* @param aMixed True if there is more than one font color
* @param outColor Color string. "" is returned for none.
*/
void GetBackgroundColorState(out boolean aMixed,out DOMString outColor);
/**
* GetListState returns what list type is in the selection.
* @param aMixed True if there is more than one type of list, or
* if there is some list and non-list
* @param aOL The company that employs me. No, really, it's
* true if an "ol" list is selected.
* @param aUL true if an "ul" list is selected.
* @param aDL true if a "dl" list is selected.
*/
void GetListState(out boolean aMixed, out boolean aOL, out boolean aUL, out boolean aDL);
/**
* GetListItemState returns what list item type is in the selection.
* @param aMixed True if there is more than one type of list item, or
* if there is some list and non-list
* @param aLI true if "li" list items are selected.
* @param aDT true if "dt" list items are selected.
* @param aDD true if "dd" list items are selected.
*/
void GetListItemState(out boolean aMixed, out boolean aLI, out boolean aDT, out boolean aDD);
/**
* GetAlignment returns what alignment is in the selection.
* @param aMixed True if there is more than one type of list item, or
* if there is some list and non-list
* @param aAlign enum value for first encountered alignment (left/center/right)
*/
void GetAlignment(out boolean aMixed, out short aAlign);
/**
* Document me!
*
*/
void GetIndentState(out boolean aCanIndent, out boolean aCanOutdent);
/**
* Document me!
*
*/
void MakeOrChangeList(in DOMString aListType, in boolean entireList);
/**
* Document me!
*
*/
void RemoveList(in DOMString aListType);
/**
* Document me!
*
*/
void Indent(in DOMString aIndent);
/**
* Document me!
*
*/
void Align(in DOMString aAlign);
/** 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.
*
* @param aTagName The HTML tagname
* Special input values:
* 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)
* Use "list" to get an OL, UL, or DL list node
* Use "td" to get either a TD or TH cell node
*
* @param aNode The node in the document to start the search
* If it is null, the anchor node of the current selection is used
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found (passes NS_SUCCEEDED macro)
*/
void GetElementOrParentByTagName(in DOMString aTagName, in nsIDOMNode aNode, out nsIDOMElement aReturn);
/** 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.
*
* @param aTagName 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)
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found (passes NS_SUCCEEDED macro)
*/
void GetSelectedElement(in DOMString aTagName, out nsIDOMElement aReturn);
/** Output the contents of the <HEAD> section as text/HTML format
*/
void GetHeadContentsAsHTML(out DOMString aOutputString);
/** Replace all children of <HEAD> with string of HTML source
*/
void ReplaceHeadContentsWithHTML(in DOMString aSourceToInsert);
/** 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)
*
* @param aTagName 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)
*/
void CreateElementWithDefaults(in DOMString aTagName, out nsIDOMElement aReturn);
/** Insert an link element as the parent of the current selection
*
* @param aElement An "A" element with a non-empty "href" attribute
*/
void InsertLinkAroundSelection(in nsIDOMElement aAnchorElement);
/** Set the value of the "bgcolor" attribute on the document's <body> element
*
* @param aColor The HTML color string, such as "#ffccff" or "yellow"
*/
void SetBackgroundColor(in DOMString aColor);
/** Set an attribute on the document's <body> element
* such as text, link, background colors
*
* 8/31/00 THIS ISN'T BEING USED? SHOULD WE DROP IT?
*
* @param aAttr The attribute to be set
* @param aValue The value of the attribute
*/
void SetBodyAttribute(in DOMString aAttr, in DOMString aValue);
//XXX Used to suppress spurious drag/drop events to workaround bug 50703
// Don't use this method! It will go away after first release!
void IgnoreSpuriousDragEvent(in boolean aIgnoreSpuriousDragEvent);
};

View File

@ -0,0 +1,331 @@
/* -*- 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.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
[scriptable, uuid(4805e684-49b9-11d3-9ce4-ed60bd6cb5bc)]
interface nsITableEditor : nsISupports
{
enum {
eNoSearch,
ePreviousColumn,
ePreviousRow
};
/* ------------ Table editing Methods -------------- */
/** Insert table methods
* Insert relative to the selected cell or the
* cell enclosing the selection anchor
* The selection is collapsed and is left in the new cell
* at the same row,col location as the original anchor cell
*
* @param aNumber Number of items to insert
* @param aAfter If TRUE, insert after the current cell,
* else insert before current cell
*/
void InsertTableCell(in long aNumber, in boolean aAfter);
void InsertTableColumn(in long aNumber, in boolean aAfter);
void InsertTableRow(in long aNumber, in boolean aAfter);
/** Delete table methods
* Delete starting at the selected cell or the
* cell (or table) enclosing the selection anchor
* The selection is collapsed and is left in the
* cell at the same row,col location as
* the previous selection anchor, if possible,
* else in the closest neigboring cell
*
* @param aNumber Number of items to insert/delete
*/
void DeleteTable();
/** Delete just the cell contents
* This is what should happen when Delete key is used
* for selected cells, to minimize upsetting the table layout
*/
void DeleteTableCellContents();
/** Delete cell elements as well as contents
* @param aNumber Number of contiguous cells, rows, or columns
*
* When there are more than 1 selected cells, aNumber is ignored.
* For Delete Rows or Columns, the complete columns or rows are
* determined by the selected cells. E.g., to delete 2 complete rows,
* user simply selects a cell in each, and they don't
* have to be contiguous.
*/
void DeleteTableCell(in long aNumber);
void DeleteTableColumn(in long aNumber);
void DeleteTableRow(in long aNumber);
/** Table Selection methods
* Selecting a row or column actually
* selects all cells (not TR in the case of rows)
*/
void SelectTableCell();
/** Select a rectangular block of cells:
* all cells falling within the row/column index of aStartCell
* to through the row/column index of the aEndCell
* aStartCell can be any location relative to aEndCell,
* as long as they are in the same table
* @param aStartCell starting cell in block
* @param aEndCell ending cell in block
*/
void SelectBlockOfCells(in nsIDOMElement aStartCell, in nsIDOMElement aEndCell);
void SelectTableRow();
void SelectTableColumn();
void SelectTable();
void SelectAllTableCells();
/** Create a new TD or TH element, the opposite type of the supplied aSourceCell
* 1. Copy all attributes from aSourceCell to the new cell
* 2. Move all contents of aSourceCell to the new cell
* 3. Replace aSourceCell in the table with the new cell
*
* @param aSourceCell The cell to be replaced
* @param aNewCell The new cell that replaces aSourceCell
*/
void SwitchTableCellHeaderType(in nsIDOMElement aSourceCell, out nsIDOMElement aNewCell);
/** Merges contents of all selected cells
* for selected cells that are adjacent,
* this will result in a larger cell with appropriate
* rowspan and colspan, and original cells are deleted
* The resulting cell is in the location of the
* cell at the upper-left corner of the adjacent
* block of selected cells
*
* @param aMergeNonContiguousContents:
* If true:
* Non-contiguous cells are not deleted,
* but their contents are still moved
* to the upper-left cell
* If false: contiguous cells are ignored
*
* If there are no selected cells,
* and selection or caret is in a cell,
* that cell and the one to the right
* are merged
*/
void JoinTableCells(in boolean aMergeNonContiguousContents);
/** Split a cell that has rowspan and/or colspan > 0
* into cells such that all new cells have
* rowspan = 1 and colspan = 1
* All of the contents are not touched --
* they will appear to be in the upper-left cell
*/
void SplitTableCell();
/** 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
* This doesn't doesn't change the selection,
* thus it can be used to fixup all tables
* in a page independant of the selection
*/
void NormalizeTable(in nsIDOMElement aTable);
/** Get the row an column index from the layout's cellmap
* If aTable is null, it will try to find enclosing table of selection ancho
*
*/
void GetCellIndexes(in nsIDOMElement aCell, out long aRowIndex, out long aColIndex);
/** Get the number of rows and columns in a table from the layout's cellmap
* If aTable is null, it will try to find enclosing table of selection ancho
* Note that all rows in table will not have this many because of
* ROWSPAN effects or if table is not "rectangular" (has short rows)
*/
void GetTableSize(in nsIDOMElement aTable, out long aRowCount, out long aColCount);
/** Get a cell element at cellmap grid coordinates
* A cell that spans across multiple cellmap locations will
* be returned multiple times, once for each location it occupies
*
* @param aTable A table in the document
* @param aRowIndex, aColIndex The 0-based cellmap indexes
*
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found (passes NS_SUCCEEDED macro)
* You can scan for all cells in a row or column
* by iterating through the appropriate indexes
* until the returned aCell is null
*/
void GetCellAt(in nsIDOMElement aTable, in long aRowIndex, in long aColIndex, out nsIDOMElement aCell);
/** Get a cell at cellmap grid coordinates and associated data
* A cell that spans across multiple cellmap locations will
* be returned multiple times, once for each location it occupies
* Examine the returned aStartRowIndex and aStartColIndex to see
* if it is in the same layout column or layout row:
* A "layout row" is all cells sharing the same top edge
* A "layout column" is all cells sharing the same left edge
* This is important to determine what to do when inserting or deleting a column or row
*
* @param aTable A table in the document
* @param aRowIndex, aColIndex The 0-based cellmap indexes
* returns values:
* @param aCell The cell at this cellmap location
* @param aStartRowIndex The row index where cell starts
* @param aStartColIndex The col index where cell starts
* @param aRowSpan May be 0 (to span down entire table) or number of cells spanned
* @param aColSpan May be 0 (to span across entire table) or number of cells spanned
* @param aActualRowSpan The actual number of cellmap locations (rows) spanned by the cell
* @param aActualColSpan The actual number of cellmap locations (columns) spanned by the cell
* @param aIsSelected
* @param
*
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if a cell is not found (passes NS_SUCCEEDED macro)
*/
void GetCellDataAt(in nsIDOMElement aTable, in long aRowIndex, in long aColIndex, out nsIDOMElement aCell,
out long aStartRowIndex, out long aStartColIndex,
out long aRowSpan, out long aColSpan,
out long aActualRowSpan, out long aActualColSpan,
out boolean aIsSelected);
/** Get the first row element in a table
*
* @param aTableElement Any TABLE or child-of-table element in the document
* @param aRowIndex The 0-based index of the row
*
* Returns:
* @param aRow The row at the requested index
* Returns null if there are no rows in table
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found (passes NS_SUCCEEDED macro)
*/
void GetFirstRow(in nsIDOMElement aTableElement, out nsIDOMElement aRow);
/** Get the next row element starting the search from aTableElement
*
* @param aTableElement Any TR or child-of-TR element in the document
*
* Returns:
* @param aRow The row to start search from
* and the row returned from the search
* Returns null if there isn't another row
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found (passes NS_SUCCEEDED macro)
*/
void GetNextRow(in nsIDOMElement aTableElement, out nsIDOMElement aRow);
/** Preferred direction to search for neighboring cell
* when trying to locate a cell to place caret in after
* a table editing action.
* Used for aDirection param in SetSelectionAfterTableEdit
*/
/** Reset a selected cell or collapsed selection (the caret) after table editing
*
* @param aTable A table in the document
* @param aRow The row ...
* @param aCol ... and column defining the cell
* where we will try to place the caret
* @param aSelected If true, we select the whole cell instead of setting caret
* @param aDirection If cell at (aCol, aRow) is not found,
* search for previous cell in the same
* column (aPreviousColumn) or row (ePreviousRow)
* or don't search for another cell (aNoSearch)
* If no cell is found, caret is place just before table;
* and if that fails, at beginning of document.
* Thus we generally don't worry about the return value
* and can use the nsSetSelectionAfterTableEdit stack-based
* object to insure we reset the caret in a table-editing method.
*/
void SetSelectionAfterTableEdit(in nsIDOMElement aTable, in long aRow, in long aCol,
in long aDirection, in boolean aSelected);
/** Examine the current selection and find
* a selected TABLE, TD or TH, or TR element.
* or return the parent TD or TH if selection is inside a table cell
* Returns null if no table element is found.
*
* @param aTableElement The table element (table, row, or cell) returned
* @param aTagName The tagname of returned element
* Note that "td" will be returned if name is actually "th"
* @param aSelectedCount How many table elements were selected
* This tells us if we have multiple cells selected
* (0 if element is a parent cell of selection)
*
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found (passes NS_SUCCEEDED macro)
*/
void GetSelectedOrParentTableElement(out nsIDOMElement aTableElement, nsString& aTagName, out long aSelectedCount);
/** Generally used after GetSelectedOrParentTableElement
* to test if selected cells are complete rows or columns
*
* @param aElement Any table or cell element or any element inside a table
* Used to get enclosing table.
* If null, selection's anchorNode is used
*
* @param aSelectionType Returns:
* 0 aCellElement was not a cell (returned result = NS_ERROR_FAILURE)
* TABLESELECTION_CELL There are 1 or more cells selected
* but complete rows or columns are not selected
* TABLESELECTION_ROW All cells are in 1 or more rows
* and in each row, all cells selected
* Note: This is the value if all rows (thus all cells) are selected
* TABLESELECTION_COLUMN All cells are in 1 or more columns
* and in each column, all cells are selected
*/
void GetSelectedCellsType(nsIDOMElement *aElement, PRUint32 &aSelectionType);
/** Get first selected element from first selection range.
* Assumes cell-selection model where each cell
* is in a separate range (selection parent node is table row)
* @param aCell Selected cell or null if ranges don't contain cell selections
* @param aRange Optional: if not null, return the selection range
* associated with the cell
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found (passes NS_SUCCEEDED macro)
*/
void GetFirstSelectedCell(nsIDOMElement **aCell, nsIDOMRange **aRange);
/** Get first selected element from first selection range.
* Assumes cell-selection model where each cell
* is in a separate range (selection parent node is table row)
* @param aCell Selected cell or null if ranges don't contain cell selections
* @param aRowIndex Optional: if not null, return the row index of first cell
* @param aColIndex Optional: if not null, return the column index of first cell
*
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found (passes NS_SUCCEEDED macro)
*/
void GetFirstSelectedCellInTable(nsIDOMElement **aCell, PRInt32 *aRowIndex, PRInt32 *aColIndex);
/** Get next selected cell element from first selection range.
* Assumes cell-selection model where each cell
* is in a separate range (selection parent node is table row)
* Always call GetFirstSelectedCell() to initialize stored index of "next" cell
* @param aCell Selected cell or null if no more selected cells
* or ranges don't contain cell selections
* @param aRange Optional: if not null, return the selection range
* associated with the cell
*/
void GetNextSelectedCell(nsIDOMElement **aCell, nsIDOMRange **aRange);
};
#endif // nsITableEditor_h__