Beispiel #1
0
        /**
         *
         * @param result
         * @param itemNr
         * @param listLevel
         * @throws IOException
         * @since 2.1.3
         */
        protected void WriteListTextBlock(Stream result, int itemNr, RtfListLevel listLevel)
        {
            byte[] t;
            result.Write(OPEN_GROUP, 0, OPEN_GROUP.Length);
            result.Write(RtfList.LIST_TEXT, 0, RtfList.LIST_TEXT.Length);
            result.Write(RtfParagraph.PARAGRAPH_DEFAULTS, 0, RtfParagraph.PARAGRAPH_DEFAULTS.Length);
            if (this.inTable)
            {
                result.Write(RtfParagraph.IN_TABLE, 0, RtfParagraph.IN_TABLE.Length);
            }
            result.Write(RtfFontList.FONT_NUMBER, 0, RtfFontList.FONT_NUMBER.Length);
            if (listLevel.GetListType() != RtfListLevel.LIST_TYPE_BULLET)
            {
                result.Write(t = IntToByteArray(listLevel.GetFontNumber().GetFontNumber()), 0, t.Length);
            }
            else
            {
                result.Write(t = IntToByteArray(listLevel.GetFontBullet().GetFontNumber()), 0, t.Length);
            }
            listLevel.WriteIndentation(result);
            result.Write(DELIMITER, 0, DELIMITER.Length);
            if (listLevel.GetListType() != RtfListLevel.LIST_TYPE_BULLET)
            {
                switch (listLevel.GetListType())
                {
                case RtfListLevel.LIST_TYPE_NUMBERED: result.Write(t = IntToByteArray(itemNr), 0, t.Length); break;

                case RtfListLevel.LIST_TYPE_UPPER_LETTERS: result.Write(t = DocWriter.GetISOBytes(RomanAlphabetFactory.GetUpperCaseString(itemNr)), 0, t.Length); break;

                case RtfListLevel.LIST_TYPE_LOWER_LETTERS: result.Write(t = DocWriter.GetISOBytes(RomanAlphabetFactory.GetLowerCaseString(itemNr)), 0, t.Length); break;

                case RtfListLevel.LIST_TYPE_UPPER_ROMAN: result.Write(t = DocWriter.GetISOBytes(RomanNumberFactory.GetUpperCaseString(itemNr)), 0, t.Length); break;

                case RtfListLevel.LIST_TYPE_LOWER_ROMAN: result.Write(t = DocWriter.GetISOBytes(RomanNumberFactory.GetLowerCaseString(itemNr)), 0, t.Length); break;
                }
                result.Write(LIST_NUMBER_END, 0, LIST_NUMBER_END.Length);
            }
            else
            {
                this.document.FilterSpecialChar(result, listLevel.GetBulletCharacter(), true, false);
            }
            result.Write(TAB, 0, TAB.Length);
            result.Write(CLOSE_GROUP, 0, CLOSE_GROUP.Length);
        }
Beispiel #2
0
        /**
         * Writes the content of the RtfList
         * @since 2.1.3
         */
        public override void WriteContent(Stream result)
        {
            if (!this.inTable)
            {
                result.Write(OPEN_GROUP, 0, OPEN_GROUP.Length);
            }

            int itemNr = 0;

            if (items != null)
            {
                for (int i = 0; i < items.Count; i++)
                {
                    RtfElement thisRtfElement = (RtfElement)items[i];
                    //thisRtfElement.WriteContent(result);
                    if (thisRtfElement is RtfListItem)
                    {
                        itemNr++;
                        RtfListItem  rtfElement = (RtfListItem)thisRtfElement;
                        RtfListLevel listLevel  = rtfElement.GetParent();
                        if (listLevel.GetListLevel() == 0)
                        {
                            CorrectIndentation();
                        }

                        if (i == 0)
                        {
                            listLevel.WriteListBeginning(result);
                            WriteListNumbers(result);
                        }

                        WriteListTextBlock(result, itemNr, listLevel);

                        rtfElement.WriteContent(result);

                        if (i < (items.Count - 1) || !this.inTable || listLevel.GetListType() > 0) // TODO Fix no paragraph on last list item in tables
                        {
                            result.Write(RtfParagraph.PARAGRAPH, 0, RtfParagraph.PARAGRAPH.Length);
                        }
                        this.document.OutputDebugLinebreak(result);
                    }
                    else if (thisRtfElement is RtfList)
                    {
                        ((RtfList)thisRtfElement).WriteContent(result);
                        //              ((RtfList)thisRtfElement).WriteListBeginning(result);
                        WriteListNumbers(result);
                        this.document.OutputDebugLinebreak(result);
                    }
                }
            }
            if (!this.inTable)
            {
                result.Write(CLOSE_GROUP, 0, CLOSE_GROUP.Length);
                result.Write(RtfParagraph.PARAGRAPH_DEFAULTS, 0, RtfParagraph.PARAGRAPH_DEFAULTS.Length);
            }
        }