internal TExcelString(TStrLenLength aStrLenLength, string s, TRTFRun[] RTFRuns, bool ForceWide) { StrLenLength = aStrLenLength; if (StrLenLength == TStrLenLength.is8bits) { if (s.Length > 0xFF) { XlsMessages.ThrowException(XlsErr.ErrInvalidStringRecord); } } OptionFlags = 0; if (ForceWide || StrOps.IsWide(s)) { OptionFlags = 1; } if ((RTFRuns != null) && (RTFRuns.Length > 0)) { OptionFlags = (byte)(OptionFlags | 8); RichTextFormats = TRTFRun.ToByteArray(RTFRuns); } else { RichTextFormats = null; } FarEastData = null; Data = s; //We have to include all data on the hash. Hash = GetHashString().GetHashCode(); }
internal TExcelString(TStrLenLength aStrLenLength, ref TxBaseRecord aRecord, ref int Ofs) { StrLenLength = aStrLenLength; byte[] tmpLen = new byte[(byte)StrLenLength]; int StrLen = 0; BitOps.ReadMem(ref aRecord, ref Ofs, tmpLen); if (StrLenLength == TStrLenLength.is8bits) { StrLen = tmpLen[0]; } else { StrLen = BitConverter.ToUInt16(tmpLen, 0); } byte[] of1 = new byte[1]; BitOps.ReadMem(ref aRecord, ref Ofs, of1); OptionFlags = of1[0]; if (HasRichText) { byte [] NumberRichTextFormatsArray = new byte[2]; BitOps.ReadMem(ref aRecord, ref Ofs, NumberRichTextFormatsArray); RichTextFormats = new byte[4 * BitConverter.ToUInt16(NumberRichTextFormatsArray, 0)]; } else { RichTextFormats = null; } if (HasFarInfo) { byte [] FarEastDataSizeArray = new byte[4]; BitOps.ReadMem(ref aRecord, ref Ofs, FarEastDataSizeArray); FarEastData = new byte[BitConverter.ToUInt32(FarEastDataSizeArray, 0)]; } else { FarEastData = null; } StringBuilder s = new StringBuilder(StrLen); StrOps.ReadStr(ref aRecord, ref Ofs, s, OptionFlags, ref OptionFlags, StrLen); Data = s.ToString(); if (RichTextFormats != null) { BitOps.ReadMem(ref aRecord, ref Ofs, RichTextFormats); } if (FarEastData != null) { BitOps.ReadMem(ref aRecord, ref Ofs, FarEastData); } //We have to include all data on the hash. Hash = GetHashString().GetHashCode(); }