You've already forked lazarus-ccr
fpspreadsheet: biff writers store selected ranges now.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4353 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -449,6 +449,7 @@ type
|
|||||||
function GetSelection: TsCellRangeArray;
|
function GetSelection: TsCellRangeArray;
|
||||||
function GetSelectionAsString: String;
|
function GetSelectionAsString: String;
|
||||||
function GetSelectionCount: Integer;
|
function GetSelectionCount: Integer;
|
||||||
|
function GetSelectionRangeIndexOfActiveCell: Integer;
|
||||||
procedure SetSelection(const ASelection: TsCellRangeArray);
|
procedure SetSelection(const ASelection: TsCellRangeArray);
|
||||||
|
|
||||||
// Comments
|
// Comments
|
||||||
@@ -3609,6 +3610,22 @@ begin
|
|||||||
Result := Length(FSelection);
|
Result := Length(FSelection);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{@@ ----------------------------------------------------------------------------
|
||||||
|
Returns the index of the selected block which contains the active cell
|
||||||
|
-------------------------------------------------------------------------------}
|
||||||
|
function TsWorksheet.GetSelectionRangeIndexOfActiveCell: Integer;
|
||||||
|
var
|
||||||
|
sel: TsCellRange;
|
||||||
|
begin
|
||||||
|
for Result := 0 to High(FSelection) do
|
||||||
|
begin
|
||||||
|
sel := FSelection[Result];
|
||||||
|
if (FActiveCellRow >= sel.Row1) and (FActiveCellRow <= sel.Row2) and
|
||||||
|
(FActiveCellCol >= sel.Col1) and (FActiveCellCol <= sel.Col2) then exit;
|
||||||
|
end;
|
||||||
|
Result := -1;
|
||||||
|
end;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
Marks an array of cell ranges as "selected". Only needed for visual controls
|
Marks an array of cell ranges as "selected". Only needed for visual controls
|
||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
|
@@ -3730,6 +3730,8 @@ procedure TsSpreadBIFFWriter.WriteSELECTION(AStream: TStream;
|
|||||||
ASheet: TsWorksheet; APane: Byte);
|
ASheet: TsWorksheet; APane: Byte);
|
||||||
var
|
var
|
||||||
activeCellRow, activeCellCol: Word;
|
activeCellRow, activeCellCol: Word;
|
||||||
|
i: Integer;
|
||||||
|
sel: TsCellRange;
|
||||||
begin
|
begin
|
||||||
if FWorkbook.ActiveWorksheet <> nil then
|
if FWorkbook.ActiveWorksheet <> nil then
|
||||||
begin
|
begin
|
||||||
@@ -3768,21 +3770,26 @@ begin
|
|||||||
AStream.WriteWord(WordToLE(activeCellCol));
|
AStream.WriteWord(WordToLE(activeCellCol));
|
||||||
|
|
||||||
{ Index into the following cell range list to the entry that contains the active cell }
|
{ Index into the following cell range list to the entry that contains the active cell }
|
||||||
AStream.WriteWord(WordToLE(0)); // there's only 1 item
|
i := ASheet.GetSelectionRangeIndexOfActiveCell;
|
||||||
|
AStream.WriteWord(WordToLE(i));
|
||||||
|
|
||||||
{ Cell range array }
|
{ Cell range array }
|
||||||
|
|
||||||
{ Count of items }
|
{ Count of cell ranges }
|
||||||
AStream.WriteWord(WordToLE(1)); // only 1 item
|
AStream.WriteWord(WordToLE(ASheet.GetSelectionCount));
|
||||||
|
|
||||||
{ Index to first and last row - are the same here }
|
|
||||||
AStream.WriteWord(WordTOLE(activeCellRow));
|
|
||||||
AStream.WriteWord(WordTOLE(activeCellRow));
|
|
||||||
|
|
||||||
|
{ Write each selected cell range }
|
||||||
|
for i := 0 to ASheet.GetSelectionCount-1 do
|
||||||
|
begin
|
||||||
|
sel := ASheet.GetSelection[i];
|
||||||
|
{ Index to first and last row of this selected range }
|
||||||
|
AStream.WriteWord(WordToLE(sel.Row1));
|
||||||
|
AStream.WriteWord(WordToLE(sel.Row2));
|
||||||
{ Index to first and last column - they are the same here again. }
|
{ Index to first and last column - they are the same here again. }
|
||||||
{ Note: BIFF8 writes bytes here! }
|
{ Note: Even BIFF8 writes bytes here! This is ok because BIFF supports only 256 columns }
|
||||||
AStream.WriteByte(activeCellCol);
|
AStream.WriteByte(sel.Col1);
|
||||||
AStream.WriteByte(activeCellCol);
|
AStream.WriteByte(sel.Col2);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TsSpreadBIFFWriter.WriteSelections(AStream: TStream;
|
procedure TsSpreadBIFFWriter.WriteSelections(AStream: TStream;
|
||||||
|
Reference in New Issue
Block a user