private void LoadParagraphs(Stream wordDocumentStream, Clx clx, PlcBtePapx plcfBtePapx) { List<Paragraph> paragraphs = new List<Paragraph>(); for (int i = 0; i < plcfBtePapx.aPnBtePapx.Length; i++) { wordDocumentStream.Position = plcfBtePapx.aPnBtePapx[i].pn * 512; PapxFkp papxFkp = BasicTypesReader.ReadPapxFkp(wordDocumentStream); for (int j = 0; j < papxFkp.rgbx.Length; j++) { int startFc = (int)papxFkp.rgfc[j]; int endFc = (int)papxFkp.rgfc[j + 1]; FileCharacterPosition fc = Array.Find(fileCharacterPositions, new Predicate<FileCharacterPosition>(delegate(FileCharacterPosition f) { return !(endFc <= f.Offset || f.Offset + f.BytesPerCharacter * f.Length < startFc); })); if (fc == null) continue; // invalid section if (startFc < fc.Offset) startFc = fc.Offset; if (endFc > fc.Offset + fc.BytesPerCharacter * fc.Length) endFc = fc.Offset + fc.BytesPerCharacter * fc.Length; Paragraph para = new Paragraph(this, (startFc - fc.Offset) / fc.BytesPerCharacter, (endFc - startFc) / fc.BytesPerCharacter, fc, papxFkp.rgbx[j].Value); paragraphs.Add(para); } } paragraphs.Sort(new Comparison<Paragraph>(delegate(Paragraph p1, Paragraph p2) { return p1.Offset - p2.Offset; })); this.paragraphs = paragraphs.ToArray(); }
internal static PlcBtePapx ReadPlcfBtePapx(Stream s, uint length) { int n = PlcBtePapx.GetLength(length); PlcBtePapx plcfBtePapx = new PlcBtePapx(); plcfBtePapx.aFC = new uint[n + 1]; for (int i = 0; i <= n; i++) { plcfBtePapx.aFC[i] = BitConverter.ToUInt32(ReadUtils.ReadExact(s, ReadUtils.DWordSize), 0); } plcfBtePapx.aPnBtePapx = new PnFkpPapx[n]; for (int i = 0; i < n; i++) { PnFkpPapx item = new PnFkpPapx(); item.pn = BitConverter.ToUInt32(ReadUtils.ReadExact(s, ReadUtils.DWordSize), 0); plcfBtePapx.aPnBtePapx[i] = item; } return plcfBtePapx; }