os/textandloc/fontservices/textshaperplugin/IcuSource/layout/LEInsertionList.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2  **********************************************************************
     3  *   Copyright (C) 1998-2004, International Business Machines
     4  *   Corporation and others.  All Rights Reserved.
     5  **********************************************************************
     6  */
     7 
     8 #ifndef __LEINSERTIONLIST_H
     9 #define __LEINSERTIONLIST_H
    10 
    11 #include "LETypes.h"
    12 
    13 U_NAMESPACE_BEGIN
    14 
    15 struct InsertionRecord;
    16 
    17 /**
    18  * This class encapsulates the callback used by <code>LEInsertionList</code>
    19  * to apply an insertion from the insertion list.
    20  *
    21  * @internal
    22  */
    23 class LEInsertionCallback
    24 {
    25 public:
    26     /**
    27      * This method will be called by <code>LEInsertionList::applyInsertions</code> for each
    28      * entry on the insertion list.
    29      *
    30      * @param atPosition the position of the insertion
    31      * @param count the number of glyphs to insert
    32      * @param newGlyphs the address of the glyphs to insert
    33      *
    34      * @return <code>TRUE</code> if <code>LEInsertions::applyInsertions</code> should
    35      *         stop after applying this insertion.
    36      *
    37      * @internal
    38      */
    39     virtual le_bool applyInsertion(le_int32 atPosition, le_int32 count, LEGlyphID newGlyphs[]) = 0;
    40 };
    41 
    42 /**
    43  * This class is used to keep track of insertions to an array of
    44  * <code>LEGlyphIDs</code>. The insertions are kept on a linked
    45  * list of <code>InsertionRecords</code> so that the glyph array
    46  * doesn't have to be grown for each insertion. The insertions are
    47  * stored on the list from leftmost to rightmost to make it easier
    48  * to do the insertions.
    49  *
    50  * The insertions are applied to the array by calling the
    51  * <code>applyInsertions</code> method, which calls a client
    52  * supplied <code>LEInsertionCallback</code> object to actually
    53  * apply the individual insertions.
    54  *
    55  * @internal
    56  */
    57 class LEInsertionList : public UObject
    58 {
    59 public:
    60     /**
    61      * Construct an empty insertion list.
    62      *
    63      * @param rightToLeft <code>TRUE</code> if the glyphs are stored
    64      *                    in the array in right to left order.
    65      *
    66      * @internal
    67      */
    68     LEInsertionList(le_bool rightToLeft);
    69 
    70     /**
    71      * The destructor.
    72      */
    73     ~LEInsertionList();
    74 
    75     /**
    76      * Add an entry to the insertion list.
    77      *
    78      * @param position the glyph at this position in the array will be
    79      *                 replaced by the new glyphs.
    80      * @param count the number of new glyphs
    81      * @param success set to an error code if the auxillary data cannot be retrieved.
    82      *
    83      * @return the address of an array in which to store the new glyphs. This will
    84      *         <em>not</em> be in the glyph array.
    85      *
    86      * @internal
    87      */
    88     LEGlyphID *insert(le_int32 position, le_int32 count,
    89         LEErrorCode &success);
    90 
    91     /**
    92      * Return the number of new glyphs that have been inserted.
    93      *
    94      * @return the number of new glyphs which have been inserted
    95      *
    96      * @internal
    97      */
    98     le_int32 getGrowAmount();
    99 
   100     /**
   101      * Call the <code>LEInsertionCallback</code> once for each
   102      * entry on the insertion list.
   103      *
   104      * @param callback the <code>LEInsertionCallback</code> to call for each insertion.
   105      *
   106      * @return <code>TRUE</code> if <code>callback</code> returned <code>TRUE</code> to
   107      *         terminate the insertion list processing.
   108      *
   109      * @internal
   110      */
   111     le_bool applyInsertions(LEInsertionCallback *callback);
   112 
   113     /**
   114      * Empty the insertion list and free all associated
   115      * storage.
   116      *
   117      * @internal
   118      */
   119     void reset();
   120 
   121     /**
   122      * ICU "poor man's RTTI", returns a UClassID for the actual class.
   123      *
   124      * @stable ICU 2.8
   125      */
   126     virtual UClassID getDynamicClassID() const;
   127 
   128     /**
   129      * ICU "poor man's RTTI", returns a UClassID for this class.
   130      *
   131      * @stable ICU 2.8
   132      */
   133     static UClassID getStaticClassID();
   134 
   135 private:
   136 
   137     /**
   138      * The head of the insertion list.
   139      *
   140      * @internal
   141      */
   142     InsertionRecord *head;
   143 
   144     /**
   145      * The tail of the insertion list.
   146      *
   147      * @internal
   148      */
   149     InsertionRecord *tail;
   150 
   151     /**
   152      * The total number of new glyphs on the insertion list.
   153      *
   154      * @internal
   155      */
   156     le_int32 growAmount;
   157 
   158     /**
   159      * Set to <code>TRUE</code> if the glyphs are in right
   160      * to left order. Since we want the rightmost insertion
   161      * to be first on the list, we need to append the
   162      * insertions in this case. Otherwise they're prepended.
   163      *
   164      * @internal
   165      */
   166     le_bool  append;
   167 };
   168 
   169 U_NAMESPACE_END
   170 #endif
   171