How To Shift All Text Items "Up" One Font Style

General TRichView support forum. Please post your questions here
Post Reply
DickBryant
Posts: 148
Joined: Wed Dec 07, 2005 2:02 pm
Contact:

How To Shift All Text Items "Up" One Font Style

Post by DickBryant »

I've decided to change my app from having two standard fonts to having 3. Now documents that my beta testers have saved using the old approach are "off" by one font style number when they are loaded.

I've worked out a method to automatically convert their files to the new format, but I need to iterate through each text item in the document and change its style from the nth style to the (n+1)th style. What is the proper code to do

Change text style of item(i) from (current style index) to (current style index +1)

Thanks!
Sergey Tkachenko
Site Admin
Posts: 17560
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Code: Select all

procedure ChangeStyle(RVData: TCustomRVData; FromNo, ToNo: Integer);
var i,r,c: Integer;
    s: String;
    table: TRVTableItemInfo;
begin
for i := 0 to RVData.ItemCount-1 do
  if RVData.GetItemStyle(i)=FromNo then begin 
    RVData.GetItem(i).StyleNo := ToNo;
    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
          ChangeStyle(table.Cells[r,c].GetRVData, FromNo, ToNo);
  end;
end;
Both styles must have the same value of Unicode property.
DickBryant
Posts: 148
Joined: Wed Dec 07, 2005 2:02 pm
Contact:

Post by DickBryant »

Works perfectly, thanks!!
Post Reply