editor/txtsvc/public/nsITextServicesDocument.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef nsITextServicesDocument_h__
michael@0 7 #define nsITextServicesDocument_h__
michael@0 8
michael@0 9 #include "nsISupports.h"
michael@0 10
michael@0 11 class nsIDOMDocument;
michael@0 12 class nsIDOMRange;
michael@0 13 class nsIEditor;
michael@0 14 class nsString;
michael@0 15 class nsITextServicesFilter;
michael@0 16
michael@0 17 /*
michael@0 18 TextServicesDocument interface to outside world
michael@0 19 */
michael@0 20
michael@0 21 #define NS_ITEXTSERVICESDOCUMENT_IID \
michael@0 22 { /* 019718E1-CDB5-11d2-8D3C-000000000000 */ \
michael@0 23 0x019718e1, 0xcdb5, 0x11d2, \
michael@0 24 { 0x8d, 0x3c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
michael@0 25
michael@0 26
michael@0 27 /**
michael@0 28 * The nsITextServicesDocument presents the document in as a
michael@0 29 * bunch of flattened text blocks. Each text block can be retrieved
michael@0 30 * as an nsString (array of characters).
michael@0 31 */
michael@0 32 class nsITextServicesDocument : public nsISupports{
michael@0 33 public:
michael@0 34
michael@0 35 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITEXTSERVICESDOCUMENT_IID)
michael@0 36
michael@0 37 typedef enum { eDSNormal=0, eDSUndlerline } TSDDisplayStyle;
michael@0 38
michael@0 39 typedef enum { eBlockNotFound=0, // There is no text block (TB) in or before the selection (S).
michael@0 40 eBlockOutside, // No TB in S, but found one before/after S.
michael@0 41 eBlockInside, // S extends beyond the start and end of TB.
michael@0 42 eBlockContains, // TB contains entire S.
michael@0 43 eBlockPartial // S begins or ends in TB but extends outside of TB.
michael@0 44 } TSDBlockSelectionStatus;
michael@0 45
michael@0 46 /**
michael@0 47 * Get the DOM document for the document in use.
michael@0 48 * @return aDocument the dom document [OUT]
michael@0 49 */
michael@0 50 NS_IMETHOD GetDocument(nsIDOMDocument **aDocument) = 0;
michael@0 51
michael@0 52 /**
michael@0 53 * Initializes the text services document to use a particular
michael@0 54 * editor. The text services document will use the DOM document
michael@0 55 * and presentation shell used by the editor.
michael@0 56 * @param aEditor is the editor to use. The editor is AddRef'd
michael@0 57 * by this method.
michael@0 58 */
michael@0 59 NS_IMETHOD InitWithEditor(nsIEditor *aEditor) = 0;
michael@0 60
michael@0 61 /**
michael@0 62 * Sets the range/extent over which the text services document
michael@0 63 * will iterate. Note that InitWithEditor() should have been called prior to
michael@0 64 * calling this method. If this method is never called, the text services
michael@0 65 * defaults to iterating over the entire document.
michael@0 66 *
michael@0 67 * @param aDOMRange is the range to use. aDOMRange must point to a
michael@0 68 * valid range object.
michael@0 69 */
michael@0 70 NS_IMETHOD SetExtent(nsIDOMRange* aDOMRange) = 0;
michael@0 71
michael@0 72 /**
michael@0 73 * Expands the end points of the range so that it spans complete words.
michael@0 74 * This call does not change any internal state of the text services document.
michael@0 75 *
michael@0 76 * @param aDOMRange the range to be expanded/adjusted.
michael@0 77 */
michael@0 78 NS_IMETHOD ExpandRangeToWordBoundaries(nsIDOMRange *aRange) = 0;
michael@0 79
michael@0 80 /**
michael@0 81 * Sets the filter to be used while iterating over content.
michael@0 82 * @param aFilter filter to be used while iterating over content.
michael@0 83 */
michael@0 84 NS_IMETHOD SetFilter(nsITextServicesFilter *aFilter) = 0;
michael@0 85
michael@0 86 /**
michael@0 87 * Returns the text in the current text block.
michael@0 88 * @param aStr will contain the text.
michael@0 89 */
michael@0 90
michael@0 91 NS_IMETHOD GetCurrentTextBlock(nsString *aStr) = 0;
michael@0 92
michael@0 93 /**
michael@0 94 * Tells the document to point to the first text block
michael@0 95 * in the document. This method does not adjust the current
michael@0 96 * cursor position or selection.
michael@0 97 */
michael@0 98
michael@0 99 NS_IMETHOD FirstBlock() = 0;
michael@0 100
michael@0 101 /**
michael@0 102 * Tells the document to point to the last text block that
michael@0 103 * contains the current selection or caret.
michael@0 104 * @param aSelectionStatus will contain the text block selection status
michael@0 105 * @param aSelectionOffset will contain the offset into the
michael@0 106 * string returned by GetCurrentTextBlock() where the selection
michael@0 107 * begins.
michael@0 108 * @param aLength will contain the number of characters that are
michael@0 109 * selected in the string.
michael@0 110 */
michael@0 111
michael@0 112 NS_IMETHOD LastSelectedBlock(TSDBlockSelectionStatus *aSelectionStatus, int32_t *aSelectionOffset, int32_t *aSelectionLength) = 0;
michael@0 113
michael@0 114 /**
michael@0 115 * Tells the document to point to the text block before
michael@0 116 * the current one. This method will return NS_OK, even
michael@0 117 * if there is no previous block. Callers should call IsDone()
michael@0 118 * to check if we have gone beyond the first text block in
michael@0 119 * the document.
michael@0 120 */
michael@0 121
michael@0 122 NS_IMETHOD PrevBlock() = 0;
michael@0 123
michael@0 124 /**
michael@0 125 * Tells the document to point to the text block after
michael@0 126 * the current one. This method will return NS_OK, even
michael@0 127 * if there is no next block. Callers should call IsDone()
michael@0 128 * to check if we have gone beyond the last text block
michael@0 129 * in the document.
michael@0 130 */
michael@0 131
michael@0 132 NS_IMETHOD NextBlock() = 0;
michael@0 133
michael@0 134 /**
michael@0 135 * IsDone() will always set aIsDone == false unless
michael@0 136 * the document contains no text, PrevBlock() was called
michael@0 137 * while the document was already pointing to the first
michael@0 138 * text block in the document, or NextBlock() was called
michael@0 139 * while the document was already pointing to the last
michael@0 140 * text block in the document.
michael@0 141 * @param aIsDone will contain the result.
michael@0 142 */
michael@0 143
michael@0 144 NS_IMETHOD IsDone(bool *aIsDone) = 0;
michael@0 145
michael@0 146 /**
michael@0 147 * SetSelection() allows the caller to set the selection
michael@0 148 * based on an offset into the string returned by
michael@0 149 * GetCurrentTextBlock(). A length of zero places the cursor
michael@0 150 * at that offset. A positive non-zero length "n" selects
michael@0 151 * n characters in the string.
michael@0 152 * @param aOffset offset into string returned by GetCurrentTextBlock().
michael@0 153 * @param aLength number characters selected.
michael@0 154 */
michael@0 155
michael@0 156 NS_IMETHOD SetSelection(int32_t aOffset, int32_t aLength) = 0;
michael@0 157
michael@0 158 /**
michael@0 159 * Scrolls the document so that the current selection is visible.
michael@0 160 */
michael@0 161
michael@0 162 NS_IMETHOD ScrollSelectionIntoView() = 0;
michael@0 163
michael@0 164 /**
michael@0 165 * Deletes the text selected by SetSelection(). Calling
michael@0 166 * DeleteSelection with nothing selected, or with a collapsed
michael@0 167 * selection (cursor) does nothing and returns NS_OK.
michael@0 168 */
michael@0 169
michael@0 170 NS_IMETHOD DeleteSelection() = 0;
michael@0 171
michael@0 172 /**
michael@0 173 * Inserts the given text at the current cursor position.
michael@0 174 * If there is a selection, it will be deleted before the
michael@0 175 * text is inserted.
michael@0 176 */
michael@0 177
michael@0 178 NS_IMETHOD InsertText(const nsString *aText) = 0;
michael@0 179 };
michael@0 180
michael@0 181 NS_DEFINE_STATIC_IID_ACCESSOR(nsITextServicesDocument,
michael@0 182 NS_ITEXTSERVICESDOCUMENT_IID)
michael@0 183
michael@0 184 #endif // nsITextServicesDocument_h__
michael@0 185

mercurial