Page 1 of 1

floating point invalid operation

Posted: Thu Jan 26, 2012 3:00 pm
by Marcer
Hi,

I use Delphi XE2, Richview 13.6.2 and Report Builder 14.02.

I try to change font name with this code :

Code: Select all

var
   oStr: TStringStream;
   iFont: Integer;
begin
   oStr := TStringStream.Create(Value);
   oStr.Position := 0;

   ppRichView.RichView.Clear;

   ppRichView.RichView.LoadRTFFromStream(oStr);

   for iFont := ppRichView.RichView.Style.TextStyles.Count - 1 downto 0 do
   begin
      if ( SameText(ppRichView.RichView.Style.TextStyles[iFont].FontName, 'MS Sans Serif') ) then
         ppRichView.RichView.Style.TextStyles[iFont].FontName := 'Microsoft Sans Serif'
      else if ( SameText(RichView.Style.TextStyles[iFont].FontName, 'Courier')) then
         ppRichView.RichView.Style.TextStyles[iFont].FontName := 'Courier New';
   end;

   ppRichView.RichView.Format;

   oStr.Free;
The error occur on call ppRichView.RichView.Format, and is occur in TRVStyle.GetAsDevicePixelsX because the PSaD.ppixScreen = 0

Other information:
ppRichView.RichView.Style.TextStyles.Count = 7
ppRichView.RichView.Style.TextStyles[0].FontName := 'MS Sans Serif'
ppRichView.RichView.Style.TextStyles[1].FontName := 'Arial'
ppRichView.RichView.Style.TextStyles[2].FontName := 'Arial'
ppRichView.RichView.Style.TextStyles[3].FontName := 'Arial'
ppRichView.RichView.Style.TextStyles[4].FontName := 'Arial'
ppRichView.RichView.Style.TextStyles[5].FontName := 'Arial'
ppRichView.RichView.Style.TextStyles[6].FontName := 'Arial'

In function "TRVStyle.GetAsDevicePixelsX"
Result := Round(Value / PSaD.ppixScreen * PSaD.ppixDevice)
Value = 0
PSaD.ppixScreen = 0
PSaD.ppixDevice = 1440

Best regards

Posted: Thu Jan 26, 2012 3:20 pm
by Marcer
And I use Wrapper v1.13.1

Posted: Thu Jan 26, 2012 7:51 pm
by Sergey Tkachenko
Just do not call ppRichView.RichView.Format. It is not needed, and, as you can see, leads to an exception

Posted: Thu Jan 26, 2012 8:13 pm
by Marcer
If I dont call ppRichView.RichView.Format, all text within this style not print correctly.

Posted: Thu Jan 26, 2012 8:33 pm
by Sergey Tkachenko
ppRichView.RichView cannot be formatted using Format, it must be formatted by RB when it prepares a report.
When do you call this code? Can you create a simple test project?

Posted: Thu Jan 26, 2012 8:50 pm
by Marcer
I test with not call format and it's ok.

Thanks Sergey!