Пример #1
0
        private static void handleTabs(ParagraphProperties pap, SprmOperation sprm)
        {
            byte[] grpprl = sprm.Grpprl;
            int offset = sprm.GrpprlOffset;
            int delSize = grpprl[offset++];
            int[] tabPositions = pap.GetRgdxaTab();
            byte[] tabDescriptors = pap.GetRgtbd();

            Hashtable tabMap = new Hashtable();
            for (int x = 0; x < tabPositions.Length; x++)
            {
                tabMap.Add(tabPositions[x], tabDescriptors[x]);
            }

            for (int x = 0; x < delSize; x++)
            {
                tabMap.Remove(LittleEndian.GetShort(grpprl, offset));
                offset += LittleEndianConsts.SHORT_SIZE;
            }

            int addSize = grpprl[offset++];
            int start = offset;
            for (int x = 0; x < addSize; x++)
            {
                int key = LittleEndian.GetShort(grpprl, offset);
                Byte val = grpprl[start + ((LittleEndianConsts.SHORT_SIZE * addSize) + x)];
                tabMap.Add(key, val);
                offset += LittleEndianConsts.SHORT_SIZE;
            }

            tabPositions = new int[tabMap.Count];
            tabDescriptors = new byte[tabPositions.Length];
            ArrayList list = new ArrayList();

            IEnumerator keyIT = tabMap.Keys.GetEnumerator();
            while (keyIT.MoveNext())
            {
                list.Add(keyIT.Current);
            }
            list.Sort();

            for (int x = 0; x < tabPositions.Length; x++)
            {
                int key = (int)list[x];
                tabPositions[x] = key;
                tabDescriptors[x] = (byte)tabMap[key];
            }

            pap.SetRgdxaTab(tabPositions);
            pap.SetRgtbd(tabDescriptors);
        }