User: hr      
Date: 2007-08-03 09:49:52+0000
Modified:
   
dba/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/OfficeGroupLayoutController.java

Log:
 INTEGRATION: CWS rpt23fix02 (1.2.4); FILE MERGED
 2007/07/25 15:05:45 tmorgner 1.2.4.1: Issue number:  78128
 
 This commit fixes the messed up repeating-header system. The whole thing has
 been redesigned to create a clean state-flow that can be debugged and traced
 without any weird mind-bending activities. The report-targets now have a
 new state (IN_GROUP_INSTANCE) to keep track of the group's processing and
 to separate repeating headers and footers from ordinary headers and footers.
 
 This patch also enforces a clean state-flow in the OfficeReportOutputTarget
 and explicitly checks for all allowed band-types and throws exceptions on
 every illegal state.

File Changes:

Directory: /dba/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/
==============================================================================

File [changed]: OfficeGroupLayoutController.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/OfficeGroupLayoutController.java?r1=1.2&r2=1.3
Delta lines:  +32 -31
---------------------
--- OfficeGroupLayoutController.java    2007-07-09 11:56:05+0000        1.2
+++ OfficeGroupLayoutController.java    2007-08-03 09:49:50+0000        1.3
@@ -40,15 +40,16 @@
 import com.sun.star.report.pentaho.OfficeNamespaces;
 import com.sun.star.report.pentaho.model.OfficeGroup;
 import com.sun.star.report.pentaho.model.OfficeGroupSection;
-import com.sun.star.report.pentaho.model.VariablesDeclarationSection;
+import org.jfree.layouting.util.AttributeMap;
 import org.jfree.report.DataSourceException;
 import org.jfree.report.ReportDataFactoryException;
 import org.jfree.report.ReportProcessingException;
 import org.jfree.report.flow.FlowController;
 import org.jfree.report.flow.ReportTarget;
+import org.jfree.report.flow.layoutprocessor.ElementLayoutController;
 import org.jfree.report.flow.layoutprocessor.LayoutController;
 import org.jfree.report.flow.layoutprocessor.SectionLayoutController;
-import org.jfree.report.flow.layoutprocessor.ElementLayoutController;
+import org.jfree.report.structure.Element;
 
 /**
  * Todo: Document me!
@@ -61,11 +62,12 @@
 {
   public static final int STATE_PROCESS_REPEATING_HEADER = 0;
   public static final int STATE_PROCESS_REPEATING_FOOTER = 1;
-  public static final int STATE_PROCESS_VARIABLES = 2;
   public static final int STATE_PROCESS_NORMAL_FLOW = 3;
   private boolean waitForJoin;
   private int state;
   private VariablesCollection variablesCollection;
+  private boolean repeatHeader;
+  private boolean repeatFooter;
 
   public OfficeGroupLayoutController()
   {
@@ -99,6 +101,14 @@
     super.initialize(node, flowController, parent);
     state = OfficeGroupLayoutController.STATE_PROCESS_REPEATING_HEADER;
     variablesCollection = new VariablesCollection(computeVariablesPrefix());
+
+
+    final OfficeGroup group = (OfficeGroup) getElement();
+    final OfficeGroupSection header = group.getHeader();
+    repeatHeader = (header != null && header.isRepeatSection());
+
+    final OfficeGroupSection footer = group.getFooter();
+    repeatFooter = (footer != null && footer.isRepeatSection());
   }
 
 
@@ -108,65 +118,47 @@
   {
     if (state == OfficeGroupLayoutController.STATE_PROCESS_REPEATING_HEADER)
     {
-      final OfficeGroup group = (OfficeGroup) getElement();
-      final OfficeGroupSection header =
-          (OfficeGroupSection) group.findFirstChild
-          (OfficeNamespaces.OOREPORT_NS, "group-header");
 
       final OfficeGroupLayoutController controller =
           (OfficeGroupLayoutController) clone();
       controller.state =
           OfficeGroupLayoutController.STATE_PROCESS_REPEATING_FOOTER;
 
-      if (header == null || header.isRepeatSection() == false)
+      if (repeatHeader == false)
       {
         return controller;
       }
 
+      final OfficeGroup group = (OfficeGroup) getElement();
+      final OfficeGroupSection header = group.getHeader();
       controller.waitForJoin = true;
       return processChild(controller, header, getFlowController());
     }
 
     if (state == OfficeGroupLayoutController.STATE_PROCESS_REPEATING_FOOTER)
     {
-      final OfficeGroup group = (OfficeGroup) getElement();
-      final OfficeGroupSection footer =
-          (OfficeGroupSection) group.findFirstChild
-          (OfficeNamespaces.OOREPORT_NS, "group-footer");
 
       final OfficeGroupLayoutController controller =
           (OfficeGroupLayoutController) clone();
-      controller.state =
-          OfficeGroupLayoutController.STATE_PROCESS_VARIABLES;
+      controller.state = OfficeGroupLayoutController.STATE_PROCESS_NORMAL_FLOW;
 
-      if (footer == null || footer.isRepeatSection() == false)
+      if (repeatFooter == false)
       {
         return controller;
       }
 
+      final OfficeGroup group = (OfficeGroup) getElement();
+      final OfficeGroupSection footer = group.getFooter();
       controller.waitForJoin = true;
       return processChild(controller, footer, getFlowController());
     }
 
-    if (state == OfficeGroupLayoutController.STATE_PROCESS_VARIABLES)
-    {
-      // todo: Fill the variables section with something sensible ..
-      final VariablesDeclarationSection variables =
-          new VariablesDeclarationSection();
-      final OfficeGroupLayoutController controller =
-          (OfficeGroupLayoutController) clone();
-      controller.state =
-          OfficeGroupLayoutController.STATE_PROCESS_NORMAL_FLOW;
-      controller.waitForJoin = true;
-      return processChild(controller, variables, getFlowController());
-    }
     return super.processContent(target);
   }
 
   protected void resetSectionForRepeat()
   {
     super.resetSectionForRepeat();
-    state = STATE_PROCESS_VARIABLES;
   }
 
   /**
@@ -215,4 +207,13 @@
   {
     return variablesCollection;
   }
+
+  protected AttributeMap computeAttributes(final FlowController fc, final 
Element element, final ReportTarget target)
+      throws DataSourceException
+  {
+    final AttributeMap map = super.computeAttributes(fc, element, target);
+    final String value = String.valueOf(repeatHeader || repeatFooter);
+    map.setAttribute(OfficeNamespaces.INTERNAL_NS, 
"repeating-header-or-footer", value);
+    return map;
+  }
 }




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to