Exemple #1
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);
            }
        }
Exemple #2
0
        /**
         * Writes the definition part of this list level
         * @param result
         * @throws IOException
         * @since 2.1.3
         */
        public void WriteDefinition(Stream result)
        {
            byte[] t;
            result.Write(OPEN_GROUP, 0, OPEN_GROUP.Length);
            result.Write(LIST, 0, LIST.Length);
            result.Write(LIST_TEMPLATE_ID, 0, LIST_TEMPLATE_ID.Length);
            result.Write(t = IntToByteArray(document.GetRandomInt()), 0, t.Length);

            int levelsToWrite = -1;

            switch (this.listType)
            {
            case LIST_TYPE_NORMAL:
                levelsToWrite = listLevels.Count;
                break;

            case LIST_TYPE_SIMPLE:
                result.Write(LIST_SIMPLE, 0, LIST_SIMPLE.Length);
                result.Write(t = IntToByteArray(1), 0, t.Length);
                levelsToWrite  = 1;
                break;

            case LIST_TYPE_HYBRID:
                result.Write(LIST_HYBRID, 0, LIST_HYBRID.Length);
                levelsToWrite = listLevels.Count;
                break;

            default:
                break;
            }
            this.document.OutputDebugLinebreak(result);

            // TODO: Figure out hybrid because multi-level hybrid does not work.
            // Seems hybrid is mixed type all single level - Simple = single level
            // SIMPLE1/HYRBID
            // 1. Line 1
            // 2. Line 2
            // MULTI-LEVEL LISTS Are Simple0 - 9 levels (0-8) all single digit
            // 1. Line 1
            // 1.1. Line 1.1
            // 1.2. Line 1.2
            // 2. Line 2

            // write the listlevels here
            for (int i = 0; i < levelsToWrite; i++)
            {
                ((RtfListLevel)listLevels[i]).WriteDefinition(result);
                this.document.OutputDebugLinebreak(result);
            }

            result.Write(LIST_ID, 0, LIST_ID.Length);
            result.Write(t = IntToByteArray(this.listID), 0, t.Length);
            result.Write(CLOSE_GROUP, 0, CLOSE_GROUP.Length);
            this.document.OutputDebugLinebreak(result);
            if (items != null)
            {
                for (int i = 0; i < items.Count; i++)
                {
                    RtfElement rtfElement = (RtfElement)items[i];
                    if (rtfElement is RtfList)
                    {
                        RtfList rl = (RtfList)rtfElement;
                        rl.WriteDefinition(result);
                        break;
                    }
                    else if (rtfElement is RtfListItem)
                    {
                        RtfListItem rli = (RtfListItem)rtfElement;
                        if (rli.WriteDefinition(result))
                        {
                            break;
                        }
                    }
                }
            }
        }