WriteDefinition() public method

public WriteDefinition ( Stream result ) : void
result Stream
return void
Ejemplo n.º 1
0
 /**
  * Writes the definition of the first element in this RtfListItem that is
  * an is {@link RtfList} to the given stream.<br>
  * If this item does not contain a {@link RtfList} element nothing is written
  * and the method returns <code>false</code>.
  *
  * @param out destination stream
  * @return <code>true</code> if a RtfList definition was written, <code>false</code> otherwise
  * @throws IOException
  * @see {@link RtfList#writeDefinition(Stream)}
  */
 public bool WriteDefinition(Stream outp)
 {
     for (int i = 0; i < chunks.Count; i++)
     {
         IRtfBasicElement rtfElement = (IRtfBasicElement)chunks[i];
         if (rtfElement is RtfList)
         {
             RtfList rl = (RtfList)rtfElement;
             rl.WriteDefinition(outp);
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
        /**
         * Writes the list and list override tables.
         */
        public virtual void WriteDefinition(Stream result)
        {
            byte[] t;
            result.Write(OPEN_GROUP, 0, OPEN_GROUP.Length);
            result.Write(LIST_TABLE, 0, LIST_TABLE.Length);
            this.document.OutputDebugLinebreak(result);

            for (int i = 0; i < picturelists.Count; i++)
            {
                RtfPictureList l = (RtfPictureList)picturelists[i];
                //          l.SetID(document.GetRandomInt());
                l.WriteDefinition(result);
                this.document.OutputDebugLinebreak(result);
            }

            for (int i = 0; i < lists.Count; i++)
            {
                RtfList l = (RtfList)lists[i];
                l.SetID(document.GetRandomInt());
                l.WriteDefinition(result);
                this.document.OutputDebugLinebreak(result);
            }
            result.Write(CLOSE_GROUP, 0, CLOSE_GROUP.Length);
            this.document.OutputDebugLinebreak(result);

            result.Write(OPEN_GROUP, 0, OPEN_GROUP.Length);
            result.Write(LIST_OVERRIDE_TABLE, 0, LIST_OVERRIDE_TABLE.Length);
            this.document.OutputDebugLinebreak(result);

            // list override index values are 1-based, not 0.
            // valid list override index values \ls are 1 to 2000.
            // if there are more then 2000 lists, the result is undefined.
            for (int i = 0; i < lists.Count; i++)
            {
                result.Write(OPEN_GROUP, 0, OPEN_GROUP.Length);
                result.Write(LIST_OVERRIDE, 0, LIST_OVERRIDE.Length);
                result.Write(RtfList.LIST_ID, 0, RtfList.LIST_ID.Length);
                result.Write(t = IntToByteArray(((RtfList)lists[i]).GetID()), 0, t.Length);
                result.Write(LIST_OVERRIDE_COUNT, 0, LIST_OVERRIDE_COUNT.Length);
                result.Write(t = IntToByteArray(0), 0, t.Length);    // is this correct? Spec says valid values are 1 or 9.
                result.Write(RtfList.LIST_NUMBER, 0, RtfList.LIST_NUMBER.Length);
                result.Write(t = IntToByteArray(((RtfList)lists[i]).GetListNumber()), 0, t.Length);
                result.Write(CLOSE_GROUP, 0, CLOSE_GROUP.Length);
                this.document.OutputDebugLinebreak(result);
            }
            result.Write(CLOSE_GROUP, 0, CLOSE_GROUP.Length);
            this.document.OutputDebugLinebreak(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Writes the list and list override tables.
        /// </summary>
        public virtual void WriteDefinition(Stream result)
        {
            byte[] t;
            result.Write(OpenGroup, 0, OpenGroup.Length);
            result.Write(_listTable, 0, _listTable.Length);
            Document.OutputDebugLinebreak(result);

            for (int i = 0; i < _picturelists.Count; i++)
            {
                RtfPictureList l = (RtfPictureList)_picturelists[i];
                //          l.SetID(document.GetRandomInt());
                l.WriteDefinition(result);
                Document.OutputDebugLinebreak(result);
            }

            for (int i = 0; i < _lists.Count; i++)
            {
                RtfList l = (RtfList)_lists[i];
                l.SetId(Document.GetRandomInt());
                l.WriteDefinition(result);
                Document.OutputDebugLinebreak(result);
            }
            result.Write(CloseGroup, 0, CloseGroup.Length);
            Document.OutputDebugLinebreak(result);

            result.Write(OpenGroup, 0, OpenGroup.Length);
            result.Write(_listOverrideTable, 0, _listOverrideTable.Length);
            Document.OutputDebugLinebreak(result);

            // list override index values are 1-based, not 0.
            // valid list override index values \ls are 1 to 2000.
            // if there are more then 2000 lists, the result is undefined.
            for (int i = 0; i < _lists.Count; i++)
            {
                result.Write(OpenGroup, 0, OpenGroup.Length);
                result.Write(_listOverride, 0, _listOverride.Length);
                result.Write(RtfList.ListId, 0, RtfList.ListId.Length);
                result.Write(t = IntToByteArray(((RtfList)_lists[i]).GetId()), 0, t.Length);
                result.Write(_listOverrideCount, 0, _listOverrideCount.Length);
                result.Write(t = IntToByteArray(0), 0, t.Length);    // is this correct? Spec says valid values are 1 or 9.
                result.Write(RtfList.ListNumber, 0, RtfList.ListNumber.Length);
                result.Write(t = IntToByteArray(((RtfList)_lists[i]).GetListNumber()), 0, t.Length);
                result.Write(CloseGroup, 0, CloseGroup.Length);
                Document.OutputDebugLinebreak(result);
            }
            result.Write(CloseGroup, 0, CloseGroup.Length);
            Document.OutputDebugLinebreak(result);
        }
Ejemplo n.º 4
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;
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Writes the definition part of this list level
        /// @throws IOException
        /// @since 2.1.3
        /// </summary>
        /// <param name="result"></param>
        public void WriteDefinition(Stream result)
        {
            byte[] t;
            result.Write(OpenGroup, 0, OpenGroup.Length);
            result.Write(_list, 0, _list.Length);
            result.Write(_listTemplateId, 0, _listTemplateId.Length);
            result.Write(t = IntToByteArray(Document.GetRandomInt()), 0, t.Length);

            int levelsToWrite = -1;

            switch (_listType)
            {
            case LIST_TYPE_NORMAL:
                levelsToWrite = _listLevels.Count;
                break;

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

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

            default:
                break;
            }
            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);
                Document.OutputDebugLinebreak(result);
            }

            result.Write(ListId, 0, ListId.Length);
            result.Write(t = IntToByteArray(_listId), 0, t.Length);
            result.Write(CloseGroup, 0, CloseGroup.Length);
            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;
                        }
                    }
                }
            }
        }