fpspreadsheet: Fix TsWorksheetGrid showing frozen cells with black border if TitleStyle is not tsNative. Fix TsSpreadsheetInspector and spready demo crashing due to ignoring the cell content type.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3908 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2015-01-29 12:39:52 +00:00
parent f4bf29da87
commit 0ecf404c0a
3 changed files with 39 additions and 17 deletions

View File

@ -781,10 +781,9 @@ end;
procedure TMainFrm.AcSortColAscExecute(Sender: TObject);
var
c, r: Cardinal;
c: Cardinal;
sortParams: TsSortParams;
begin
r := WorksheetGrid.GetWorksheetRow(WorksheetGrid.Row);
c := WorksheetGrid.GetWorksheetCol(WorksheetGrid.Col);
sortParams := InitSortParams;
WorksheetGrid.BeginUpdate;
@ -1138,19 +1137,19 @@ begin
if ACell=nil
then Strings.Add('ContentType=')
else Strings.Add(Format('ContentType=%s', [GetEnumName(TypeInfo(TCellContentType), ord(ACell^.ContentType))]));
if ACell=nil
if (ACell=nil) or (ACell^.ContentType <> cctNumber)
then Strings.Add('NumberValue=')
else Strings.Add(Format('NumberValue=%g', [ACell^.NumberValue]));
if ACell=nil
if (ACell=nil) or (ACell^.ContentType <> cctDateTime)
then Strings.Add('DateTimeValue=')
else Strings.Add(Format('DateTimeValue=%g', [ACell^.DateTimeValue]));
if ACell=nil
if (ACell=nil) or (ACell^.ContentType <> cctUTF8String)
then Strings.Add('UTF8StringValue=')
else Strings.Add(Format('UTF8StringValue=%s', [ACell^.UTF8StringValue]));
if ACell=nil
if (ACell=nil) or (ACell^.ContentType <> cctBool)
then Strings.Add('BoolValue=')
else Strings.Add(Format('BoolValue=%s', [BoolToStr(ACell^.BoolValue)]));
if ACell=nil
if (ACell=nil) or (ACell^.ContentType <> cctError)
then Strings.Add('ErrorValue=')
else Strings.Add(Format('ErrorValue=%s', [
GetEnumName(TypeInfo(TsErrorValue), ord(ACell^.ErrorValue)) ]));

View File

@ -2657,14 +2657,17 @@ begin
AStrings.Add(Format('ContentType=%s', [
GetEnumName(TypeInfo(TCellContentType), ord(ACell^.ContentType))
]));
AStrings.Add(Format('NumberValue=%g', [ACell^.NumberValue]));
AStrings.Add(Format('DateTimeValue=%g', [ACell^.DateTimeValue]));
AStrings.Add(Format('UTF8StringValue=%s', [ACell^.UTF8StringValue]));
AStrings.Add(Format('BoolValue=%s', [BoolToStr(ACell^.BoolValue)]));
AStrings.Add(Format('ErrorValue=%s', [
GetEnumName(TypeInfo(TsErrorValue), ord(ACell^.ErrorValue))
]));
AStrings.Add(Format('FormulaValue=%s', [Worksheet.ReadFormulaAsString(ACell, true)])); //^.FormulaValue]));
if ACell^.ContentType = cctNumber then
AStrings.Add(Format('NumberValue=%g', [ACell^.NumberValue]));
if ACell^.ContentType = cctDateTime then
AStrings.Add(Format('DateTimeValue=%g', [ACell^.DateTimeValue]));
if ACell^.ContentType = cctUTF8String then
AStrings.Add(Format('UTF8StringValue=%s', [ACell^.UTF8StringValue]));
if ACell^.ContentType = cctBool then
AStrings.Add(Format('BoolValue=%s', [BoolToStr(ACell^.BoolValue)]));
if ACell^.ContentType = cctError then
AStrings.Add(Format('ErrorValue=%s', [GetEnumName(TypeInfo(TsErrorValue), ord(ACell^.ErrorValue))]));
AStrings.Add(Format('FormulaValue=%s', [Worksheet.ReadFormulaAsString(ACell, true)]));
if ACell^.SharedFormulaBase = nil then
AStrings.Add('SharedFormulaBase=')
else

View File

@ -147,6 +147,7 @@ type
procedure DrawAllRows; override;
procedure DrawCellBorders; overload;
procedure DrawCellBorders(ACol, ARow: Integer; ARect: TRect); overload;
procedure DrawCellGrid(ACol,ARow: Integer; ARect: TRect; AState: TGridDrawState); override;
procedure DrawFocusRect(aCol,aRow:Integer; ARect:TRect); override;
procedure DrawFrozenPaneBorders(ARect: TRect);
procedure DrawRow(aRow: Integer); override;
@ -1481,6 +1482,25 @@ begin
end;
end;
{@@ ----------------------------------------------------------------------------
Method inherited method from TCustomGrid. Is overridden here to avoid painting
of the border of frozen cells in black under some circumstances.
-------------------------------------------------------------------------------}
procedure TsCustomWorksheetGrid.DrawCellGrid(ACol, ARow: Integer; ARect: TRect;
AState: TGridDrawState);
begin
if (TitleStyle <> tsNative) and (gdFixed in AState) and
{DisplayFixedColRow and} ((FFrozenCols > 0) or (FFrozenRows > 0)) then
begin
// Draw default cell borders only in the header cols/rows.
// If there are frozen cells they would get a black border, so we don't
// draw their borders here - they are drawn by "DrawRow" anyway.
if ((ACol=0) or (ARow = 0)) and DisplayFixedColRow then
inherited;
end else
inherited;
end;
{@@ ----------------------------------------------------------------------------
This procedure is responsible for painting the focus rectangle. We don't want
the red dashed rectangle here, but prefer the thick Excel-like black border
@ -1499,7 +1519,7 @@ end;
{@@ ----------------------------------------------------------------------------
Draws a solid line along the borders of frozen panes.
@param ARect This rectangle indicates the area containing movable cells.
@param ARect This rectangle indicates the area containing scrollable cells.
If the grid has frozen panes, a black line is drawn along the
upper and/or left edge of this rectangle (depending on the
value of FrozenRows and FrozenCols).
@ -1731,7 +1751,7 @@ begin
end;
end; // with GCache.VisibleGrid ...
// Draw Fixed Columns
// Draw fixed columns
gr := ARow;
for gc := 0 to FixedCols-1 do begin
gds := [gdFixed];