View Issue Details

IDProjectCategoryView StatusLast Update
0023058LazarusLazReportpublic2013-09-18 14:00
ReporterStephanoAssigned ToJesus Reyes 
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Product Version1.1 (SVN)Product Build 
Target Version1.2.0Fixed in Version1.1 (SVN) 
Summary0023058: Lazreport cannot open older frf files
DescriptionOpening version 23 frf reports yields an 'Unsupported frf Format' error. This is due in part to recent FPC changes, and an incorrectly assumed layout.

A tentative patch is attached. I am not sure where to use FPC_FULLVERSION vs frversion conditionals.

Lazarus 1.1 r38924 FPC 2.6.1 i386-linux-gtk 2
TagsNo tags attached.
Fixed in Revision39530
LazTarget1.2
Widgetset
Attached Files
  • lazreport-frf.diff (3,086 bytes)
    Index: components/lazreport/source/lr_class.pas
    ===================================================================
    --- components/lazreport/source/lr_class.pas	(revision 38924)
    +++ components/lazreport/source/lr_class.pas	(working copy)
    @@ -2143,11 +2143,22 @@
         Read(dy, 4);
         Read(Flags, 2);
     
    -    S := 0;
    -    Read(S, SizeOf(S)); fFrameWidth := S;
    -    Read(fFrameColor, SizeOf(fFrameColor));
    -    Read(fFrames,SizeOf(fFrames));
    -    Read(fFrameStyle, SizeOf(fFrameStyle));
    +    if frVersion > 23 then
    +    begin
    +      S := 0;
    +      Read(S, SizeOf(S)); fFrameWidth := S;
    +      Read(fFrameColor, SizeOf(fFrameColor));
    +      Read(fFrames,SizeOf(fFrames));
    +      Read(fFrameStyle, SizeOf(fFrameStyle));
    +    end
    +    else
    +    begin
    +      Read(fFrames,2{SizeOf(fFrames)});
    +      S := 0;
    +      Read(S, SizeOf(S)); fFrameWidth := S;
    +      Read(fFrameColor, SizeOf(fFrameColor));
    +      Read(fFrameStyle, 2{SizeOf(fFrameStyle)});
    +    end;
     
         Read(fFillColor, 4);
     
    @@ -3542,6 +3553,8 @@
         Font.Style := frSetFontStyle(w);
         Read(i, 4);
         Font.Color := i;
    +    if frVersion <= 23 then
    +      Read(Adjust, 4);
         Read(w, 2);
         if frVersion < 23 then
           w := frCharset;
    @@ -3552,17 +3565,19 @@
           HighlightStr := ReadString(Stream);
         end;
         
    +    if frVersion >23 then
    +    begin
    +      Read(TmpAlign{%H-},SizeOf(TmpAlign));
    +      Read(TmpLayout{%H-},SizeOf(TmpLayout));
    +      tmpAngle := 0;
    +      Read(tmpAngle,SizeOf(tmpAngle));
     
    -    Read(TmpAlign{%H-},SizeOf(TmpAlign));
    -    Read(TmpLayout{%H-},SizeOf(TmpLayout));
    -    tmpAngle := 0;
    -    Read(tmpAngle,SizeOf(tmpAngle));
    -
    -    BeginUpdate;
    -    Alignment := tmpAlign;
    -    Layout := tmpLayout;
    -    Angle := tmpAngle;
    -    EndUpdate;
    +      BeginUpdate;
    +      Alignment := tmpAlign;
    +      Layout := tmpLayout;
    +      Angle := tmpAngle;
    +      EndUpdate;
    +    end;
       end;
     
       if frVersion = 21 then
    @@ -3913,12 +3928,15 @@
     procedure TfrBandView.LoadFromStream(Stream: TStream);
     begin
       inherited LoadFromStream(Stream);
    -  
    -  With Stream do
    +
    +  if frVersion > 23 then
       begin
    -    Read(fBandType,SizeOf(BandType));
    -    fCondition :=ReadString(Stream);
    -    fDataSetStr:=ReadString(Stream);
    +    With Stream do
    +    begin
    +      Read(fBandType,SizeOf(BandType));
    +      fCondition :=ReadString(Stream);
    +      fDataSetStr:=ReadString(Stream);
    +    end;
       end;
     end;
     
    @@ -7158,7 +7176,8 @@
         Read(fColGap, 4);
         if frVersion>23 then                          //todo: - remove this
           Read(ord(APageType), SizeOf(TfrPageType));  //todo: - remove this
    -    Read(fLayoutOrder, 4);
    +    if frVersion>23 then
    +      Read(fLayoutOrder, 4);
       end;
       ChangePaper(pgSize, Width, Height, Orientation);
     end;
    @@ -7983,7 +8002,10 @@
           j := AddValue;
           with Objects[j] do
           begin
    -        ReadBuffer(Typ, SizeOf(Typ));
    +        if frVersion > 23 then
    +          ReadBuffer(Typ, SizeOf(Typ))
    +        else
    +          ReadBuffer(Typ, 1{SizeOf(Typ)});
             ReadBuffer(OtherKind, SizeOf(OtherKind));
             DataSet := ReadStr;
             Field := ReadStr;
    
    lazreport-frf.diff (3,086 bytes)

Relationships

related to 0023961 closedJesus Reyes Lazarus LazReport marks all frf bands as ReportTitle bands 
related to 0025037 resolvedJesus Reyes Packages lost fast report .frf opening possibility 

Activities

2012-10-04 22:40

 

lazreport-frf.diff (3,086 bytes)
Index: components/lazreport/source/lr_class.pas
===================================================================
--- components/lazreport/source/lr_class.pas	(revision 38924)
+++ components/lazreport/source/lr_class.pas	(working copy)
@@ -2143,11 +2143,22 @@
     Read(dy, 4);
     Read(Flags, 2);
 
-    S := 0;
-    Read(S, SizeOf(S)); fFrameWidth := S;
-    Read(fFrameColor, SizeOf(fFrameColor));
-    Read(fFrames,SizeOf(fFrames));
-    Read(fFrameStyle, SizeOf(fFrameStyle));
+    if frVersion > 23 then
+    begin
+      S := 0;
+      Read(S, SizeOf(S)); fFrameWidth := S;
+      Read(fFrameColor, SizeOf(fFrameColor));
+      Read(fFrames,SizeOf(fFrames));
+      Read(fFrameStyle, SizeOf(fFrameStyle));
+    end
+    else
+    begin
+      Read(fFrames,2{SizeOf(fFrames)});
+      S := 0;
+      Read(S, SizeOf(S)); fFrameWidth := S;
+      Read(fFrameColor, SizeOf(fFrameColor));
+      Read(fFrameStyle, 2{SizeOf(fFrameStyle)});
+    end;
 
     Read(fFillColor, 4);
 
@@ -3542,6 +3553,8 @@
     Font.Style := frSetFontStyle(w);
     Read(i, 4);
     Font.Color := i;
+    if frVersion <= 23 then
+      Read(Adjust, 4);
     Read(w, 2);
     if frVersion < 23 then
       w := frCharset;
@@ -3552,17 +3565,19 @@
       HighlightStr := ReadString(Stream);
     end;
     
+    if frVersion >23 then
+    begin
+      Read(TmpAlign{%H-},SizeOf(TmpAlign));
+      Read(TmpLayout{%H-},SizeOf(TmpLayout));
+      tmpAngle := 0;
+      Read(tmpAngle,SizeOf(tmpAngle));
 
-    Read(TmpAlign{%H-},SizeOf(TmpAlign));
-    Read(TmpLayout{%H-},SizeOf(TmpLayout));
-    tmpAngle := 0;
-    Read(tmpAngle,SizeOf(tmpAngle));
-
-    BeginUpdate;
-    Alignment := tmpAlign;
-    Layout := tmpLayout;
-    Angle := tmpAngle;
-    EndUpdate;
+      BeginUpdate;
+      Alignment := tmpAlign;
+      Layout := tmpLayout;
+      Angle := tmpAngle;
+      EndUpdate;
+    end;
   end;
 
   if frVersion = 21 then
@@ -3913,12 +3928,15 @@
 procedure TfrBandView.LoadFromStream(Stream: TStream);
 begin
   inherited LoadFromStream(Stream);
-  
-  With Stream do
+
+  if frVersion > 23 then
   begin
-    Read(fBandType,SizeOf(BandType));
-    fCondition :=ReadString(Stream);
-    fDataSetStr:=ReadString(Stream);
+    With Stream do
+    begin
+      Read(fBandType,SizeOf(BandType));
+      fCondition :=ReadString(Stream);
+      fDataSetStr:=ReadString(Stream);
+    end;
   end;
 end;
 
@@ -7158,7 +7176,8 @@
     Read(fColGap, 4);
     if frVersion>23 then                          //todo: - remove this
       Read(ord(APageType), SizeOf(TfrPageType));  //todo: - remove this
-    Read(fLayoutOrder, 4);
+    if frVersion>23 then
+      Read(fLayoutOrder, 4);
   end;
   ChangePaper(pgSize, Width, Height, Orientation);
 end;
@@ -7983,7 +8002,10 @@
       j := AddValue;
       with Objects[j] do
       begin
-        ReadBuffer(Typ, SizeOf(Typ));
+        if frVersion > 23 then
+          ReadBuffer(Typ, SizeOf(Typ))
+        else
+          ReadBuffer(Typ, 1{SizeOf(Typ)});
         ReadBuffer(OtherKind, SizeOf(OtherKind));
         DataSet := ReadStr;
         Field := ReadStr;
lazreport-frf.diff (3,086 bytes)

Stephano

2012-10-05 08:20

developer   ~0062890

The patch still has the following shortcomings:
- It does not distinguish the band type
- It does not read the dataset name

Jesus Reyes

2012-12-09 21:15

developer   ~0064220

please attach a sample version 23 frf file

Stephano

2012-12-11 20:31

developer   ~0064245

Many version 23 frf files are in the demo folder in:
http://www.fast-report.com/pbc_download/fr234.zip

Some of these fail to load even with the patch applied.

Stephano

2012-12-13 20:42

developer   ~0064287

Last edited: 2012-12-13 20:43

As of rev 39529, frf reports can be opened except:
Demos/REPORTS/123.frf, Demos/CNVREPS/fmt2217.frf:
Unsupported FRF format
List index (10) out of bounds

Demos/REPORTS/DOC4.frf: Lazarus crashes

Demos/CNVREPS/fmt22.frf: Unsupported FRF format

Jesus Reyes

2012-12-13 22:32

developer   ~0064289

Last edited: 2012-12-13 22:38

DOC4.frf fixed.

123.frf I consider this report corrupt, it's supposed to be version 2.3, but strings are encoded differently.

fmt22.frf is format version 2.2 and as far as I can tell reading the code from fr234, it's also not supported in that version, why should LazReport?

BTW I don't think this old format reports have any relevance currently (including 2.3 version), LazReport should focus on lrf report format, or, should I ask, do you have that much old reports and you want to convert them to LazReport?

Stephano

2012-12-14 09:51

developer   ~0064295

Support for frf 2.3 to lrf is important for older Delphi projects to be converted to Lazarus. Furthermore, there were lots of frversion > 23 conditionals in the LazReport code showing that LazReport used to support frf 2.3 in the past. The sets size change (FPC 2.4?) is the main culprit behind the breaking of that support.

I had converted some old reports (from old Delphi projects) with my patch, although with some manual intervention. Your patch converts the same files smoothly.

DOC4.frf is now OK as well

Issue History

Date Modified Username Field Change
2012-10-04 22:40 Stephano New Issue
2012-10-04 22:40 Stephano File Added: lazreport-frf.diff
2012-10-04 22:40 Stephano LazTarget => -
2012-10-04 22:43 Stephano Status new => assigned
2012-10-04 22:43 Stephano Assigned To => Jesus Reyes
2012-10-05 08:20 Stephano Note Added: 0062890
2012-12-09 21:15 Jesus Reyes Note Added: 0064220
2012-12-09 21:15 Jesus Reyes Status assigned => feedback
2012-12-11 20:31 Stephano Note Added: 0064245
2012-12-13 20:42 Stephano Note Added: 0064287
2012-12-13 20:43 Stephano Note Edited: 0064287
2012-12-13 22:32 Jesus Reyes Fixed in Revision => 39530
2012-12-13 22:32 Jesus Reyes LazTarget - => 1.2
2012-12-13 22:32 Jesus Reyes Status feedback => resolved
2012-12-13 22:32 Jesus Reyes Fixed in Version => 1.1 (SVN)
2012-12-13 22:32 Jesus Reyes Resolution open => fixed
2012-12-13 22:32 Jesus Reyes Note Added: 0064289
2012-12-13 22:32 Jesus Reyes Target Version => 1.2.0
2012-12-13 22:38 Jesus Reyes Note Edited: 0064289
2012-12-14 09:51 Stephano Note Added: 0064295
2012-12-14 09:52 Stephano Status resolved => closed
2013-02-26 15:51 Stephano Relationship added related to 0023961
2013-09-18 14:00 Stephano Relationship added related to 0025037