Row.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Runtime.InteropServices;
  5. using Biff8Excel.Interfaces;
  6. namespace Biff8Excel.Records
  7. {
  8. [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 1)]
  9. struct RecordRow
  10. {
  11. public ushort opcode;
  12. public ushort length;
  13. public ushort rownumber;
  14. public ushort firstcol;
  15. public ushort lastcol;
  16. public ushort height;
  17. public ushort zeronotused;
  18. public ushort notused;
  19. [MarshalAs(UnmanagedType.U1, SizeConst = 1)]public byte optionflags1; // hidden, badFontHeight, xf flag
  20. [MarshalAs(UnmanagedType.U1, SizeConst = 1)]public byte optionflags2; //Alawys 0x1
  21. public ushort optionflags3; //has xf style
  22. }
  23. internal class Row : IRecords
  24. {
  25. RecordRow row;
  26. byte m_RowHidden;
  27. byte m_RowFontNoMatch;
  28. byte m_RowExplicitFormat;
  29. ushort m_XFIndex;
  30. ushort m_SpaceAbove;
  31. ushort m_SpaceBelow;
  32. const int TwipsPerPixelY = 15;
  33. public Row()
  34. {
  35. row.opcode = 0x208;
  36. row.length = 0x10;
  37. row.height = (ushort)(row.height | 0x8000); //flag for default height
  38. row.zeronotused = 0x0;
  39. row.notused = 0x0;
  40. }
  41. public ushort ID
  42. {
  43. get { return row.opcode; }
  44. }
  45. public ushort RecordSize
  46. {
  47. get { return 20; }
  48. }
  49. public ushort RowNumber
  50. {
  51. set { row.rownumber = value; }
  52. }
  53. public ushort FirstColumnNumber
  54. {
  55. set { row.firstcol = value; }
  56. get { return row.firstcol;}
  57. }
  58. public ushort LastColumnNumber
  59. {
  60. set { row.lastcol = value; }
  61. get { return row.lastcol; }
  62. }
  63. public bool Hidden
  64. {
  65. set { m_RowHidden = (byte)(value ? 0x20 : 0x0); }
  66. }
  67. public ushort HeightInPoints
  68. {
  69. set
  70. {
  71. // field_4_height = vData * Screen.TwipsPerPixelY
  72. row.height = (ushort)(value * TwipsPerPixelY);
  73. m_RowFontNoMatch = 0x40;
  74. }
  75. get { return (ushort)(row.height / TwipsPerPixelY); }
  76. }
  77. public ushort ExtendedFormatIndex
  78. {
  79. set {
  80. m_XFIndex = value;
  81. m_RowExplicitFormat = (byte)(value > 0 ? 0x80 : 0x0);
  82. }
  83. }
  84. public bool AdditionalSpaceAbove
  85. {
  86. set { m_SpaceAbove = (ushort)(value ? 0x1000 : 0x0);}
  87. }
  88. public bool AdditionalSpaceBelow
  89. {
  90. set {
  91. if (value)
  92. m_SpaceBelow = 0x2000;
  93. else
  94. m_SpaceBelow = 0;
  95. }
  96. }
  97. #region IRecords ³ÉÔ±
  98. public byte[] GetByte()
  99. {
  100. row.optionflags1 = (byte)(m_RowHidden | m_RowFontNoMatch | m_RowExplicitFormat);
  101. row.optionflags2 = 0x1;
  102. row.optionflags3 = (ushort)(m_XFIndex | m_SpaceAbove | m_SpaceBelow);
  103. return Globals.GetStructToBytes(row);
  104. }
  105. #endregion
  106. }
  107. }