fpspreadsheet: In TsWorksheetGrid, draw a borderline along frozen panes. Fix black background color appearing when re-saving an fpspreadsheet-created workbook in Excel. Some more extended comments for doc-o-matic.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3224 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
24fac70d0c
commit
897ad1d9d2
@ -33,7 +33,7 @@ begin
|
|||||||
|
|
||||||
// Create the spreadsheet
|
// Create the spreadsheet
|
||||||
MyWorkbook := TsWorkbook.Create;
|
MyWorkbook := TsWorkbook.Create;
|
||||||
MyWorksheet := MyWorkbook.AddWorksheet(Str_Worksheet1);
|
MyWorksheet := MyWorkbook.AddWorksheet(UTF8ToAnsi(Str_Worksheet1));
|
||||||
|
|
||||||
MyWorksheet.Options := MyWorksheet.Options + [soHasFrozenPanes];
|
MyWorksheet.Options := MyWorksheet.Options + [soHasFrozenPanes];
|
||||||
MyWorksheet.LeftPaneWidth := 1;
|
MyWorksheet.LeftPaneWidth := 1;
|
||||||
|
@ -56,6 +56,7 @@ begin
|
|||||||
MyWorksheet.LeftPaneWidth := 20*72*2; // 72 pt = inch --> 2 inches = 5 cm
|
MyWorksheet.LeftPaneWidth := 20*72*2; // 72 pt = inch --> 2 inches = 5 cm
|
||||||
}
|
}
|
||||||
// Write some cells
|
// Write some cells
|
||||||
|
MyWorksheet.WriteNumber(0, 0, 1.0); // A1
|
||||||
MyWorksheet.WriteNumber(0, 1, 2.0); // B1
|
MyWorksheet.WriteNumber(0, 1, 2.0); // B1
|
||||||
MyWorksheet.WriteNumber(0, 2, 3.0); // C1
|
MyWorksheet.WriteNumber(0, 2, 3.0); // C1
|
||||||
MyWorksheet.WriteNumber(0, 3, 4.0); // D1
|
MyWorksheet.WriteNumber(0, 3, 4.0); // D1
|
||||||
|
@ -48,6 +48,9 @@
|
|||||||
</Win32>
|
</Win32>
|
||||||
</Options>
|
</Options>
|
||||||
</Linking>
|
</Linking>
|
||||||
|
<Other>
|
||||||
|
<CompilerPath Value="$(CompPath)"/>
|
||||||
|
</Other>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
</Item2>
|
</Item2>
|
||||||
<Item3 Name="Release">
|
<Item3 Name="Release">
|
||||||
@ -79,6 +82,9 @@
|
|||||||
</Win32>
|
</Win32>
|
||||||
</Options>
|
</Options>
|
||||||
</Linking>
|
</Linking>
|
||||||
|
<Other>
|
||||||
|
<CompilerPath Value="$(CompPath)"/>
|
||||||
|
</Other>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
</Item3>
|
</Item3>
|
||||||
</BuildModes>
|
</BuildModes>
|
||||||
@ -137,6 +143,9 @@
|
|||||||
</Win32>
|
</Win32>
|
||||||
</Options>
|
</Options>
|
||||||
</Linking>
|
</Linking>
|
||||||
|
<Other>
|
||||||
|
<CompilerPath Value="$(CompPath)"/>
|
||||||
|
</Other>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
<Debugging>
|
<Debugging>
|
||||||
<Exceptions Count="5">
|
<Exceptions Count="5">
|
||||||
|
@ -967,10 +967,6 @@ object Form1: TForm1
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object MnuWordwrap: TMenuItem
|
|
||||||
Action = AcWordwrap
|
|
||||||
AutoCheck = True
|
|
||||||
end
|
|
||||||
object MnuNumberFormat: TMenuItem
|
object MnuNumberFormat: TMenuItem
|
||||||
Caption = 'Number format'
|
Caption = 'Number format'
|
||||||
object MenuItem33: TMenuItem
|
object MenuItem33: TMenuItem
|
||||||
@ -1014,6 +1010,9 @@ object Form1: TForm1
|
|||||||
Action = AcNFShortDateTime
|
Action = AcNFShortDateTime
|
||||||
AutoCheck = True
|
AutoCheck = True
|
||||||
end
|
end
|
||||||
|
object MenuItem60: TMenuItem
|
||||||
|
Caption = '-'
|
||||||
|
end
|
||||||
object MenuItem52: TMenuItem
|
object MenuItem52: TMenuItem
|
||||||
Action = AcNFShortDate
|
Action = AcNFShortDate
|
||||||
AutoCheck = True
|
AutoCheck = True
|
||||||
@ -1030,6 +1029,9 @@ object Form1: TForm1
|
|||||||
Action = AcNFCustomMY
|
Action = AcNFCustomMY
|
||||||
AutoCheck = True
|
AutoCheck = True
|
||||||
end
|
end
|
||||||
|
object MenuItem61: TMenuItem
|
||||||
|
Caption = '-'
|
||||||
|
end
|
||||||
object MenuItem56: TMenuItem
|
object MenuItem56: TMenuItem
|
||||||
Action = AcNFShortTime
|
Action = AcNFShortTime
|
||||||
AutoCheck = True
|
AutoCheck = True
|
||||||
@ -1046,6 +1048,17 @@ object Form1: TForm1
|
|||||||
Action = AcNFLongTimeAM
|
Action = AcNFLongTimeAM
|
||||||
AutoCheck = True
|
AutoCheck = True
|
||||||
end
|
end
|
||||||
|
object MenuItem62: TMenuItem
|
||||||
|
Caption = '-'
|
||||||
|
end
|
||||||
|
object MenuItem63: TMenuItem
|
||||||
|
Action = AcNFTimeInterval
|
||||||
|
AutoCheck = True
|
||||||
|
end
|
||||||
|
end
|
||||||
|
object MnuWordwrap: TMenuItem
|
||||||
|
Action = AcWordwrap
|
||||||
|
AutoCheck = True
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -142,6 +142,10 @@ type
|
|||||||
MenuItem57: TMenuItem;
|
MenuItem57: TMenuItem;
|
||||||
MenuItem58: TMenuItem;
|
MenuItem58: TMenuItem;
|
||||||
MenuItem59: TMenuItem;
|
MenuItem59: TMenuItem;
|
||||||
|
MenuItem60: TMenuItem;
|
||||||
|
MenuItem61: TMenuItem;
|
||||||
|
MenuItem62: TMenuItem;
|
||||||
|
MenuItem63: TMenuItem;
|
||||||
MnuFmtDateTimeMSZ: TMenuItem;
|
MnuFmtDateTimeMSZ: TMenuItem;
|
||||||
MnuTimeInterval: TMenuItem;
|
MnuTimeInterval: TMenuItem;
|
||||||
MnuShortTimeAM: TMenuItem;
|
MnuShortTimeAM: TMenuItem;
|
||||||
@ -281,6 +285,8 @@ uses
|
|||||||
fpcanvas, fpsutils, fpsnumformatparser;
|
fpcanvas, fpsutils, fpsnumformatparser;
|
||||||
|
|
||||||
const
|
const
|
||||||
|
DROPDOWN_COUNT = 24;
|
||||||
|
|
||||||
HORALIGN_TAG = 100;
|
HORALIGN_TAG = 100;
|
||||||
VERTALIGN_TAG = 110;
|
VERTALIGN_TAG = 110;
|
||||||
TEXTROT_TAG = 130;
|
TEXTROT_TAG = 130;
|
||||||
@ -305,6 +311,7 @@ const
|
|||||||
TB_INNER_BORDER = $0800;
|
TB_INNER_BORDER = $0800;
|
||||||
// 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.
|
||||||
|
|
||||||
|
|
||||||
{ TForm1 }
|
{ TForm1 }
|
||||||
|
|
||||||
procedure TForm1.AcEditExecute(Sender: TObject);
|
procedure TForm1.AcEditExecute(Sender: TObject);
|
||||||
@ -695,6 +702,8 @@ begin
|
|||||||
FormatToolbar.Height := FontCombobox.Height + 2*FontCombobox.Top;
|
FormatToolbar.Height := FontCombobox.Height + 2*FontCombobox.Top;
|
||||||
FormatToolbar.ButtonHeight := FormatToolbar.Height - 4;
|
FormatToolbar.ButtonHeight := FormatToolbar.Height - 4;
|
||||||
|
|
||||||
|
CbBackgroundCOlor.Height := FontCombobox.Height;
|
||||||
|
|
||||||
// Populate font combobox
|
// Populate font combobox
|
||||||
FontCombobox.Items.Assign(Screen.Fonts);
|
FontCombobox.Items.Assign(Screen.Fonts);
|
||||||
|
|
||||||
@ -714,6 +723,10 @@ begin
|
|||||||
AcBorderOuter.Tag := LEFT_BORDER_THIN + RIGHT_BORDER_THIN + TOP_BORDER_THIN + BOTTOM_BORDER_THIN;
|
AcBorderOuter.Tag := LEFT_BORDER_THIN + RIGHT_BORDER_THIN + TOP_BORDER_THIN + BOTTOM_BORDER_THIN;
|
||||||
AcBorderOuterMedium.Tag := LEFT_BORDER_THICK + RIGHT_BORDER_THICK + TOP_BORDER_THICK + BOTTOM_BORDER_THICK;
|
AcBorderOuterMedium.Tag := LEFT_BORDER_THICK + RIGHT_BORDER_THICK + TOP_BORDER_THICK + BOTTOM_BORDER_THICK;
|
||||||
AcBorderAll.Tag := AcBorderOuter.Tag + AcBorderInner.Tag;
|
AcBorderAll.Tag := AcBorderOuter.Tag + AcBorderInner.Tag;
|
||||||
|
|
||||||
|
FontCombobox.DropDownCount := DROPDOWN_COUNT;
|
||||||
|
FontSizeCombobox.DropDownCount := DROPDOWN_COUNT;
|
||||||
|
CbBackgroundColor.DropDownCount := DROPDOWN_COUNT;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.LoadFile(const AFileName: String);
|
procedure TForm1.LoadFile(const AFileName: String);
|
||||||
|
@ -47,6 +47,9 @@
|
|||||||
</Win32>
|
</Win32>
|
||||||
</Options>
|
</Options>
|
||||||
</Linking>
|
</Linking>
|
||||||
|
<Other>
|
||||||
|
<CompilerPath Value="$(CompPath)"/>
|
||||||
|
</Other>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
</Item2>
|
</Item2>
|
||||||
<Item3 Name="Release">
|
<Item3 Name="Release">
|
||||||
@ -78,6 +81,9 @@
|
|||||||
</Win32>
|
</Win32>
|
||||||
</Options>
|
</Options>
|
||||||
</Linking>
|
</Linking>
|
||||||
|
<Other>
|
||||||
|
<CompilerPath Value="$(CompPath)"/>
|
||||||
|
</Other>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
</Item3>
|
</Item3>
|
||||||
</BuildModes>
|
</BuildModes>
|
||||||
@ -136,6 +142,9 @@
|
|||||||
</Win32>
|
</Win32>
|
||||||
</Options>
|
</Options>
|
||||||
</Linking>
|
</Linking>
|
||||||
|
<Other>
|
||||||
|
<CompilerPath Value="$(CompPath)"/>
|
||||||
|
</Other>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
<Debugging>
|
<Debugging>
|
||||||
<Exceptions Count="5">
|
<Exceptions Count="5">
|
||||||
|
@ -301,6 +301,7 @@ const
|
|||||||
// Will be removed sooner or later...
|
// Will be removed sooner or later...
|
||||||
scRGBColor = $FFFF;
|
scRGBColor = $FFFF;
|
||||||
|
|
||||||
|
scTransparent = $FFFE;
|
||||||
scNotDefined = $FFFF;
|
scNotDefined = $FFFF;
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -2307,12 +2308,33 @@ begin
|
|||||||
ChangedCell(ARow, ACol);
|
ChangedCell(ARow, ACol);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{@@
|
||||||
|
Writes data defined as a string into a cell. Depending on the structure of the
|
||||||
|
string, the worksheet tries to guess whether it is a number, a date/time or
|
||||||
|
a text and calls the corresponding writing method.
|
||||||
|
|
||||||
|
@param ARow Row index of the cell
|
||||||
|
@param ACol Column index of the cell
|
||||||
|
@param AValue Value to be written into the cell given as a string. Depending
|
||||||
|
on the structure of the string, however, the value is written
|
||||||
|
as a number, a date/time or a text.
|
||||||
|
}
|
||||||
procedure TsWorksheet.WriteCellValueAsString(ARow, ACol: Cardinal;
|
procedure TsWorksheet.WriteCellValueAsString(ARow, ACol: Cardinal;
|
||||||
AValue: String);
|
AValue: String);
|
||||||
begin
|
begin
|
||||||
WriteCellValueAsString(GetCell(ARow, ACol), AValue);
|
WriteCellValueAsString(GetCell(ARow, ACol), AValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{@@
|
||||||
|
Writes data defined as a string into a cell. Depending on the structure of the
|
||||||
|
string, the worksheet tries to guess whether it is a number, a date/time or
|
||||||
|
a text and calls the corresponding writing method.
|
||||||
|
|
||||||
|
@param ACell Poiner to the cell
|
||||||
|
@param AValue Value to be written into the cell given as a string. Depending
|
||||||
|
on the structure of the string, however, the value is written
|
||||||
|
as a number, a date/time or a text.
|
||||||
|
}
|
||||||
procedure TsWorksheet.WriteCellValueAsString(ACell: PCell; AValue: String);
|
procedure TsWorksheet.WriteCellValueAsString(ACell: PCell; AValue: String);
|
||||||
var
|
var
|
||||||
isPercent: Boolean;
|
isPercent: Boolean;
|
||||||
@ -2716,12 +2738,18 @@ procedure TsWorksheet.WriteNumberFormat(ACell: PCell;
|
|||||||
begin
|
begin
|
||||||
if ACell = nil then
|
if ACell = nil then
|
||||||
exit;
|
exit;
|
||||||
Include(ACell^.UsedFormattingFields, uffNumberFormat);
|
|
||||||
ACell^.NumberFormat := ANumberFormat;
|
ACell^.NumberFormat := ANumberFormat;
|
||||||
|
if ANumberFormat <> nfGeneral then begin
|
||||||
|
Include(ACell^.UsedFormattingFields, uffNumberFormat);
|
||||||
if (AFormatString = '') then
|
if (AFormatString = '') then
|
||||||
ACell^.NumberFormatStr := BuildNumberFormatString(ANumberFormat, Workbook.FormatSettings)
|
ACell^.NumberFormatStr := BuildNumberFormatString(ANumberFormat, Workbook.FormatSettings)
|
||||||
else
|
else
|
||||||
ACell^.NumberFormatStr := AFormatString;
|
ACell^.NumberFormatStr := AFormatString;
|
||||||
|
end else begin
|
||||||
|
Exclude(ACell^.UsedFormattingFields, uffNumberFormat);
|
||||||
|
ACell^.NumberFormatStr := '';
|
||||||
|
end;
|
||||||
ChangedCell(ACell^.Row, ACell^.Col);
|
ChangedCell(ACell^.Row, ACell^.Col);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2932,7 +2960,8 @@ end;
|
|||||||
@param ARow Row index of the cell
|
@param ARow Row index of the cell
|
||||||
@param ACol Column index of the cell
|
@param ACol Column index of the cell
|
||||||
@param AColor Index of the new background color into the workbook's
|
@param AColor Index of the new background color into the workbook's
|
||||||
color palette.
|
color palette. Use the color index scTransparent to
|
||||||
|
erase an existing background color.
|
||||||
}
|
}
|
||||||
procedure TsWorksheet.WriteBackgroundColor(ARow, ACol: Cardinal;
|
procedure TsWorksheet.WriteBackgroundColor(ARow, ACol: Cardinal;
|
||||||
AColor: TsColor);
|
AColor: TsColor);
|
||||||
@ -2940,8 +2969,12 @@ var
|
|||||||
ACell: PCell;
|
ACell: PCell;
|
||||||
begin
|
begin
|
||||||
ACell := GetCell(ARow, ACol);
|
ACell := GetCell(ARow, ACol);
|
||||||
ACell^.UsedFormattingFields := ACell^.UsedFormattingFields + [uffBackgroundColor];
|
if AColor = scTransparent then
|
||||||
|
Exclude(ACell^.UsedFormattingFields, uffBackgroundColor)
|
||||||
|
else begin
|
||||||
|
Include(ACell^.UsedFormattingFields, uffBackgroundColor);
|
||||||
ACell^.BackgroundColor := AColor;
|
ACell^.BackgroundColor := AColor;
|
||||||
|
end;
|
||||||
ChangedCell(ARow, ACol);
|
ChangedCell(ARow, ACol);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -3086,7 +3119,7 @@ var
|
|||||||
lCell: PCell;
|
lCell: PCell;
|
||||||
begin
|
begin
|
||||||
lCell := GetCell(ARow, ACol);
|
lCell := GetCell(ARow, ACol);
|
||||||
lCell^.UsedFormattingFields := lCell^.UsedFormattingFields + [uffHorAlign];
|
Include(lCell^.UsedFormattingFields, uffHorAlign);
|
||||||
lCell^.HorAlignment := AValue;
|
lCell^.HorAlignment := AValue;
|
||||||
ChangedCell(ARow, ACol);
|
ChangedCell(ARow, ACol);
|
||||||
end;
|
end;
|
||||||
@ -3104,7 +3137,7 @@ var
|
|||||||
lCell: PCell;
|
lCell: PCell;
|
||||||
begin
|
begin
|
||||||
lCell := GetCell(ARow, ACol);
|
lCell := GetCell(ARow, ACol);
|
||||||
lCell^.UsedFormattingFields := lCell^.UsedFormattingFields + [uffVertAlign];
|
Include(lCell^.UsedFormattingFields, uffVertAlign);
|
||||||
lCell^.VertAlignment := AValue;
|
lCell^.VertAlignment := AValue;
|
||||||
ChangedCell(ARow, ACol);
|
ChangedCell(ARow, ACol);
|
||||||
end;
|
end;
|
||||||
|
@ -113,6 +113,7 @@ type
|
|||||||
procedure DrawCellBorders; overload;
|
procedure DrawCellBorders; overload;
|
||||||
procedure DrawCellBorders(ACol, ARow: Integer; ARect: TRect); overload;
|
procedure DrawCellBorders(ACol, ARow: Integer; ARect: TRect); overload;
|
||||||
procedure DrawFocusRect(aCol,aRow:Integer; ARect:TRect); override;
|
procedure DrawFocusRect(aCol,aRow:Integer; ARect:TRect); override;
|
||||||
|
procedure DrawFrozenPaneBorders(ARect: TRect);
|
||||||
procedure DrawSelection;
|
procedure DrawSelection;
|
||||||
procedure DrawTextInCell(ACol, ARow: Integer; ARect: TRect; AState: TGridDrawState); override;
|
procedure DrawTextInCell(ACol, ARow: Integer; ARect: TRect; AState: TGridDrawState); override;
|
||||||
function GetBorderStyle(ACol, ARow, ADeltaCol, ADeltaRow: Integer;
|
function GetBorderStyle(ACol, ARow, ADeltaCol, ADeltaRow: Integer;
|
||||||
@ -478,6 +479,11 @@ end;
|
|||||||
|
|
||||||
{ TsCustomWorksheetGrid }
|
{ TsCustomWorksheetGrid }
|
||||||
|
|
||||||
|
{@@
|
||||||
|
Constructor of the grid. Activates the display of column and row headers
|
||||||
|
and creates an internal "CellFont". Creates a given number of empty rows
|
||||||
|
and columns.
|
||||||
|
}
|
||||||
constructor TsCustomWorksheetGrid.Create(AOwner: TComponent);
|
constructor TsCustomWorksheetGrid.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
@ -487,6 +493,9 @@ begin
|
|||||||
FCellFont := TFont.Create;
|
FCellFont := TFont.Create;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{@@
|
||||||
|
Destructor of the grid: Destroys the workbook and the internal CellFont
|
||||||
|
}
|
||||||
destructor TsCustomWorksheetGrid.Destroy;
|
destructor TsCustomWorksheetGrid.Destroy;
|
||||||
begin
|
begin
|
||||||
FreeAndNil(FWorkbook);
|
FreeAndNil(FWorkbook);
|
||||||
@ -494,15 +503,24 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Suppresses unnecessary repaints. }
|
{@@
|
||||||
|
The BeginUpdate/EndUpdate pair suppresses unnecessary painting of the grid.
|
||||||
|
Call BeginUpdate to stop refreshing the grid, and call EndUpdate to release
|
||||||
|
the lock and to repaint the grid again.
|
||||||
|
}
|
||||||
procedure TsCustomWorksheetGrid.BeginUpdate;
|
procedure TsCustomWorksheetGrid.BeginUpdate;
|
||||||
begin
|
begin
|
||||||
inc(FLockCount);
|
inc(FLockCount);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Converts the column width, given in "characters" of the default font, to pixels
|
{@@
|
||||||
All chars are assumed to have the same width defined by the "0".
|
Converts the column width, given in "characters" of the default font, to pixels
|
||||||
Therefore, this calculation is only approximate. }
|
All chars are assumed to have the same width defined by the width of the
|
||||||
|
"0" character. Therefore, this calculation is only approximate.
|
||||||
|
|
||||||
|
@param AWidth Width of a column given as "character count".
|
||||||
|
@return Column width in pixels.
|
||||||
|
}
|
||||||
function TsCustomWorksheetGrid.CalcColWidth(AWidth: Single): Integer;
|
function TsCustomWorksheetGrid.CalcColWidth(AWidth: Single): Integer;
|
||||||
var
|
var
|
||||||
w0: Integer;
|
w0: Integer;
|
||||||
@ -512,9 +530,14 @@ begin
|
|||||||
Result := Round(AWidth * w0);
|
Result := Round(AWidth * w0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Finds the max cell height per row and uses this to define the RowHeights[].
|
{@@
|
||||||
Returns DefaultRowHeight if the row does not contain any cells.
|
Finds the maximum cell height per row and uses this to define the RowHeights[].
|
||||||
ARow is a grid row index. }
|
Returns DefaultRowHeight if the row does not contain any cells, or if the
|
||||||
|
worksheet does not have a TRow record for this particular row.
|
||||||
|
ARow is a grid row index.
|
||||||
|
|
||||||
|
@param ARow Index of the row, in grid units
|
||||||
|
}
|
||||||
function TsCustomWorksheetGrid.CalcAutoRowHeight(ARow: Integer): Integer;
|
function TsCustomWorksheetGrid.CalcAutoRowHeight(ARow: Integer): Integer;
|
||||||
var
|
var
|
||||||
c: Integer;
|
c: Integer;
|
||||||
@ -529,7 +552,14 @@ begin
|
|||||||
Result := h;
|
Result := h;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Converts the row height (from a worksheet row), given in lines, to pixels }
|
{@@
|
||||||
|
Converts the row height (from a worksheet row record), given in lines, to
|
||||||
|
pixels as needed by the grid
|
||||||
|
|
||||||
|
@param AHeight Row height expressed as default font line count from the
|
||||||
|
worksheet
|
||||||
|
@result Row height in pixels
|
||||||
|
}
|
||||||
function TsCustomWorksheetGrid.CalcRowHeight(AHeight: Single): Integer;
|
function TsCustomWorksheetGrid.CalcRowHeight(AHeight: Single): Integer;
|
||||||
var
|
var
|
||||||
h_pts: Single;
|
h_pts: Single;
|
||||||
@ -538,15 +568,32 @@ begin
|
|||||||
Result := PtsToPX(h_pts, Screen.PixelsPerInch) + 4;
|
Result := PtsToPX(h_pts, Screen.PixelsPerInch) + 4;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{@@
|
||||||
|
Handler for the event OnChangeCell fired by the worksheet when the contents
|
||||||
|
of formatting of a cell has changed.
|
||||||
|
As a consequence, the grid may have to update the cell.
|
||||||
|
Row/Col coordinates are in worksheet units here!
|
||||||
|
|
||||||
|
@param ASender Sender of the event OnChangeFont (the worksheet)
|
||||||
|
@param ARow Row index of the changed cell, in worksheet units!
|
||||||
|
@param ACol Column index of the changed cell, in worksheet units!
|
||||||
|
}
|
||||||
procedure TsCustomWorksheetGrid.ChangedCellHandler(ASender: TObject; ARow, ACol:Cardinal);
|
procedure TsCustomWorksheetGrid.ChangedCellHandler(ASender: TObject; ARow, ACol:Cardinal);
|
||||||
begin
|
begin
|
||||||
Unused(ASender, ARow, ACol);
|
Unused(ASender, ARow, ACol);
|
||||||
if FLockCount = 0 then Invalidate;
|
if FLockCount = 0 then Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Handler for the event that the font has changed in a given cell.
|
{@@
|
||||||
As a consequence, the row height may have to be adapted.
|
Handler for the event OnChangeFont fired by the worksheet when the font has
|
||||||
Row/Col coordinates are in worksheet units here! }
|
changed in a cell.
|
||||||
|
As a consequence, the grid may have to update the row height.
|
||||||
|
Row/Col coordinates are in worksheet units here!
|
||||||
|
|
||||||
|
@param ASender Sender of the event OnChangeFont (the worksheet)
|
||||||
|
@param ARow Row index of the cell with the changed font, in worksheet units!
|
||||||
|
@param ACol Column index of the cell with the changed font, in worksheet units!
|
||||||
|
}
|
||||||
procedure TsCustomWorksheetGrid.ChangedFontHandler(ASender: TObject; ARow, ACol: Cardinal);
|
procedure TsCustomWorksheetGrid.ChangedFontHandler(ASender: TObject; ARow, ACol: Cardinal);
|
||||||
var
|
var
|
||||||
lRow: PRow;
|
lRow: PRow;
|
||||||
@ -564,7 +611,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Converts a spreadsheet font to a font used for painting (TCanvas.Font). }
|
{@@
|
||||||
|
Converts a spreadsheet font to a font used for painting (TCanvas.Font).
|
||||||
|
|
||||||
|
@param sFont Font as used by fpspreadsheet (input)
|
||||||
|
@param AFont Font as used by TCanvas for painting (output)
|
||||||
|
}
|
||||||
procedure TsCustomWorksheetGrid.Convert_sFont_to_Font(sFont: TsFont; AFont: TFont);
|
procedure TsCustomWorksheetGrid.Convert_sFont_to_Font(sFont: TsFont; AFont: TFont);
|
||||||
begin
|
begin
|
||||||
if Assigned(AFont) and Assigned(sFont) then begin
|
if Assigned(AFont) and Assigned(sFont) then begin
|
||||||
@ -579,7 +631,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Converts a font used for painting (TCanvas.Font) to a spreadsheet font }
|
{@@
|
||||||
|
Converts a font used for painting (TCanvas.Font) to a spreadsheet font
|
||||||
|
|
||||||
|
@param AFont Font as used by TCanvas for painting (input)
|
||||||
|
@param sFont Font as used by fpspreadsheet (output)
|
||||||
|
}
|
||||||
procedure TsCustomWorksheetGrid.Convert_Font_to_sFont(AFont: TFont; sFont: TsFont);
|
procedure TsCustomWorksheetGrid.Convert_Font_to_sFont(AFont: TFont; sFont: TsFont);
|
||||||
begin
|
begin
|
||||||
if Assigned(AFont) and Assigned(sFont) then begin
|
if Assigned(AFont) and Assigned(sFont) then begin
|
||||||
@ -594,8 +651,20 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Is overridden to show "frozen" cells in the same style as normal cells.
|
{@@
|
||||||
"Frozen" cells are internally "fixed" cells of the grid. }
|
This is one of the main painting methods inherited from TsCustomGrid. It is
|
||||||
|
overridden here to achieve the feature of "frozen" cells which should be
|
||||||
|
painted in the same style as normal cells.
|
||||||
|
|
||||||
|
Internally, "frozen" cells are "fixed" cells of the grid. Therefore, it is
|
||||||
|
not possible to select any cell within the frozen panes - in contrast to the
|
||||||
|
standard spreadsheet applications.
|
||||||
|
|
||||||
|
@param ACol Column index of the cell being drawn
|
||||||
|
@param ARow Row index of the cell beging drawn
|
||||||
|
@param ARect Rectangle, in grid pixels, covered by the cell
|
||||||
|
@param AState Grid drawing state, as defined by TsCustomGrid
|
||||||
|
}
|
||||||
procedure TsCustomWorksheetGrid.DefaultDrawCell(aCol, aRow: Integer; var aRect: TRect;
|
procedure TsCustomWorksheetGrid.DefaultDrawCell(aCol, aRow: Integer; var aRect: TRect;
|
||||||
AState: TGridDrawState);
|
AState: TGridDrawState);
|
||||||
var
|
var
|
||||||
@ -614,7 +683,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
if wasFixed then begin
|
if wasFixed then begin
|
||||||
wasFixed := true; // ?????
|
|
||||||
AState := AState - [gdFixed];
|
AState := AState - [gdFixed];
|
||||||
Canvas.Brush.Color := clWindow;
|
Canvas.Brush.Color := clWindow;
|
||||||
end;
|
end;
|
||||||
@ -627,8 +695,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Adjusts the grid's canvas before painting a given cell. Considers, e.g.
|
{@@
|
||||||
background color, horizontal alignment, vertical alignment, etc. }
|
Adjusts the grid's canvas before painting a given cell. Considers, e.g.
|
||||||
|
background color, horizontal alignment, vertical alignment, etc.
|
||||||
|
|
||||||
|
@param ACol Column index of the cell being painted
|
||||||
|
@param ARow Row index of the cell being painted
|
||||||
|
@param AState Grid drawing state -- see TsCustomGrid.
|
||||||
|
}
|
||||||
procedure TsCustomWorksheetGrid.DoPrepareCanvas(ACol, ARow: Integer;
|
procedure TsCustomWorksheetGrid.DoPrepareCanvas(ACol, ARow: Integer;
|
||||||
AState: TGridDrawState);
|
AState: TGridDrawState);
|
||||||
var
|
var
|
||||||
@ -711,10 +785,13 @@ begin
|
|||||||
inherited DoPrepareCanvas(ACol, ARow, AState);
|
inherited DoPrepareCanvas(ACol, ARow, AState);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Is overridden in order to paint the cell borders and the selection rectangle.
|
{@@
|
||||||
Both features can extend into the neighbor cells and thus are clipped at the
|
This method is inherited from TsCustomGrid, but is overridden here in order
|
||||||
cell borders by the standard painting mechanism. In DrawAllRows, clipping at
|
to paint the cell borders and the selection rectangle.
|
||||||
cell borders is no longer active. }
|
Both features can extend into the neighbor cells and thus would be clipped
|
||||||
|
at the cell borders by the standard painting mechanism. At the time when
|
||||||
|
DrawAllRows is called, however, clipping at cell borders is no longer active.
|
||||||
|
}
|
||||||
procedure TsCustomWorksheetGrid.DrawAllRows;
|
procedure TsCustomWorksheetGrid.DrawAllRows;
|
||||||
var
|
var
|
||||||
cliprect: TRect;
|
cliprect: TRect;
|
||||||
@ -731,6 +808,9 @@ begin
|
|||||||
ColRowToOffset(True, True, FixedCols-1, tmp, cliprect.Left);
|
ColRowToOffset(True, True, FixedCols-1, tmp, cliprect.Left);
|
||||||
if FixedRows > 0 then
|
if FixedRows > 0 then
|
||||||
ColRowToOffset(False, True, FixedRows-1, tmp, cliprect.Top);
|
ColRowToOffset(False, True, FixedRows-1, tmp, cliprect.Top);
|
||||||
|
|
||||||
|
DrawFrozenPaneBorders(clipRect);
|
||||||
|
|
||||||
rgn := CreateRectRgn(cliprect.Left, cliprect.top, cliprect.Right, cliprect.Bottom);
|
rgn := CreateRectRgn(cliprect.Left, cliprect.top, cliprect.Right, cliprect.Bottom);
|
||||||
SelectClipRgn(Canvas.Handle, Rgn);
|
SelectClipRgn(Canvas.Handle, Rgn);
|
||||||
|
|
||||||
@ -743,7 +823,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Draws the borders of all cells. }
|
{@@
|
||||||
|
Draws the borders of all cells. Calls DrawCellBorder for each individual cell.
|
||||||
|
}
|
||||||
procedure TsCustomWorksheetGrid.DrawCellBorders;
|
procedure TsCustomWorksheetGrid.DrawCellBorders;
|
||||||
var
|
var
|
||||||
cell: PCell;
|
cell: PCell;
|
||||||
@ -764,10 +846,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Draws the border lines around a given cell. Note that when this procedure is
|
{@@
|
||||||
|
Draws the border lines around a given cell. Note that when this procedure is
|
||||||
called the output is clipped by the cell rectangle, but thick and double
|
called the output is clipped by the cell rectangle, but thick and double
|
||||||
border styles extend into the neighbor cell. Therefore, these border lines
|
border styles extend into the neighbor cell. Therefore, these border lines
|
||||||
are drawn in parts. }
|
are drawn in parts.
|
||||||
|
|
||||||
|
@param ACol Column Index
|
||||||
|
@param ARow Row index
|
||||||
|
@param ARect Rectangle in pixels occupied by the cell.
|
||||||
|
}
|
||||||
procedure TsCustomWorksheetGrid.DrawCellBorders(ACol, ARow: Integer; ARect: TRect);
|
procedure TsCustomWorksheetGrid.DrawCellBorders(ACol, ARow: Integer; ARect: TRect);
|
||||||
|
|
||||||
procedure DrawBorderLine(ACoord: Integer; ARect: TRect; IsHor: Boolean;
|
procedure DrawBorderLine(ACoord: Integer; ARect: TRect; IsHor: Boolean;
|
||||||
@ -858,7 +946,29 @@ begin
|
|||||||
// Nothing do to
|
// Nothing do to
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Draws the selection rectangle, 3 pixels wide as in Excel. }
|
{@@
|
||||||
|
Draws a solid line along the borders of frozen panes.
|
||||||
|
|
||||||
|
@param ARect This rectangle indicates the area with movable cells. If the
|
||||||
|
grid has frozen panes a black line is drawn along the upper
|
||||||
|
and/or left edge of this rectangle.
|
||||||
|
}
|
||||||
|
procedure TsCustomWorksheetGrid.DrawFrozenPaneBorders(ARect: TRect);
|
||||||
|
begin
|
||||||
|
if (soHasFrozenPanes in FWorksheet.Options) then begin
|
||||||
|
Canvas.Pen.Style := psSolid;
|
||||||
|
Canvas.Pen.Color := clBlack;
|
||||||
|
Canvas.Pen.Width := 1;
|
||||||
|
if FFrozenRows > 0 then
|
||||||
|
Canvas.Line(ARect.Left, ARect.Top, ARect.Right, ARect.Top);
|
||||||
|
if FFrozenCols > 0 then
|
||||||
|
Canvas.Line(ARect.Left, ARect.Top, ARect.Left, ARect.Bottom);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{@@
|
||||||
|
Draws the selection rectangle, 3 pixels wide as in Excel.
|
||||||
|
}
|
||||||
procedure TsCustomWorksheetGrid.DrawSelection;
|
procedure TsCustomWorksheetGrid.DrawSelection;
|
||||||
var
|
var
|
||||||
P1, P2: TPoint;
|
P1, P2: TPoint;
|
||||||
@ -884,9 +994,16 @@ begin
|
|||||||
Canvas.Rectangle(P1.X, P1.Y, P2.X, P2.Y);
|
Canvas.Rectangle(P1.X, P1.Y, P2.X, P2.Y);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Draws the cell text. Calls "GetCellText" to determine the text in the cell.
|
{@@
|
||||||
|
Draws the cell text. Calls "GetCellText" to determine the text in the cell.
|
||||||
Takes care of horizontal and vertical text alignment, text rotation and
|
Takes care of horizontal and vertical text alignment, text rotation and
|
||||||
text wrapping }
|
text wrapping
|
||||||
|
|
||||||
|
@param ACol Column index of the cell
|
||||||
|
@param ARow Row index of the cell
|
||||||
|
@param ARect Rectangle in pixels occupied by the cell.
|
||||||
|
@param AState Drawing state of the grid -- see TCustomGrid
|
||||||
|
}
|
||||||
procedure TsCustomWorksheetGrid.DrawTextInCell(ACol, ARow: Integer; ARect: TRect;
|
procedure TsCustomWorksheetGrid.DrawTextInCell(ACol, ARow: Integer; ARect: TRect;
|
||||||
AState: TGridDrawState);
|
AState: TGridDrawState);
|
||||||
var
|
var
|
||||||
@ -970,6 +1087,12 @@ begin
|
|||||||
txtRot, wrapped, false);
|
txtRot, wrapped, false);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{@@
|
||||||
|
Is called when editing of a cell is completed. Determines the worksheet cell
|
||||||
|
and writes the text into the worksheet. Tries to keep the format of the cell,
|
||||||
|
but if it is a new cell, or the content type has changed, tries to figure out
|
||||||
|
the content type (number, date/time, text).
|
||||||
|
}
|
||||||
procedure TsCustomWorksheetGrid.EditingDone;
|
procedure TsCustomWorksheetGrid.EditingDone;
|
||||||
var
|
var
|
||||||
oldText: String;
|
oldText: String;
|
||||||
@ -989,14 +1112,24 @@ begin
|
|||||||
FEditing := false;
|
FEditing := false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{@@
|
||||||
|
The BeginUpdate/EndUpdate pair suppresses unnecessary painting of the grid.
|
||||||
|
Call BeginUpdate to stop refreshing the grid, and call EndUpdate to release
|
||||||
|
the lock and to repaint the grid again.
|
||||||
|
}
|
||||||
procedure TsCustomWorksheetGrid.EndUpdate;
|
procedure TsCustomWorksheetGrid.EndUpdate;
|
||||||
begin
|
begin
|
||||||
dec(FLockCount);
|
dec(FLockCount);
|
||||||
if FLockCount = 0 then Invalidate;
|
if FLockCount = 0 then Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Copies the borders of a cell to its neighbors. This avoids the nightmare of
|
{@@
|
||||||
changing borders due to border conflicts of adjacent cells. }
|
Copies the borders of a cell to its neighbors. This avoids the nightmare of
|
||||||
|
changing borders due to border conflicts of adjacent cells.
|
||||||
|
|
||||||
|
@param ACol Column index of the cell
|
||||||
|
@param ARow Row index of the cell
|
||||||
|
}
|
||||||
procedure TsCustomWorksheetGrid.FixNeighborCellBorders(ACol, ARow: Integer);
|
procedure TsCustomWorksheetGrid.FixNeighborCellBorders(ACol, ARow: Integer);
|
||||||
|
|
||||||
procedure SetNeighborBorder(NewRow, NewCol: Integer;
|
procedure SetNeighborBorder(NewRow, NewCol: Integer;
|
||||||
@ -1032,10 +1165,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ The "colors" used by the spreadsheet are indexes into the workbook's color
|
{@@
|
||||||
|
The "colors" used by the spreadsheet are indexes into the workbook's color
|
||||||
palette. If the user wants to set a color to a particular rgb value this is
|
palette. If the user wants to set a color to a particular rgb value this is
|
||||||
not possible in general. The method FindNearestPaletteIndex finds the bast
|
not possible in general. The method FindNearestPaletteIndex finds the bast
|
||||||
matching color in the palette. }
|
matching color in the palette.
|
||||||
|
|
||||||
|
@param AColor Color index into the workbook's palette
|
||||||
|
}
|
||||||
function TsCustomWorksheetGrid.FindNearestPaletteIndex(AColor: TColor): TsColor;
|
function TsCustomWorksheetGrid.FindNearestPaletteIndex(AColor: TColor): TsColor;
|
||||||
|
|
||||||
procedure ColorToHSL(RGB: TColor; out H, S, L : double);
|
procedure ColorToHSL(RGB: TColor; out H, S, L : double);
|
||||||
@ -1121,6 +1258,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{@@
|
||||||
|
Returns the background color of a cell. The color is given as an index into
|
||||||
|
the workbook's color palette.
|
||||||
|
|
||||||
|
@param ACol Column index of the cell
|
||||||
|
@param ARow Row index of the cell
|
||||||
|
@result Color index of the cell's background color.
|
||||||
|
}
|
||||||
function TsCustomWorksheetGrid.GetBackgroundColor(ACol, ARow: Integer): TsColor;
|
function TsCustomWorksheetGrid.GetBackgroundColor(ACol, ARow: Integer): TsColor;
|
||||||
var
|
var
|
||||||
cell: PCell;
|
cell: PCell;
|
||||||
@ -1133,6 +1278,17 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{@@
|
||||||
|
Returns the background color of a cell range defined by a rectangle. The color
|
||||||
|
is given as an index into the workbook's color palette. If the colors are
|
||||||
|
different from cell to cell the value scUndefined is returned.
|
||||||
|
|
||||||
|
@param ARect Cell range defined as a rectangle: Left/Top refers to the cell
|
||||||
|
in the left/top corner of the selection, Right/Bottom to the
|
||||||
|
right/bottom corner.
|
||||||
|
@return Color index common to all cells within the selection. If the cells'
|
||||||
|
background colors are different the value scUndefined is returned.
|
||||||
|
}
|
||||||
function TsCustomWorksheetGrid.GetBackgroundColors(ARect: TGridRect): TsColor;
|
function TsCustomWorksheetGrid.GetBackgroundColors(ARect: TGridRect): TsColor;
|
||||||
var
|
var
|
||||||
c, r: Integer;
|
c, r: Integer;
|
||||||
@ -1150,6 +1306,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{@@
|
||||||
|
Returns the cell borders which are drawn around a given cell.
|
||||||
|
|
||||||
|
@param ACol Column index of the cell
|
||||||
|
@param ARow Row index of the cell
|
||||||
|
@return Set with flags indicating where borders are drawn (top/left/right/bottom)
|
||||||
|
}
|
||||||
function TsCustomWorksheetGrid.GetCellBorder(ACol, ARow: Integer): TsCellBorders;
|
function TsCustomWorksheetGrid.GetCellBorder(ACol, ARow: Integer): TsCellBorders;
|
||||||
var
|
var
|
||||||
cell: PCell;
|
cell: PCell;
|
||||||
@ -1162,6 +1325,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{@@
|
||||||
|
Returns the cell borders which are drawn around a given rectangular cell range.
|
||||||
|
|
||||||
|
@param ARect Rectangle defining the range of cell.
|
||||||
|
@return Set with flags indicating where borders are drawn (top/left/right/bottom)
|
||||||
|
If the individual cells within the range have different borders an
|
||||||
|
empty set is returned.
|
||||||
|
}
|
||||||
function TsCustomWorksheetGrid.GetCellBorders(ARect: TGridRect): TsCellBorders;
|
function TsCustomWorksheetGrid.GetCellBorders(ARect: TGridRect): TsCellBorders;
|
||||||
var
|
var
|
||||||
c, r: Integer;
|
c, r: Integer;
|
||||||
|
@ -803,9 +803,9 @@ begin
|
|||||||
|
|
||||||
// Background color not supported, only shaded background
|
// Background color not supported, only shaded background
|
||||||
if xf.HorAlign_Border_Background and $80 <> 0 then
|
if xf.HorAlign_Border_Background and $80 <> 0 then
|
||||||
lData.BackgroundColor := 1 // shaded background = "true"
|
lData.BackgroundColor := 1 // encodes "shaded background = true"
|
||||||
else
|
else
|
||||||
ldata.BackgroundColor := 0; // shaded background = "false"
|
ldata.BackgroundColor := 0; // encodes "shaded background = false"
|
||||||
|
|
||||||
// Add the decoded data to the list
|
// Add the decoded data to the list
|
||||||
FXFList.Add(lData);
|
FXFList.Add(lData);
|
||||||
|
@ -382,7 +382,8 @@ begin
|
|||||||
begin
|
begin
|
||||||
len := Length(Boundsheets);
|
len := Length(Boundsheets);
|
||||||
SetLength(Boundsheets, len + 1);
|
SetLength(Boundsheets, len + 1);
|
||||||
Boundsheets[len] := WriteBoundsheet(AStream, Workbook.GetWorksheetByIndex(i).Name);
|
Boundsheets[len] := WriteBoundsheet(AStream, UTF8ToAnsi(Workbook.GetWorksheetByIndex(i).Name));
|
||||||
|
// BIFF8 does not support unicode --> Need UTF8ToAnsi !
|
||||||
end;
|
end;
|
||||||
|
|
||||||
WriteEOF(AStream);
|
WriteEOF(AStream);
|
||||||
@ -1419,6 +1420,7 @@ var
|
|||||||
xf: TXFRecord;
|
xf: TXFRecord;
|
||||||
b: Byte;
|
b: Byte;
|
||||||
dw: DWord;
|
dw: DWord;
|
||||||
|
fill: Word;
|
||||||
begin
|
begin
|
||||||
AStream.ReadBuffer(xf, SizeOf(xf));
|
AStream.ReadBuffer(xf, SizeOf(xf));
|
||||||
|
|
||||||
@ -1489,8 +1491,14 @@ begin
|
|||||||
lData.BorderStyles[cbNorth].Color := (xf.Border_Background_2 and MASK_XF_BORDER_TOP_COLOR) shr 9;
|
lData.BorderStyles[cbNorth].Color := (xf.Border_Background_2 and MASK_XF_BORDER_TOP_COLOR) shr 9;
|
||||||
lData.BorderStyles[cbSouth].Color := (xf.Border_Background_1 and MASK_XF_BORDER_BOTTOM_COLOR) shr 25;
|
lData.BorderStyles[cbSouth].Color := (xf.Border_Background_1 and MASK_XF_BORDER_BOTTOM_COLOR) shr 25;
|
||||||
|
|
||||||
|
// Background fill style
|
||||||
|
fill := (xf.Border_Background_1 and MASK_XF_BKGR_FILLPATTERN) shr 16;
|
||||||
|
|
||||||
// Background color
|
// Background color
|
||||||
lData.BackgroundColor := xf.Border_Background_1 AND MASK_XF_BKGR_PATTERN_COLOR;
|
if fill = 0 then
|
||||||
|
lData.BackgroundColor := scTransparent
|
||||||
|
else
|
||||||
|
lData.BackgroundColor := xf.Border_Background_1 and MASK_XF_BKGR_PATTERN_COLOR;
|
||||||
|
|
||||||
// Add the XF to the list
|
// Add the XF to the list
|
||||||
FXFList.Add(lData);
|
FXFList.Add(lData);
|
||||||
|
@ -266,6 +266,9 @@ const
|
|||||||
MASK_XF_BORDER_TOP_COLOR = $0000007F;
|
MASK_XF_BORDER_TOP_COLOR = $0000007F;
|
||||||
MASK_XF_BORDER_BOTTOM_COLOR = $00003F80;
|
MASK_XF_BORDER_BOTTOM_COLOR = $00003F80;
|
||||||
|
|
||||||
|
{ XF CELL BACKGROUND PATTERN }
|
||||||
|
MASK_XF_BACKGROUND_PATTERN = $FC000000;
|
||||||
|
|
||||||
TEXT_ROTATIONS: Array[TsTextRotation] of Byte = (
|
TEXT_ROTATIONS: Array[TsTextRotation] of Byte = (
|
||||||
XF_ROTATION_HORIZONTAL,
|
XF_ROTATION_HORIZONTAL,
|
||||||
XF_ROTATION_90DEG_CW,
|
XF_ROTATION_90DEG_CW,
|
||||||
@ -1833,6 +1836,7 @@ var
|
|||||||
xf: TXFRecord;
|
xf: TXFRecord;
|
||||||
b: Byte;
|
b: Byte;
|
||||||
dw: DWord;
|
dw: DWord;
|
||||||
|
fill: Integer;
|
||||||
begin
|
begin
|
||||||
AStream.ReadBuffer(xf, SizeOf(xf));
|
AStream.ReadBuffer(xf, SizeOf(xf));
|
||||||
|
|
||||||
@ -1902,9 +1906,15 @@ begin
|
|||||||
lData.BorderStyles[cbNorth].Color := (xf.Border_Background_2 and MASK_XF_BORDER_TOP_COLOR);
|
lData.BorderStyles[cbNorth].Color := (xf.Border_Background_2 and MASK_XF_BORDER_TOP_COLOR);
|
||||||
lData.BorderStyles[cbSouth].Color := (xf.Border_Background_2 and MASK_XF_BORDER_BOTTOM_COLOR) shr 7;
|
lData.BorderStyles[cbSouth].Color := (xf.Border_Background_2 and MASK_XF_BORDER_BOTTOM_COLOR) shr 7;
|
||||||
|
|
||||||
// Background color;
|
// Background fill pattern
|
||||||
|
fill := (xf.Border_Background_2 and MASK_XF_BACKGROUND_PATTERN) shr 26;
|
||||||
|
|
||||||
|
// Background color
|
||||||
xf.Border_Background_3 := DWordLEToN(xf.Border_Background_3);
|
xf.Border_Background_3 := DWordLEToN(xf.Border_Background_3);
|
||||||
lData.BackgroundColor := xf.Border_Background_3 AND $007F;
|
if fill <> 0 then
|
||||||
|
lData.BackgroundColor := xf.Border_Background_3 and $007F
|
||||||
|
else
|
||||||
|
lData.BackgroundColor := scTransparent; // this means "no fill"
|
||||||
|
|
||||||
// Add the XF to the list
|
// Add the XF to the list
|
||||||
FXFList.Add(lData);
|
FXFList.Add(lData);
|
||||||
|
@ -840,10 +840,11 @@ begin
|
|||||||
Exclude(lCell^.UsedFormattingFields, uffBorder);
|
Exclude(lCell^.UsedFormattingFields, uffBorder);
|
||||||
|
|
||||||
// Background color
|
// Background color
|
||||||
if XFData.BackgroundColor <> 0 then begin
|
if XFData.BackgroundColor <> scTransparent then begin
|
||||||
Include(lCell^.UsedFormattingFields, uffBackgroundColor);
|
Include(lCell^.UsedFormattingFields, uffBackgroundColor);
|
||||||
lCell^.BackgroundColor := XFData.BackgroundColor;
|
lCell^.BackgroundColor := XFData.BackgroundColor;
|
||||||
end;
|
end else
|
||||||
|
Exclude(lCell^.UsedFormattingFields, uffBackgroundColor);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user