2001-09-26 02:53:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:21:17 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-03-31 23:25:05 +04:00
|
|
|
*
|
2004-04-18 18:21:17 +04:00
|
|
|
* 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/
|
1999-03-31 23:25:05 +04:00
|
|
|
*
|
2001-09-26 02:53:13 +04:00
|
|
|
* 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.
|
1999-03-31 23:25:05 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:21:17 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-26 02:53:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:43:54 +03:00
|
|
|
*
|
2001-09-26 02:53:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:21:17 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-26 02:53:13 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 18:21:17 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-26 02:53:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 18:21:17 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-26 02:53:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-03-31 23:25:05 +04:00
|
|
|
|
|
|
|
#ifndef nsITextServicesDocument_h__
|
|
|
|
#define nsITextServicesDocument_h__
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
|
|
|
|
|
|
|
class nsIDOMDocument;
|
2003-04-17 18:29:08 +04:00
|
|
|
class nsIDOMRange;
|
1999-03-31 23:25:05 +04:00
|
|
|
class nsIPresShell;
|
|
|
|
class nsIEditor;
|
|
|
|
class nsString;
|
2002-12-10 18:03:04 +03:00
|
|
|
class nsITextServicesFilter;
|
1999-03-31 23:25:05 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
TextServicesDocument interface to outside world
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define NS_ITEXTSERVICESDOCUMENT_IID \
|
|
|
|
{ /* 019718E1-CDB5-11d2-8D3C-000000000000 */ \
|
|
|
|
0x019718e1, 0xcdb5, 0x11d2, \
|
|
|
|
{ 0x8d, 0x3c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
1999-04-23 20:52:28 +04:00
|
|
|
* The nsITextServicesDocument presents the document in as a
|
|
|
|
* bunch of flattened text blocks. Each text block can be retrieved
|
|
|
|
* as an nsString (array of characters).
|
1999-03-31 23:25:05 +04:00
|
|
|
*/
|
|
|
|
class nsITextServicesDocument : public nsISupports{
|
|
|
|
public:
|
|
|
|
|
2005-11-11 17:36:26 +03:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITEXTSERVICESDOCUMENT_IID)
|
1999-03-31 23:25:05 +04:00
|
|
|
|
1999-04-23 20:52:28 +04:00
|
|
|
typedef enum { eDSNormal=0, eDSUndlerline } TSDDisplayStyle;
|
|
|
|
|
1999-05-11 23:16:24 +04:00
|
|
|
typedef enum { eBlockNotFound=0, // There is no text block (TB) in or before the selection (S).
|
|
|
|
eBlockOutside, // No TB in S, but found one before/after S.
|
|
|
|
eBlockInside, // S extends beyond the start and end of TB.
|
|
|
|
eBlockContains, // TB contains entire S.
|
|
|
|
eBlockPartial // S begins or ends in TB but extends outside of TB.
|
|
|
|
} TSDBlockSelectionStatus;
|
|
|
|
|
1999-04-23 20:52:28 +04:00
|
|
|
/**
|
2003-01-16 18:02:33 +03:00
|
|
|
* Initializes the text services document to use a particular
|
1999-04-23 20:52:28 +04:00
|
|
|
* DOM document.
|
|
|
|
* @param aDOMDocument is the document to use. It is AddRef'd
|
|
|
|
* by this method.
|
|
|
|
* @param aPresShell is the presentation shell to use when
|
|
|
|
* setting the selection. It is AddRef'd by this method.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD InitWithDocument(nsIDOMDocument *aDOMDocument, nsIPresShell *aPresShell) = 0;
|
|
|
|
|
2003-01-16 18:02:33 +03:00
|
|
|
/**
|
|
|
|
* Get the DOM document for the document in use.
|
|
|
|
* @return aDocument the dom document [OUT]
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetDocument(nsIDOMDocument **aDocument) = 0;
|
|
|
|
|
1999-03-31 23:25:05 +04:00
|
|
|
/**
|
1999-04-23 20:52:28 +04:00
|
|
|
* Initializes the text services document to use a particular
|
|
|
|
* editor. The text services document will use the DOM document
|
|
|
|
* and presentation shell used by the editor.
|
|
|
|
* @param aEditor is the editor to use. The editor is AddRef'd
|
|
|
|
* by this method.
|
1999-03-31 23:25:05 +04:00
|
|
|
*/
|
1999-04-23 20:52:28 +04:00
|
|
|
NS_IMETHOD InitWithEditor(nsIEditor *aEditor) = 0;
|
1999-03-31 23:25:05 +04:00
|
|
|
|
2003-04-17 18:29:08 +04:00
|
|
|
/**
|
|
|
|
* Sets the range/extent over which the text services document
|
|
|
|
* will iterate. Note that InitWithDocument() or InitWithEditor()
|
|
|
|
* should have been called prior to calling this method. If this
|
|
|
|
* method is never called, the text services defaults to iterating
|
|
|
|
* over the entire document.
|
|
|
|
*
|
|
|
|
* @param aDOMRange is the range to use. aDOMRange must point to a
|
|
|
|
* valid range object.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD SetExtent(nsIDOMRange* aDOMRange) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the range that the text services document
|
|
|
|
* is currently iterating over. If SetExtent() was never
|
|
|
|
* called, this method will return a range that spans the
|
|
|
|
* entire body of the document.
|
|
|
|
*
|
|
|
|
* @param aDOMRange will contain an AddRef'd pointer to the range.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetExtent(nsIDOMRange** aDOMRange) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Expands the end points of the range so that it spans complete words.
|
|
|
|
* This call does not change any internal state of the text services document.
|
|
|
|
*
|
|
|
|
* @param aDOMRange the range to be expanded/adjusted.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD ExpandRangeToWordBoundaries(nsIDOMRange *aRange) = 0;
|
|
|
|
|
2002-12-10 18:03:04 +03:00
|
|
|
/**
|
|
|
|
* Sets the filter to be used while iterating over content.
|
|
|
|
* @param aFilter filter to be used while iterating over content.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD SetFilter(nsITextServicesFilter *aFilter) = 0;
|
|
|
|
|
1999-03-31 23:25:05 +04:00
|
|
|
/**
|
1999-04-23 20:52:28 +04:00
|
|
|
* Returns true if the document can be modified with calls
|
|
|
|
* to DeleteSelection() and InsertText().
|
|
|
|
* @param aCanEdit is true if the document can be modified,
|
|
|
|
* false if it can't.
|
1999-03-31 23:25:05 +04:00
|
|
|
*/
|
1999-04-23 20:52:28 +04:00
|
|
|
NS_IMETHOD CanEdit(PRBool *aCanEdit) = 0;
|
1999-03-31 23:25:05 +04:00
|
|
|
|
|
|
|
/**
|
1999-04-23 20:52:28 +04:00
|
|
|
* Returns the text in the current text block.
|
|
|
|
* @param aStr will contain the text.
|
1999-03-31 23:25:05 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
NS_IMETHOD GetCurrentTextBlock(nsString *aStr) = 0;
|
|
|
|
|
|
|
|
/**
|
1999-04-23 20:52:28 +04:00
|
|
|
* Tells the document to point to the first text block
|
|
|
|
* in the document. This method does not adjust the current
|
|
|
|
* cursor position or selection.
|
1999-03-31 23:25:05 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
NS_IMETHOD FirstBlock() = 0;
|
|
|
|
|
|
|
|
/**
|
1999-04-23 20:52:28 +04:00
|
|
|
* Tells the document to point to the last text block in the
|
|
|
|
* document. This method does not adjust the current cursor
|
|
|
|
* position or selection.
|
1999-03-31 23:25:05 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
NS_IMETHOD LastBlock() = 0;
|
|
|
|
|
|
|
|
/**
|
1999-04-23 20:52:28 +04:00
|
|
|
* Tells the document to point to the first text block that
|
|
|
|
* contains the current selection or caret.
|
1999-05-11 23:16:24 +04:00
|
|
|
* @param aSelectionStatus will contain the text block selection status
|
1999-04-23 20:52:28 +04:00
|
|
|
* @param aSelectionOffset will contain the offset into the
|
|
|
|
* string returned by GetCurrentTextBlock() where the selection
|
|
|
|
* begins.
|
|
|
|
* @param aLength will contain the number of characters that are
|
|
|
|
* selected in the string.
|
|
|
|
*/
|
|
|
|
|
1999-05-11 23:16:24 +04:00
|
|
|
NS_IMETHOD FirstSelectedBlock(TSDBlockSelectionStatus *aSelectionStatus, PRInt32 *aSelectionOffset, PRInt32 *aSelectionLength) = 0;
|
1999-04-23 20:52:28 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tells the document to point to the last text block that
|
|
|
|
* contains the current selection or caret.
|
1999-05-11 23:16:24 +04:00
|
|
|
* @param aSelectionStatus will contain the text block selection status
|
1999-04-23 20:52:28 +04:00
|
|
|
* @param aSelectionOffset will contain the offset into the
|
|
|
|
* string returned by GetCurrentTextBlock() where the selection
|
|
|
|
* begins.
|
|
|
|
* @param aLength will contain the number of characters that are
|
|
|
|
* selected in the string.
|
|
|
|
*/
|
|
|
|
|
1999-05-11 23:16:24 +04:00
|
|
|
NS_IMETHOD LastSelectedBlock(TSDBlockSelectionStatus *aSelectionStatus, PRInt32 *aSelectionOffset, PRInt32 *aSelectionLength) = 0;
|
1999-04-23 20:52:28 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tells the document to point to the text block before
|
|
|
|
* the current one. This method will return NS_OK, even
|
|
|
|
* if there is no previous block. Callers should call IsDone()
|
|
|
|
* to check if we have gone beyond the first text block in
|
|
|
|
* the document.
|
1999-03-31 23:25:05 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
NS_IMETHOD PrevBlock() = 0;
|
|
|
|
|
|
|
|
/**
|
1999-04-23 20:52:28 +04:00
|
|
|
* Tells the document to point to the text block after
|
|
|
|
* the current one. This method will return NS_OK, even
|
|
|
|
* if there is no next block. Callers should call IsDone()
|
|
|
|
* to check if we have gone beyond the last text block
|
|
|
|
* in the document.
|
1999-03-31 23:25:05 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
NS_IMETHOD NextBlock() = 0;
|
|
|
|
|
|
|
|
/**
|
1999-04-23 20:52:28 +04:00
|
|
|
* IsDone() will always set aIsDone == PR_FALSE unless
|
|
|
|
* the document contains no text, PrevBlock() was called
|
|
|
|
* while the document was already pointing to the first
|
|
|
|
* text block in the document, or NextBlock() was called
|
|
|
|
* while the document was already pointing to the last
|
|
|
|
* text block in the document.
|
|
|
|
* @param aIsDone will contain the result.
|
1999-03-31 23:25:05 +04:00
|
|
|
*/
|
|
|
|
|
1999-04-23 20:52:28 +04:00
|
|
|
NS_IMETHOD IsDone(PRBool *aIsDone) = 0;
|
1999-03-31 23:25:05 +04:00
|
|
|
|
|
|
|
/**
|
1999-04-23 20:52:28 +04:00
|
|
|
* SetSelection() allows the caller to set the selection
|
|
|
|
* based on an offset into the string returned by
|
|
|
|
* GetCurrentTextBlock(). A length of zero places the cursor
|
|
|
|
* at that offset. A positive non-zero length "n" selects
|
|
|
|
* n characters in the string.
|
|
|
|
* @param aOffset offset into string returned by GetCurrentTextBlock().
|
|
|
|
* @param aLength number characters selected.
|
1999-03-31 23:25:05 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
NS_IMETHOD SetSelection(PRInt32 aOffset, PRInt32 aLength) = 0;
|
|
|
|
|
1999-09-30 00:04:34 +04:00
|
|
|
/**
|
|
|
|
* Scrolls the document so that the current selection is visible.
|
|
|
|
*/
|
|
|
|
|
|
|
|
NS_IMETHOD ScrollSelectionIntoView() = 0;
|
|
|
|
|
1999-03-31 23:25:05 +04:00
|
|
|
/**
|
1999-04-23 20:52:28 +04:00
|
|
|
* Deletes the text selected by SetSelection(). Calling
|
|
|
|
* DeleteSelection with nothing selected, or with a collapsed
|
|
|
|
* selection (cursor) does nothing and returns NS_OK.
|
1999-03-31 23:25:05 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
NS_IMETHOD DeleteSelection() = 0;
|
|
|
|
|
|
|
|
/**
|
1999-04-23 20:52:28 +04:00
|
|
|
* Inserts the given text at the current cursor position.
|
|
|
|
* If there is a selection, it will be deleted before the
|
|
|
|
* text is inserted.
|
1999-03-31 23:25:05 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
NS_IMETHOD InsertText(const nsString *aText) = 0;
|
1999-04-23 20:52:28 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the display style for the text selected by SetSelection().
|
|
|
|
* @param aStyle is the style to apply to the selected text.
|
|
|
|
*/
|
|
|
|
|
|
|
|
NS_IMETHOD SetDisplayStyle(TSDDisplayStyle aStyle) = 0;
|
2005-02-02 00:12:53 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the DOM range for a given offset and length
|
|
|
|
* @param aOffset offset into string returned by GetCurrentTextBlock().
|
|
|
|
* @param aLength number characters selected.
|
|
|
|
* @return aDOMRange the DOM range that represents the offset and length
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetDOMRangeFor(PRInt32 aOffset, PRInt32 aLength, nsIDOMRange** aRange) = 0;
|
1999-03-31 23:25:05 +04:00
|
|
|
};
|
|
|
|
|
2005-11-11 17:36:26 +03:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsITextServicesDocument,
|
|
|
|
NS_ITEXTSERVICESDOCUMENT_IID)
|
|
|
|
|
1999-03-31 23:25:05 +04:00
|
|
|
#endif // nsITextServicesDocument_h__
|
|
|
|
|