There is a example of how to constructure a tree from RVData
procedure TMainForm.ShowStructure(RVData: TCustomRVData; Node: TcxTreeListNode;
ParentID: integer; newtag: boolean; json: boolean; grid_type: integer);
var
i, StyleNo, ItemNo, combo_count, new_tag: Integer;
ParaNode, ItemNode, SubItemNode: TcxTreeListNode;
item: TCustomRVItemInfo;
AName: TRVAnsiString;
ACtrl: TControl;
AVAlign: TRVVAlign;
ATag: TRVTag;
old_tag, keylist, valuelist: string;
function GetExtraBreakProps(i: Integer; ParentID: integer): string;
begin
if RVData.PageBreaksBeforeItems then
begin
Result := '; page break';
exit;
end;
if RVData.ClearLeft then
if RVData.ClearRight then
Result := '; clear both'
else
Result := '; clear left'
else if RVData.ClearRight then
Result := '; clear right'
else
Result := '';
end;
function GetExtraItemString(i: Integer; ParentID: integer): string;
begin
Result := '';
if RVData.GetItem(i).GetBoolValueEx(rvbpJump, RVData.GetRVStyle) then
Result := '; hyperlink';
if TRVTag(RVData.GetItemTag(i)) <> '' then
Result := Result + '; tag: "' + TRVTag(RVData.GetItemTag(i)) + '"';
end;
procedure AddCheckpoint(i: Integer; ParentID: integer);
var
CPTag: TRVTag;
CPName: string;
CPRE: Boolean;
begin
if RVData.GetItemCheckpoint(i) <> nil then
begin
RVData.GetCheckpointInfo(RVData.GetItemCheckpoint(i), CPTag, CPName, CPRE);
SubItemNode := ItemNode.AddChild;
SubItemNode.Data := Pointer(i);
SubItemNode.Texts[0] := Format('Checkpoint "%s"', [CPName]);
SubItemNode.Texts[3] := '0';
SubItemNode.ImageIndex := -1;
end;
end;
procedure AddComponentInfo(i: Integer; ParentID: integer);
var
cmt: TControl;
begin
end;
procedure AddTableInfo(i: Integer; ParentID: integer);
var
r, c: Integer;
table: TRVTableItemInfo;
RowNode, ColNode, CellNode: TcxTreeListNode;
table_name, col_name, row_name, cell_name: string;
begin
table := TRVTableItemInfo(RVData.GetItem(i));
table.Tag := getItemNextTag(table.Tag, newtag);
table_name := 'Table_' + Table.Tag;
ItemNode.Texts[1] := table.Tag;
ItemNode.Texts[2] := table_name;
ItemNode.Texts[3] := '0';
ItemNode.ImageIndex := -1;
//
//ÁÐ
if grid_type <> 1 then
begin
for c := 0 to table.ColCount - 1 do
begin
ColNode := ItemNode.AddChild;
ColNode.Data := Pointer(i);
col_name := table_name + '_Col_' + intToStr(c);
ColNode.Texts[0] := Format('Col_ %d', [c]);
ColNode.Texts[2] := col_name;
ColNode.Texts[3] := '0';
ColNode.ImageIndex := 0;
for r := 0 to table.RowCount - 1 do
begin
if table.Cells[r, c] <> nil then
begin
//table.Cells[r,c].GetRVData.SetItemTag(i, strToInt(getItemNextTag(table.Cells[r, c].Tag));
table.Cells[r, c].Tag := getItemNextTag(table.Cells[r, c].Tag, newtag);
//cell_name := table_name + '_Cell_'+'C'+IntToStr(c)+'_R'+IntToStr(r);
cell_name := table_name + '_Cell_' + 'R' + IntToStr(r) + '_C' + IntToStr(c);
CellNode := ColNode.AddChild;
CellNode.Data := Pointer(i);
CellNode.Texts[0] := Format('Cell [%d, %d]', [r, c]);
CellNode.Texts[1] := table.Cells[r, c].Tag;
CellNode.Texts[2] := cell_name;
CellNode.Texts[3] := '1';
CellNode.ImageIndex := 0;
ShowStructure(table.Cells[r, c].GetRVData, CellNode, ItemNo, newtag, json, grid_type);
end;
end;
end;
end;
//ÐÐ
if grid_type <> 0 then
begin
for r := 0 to table.RowCount - 1 do
begin
row_name := table_name + '_Row_' + intToStr(r);
RowNode := ItemNode.AddChild;
RowNode.Data := Pointer(i);
RowNode.Texts[0] := Format('Row %d', [r]);
RowNode.Texts[2] := row_name;
RowNode.Texts[3] := '0';
RowNode.ImageIndex := 0;
for c := 0 to table.ColCount - 1 do
begin
if table.Cells[r, c] <> nil then
begin
table.Cells[r, c].Tag := getItemNextTag(table.Cells[r, c].Tag, newtag);
cell_name := table_name + '_Cell_' + 'C' + IntToStr(c) + '_R' + IntToStr(c);
CellNode := RowNode.AddChild;
CellNode.Data := Pointer(i);
CellNode.Texts[0] := Format('Cell [%d, %d]', [r, c]);
CellNode.Texts[1] := table.Cells[r, c].Tag;
CellNode.Texts[2] := cell_name;
CellNode.Texts[3] := '0';
CellNode.ImageIndex := 0;
ShowStructure(table.Cells[r, c].GetRVData, CellNode, ItemNo, newtag, json, grid_type);
end;
end;
end;
end;
end;
procedure AddListMarkerInfo(i: Integer; ParentID: integer);
var
ListNo, Level, StartFrom: Integer;
UseStartFrom: Boolean;
s: string;
begin
RVData.GetListMarkerInfo(i, ListNo, Level, StartFrom, UseStartFrom);
s := Format('ListNo=%d, Level=%d', [ListNo, Level]);
if UseStartFrom then
s := s + Format(', start from %d', [StartFrom]);
//Node.Owner.AddChild(ItemNode, s);
SubItemNode := ItemNode.AddChild;
SubItemNode.Data := Pointer(i);
SubItemNode.Texts[0] := s;
SubItemNode.Texts[3] := '0';
SubItemNode.ImageIndex := -1;
end;
function GetParaCaption(i: Integer; ParentID: integer): string;
var
Level: Integer;
begin
Level := RVData.GetRVStyle.ParaStyles[RVData.GetItemPara(i)].OutlineLevel;
if Level <= 0 then
Result := 'Paragraph'
else
Result := Format('Heading level %d', [Level]);
end;
begin
ParaNode := nil;
for i := 0 to RVData.ItemCount - 1 do
begin
if RVData.IsParaStart(i) then
begin
ParaNode := Node.AddChild;
ParaNode.Data := Pointer(i);
if json then
begin
ParaNode.Texts[0] := Format('%s', [GetParaCaption(i, ParentID)]);
end
else
begin
ParaNode.Texts[0] := Format('%s, ParaNo=%d%s', [GetParaCaption(i, ParentID), RVData.GetItemPara(i), GetExtraBreakProps(i, ParentID)]);
end;
ParaNode.Texts[2] := '';
ParaNode.Texts[3] := '0';
ParaNode.ImageIndex := -1;
end
else if RVData.IsFromNewLine(i) then
begin
ItemNode := ParaNode.AddChild;
ItemNode.Data := Pointer(i);
if json then
begin
ItemNode.Texts[0] := Format('Line break%s', [GetExtraBreakProps(i, ParentID)]);
end
else
begin
ItemNode.Texts[0] := Format('Line break%s', [GetExtraBreakProps(i, ParentID)]);
end;
ItemNode.Texts[2] := '';
ItemNode.Texts[3] := '0';
ItemNode.ImageIndex := -1;
end;
StyleNo := RVData.GetItemStyle(i);
if StyleNo >= 0 then
begin
item := RVData.GetItem(i);
//item.Tag := strToInt(getItemNextTag(item.Tag, newtag));
ItemNode := ParaNode.AddChild;
ItemNode.Data := Pointer(i);
if json then
begin
ItemNode.Texts[0] := Format('%s', [RVData.GetItemText(i)]);
end
else
begin
ItemNode.Texts[0] := Format('Text "%s", StyleNo=%d%s', [RVData.GetItemText(i), StyleNo, GetExtraItemString(i, ParentID)]);
end;
ItemNode.Texts[3] := '0';
ItemNode.ImageIndex := -1;
end
else
begin
item := RVData.GetItem(i);
item.Tag := getItemNextTag(item.Tag, newtag);
ItemNode := ParaNode.AddChild;
ItemNode.Data := Pointer(i);
if StyleNo = rvsComponent then
begin
//AddComponentInfo(i, i);
//RVEMain.RichViewEdit.GetCurrentControlInfo(AName, ACtrl, AVAlign, ATag);
//RVEMain.RichViewEdit.GetControlInfo(i, AName, ACtrl, AVAlign, ATag);
RVData.GetControlInfo(i, AName, ACtrl, AVAlign, ATag);
if json then
begin
ItemNode.Texts[0] := getControlText(ACtrl);
ItemNode.Texts[1] := item.ClassName;
ItemNode.Values[4] := '';
ItemNode.Values[5] := '';
keylist := '';
valuelist := '';
if ACtrl is TSRVComboBox then
begin
for combo_count := 0 to TSRVComboBox(ACtrl).Items.Count - 1 do
begin
keylist := keylist + TSRVComboBox(ACtrl).Items.Items[combo_count].Key + '|';
valuelist := valuelist + TSRVComboBox(ACtrl).Items.Items[combo_count].Caption + '|';
end;
ItemNode.Values[4] := keylist;
ItemNode.Values[5] := valuelist;
end;
end
else
begin
ItemNode.Texts[0] := getControlText(ACtrl);
//ItemNode.Texts[0] := Format('%s [StyleNo=%d]%s', [RVData.GetItem(i).ClassName, StyleNo, GetExtraItemString(i, ParentID)]);
end;
ItemNode.Texts[1] := item.Tag;
ItemNode.Texts[2] := AName;
ItemNode.Texts[3] := '0';
ItemNode.ImageIndex := 0;
end
else if item is TRVTableItemInfo then
begin
ItemNode.Texts[0] := Format('%s [StyleNo=%d]%s', [RVData.GetItem(i).ClassName, StyleNo, GetExtraItemString(i, ParentID)]);
ItemNode.Values[0] := item.ClassName;
ItemNode.Texts[1] := item.Tag;
ItemNode.Texts[3] := '0';
ItemNode.ImageIndex := -1;
AddTableInfo(i, i);
end
else if item is TCustomRVNoteItemInfo then
begin
ShowStructure(TCustomRVNoteItemInfo(item).Document, ItemNode.AddChild, i, newtag, json, grid_type);
//Node.Owner.AddChildObject(ItemNode, 'Note text', Pointer(i)));
end;
//else if RVData.GetItem(i) is TRVMarkerItemInfo then
// AddListMarkerInfo(i);
end;
AddCheckpoint(i, ParentID);
end;
end;
RVData
-
- Site Admin
- Posts: 17602
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: RVData
Is it a reworked code from https://www.trichview.com/forums/viewto ... f=3&t=3627 ?