Beispiel #1
0
 internal Paragraph(WordDocument owner, int offset, int length,
     WordDocument.FileCharacterPosition fcp, PapxInFkps papxInFkps)
 {
     this.owner = owner;
     this.Offset = offset;
     this.Length = length;
     this.FileCharacterPosition = fcp;
     this.PapxInFkps = papxInFkps;
 }
        internal static PapxFkp ReadPapxFkp(Stream s)
        {
            byte[] data = ReadUtils.ReadExact(s, PapxFkp.Size);
            MemoryStream dataStream = new MemoryStream(data, false);

            PapxFkp papxFkp = new PapxFkp();

            papxFkp.cpara = data[PapxFkp.Size - 1];
            int cpara = papxFkp.cpara;
            if (cpara < 1 || cpara > 0x1D)
                throw new WordFileReaderException("Invalid PapxFkp: cpara");

            papxFkp.rgfc = new uint[cpara + 1];
            for (int i = 0; i <= cpara; i++)
            {
                papxFkp.rgfc[i] = BitConverter.ToUInt32(data, i * 4);
            }
            papxFkp.rgbx = new KeyValuePair<BxPap, PapxInFkps>[cpara];
            int rgbxOffset = (cpara + 1) * 4;
            for (int i = 0; i < cpara; i++)
            {
                BxPap bxPap = new BxPap();
                bxPap.bOffset = data[rgbxOffset + i * BxPap.Size];

                int papxInFkpsOffset = 2 * bxPap.bOffset;

                PapxInFkps papxInFkps = new PapxInFkps();
                papxInFkps.cb = data[papxInFkpsOffset++];
                int grpprlInPapxLength;
                if (papxInFkps.cb == 0)
                {
                    int cb_ = data[papxInFkpsOffset++];
                    grpprlInPapxLength = 2 * cb_;
                }
                else
                {
                    grpprlInPapxLength = 2 * papxInFkps.cb - 1;
                }
                GrpPrlAndIstd grpPrlAndIstd = new GrpPrlAndIstd();
                grpPrlAndIstd.istd = BitConverter.ToUInt16(data, papxInFkpsOffset);
                dataStream.Position = papxInFkpsOffset + 2;
                int position = 2;
                grpPrlAndIstd.grpprl = ReadPrls(dataStream, grpprlInPapxLength - position, ref position);

                papxInFkps.grpprlInPapx = grpPrlAndIstd;

                papxFkp.rgbx[i] = new KeyValuePair<BxPap,PapxInFkps>(bxPap, papxInFkps);
            }
            return papxFkp;
        }