sl@0: /* sl@0: ********************************************************************** sl@0: * Copyright (C) 1998-2004, International Business Machines sl@0: * Corporation and others. All Rights Reserved. sl@0: ********************************************************************** sl@0: */ sl@0: sl@0: #ifndef __LEINSERTIONLIST_H sl@0: #define __LEINSERTIONLIST_H sl@0: sl@0: #include "LETypes.h" sl@0: sl@0: U_NAMESPACE_BEGIN sl@0: sl@0: struct InsertionRecord; sl@0: sl@0: /** sl@0: * This class encapsulates the callback used by <code>LEInsertionList</code> sl@0: * to apply an insertion from the insertion list. sl@0: * sl@0: * @internal sl@0: */ sl@0: class LEInsertionCallback sl@0: { sl@0: public: sl@0: /** sl@0: * This method will be called by <code>LEInsertionList::applyInsertions</code> for each sl@0: * entry on the insertion list. sl@0: * sl@0: * @param atPosition the position of the insertion sl@0: * @param count the number of glyphs to insert sl@0: * @param newGlyphs the address of the glyphs to insert sl@0: * sl@0: * @return <code>TRUE</code> if <code>LEInsertions::applyInsertions</code> should sl@0: * stop after applying this insertion. sl@0: * sl@0: * @internal sl@0: */ sl@0: virtual le_bool applyInsertion(le_int32 atPosition, le_int32 count, LEGlyphID newGlyphs[]) = 0; sl@0: }; sl@0: sl@0: /** sl@0: * This class is used to keep track of insertions to an array of sl@0: * <code>LEGlyphIDs</code>. The insertions are kept on a linked sl@0: * list of <code>InsertionRecords</code> so that the glyph array sl@0: * doesn't have to be grown for each insertion. The insertions are sl@0: * stored on the list from leftmost to rightmost to make it easier sl@0: * to do the insertions. sl@0: * sl@0: * The insertions are applied to the array by calling the sl@0: * <code>applyInsertions</code> method, which calls a client sl@0: * supplied <code>LEInsertionCallback</code> object to actually sl@0: * apply the individual insertions. sl@0: * sl@0: * @internal sl@0: */ sl@0: class LEInsertionList : public UObject sl@0: { sl@0: public: sl@0: /** sl@0: * Construct an empty insertion list. sl@0: * sl@0: * @param rightToLeft <code>TRUE</code> if the glyphs are stored sl@0: * in the array in right to left order. sl@0: * sl@0: * @internal sl@0: */ sl@0: LEInsertionList(le_bool rightToLeft); sl@0: sl@0: /** sl@0: * The destructor. sl@0: */ sl@0: ~LEInsertionList(); sl@0: sl@0: /** sl@0: * Add an entry to the insertion list. sl@0: * sl@0: * @param position the glyph at this position in the array will be sl@0: * replaced by the new glyphs. sl@0: * @param count the number of new glyphs sl@0: * @param success set to an error code if the auxillary data cannot be retrieved. sl@0: * sl@0: * @return the address of an array in which to store the new glyphs. This will sl@0: * <em>not</em> be in the glyph array. sl@0: * sl@0: * @internal sl@0: */ sl@0: LEGlyphID *insert(le_int32 position, le_int32 count, sl@0: LEErrorCode &success); sl@0: sl@0: /** sl@0: * Return the number of new glyphs that have been inserted. sl@0: * sl@0: * @return the number of new glyphs which have been inserted sl@0: * sl@0: * @internal sl@0: */ sl@0: le_int32 getGrowAmount(); sl@0: sl@0: /** sl@0: * Call the <code>LEInsertionCallback</code> once for each sl@0: * entry on the insertion list. sl@0: * sl@0: * @param callback the <code>LEInsertionCallback</code> to call for each insertion. sl@0: * sl@0: * @return <code>TRUE</code> if <code>callback</code> returned <code>TRUE</code> to sl@0: * terminate the insertion list processing. sl@0: * sl@0: * @internal sl@0: */ sl@0: le_bool applyInsertions(LEInsertionCallback *callback); sl@0: sl@0: /** sl@0: * Empty the insertion list and free all associated sl@0: * storage. sl@0: * sl@0: * @internal sl@0: */ sl@0: void reset(); sl@0: sl@0: /** sl@0: * ICU "poor man's RTTI", returns a UClassID for the actual class. sl@0: * sl@0: * @stable ICU 2.8 sl@0: */ sl@0: virtual UClassID getDynamicClassID() const; sl@0: sl@0: /** sl@0: * ICU "poor man's RTTI", returns a UClassID for this class. sl@0: * sl@0: * @stable ICU 2.8 sl@0: */ sl@0: static UClassID getStaticClassID(); sl@0: sl@0: private: sl@0: sl@0: /** sl@0: * The head of the insertion list. sl@0: * sl@0: * @internal sl@0: */ sl@0: InsertionRecord *head; sl@0: sl@0: /** sl@0: * The tail of the insertion list. sl@0: * sl@0: * @internal sl@0: */ sl@0: InsertionRecord *tail; sl@0: sl@0: /** sl@0: * The total number of new glyphs on the insertion list. sl@0: * sl@0: * @internal sl@0: */ sl@0: le_int32 growAmount; sl@0: sl@0: /** sl@0: * Set to <code>TRUE</code> if the glyphs are in right sl@0: * to left order. Since we want the rightmost insertion sl@0: * to be first on the list, we need to append the sl@0: * insertions in this case. Otherwise they're prepended. sl@0: * sl@0: * @internal sl@0: */ sl@0: le_bool append; sl@0: }; sl@0: sl@0: U_NAMESPACE_END sl@0: #endif sl@0: