Page 1 of 1

What Could Be The Problem Here?

Posted: Wed Dec 06, 2006 9:29 pm
by DickBryant
Hi Sergey,

With respect to the fix I described below in "How To Shift All Text Items "Up" One Font Style" I have this report back from one of the testers:

"Bad news. Different problem. Attached are the files. Now certain letters / characters are being replaced by ?. No obvious logic but must be something in the background like certain Chinese characters are being replaced by ? and offhand the Roman letters being replaced had accents. For one I looked at I recall it coming from the Unicode Arial font for East European languages (inverted circumflex accent on a vowel)."

Here's the code I used to modify the document to update it to the new 'three standard font' format from the old 'two standard font' format:

with FMain.RVStyleQ do
begin
if not ((TextStyles[0].FontName = QFontName) and (TextStyles[0].Size = QFontSize)) then
CanConvert := False;
if not ((TextStyles[1].FontName = AFontName) and (TextStyles[1].Size = AFontSize)) then
CanConvert := False;

if CanConvert then
begin
NumberOfFonts := TextStyles.Count;

//Add a dummy font at the end so we have enough room
with TextStyles.Add do
begin
TextStyles[NumberOfFonts].FontName := WFontName;
TextStyles[NumberOfFonts].Size := WFontSize;
TextStyles[NumberOfFonts].Style := WFontStyle;
TextStyles[NumberOfFonts].Color := WFontColor;
end;

//Insert the new 'system font' at position 0 after bumping the rest of the fonts up one position
for i := NumberOfFonts downto 1 do
begin
TextStyles := TextStyles[i-1];
end;
TextStyles[0].FontName := WFontName;
TextStyles[0].Size := WFontSize;
TextStyles[0].Style := WFontStyle;
TextStyles[0].Color := WFontColor;

//Iterate through the MasterRV table and make changes the the fonts one cell at a time using
//RichViewEdit3 as the scratchpad
with MasterRVTable do
begin
Stream := TMemoryStream.Create;
for r := 0 to Rows.Count -1 do
begin
for c := 0 to Rows[r].Count - 1 do
begin //Operation on each cell
case c of
0,2,3,13,14,16,17,27:
begin
//Skip this cell
end;
else
begin
//Load the cell
try
Cells[r, c].SaveRVFToStream(Stream, False, clNone, nil, nil);
Stream.Position := 0;
FMain.RichViewEdit3.Clear;
FMain.RichViewEdit3.LoadRVFFromStream(Stream);
finally
Stream.Clear;
end;
FMain.RichViewEdit3.Format;

//Modify the font styles and save the cell
if FMain.RichViewEdit3.ItemCount > 0 then
begin
for i := 0 to FMain.RichViewEdit3.ItemCount-1 do
begin
FromNo := FMain.RichViewEdit3.RVData.GetItemStyle(i);
ToNo := FromNo + 1;
FMain.RichViewEdit3.RVData.GetItem(i).StyleNo := ToNo;
end;
FMain.RichViewEdit3.SaveRVFToStream(Stream,False);
Stream.Position := 0;
MasterRVTable.Cells[r,c].Clear;
MasterRVTable.Cells[r,c].InsertRVFFromStream(Stream, 0, Dummy1, Dummy2, Dummy3, False);
Stream.Clear;
end;
end;
end;
end;
end;
Stream.Free;
//Save the modified file
FMain.RichViewEdit1.SaveRVF(StrPas(FLSFile),False);
end;

Posted: Thu Dec 07, 2006 1:41 pm
by Sergey Tkachenko
Can you send me this as a compilable project + example of RVF document?

Posted: Thu Dec 07, 2006 2:02 pm
by DickBryant
I'll send you the RVF document. Would love to send a compilable examble, but much too complex to boil down to simple example.