public void Serialize(ContinuableRecordOutput out1) { int numberOfRichTextRuns = 0; int extendedDataSize = 0; if (IsRichText && field_4_format_Runs != null) { numberOfRichTextRuns = field_4_format_Runs.Count; } if (IsExtendedText && field_5_ext_rst != null) { extendedDataSize = field_5_ext_rst.Length; } out1.WriteString(field_3_string, numberOfRichTextRuns, extendedDataSize); if (numberOfRichTextRuns > 0) { //This will ensure that a run does not split a continue for (int i = 0; i < numberOfRichTextRuns; i++) { if (out1.AvailableSpace < 4) { out1.WriteContinue(); } FormatRun r = field_4_format_Runs[i]; r.Serialize(out1); } } if (extendedDataSize > 0) { // OK ExtRst is actually not documented, so i am going to hope // that we can actually continue on byte boundaries int extPos = 0; while (true) { int nBytesToWrite = Math.Min(extendedDataSize - extPos, out1.AvailableSpace); out1.Write(field_5_ext_rst, extPos, nBytesToWrite); extPos += nBytesToWrite; if (extPos >= extendedDataSize) { break; } out1.WriteContinue(); } } }
/** * Serialises out the String. There are special rules * about where we can and can't split onto * Continue records. */ public void Serialize(ContinuableRecordOutput out1) { int numberOfRichTextRuns = 0; int extendedDataSize = 0; if (IsRichText && field_4_format_Runs != null) { numberOfRichTextRuns = field_4_format_Runs.Count; } if (IsExtendedText && field_5_ext_rst != null) { extendedDataSize = 4 + field_5_ext_rst.DataSize; } // Serialise the bulk of the String // The WriteString handles tricky continue stuff for us out1.WriteString(field_3_string, numberOfRichTextRuns, extendedDataSize); if (numberOfRichTextRuns > 0) { //This will ensure that a run does not split a continue for (int i = 0; i < numberOfRichTextRuns; i++) { if (out1.AvailableSpace < 4) { out1.WriteContinue(); } FormatRun r = field_4_format_Runs[(i)]; r.Serialize(out1); } } if (extendedDataSize > 0) { field_5_ext_rst.Serialize(out1); } }