Class: XFRecord
- Inherits:
-
BiffRecord
- Object
- BiffRecord
- XFRecord
- Defined in:
- lib/surpass/biff_record.rb
Overview
XF Substructures
-------------------------------------------------------------------------
XF_TYPE_PROT XF Type and Cell Protection (3 Bits), BIFF3-BIFF8
These 3 bits are part of a specific data byte.
Bit Mask Contents
0 01H 1 = Cell is locked
1 02H 1 = Formula is hidden
2 04H 0 = Cell XF; 1 = Style XF
XF_USED_ATTRIB Attributes Used from Parent Style XF (6 Bits),
BIFF3-BIFF8 Each bit describes the validity of a specific group
of attributes. In cell XFs a cleared bit means the attributes of the
parent style XF are used (but only if the attributes are valid there),
a set bit means the attributes of this XF are used. In style XFs
a cleared bit means the attribute setting is valid, a set bit means the
attribute should be ignored.
Bit Mask Contents
0 01H Flag for number format
1 02H Flag for font
2 04H Flag for horizontal and vertical alignment, text wrap, indentation, orientation, rotation, and
text direction
3 08H Flag for border lines
4 10H Flag for background area style
5 20H Flag for cell protection (cell locked and formula hidden)
XF_HOR_ALIGN Horizontal Alignment (3 Bits), BIFF2-BIFF8 The horizontal
alignment consists of 3 bits and is part of a specific data byte.
Value Horizontal alignment
00H General
01H Left
02H Centred
03H Right
04H Filled
05H Justified (BIFF4-BIFF8X)
06H Centred across selection (BIFF4-BIFF8X)
07H Distributed (BIFF8X)
XF_VERT_ALIGN Vertical Alignment (2 or 3 Bits), BIFF4-BIFF8
The vertical alignment consists of 2 bits (BIFF4) or 3 bits (BIFF5-BIFF8)
and is part of a specific data byte. Vertical alignment is not available
in BIFF2 and BIFF3.
Value Vertical alignment
00H Top
01H Centred
02H Bottom
03H Justified (BIFF5-BIFF8X)
04H Distributed (BIFF8X)
XF_ORIENTATION Text Orientation (2 Bits), BIFF4-BIFF7 In the BIFF
versions BIFF4-BIFF7, text can be rotated in steps of 90 degrees
or stacked. The orientation mode consists of 2 bits and is part of
a specific data byte. In BIFF8 a rotation angle occurs instead of these
flags.
Value Text orientation
00H Not rotated
01H Letters are stacked top-to-bottom, but not rotated
02H Text is rotated 90 degrees counterclockwise
03H Text is rotated 90 degrees clockwise
XF_ROTATION Text Rotation Angle (1 Byte), BIFF8
Value Text rotation
0 Not rotated
1-90 1 to 90 degrees counterclockwise
91-180 1 to 90 degrees clockwise
255 Letters are stacked top-to-bottom, but not rotated
XF_BORDER_34 Cell Border Style (4 Bytes), BIFF3-BIFF4 Cell borders
contain a line style and a line colour for each line of the border.
Bit Mask Contents
2-0 00000007H Top line style
7-3 000000F8H Colour index for top line colour
10-8 00000700H Left line style
15-11 0000F800H Colour index for left line colour
18-16 00070000H Bottom line style
23-19 00F80000H Colour index for bottom line colour
26-24 07000000H Right line style
31-27 F8000000H Colour index for right line colour
XF_AREA_34 Cell Background Area Style (2 Bytes), BIFF3-BIFF4 A cell
background area style contains an area pattern and a foreground and
background colour.
Bit Mask Contents
5-0 003FH Fill pattern
10-6 07C0H Colour index for pattern colour
15-11 F800H Colour index for pattern background
Record XF, BIFF8:
Offset Size Contents
0 2 Index to FONT record
2 2 Index to FORMAT record
4 2 Bit Mask Contents
2-0 0007H XF_TYPE_PROT . XF type, cell protection (see above)
15-4 FFF0H Index to parent style XF (always FFFH in style XFs)
6 1 Bit Mask Contents
2-0 07H XF_HOR_ALIGN . Horizontal alignment (see above)
3 08H 1 = Text is wrapped at right border
6-4 70H XF_VERT_ALIGN . Vertical alignment (see above)
7 1 XF_ROTATION: Text rotation angle (see above)
8 1 Bit Mask Contents
3-0 0FH Indent level
4 10H 1 = Shrink content to fit into cell
5 merge
7-6 C0H Text direction (BIFF8X only)
00b = According to context
01b = Left-to-right
10b = Right-to-left
9 1 Bit Mask Contents
7-2 FCH XF_USED_ATTRIB . Used attributes (see above)
10 4 Cell border lines and background area:
Bit Mask Contents
3-0 0000000FH Left line style
7-4 000000F0H Right line style
11-8 00000F00H Top line style
15-12 0000F000H Bottom line style
22-16 007F0000H Colour index for left line colour
29-23 3F800000H Colour index for right line colour
30 40000000H 1 = Diagonal line from top left to right bottom
31 80000000H 1 = Diagonal line from bottom left to right top
14 4 Bit Mask Contents
6-0 0000007FH Colour index for top line colour
13-7 00003F80H Colour index for bottom line colour
20-14 001FC000H Colour index for diagonal line colour
24-21 01E00000H Diagonal line style
31-26 FC000000H Fill pattern
18 2 Bit Mask Contents
6-0 007FH Colour index for pattern colour
13-7 3F80H Colour index for pattern background
Constant Summary collapse
- RECORD_ID =
0x00E0
Constants inherited from BiffRecord
BiffRecord::BIFF_LIMIT, BiffRecord::CONTINUE_RECORD_ID
Instance Attribute Summary
Attributes inherited from BiffRecord
Instance Method Summary collapse
-
#initialize(xf, xf_type = 'cell') ⇒ XFRecord
constructor
A new instance of XFRecord.
Methods inherited from BiffRecord
Constructor Details
#initialize(xf, xf_type = 'cell') ⇒ XFRecord
Returns a new instance of XFRecord.
808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 |
# File 'lib/surpass/biff_record.rb', line 808 def initialize(xf, xf_type = 'cell') font_xf_idx, fmt_str_xf_idx, alignment, borders, pattern, protection = xf fnt = [font_xf_idx].pack('v') fmt = [fmt_str_xf_idx].pack('v') if xf_type === 'cell' protection = ((protection.cell_locked & 0x01) << 0) | ((protection.formula_hidden & 0x01) << 1) prt = [protection].pack('v') else prt = [0xFFF5].pack('v') end aln_value = ((alignment.horz & 0x07) << 0) | ((alignment.wrap & 0x01) << 3) | ((alignment.vert & 0x07) << 4) aln = [aln_value].pack('C') rot = [alignment.rota].pack('C') txt_value = ((alignment.inde & 0x0F) << 0) | ((alignment.shri & 0x01) << 4) | ((alignment.merg & 0x01) << 5) | ((alignment.dire & 0x03) << 6) txt = [txt_value].pack('C') used_attr = (xf_type === 'cell') ? [0xF8].pack('C') : [0xF4].pack('C') borders.left_colour = 0x00 if borders.left == Borders::NO_LINE borders.right_colour = 0x00 if borders.right == Borders::NO_LINE borders.top_colour = 0x00 if borders.top == Borders::NO_LINE borders.bottom_colour = 0x00 if borders.bottom == Borders::NO_LINE borders.diag_colour = 0x00 if borders.diag == Borders::NO_LINE brd1_value = ((borders.left & 0x0F) << 0 ) | ((borders.right & 0x0F) << 4 ) | ((borders.top & 0x0F) << 8 ) | ((borders.bottom & 0x0F) << 12) | ((borders.left_colour & 0x7F) << 16) | ((borders.right_colour & 0x7F) << 23) | ((borders.need_diag1 & 0x01) << 30) | ((borders.need_diag2 & 0x01) << 31) brd1 = [brd1_value].pack('V') brd2_value = ((borders.top_colour & 0x7F) << 0 ) | ((borders.bottom_colour & 0x7F) << 7 ) | ((borders.diag_colour & 0x7F) << 14) | ((borders.diag & 0x0F) << 21) | ((pattern.pattern & 0x3F) << 26) brd2 = [brd2_value].pack('V') pat_value = ((pattern.pattern_fore_colour & 0x7F) << 0 ) | ((pattern.pattern_back_colour & 0x7F) << 7 ) pat = [pat_value].pack('v') @record_data = fnt + fmt + prt + aln + rot + txt + used_attr + brd1 + brd2 + pat end |