internal override void SaveToStream(IDataStream Workbook, TSaveData SaveData, int Row) { base.SaveToStream(Workbook, SaveData, Row); Workbook.Write16(OptionFlags); Workbook.Write16(ObjId); byte[] bAuthor = Biff8Author(); Workbook.Write(bAuthor, bAuthor.Length); }
private void WriteLocalFile(IDataStream DataStream, string value, ref int NewPos) { int i = 0; while (i + 3 <= value.Length && value.Substring(i, 3) == ".." + Path.DirectorySeparatorChar) { i += 3; } value = value.Substring(i); bool IsCompressed = !StrOps.IsWide(value); int WideDataLen = 0; byte[] ByteStr = null; if (!IsCompressed) { ByteStr = Encoding.Unicode.GetBytes(value); WideDataLen = 4 + 2 + ByteStr.Length; } NewPos += 2 + 4 + value.Length + 1 + 24 + 4 + WideDataLen; if (DataStream == null) { return; } DataStream.Write16((UInt16)(i / 3)); DataStream.Write32((UInt32)(value.Length + 1)); byte[] NewData = new byte[value.Length + 1]; StrOps.CompressBestUnicode(value, NewData, 0); DataStream.Write(NewData, NewData.Length); DataStream.Write32(0xDEADFFFF); NewData = new byte[20]; DataStream.Write(NewData, NewData.Length); if (IsCompressed) { DataStream.Write32(0); return; } else { DataStream.Write32((UInt32)(4 + 2 + ByteStr.Length)); } DataStream.Write32((UInt32)ByteStr.Length); DataStream.Write16(0x0003); DataStream.Write(ByteStr, ByteStr.Length); }
internal override void SaveToStream(IDataStream Workbook, TSaveData SaveData, int Row) { //We can't check for ColSplit/RowSplit since we don't know what it is. It doesn't really matter either. Biff8Utils.CheckRow(FirstVisibleRow); Biff8Utils.CheckCol(FirstVisibleCol); Workbook.WriteHeader((UInt16)Id, (UInt16)TotalSizeNoHeaders()); Workbook.Write16((UInt16)ColSplit); Workbook.Write16((UInt16)RowSplit); Workbook.Write16((UInt16)FirstVisibleRow); Workbook.Write16((UInt16)FirstVisibleCol); Workbook.Write16((UInt16)ActivePane); }
private void WriteString(IDataStream DataStream, string value, ref int NewPos, int ByteSize) { if (value == null || value.Length == 0) { return; } byte[] ByteStr = Encoding.Unicode.GetBytes(value); if (DataStream != null) { DataStream.Write32((UInt32)((ByteStr.Length + 2) / ByteSize)); } NewPos += 4; if (DataStream != null) { DataStream.Write(ByteStr, ByteStr.Length); } NewPos += ByteStr.Length; if (DataStream != null) { DataStream.Write16(0); } NewPos += 2; }
internal void WriteExtSST(IDataStream DataStream, bool Repeatable) { // Calc number of strings per hash bucket UInt16 n = (UInt16)((Data.Count / 128) + 1); if (n < 8) { n = 8; } int nBuckets = 0; if (Data.Count == 0) { nBuckets = 0; } else { nBuckets = (Data.Count - 1) / n + 1; } DataStream.WriteHeader((UInt16)xlr.EXTSST, (UInt16)(2 + 8 * nBuckets)); DataStream.Write16(n); if (Repeatable) { //REPEATABLEWRITES TSSTEntry[] SortedEntries = new TSSTEntry[Data.Count]; Data.Keys.CopyTo(SortedEntries, 0); Array.Sort(SortedEntries); int i = 0; while (i < SortedEntries.Length) { TSSTEntry e = SortedEntries[i]; DataStream.Write32((UInt32)e.AbsStreamPos); DataStream.Write32(e.RecordStreamPos); i += n; } } else { Dictionary <TSSTEntry, TSSTEntry> .Enumerator myEnumerator = Data.GetEnumerator(); while (myEnumerator.MoveNext()) { TSSTEntry e = myEnumerator.Current.Key; DataStream.Write32((UInt32)e.AbsStreamPos); DataStream.Write32(e.RecordStreamPos); for (int i = 0; i < n - 1; i++) { if (!myEnumerator.MoveNext()) { return; //the if is needed to fix a bug in mono. } } } } }
internal void SaveStandardWidth(IDataStream DataStream) { if (!AllowStandardWidth || DefColWidthChars256 < 0) { return; } DataStream.WriteHeader((UInt16)xlr.STANDARDWIDTH, 2); DataStream.Write16((UInt16)DefColWidthChars256); }
internal override void SaveFirstMul(IDataStream Workbook, TSaveData SaveData, int Row, int JoinedRecordSize) { unchecked { Workbook.WriteHeader((UInt16)xlr.MULBLANK, (UInt16)(JoinedRecordSize - XlsConsts.SizeOfTRecordHeader)); Workbook.Write32((UInt32)((UInt16)Row + (((UInt16)Col) << 16))); } Workbook.Write16(SaveData.GetBiff8FromCellXF(XF)); }
internal override void SaveToStream(IDataStream Workbook, TSaveData SaveData, int Row) { if (FText == null || FText.Length == 0) { return; } byte[] b = Encoding.Unicode.GetBytes(TrimmedText); Workbook.WriteHeader((UInt16)Id, (UInt16)(b.Length + 12)); Workbook.Write16(0x0800); //record id Workbook.WriteRow(FirstRow); Workbook.WriteRow(LastRow); Workbook.WriteCol(FirstCol); Workbook.WriteCol(LastCol); Workbook.Write(b, b.Length); Workbook.Write16(0); //null terminated. }
internal void SaveToStream(IDataStream DataStream, TSaveData SaveData, byte PanePos) { if (SelectedCells == null || SelectedCells.Length == 0) { return; } if ((SaveData.ExcludedRecords & TExcludedRecords.CellSelection) != 0) { return; //Note that this will invalidate the size, but it doesnt matter as this is not saved for real use. We could write blanks here if we wanted to keep the offsets right. } byte[] ppos = new byte[1]; ppos[0] = PanePos; int CurrentPos = 0; do { int OldPos = CurrentPos; UInt16 RecordSize = ActualRecordSize(ref CurrentPos); DataStream.WriteHeader((UInt16)xlr.SELECTION, (UInt16)(RecordSize - XlsConsts.SizeOfTRecordHeader)); DataStream.Write(ppos, ppos.Length); DataStream.WriteRow(ActiveRow); DataStream.WriteCol(ActiveCol); DataStream.Write16((UInt16)ActiveSel); int len = CurrentPos - OldPos; DataStream.Write16((UInt16)len); unchecked { for (int i = 0; i < len; i++) { DataStream.WriteRow(SelectedCells[i].Top); DataStream.WriteRow(SelectedCells[i].Bottom); DataStream.WriteColByte(SelectedCells[i].Left); DataStream.WriteColByte(SelectedCells[i].Right); } } }while (CurrentPos < SelectedCells.Length); }
internal void SaveTabIds(IDataStream DataStream) { CheckTabId(); if (FTabList.Count > XlsConsts.MaxTabIdCount || FTabList.Count != FBoundSheets.Count) { return; } DataStream.WriteHeader((UInt16)xlr.TABID, (UInt16)(2 * FTabList.Count)); for (int i = 0; i < FTabList.Count; i++) { DataStream.Write16((UInt16)FTabList[i]); } }
private void SaveToStreamExt(IDataStream DataStream, TSaveData SaveData, int FirstRecord, int RecordCount) { if (RecordCount > 0) { Sort(); //just in case... int MyRecordCount = RecordCount; DataStream.WriteHeader((UInt16)RecordId, (UInt16)(2 + RecordCount * TPageBreak.Biff8Length)); DataStream.Write16((UInt16)MyRecordCount); for (int i = FirstRecord; i < FirstRecord + RecordCount; i++) { DataStream.Write(FList[i].Biff8Data(), TPageBreak.Biff8Length); } } }
internal static void SaveToStream(TNameRecordList Names, IDataStream Workbook, TFormulaType FmlaType, TParsedTokenList Data, bool WriteLen) { if (Data.TextLenght > FlxConsts.Max_FormulaLen97_2003) { FlxMessages.ThrowException(FlxErr.ErrFormulaTooLong, TFormulaConvertInternalToText.AsString(Data, 0, 0, null)); } int FmlaNoArrayLen; byte[] bData = TFormulaConvertInternalToBiff8.GetTokenData(Names, Data, FmlaType, out FmlaNoArrayLen); if (WriteLen) { Workbook.Write16((UInt16)FmlaNoArrayLen); } Workbook.Write(bData, bData.Length); }
private void SaveOneRecord(int i, int k, IDataStream DataStream, TSaveData SaveData) { DataStream.WriteHeader((UInt16)xlr.COLINFO, (UInt16)TColInfoRecord.Length); DataStream.Write16((UInt16)i); DataStream.Write16((UInt16)k); DataStream.Write16((UInt16)this[i].Width); DataStream.Write16(SaveData.GetBiff8FromCellXF(this[i].XF)); DataStream.Write16((UInt16)(this[i].Options)); DataStream.Write16(0); }
internal override void SaveToStream(IDataStream Workbook, TSaveData SaveData, int Row) { Workbook.WriteHeader((UInt16)Id, (UInt16)TotalSizeNoHeaders()); Workbook.Write16((UInt16)Id); //FrtHeader Workbook.Write(new byte[10], 10); Workbook.Write32((UInt32)TotalSizeNoHeaders()); int ic = SheetColor.GetBiff8ColorIndex(SaveData.Palette, TAutomaticColor.SheetTab); if (ic < 0x08 || ic > 0x3f) { ic = 0x7f; } Workbook.Write32((UInt32)ic); UInt32 ic2 = (UInt32)ic; if (CondFmtCalc) { ic2 |= 0x80; } if (NotPublished) { ic2 |= 0x100; } Workbook.Write32(ic2); switch (SheetColor.ColorType) { case TColorType.RGB: Workbook.Write32(0x02); UInt32 RGB = (UInt32)(SheetColor.RGB); UInt32 BGR = 0xFF000000 | (RGB & 0x00FF00) | ((RGB & 0xFF0000) >> 16) | ((RGB & 0x0000FF) << 16); Workbook.Write32(BGR); break; case TColorType.Automatic: Workbook.Write32(0x00); Workbook.Write32(0x00); break; case TColorType.Theme: Workbook.Write32(0x03); Workbook.Write32((UInt32)SheetColor.Theme); break; case TColorType.Indexed: Workbook.Write32(0x01); Workbook.Write32((UInt32)ic); break; default: XlsMessages.ThrowException(XlsErr.ErrExcelInvalid); break; } Workbook.Write(BitConverter.GetBytes(SheetColor.Tint), 8); }
internal static void SaveDSF(IDataStream DataStream) { DataStream.WriteHeader((UInt16)xlr.DSF, 2); DataStream.Write16(0); //we won't use double stream files, as the content in the other stream will probably be out of date. }
internal override void SaveLastMul(IDataStream Workbook, TSaveData SaveData) { Workbook.Write16(SaveData.GetBiff8FromCellXF(XF)); Workbook.Write16((UInt16)Col); }
internal override void SaveMidMul(IDataStream Workbook, TSaveData SaveData) { Workbook.Write16(SaveData.GetBiff8FromCellXF(XF)); }
internal override void SaveLastMul(IDataStream Workbook, TSaveData SaveData) { Workbook.Write16(SaveData.GetBiff8FromCellXF(XF)); Workbook.Write(BitConverter.GetBytes((Int32)RK), 4); Workbook.Write16((UInt16)Col); }