2 **********************************************************************
3 * Copyright (C) 1998-2008, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
9 #include "LEInsertionList.h"
15 struct InsertionRecord
17 InsertionRecord *next;
20 LEGlyphID glyphs[ANY_NUMBER];
23 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(LEInsertionList)
25 LEInsertionList::LEInsertionList(le_bool rightToLeft)
26 : head(NULL), tail(NULL), growAmount(0), append(rightToLeft)
28 tail = (InsertionRecord *) &head;
31 LEInsertionList::~LEInsertionList()
36 void LEInsertionList::reset()
38 while (head != NULL) {
39 InsertionRecord *record = head;
42 LE_DELETE_ARRAY(record);
45 tail = (InsertionRecord *) &head;
49 le_int32 LEInsertionList::getGrowAmount()
54 LEGlyphID *LEInsertionList::insert(le_int32 position, le_int32 count, LEErrorCode &success)
56 if (LE_FAILURE(success)) {
60 InsertionRecord *insertion = (InsertionRecord *) LE_NEW_ARRAY(char, sizeof(InsertionRecord) + (count - ANY_NUMBER) * sizeof (LEGlyphID));
61 if (insertion == NULL) {
62 success = LE_MEMORY_ALLOCATION_ERROR;
66 insertion->position = position;
67 insertion->count = count;
69 growAmount += count - 1;
72 // insert on end of list...
73 insertion->next = NULL;
74 tail->next = insertion;
77 // insert on front of list...
78 insertion->next = head;
82 return insertion->glyphs;
85 le_bool LEInsertionList::applyInsertions(LEInsertionCallback *callback)
87 for (InsertionRecord *rec = head; rec != NULL; rec = rec->next) {
88 if (callback->applyInsertion(rec->position, rec->count, rec->glyphs)) {