Browse Source

* Patch from Pascal Riekenberg: ApplyBandWidth: handle child bands like main parent band

git-svn-id: trunk@37481 -
michael 7 years ago
parent
commit
2af27756da
1 changed files with 20 additions and 4 deletions
  1. 20 4
      packages/fcl-report/src/fpreport.pp

+ 20 - 4
packages/fcl-report/src/fpreport.pp

@@ -841,6 +841,7 @@ type
   TFPReportCustomBand = class(TFPReportElementWithChildren)
   TFPReportCustomBand = class(TFPReportElementWithChildren)
   private
   private
     FChildBand: TFPReportChildBand;
     FChildBand: TFPReportChildBand;
+    FParentBand: TFPReportCustomBand;
     FKeepTogetherWithChildren: Boolean;
     FKeepTogetherWithChildren: Boolean;
     FUseParentFont: boolean;
     FUseParentFont: boolean;
     FVisibleOnPage: TFPReportVisibleOnPage;
     FVisibleOnPage: TFPReportVisibleOnPage;
@@ -887,6 +888,7 @@ type
     property    VisibleOnPage: TFPReportVisibleOnPage read FVisibleOnPage write SetVisibleOnPage;
     property    VisibleOnPage: TFPReportVisibleOnPage read FVisibleOnPage write SetVisibleOnPage;
     function    EvaluateVisibility: boolean; override;
     function    EvaluateVisibility: boolean; override;
     property    ChildBand: TFPReportChildBand read FChildBand write SetChildBand;
     property    ChildBand: TFPReportChildBand read FChildBand write SetChildBand;
+    property    ParentBand: TFPReportCustomBand read FParentBand;
     property    Page : TFPReportCustomPage read GetReportPage;
     property    Page : TFPReportCustomPage read GetReportPage;
   end;
   end;
   TFPReportCustomBandClass = Class of TFPReportCustomBand;
   TFPReportCustomBandClass = Class of TFPReportCustomBand;
@@ -6673,12 +6675,21 @@ begin
 end;
 end;
 
 
 procedure TFPReportCustomPage.ApplyBandWidth(ABand: TFPReportCustomBand);
 procedure TFPReportCustomPage.ApplyBandWidth(ABand: TFPReportCustomBand);
+
+var
+  lBand: TFPReportCustomBand;
+
 begin
 begin
+  lBand := ABand;
+  if ABand is TFPReportCustomChildBand then
+    { handle child bands like main parent band }
+    while Assigned(lBand.ParentBand) do
+      lBand := lBand.ParentBand;
   { set Band Width appropriately - certain bands are not affected by ColumnCount }
   { set Band Width appropriately - certain bands are not affected by ColumnCount }
-  if (ABand is TFPReportCustomTitleBand)
-      or (ABand is TFPReportCustomSummaryBand)
-      or (ABand is TFPReportCustomPageHeaderBand)
-      or (ABand is TFPReportCustomPageFooterBand) then
+  if (lBand is TFPReportCustomTitleBand)
+      or (lBand is TFPReportCustomSummaryBand)
+      or (lBand is TFPReportCustomPageHeaderBand)
+      or (lBand is TFPReportCustomPageFooterBand) then
     ABand.Layout.Width := Layout.Width
     ABand.Layout.Width := Layout.Width
   else
   else
     ABand.Layout.Width := BandWidthFromColumnCount;
     ABand.Layout.Width := BandWidthFromColumnCount;
@@ -7669,6 +7680,11 @@ begin
     if b = self then
     if b = self then
       raise EReportError.Create(SErrChildBandCircularReference);
       raise EReportError.Create(SErrChildBandCircularReference);
   end;
   end;
+  if Assigned(FChildBand) then
+  begin
+    FChildBand.FParentBand := Self;
+    Page.ApplyBandWidth(FChildBand);
+  end;
 end;
 end;
 
 
 procedure TFPReportCustomBand.ApplyStretchMode;
 procedure TFPReportCustomBand.ApplyStretchMode;