View Issue Details

IDProjectCategoryView StatusLast Update
0018647PackagesLazReportpublic2011-10-14 22:26
ReporterJack Assigned ToJesus Reyes  
PrioritynormalSeveritytweakReproducibilityalways
Status resolvedResolutionfixed 
Fixed in Version0.9.31 (SVN) 
Summary0018647: Set CurReport in CompositeReport
DescriptionSorry for my english.

How to determine currently processig Report in event CompositeReport.OnBeginDoc?
I add one line in procedure TfrCompositeReport.DoBuildReport to set variable CurReport.
Bellow is changed procedure

Lazarus 0.9.28.2 r22279 FPC 2.2.4 i386-win32-win32/win64
Additional Informationprocedure TfrCompositeReport.DoBuildReport;
var
  i: Integer;
  Doc: TfrReport;
  ParamOk: Boolean;
begin
  CanRebuild := True;
  PageNo := 0;
  for i := 0 to Reports.Count - 1 do
  begin
    Doc := TfrReport(Reports[i]);
    CompositeMode := False;
    if i <> Reports.Count - 1 then
      if (TfrReport(Reports[i + 1]).Pages.Count > 0) and
        TfrReport(Reports[i + 1]).Pages[0].PrintToPrevPage then
        CompositeMode := True;
    CurReport:= Doc; // ADD THIS LINE
    if Assigned(Doc.FOnBeginDoc) and FirstTime then
      Doc.FOnBeginDoc;
    ParamOk := True;
    if (frDataManager <> nil) and FirstTime then
    begin
      Doc.FillQueryParams;
      ParamOk := frDataManager.ShowParamsDialog;
    end;
    if ParamOk then
      Doc.DoBuildReport;
    if (frDataManager <> nil) and FinalPass then
      frDataManager.AfterParamsDialog;
    if Assigned(Doc.FOnEndDoc) and FinalPass then
      Doc.FOnEndDoc;
    Append := CompositeMode;
    CompositeMode := False;
    if Terminated then break;
  end;
end;
TagsNo tags attached.
Fixed in Revision32891
LazTarget0.99.0
Widgetset
Attached Files

Activities

Jack

2011-01-31 23:20

reporter   ~0045652

I added TfrEMFPages.AddFromStream procedure in order to combine several reports.
Usage:
Prepare any report,
save it to a stream using report.EMFPages.SaveToStream(stream)
go to begin of stream stream.Position: = 0,
use the new procedure result_report.EMFPages.AddFromStream(stream) to add prepared_report to result_report,
repeat these steps for other reports. Finally, print result_report.
PS: Sorry for my english.

Diff is from: Lazarus 0.9.31 r29240 i386-win32-win32/win64

2011-01-31 23:20

 

lr_class.pas.diff (2,317 bytes)   
--- lr_class.pas.old	2011-01-10 07:16:38.000000000 +0100
+++ lr_class.pas	2011-01-31 20:52:20.296875000 +0100
@@ -810,6 +810,7 @@
     procedure Insert(Index: Integer; APage: TfrPage);
     procedure Delete(Index: Integer);
     procedure LoadFromStream(AStream: TStream);
+    procedure AddFromStream(AStream: TStream);       //add pages
     procedure LoadFromXML(XML: TLrXMLConfig; const Path: String);
     procedure SaveToStream(AStream: TStream);
     procedure SaveToXML(XML: TLrXMLConfig; const Path: String);
@@ -7426,6 +7427,59 @@
   until i >= c;
 end;
 
+procedure TfrEMFPages.AddFromStream(AStream: TStream);
+var
+  i, o, c: Integer;
+  b, compr: Byte;
+  p: PfrPageInfo;
+  s: TMemoryStream;
+
+begin
+  //Clear;
+  AStream.Read(compr, 1);
+  if not (compr in [0, 1, 255]) then
+  begin
+    Exit;
+  end;
+  Parent.SetPrinterTo(frReadString(AStream));
+  AStream.Read(c, 4);
+  i := 0;
+  repeat
+    AStream.Read(o, 4);
+    GetMem(p, SizeOf(TfrPageInfo));
+    FillChar(p^, SizeOf(TfrPageInfo), #0);
+    FPages.Add(p);
+    with p^ do
+    begin
+      AStream.Read(pgSize, 2);
+      AStream.Read(pgWidth, 4);
+      AStream.Read(pgHeight, 4);
+      AStream.Read(b, 1);
+      pgOr := TPrinterOrientation(b);
+      AStream.Read(b, 1);
+      pgMargins := Boolean(b);
+      if compr <> 0 then
+      begin
+        s := TMemoryStream.Create;
+        s.CopyFrom(AStream, o - AStream.Position);
+        Stream := TMemoryStream.Create;
+        frCompressor.DeCompress(s, Stream);
+        s.Free;
+      end
+      else
+      begin
+        Stream := TMemoryStream.Create;
+        Stream.CopyFrom(AStream, o - AStream.Position);
+      end;
+      Prn.SetPrinterInfo(pgSize, pgWidth, pgHeight, pgOr);
+      Prn.FillPrnInfo(PrnInfo);
+    end;
+    AStream.Seek(o, soFromBeginning);
+    Inc(i);
+  until i >= c;
+end;
+
+
 procedure TfrEMFPages.LoadFromXML(XML: TLrXMLConfig; const Path: String);
 begin
   // todo
@@ -9252,6 +9306,7 @@
       if (TfrReport(Reports[i + 1]).Pages.Count > 0) and
         TfrReport(Reports[i + 1]).Pages[0].PrintToPrevPage then
         CompositeMode := True;
+    CurReport := Doc;
     if Assigned(Doc.FOnBeginDoc) and FirstTime then
       Doc.FOnBeginDoc;
     ParamOk := True;
lr_class.pas.diff (2,317 bytes)   

Jesus Reyes

2011-10-14 22:25

developer   ~0052986

Thanks, I Modified the patch refactoring LoadFromStream, please test.

Issue History

Date Modified Username Field Change
2011-01-31 12:24 Jack New Issue
2011-01-31 23:20 Jack Note Added: 0045652
2011-01-31 23:20 Jack File Added: lr_class.pas.diff
2011-10-14 20:35 Vincent Snijders Status new => assigned
2011-10-14 20:35 Vincent Snijders Assigned To => Jesus Reyes
2011-10-14 20:35 Vincent Snijders Project Lazarus CCR => Packages
2011-10-14 20:36 Vincent Snijders LazTarget => 0.99.0
2011-10-14 20:36 Vincent Snijders Target Version => 0.99
2011-10-14 22:25 Jesus Reyes Fixed in Revision => 32891
2011-10-14 22:25 Jesus Reyes Status assigned => resolved
2011-10-14 22:25 Jesus Reyes Fixed in Version => 0.9.31 (SVN)
2011-10-14 22:25 Jesus Reyes Resolution open => fixed
2011-10-14 22:25 Jesus Reyes Note Added: 0052986