Tag: cws_ooo300_dba30j User: oj Date: 2008-09-01 11:46:05+0000 Modified: dba/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/VariablesDeclarationLayoutController.java dba/reportbuilder/java/com/sun/star/report/pentaho/output/text/VariablesDeclarations.java
Log: #i93017# add time as double value File Changes: Directory: /dba/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ =============================================================================== File [changed]: VariablesDeclarationLayoutController.java Url: http://dba.openoffice.org/source/browse/dba/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/VariablesDeclarationLayoutController.java?r1=1.1.1.1&r2=1.1.1.1.4.1 Delta lines: +154 -133 ----------------------- --- VariablesDeclarationLayoutController.java 2008-08-12 14:14:11+0000 1.1.1.1 +++ VariablesDeclarationLayoutController.java 2008-09-01 11:46:02+0000 1.1.1.1.4.1 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: VariablesDeclarationLayoutController.java,v $ - * $Revision: 1.1.1.1 $ + * $Revision: 1.1.1.1.4.1 $ * * This file is part of OpenOffice.org. * @@ -27,8 +27,6 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ - - package com.sun.star.report.pentaho.layoutprocessor; import com.sun.star.report.pentaho.OfficeNamespaces; @@ -47,6 +45,8 @@ import org.jfree.report.structure.Element; import java.util.Date; import java.text.SimpleDateFormat; +import org.jfree.formula.parser.ParseException; +import org.jfree.formula.typing.Type; /** * Writes a full variables-declaration section. @@ -57,6 +57,7 @@ public class VariablesDeclarationLayoutController extends AbstractLayoutController { + private boolean processed; public VariablesDeclarationLayoutController() @@ -68,7 +69,7 @@ LayoutController parent = getParent(); while (parent != null) { - if (parent instanceof OfficeRepeatingStructureLayoutController) + if ( parent instanceof OfficeRepeatingStructureLayoutController ) { return (OfficeRepeatingStructureLayoutController) parent; } @@ -94,7 +95,7 @@ throws DataSourceException, ReportDataFactoryException, ReportProcessingException { - if (processed) + if ( processed ) { throw new IllegalStateException("Already processed."); } @@ -104,14 +105,14 @@ vlc.processed = true; final OfficeRepeatingStructureLayoutController orslc = getRepeatingParent(); - if (orslc == null) + if ( orslc == null ) { // There is no repeating parent. What the heck are we doing here .. return vlc; } final VariablesCollection collection = orslc.getVariablesCollection(); - if (collection.getVariablesCount() == 0) + if ( collection.getVariablesCount() == 0 ) { // no processing necessary, as the header or footer contain no variables at all .. return vlc; @@ -137,6 +138,21 @@ return vlc; } + private double convertTime(Date date, final SimpleDateFormat dateFormat) + { + + dateFormat.applyPattern("HH"); + double hour = Double.parseDouble(dateFormat.format(date)); + dateFormat.applyPattern("m"); + double minute = Double.parseDouble(dateFormat.format(date)); + dateFormat.applyPattern("ss"); + double second = Double.parseDouble(dateFormat.format(date)); + dateFormat.applyPattern("ZZ"); + double n100second = Double.parseDouble(dateFormat.format(date)); + + return (hour + (minute / 60) + (second / (60 * 60)) + (n100second / (60 * 60 * 100))) / 24; + } + private AttributeMap generateVariableSetSection(final FormattedTextElement variable) throws DataSourceException { @@ -149,12 +165,18 @@ final Object value = LayoutControllerUtil.evaluateExpression(getFlowController(), variable, valueExpression); String formula = FormatValueUtility.applyValueForVariable(value, variableSection); if ( formula == null ) + { formula = "" + value; - if (value instanceof Date) + } + if ( value instanceof Date ) { - Date date = (Date)value; + Date date = (Date) value; final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy;MM;dd"); - formula = "Date(" + dateFormat.format(date) + ")"; + formula = "Date(" + dateFormat.format(date) + ") + " + convertTime(date, dateFormat); + /*TIME("; + dateFormat.applyPattern("HH;mm;ss"); + formula = formula + dateFormat.format(date) + ")"; + * */ } variableSection.setAttribute(OfficeNamespaces.TEXT_NS, "formula", "ooow:" + formula); return variableSection; @@ -184,7 +206,6 @@ throws DataSourceException, ReportDataFactoryException, ReportProcessingException { - throw new UnsupportedOperationException - ("Join is not supported in this layout controller"); + throw new UnsupportedOperationException("Join is not supported in this layout controller"); } } Directory: /dba/reportbuilder/java/com/sun/star/report/pentaho/output/text/ =========================================================================== File [changed]: VariablesDeclarations.java Url: http://dba.openoffice.org/source/browse/dba/reportbuilder/java/com/sun/star/report/pentaho/output/text/VariablesDeclarations.java?r1=1.1.1.1&r2=1.1.1.1.4.1 Delta lines: +7 -1 ------------------- --- VariablesDeclarations.java 2008-08-12 14:14:12+0000 1.1.1.1 +++ VariablesDeclarations.java 2008-09-01 11:46:02+0000 1.1.1.1.4.1 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: VariablesDeclarations.java,v $ - * $Revision: 1.1.1.1 $ + * $Revision: 1.1.1.1.4.1 $ * * This file is part of OpenOffice.org. * @@ -75,6 +75,12 @@ { // create the default mapping as well.. holder.put(null, name); + holder.put("time", name); + holder.put("date", name); + holder.put("datetime", name); + holder.put("float", name); + holder.put("string", name); + holder.put("boolean", name); } holder.put(type, name); return result; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
