Page 1 of 1

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

Posted: Sat Dec 02, 2006 12:00 am
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!

Posted: Sat Dec 02, 2006 12:44 pm
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.

Posted: Sat Dec 02, 2006 3:53 pm
by DickBryant
Works perfectly, thanks!!