Tag: cws_src680_pentaho1
User: tmorgner
Date: 2008-01-15 13:46:53+0000
Added:
   
dba/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/OfficePageSectionLayoutController.java

Modified:
   
dba/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/OfficeReportLayoutController.java
   
dba/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/OfficeTableTemplateLayoutController.java
   
dba/reportdesign/java/com/sun/star/report/pentaho/output/OfficeDocumentReportTarget.java
   
dba/reportdesign/java/com/sun/star/report/pentaho/output/spreadsheet/SpreadsheetRawReportTarget.java
   
dba/reportdesign/java/com/sun/star/report/pentaho/output/text/TextRawReportTarget.java

Log:
 Issue number:  79173
 
 The report engine now duplicates the page-header and footer sections 
 at the correct position to be inserted into a spreadsheet document. The
 text-document output silently ignores these new header definitions. 
 
 Although this solution is a slight waste of computing cycles, it provides
 a relatively non-intrusive solution to the problem that spreadsheet documents
 do not have per-page headers and footers like text-documents have.
 
 The spreadsheet export is treated as a single page; manual pagebreaks are
 ignored. 
 
 

File Changes:

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

File [added]: OfficePageSectionLayoutController.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/OfficePageSectionLayoutController.java?rev=1.1.2.1&content-type=text/vnd.viewcvs-markup
Added lines: 28
---------------
package com.sun.star.report.pentaho.layoutprocessor;

import org.jfree.report.flow.layoutprocessor.SectionLayoutController;
import org.jfree.report.flow.FlowController;
import org.jfree.report.flow.ReportTarget;
import org.jfree.report.structure.Element;
import org.jfree.report.DataSourceException;
import org.jfree.layouting.util.AttributeMap;
import com.sun.star.report.pentaho.OfficeNamespaces;

/**
 * Todo: Document Me
 *
 * @author Thomas Morgner
 */
public class OfficePageSectionLayoutController extends SectionLayoutController
{
  public OfficePageSectionLayoutController()
  {
  }

  protected AttributeMap computeAttributes(final FlowController flowController, 
final Element element, final ReportTarget reportTarget) throws 
DataSourceException
  {
    final AttributeMap map = super.computeAttributes(flowController, element, 
reportTarget);
    map.setAttribute(OfficeNamespaces.INTERNAL_NS, "role", 
"spreadsheet-section");
    return map;
  }
}

File [changed]: OfficeReportLayoutController.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/OfficeReportLayoutController.java?r1=1.2&r2=1.2.40.1
Delta lines:  +40 -12
---------------------
--- OfficeReportLayoutController.java   2007-07-09 11:56:05+0000        1.2
+++ OfficeReportLayoutController.java   2008-01-15 13:46:50+0000        1.2.40.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: OfficeReportLayoutController.java,v $
  *
- *  $Revision: 1.2 $
+ *  $Revision: 1.2.40.1 $
  *
- *  last change: $Author: rt $ $Date: 2007/07/09 11:56:05 $
+ *  last change: $Author: tmorgner $ $Date: 2008/01/15 13:46:50 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -63,13 +63,15 @@
   private static final int STATE_TEMPLATES = 1;
   private static final int STATE_PAGE_HEADER_DONE = 2;
   private static final int STATE_PAGE_FOOTER_DONE = 3;
-  private static final int STATE_COLUMN_HEADER_DONE = 4;
-  private static final int STATE_COLUMN_FOOTER_DONE = 5;
-  private static final int STATE_INITIAL_VARIABLES_DONE = 6;
-  private static final int STATE_REPORT_HEADER_DONE = 7;
-  private static final int STATE_REPORT_BODY_DONE = 8;
-  private static final int STATE_REPORT_FOOTER_VARIABLES = 9;
-  private static final int STATE_REPORT_FOOTER_DONE = 10;
+  private static final int STATE_SPREADSHEET_PAGE_HEADER_DONE = 4;
+  private static final int STATE_SPREADSHEET_PAGE_FOOTER_DONE = 5;
+  private static final int STATE_COLUMN_HEADER_DONE = 6;
+  private static final int STATE_COLUMN_FOOTER_DONE = 7;
+  private static final int STATE_INITIAL_VARIABLES_DONE = 8;
+  private static final int STATE_REPORT_HEADER_DONE = 9;
+  private static final int STATE_REPORT_BODY_DONE = 10;
+  private static final int STATE_REPORT_FOOTER_VARIABLES = 11;
+  private static final int STATE_REPORT_FOOTER_DONE = 12;
 
   private int state;
   private VariablesCollection variablesCollection;
@@ -133,7 +135,7 @@
     {
       case OfficeReportLayoutController.STATE_NOT_STARTED:
       {
-        return 
delegateToTemplace(OfficeReportLayoutController.STATE_TEMPLATES);
+        return 
delegateToTemplates(OfficeReportLayoutController.STATE_TEMPLATES);
       }
       case OfficeReportLayoutController.STATE_TEMPLATES:
       {
@@ -142,6 +144,11 @@
       }
       case OfficeReportLayoutController.STATE_PAGE_HEADER_DONE:
       {
+        return delegateSpreadsheetSection(or.getPageHeader(),
+            OfficeReportLayoutController.STATE_SPREADSHEET_PAGE_HEADER_DONE);
+      }
+      case OfficeReportLayoutController.STATE_SPREADSHEET_PAGE_HEADER_DONE:
+      {
         return delegateSection(or.getPageFooter(),
             OfficeReportLayoutController.STATE_PAGE_FOOTER_DONE);
       }
@@ -182,18 +189,39 @@
       }
       case OfficeReportLayoutController.STATE_REPORT_FOOTER_DONE:
       {
+        return delegateSpreadsheetSection(or.getPageFooter(),
+            OfficeReportLayoutController.STATE_SPREADSHEET_PAGE_FOOTER_DONE);
+      }
+      case OfficeReportLayoutController.STATE_SPREADSHEET_PAGE_FOOTER_DONE:
+      {
         final OfficeReportLayoutController olc = 
(OfficeReportLayoutController) clone();
         olc.setProcessingState(ElementLayoutController.FINISHING);
         return olc;
       }
       default:
       {
-        throw new IllegalStateException();
+        throw new IllegalStateException("Invalid processing state 
encountered.");
       }
     }
   }
 
-  private LayoutController delegateToTemplace(final int nextState)
+  private LayoutController delegateSpreadsheetSection(final Node node, final 
int nextState)
+      throws DataSourceException, ReportProcessingException, 
ReportDataFactoryException
+  {
+    final OfficeReportLayoutController olc = (OfficeReportLayoutController) 
clone();
+    olc.state = nextState;
+
+    if (node == null)
+    {
+      return olc;
+    }
+    
+    final OfficePageSectionLayoutController templateLc = new 
OfficePageSectionLayoutController();
+    templateLc.initialize(node, getFlowController(), olc);
+    return templateLc;
+  }
+
+  private LayoutController delegateToTemplates(final int nextState)
       throws ReportProcessingException, ReportDataFactoryException,
       DataSourceException
   {

File [changed]: OfficeTableTemplateLayoutController.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/OfficeTableTemplateLayoutController.java?r1=1.2&r2=1.2.40.1
Delta lines:  +10 -2
--------------------
--- OfficeTableTemplateLayoutController.java    2007-07-09 11:56:06+0000        
1.2
+++ OfficeTableTemplateLayoutController.java    2008-01-15 13:46:50+0000        
1.2.40.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: OfficeTableTemplateLayoutController.java,v $
  *
- *  $Revision: 1.2 $
+ *  $Revision: 1.2.40.1 $
  *
- *  last change: $Author: rt $ $Date: 2007/07/09 11:56:06 $
+ *  last change: $Author: tmorgner $ $Date: 2008/01/15 13:46:50 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -91,6 +91,10 @@
 
     final OfficeReport report = (OfficeReport) node;
     final ArrayList tables = new ArrayList();
+    if (report.getPageHeader() != null)
+    {
+      addFromSection(tables, (Section) report.getPageHeader());
+    }
     if (report.getReportHeader() != null)
     {
       addFromSection(tables, (Section) report.getReportHeader());
@@ -100,6 +104,10 @@
     {
       addFromSection(tables, (Section) report.getReportFooter());
     }
+    if (report.getPageFooter() != null)
+    {
+      addFromSection(tables, (Section) report.getPageFooter());
+    }
 
     this.nodes = (Node[]) tables.toArray(new Node[tables.size()]);
   }

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

File [changed]: OfficeDocumentReportTarget.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/output/OfficeDocumentReportTarget.java?r1=1.3&r2=1.3.32.1
Delta lines:  +25 -9
--------------------
--- OfficeDocumentReportTarget.java     2007-08-03 09:50:45+0000        1.3
+++ OfficeDocumentReportTarget.java     2008-01-15 13:46:50+0000        1.3.32.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: OfficeDocumentReportTarget.java,v $
  *
- *  $Revision: 1.3 $
+ *  $Revision: 1.3.32.1 $
  *
- *  last change: $Author: hr $ $Date: 2007/08/03 09:50:45 $
+ *  last change: $Author: tmorgner $ $Date: 2008/01/15 13:46:50 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -118,6 +118,8 @@
   public static final int ROLE_DETAIL = 9;
   public static final int ROLE_VARIABLES = 10;
   public static final int ROLE_TEMPLATE = 11;
+  public static final int ROLE_SPREADSHEET_PAGE_HEADER = 12;
+  public static final int ROLE_SPREADSHEET_PAGE_FOOTER = 13;
 
   public static final int STATE_IN_DOCUMENT = 0;
   public static final int STATE_IN_BODY = 1;
@@ -495,7 +497,7 @@
     // todo
     if (DEBUG_ELEMENTS)
     {
-      Log.debug("Starting " + getCurrentState() + "/" + states.size() + " " +
+      Log.debug("Starting " + getCurrentState() + '/' + states.size() + ' ' +
           ReportTargetUtil.getNamespaceFromAttribute(attrs) + " -> " +
           ReportTargetUtil.getElemenTypeFromAttribute(attrs));
     }
@@ -554,12 +556,26 @@
             }
             else if 
(ReportTargetUtil.isElementOfType(OfficeNamespaces.OOREPORT_NS, "page-header", 
attrs))
             {
+              if 
("spreadsheet-section".equals(attrs.getAttribute(OfficeNamespaces.INTERNAL_NS, 
"role")))
+              {
+                currentRole = 
OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_HEADER;
+              }
+              else
+              {
               currentRole = OfficeDocumentReportTarget.ROLE_PAGE_HEADER;
             }
+            }
             else if 
(ReportTargetUtil.isElementOfType(OfficeNamespaces.OOREPORT_NS, "page-footer", 
attrs))
             {
+              if 
("spreadsheet-section".equals(attrs.getAttribute(OfficeNamespaces.INTERNAL_NS, 
"role")))
+              {
+                currentRole = 
OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_FOOTER;
+              }
+              else
+              {
               currentRole = OfficeDocumentReportTarget.ROLE_PAGE_FOOTER;
             }
+            }
             else if 
(ReportTargetUtil.isElementOfType(OfficeNamespaces.OOREPORT_NS, 
"report-header", attrs))
             {
               currentRole = OfficeDocumentReportTarget.ROLE_REPORT_HEADER;
@@ -1213,7 +1229,7 @@
     return CSSValueFactory.createLengthValue(cssValue);
   }
 
-  public boolean isRepeatingSection()
+  protected boolean isRepeatingSection()
   {
     return (currentRole == 
OfficeDocumentReportTarget.ROLE_REPEATING_GROUP_FOOTER ||
         currentRole == OfficeDocumentReportTarget.ROLE_REPEATING_GROUP_HEADER 
||
@@ -1268,7 +1284,7 @@
 
         if (imageAreaWidthVal == null || imageAreaHeightVal == null)
         {
-          Log.debug ("Image data returned from context is invalid. Maybe this 
is not an image?");
+          Log.debug("Image data returned from context is invalid. Maybe this 
is not an image?");
           return;
         }
         else

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

File [changed]: SpreadsheetRawReportTarget.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/output/spreadsheet/SpreadsheetRawReportTarget.java?r1=1.3&r2=1.3.32.1
Delta lines:  +67 -65
---------------------
--- SpreadsheetRawReportTarget.java     2007-08-03 09:51:10+0000        1.3
+++ SpreadsheetRawReportTarget.java     2008-01-15 13:46:50+0000        1.3.32.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: SpreadsheetRawReportTarget.java,v $
  *
- *  $Revision: 1.3 $
+ *  $Revision: 1.3.32.1 $
  *
- *  last change: $Author: hr $ $Date: 2007/08/03 09:51:10 $
+ *  last change: $Author: tmorgner $ $Date: 2008/01/15 13:46:50 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -82,6 +82,70 @@
  */
 public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget
 {
+
+  /**
+   * This class represents a column boundary, not in width, but it's actual 
boundary location. One of the motivations
+   * for creating this class was to be able to record the boundaries for each 
incoming table while consuming as few
+   * objects/memory as possible.
+   */
+  private static class ColumnBoundary implements Comparable
+  {
+    private HashSet tableIndices;
+
+    private float boundary;
+
+    private ColumnBoundary(final float boundary)
+    {
+      this.tableIndices = new HashSet();
+      this.boundary = boundary;
+    }
+
+    public void addTableIndex(final int table)
+    {
+      tableIndices.add(IntegerCache.getInteger(table));
+    }
+
+    public float getBoundary()
+    {
+      return boundary;
+    }
+
+    public boolean isContainedByTable(final int table)
+    {
+      final Integer index = IntegerCache.getInteger(table);
+      return tableIndices.contains(index);
+    }
+
+    public int compareTo(final Object arg0)
+    {
+      if (arg0.equals(this))
+      {
+        return 0;
+      }
+      if (arg0 instanceof ColumnBoundary)
+      {
+        if (boundary > ((ColumnBoundary) arg0).boundary)
+        {
+          return 1;
+        }
+        else
+        {
+          return -1;
+        }
+      }
+      return 1;
+    }
+
+    public boolean equals(final Object obj)
+    {
+      if (obj instanceof ColumnBoundary)
+      {
+        return ((ColumnBoundary) obj).boundary == boundary;
+      }
+      return false;
+    }
+  }
+  
   private String tableBackgroundColor; // null means transparent ...
 
   private static final ColumnBoundary[] EMPTY_COLBOUNDS = new 
ColumnBoundary[0];
@@ -691,66 +755,4 @@
     return "application/vnd.oasis.opendocument.spreadsheet";
   }
 
-  /**
-   * This class represents a column boundary, not in width, but it's actual 
boundary location. One of the motivations
-   * for creating this class was to be able to record the boundaries for each 
incoming table while consuming as few
-   * objects/memory as possible.
-   */
-  private static class ColumnBoundary implements Comparable
-  {
-    private HashSet tableIndices;
-
-    private float boundary;
-
-    private ColumnBoundary(final float boundary)
-    {
-      this.tableIndices = new HashSet();
-      this.boundary = boundary;
-    }
-
-    public void addTableIndex(final int table)
-    {
-      tableIndices.add(IntegerCache.getInteger(table));
-    }
-
-    public float getBoundary()
-    {
-      return boundary;
-    }
-
-    public boolean isContainedByTable(final int table)
-    {
-      final Integer index = IntegerCache.getInteger(table);
-      return tableIndices.contains(index);
-    }
-
-    public int compareTo(final Object arg0)
-    {
-      if (arg0.equals(this))
-      {
-        return 0;
-      }
-      if (arg0 instanceof ColumnBoundary)
-      {
-        if (boundary > ((ColumnBoundary) arg0).boundary)
-        {
-          return 1;
-        }
-        else
-        {
-          return -1;
-        }
-      }
-      return 1;
-    }
-
-    public boolean equals(final Object obj)
-    {
-      if (obj instanceof ColumnBoundary)
-      {
-        return ((ColumnBoundary) obj).boundary == boundary;
-      }
-      return false;
-    }
-  }
 }

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

File [changed]: TextRawReportTarget.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/output/text/TextRawReportTarget.java?r1=1.3&r2=1.3.32.1
Delta lines:  +12 -6
--------------------
--- TextRawReportTarget.java    2007-08-03 09:51:21+0000        1.3
+++ TextRawReportTarget.java    2008-01-15 13:46:51+0000        1.3.32.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: TextRawReportTarget.java,v $
  *
- *  $Revision: 1.3 $
+ *  $Revision: 1.3.32.1 $
  *
- *  last change: $Author: hr $ $Date: 2007/08/03 09:51:21 $
+ *  last change: $Author: tmorgner $ $Date: 2008/01/15 13:46:51 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -1031,7 +1031,9 @@
       // repeating sections have other ways of defining columns ..
       return;
     }
-    if (getCurrentRole() == ROLE_TEMPLATE)
+    if (getCurrentRole() == ROLE_TEMPLATE ||
+        getCurrentRole() == ROLE_SPREADSHEET_PAGE_HEADER ||
+        getCurrentRole() == ROLE_SPREADSHEET_PAGE_FOOTER)
     {
       // the template section would break the multi-column stuff and we dont 
open up sections there
       // anyway ..
@@ -1059,7 +1061,9 @@
       throws IOException, DataSourceException, ReportProcessingException
   {
     sectionHeight = new LengthCalculator();
-    if (role == OfficeDocumentReportTarget.ROLE_TEMPLATE)
+    if (role == OfficeDocumentReportTarget.ROLE_TEMPLATE ||
+        role == OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_HEADER ||
+        role == OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_FOOTER)
     {
       // Start buffering with an dummy styles-collection, so that the global 
styles dont get polluted ..
       startBuffering(new OfficeStylesCollection(), true);
@@ -1199,7 +1203,9 @@
   protected void endReportSection(final AttributeMap attrs, final int role)
       throws IOException, DataSourceException, ReportProcessingException
   {
-    if (role == ROLE_TEMPLATE)
+    if (role == OfficeDocumentReportTarget.ROLE_TEMPLATE ||
+        role == OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_HEADER ||
+        role == OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_FOOTER)
     {
       finishBuffering();
       return;




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

Reply via email to