editor/txtsvc/public/nsITextServicesDocument.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/txtsvc/public/nsITextServicesDocument.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,185 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsITextServicesDocument_h__
    1.10 +#define nsITextServicesDocument_h__
    1.11 +
    1.12 +#include "nsISupports.h"
    1.13 +
    1.14 +class nsIDOMDocument;
    1.15 +class nsIDOMRange;
    1.16 +class nsIEditor;
    1.17 +class nsString;
    1.18 +class nsITextServicesFilter;
    1.19 +
    1.20 +/*
    1.21 +TextServicesDocument interface to outside world
    1.22 +*/
    1.23 +
    1.24 +#define NS_ITEXTSERVICESDOCUMENT_IID            \
    1.25 +{ /* 019718E1-CDB5-11d2-8D3C-000000000000 */    \
    1.26 +0x019718e1, 0xcdb5, 0x11d2,                     \
    1.27 +{ 0x8d, 0x3c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
    1.28 +
    1.29 +
    1.30 +/**
    1.31 + * The nsITextServicesDocument presents the document in as a
    1.32 + * bunch of flattened text blocks. Each text block can be retrieved
    1.33 + * as an nsString (array of characters).
    1.34 + */
    1.35 +class nsITextServicesDocument  : public nsISupports{
    1.36 +public:
    1.37 +
    1.38 +  NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITEXTSERVICESDOCUMENT_IID)
    1.39 +
    1.40 +  typedef enum { eDSNormal=0, eDSUndlerline } TSDDisplayStyle;
    1.41 +
    1.42 +  typedef enum { eBlockNotFound=0, // There is no text block (TB) in or before the selection (S).
    1.43 +                 eBlockOutside,    // No TB in S, but found one before/after S.
    1.44 +                 eBlockInside,     // S extends beyond the start and end of TB.
    1.45 +                 eBlockContains,   // TB contains entire S.
    1.46 +                 eBlockPartial     // S begins or ends in TB but extends outside of TB.
    1.47 +  } TSDBlockSelectionStatus;
    1.48 +
    1.49 +  /**
    1.50 +   * Get the DOM document for the document in use.
    1.51 +   * @return aDocument the dom document [OUT]
    1.52 +   */
    1.53 +  NS_IMETHOD GetDocument(nsIDOMDocument **aDocument) = 0;
    1.54 +
    1.55 +  /**
    1.56 +   * Initializes the text services document to use a particular
    1.57 +   * editor. The text services document will use the DOM document
    1.58 +   * and presentation shell used by the editor.
    1.59 +   * @param aEditor is the editor to use. The editor is AddRef'd
    1.60 +   * by this method.
    1.61 +   */
    1.62 +  NS_IMETHOD InitWithEditor(nsIEditor *aEditor) = 0;
    1.63 +
    1.64 +  /**
    1.65 +   * Sets the range/extent over which the text services document
    1.66 +   * will iterate. Note that InitWithEditor() should have been called prior to
    1.67 +   * calling this method. If this method is never called, the text services
    1.68 +   * defaults to iterating over the entire document.
    1.69 +   *
    1.70 +   * @param aDOMRange is the range to use. aDOMRange must point to a
    1.71 +   * valid range object.
    1.72 +   */
    1.73 +  NS_IMETHOD SetExtent(nsIDOMRange* aDOMRange) = 0;
    1.74 +
    1.75 +  /**
    1.76 +   * Expands the end points of the range so that it spans complete words.
    1.77 +   * This call does not change any internal state of the text services document.
    1.78 +   *
    1.79 +   * @param aDOMRange the range to be expanded/adjusted.
    1.80 +   */
    1.81 +  NS_IMETHOD ExpandRangeToWordBoundaries(nsIDOMRange *aRange) = 0;
    1.82 +
    1.83 +  /**
    1.84 +   * Sets the filter to be used while iterating over content.
    1.85 +   * @param aFilter filter to be used while iterating over content.
    1.86 +   */
    1.87 +  NS_IMETHOD SetFilter(nsITextServicesFilter *aFilter) = 0;
    1.88 +
    1.89 +  /**
    1.90 +   * Returns the text in the current text block.
    1.91 +   * @param aStr will contain the text.
    1.92 +   */
    1.93 +
    1.94 +  NS_IMETHOD GetCurrentTextBlock(nsString *aStr) = 0;
    1.95 +
    1.96 +  /**
    1.97 +   * Tells the document to point to the first text block
    1.98 +   * in the document. This method does not adjust the current
    1.99 +   * cursor position or selection.
   1.100 +   */
   1.101 +
   1.102 +  NS_IMETHOD FirstBlock() = 0;
   1.103 +
   1.104 +  /**
   1.105 +   * Tells the document to point to the last text block that
   1.106 +   * contains the current selection or caret.
   1.107 +   * @param aSelectionStatus will contain the text block selection status
   1.108 +   * @param aSelectionOffset will contain the offset into the
   1.109 +   * string returned by GetCurrentTextBlock() where the selection
   1.110 +   * begins.
   1.111 +   * @param aLength will contain the number of characters that are
   1.112 +   * selected in the string.
   1.113 +   */
   1.114 +
   1.115 +  NS_IMETHOD LastSelectedBlock(TSDBlockSelectionStatus *aSelectionStatus, int32_t *aSelectionOffset, int32_t *aSelectionLength) = 0;
   1.116 +
   1.117 +  /**
   1.118 +   * Tells the document to point to the text block before
   1.119 +   * the current one. This method will return NS_OK, even
   1.120 +   * if there is no previous block. Callers should call IsDone()
   1.121 +   * to check if we have gone beyond the first text block in
   1.122 +   * the document.
   1.123 +   */
   1.124 +
   1.125 +  NS_IMETHOD PrevBlock() = 0;
   1.126 +
   1.127 +  /**
   1.128 +   * Tells the document to point to the text block after
   1.129 +   * the current one. This method will return NS_OK, even
   1.130 +   * if there is no next block. Callers should call IsDone()
   1.131 +   * to check if we have gone beyond the last text block
   1.132 +   * in the document.
   1.133 +   */
   1.134 +
   1.135 +  NS_IMETHOD NextBlock() = 0;
   1.136 +
   1.137 +  /**
   1.138 +   * IsDone() will always set aIsDone == false unless
   1.139 +   * the document contains no text, PrevBlock() was called
   1.140 +   * while the document was already pointing to the first
   1.141 +   * text block in the document, or NextBlock() was called
   1.142 +   * while the document was already pointing to the last
   1.143 +   * text block in the document.
   1.144 +   * @param aIsDone will contain the result.
   1.145 +   */
   1.146 +
   1.147 +  NS_IMETHOD IsDone(bool *aIsDone) = 0;
   1.148 +
   1.149 +  /**
   1.150 +   * SetSelection() allows the caller to set the selection
   1.151 +   * based on an offset into the string returned by
   1.152 +   * GetCurrentTextBlock(). A length of zero places the cursor
   1.153 +   * at that offset. A positive non-zero length "n" selects
   1.154 +   * n characters in the string.
   1.155 +   * @param aOffset offset into string returned by GetCurrentTextBlock().
   1.156 +   * @param aLength number characters selected.
   1.157 +   */
   1.158 +
   1.159 +  NS_IMETHOD SetSelection(int32_t aOffset, int32_t aLength) = 0;
   1.160 +
   1.161 +  /**
   1.162 +   * Scrolls the document so that the current selection is visible.
   1.163 +   */
   1.164 +
   1.165 +  NS_IMETHOD ScrollSelectionIntoView() = 0;
   1.166 +
   1.167 +  /**
   1.168 +   * Deletes the text selected by SetSelection(). Calling
   1.169 +   * DeleteSelection with nothing selected, or with a collapsed
   1.170 +   * selection (cursor) does nothing and returns NS_OK.
   1.171 +   */
   1.172 +
   1.173 +  NS_IMETHOD DeleteSelection() = 0;
   1.174 +
   1.175 +  /**
   1.176 +   * Inserts the given text at the current cursor position.
   1.177 +   * If there is a selection, it will be deleted before the
   1.178 +   * text is inserted.
   1.179 +   */
   1.180 +
   1.181 +  NS_IMETHOD InsertText(const nsString *aText) = 0;
   1.182 +};
   1.183 +
   1.184 +NS_DEFINE_STATIC_IID_ACCESSOR(nsITextServicesDocument,
   1.185 +                              NS_ITEXTSERVICESDOCUMENT_IID)
   1.186 +
   1.187 +#endif // nsITextServicesDocument_h__
   1.188 +

mercurial