fpspreadsheet: Show info on Merge cell option in XF record by BIFF explorer. Trying to improve with of color box in spready.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3555 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2014-09-12 15:16:46 +00:00
parent b70cc35da3
commit 02a3b17e6e
5 changed files with 52 additions and 59 deletions

View File

@ -4,7 +4,7 @@ object MainFrm: TMainFrm
Top = 258 Top = 258
Width = 884 Width = 884
Caption = 'spready' Caption = 'spready'
ClientHeight = 619 ClientHeight = 614
ClientWidth = 884 ClientWidth = 884
Menu = MainMenu Menu = MainMenu
OnActivate = FormActivate OnActivate = FormActivate
@ -14,7 +14,7 @@ object MainFrm: TMainFrm
object Panel1: TPanel object Panel1: TPanel
Left = 0 Left = 0
Height = 78 Height = 78
Top = 541 Top = 536
Width = 884 Width = 884
Align = alBottom Align = alBottom
BevelOuter = bvNone BevelOuter = bvNone
@ -23,9 +23,9 @@ object MainFrm: TMainFrm
TabOrder = 6 TabOrder = 6
object CbShowHeaders: TCheckBox object CbShowHeaders: TCheckBox
Left = 8 Left = 8
Height = 19 Height = 24
Top = 8 Top = 8
Width = 93 Width = 116
Caption = 'Show headers' Caption = 'Show headers'
Checked = True Checked = True
OnClick = CbShowHeadersClick OnClick = CbShowHeadersClick
@ -34,9 +34,9 @@ object MainFrm: TMainFrm
end end
object CbShowGridLines: TCheckBox object CbShowGridLines: TCheckBox
Left = 8 Left = 8
Height = 19 Height = 24
Top = 39 Top = 39
Width = 100 Width = 125
Caption = 'Show grid lines' Caption = 'Show grid lines'
Checked = True Checked = True
OnClick = CbShowGridLinesClick OnClick = CbShowGridLinesClick
@ -45,7 +45,7 @@ object MainFrm: TMainFrm
end end
object EdFrozenCols: TSpinEdit object EdFrozenCols: TSpinEdit
Left = 645 Left = 645
Height = 23 Height = 28
Top = 8 Top = 8
Width = 52 Width = 52
OnChange = EdFrozenColsChange OnChange = EdFrozenColsChange
@ -53,7 +53,7 @@ object MainFrm: TMainFrm
end end
object EdFrozenRows: TSpinEdit object EdFrozenRows: TSpinEdit
Left = 645 Left = 645
Height = 23 Height = 28
Top = 39 Top = 39
Width = 52 Width = 52
OnChange = EdFrozenRowsChange OnChange = EdFrozenRowsChange
@ -61,37 +61,37 @@ object MainFrm: TMainFrm
end end
object Label1: TLabel object Label1: TLabel
Left = 560 Left = 560
Height = 15 Height = 20
Top = 13 Top = 13
Width = 62 Width = 77
Caption = 'Frozen cols:' Caption = 'Frozen cols:'
FocusControl = EdFrozenCols FocusControl = EdFrozenCols
ParentColor = False ParentColor = False
end end
object Label2: TLabel object Label2: TLabel
Left = 560 Left = 560
Height = 15 Height = 20
Top = 40 Top = 40
Width = 66 Width = 82
Caption = 'Frozen rows:' Caption = 'Frozen rows:'
FocusControl = EdFrozenRows FocusControl = EdFrozenRows
ParentColor = False ParentColor = False
end end
object CbReadFormulas: TCheckBox object CbReadFormulas: TCheckBox
Left = 160 Left = 160
Height = 19 Height = 24
Top = 8 Top = 8
Width = 96 Width = 120
Caption = 'Read formulas' Caption = 'Read formulas'
OnChange = CbReadFormulasChange OnChange = CbReadFormulasChange
TabOrder = 2 TabOrder = 2
end end
object CbHeaderStyle: TComboBox object CbHeaderStyle: TComboBox
Left = 408 Left = 408
Height = 23 Height = 28
Top = 8 Top = 8
Width = 116 Width = 116
ItemHeight = 15 ItemHeight = 20
ItemIndex = 2 ItemIndex = 2
Items.Strings = ( Items.Strings = (
'Lazarus' 'Lazarus'
@ -105,9 +105,9 @@ object MainFrm: TMainFrm
end end
object CbAutoCalcFormulas: TCheckBox object CbAutoCalcFormulas: TCheckBox
Left = 160 Left = 160
Height = 19 Height = 24
Top = 39 Top = 39
Width = 128 Width = 158
Caption = 'Calculate on change' Caption = 'Calculate on change'
OnChange = CbAutoCalcFormulasChange OnChange = CbAutoCalcFormulasChange
TabOrder = 3 TabOrder = 3
@ -200,19 +200,19 @@ object MainFrm: TMainFrm
end end
object FontComboBox: TComboBox object FontComboBox: TComboBox
Left = 52 Left = 52
Height = 23 Height = 28
Top = 2 Top = 2
Width = 127 Width = 127
ItemHeight = 15 ItemHeight = 20
OnSelect = FontComboBoxSelect OnSelect = FontComboBoxSelect
TabOrder = 0 TabOrder = 0
end end
object FontSizeComboBox: TComboBox object FontSizeComboBox: TComboBox
Left = 179 Left = 179
Height = 23 Height = 28
Top = 2 Top = 2
Width = 48 Width = 48
ItemHeight = 15 ItemHeight = 20
Items.Strings = ( Items.Strings = (
'8' '8'
'9' '9'
@ -301,7 +301,6 @@ object MainFrm: TMainFrm
Height = 26 Height = 26
Top = 2 Top = 2
Width = 149 Width = 149
ColorRectWidth = 8
NoneColorColor = clDefault NoneColorColor = clDefault
Style = [cbPrettyNames, cbCustomColors] Style = [cbPrettyNames, cbCustomColors]
OnGetColors = CbBackgroundColorGetColors OnGetColors = CbBackgroundColorGetColors
@ -382,7 +381,7 @@ object MainFrm: TMainFrm
end end
object InspectorSplitter: TSplitter object InspectorSplitter: TSplitter
Left = 648 Left = 648
Height = 462 Height = 457
Top = 79 Top = 79
Width = 5 Width = 5
Align = alRight Align = alRight
@ -390,7 +389,7 @@ object MainFrm: TMainFrm
end end
object InspectorPageControl: TPageControl object InspectorPageControl: TPageControl
Left = 653 Left = 653
Height = 462 Height = 457
Top = 79 Top = 79
Width = 231 Width = 231
ActivePage = PgCellValue ActivePage = PgCellValue
@ -400,11 +399,11 @@ object MainFrm: TMainFrm
OnChange = InspectorPageControlChange OnChange = InspectorPageControlChange
object PgCellValue: TTabSheet object PgCellValue: TTabSheet
Caption = 'Cell value' Caption = 'Cell value'
ClientHeight = 434 ClientHeight = 424
ClientWidth = 223 ClientWidth = 223
object CellInspector: TValueListEditor object CellInspector: TValueListEditor
Left = 0 Left = 0
Height = 434 Height = 424
Top = 0 Top = 0
Width = 223 Width = 223
Align = alClient Align = alClient
@ -445,7 +444,7 @@ object MainFrm: TMainFrm
end end
object TabControl: TTabControl object TabControl: TTabControl
Left = 0 Left = 0
Height = 462 Height = 457
Top = 79 Top = 79
Width = 648 Width = 648
OnChange = TabControlChange OnChange = TabControlChange
@ -453,7 +452,7 @@ object MainFrm: TMainFrm
TabOrder = 3 TabOrder = 3
object WorksheetGrid: TsWorksheetGrid object WorksheetGrid: TsWorksheetGrid
Left = 2 Left = 2
Height = 457 Height = 452
Top = 3 Top = 3
Width = 644 Width = 644
FrozenCols = 0 FrozenCols = 0
@ -470,7 +469,7 @@ object MainFrm: TMainFrm
TitleStyle = tsNative TitleStyle = tsNative
OnSelection = WorksheetGridSelection OnSelection = WorksheetGridSelection
ColWidths = ( ColWidths = (
42 56
64 64
64 64
64 64

View File

@ -322,10 +322,10 @@ uses
const const
DROPDOWN_COUNT = 24; DROPDOWN_COUNT = 24;
HORALIGN_TAG = 100; HORALIGN_TAG = 100;
VERTALIGN_TAG = 110; VERTALIGN_TAG = 110;
TEXTROT_TAG = 130; TEXTROT_TAG = 130;
NUMFMT_TAG = 1000; // differnce 10 per format item NUMFMT_TAG = 1000; // difference 10 per format item
LEFT_BORDER_THIN = $0001; LEFT_BORDER_THIN = $0001;
LEFT_BORDER_THICK = $0002; LEFT_BORDER_THICK = $0002;
@ -347,19 +347,6 @@ const
// Use a combination of these bits for the "Tag" of the Border actions - see FormCreate. // Use a combination of these bits for the "Tag" of the Border actions - see FormCreate.
{ Utilities }
{ Determines the "real" size of font. Default font usually reports font size 0...
http://comments.gmane.org/gmane.comp.ide.lazarus.general/70758 }
function RealFontSize(AFont: TFont): Integer;
var
logFont: TLogFont;
begin
LCLIntf.GetObject(AFont.Reference.Handle, SizeOf(TLogFont), @logFont);
Result := abs(logFont.lfHeight);
end;
{ TMainFrm } { TMainFrm }
procedure TMainFrm.AcEditExecute(Sender: TObject); procedure TMainFrm.AcEditExecute(Sender: TObject);
@ -821,7 +808,7 @@ begin
FormatToolbar.ButtonHeight := FormatToolbar.Height - 4; FormatToolbar.ButtonHeight := FormatToolbar.Height - 4;
CbBackgroundColor.ItemHeight := FontCombobox.ItemHeight; CbBackgroundColor.ItemHeight := FontCombobox.ItemHeight;
//CbBackgroundColor.ColorRectWidth := RealFontSize(CbBackgroundColor.Font); CbBackgroundColor.ColorRectWidth := round(screen.PixelsPerInch/120*CbBackgroundColor.ColorRectWidth);
// Populate font combobox // Populate font combobox
FontCombobox.Items.Assign(Screen.Fonts); FontCombobox.Items.Assign(Screen.Fonts);

View File

@ -3327,9 +3327,7 @@ procedure TsCustomWorksheetGrid.UnmergeCells;
begin begin
FWorksheet.UnmergeCells( FWorksheet.UnmergeCells(
GetWorksheetRow(Selection.Top), GetWorksheetRow(Selection.Top),
GetWorksheetCol(Selection.Left), GetWorksheetCol(Selection.Left)
GetWorksheetRow(Selection.Bottom),
GetWorksheetCol(Selection.Right)
); );
end; end;

View File

@ -4714,6 +4714,9 @@ begin
if b and $10 = 0 if b and $10 = 0
then FDetails.Add('Bit $10 = 0: Don''t shrink content to fit into cell') then FDetails.Add('Bit $10 = 0: Don''t shrink content to fit into cell')
else FDetails.Add('Bit $10 = 1: Shrink content to fit into cell'); else FDetails.Add('Bit $10 = 1: Shrink content to fit into cell');
if b and $20 = 0
then FDetails.Add('Bit $20 = 0: Merge Cell option is OFF')
else FDetails.Add('Bit $20 = 1: Merge Cell option is ON');
case (b and $C0) shr 6 of case (b and $C0) shr 6 of
0: FDetails.Add('Bits 6-7 = 0: Text direction according to context'); 0: FDetails.Add('Bits 6-7 = 0: Text direction according to context');
1: FDetails.Add('Bits 6-7 = 1: Text direction left-to-right'); 1: FDetails.Add('Bits 6-7 = 1: Text direction left-to-right');

View File

@ -1129,7 +1129,7 @@ procedure TsSpreadBIFF8Writer.WriteXF(AStream: TStream; AFontIndex: Word;
AddBackground: Boolean = false; ABackgroundColor: TsColor = scSilver); AddBackground: Boolean = false; ABackgroundColor: TsColor = scSilver);
var var
XFOptions: Word; XFOptions: Word;
XFAlignment, XFOrientationAttrib: Byte; XFAlignment, XFIndentShrinkMerge, XFOrientationAttrib: Byte;
XFBorderDWord1, XFBorderDWord2: DWord; XFBorderDWord1, XFBorderDWord2: DWord;
begin begin
{ BIFF Record header } { BIFF Record header }
@ -1137,10 +1137,10 @@ begin
AStream.WriteWord(WordToLE(20)); AStream.WriteWord(WordToLE(20));
{ Index to FONT record } { Index to FONT record }
AStream.WriteWord(WordToLE(AFontIndex)); AStream.WriteWord(WordToLE(AFontIndex)); // Offset 4
{ Index to FORMAT record } { Index to FORMAT record }
AStream.WriteWord(WordToLE(AFormatIndex)); AStream.WriteWord(WordToLE(AFormatIndex)); // Offset 6
{ XF type, cell protection and parent style XF } { XF type, cell protection and parent style XF }
XFOptions := AXF_TYPE_PROT and MASK_XF_TYPE_PROT; XFOptions := AXF_TYPE_PROT and MASK_XF_TYPE_PROT;
@ -1148,7 +1148,7 @@ begin
if AXF_TYPE_PROT and MASK_XF_TYPE_PROT_STYLE_XF <> 0 then if AXF_TYPE_PROT and MASK_XF_TYPE_PROT_STYLE_XF <> 0 then
XFOptions := XFOptions or MASK_XF_TYPE_PROT_PARENT; XFOptions := XFOptions or MASK_XF_TYPE_PROT_PARENT;
AStream.WriteWord(WordToLE(XFOptions)); AStream.WriteWord(WordToLE(XFOptions)); // Offset 8
{ Alignment and text break } { Alignment and text break }
XFAlignment := 0; XFAlignment := 0;
@ -1166,13 +1166,19 @@ begin
if AWordWrap then if AWordWrap then
XFAlignment := XFAlignment or MASK_XF_TEXTWRAP; XFAlignment := XFAlignment or MASK_XF_TEXTWRAP;
AStream.WriteByte(XFAlignment); AStream.WriteByte(XFAlignment); // Offset 10
{ Text rotation } { Text rotation }
AStream.WriteByte(ATextRotation); // 0 is horizontal / normal AStream.WriteByte(ATextRotation); // 0 is horizontal / normal // Offset 11
{ Indentation, shrink and text direction } { Indentation, shrink, merge and text direction:
AStream.WriteByte(0); see "Excel97-2007BinaryFileFormat(xls)Specification.pdf", p281 ff
Bits 0-3: Indent value
Bit 4: Shrink to fit
Bit 5: MergeCell
Bits 6-7: Reading direction }
XFIndentShrinkMerge := 0;
AStream.WriteByte(XFIndentShrinkMerge); // Offset 12
{ Used attributes } { Used attributes }
XFOrientationAttrib := XFOrientationAttrib :=