[How to] How to make Unicode editor
Posted: Wed Sep 07, 2005 9:43 am
This information is about TRichView versions prior to 11. Information about TRichView 11 and newer is in the next post.
1) Set Unicode property to True for all TextStyles in TRVStyle
2) Set RichViewEdit1.RTFReadProperties.UnicodeMode = rvruOnlyUnicode
3) Some methods cannot be used if the document is in Unicode.
- Add, AddFmt, AddNL, AddNLTag, AddTextBlockNL (use AddNLATag or AddNLWTag instead)
- AddTextNL (use AddTextNLA or AddTextNLW instead);
- SetItemText (use SetItemTextA or SetItemTextW instead)
- SetItemTextEd (use SetItemTextEdA or SetItemTextEdW instead)
- SetCurrentItemText (use SetCurrentItemTextA or SetCurrentItemTextW
instead)
4) Existing non-Unicode RVF documents must be converted to Unicode by
calling ConvertToUnicode after loading them (see below).
It's safe to call this procedure for Unicode documents - it will do nothing.
1) Set Unicode property to True for all TextStyles in TRVStyle
2) Set RichViewEdit1.RTFReadProperties.UnicodeMode = rvruOnlyUnicode
3) Some methods cannot be used if the document is in Unicode.
- Add, AddFmt, AddNL, AddNLTag, AddTextBlockNL (use AddNLATag or AddNLWTag instead)
- AddTextNL (use AddTextNLA or AddTextNLW instead);
- SetItemText (use SetItemTextA or SetItemTextW instead)
- SetItemTextEd (use SetItemTextEdA or SetItemTextEdW instead)
- SetCurrentItemText (use SetCurrentItemTextA or SetCurrentItemTextW
instead)
4) Existing non-Unicode RVF documents must be converted to Unicode by
calling ConvertToUnicode after loading them (see below).
It's safe to call this procedure for Unicode documents - it will do nothing.
Code: Select all
uses CRVData, RVItem, RVUni;
procedure ConvertRVToUnicode(RVData: TCustomRVData);
var i,r,c, StyleNo: Integer;
table: TRVTableItemInfo;
begin
for i := 0 to RVData.ItemCount-1 do begin
StyleNo := RVData.GetItemStyle(i);
if StyleNo>=0 then begin
if not RVData.GetRVStyle.TextStyles[StyleNo].Unicode then begin
RVData.SetItemText(i, RVU_GetRawUnicode(RVData.GetItemTextW(i)));
Include(RVData.GetItem(i).ItemOptions, rvioUnicode);
end;
end
else if RVData.GetItemStyle(i)=rvsTable then begin
table := TRVTableItemInfo(RVData.GetItem(i));
for r := 0 to table.Rows.Count-1 do
for c := 0 to table.Rows[r].Count-1 do
if table.Cells[r,c]<>nil then
ConvertRVToUnicode(table.Cells[r,c].GetRVData);
end;
end;
end;
procedure ConvertToUnicode(rv: TCustomRichView);
var i: Integer;
begin
ConvertRVToUnicode(rv.RVData);
for i := 0 to rv.Style.TextStyles.Count-1 do
rv.Style.TextStyles[i].Unicode := True;
end;