コード例 #1
0
        public int AddList(ListData lst, ListFormatOverride override1)
        {
            int lsid = lst.GetLsid();

            while (_listMap[lsid] != null)
            {
                lsid = lst.ResetListID();
                override1.SetLsid(lsid);
            }
            _listMap.Add(lsid, lst);
            _overrideList.Add(override1);
            return(lsid);
        }
コード例 #2
0
ファイル: ListFormatOverride.cs プロジェクト: zzy092/npoi
        public override bool Equals(Object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            ListFormatOverride lfo = (ListFormatOverride)obj;

            return(lfo._clfolvl == _clfolvl && lfo._lsid == _lsid &&
                   lfo._reserved1 == _reserved1 && lfo._reserved2 == _reserved2 &&
                   Arrays.Equals(lfo._reserved3, _reserved3) &&
                   Arrays.Equals(lfo._levelOverrides, _levelOverrides));
        }
コード例 #3
0
        public ListTables(byte[] tableStream, int lstOffset, int lfoOffset)
        {
            // get the list data
            int length = LittleEndian.GetShort(tableStream, lstOffset);

            lstOffset += LittleEndianConsts.SHORT_SIZE;
            int levelOffset = lstOffset + (length * LIST_DATA_SIZE);

            for (int x = 0; x < length; x++)
            {
                ListData lst = new ListData(tableStream, lstOffset);
                _listMap.Add(lst.GetLsid(), lst);
                lstOffset += LIST_DATA_SIZE;

                int num = lst.numLevels();
                for (int y = 0; y < num; y++)
                {
                    ListLevel lvl = new ListLevel(tableStream, levelOffset);
                    lst.SetLevel(y, lvl);
                    levelOffset += lvl.GetSizeInBytes();
                }
            }

            // now get the list format overrides. The size is an int unlike the LST size
            length     = LittleEndian.GetInt(tableStream, lfoOffset);
            lfoOffset += LittleEndianConsts.INT_SIZE;
            int lfolvlOffset = lfoOffset + (LIST_FORMAT_OVERRIDE_SIZE * length);

            for (int x = 0; x < length; x++)
            {
                ListFormatOverride lfo = new ListFormatOverride(tableStream, lfoOffset);
                lfoOffset += LIST_FORMAT_OVERRIDE_SIZE;
                int num = lfo.numOverrides();
                for (int y = 0; y < num; y++)
                {
                    while (tableStream[lfolvlOffset] == 255)
                    {
                        lfolvlOffset++;
                    }
                    ListFormatOverrideLevel lfolvl = new ListFormatOverrideLevel(tableStream, lfolvlOffset);
                    lfo.SetOverride(y, lfolvl);
                    lfolvlOffset += lfolvl.GetSizeInBytes();
                }
                _overrideList.Add(lfo);
            }
        }
コード例 #4
0
ファイル: ListTables.cs プロジェクト: JnS-Software-LLC/npoi
        public ListTables(byte[] tableStream, int lstOffset, int lfoOffset)
        {
            // get the list data
            int length = LittleEndian.GetShort(tableStream, lstOffset);
            lstOffset += LittleEndianConsts.SHORT_SIZE;
            int levelOffset = lstOffset + (length * LIST_DATA_SIZE);

            for (int x = 0; x < length; x++)
            {
                ListData lst = new ListData(tableStream, lstOffset);
                _listMap.Add(lst.GetLsid(), lst);
                lstOffset += LIST_DATA_SIZE;

                int num = lst.numLevels();
                for (int y = 0; y < num; y++)
                {
                    ListLevel lvl = new ListLevel(tableStream, levelOffset);
                    lst.SetLevel(y, lvl);
                    levelOffset += lvl.GetSizeInBytes();
                }
            }

            // now get the list format overrides. The size is an int unlike the LST size
            length = LittleEndian.GetInt(tableStream, lfoOffset);
            lfoOffset += LittleEndianConsts.INT_SIZE;
            int lfolvlOffset = lfoOffset + (LIST_FORMAT_OVERRIDE_SIZE * length);
            for (int x = 0; x < length; x++)
            {
                ListFormatOverride lfo = new ListFormatOverride(tableStream, lfoOffset);
                lfoOffset += LIST_FORMAT_OVERRIDE_SIZE;
                int num = lfo.numOverrides();
                for (int y = 0; y < num; y++)
                {
                    while (tableStream[lfolvlOffset] == 255)
                    {
                        lfolvlOffset++;
                    }
                    ListFormatOverrideLevel lfolvl = new ListFormatOverrideLevel(tableStream, lfolvlOffset);
                    lfo.SetOverride(y, lfolvl);
                    lfolvlOffset += lfolvl.GetSizeInBytes();
                }
                _overrideList.Add(lfo);
            }
        }
コード例 #5
0
        public int GetOverrideIndexFromListID(int lstid)
        {
            int returnVal = -1;
            int size      = _overrideList.Count;

            for (int x = 0; x < size; x++)
            {
                ListFormatOverride next = _overrideList[x];
                if (next.GetLsid() == lstid)
                {
                    // 1-based index I think
                    returnVal = x + 1;
                    break;
                }
            }
            if (returnVal == -1)
            {
                throw new InvalidDataException("No list found with the specified ID");
            }
            return(returnVal);
        }
コード例 #6
0
        public void WriteListOverridesTo(HWPFStream tableStream)
        {
            // use this stream as a buffer for the levels since their size varies.
            MemoryStream levelBuf = new MemoryStream();

            int size = _overrideList.Count;

            byte[] intHolder = new byte[4];
            LittleEndian.PutInt(intHolder, 0, size);
            tableStream.Write(intHolder);

            for (int x = 0; x < size; x++)
            {
                ListFormatOverride lfo = _overrideList[x];
                tableStream.Write(lfo.ToArray());
                ListFormatOverrideLevel[] lfolvls = lfo.GetLevelOverrides();
                for (int y = 0; y < lfolvls.Length; y++)
                {
                    byte[] bytes = lfolvls[y].ToArray();
                    levelBuf.Write(bytes, 0, bytes.Length);
                }
            }
            tableStream.Write(levelBuf.ToArray());
        }
コード例 #7
0
ファイル: HWPFList.cs プロジェクト: hanwangkun/npoi
 /**
  *
  * @param numbered true if the list should be numbered; false if it should be
  *        bulleted.
  * @param styleSheet The document's stylesheet.
  */
 public HWPFList(bool numbered, StyleSheet styleSheet)
 {
     _listData = new ListData((int)(new Random((int)DateTime.Now.Ticks).Next(0,100)/100 * DateTime.Now.Millisecond), numbered);
     _override = new ListFormatOverride(_listData.GetLsid());
     _styleSheet = styleSheet;
 }
コード例 #8
0
ファイル: ListTables.cs プロジェクト: JnS-Software-LLC/npoi
 public int AddList(ListData lst, ListFormatOverride override1)
 {
     int lsid = lst.GetLsid();
     while (_listMap[lsid] != null)
     {
         lsid = lst.ResetListID();
         override1.SetLsid(lsid);
     }
     _listMap.Add(lsid, lst);
     _overrideList.Add(override1);
     return lsid;
 }