📄 rvtable.pas
字号:
TRVUndoCellSpitHorz = class(TRVUndoModifyItemProps)
public
Flag, DecreaseHeight: Boolean;
Row, Col, Row2, OldBestHeight: Integer;
procedure Undo(RVData: TRichViewRVData); override;
end;
TRVUndoCellSpitVert = class(TRVUndoModifyItemProps)
public
Flag, DecreaseWidth: Boolean;
Row, Col, Col2: Integer;
OldBestWidth: TRVHTMLLength;
procedure Undo(RVData: TRichViewRVData); override;
end;
TRVUndoDeleteRows = class(TRVUndoModifyItemProps)
public
Flag: Boolean;
Row, Count: Integer;
Rows: TList;
procedure Undo(RVData: TRichViewRVData); override;
//!!procedure ChangeRVData(ARVData: TRichViewRVData; Restoring: Boolean); override;
destructor Destroy; override;
end;
TCustomRVUndoWithCells = class(TRVUndoModifyItemProps)
public
Flag: Boolean;
CellsList: TList;
//!!procedure ChangeRVData(ARVData: TRichViewRVData; Restoring: Boolean); override;
destructor Destroy; override;
end;
TRVUndoDeleteCols = class(TCustomRVUndoWithCells)
public
Col, Count: Integer;
procedure Undo(RVData: TRichViewRVData); override;
end;
TRVUndoCellsClear = class (TCustomRVUndoWithCells)
public
RowList, ColList: TRVIntegerList;
procedure Undo(RVData: TRichViewRVData); override;
destructor Destroy; override;
end;
TRVUndoMergeItem = class
public
Row,Col,ItemCount: Integer;
Cell: TRVTableCellData;
constructor Create(Table: TRVTableItemInfo; ARow,ACol,AVampRow,AVampCol: Integer);
end;
TRVUndoMerge = class(TRVUndoModifyItemProps)
public
Flag: Boolean;
Row, Col, OldColSpan, OldRowSpan, NewColSpan,NewRowSpan: Integer;
OldBestWidth: TRVHTMLLength;
MergedItemsList: TRVList;
//!!procedure ChangeRVData(ARVData: TRichViewRVData; Restoring: Boolean); override;
procedure Undo(RVData: TRichViewRVData); override;
destructor Destroy; override;
end;
TRVUndoUnmerge = class(TRVUndoModifyItemProps)
public
Flag, UnmergeCols, UnmergeRows: Boolean;
Row, Col, OldColSpan, OldRowSpan, OldBestHeight: Integer;
OldBestWidth: TRVHTMLLength;
procedure Undo(RVData: TRichViewRVData); override;
end;
TRVUndoCellModify = class(TRVCompositeUndo)
public
Row,Col, CaretItemNo, CaretOffs: Integer;
procedure Undo(RVData: TRichViewRVData); override;
end;
TRVUndoMultiCellsModify = class(TRVCompositeUndo)
public
RowList, ColList, CountList: TRVIntegerList;
OldW: Integer;
procedure Undo(RVData: TRichViewRVData); override;
destructor Destroy; override;
function RequiresFormat: Boolean; override;
function RequiresFullReformat1(RVData: TRichViewRVData): Boolean; override;
function RequiresFullReformat2(RVData: TRichViewRVData): Boolean; override;
end;
function AddTableUndoInfo(RVData: TRichViewRVData; UndoInfoClass: TRVUndoInfoClass;
ItemNo: Integer;
AffectSize, AffectWidth: Boolean): TRVUndoModifyItemProps;
var List: TRVUndoList;
begin
List := TRVEditRVData(RVData).GetUndoList;
if List<>nil then begin
Result := TRVUndoModifyItemProps(UndoInfoClass.Create);
Result.Action := rvuModifyItem;
Result.ItemNo := ItemNo;
Result.AffectSize := AffectSize;
Result.AffectWidth := AffectWidth;
List.AddInfo(Result);
end
else
Result := nil;
end;
{======================== TRVUndoModifyCellIntProperty ========================}
procedure TRVUndoModifyCellIntProperty.SetOppositeUndoInfoProps(UndoInfo: TRVUndoModifyItemProps);
begin
if UndoInfo<>nil then begin
(UndoInfo as TRVUndoModifyCellIntProperty).Row := Row;
TRVUndoModifyCellIntProperty(UndoInfo).Col := Col;
end;
end;
{------------------------------------------------------------------------------}
procedure TRVUndoModifyCellIntProperty.Undo(RVData: TRichViewRVData);
var table: TRVTableItemInfo;
begin
table := RVData.GetItem(ItemNo) as TRVTableItemInfo;
table.Changed;
SubObject := table.Cells[Row,Col];
inherited Undo(RVData);
end;
{====================== TRVUndoModifyCellVisibleBorders =======================}
procedure TRVUndoModifyCellVisibleBorders.Undo(RVData: TRichViewRVData);
var table: TRVTableItemInfo;
cell: TRVTableCellData;
ui: TRVUndoModifyCellVisibleBorders;
begin
table := RVData.GetItem(ItemNo) as TRVTableItemInfo;
SubObject := table.Cells[Row,Col];
Cell := table.Cells[Row,Col];
ui := TRVUndoModifyCellVisibleBorders(AddTableUndoInfo(RVData, TRVUndoModifyCellVisibleBorders, ItemNo, False, False));
if ui<>nil then begin
ui.Row := Row;
ui.Col := Col;
ui.Left := Cell.VisibleBorders.Left;
ui.Top := Cell.VisibleBorders.Top;
ui.Right := Cell.VisibleBorders.Right;
ui.Bottom := Cell.VisibleBorders.Bottom;
end;
Cell.VisibleBorders.SetValues(Left, Top, Right, Bottom);
table.Changed;
end;
{========================= TRVUndoRowVAlign ===================================}
procedure TRVUndoRowVAlign.Undo(RVData: TRichViewRVData);
var table: TRVTableItemInfo;
ui: TRVUndoRowVAlign;
begin
table := RVData.GetItem(ItemNo) as TRVTableItemInfo;
ui := TRVUndoRowVAlign(AddTableUndoInfo(RVData, TRVUndoRowVAlign, ItemNo, True, False));
if ui<>nil then begin
ui.OldVAlign := table.Rows[Row].VAlign;
ui.Row := Row;
end;
table.Rows[Row].VAlign := OldVAlign;
table.Changed;
end;
{=========================== TRVUndoModifyCellIntProperties ===================}
procedure TRVUndoModifyCellIntProperties.SetOppositeUndoInfoProps(
UndoInfo: TRVUndoModifyItemProps);
begin
if UndoInfo<>nil then begin
(UndoInfo as TRVUndoModifyCellIntProperties).Row := Row;
TRVUndoModifyCellIntProperties(UndoInfo).Col := Col;
end;
end;
{------------------------------------------------------------------------------}
procedure TRVUndoModifyCellIntProperties.Undo(RVData: TRichViewRVData);
var table: TRVTableItemInfo;
begin
table := RVData.GetItem(ItemNo) as TRVTableItemInfo;
table.Changed;
SubObject := table.Cells[Row,Col];
inherited Undo(RVData);
end;
{========================= TRVUndoInsertTableRows =============================}
procedure TRVUndoInsertTableRows.Undo(RVData: TRichViewRVData);
var ui: TRVUndoInsertTableRows;
table: TRVTableItemInfo;
begin
table := RVData.GetItem(ItemNo) as TRVTableItemInfo;
ui := TRVUndoInsertTableRows(AddTableUndoInfo(RVData, TRVUndoInsertTableRows,
ItemNo, True, True));
if ui<>nil then begin
ui.Flag := not Flag;
ui.Row := Row;
ui.Count := Count;
end;
if Flag then
table.Rows.Do_InsertRows(Row,Count)
else
table.Rows.Do_UnInsertRows(Row,Count);
table.Changed;
end;
{========================= TRVUndoInsertTableCell =============================}
procedure TRVUndoInsertTableCell.Undo(RVData: TRichViewRVData);
var ui: TRVUndoInsertTableCell;
table: TRVTableItemInfo;
begin
table := RVData.GetItem(ItemNo) as TRVTableItemInfo;
ui := TRVUndoInsertTableCell(AddTableUndoInfo(RVData, TRVUndoInsertTableCell,
ItemNo, True, True));
if ui<>nil then begin
ui.Flag := not Flag;
ui.Row := Row;
ui.Col := Col;
end;
if Flag then
table.Rows[Row].Insert(Col)
else
table.Rows[Row].Delete(Col);
table.Changed;
end;
{========================== TRVUndoSpreadOverEmptyCells =======================}
procedure TRVUndoSpreadOverEmptyCells.Undo(RVData: TRichViewRVData);
var ui: TRVUndoSpreadOverEmptyCells;
table: TRVTableItemInfo;
begin
table := RVData.GetItem(ItemNo) as TRVTableItemInfo;
ui := TRVUndoSpreadOverEmptyCells(AddTableUndoInfo(RVData, TRVUndoSpreadOverEmptyCells,
ItemNo, True, True));
if ui<>nil then begin
ui.Flag := not Flag;
ui.Row := Row;
ui.Col := Col;
ui.ColSpan := ColSpan;
end;
if Flag then
table.Rows.Do_SpreadOverEmptyCells(Row,Col,ColSpan)
else
table.Rows.Do_UnSpreadOverEmptyCells(Row,Col,ColSpan);
table.Changed;
end;
{=============================== TRVUndoSpan ==================================}
procedure TRVUndoSpan.Undo(RVData: TRichViewRVData);
var ui: TRVUndoSpan;
table: TRVTableItemInfo;
begin
table := RVData.GetItem(ItemNo) as TRVTableItemInfo;
ui := TRVUndoSpan(AddTableUndoInfo(RVData, TRVUndoSpan,
ItemNo, True, True));
if ui<>nil then begin
ui.IsColSpan := IsColSpan;
if IsColSpan then
ui.OldSpan := table.Cells[Row,Col].ColSpan
else
ui.OldSpan := table.Cells[Row,Col].RowSpan;
ui.Row := Row;
ui.Col := Col;
end;
if IsColSpan then
table.Cells[Row,Col].FColSpan := OldSpan
else
table.Cells[Row,Col].FRowSpan := OldSpan;
table.Changed;
end;
{============================ TRVUndoFreeEmptyCell ============================}
procedure TRVUndoFreeEmptyCell.Undo(RVData: TRichViewRVData);
var ui: TRVUndoFreeEmptyCell;
table: TRVTableItemInfo;
begin
table := RVData.GetItem(ItemNo) as TRVTableItemInfo;
ui := TRVUndoFreeEmptyCell(AddTableUndoInfo(RVData, TRVUndoFreeEmptyCell,
ItemNo, True, True));
if ui<>nil then begin
ui.Flag := not Flag;
ui.Row := Row;
ui.Col := Col;
ui.ColSpan := ColSpan;
ui.RowSpan := RowSpan;
end;
if Flag then
table.Rows.Do_FreeEmptyCells(Row,Col,ColSpan,RowSpan)
else
table.Rows.Do_UnFreeEmptyCells(Row,Col,ColSpan,RowSpan);
table.Changed;
end;
{========================== TRVUndoInsertEmptyCell ============================}
procedure TRVUndoInsertEmptyCell.Undo(RVData: TRichViewRVData);
var ui: TRVUndoInsertEmptyCell;
table: TRVTableItemInfo;
begin
table := RVData.GetItem(ItemNo) as TRVTableItemInfo;
ui := TRVUndoInsertEmptyCell(AddTableUndoInfo(RVData, TRVUndoInsertEmptyCell,
ItemNo, True, True));
if ui<>nil then begin
ui.Flag := not Flag;
ui.Row := Row;
ui.Col := Col;
ui.ColCount := ColCount;
ui.RowCount := RowCount;
end;
if Flag then
table.Rows.Do_InsertEmptyCells(Row,Col,ColCount,RowCount)
else
table.Rows.Do_UnInsertEmptyCells(Row,Col,ColCount,RowCount);
table.Changed;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -