os/textandloc/fontservices/textshaperplugin/IcuSource/layout/LEInsertionList.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/layout/LEInsertionList.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,171 @@
     1.4 +/*
     1.5 + **********************************************************************
     1.6 + *   Copyright (C) 1998-2004, International Business Machines
     1.7 + *   Corporation and others.  All Rights Reserved.
     1.8 + **********************************************************************
     1.9 + */
    1.10 +
    1.11 +#ifndef __LEINSERTIONLIST_H
    1.12 +#define __LEINSERTIONLIST_H
    1.13 +
    1.14 +#include "LETypes.h"
    1.15 +
    1.16 +U_NAMESPACE_BEGIN
    1.17 +
    1.18 +struct InsertionRecord;
    1.19 +
    1.20 +/**
    1.21 + * This class encapsulates the callback used by <code>LEInsertionList</code>
    1.22 + * to apply an insertion from the insertion list.
    1.23 + *
    1.24 + * @internal
    1.25 + */
    1.26 +class LEInsertionCallback
    1.27 +{
    1.28 +public:
    1.29 +    /**
    1.30 +     * This method will be called by <code>LEInsertionList::applyInsertions</code> for each
    1.31 +     * entry on the insertion list.
    1.32 +     *
    1.33 +     * @param atPosition the position of the insertion
    1.34 +     * @param count the number of glyphs to insert
    1.35 +     * @param newGlyphs the address of the glyphs to insert
    1.36 +     *
    1.37 +     * @return <code>TRUE</code> if <code>LEInsertions::applyInsertions</code> should
    1.38 +     *         stop after applying this insertion.
    1.39 +     *
    1.40 +     * @internal
    1.41 +     */
    1.42 +    virtual le_bool applyInsertion(le_int32 atPosition, le_int32 count, LEGlyphID newGlyphs[]) = 0;
    1.43 +};
    1.44 +
    1.45 +/**
    1.46 + * This class is used to keep track of insertions to an array of
    1.47 + * <code>LEGlyphIDs</code>. The insertions are kept on a linked
    1.48 + * list of <code>InsertionRecords</code> so that the glyph array
    1.49 + * doesn't have to be grown for each insertion. The insertions are
    1.50 + * stored on the list from leftmost to rightmost to make it easier
    1.51 + * to do the insertions.
    1.52 + *
    1.53 + * The insertions are applied to the array by calling the
    1.54 + * <code>applyInsertions</code> method, which calls a client
    1.55 + * supplied <code>LEInsertionCallback</code> object to actually
    1.56 + * apply the individual insertions.
    1.57 + *
    1.58 + * @internal
    1.59 + */
    1.60 +class LEInsertionList : public UObject
    1.61 +{
    1.62 +public:
    1.63 +    /**
    1.64 +     * Construct an empty insertion list.
    1.65 +     *
    1.66 +     * @param rightToLeft <code>TRUE</code> if the glyphs are stored
    1.67 +     *                    in the array in right to left order.
    1.68 +     *
    1.69 +     * @internal
    1.70 +     */
    1.71 +    LEInsertionList(le_bool rightToLeft);
    1.72 +
    1.73 +    /**
    1.74 +     * The destructor.
    1.75 +     */
    1.76 +    ~LEInsertionList();
    1.77 +
    1.78 +    /**
    1.79 +     * Add an entry to the insertion list.
    1.80 +     *
    1.81 +     * @param position the glyph at this position in the array will be
    1.82 +     *                 replaced by the new glyphs.
    1.83 +     * @param count the number of new glyphs
    1.84 +     * @param success set to an error code if the auxillary data cannot be retrieved.
    1.85 +     *
    1.86 +     * @return the address of an array in which to store the new glyphs. This will
    1.87 +     *         <em>not</em> be in the glyph array.
    1.88 +     *
    1.89 +     * @internal
    1.90 +     */
    1.91 +    LEGlyphID *insert(le_int32 position, le_int32 count,
    1.92 +        LEErrorCode &success);
    1.93 +
    1.94 +    /**
    1.95 +     * Return the number of new glyphs that have been inserted.
    1.96 +     *
    1.97 +     * @return the number of new glyphs which have been inserted
    1.98 +     *
    1.99 +     * @internal
   1.100 +     */
   1.101 +    le_int32 getGrowAmount();
   1.102 +
   1.103 +    /**
   1.104 +     * Call the <code>LEInsertionCallback</code> once for each
   1.105 +     * entry on the insertion list.
   1.106 +     *
   1.107 +     * @param callback the <code>LEInsertionCallback</code> to call for each insertion.
   1.108 +     *
   1.109 +     * @return <code>TRUE</code> if <code>callback</code> returned <code>TRUE</code> to
   1.110 +     *         terminate the insertion list processing.
   1.111 +     *
   1.112 +     * @internal
   1.113 +     */
   1.114 +    le_bool applyInsertions(LEInsertionCallback *callback);
   1.115 +
   1.116 +    /**
   1.117 +     * Empty the insertion list and free all associated
   1.118 +     * storage.
   1.119 +     *
   1.120 +     * @internal
   1.121 +     */
   1.122 +    void reset();
   1.123 +
   1.124 +    /**
   1.125 +     * ICU "poor man's RTTI", returns a UClassID for the actual class.
   1.126 +     *
   1.127 +     * @stable ICU 2.8
   1.128 +     */
   1.129 +    virtual UClassID getDynamicClassID() const;
   1.130 +
   1.131 +    /**
   1.132 +     * ICU "poor man's RTTI", returns a UClassID for this class.
   1.133 +     *
   1.134 +     * @stable ICU 2.8
   1.135 +     */
   1.136 +    static UClassID getStaticClassID();
   1.137 +
   1.138 +private:
   1.139 +
   1.140 +    /**
   1.141 +     * The head of the insertion list.
   1.142 +     *
   1.143 +     * @internal
   1.144 +     */
   1.145 +    InsertionRecord *head;
   1.146 +
   1.147 +    /**
   1.148 +     * The tail of the insertion list.
   1.149 +     *
   1.150 +     * @internal
   1.151 +     */
   1.152 +    InsertionRecord *tail;
   1.153 +
   1.154 +    /**
   1.155 +     * The total number of new glyphs on the insertion list.
   1.156 +     *
   1.157 +     * @internal
   1.158 +     */
   1.159 +    le_int32 growAmount;
   1.160 +
   1.161 +    /**
   1.162 +     * Set to <code>TRUE</code> if the glyphs are in right
   1.163 +     * to left order. Since we want the rightmost insertion
   1.164 +     * to be first on the list, we need to append the
   1.165 +     * insertions in this case. Otherwise they're prepended.
   1.166 +     *
   1.167 +     * @internal
   1.168 +     */
   1.169 +    le_bool  append;
   1.170 +};
   1.171 +
   1.172 +U_NAMESPACE_END
   1.173 +#endif
   1.174 +