Exemplo n.º 1
0
		internal Style(Workbook wb, XfRecord xf) : base(wb)
		{	
			if(xf.FontIdx > 0 && xf.FontIdx < wb.Fonts.Count)
    	        _font = wb.Fonts[xf.FontIdx - 1];
		    _format = wb.Formats[xf.FormatIdx];
			_typeAndProtection = xf.TypeAndProtection;
			if(_typeAndProtection.IsCell)
				_parentStyle = wb.Styles[xf.ParentIdx];
			_horizontalAlignment = xf.HorizontalAlignment;
			_wrapped = xf.Wrapped;
			_verticalAlignment = xf.VerticalAlignment;
			_rotation = xf.Rotation;
			_indentLevel = xf.IndentLevel;
			_shrinkContent = xf.ShrinkContent;
			_parentStyleAttributes = xf.ParentStyle;
			_leftLineStyle = xf.LeftLineStyle;
			_rightLineStyle = xf.RightLineStyle;
			_topLineStyle = xf.TopLineStyle;
			_bottomLineStyle = xf.BottomLineStyle;
			_leftLineColor = wb.Palette.GetColor(xf.LeftLineColor);
			_rightLineColor = wb.Palette.GetColor(xf.RightLineColor);
			_diagonalRightTopToLeftBottom = xf.DiagonalRightTopToLeftBottom;
			_diagonalLeftBottomToTopRight = xf.DiagonalLeftBottomToTopRight;
			_topLineColor = wb.Palette.GetColor(xf.TopLineColor);
			_bottomLineColor = wb.Palette.GetColor(xf.BottomLineColor);
			_diagonalLineColor = wb.Palette.GetColor(xf.DiagonalLineColor);
			_diagonalLineStyle = xf.DiagonalLineStyle;
			_fillPattern = xf.FillPattern;
			_patternColor = wb.Palette.GetColor(xf.PatternColor);
			_patternBackground = wb.Palette.GetColor(xf.PatternBackground);
		}
Exemplo n.º 2
0
		/// <summary>
		/// The constructor for the record.
		/// </summary>
		/// <param name="biff">The GenericBiff record that should contain the correct type and data for the XF record.</param>
		/// <exception cref="InvalidRecordIdException">
		/// An InvalidRecordIdException is thrown if biff contains an invalid type or invalid data.
		/// </exception>
		public XfRecord(GenericBiff biff) 
		{
			if(biff.Id == (ushort)RecordType.Xf)
			{
				BinaryReader reader = new BinaryReader(biff.GetDataStream());
				
				_fontIdx = reader.ReadUInt16();
				_formatIdx = reader.ReadUInt16();

				ushort data = reader.ReadUInt16();
				_typeAndProtection = new TypeAndProtection(data & 0x000F);
				_parentIdx = (ushort)((data & 0xFFF0) >> 8);

				byte data2 = reader.ReadByte();
				_horizontalAlignment = (HorizontalAlignment)(data2 & 0x07);
				_wrapped = (data & 0x088) != 0;
				_verticalAlignment = (VerticalAlignment)((data2 & 0x70) >> 4);
				
				data2 = reader.ReadByte();
				_rotation = new Rotation(data2);

				data2 = reader.ReadByte();
				_indentLevel = new Nibble((byte)(data2 & 0x0F));
				_shrinkContent = (data2 & 0x10) == 1;

				_parentStyle = (ParentStyleAttributes)(reader.ReadByte());
					
				uint data3 = reader.ReadUInt32();
				_leftLineStyle = (LineStyle)(data3 & 0x0000000F);
				_rightLineStyle = (LineStyle)((data3 & 0x000000F0) >> 1);
				_topLineStyle = (LineStyle)((data3 & 0x00000F00) >> 2);
				_bottomLineStyle = (LineStyle)((data3 & 0x0000F000) >> 3);
				_rightLineColor = (ushort)((data3 & 0x007F0000) >> 4);
				_leftLineColor = (ushort)((data3 & 0x3F800000) >> 5);
				_diagonalRightTopToLeftBottom = (data & 0x40000000) == 1;
				_diagonalLeftBottomToTopRight = (data & 0x80000000) == 1;

				data3 = reader.ReadUInt32();
				_topLineColor = (ushort)(data3 & 0x0000007F);
				_bottomLineColor = (ushort)((data3 & 0x00003F80) >> 1);
				_diagonalLineColor = (ushort)((data3 & 0x001FC000) >> 3);
				_diagonalLineStyle = (LineStyle)((data3 & 0x01E00000) >> 5);
				_fillPattern = (FillPattern)((data3 & 0xFC000000) >> 6);

				data = reader.ReadUInt16();
				_patternColor = (ushort)(data & 0x007F);
				_patternBackground = (ushort)((data & 0x3F80) >> 7);

				Debug.Assert(reader.BaseStream.Position == reader.BaseStream.Length);
			}
			else
				throw new InvalidRecordIdException(biff.Id, RecordType.Xf);
		}