public byte[] WriteTo(HWPFStream docStream) { PlexOfCps textPlex = new PlexOfCps(PieceDescriptor.SizeInBytes); // int fcMin = docStream.Getoffset(); int size = _textPieces.Count; for (int x = 0; x < size; x++) { TextPiece next = _textPieces[x]; PieceDescriptor pd = next.PieceDescriptor; int offset = docStream.Offset; int mod = (offset % POIFSConstants.SMALLER_BIG_BLOCK_SIZE); if (mod != 0) { mod = POIFSConstants.SMALLER_BIG_BLOCK_SIZE - mod; byte[] buf = new byte[mod]; docStream.Write(buf); } // set the text piece position to the current docStream offset. pd.FilePosition = (docStream.Offset); // write the text to the docstream and save the piece descriptor to // the // plex which will be written later to the tableStream. docStream.Write(next.RawBytes); // The TextPiece is already in characters, which // Makes our life much easier int nodeStart = next.Start; int nodeEnd = next.End; textPlex.AddProperty(new GenericPropertyNode(nodeStart, nodeEnd, pd.ToByteArray())); } return textPlex.ToByteArray(); }