Tag: cws_dev300_rptchart02
User: oj      
Date: 2008-04-17 08:12:21+0000
Modified:
   dba/reportdesign/java/com/sun/star/report/pentaho/PentahoReportJob.java

Log:
 correct interval handling

File Changes:

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

File [changed]: PentahoReportJob.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/PentahoReportJob.java?r1=1.3.4.2&r2=1.3.4.3
Delta lines:  +41 -7
--------------------
--- PentahoReportJob.java       2008-04-16 06:21:01+0000        1.3.4.2
+++ PentahoReportJob.java       2008-04-17 08:12:18+0000        1.3.4.3
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: PentahoReportJob.java,v $
- * $Revision: 1.3.4.2 $
+ * $Revision: 1.3.4.3 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -54,10 +54,13 @@
 import com.sun.star.report.pentaho.output.text.TextRawReportProcessor;
 import 
com.sun.star.report.pentaho.output.spreadsheet.SpreadsheetRawReportProcessor;
 import java.util.List;
+import org.jfree.formula.lvalues.ContextLookup;
 import org.jfree.formula.lvalues.FormulaFunction;
 import org.jfree.formula.lvalues.LValue;
+import org.jfree.formula.lvalues.Term;
 import org.jfree.formula.parser.FormulaParser;
 import org.jfree.formula.parser.ParseException;
+import org.jfree.report.expressions.Expression;
 import org.jfree.report.expressions.FormulaExpression;
 import org.jfree.report.flow.DefaultReportJob;
 import org.jfree.report.flow.ReportProcessor;
@@ -225,7 +228,7 @@
         listeners.remove(indicator);
     }
 
-    private void collectGroupExpressions(final Node[] nodes, final List 
expressions, final FormulaParser parser)
+    private void collectGroupExpressions(final Node[] nodes, final List 
expressions, final FormulaParser parser, final Expression reportFunctions[])
     {
         for (int i = 0; i < nodes.length; i++)
         {
@@ -241,8 +244,36 @@
                     final LValue[] parameters = function.getChildValues();
                     if (parameters.length > 0)
                     {
+                        String name = parameters[0].toString();
+                        for (int j = 0; j < reportFunctions.length; j++)
+                        {
+                            if (reportFunctions[j] instanceof 
FormulaExpression)
+                            {
+                                final FormulaExpression reportExp = 
(FormulaExpression) reportFunctions[j];
+
+                                if (reportExp.getName().equals(name))
+                                {
+                                    final LValue val = (LValue) 
parser.parse(reportExp.getFormulaExpression());
+                                    if (val instanceof FormulaFunction)
+                                    {
+                                        final FormulaFunction reportFunction = 
(FormulaFunction) val;
+                                    
+                                        final ContextLookup context = 
(ContextLookup) reportFunction.getChildValues()[0];
+                                        name = context.getName();
+                                    }
+                                    else if (val instanceof Term)
+                                    {
+                                        final Term term = (Term) val;
+                                        final ContextLookup context = 
(ContextLookup) term.getHeadValue().getChildValues()[0];
+                                        name = context.getName();
+                                    }
+                                    break;
+                                }
+                            }
+                        }
+
                         final Object[] pair = new Object[2];
-                        pair[0] = parameters[0].toString();
+                        pair[0] = name;
                         pair[1] = 
group.getAttribute(OfficeNamespaces.OOREPORT_NS, "sort-ascending");
                         expressions.add(pair);
                     }
@@ -254,7 +285,7 @@
                 if (node instanceof Section)
                 {
                     final Section section = (Section) node;
-                    collectGroupExpressions(section.getNodeArray(), 
expressions, parser);
+                    collectGroupExpressions(section.getNodeArray(), 
expressions, parser, reportFunctions);
                 }
 
             }
@@ -262,6 +293,7 @@
             {
                 return;
             }
+
         }
     }
 
@@ -287,13 +319,14 @@
                 parameters.put(SDBCReportDataFactory.MASTER_VALUES, 
masterValues);
                 parameters.put(SDBCReportDataFactory.DETAIL_COLUMNS, 
detailColumns);
             }
+
             final Node[] nodes = report.getNodeArray();
 
             final FormulaParser parser = new FormulaParser();
             final ArrayList expressions = new ArrayList();
             final OfficeReport officeReport = (OfficeReport) ((Section) 
nodes[0]).getNode(0);
             final Section reportBody = (Section) officeReport.getBodySection();
-            collectGroupExpressions(reportBody.getNodeArray(), expressions, 
parser);
+            collectGroupExpressions(reportBody.getNodeArray(), expressions, 
parser, officeReport.getExpressions());
             parameters.put(SDBCReportDataFactory.GROUP_EXPRESSIONS, 
expressions);
             final String command = (String) 
officeReport.getAttribute(OfficeNamespaces.OOREPORT_NS, "command");
             final String commandType = (String) 
officeReport.getAttribute(OfficeNamespaces.OOREPORT_NS, 
SDBCReportDataFactory.COMMAND_TYPE);
@@ -318,6 +351,7 @@
             throws ReportExecutionException
     {
         final ReportProcessor ret;
+
         if 
(PentahoReportEngineMetaData.OPENDOCUMENT_SPREADSHEET.equals(mimeType))
         {
             ret = new SpreadsheetRawReportProcessor(inputRepository, 
outputRepository, outputName, imageService, dataSourceFactory);




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

Reply via email to