You've already forked lazarus-ccr
fpspreadsheet: Fix cell range selection issue in TsWorksheetGrid if grid is in edit mode. Fix ods reporting an error due to a worksheet with empty name. Fix some bugs added when introducing text overflow cells (frozen cells incorrectly painted, failure to determine row heights correctly)
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3564 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -84,12 +84,23 @@ object MainFrm: TMainFrm
|
|||||||
object CbAutoCalcFormulas: TCheckBox
|
object CbAutoCalcFormulas: TCheckBox
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 19
|
Height = 19
|
||||||
Top = 39
|
Top = 32
|
||||||
Width = 128
|
Width = 128
|
||||||
Caption = 'Calculate on change'
|
Caption = 'Calculate on change'
|
||||||
OnChange = CbAutoCalcFormulasChange
|
OnChange = CbAutoCalcFormulasChange
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
|
object CbTextOverflow: TCheckBox
|
||||||
|
Left = 8
|
||||||
|
Height = 19
|
||||||
|
Top = 56
|
||||||
|
Width = 91
|
||||||
|
Caption = 'Text overflow'
|
||||||
|
Checked = True
|
||||||
|
OnChange = CbTextOverflowChange
|
||||||
|
State = cbChecked
|
||||||
|
TabOrder = 5
|
||||||
|
end
|
||||||
end
|
end
|
||||||
object ToolBar1: TToolBar
|
object ToolBar1: TToolBar
|
||||||
Left = 0
|
Left = 0
|
||||||
@ -442,9 +453,9 @@ object MainFrm: TMainFrm
|
|||||||
FrozenRows = 0
|
FrozenRows = 0
|
||||||
ReadFormulas = False
|
ReadFormulas = False
|
||||||
Align = alClient
|
Align = alClient
|
||||||
|
AutoAdvance = aaDown
|
||||||
BorderStyle = bsNone
|
BorderStyle = bsNone
|
||||||
ColCount = 27
|
ColCount = 27
|
||||||
ExtendedSelect = False
|
|
||||||
MouseWheelOption = mwGrid
|
MouseWheelOption = mwGrid
|
||||||
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goRowSizing, goColSizing, goThumbTracking, goSmoothScroll, goFixedColSizing]
|
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goRowSizing, goColSizing, goThumbTracking, goSmoothScroll, goFixedColSizing]
|
||||||
RowCount = 101
|
RowCount = 101
|
||||||
|
@ -86,6 +86,7 @@ type
|
|||||||
CbReadFormulas: TCheckBox;
|
CbReadFormulas: TCheckBox;
|
||||||
CbHeaderStyle: TComboBox;
|
CbHeaderStyle: TComboBox;
|
||||||
CbAutoCalcFormulas: TCheckBox;
|
CbAutoCalcFormulas: TCheckBox;
|
||||||
|
CbTextOverflow: TCheckBox;
|
||||||
EdFormula: TEdit;
|
EdFormula: TEdit;
|
||||||
EdCellAddress: TEdit;
|
EdCellAddress: TEdit;
|
||||||
FontComboBox: TComboBox;
|
FontComboBox: TComboBox;
|
||||||
@ -277,6 +278,7 @@ type
|
|||||||
procedure CbHeaderStyleChange(Sender: TObject);
|
procedure CbHeaderStyleChange(Sender: TObject);
|
||||||
procedure CbReadFormulasChange(Sender: TObject);
|
procedure CbReadFormulasChange(Sender: TObject);
|
||||||
procedure CbBackgroundColorGetColors(Sender: TCustomColorBox; Items: TStrings);
|
procedure CbBackgroundColorGetColors(Sender: TCustomColorBox; Items: TStrings);
|
||||||
|
procedure CbTextOverflowChange(Sender: TObject);
|
||||||
procedure EdCellAddressEditingDone(Sender: TObject);
|
procedure EdCellAddressEditingDone(Sender: TObject);
|
||||||
procedure EdFormulaEditingDone(Sender: TObject);
|
procedure EdFormulaEditingDone(Sender: TObject);
|
||||||
procedure EdFrozenColsChange(Sender: TObject);
|
procedure EdFrozenColsChange(Sender: TObject);
|
||||||
@ -725,6 +727,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainFrm.CbTextOverflowChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
WorksheetGrid.TextOverflow := CbTextOverflow.Checked;
|
||||||
|
WorksheetGrid.Invalidate;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMainFrm.CbBackgroundColorSelect(Sender: TObject);
|
procedure TMainFrm.CbBackgroundColorSelect(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if CbBackgroundColor.ItemIndex <= 0 then
|
if CbBackgroundColor.ItemIndex <= 0 then
|
||||||
@ -878,6 +886,7 @@ begin
|
|||||||
AcShowHeaders.Checked := WorksheetGrid.ShowHeaders;
|
AcShowHeaders.Checked := WorksheetGrid.ShowHeaders;
|
||||||
EdFrozenCols.Value := WorksheetGrid.FrozenCols;
|
EdFrozenCols.Value := WorksheetGrid.FrozenCols;
|
||||||
EdFrozenRows.Value := WorksheetGrid.FrozenRows;
|
EdFrozenRows.Value := WorksheetGrid.FrozenRows;
|
||||||
|
WorksheetGrid.TextOverflow := CbTextOverflow.Checked;
|
||||||
SetupBackgroundColorBox;
|
SetupBackgroundColorBox;
|
||||||
|
|
||||||
// Load names of worksheets into tabcontrol and show first sheet
|
// Load names of worksheets into tabcontrol and show first sheet
|
||||||
|
@ -1287,6 +1287,7 @@ var
|
|||||||
BodyNode, SpreadSheetNode, TableNode: TDOMNode;
|
BodyNode, SpreadSheetNode, TableNode: TDOMNode;
|
||||||
StylesNode: TDOMNode;
|
StylesNode: TDOMNode;
|
||||||
OfficeSettingsNode: TDOMNode;
|
OfficeSettingsNode: TDOMNode;
|
||||||
|
nodename: String;
|
||||||
begin
|
begin
|
||||||
//unzip files into AFileName path
|
//unzip files into AFileName path
|
||||||
FilePath := GetTempDir(false);
|
FilePath := GetTempDir(false);
|
||||||
@ -1334,10 +1335,11 @@ begin
|
|||||||
//process each table (sheet)
|
//process each table (sheet)
|
||||||
TableNode := SpreadSheetNode.FindNode('table:table');
|
TableNode := SpreadSheetNode.FindNode('table:table');
|
||||||
while Assigned(TableNode) do begin
|
while Assigned(TableNode) do begin
|
||||||
|
nodename := TableNode.Nodename;
|
||||||
// These nodes occur due to leading spaces which are not skipped
|
// These nodes occur due to leading spaces which are not skipped
|
||||||
// automatically any more due to PreserveWhiteSpace option applied
|
// automatically any more due to PreserveWhiteSpace option applied
|
||||||
// to ReadXMLFile
|
// to ReadXMLFile
|
||||||
if TableNode.NodeName = '#text' then begin
|
if nodeName <> 'table:table' then begin // '#text' then begin
|
||||||
TableNode := TableNode.NextSibling;
|
TableNode := TableNode.NextSibling;
|
||||||
continue;
|
continue;
|
||||||
end;
|
end;
|
||||||
@ -1839,7 +1841,7 @@ begin
|
|||||||
// These nodes occur due to indentation spaces which are not skipped
|
// These nodes occur due to indentation spaces which are not skipped
|
||||||
// automatically any more due to PreserveWhiteSpace option applied
|
// automatically any more due to PreserveWhiteSpace option applied
|
||||||
// to ReadXMLFile
|
// to ReadXMLFile
|
||||||
if nodeName = '#text' then begin
|
if nodeName <> 'table:table-cell' then begin //= '#text' then begin
|
||||||
cellNode := cellNode.NextSibling;
|
cellNode := cellNode.NextSibling;
|
||||||
Continue;
|
Continue;
|
||||||
end;
|
end;
|
||||||
@ -1963,7 +1965,7 @@ begin
|
|||||||
cfgEntryItemNode := cfgItemMapEntryNode.FirstChild;
|
cfgEntryItemNode := cfgItemMapEntryNode.FirstChild;
|
||||||
while Assigned(cfgEntryItemNode) do begin
|
while Assigned(cfgEntryItemNode) do begin
|
||||||
nodeName := cfgEntryItemNode.NodeName;
|
nodeName := cfgEntryItemNode.NodeName;
|
||||||
if (nodeName <> '#text') and (nodeName = 'config:config-item')
|
if (nodeName = 'config:config-item')
|
||||||
then begin
|
then begin
|
||||||
cfgName := lowercase(GetAttrValue(cfgEntryItemNode, 'config:name'));
|
cfgName := lowercase(GetAttrValue(cfgEntryItemNode, 'config:name'));
|
||||||
if cfgName = 'showgrid' then begin
|
if cfgName = 'showgrid' then begin
|
||||||
@ -1975,7 +1977,7 @@ begin
|
|||||||
if cfgValue = 'false' then showHeaders := false;
|
if cfgValue = 'false' then showHeaders := false;
|
||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
if (nodeName <> '#text') and (nodeName = 'config:config-item-map-named') and
|
if (nodeName = 'config:config-item-map-named') and
|
||||||
(GetAttrValue(cfgEntryItemNode, 'config:name') = 'Tables')
|
(GetAttrValue(cfgEntryItemNode, 'config:name') = 'Tables')
|
||||||
then begin
|
then begin
|
||||||
cfgTableItemNode := cfgEntryItemNode.FirstChild;
|
cfgTableItemNode := cfgEntryItemNode.FirstChild;
|
||||||
|
@ -47,6 +47,7 @@ type
|
|||||||
FEditing: Boolean;
|
FEditing: Boolean;
|
||||||
FCellFont: TFont;
|
FCellFont: TFont;
|
||||||
FAutoCalc: Boolean;
|
FAutoCalc: Boolean;
|
||||||
|
FTextOverflow: Boolean;
|
||||||
FReadFormulas: Boolean;
|
FReadFormulas: Boolean;
|
||||||
FDrawingCell: PCell;
|
FDrawingCell: PCell;
|
||||||
function CalcAutoRowHeight(ARow: Integer): Integer;
|
function CalcAutoRowHeight(ARow: Integer): Integer;
|
||||||
@ -165,6 +166,8 @@ type
|
|||||||
property ShowGridLines: Boolean read GetShowGridLines write SetShowGridLines default true;
|
property ShowGridLines: Boolean read GetShowGridLines write SetShowGridLines default true;
|
||||||
{@@ Shows/hides column and row headers in the fixed col/row style of the grid. }
|
{@@ Shows/hides column and row headers in the fixed col/row style of the grid. }
|
||||||
property ShowHeaders: Boolean read GetShowHeaders write SetShowHeaders default true;
|
property ShowHeaders: Boolean read GetShowHeaders write SetShowHeaders default true;
|
||||||
|
{@@ Activates text overflow (cells reaching into neighbors) }
|
||||||
|
property TextOverflow: Boolean read FTextOverflow write FTextOverflow default false;
|
||||||
|
|
||||||
public
|
public
|
||||||
{ public methods }
|
{ public methods }
|
||||||
@ -328,6 +331,8 @@ type
|
|||||||
property ShowGridLines;
|
property ShowGridLines;
|
||||||
{@@ Shows/hides column and row headers in the fixed col/row style of the grid. }
|
{@@ Shows/hides column and row headers in the fixed col/row style of the grid. }
|
||||||
property ShowHeaders;
|
property ShowHeaders;
|
||||||
|
{@@ Activates text overflow (cells reaching into neighbors) }
|
||||||
|
property TextOverflow;
|
||||||
|
|
||||||
{@@ inherited from ancestors}
|
{@@ inherited from ancestors}
|
||||||
property Align;
|
property Align;
|
||||||
@ -368,7 +373,7 @@ type
|
|||||||
{@@ inherited from ancestors}
|
{@@ inherited from ancestors}
|
||||||
property Enabled;
|
property Enabled;
|
||||||
{@@ inherited from ancestors}
|
{@@ inherited from ancestors}
|
||||||
property ExtendedSelect;
|
property ExtendedSelect default true;
|
||||||
{@@ inherited from ancestors}
|
{@@ inherited from ancestors}
|
||||||
property FixedColor;
|
property FixedColor;
|
||||||
{@@ inherited from ancestors}
|
{@@ inherited from ancestors}
|
||||||
@ -1083,8 +1088,8 @@ begin
|
|||||||
then begin
|
then begin
|
||||||
r := ARow - FHeaderCount;
|
r := ARow - FHeaderCount;
|
||||||
c := ACol - FHeaderCount;
|
c := ACol - FHeaderCount;
|
||||||
lCell := FDrawingCell;
|
//lCell := FDrawingCell;
|
||||||
// lCell := FWorksheet.FindCell(r, c);
|
lCell := FWorksheet.FindCell(r, c);
|
||||||
if lCell <> nil then begin
|
if lCell <> nil then begin
|
||||||
// Background color
|
// Background color
|
||||||
if (uffBackgroundColor in lCell^.UsedFormattingFields) then begin
|
if (uffBackgroundColor in lCell^.UsedFormattingFields) then begin
|
||||||
@ -1401,7 +1406,7 @@ procedure TsCustomWorksheetGrid.DrawRow(ARow: Integer);
|
|||||||
var
|
var
|
||||||
gds: TGridDrawState;
|
gds: TGridDrawState;
|
||||||
sr, sc, sr1,sc1,sr2,sc2: Cardinal; // sheet row/column
|
sr, sc, sr1,sc1,sr2,sc2: Cardinal; // sheet row/column
|
||||||
gr, gc, gcNext, gcLast, gc1, gc2: Integer; // grid row/column
|
gr, gc, gcNext, gcLast, gc1, gc2, gcLastUsed: Integer; // grid row/column
|
||||||
Rs: Boolean;
|
Rs: Boolean;
|
||||||
rct, saved_rct: TRect;
|
rct, saved_rct: TRect;
|
||||||
clipArea: Trect;
|
clipArea: Trect;
|
||||||
@ -1464,6 +1469,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
sr := GetWorksheetRow(ARow);
|
sr := GetWorksheetRow(ARow);
|
||||||
|
gcLastUsed := GetGridCol(FWorksheet.GetLastOccupiedColIndex);
|
||||||
|
|
||||||
// Draw columns in this row
|
// Draw columns in this row
|
||||||
with GCache.VisibleGrid do
|
with GCache.VisibleGrid do
|
||||||
@ -1473,7 +1479,7 @@ begin
|
|||||||
// Because of possible cell overflow from cells left of the visible range
|
// Because of possible cell overflow from cells left of the visible range
|
||||||
// we have to seek to the left for the first occupied text cell
|
// we have to seek to the left for the first occupied text cell
|
||||||
// and start painting from here.
|
// and start painting from here.
|
||||||
if sr <> Cardinal(-1) then
|
if FTextOverflow and (sr <> Cardinal(-1)) then
|
||||||
while (gc > FixedCols) do
|
while (gc > FixedCols) do
|
||||||
begin
|
begin
|
||||||
dec(gc);
|
dec(gc);
|
||||||
@ -1497,8 +1503,8 @@ begin
|
|||||||
// Now find the last column. Again text can overflow into the visible area
|
// Now find the last column. Again text can overflow into the visible area
|
||||||
// from cells to the right.
|
// from cells to the right.
|
||||||
gcLast := Right;
|
gcLast := Right;
|
||||||
if sr <> Cardinal(-1) then
|
if FTextOverflow and (sr <> Cardinal(-1)) then
|
||||||
while gcLast < ColCount-1 do begin
|
while (gcLast < ColCount-1) and (gcLast < gcLastUsed) do begin
|
||||||
inc(gcLast);
|
inc(gcLast);
|
||||||
cell := FWorksheet.FindCell(sr, GetWorksheetCol(gcLast));
|
cell := FWorksheet.FindCell(sr, GetWorksheetCol(gcLast));
|
||||||
// Empty cell --> proceed with next cell to the right
|
// Empty cell --> proceed with next cell to the right
|
||||||
@ -1514,9 +1520,10 @@ begin
|
|||||||
Break;
|
Break;
|
||||||
// All other cases --> no overflow --> return to initial right column
|
// All other cases --> no overflow --> return to initial right column
|
||||||
gcLast := Right;
|
gcLast := Right;
|
||||||
|
Break;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
while gc <= gcLast do begin
|
while (gc <= gcLast) do begin
|
||||||
gr := ARow;
|
gr := ARow;
|
||||||
rct := saved_rct;
|
rct := saved_rct;
|
||||||
// FDrawingCell is the cell which is currently being painted. We store
|
// FDrawingCell is the cell which is currently being painted. We store
|
||||||
@ -1529,6 +1536,8 @@ begin
|
|||||||
if (cell = nil) or (cell^.MergedNeighbors = []) then begin
|
if (cell = nil) or (cell^.MergedNeighbors = []) then begin
|
||||||
// single cell
|
// single cell
|
||||||
FDrawingCell := cell;
|
FDrawingCell := cell;
|
||||||
|
if FTextOverflow then
|
||||||
|
begin
|
||||||
gds := GetGridDrawState(gc, gr);
|
gds := GetGridDrawState(gc, gr);
|
||||||
ColRowToOffset(true, true, gc, rct.Left, rct.Right);
|
ColRowToOffset(true, true, gc, rct.Left, rct.Right);
|
||||||
if CellOverflow(gc, gr, gds, gc1, gc2, rct) then
|
if CellOverflow(gc, gr, gds, gc1, gc2, rct) then
|
||||||
@ -1536,6 +1545,7 @@ begin
|
|||||||
gc := gc1;
|
gc := gc1;
|
||||||
gcNext := gc + (gc2 - gc1) + 1;
|
gcNext := gc + (gc2 - gc1) + 1;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
@ -1588,8 +1598,11 @@ begin
|
|||||||
ColRowToOffset(True, True, gc, rct.Left, rct.Right);
|
ColRowToOffset(True, True, gc, rct.Left, rct.Right);
|
||||||
// is this column within the ClipRect?
|
// is this column within the ClipRect?
|
||||||
if (rct.Left < rct.Right) and HorizontalIntersect(rct, clipArea) then
|
if (rct.Left < rct.Right) and HorizontalIntersect(rct, clipArea) then
|
||||||
|
begin
|
||||||
|
FDrawingCell := FWorksheet.FindCell(GetWorksheetRow(gr), GetWorksheetCol(gc));
|
||||||
DoDrawCell(gc, gr);
|
DoDrawCell(gc, gr);
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{@@
|
{@@
|
||||||
@ -3450,7 +3463,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
lRow := FWorksheet.FindRow(i - FHeaderCount);
|
lRow := FWorksheet.FindRow(i - FHeaderCount);
|
||||||
if (lRow <> nil) then
|
if (lRow <> nil) then
|
||||||
RowHeights[i] := CalcRowHeight(lRow^.Height);
|
h := CalcRowHeight(lRow^.Height);
|
||||||
end;
|
end;
|
||||||
RowHeights[i] := h;
|
RowHeights[i] := h;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user