HasNext() public method

public HasNext ( ) : bool
return bool
Ejemplo n.º 1
0
 /**
 * Generates a list of numbers from a string.
 * @param ranges the comma separated ranges
 * @param maxNumber the maximum number in the range
 * @return a list with the numbers as <CODE>Integer</CODE>
 */    
 public static ICollection<int> Expand(String ranges, int maxNumber) {
     SequenceList parse = new SequenceList(ranges);
     List<int> list = new List<int>();
     bool sair = false;
     while (!sair) {
         sair = parse.GetAttributes();
         if (parse.low == -1 && parse.high == -1 && !parse.even && !parse.odd)
             continue;
         if (parse.low < 1)
             parse.low = 1;
         if (parse.high < 1 || parse.high > maxNumber)
             parse.high = maxNumber;
         if (parse.low > maxNumber)
             parse.low = maxNumber;
         
         //System.out.Println("low="+parse.low+",high="+parse.high+",odd="+parse.odd+",even="+parse.even+",inverse="+parse.inverse);
         int inc = 1;
         if (parse.inverse) {
             if (parse.low > parse.high) {
                 int t = parse.low;
                 parse.low = parse.high;
                 parse.high = t;
             }
             for (ListIterator<int> it = new ListIterator<int>(list); it.HasNext();) {
                 int n = it.Next();
                 if (parse.even && (n & 1) == 1)
                     continue;
                 if (parse.odd && (n & 1) == 0)
                     continue;
                 if (n >= parse.low && n <= parse.high)
                     it.Remove();
             }
         }
         else {
             if (parse.low > parse.high) {
                 inc = -1;
                 if (parse.odd || parse.even) {
                     --inc;
                     if (parse.even)
                         parse.low &= ~1;
                     else
                         parse.low -= ((parse.low & 1) == 1 ? 0 : 1);
                 }
                 for (int k = parse.low; k >= parse.high; k += inc) {
                     list.Add(k);
                 }
             }
             else {
                 if (parse.odd || parse.even) {
                     ++inc;
                     if (parse.odd)
                         parse.low |= 1;
                     else
                         parse.low += ((parse.low & 1) == 1 ? 1 : 0);
                 }
                 for (int k = parse.low; k <= parse.high; k += inc)
                     list.Add(k);
             }
         }
     }
     return list;
 }
Ejemplo n.º 2
0
 protected void FillOCProperties(bool erase) {
     if (vOCProperties == null)
         vOCProperties = new PdfOCProperties();
     if (erase) {
         vOCProperties.Remove(PdfName.OCGS);
         vOCProperties.Remove(PdfName.D);
     }
     if (vOCProperties.Get(PdfName.OCGS) == null) {
         PdfArray gr = new PdfArray();
         foreach (PdfLayer layer in documentOCG.Keys) {
             gr.Add(layer.Ref);
         }
         vOCProperties.Put(PdfName.OCGS, gr);
     }
     if (vOCProperties.Get(PdfName.D) != null)
         return;
     List<IPdfOCG> docOrder = new List<IPdfOCG>(documentOCGorder);
     for (ListIterator<IPdfOCG> it = new ListIterator<IPdfOCG>(docOrder); it.HasNext();) {
         PdfLayer layer = (PdfLayer)it.Next();
         if (layer.Parent != null)
             it.Remove();
     }
     PdfArray order = new PdfArray();
     foreach (PdfLayer layer in docOrder) {
         GetOCGOrder(order, layer);
     }
     PdfDictionary d = new PdfDictionary();
     vOCProperties.Put(PdfName.D, d);
     d.Put(PdfName.ORDER, order);
     PdfArray grx = new PdfArray();
     foreach (PdfLayer layer in documentOCG.Keys) {
         if (!layer.On)
             grx.Add(layer.Ref);
     }
     if (grx.Size > 0)
         d.Put(PdfName.OFF, grx);
     if (OCGRadioGroup.Size > 0)
         d.Put(PdfName.RBGROUPS, OCGRadioGroup);
     if (OCGLocked.Size > 0)
         d.Put(PdfName.LOCKED, OCGLocked);
     AddASEvent(PdfName.VIEW, PdfName.ZOOM);
     AddASEvent(PdfName.VIEW, PdfName.VIEW);
     AddASEvent(PdfName.PRINT, PdfName.PRINT);
     AddASEvent(PdfName.EXPORT, PdfName.EXPORT);
     d.Put(PdfName.LISTMODE, PdfName.VISIBLEPAGES);
 }
Ejemplo n.º 3
0
 virtual protected internal PRIndirectReference GetSinglePage(int n) {
     PdfDictionary acc = new PdfDictionary();
     PdfDictionary top = reader.rootPages;
     int baseb = 0;
     while (true) {
         for (int k = 0; k < pageInhCandidates.Length; ++k) {
             PdfObject obj = top.Get(pageInhCandidates[k]);
             if (obj != null)
                 acc.Put(pageInhCandidates[k], obj);
         }
         PdfArray kids = (PdfArray)PdfReader.GetPdfObjectRelease(top.Get(PdfName.KIDS));
         for (ListIterator<PdfObject> it = new ListIterator<PdfObject>(kids.ArrayList); it.HasNext();) {
             PRIndirectReference refi = (PRIndirectReference)it.Next();
             PdfDictionary dic = (PdfDictionary)GetPdfObject(refi);
             int last = reader.lastXrefPartial;
             PdfObject count = GetPdfObjectRelease(dic.Get(PdfName.COUNT));
             reader.lastXrefPartial = last;
             int acn = 1;
             if (count != null && count.Type == PdfObject.NUMBER)
                 acn = ((PdfNumber)count).IntValue;
             if (n < baseb + acn) {
                 if (count == null) {
                     dic.MergeDifferent(acc);
                     return refi;
                 }
                 reader.ReleaseLastXrefPartial();
                 top = dic;
                 break;
             }
             reader.ReleaseLastXrefPartial();
             baseb += acn;
         }
     }
 }
Ejemplo n.º 4
0
        /**
        * Removes the bookmark entries for a number of page ranges. The page ranges
        * consists of a number of pairs with the start/end page range. The page numbers
        * are inclusive.
        * @param list the bookmarks
        * @param pageRange the page ranges, always in pairs.
        */    
        public static void EliminatePages(IList<Dictionary<String, Object>> list, int[] pageRange) {
            if (list == null)
                return;

            for (ListIterator<Dictionary<String, Object>> it = new ListIterator<Dictionary<string,object>>(list); it.HasNext();) {
                Dictionary<String, Object> map = it.Next();
                bool hit = false;
                if (map.ContainsKey("Action") && "GoTo".Equals(map["Action"])) {
                    String page = null;
                    if (map.ContainsKey("Page"))
                        page = (String)map["Page"];
                    if (page != null) {
                        page = page.Trim();
                        int idx = page.IndexOf(' ');
                        int pageNum;
                        if (idx < 0)
                            pageNum = int.Parse(page);
                        else
                            pageNum = int.Parse(page.Substring(0, idx));
                        int len = pageRange.Length & 0x7ffffffe;
                        for (int k = 0; k < len; k += 2) {
                            if (pageNum >= pageRange[k] && pageNum <= pageRange[k + 1]) {
                                hit = true;
                                break;
                            }
                        }
                    }
                }
                IList<Dictionary<String, Object>> kids = null;
                if (map.ContainsKey("Kids"))
                    kids = (IList<Dictionary<String, Object>>)map["Kids"];
                if (kids != null) {
                    EliminatePages(kids, pageRange);
                    if (kids.Count == 0) {
                        map.Remove("Kids");
                        kids = null;
                    }
                }
                if (hit) {
                    if (kids == null)
                        it.Remove();
                    else {
                        map.Remove("Action");
                        map.Remove("Page");
                        map.Remove("Named");
                    }
                }
            }
        }
Ejemplo n.º 5
0
        /**
        * Removes the bookmark entries for a number of page ranges. The page ranges
        * consists of a number of pairs with the start/end page range. The page numbers
        * are inclusive.
        * @param list the bookmarks
        * @param pageRange the page ranges, always in pairs.
        */
        public static void EliminatePages(ArrayList list, int[] pageRange)
        {
            if (list == null)
                return;

            for (ListIterator it = new ListIterator(list); it.HasNext();) {
                Hashtable map = (Hashtable)it.Next();
                bool hit = false;
                if ("GoTo".Equals(map["Action"])) {
                    String page = (String)map["Page"];
                    if (page != null) {
                        page = page.Trim();
                        int idx = page.IndexOf(' ');
                        int pageNum;
                        if (idx < 0)
                            pageNum = int.Parse(page);
                        else
                            pageNum = int.Parse(page.Substring(0, idx));
                        int len = pageRange.Length & 0x7ffffffe;
                        for (int k = 0; k < len; k += 2) {
                            if (pageNum >= pageRange[k] && pageNum <= pageRange[k + 1]) {
                                hit = true;
                                break;
                            }
                        }
                    }
                }
                ArrayList kids = (ArrayList)map["Kids"];
                if (kids != null) {
                    EliminatePages(kids, pageRange);
                    if (kids.Count == 0) {
                        map.Remove("Kids");
                        kids = null;
                    }
                }
                if (hit) {
                    if (kids == null)
                        it.Remove();
                    else {
                        map.Remove("Action");
                        map.Remove("Page");
                        map.Remove("Named");
                    }
                }
            }
        }
Ejemplo n.º 6
0
        /**
        * Write the content of the <code>RtfCell</code>.
        *
        * @param os The <code>Stream</code> to which to write the content of
        * the <code>RtfCell</code> to.
        * @return true if writing the cell content succeeded
        * @throws DocumentException
        */
        public bool WriteCellContent(MemoryStream os)
        {
            try {
                if (mergeType == MERGE_HORIZ_PREV || mergeType == MERGE_BOTH_PREV) {
                    return true;
                }

                if (!emptyCell) {
                    Paragraph container = null;
                    ListIterator cellIterator = new ListIterator(store.Elements);
                    while (cellIterator.HasNext()) {
                        IElement element = (IElement)cellIterator.Next();
                        // should we wrap it in a paragraph
                        if (!(element is Paragraph)) {
                            if (container != null) {
                                container.Add(element);
                            } else {
                                container = new Paragraph();
                                container.Alignment = store.HorizontalAlignment;
                                container.Add(element);
                            }
                        } else {
                            if (container != null) {
                                writer.AddElement(container, os);
                                container =null;
                                container =null;
                            }

                            // if horizontal alignment is undefined overwrite
                            // with that of enclosing cell
                            if (element is Paragraph && ((Paragraph) element).Alignment == Element.ALIGN_UNDEFINED) {
                                ((Paragraph) element).Alignment = store.HorizontalAlignment;
                            }
                            writer.AddElement(element, os);
                            if (element.Type == Element.PARAGRAPH && cellIterator.HasNext()) {
                                os.WriteByte(RtfWriter.escape);
                                os.Write(RtfWriter.paragraph, 0, RtfWriter.paragraph.Length);
                            }
                        }
                    }
                    if (container != null) {
                        writer.AddElement(container, os);
                        container =null;
                    }
                } else {
                    os.WriteByte(RtfWriter.escape);
                    os.Write(RtfWriter.paragraphDefaults, 0, RtfWriter.paragraphDefaults.Length);
                    os.WriteByte(RtfWriter.escape);
                    os.Write(cellInTable, 0, cellInTable.Length);
                }
                os.WriteByte(RtfWriter.escape);
                os.Write(cellEnd, 0, cellEnd.Length);
            } catch (IOException ) {
                return false;
            }
            return true;
        }
Ejemplo n.º 7
0
        /**
        * Adds a new table to
        * @param table              Table to add.  Rendered rows will be deleted after processing.
        * @param onlyFirstPage      Render only the first full page
        * @throws DocumentException
        */
        private void AddPdfTable(Table t)
        {
            // before every table, we flush all lines
            FlushLines();

            PdfTable table = new PdfTable(t, IndentLeft, IndentRight, IndentTop - currentHeight);
            RenderingContext ctx = new RenderingContext();
            ctx.pagetop = IndentTop;
            ctx.oldHeight = currentHeight;
            ctx.cellGraphics = new PdfContentByte(writer);
            ctx.rowspanMap = new Hashtable();
            ctx.table = table;

            // initialisation of parameters
            PdfCell cell;

            // drawing the table
            ArrayList headercells = table.HeaderCells;
            ArrayList cells = table.Cells;
            ArrayList rows = ExtractRows(cells, ctx);
            bool isContinue = false;
            while (cells.Count != 0) {
                // initialisation of some extra parameters;
                ctx.lostTableBottom = 0;

                // loop over the cells
                bool cellsShown = false;

                // draw the cells (line by line)
                ListIterator iterator = new ListIterator(rows);

                bool atLeastOneFits = false;
                while (iterator.HasNext()) {
                    ArrayList row = (ArrayList) iterator.Next();
                    AnalyzeRow(rows, ctx);
                    RenderCells(ctx, row, table.HasToFitPageCells() & atLeastOneFits);

                    if (!MayBeRemoved(row)) {
                        break;
                    }

                    ConsumeRowspan(row, ctx);
                    iterator.Remove();
                    atLeastOneFits = true;
                }

            //          compose cells array list for subsequent code
                cells.Clear();
                Hashtable opt = new Hashtable();
                foreach (ArrayList row in rows) {
                    foreach (PdfCell cellp in row) {
                        if (!opt.ContainsKey(cellp)) {
                            cells.Add(cellp);
                            opt[cellp] = null;
                        }
                    }
                }
                // we paint the graphics of the table after looping through all the cells
                Rectangle tablerec = new Rectangle(table);
                tablerec.Border = table.Border;
                tablerec.BorderWidth = table.BorderWidth;
                tablerec.BorderColor = table.BorderColor;
                tablerec.BackgroundColor = table.BackgroundColor;
                PdfContentByte under = writer.DirectContentUnder;
                under.Rectangle(tablerec.GetRectangle(Top, IndentBottom));
                under.Add(ctx.cellGraphics);
                // bugfix by Gerald Fehringer: now again add the border for the table
                // since it might have been covered by cell backgrounds
                tablerec.BackgroundColor = null;
                tablerec = tablerec.GetRectangle(Top, IndentBottom);
                tablerec.Border = table.Border;
                under.Rectangle(tablerec);
                // end bugfix
                ctx.cellGraphics = new PdfContentByte(null);
                // if the table continues on the next page
                if (rows.Count != 0) {
                    isContinue = true;
                    graphics.SetLineWidth(table.BorderWidth);
                    if (cellsShown && (table.Border & Rectangle.BOTTOM_BORDER) == Rectangle.BOTTOM_BORDER) {
                        // Draw the bottom line

                        // the color is set to the color of the element
                        Color tColor = table.BorderColor;
                        if (tColor != null) {
                            graphics.SetColorStroke(tColor);
                        }
                        graphics.MoveTo(table.Left, Math.Max(table.Bottom, IndentBottom));
                        graphics.LineTo(table.Right, Math.Max(table.Bottom, IndentBottom));
                        graphics.Stroke();
                        if (tColor != null) {
                            graphics.ResetRGBColorStroke();
                        }
                    }

                    // old page
                    pageEmpty = false;
                    float difference = ctx.lostTableBottom;

                    // new page
                    NewPage();
                    // G.F.: if something added in page event i.e. currentHeight > 0
                    float heightCorrection = 0;
                    bool somethingAdded = false;
                    if (currentHeight > 0) {
                        heightCorrection = 6;
                        currentHeight += heightCorrection;
                        somethingAdded = true;
                        NewLine();
                        FlushLines();
                        indentation.indentTop = currentHeight - leading;
                        currentHeight = 0;
                    }
                    else {
                        FlushLines();
                    }

                    // this part repeats the table headers (if any)
                    int size = headercells.Count;
                    if (size > 0) {
                        // this is the top of the headersection
                        cell = (PdfCell) headercells[0];
                        float oldTop = cell.GetTop(0);
                        // loop over all the cells of the table header
                        for (int ii = 0; ii < size; ii++) {
                            cell = (PdfCell) headercells[ii];
                            // calculation of the new cellpositions
                            cell.Top = IndentTop - oldTop + cell.GetTop(0);
                            cell.Bottom = IndentTop - oldTop + cell.GetBottom(0);
                            ctx.pagetop = cell.Bottom;
                            // we paint the borders of the cell
                            ctx.cellGraphics.Rectangle(cell.Rectangle(IndentTop, IndentBottom));
                            // we write the text of the cell
                            ArrayList images = cell.GetImages(IndentTop, IndentBottom);
                            foreach (Image image in images) {
                                cellsShown = true;
                                graphics.AddImage(image);
                            }
                            lines = cell.GetLines(IndentTop, IndentBottom);
                            float cellTop = cell.GetTop(IndentTop);
                            text.MoveText(0, cellTop-heightCorrection);
                            float cellDisplacement = FlushLines() - cellTop+heightCorrection;
                            text.MoveText(0, cellDisplacement);
                        }
                        currentHeight = IndentTop - ctx.pagetop + table.Cellspacing;
                        text.MoveText(0, ctx.pagetop - IndentTop - currentHeight);
                    }
                    else {
                        if (somethingAdded) {
                            ctx.pagetop = IndentTop;
                            text.MoveText(0, -table.Cellspacing);
                        }
                    }
                    ctx.oldHeight = currentHeight - heightCorrection;
                    // calculating the new positions of the table and the cells
                    size = Math.Min(cells.Count, table.Columns);
                    int i = 0;
                    while (i < size) {
                        cell = (PdfCell) cells[i];
                        if (cell.GetTop(-table.Cellspacing) > ctx.lostTableBottom) {
                            float newBottom = ctx.pagetop - difference + cell.Bottom;
                            float neededHeight = cell.RemainingHeight;
                            if (newBottom > ctx.pagetop - neededHeight) {
                                difference += newBottom - (ctx.pagetop - neededHeight);
                            }
                        }
                        i++;
                    }
                    size = cells.Count;
                    table.Top = IndentTop;
                    table.Bottom = ctx.pagetop - difference + table.GetBottom(table.Cellspacing);
                    for (i = 0; i < size; i++) {
                        cell = (PdfCell) cells[i];
                        float newBottom = ctx.pagetop - difference + cell.Bottom;
                        float newTop = ctx.pagetop - difference + cell.GetTop(-table.Cellspacing);
                        if (newTop > IndentTop - currentHeight) {
                            newTop = IndentTop - currentHeight;
                        }
                        cell.Top = newTop ;
                        cell.Bottom = newBottom ;
                    }
                }
            }

            float tableHeight = table.Top - table.Bottom;
            // bugfix by Adauto Martins when have more than two tables and more than one page
            // If continuation of table in other page (bug report #1460051)
            if (isContinue) {
                currentHeight = tableHeight;
                text.MoveText(0, -(tableHeight - (ctx.oldHeight * 2)));
            }
            else {
                currentHeight = ctx.oldHeight + tableHeight;
                text.MoveText(0, -tableHeight);
            }
            pageEmpty = false;
        }
Ejemplo n.º 8
0
        protected internal ArrayList ExtractRows(ArrayList cells, RenderingContext ctx)
        {
            PdfCell cell;
            PdfCell previousCell = null;
            ArrayList rows = new ArrayList();
            ArrayList rowCells = new ArrayList();

            ListIterator iterator = new ListIterator(cells);
            while (iterator.HasNext()) {
                cell = (PdfCell) iterator.Next();

                bool isAdded = false;

                bool isEndOfRow = !iterator.HasNext();
                bool isCurrentCellPartOfRow = !iterator.HasNext();

                if (previousCell != null) {
                    if (cell.Left <= previousCell.Left) {
                        isEndOfRow = true;
                        isCurrentCellPartOfRow = false;
                    }
                }

                if (isCurrentCellPartOfRow) {
                    rowCells.Add(cell);
                    isAdded = true;
                }

                if (isEndOfRow) {
                    if (rowCells.Count != 0) {
                        // add to rowlist
                        rows.Add(rowCells);
                    }

                    // start a new list for next line
                    rowCells = new ArrayList();
                }

                if (!isAdded) {
                    rowCells.Add(cell);
                }

                previousCell = cell;
            }

            if (rowCells.Count != 0) {
                rows.Add(rowCells);
            }

            // fill row information with rowspan cells to get complete "scan lines"
            for (int i = rows.Count - 1; i >= 0; i--) {
                ArrayList row = (ArrayList) rows[i];

                // iterator through row
                for (int j = 0; j < row.Count; j++) {
                    PdfCell c = (PdfCell) row[j];
                    int rowspan = c.Rowspan;

                    // fill in missing rowspan cells to complete "scan line"
                    for (int k = 1; k < rowspan && rows.Count < i+k; k++) {
                        ArrayList spannedRow = ((ArrayList) rows[i + k]);
                        if (spannedRow.Count > j)
                            spannedRow.Insert(j, c);
                    }
                }
            }

            return rows;
        }
Ejemplo n.º 9
0
 /**
 * Write a <code>List</code>
 *
 * @param list The <code>List</code> to be written
 * @param outp The <code>MemoryStream</code> to write to
 *
 * @throws    IOException
 * @throws    DocumentException
 */
 private void WriteList(List list, MemoryStream outp)
 {
     int type = 0;
     int align = 0;
     int fontNr = AddFont(new Font(Font.SYMBOL, 10, Font.NORMAL, new Color(0, 0, 0)));
     if (!list.IsNumbered()) type = 23;
     if (listLevel == 0) {
         maxListLevel = 0;
         listtable.WriteByte(openGroup);
         listtable.WriteByte(escape);
         listtable.Write(listDefinition, 0, listDefinition.Length);
         int i = GetRandomInt();
         listtable.WriteByte(escape);
         listtable.Write(listTemplateID, 0, listTemplateID.Length);
         WriteInt(listtable, i);
         listtable.WriteByte(escape);
         listtable.Write(hybridList, 0, hybridList.Length);
         listtable.WriteByte((byte) '\n');
     }
     if (listLevel >= maxListLevel) {
         maxListLevel++;
         listtable.WriteByte(openGroup);
         listtable.WriteByte(escape);
         listtable.Write(listLevelDefinition, 0, listLevelDefinition.Length);
         listtable.WriteByte(escape);
         listtable.Write(listLevelTypeOld, 0, listLevelTypeOld.Length);
         WriteInt(listtable, type);
         listtable.WriteByte(escape);
         listtable.Write(listLevelTypeNew, 0, listLevelTypeNew.Length);
         WriteInt(listtable, type);
         listtable.WriteByte(escape);
         listtable.Write(listLevelAlignOld, 0, listLevelAlignOld.Length);
         WriteInt(listtable, align);
         listtable.WriteByte(escape);
         listtable.Write(listLevelAlignNew, 0, listLevelAlignNew.Length);
         WriteInt(listtable, align);
         listtable.WriteByte(escape);
         listtable.Write(listLevelStartAt, 0, listLevelStartAt.Length);
         WriteInt(listtable, 1);
         listtable.WriteByte(openGroup);
         listtable.WriteByte(escape);
         listtable.Write(listLevelTextDefinition, 0, listLevelTextDefinition.Length);
         listtable.WriteByte(escape);
         listtable.Write(listLevelTextLength, 0, listLevelTextLength.Length);
         if (list.IsNumbered()) {
             WriteInt(listtable, 2);
         } else {
             WriteInt(listtable, 1);
         }
         listtable.WriteByte(escape);
         if (list.IsNumbered()) {
             listtable.Write(listLevelTextStyleNumbers, 0, listLevelTextStyleNumbers.Length);
         } else {
             listtable.Write(listLevelTextStyleBullet, 0, listLevelTextStyleBullet.Length);
         }
         listtable.WriteByte(commaDelimiter);
         listtable.WriteByte(closeGroup);
         listtable.WriteByte(openGroup);
         listtable.WriteByte(escape);
         listtable.Write(listLevelNumbersDefinition, 0, listLevelNumbersDefinition.Length);
         if (list.IsNumbered()) {
             listtable.WriteByte(delimiter);
             listtable.Write(listLevelNumbers, 0, listLevelNumbers.Length);
             WriteInt(listtable, listLevel + 1);
         }
         listtable.WriteByte(commaDelimiter);
         listtable.WriteByte(closeGroup);
         if (!list.IsNumbered()) {
             listtable.WriteByte(escape);
             listtable.WriteByte(fontNumber);
             WriteInt(listtable, fontNr);
         }
         listtable.WriteByte(escape);
         listtable.Write(firstIndent, 0, firstIndent.Length);
         WriteInt(listtable, (int) (list.IndentationLeft * TWIPSFACTOR * -1));
         listtable.WriteByte(escape);
         listtable.Write(listIndent, 0, listIndent.Length);
         WriteInt(listtable, (int) ((list.IndentationLeft + list.SymbolIndent) * TWIPSFACTOR));
         listtable.WriteByte(escape);
         listtable.Write(rightIndent, 0, rightIndent.Length);
         WriteInt(listtable, (int) (list.IndentationRight * TWIPSFACTOR));
         listtable.WriteByte(escape);
         listtable.Write(tabStop, 0, tabStop.Length);
         WriteInt(listtable, (int) (list.SymbolIndent * TWIPSFACTOR));
         listtable.WriteByte(closeGroup);
         listtable.WriteByte((byte) '\n');
     }
     // Actual List Begin in Content
     outp.WriteByte(escape);
     outp.Write(paragraphDefaults, 0, paragraphDefaults.Length);
     outp.WriteByte(escape);
     outp.Write(alignLeft, 0, alignLeft.Length);
     outp.WriteByte(escape);
     outp.Write(firstIndent, 0, firstIndent.Length);
     WriteInt(outp, (int) (list.IndentationLeft * TWIPSFACTOR * -1));
     outp.WriteByte(escape);
     outp.Write(listIndent, 0, listIndent.Length);
     WriteInt(outp, (int) ((list.IndentationLeft + list.SymbolIndent) * TWIPSFACTOR));
     outp.WriteByte(escape);
     outp.Write(rightIndent, 0, rightIndent.Length);
     WriteInt(outp, (int) (list.IndentationRight * TWIPSFACTOR));
     outp.WriteByte(escape);
     outp.Write(fontSize, 0, fontSize.Length);
     WriteInt(outp, 20);
     outp.WriteByte(escape);
     outp.Write(listBegin, 0, listBegin.Length);
     WriteInt(outp, currentListID);
     if (listLevel > 0) {
         outp.WriteByte(escape);
         outp.Write(listCurrentLevel, 0, listCurrentLevel.Length);
         WriteInt(outp, listLevel);
     }
     outp.WriteByte(openGroup);
     ListIterator listItems = new ListIterator(list.Items);
     IElement listElem;
     int count = 1;
     while (listItems.HasNext()) {
         listElem = (IElement) listItems.Next();
         if (listElem.Type == Element.CHUNK) {
             listElem = new ListItem((Chunk) listElem);
         }
         if (listElem.Type == Element.LISTITEM) {
             outp.WriteByte(openGroup);
             outp.WriteByte(escape);
             outp.Write(listTextOld, 0, listTextOld.Length);
             outp.WriteByte(escape);
             outp.Write(paragraphDefaults, 0, paragraphDefaults.Length);
             outp.WriteByte(escape);
             outp.WriteByte(fontNumber);
             if (list.IsNumbered()) {
                 WriteInt(outp, AddFont(new Font(Font.TIMES_ROMAN, Font.NORMAL, 10, new Color(0, 0, 0))));
             } else {
                 WriteInt(outp, fontNr);
             }
             outp.WriteByte(escape);
             outp.Write(firstIndent, 0, firstIndent.Length);
             WriteInt(outp, (int) (list.IndentationLeft * TWIPSFACTOR * -1));
             outp.WriteByte(escape);
             outp.Write(listIndent, 0, listIndent.Length);
             WriteInt(outp, (int) ((list.IndentationLeft + list.SymbolIndent) * TWIPSFACTOR));
             outp.WriteByte(escape);
             outp.Write(rightIndent, 0, rightIndent.Length);
             WriteInt(outp, (int) (list.IndentationRight * TWIPSFACTOR));
             outp.WriteByte(delimiter);
             if (list.IsNumbered()) {
                 WriteInt(outp, count);
                 outp.WriteByte((byte)'.');
             } else {
                 outp.WriteByte(escape);
                 outp.Write(listBulletOld, 0, listBulletOld.Length);
             }
             outp.WriteByte(escape);
             outp.Write(tab, 0, tab.Length);
             outp.WriteByte(closeGroup);
             WriteListElement((ListItem) listElem, outp);
             count++;
         } else if (listElem.Type == Element.LIST) {
             listLevel++;
             WriteList((List) listElem, outp);
             listLevel--;
             outp.WriteByte(escape);
             outp.Write(paragraphDefaults, 0, paragraphDefaults.Length);
             outp.WriteByte(escape);
             outp.Write(alignLeft, 0, alignLeft.Length);
             outp.WriteByte(escape);
             outp.Write(firstIndent, 0, firstIndent.Length);
             WriteInt(outp, (int) (list.IndentationLeft * TWIPSFACTOR * -1));
             outp.WriteByte(escape);
             outp.Write(listIndent, 0, listIndent.Length);
             WriteInt(outp, (int) ((list.IndentationLeft + list.SymbolIndent) * TWIPSFACTOR));
             outp.WriteByte(escape);
             outp.Write(rightIndent, 0, rightIndent.Length);
             WriteInt(outp, (int) (list.IndentationRight * TWIPSFACTOR));
             outp.WriteByte(escape);
             outp.Write(fontSize, 0, fontSize.Length);
             WriteInt(outp, 20);
             outp.WriteByte(escape);
             outp.Write(listBegin, 0, listBegin.Length);
             WriteInt(outp, currentListID);
             if (listLevel > 0) {
                 outp.WriteByte(escape);
                 outp.Write(listCurrentLevel, 0, listCurrentLevel.Length);
                 WriteInt(outp, listLevel);
             }
         }
         outp.WriteByte((byte) '\n');
     }
     outp.WriteByte(closeGroup);
     if (listLevel == 0) {
         int i = GetRandomInt();
         listtable.WriteByte(escape);
         listtable.Write(listID, 0, listID.Length);
         WriteInt(listtable, i);
         listtable.WriteByte(closeGroup);
         listtable.WriteByte((byte) '\n');
         listoverride.WriteByte(openGroup);
         listoverride.WriteByte(escape);
         listoverride.Write(listOverride, 0, listOverride.Length);
         listoverride.WriteByte(escape);
         listoverride.Write(listID, 0, listID.Length);
         WriteInt(listoverride, i);
         listoverride.WriteByte(escape);
         listoverride.Write(listOverrideCount, 0, listOverrideCount.Length);
         WriteInt(listoverride, 0);
         listoverride.WriteByte(escape);
         listoverride.Write(listBegin, 0, listBegin.Length);
         WriteInt(listoverride, currentListID);
         currentListID++;
         listoverride.WriteByte(closeGroup);
         listoverride.WriteByte((byte) '\n');
     }
     outp.WriteByte(escape);
     outp.Write(paragraphDefaults, 0, paragraphDefaults.Length);
 }