Tag: cws_ooh680_pentaho2
User: oj      
Date: 2008-01-21 09:00:27+0000
Added:
   
dba/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/OfficePageSectionLayoutController.java

Modified:
   
dba/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/FormattedTextLayoutController.java
   
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:
 #i79173# #i78502# import changes from pentaho1

File Changes:

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

File [changed]: FormattedTextLayoutController.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/FormattedTextLayoutController.java?r1=1.3&r2=1.3.74.1
Delta lines:  +51 -3
--------------------
--- FormattedTextLayoutController.java  2007-08-03 09:49:15+0000        1.3
+++ FormattedTextLayoutController.java  2008-01-21 09:00:24+0000        1.3.74.1
@@ -39,6 +39,8 @@
 
 import com.sun.star.report.pentaho.OfficeNamespaces;
 import com.sun.star.report.pentaho.model.FormattedTextElement;
+import com.sun.star.report.pentaho.model.OfficeDocument;
+import com.sun.star.report.pentaho.model.OfficeStyle;
 import org.jfree.formula.Formula;
 import org.jfree.formula.lvalues.LValue;
 import org.jfree.formula.parser.ParseException;
@@ -101,7 +103,7 @@
     }
     catch (final ParseException e)
     {
-      Log.debug ("Parse Exception" , e);
+      Log.debug("Parse Exception", e);
       return false;
     }
   }
@@ -122,6 +124,13 @@
           Element.NAMESPACE_ATTRIBUTE, OfficeNamespaces.TEXT_NS);
       variablesGet.setAttribute(OfficeNamespaces.TEXT_NS, "name", name);
       //variablesGet.setAttribute(OfficeNamespaces.TEXT_NS, "display", 
"value");
+      
+      final String dataStyleName = computeValueStyle();
+      if (dataStyleName != null)
+      {
+        variablesGet.setAttribute(OfficeNamespaces.STYLE_NS, 
"data-style-name", dataStyleName);
+      }
+
       final String valueType = computeValueType();
       variablesGet.setAttribute(OfficeNamespaces.OFFICE_NS, "value-type", 
valueType);
       target.startElement(variablesGet);
@@ -141,6 +150,22 @@
     return join(getFlowController());
   }
 
+
+  private OfficeDocument getDocument()
+  {
+    LayoutController parent = getParent();
+    while (parent != null)
+    {
+      final Object node = parent.getNode();
+      if (node instanceof OfficeDocument)
+      {
+        return (OfficeDocument) node;
+      }
+      parent = parent.getParent();
+    }
+    return null;
+  }
+
   private Element getParentTableCell()
   {
     LayoutController parent = getParent();
@@ -156,7 +181,30 @@
     return null;
   }
 
-  private String computeValueType ()
+  private String computeValueStyle()
+  {
+    final Element tce = getParentTableCell();
+    if (tce == null)
+    {
+      return null;
+    }
+
+    final String cellStyleName = (String) 
tce.getAttribute(OfficeNamespaces.TABLE_NS, "style-name");
+    if (cellStyleName == null)
+    {
+      return null;
+    }
+    final OfficeDocument document = getDocument();
+    if (document == null)
+    {
+      return null;
+    }
+
+    final OfficeStyle style = 
document.getStylesCollection().getStyle("table-cell", cellStyleName);
+    return (String) style.getAttribute(OfficeNamespaces.STYLE_NS, 
"data-style-name");
+  }
+
+  private String computeValueType()
   {
     final Element tce = getParentTableCell();
     if (tce == null)
@@ -168,7 +216,7 @@
     final String type = (String) tce.getAttribute(OfficeNamespaces.OFFICE_NS, 
"value-type");
     if (type == null)
     {
-      Log.error ("The Table-Cell does not have a office:value attribute 
defined. Your content will be messed up.");
+      Log.error("The Table-Cell does not have a office:value attribute 
defined. Your content will be messed up.");
       return "string";
     }
     return type;

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.4.2&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.82.1
Delta lines:  +41 -13
---------------------
--- OfficeReportLayoutController.java   2007-07-09 11:56:05+0000        1.2
+++ OfficeReportLayoutController.java   2008-01-21 09:00:24+0000        1.2.82.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.82.1
Delta lines:  +11 -3
--------------------
--- OfficeTableTemplateLayoutController.java    2007-07-09 11:56:06+0000        
1.2
+++ OfficeTableTemplateLayoutController.java    2008-01-21 09:00:24+0000        
1.2.82.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.74.1
Delta lines:  +22 -6
--------------------
--- OfficeDocumentReportTarget.java     2007-08-03 09:50:45+0000        1.3
+++ OfficeDocumentReportTarget.java     2008-01-21 09:00:24+0000        1.3.74.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.74.1
Delta lines:  +92 -62
---------------------
--- SpreadsheetRawReportTarget.java     2007-08-03 09:51:10+0000        1.3
+++ SpreadsheetRawReportTarget.java     2008-01-21 09:00:24+0000        1.3.74.1
@@ -52,6 +52,7 @@
 import com.sun.star.report.pentaho.model.OfficeStylesCollection;
 import com.sun.star.report.pentaho.model.OfficeMasterPage;
 import com.sun.star.report.pentaho.model.OfficeMasterStyles;
+import com.sun.star.report.pentaho.model.PageSection;
 import com.sun.star.report.pentaho.output.OfficeDocumentReportTarget;
 import com.sun.star.report.pentaho.output.StyleUtilities;
 import com.sun.star.report.pentaho.output.text.MasterPageFactory;
@@ -82,6 +83,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];
@@ -147,6 +212,33 @@
     }
   }
 
+  protected void startReportSection(final AttributeMap attrs, final int role) 
throws IOException, DataSourceException, ReportProcessingException
+  {
+    if ((role == OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_HEADER ||
+         role == OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_FOOTER) &&
+        (PageSection.isPrintWithReportHeader(attrs) == false ||
+         PageSection.isPrintWithReportFooter(attrs) == false))
+    {
+      startBuffering(new OfficeStylesCollection(), true);
+      return;
+    }
+    super.startReportSection(attrs, role);
+  }
+
+  protected void endReportSection(final AttributeMap attrs, final int role) 
throws IOException, DataSourceException, ReportProcessingException
+  {
+    if ((role == OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_HEADER ||
+         role == OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_FOOTER) &&
+        (PageSection.isPrintWithReportHeader(attrs) == false ||
+         PageSection.isPrintWithReportFooter(attrs) == false))
+    {
+      finishBuffering();
+      return;
+    }
+
+    super.endReportSection(attrs, role);    
+  }
+
   private void processElement(final AttributeMap attrs, final String 
namespace, final String elementType)
       throws IOException, ReportProcessingException
   {
@@ -691,66 +783,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.74.1
Delta lines:  +9 -3
-------------------
--- TextRawReportTarget.java    2007-08-03 09:51:21+0000        1.3
+++ TextRawReportTarget.java    2008-01-21 09:00:25+0000        1.3.74.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