Adding numbered comments from RVF
Posted: Fri Jun 22, 2007 12:42 pm
I'm doing an operation in which I'm adding a series of small TRichView documents, stored in RVF, to the end of an existing document. Each of these small documents is actually a comment, so I need to create a numbered list, adding a list marker before each comment. This seems to be half-working; all of the small documents are added correctly, but the list numbers don't show up. Here's what I have:
if CommList.Count > 0 then
begin
//Add a numbered list style to the RVS, so we can use it for the comment list
ListInfo := tmpRVS.ListStyles.Add;
ListNo := tmpRVS.ListStyles.Count-1;
ListLevel := ListInfo.Levels.Add;
LevelNo := ListInfo.Levels.Count-1;
with ListLevel do
begin
ListType := rvlstDecimal;
Font.Assign(tmpRVS.TextStyles[0]);
FirstIndent := 0;
LeftIndent := 24;
FormatString := '%1.';
FormatStringW := WideString('%1.');
StartFrom := 1;
MarkerIndent := 12;
end;
for i := 1 to CommList.Count do
begin
//Get the comment rvf
strTemp := GetCommentRVFFromCommNum(i);
StrStream := TStringStream.Create(strTemp);;
try
//Add the comment to the end of the document
StrStream.Position := 0;
//Add a list item
tmpRVE.SetListMarkerInfo(-1, ListNo, LevelNo, 0, 0, False);
tmpRVE.AddNLWTag('', -1, -1, 0);
SetCursorToEnd;
tmpRVE.InsertRVFFromStreamEd(StrStream);
tmpRVE.Format;
finally
FreeAndNil(StrStream);
end;
end;
SetCursorToEnd is a simple inline function that does this:
procedure SetCursorToEnd;
begin
//Format first, just in case
tmpRVE.Format;
//Set the cursor to the end of the document
tmpRVE.SetSelectionBounds(tmpRVE.ItemCount-1,
tmpRVE.GetOffsAfterItem(tmpRVE.ItemCount-1), tmpRVE.ItemCount-1,
tmpRVE.GetOffsAfterItem(tmpRVE.ItemCount-1));
end;
If I don't use that, the comments are all added at the beginning of the document. The result, when saved out to RTF, doesn't show any list numbers. I must be doing something wrong, but I can't figure it out. Any ideas?
All help appreciated,
Martin
if CommList.Count > 0 then
begin
//Add a numbered list style to the RVS, so we can use it for the comment list
ListInfo := tmpRVS.ListStyles.Add;
ListNo := tmpRVS.ListStyles.Count-1;
ListLevel := ListInfo.Levels.Add;
LevelNo := ListInfo.Levels.Count-1;
with ListLevel do
begin
ListType := rvlstDecimal;
Font.Assign(tmpRVS.TextStyles[0]);
FirstIndent := 0;
LeftIndent := 24;
FormatString := '%1.';
FormatStringW := WideString('%1.');
StartFrom := 1;
MarkerIndent := 12;
end;
for i := 1 to CommList.Count do
begin
//Get the comment rvf
strTemp := GetCommentRVFFromCommNum(i);
StrStream := TStringStream.Create(strTemp);;
try
//Add the comment to the end of the document
StrStream.Position := 0;
//Add a list item
tmpRVE.SetListMarkerInfo(-1, ListNo, LevelNo, 0, 0, False);
tmpRVE.AddNLWTag('', -1, -1, 0);
SetCursorToEnd;
tmpRVE.InsertRVFFromStreamEd(StrStream);
tmpRVE.Format;
finally
FreeAndNil(StrStream);
end;
end;
SetCursorToEnd is a simple inline function that does this:
procedure SetCursorToEnd;
begin
//Format first, just in case
tmpRVE.Format;
//Set the cursor to the end of the document
tmpRVE.SetSelectionBounds(tmpRVE.ItemCount-1,
tmpRVE.GetOffsAfterItem(tmpRVE.ItemCount-1), tmpRVE.ItemCount-1,
tmpRVE.GetOffsAfterItem(tmpRVE.ItemCount-1));
end;
If I don't use that, the comments are all added at the beginning of the document. The result, when saved out to RTF, doesn't show any list numbers. I must be doing something wrong, but I can't figure it out. Any ideas?
All help appreciated,
Martin