浏览代码

* Put elements that are not on any band on a null band

git-svn-id: trunk@38933 -
michael 7 年之前
父节点
当前提交
d37b1b631e
共有 1 个文件被更改,包括 25 次插入2 次删除
  1. 25 2
      packages/fcl-report/src/fplazreport.pp

+ 25 - 2
packages/fcl-report/src/fplazreport.pp

@@ -42,11 +42,12 @@ Type
     FOnSetCustomProps: TCustomPropEvent;
     FOnSetCustomProps: TCustomPropEvent;
     FOnSubstituteFont: TFontSubstitutionEvent;
     FOnSubstituteFont: TFontSubstitutionEvent;
     FCounter : Integer;
     FCounter : Integer;
+    FNullBand : TFPReportChildBand;
   Protected
   Protected
     class function Red(rgb: Integer): BYTE; virtual;
     class function Red(rgb: Integer): BYTE; virtual;
     class function Green(rgb: Integer): BYTE; virtual;
     class function Green(rgb: Integer): BYTE; virtual;
     class function Blue(rgb: Integer): BYTE; virtual;
     class function Blue(rgb: Integer): BYTE; virtual;
-    class function FindBand(aPage: TFPReportCustomPage; aTop: double): TFPReportCustomBand; virtual;
+    function FindBand(aPage: TFPReportCustomPage; aTop: double; AElement: TFPReportElement=Nil): TFPReportCustomBand; virtual;
     class function GetProperty(aNode: TDOMNode; const aName: String; const aValue: string='Value'): UTF8String; virtual;
     class function GetProperty(aNode: TDOMNode; const aName: String; const aValue: string='Value'): UTF8String; virtual;
     function ApplyFrame(aDataNode: TDOMNode; aFrame: TFPReportFrame): Boolean; virtual;
     function ApplyFrame(aDataNode: TDOMNode; aFrame: TFPReportFrame): Boolean; virtual;
     procedure ApplyObjectProperties(ObjNode: TDOMNode; aObj: TFPReportElement); virtual;
     procedure ApplyObjectProperties(ObjNode: TDOMNode; aObj: TFPReportElement); virtual;
@@ -95,6 +96,7 @@ Resourcestring
   SUnknownBarcodeType = 'Unknown barcode type: "%s"';
   SUnknownBarcodeType = 'Unknown barcode type: "%s"';
   SIgnoringAngleOnBarcode = 'Igoring angle on barcode';
   SIgnoringAngleOnBarcode = 'Igoring angle on barcode';
   SIgnoringShowTextOnBarcode = 'Igoring showtext on barcode';
   SIgnoringShowTextOnBarcode = 'Igoring showtext on barcode';
+  SLogNullBandAssigned = 'Null (child) band assigned for element of type "%s" at pos %5.3f';
 
 
 function PixelsToMM(Const Dist: double) : TFPReportUnits;
 function PixelsToMM(Const Dist: double) : TFPReportUnits;
 begin
 begin
@@ -228,9 +230,11 @@ begin
       Result := UTF8Encode(bNode.Attributes.GetNamedItem(aValue).NodeValue);
       Result := UTF8Encode(bNode.Attributes.GetNamedItem(aValue).NodeValue);
 end;
 end;
 
 
-Class function TFPLazReport.FindBand(aPage : TFPReportCustomPage;aTop : double) : TFPReportCustomBand;
+function TFPLazReport.FindBand(aPage : TFPReportCustomPage;aTop : double; AElement : TFPReportElement = Nil) : TFPReportCustomBand;
 var
 var
   b : Integer;
   b : Integer;
+  S : String;
+
 begin
 begin
   Result := nil;
   Result := nil;
   for b := 0 to aPage.BandCount-1 do
   for b := 0 to aPage.BandCount-1 do
@@ -242,6 +246,25 @@ begin
           break;
           break;
         end;
         end;
     end;
     end;
+  if (Result=Nil) then
+    begin
+    if (FNullBand=Nil) then
+      begin
+      FNullBand:=TFPReportChildBand.Create(Self);
+      FNullBand.Name:='NullBand';
+      FNullBand.Layout.Height:=aPage.Layout.Height;
+      FNullBand.Parent:=aPage;
+      end;
+    Result:=FNullBand;
+    end;
+  if (Result=FNullBand) and Assigned(FOnLog) then
+    begin
+    if aElement = Nil then
+      S:='<unknown>'
+    else
+      S:=aElement.ClassName;
+    DoLog(SLogNullBandAssigned,[S,aTop]);
+    end;
 end;
 end;
 
 
 Function TFPLazReport.ConvertBand(aBandNode : TDomNode;aPage: TFPReportCustomPage) : TFPReportCustomBand;
 Function TFPLazReport.ConvertBand(aBandNode : TDomNode;aPage: TFPReportCustomPage) : TFPReportCustomBand;