Hi Sergey-
Do you have any updates for the exampe:
http://www.trichview.com/support/files/script2.zip
in the main unit, you said:
- supporting Unicode text (some modifications in InsertMultilineText are Not implemented
I tried your example, and it really cannot support multi text unicode, this is the snapshot:
the A part is the original 2-line text and the B part is the result, I tried to solve the problem but haven't find any solution so far, do you have any better solutions on how to change InsertMultilineText menthod to support unicode for multiline text?
How to support unicode for multiline text
procedure InsertMultilineText(RVData: TCustomRVData; var ItemNo, Pos: Integer; const Value: String);
var
item: TRVTextItemInfo;
s1, s2: String;
sl: TStringList;
i: Integer;
begin
if Value='' then exit;
s1 := RVData.GetItemTextA(ItemNo);
s2 := Copy(s1, Pos, Length(s1));
s1 := Copy(s1, 1, Pos-1);
sl := TStringList.Create;
sl.Text := Value;
// workaround - TStringList ignores the last cr lf
if (Length(Value)>1) and (Value[Length(Value)-1]=#13) and (Value[Length(Value)]=#10) then
sl.Add('');
// end of workaround
if sl.Count=1 then begin // if it's a single line, then do this
RVData.SetItemTextA(ItemNo, s1+Value+s2);
sl.Free;
inc(Pos, Length(Value)-1);
exit; // exit when this is done
end;
RVData.SetItemTextA(ItemNo, s1+sl[0]);
// for multi-line, maybe this is whether the non-unicode is caused
for i := 1 to sl.Count-1 do begin
item := RichViewTextItemClass.Create(RVData);
s1 := sl;
if i=sl.Count-1 then s1 := s1+s2;
item.StyleNo := RVData.GetItemStyle(ItemNo);
item.ParaNo := RVData.GetItemPara(ItemNo);
item.Inserting(RVData, s1, False);
RVData.Items.InsertObject(ItemNo+i, s1, item);
item.Inserted(RVData, ItemNo+i);
end;
ItemNo := ItemNo+sl.Count-1;
Pos := Length(sl[sl.Count-1])+1;
sl.Free;
end;
var
item: TRVTextItemInfo;
s1, s2: String;
sl: TStringList;
i: Integer;
begin
if Value='' then exit;
s1 := RVData.GetItemTextA(ItemNo);
s2 := Copy(s1, Pos, Length(s1));
s1 := Copy(s1, 1, Pos-1);
sl := TStringList.Create;
sl.Text := Value;
// workaround - TStringList ignores the last cr lf
if (Length(Value)>1) and (Value[Length(Value)-1]=#13) and (Value[Length(Value)]=#10) then
sl.Add('');
// end of workaround
if sl.Count=1 then begin // if it's a single line, then do this
RVData.SetItemTextA(ItemNo, s1+Value+s2);
sl.Free;
inc(Pos, Length(Value)-1);
exit; // exit when this is done
end;
RVData.SetItemTextA(ItemNo, s1+sl[0]);
// for multi-line, maybe this is whether the non-unicode is caused
for i := 1 to sl.Count-1 do begin
item := RichViewTextItemClass.Create(RVData);
s1 := sl;
if i=sl.Count-1 then s1 := s1+s2;
item.StyleNo := RVData.GetItemStyle(ItemNo);
item.ParaNo := RVData.GetItemPara(ItemNo);
item.Inserting(RVData, s1, False);
RVData.Items.InsertObject(ItemNo+i, s1, item);
item.Inserted(RVData, ItemNo+i);
end;
ItemNo := ItemNo+sl.Count-1;
Pos := Length(sl[sl.Count-1])+1;
sl.Free;
end;
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Oops, sorry.
Done. Not only modifications to support Unicode in this demo, but also a completely Unicode version.
See here: http://www.trichview.com/forums/viewtopic.php?t=9#5883
Done. Not only modifications to support Unicode in this demo, but also a completely Unicode version.
See here: http://www.trichview.com/forums/viewtopic.php?t=9#5883