Tag: cws_ooo300_dba301a User: oj Date: 2008-08-27 14:51:50+0000 Modified: dba/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/VariablesDeclarationLayoutController.java
Log: convert time into double File Changes: Directory: /dba/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/ ============================================================================== File [changed]: VariablesDeclarationLayoutController.java Url: http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/VariablesDeclarationLayoutController.java?r1=1.5&r2=1.5.44.1 Delta lines: +155 -134 ----------------------- --- VariablesDeclarationLayoutController.java 2008-06-16 13:10:50+0000 1.5 +++ VariablesDeclarationLayoutController.java 2008-08-27 14:51:47+0000 1.5.44.1 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: VariablesDeclarationLayoutController.java,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.44.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"); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
