123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Runtime.InteropServices;
- using Biff8Excel.Interfaces;
- namespace Biff8Excel.Records
- {
- [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 1)]
- struct RecordExtendedFormat
- {
- public ushort opcode;
- public ushort length;
- public ushort fontIndex;
- public ushort formatIndex;
- public ushort cellOptions;
- [MarshalAs(UnmanagedType.U1, SizeConst = 1)]public byte alignmentOptions;
- [MarshalAs(UnmanagedType.U1, SizeConst = 1)]public byte rotationOptions;
- [MarshalAs(UnmanagedType.U1, SizeConst = 1)]public byte indentationOpions;
- [MarshalAs(UnmanagedType.U1, SizeConst = 1)]public byte usedAttribute;
- public uint borderOptions1;
- public uint borderOptions2;
- public ushort fillPalleteOptions;
- }
- internal class ExtendedFormat : IRecords
- {
- byte mHAlign;
- byte mWrapText;
- byte mVAlign;
-
- uint mLeftLineStyle;
- uint mRightLineStyle;
- uint mTopLineStyle;
- uint mBottomLineStyle;
- uint mLeftColourIndex;
- uint mRightColourIndex;
- uint mDiagTLBR;
- uint mDiagTRBL;
- uint mTopColourIndex;
- uint mBottomColourIndex;
- uint mDiagColourIndex;
- uint mDiagLineStyle;
- uint mFillPattern;
- ushort mPatternFore ;
- ushort mPatternBack;
-
- RecordExtendedFormat extendedformat;
- public ExtendedFormat()
- {
- extendedformat.opcode = 0xE0;
- extendedformat.length = 0x14;
- }
- public ushort ID
- {
- get { return extendedformat.opcode; }
- }
- public ushort RecordSize
- {
- get { return 24; }
- }
- public ushort FontIndex
- {
- set { extendedformat.fontIndex = value; }
- }
- public ushort FormatIndex
- {
- set
- {
- extendedformat.formatIndex = value;
- }
- }
- public bool CellIsLocked
- {
- set
- {
- if (value)
- extendedformat.cellOptions |= 0x1;
- else
- //extendedformat.cellOptions &= ~0x1;
- extendedformat.cellOptions = (ushort)(extendedformat.cellOptions & (~0x1));
- }
- }
- public bool FormulaHidden
- {
- set {
- if (value)
- extendedformat.cellOptions |= 0x2;
- else
- //extendedformat.cellOptions &= ~0x2;
- extendedformat.cellOptions = (ushort)(extendedformat.cellOptions & (~0x2));
- }
- }
- public byte StyleType
- {
- set
- {
- if (value == 0x1) //SheetStyle
- {
- extendedformat.cellOptions |= 0x4;
- extendedformat.cellOptions = (ushort)(extendedformat.cellOptions | 0xFFF0);
- //extendedformat.cellOptions |= -16;
- }
- else
- {
- //extendedformat.cellOptions &= ~0x4;
- extendedformat.cellOptions = (ushort)(extendedformat.cellOptions & (~0x4));
- }
- }
- }
- void SetAlignment()
- {
- extendedformat.alignmentOptions = 0;
- extendedformat.alignmentOptions |= mHAlign;
- extendedformat.alignmentOptions |= mWrapText;
- extendedformat.alignmentOptions |= mVAlign;
- }
- public byte HorizontalAlignment
- {
- set
- {
- mHAlign = value;
- this.SetAlignment();
- }
- }
- public bool WrapText
- {
- set
- {
- mWrapText = (byte)(value ? 0x8 : 0x0);
- this.SetAlignment();
- }
- }
- public byte VerticalAlignment
- {
- set
- {
- mVAlign = value;
- //mVAlign = mVAlign * Math.Pow(2,4)
- mVAlign *= 16;
- this.SetAlignment();
- }
- }
- public byte TextRoationAngle
- {
- set { extendedformat.rotationOptions = value; }
- }
- public bool StackText
- {
- set
- {
- if (value)
- extendedformat.rotationOptions = 0xFF;
- }
- }
- public byte UsedAttribute
- {
- set { extendedformat.usedAttribute = value; }
- }
- void SetBorderOptions1()
- {
- extendedformat.borderOptions1 = 0;
- extendedformat.borderOptions1 |= mLeftLineStyle;
- extendedformat.borderOptions1 |= mRightLineStyle;
- extendedformat.borderOptions1 |= mTopLineStyle;
- extendedformat.borderOptions1 |= mBottomLineStyle;
- extendedformat.borderOptions1 |= mLeftColourIndex;
- extendedformat.borderOptions1 |= mRightColourIndex;
- extendedformat.borderOptions1 |= mDiagTLBR;
- extendedformat.borderOptions1 |= mDiagTRBL;
- }
- public byte LeftLineStyle
- {
- set
- {
- mLeftLineStyle = value;
- extendedformat.usedAttribute |= (0x8 << 2 );
- this.SetBorderOptions1();
- }
- }
- public byte LeftLineColour
- {
- set
- {
- // mLeftColourIndex = CLng(vData) * (2 ^ 16)
- mLeftColourIndex = (uint)(value << 16);
- this.SetBorderOptions1();
- }
- }
- public byte RightLineStyle
- {
- set
- {
- // mRightLineStyle = CLng(vData) * (2 ^ 4)
- mRightLineStyle = (uint)(value << 4);
- extendedformat.usedAttribute |= (0x8 << 2);
- this.SetBorderOptions1();
- }
- }
- public byte RightLineColour
- {
- set
- {
- // mRightColourIndex = CLng(vData) * (2 ^ 23)
- mRightColourIndex = (uint)(value << 23);
- this.SetBorderOptions1();
- }
- }
- public byte TopLineStyle
- {
- set
- {
- // mTopLineStyle = CLng(vData) * (2 ^ 8)
- mTopLineStyle = (uint)(value << 8);
- // field_6_used_Attribute = field_6_used_Attribute Or (&H8 * (2 ^ 2))
- extendedformat.usedAttribute |= (0x8 << 2);
- this.SetBorderOptions1();
- }
- }
- public byte TopLineColour
- {
- set
- {
- // mTopColourIndex = CLng(vData) * (2 ^ 0)
- mTopColourIndex = value;
- this.SetBorderOptions2();
- }
- }
- public byte BottomLineStyle
- {
- set
- {
- // mBottomLineStyle = CLng(vData) * (2 ^ 12)
- mBottomLineStyle = (uint)(value << 12);
- // field_6_used_Attribute = field_6_used_Attribute Or (&H8 * (2 ^ 2))
- extendedformat.usedAttribute |= (0x8 << 2);
- this.SetBorderOptions1();
- }
- }
- void SetBorderOptions2()
- {
- extendedformat.borderOptions2 = 0;
- extendedformat.borderOptions2 |= mTopColourIndex;
- extendedformat.borderOptions2 |= mBottomColourIndex;
- extendedformat.borderOptions2 |= mDiagColourIndex;
- extendedformat.borderOptions2 |= mDiagLineStyle;
- extendedformat.borderOptions2 |= mFillPattern;
- }
- public byte BottomLineColour
- {
- set
- {
- // mBottomColourIndex = CLng(vData) * (2 ^ 7)
- mBottomColourIndex = (uint)(value << 7);
- this.SetBorderOptions2();
- }
- }
- public byte DiagLineTopLeftToBottonRight
- {
- set
- {
- // mDiagTLBR = CLng(vData) * (2 ^ 30)
- mDiagTLBR = (uint)(value << 30);
- // field_6_used_Attribute = field_6_used_Attribute Or (&H8 * (2 ^ 2))
- extendedformat.usedAttribute |= (0x8 << 2);
- this.SetBorderOptions1();
- }
- }
- public byte DiagLineTopRightToBottonLeft
- {
- set
- {
- mDiagTRBL = (uint)(value << 31);
- // field_6_used_Attribute = field_6_used_Attribute Or (&H8 * (2 ^ 2))
- extendedformat.usedAttribute |= (0x8 << 2);
- this.SetBorderOptions1();
- }
- }
- public byte DiagLineStyle
- {
- set
- {
- mDiagLineStyle = (uint)(value << 21);
- extendedformat.usedAttribute |= (0x8 << 2);
- this.SetBorderOptions2();
- }
- }
- public byte DiagLineColour
- {
- set
- {
- mDiagColourIndex = (uint)(value << 14);
- this.SetBorderOptions2();
- }
- }
- public byte FillPattern
- {
- set
- {
- mFillPattern = (uint)(value << 26);
- this.SetBorderOptions2();
- }
- }
- public byte PatternForeColour
- {
- set
- {
- mPatternFore = (ushort)(value << 0); //Shift Bits Up by 0
- extendedformat.fillPalleteOptions = 0;
- extendedformat.fillPalleteOptions |= mPatternFore;
- extendedformat.fillPalleteOptions |= mPatternBack;
- }
- }
- public byte PatternBackColour
- {
- set
- {
- mPatternBack = (ushort)(value << 7); //Shift Bits Up by 7
- extendedformat.fillPalleteOptions = 0;
- extendedformat.fillPalleteOptions |= mPatternFore;
- extendedformat.fillPalleteOptions |= mPatternBack;
- }
- }
- #region IRecords ³ÉÔ±
- public byte[] GetByte()
- {
- return Globals.GetStructToBytes(extendedformat);
- }
- #endregion
- }
- }
|