diff options
4 files changed, 40 insertions, 14 deletions
diff --git a/reportbuilder/java/com/sun/star/report/pentaho/configuration.properties b/reportbuilder/java/com/sun/star/report/pentaho/configuration.properties index 8af708eb60c5..186b8568cb6a 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/configuration.properties +++ b/reportbuilder/java/com/sun/star/report/pentaho/configuration.properties @@ -140,6 +140,7 @@ com.sun.star.report.pentaho.output.namespace.oasis-data=urn:oasis:names:tc:opend com.sun.star.report.pentaho.output.default.oasis-data=allow com.sun.star.report.pentaho.output.tag.oasis-data.text=deny com.sun.star.report.pentaho.output.tag.oasis-data.currency-symbol=deny +com.sun.star.report.pentaho.output.tag.oasis-data.embedded-text=deny com.sun.star.report.pentaho.output.namespace.oasis-draw=urn:oasis:names:tc:opendocument:xmlns:drawing:1.0 com.sun.star.report.pentaho.output.default.oasis-draw=deny diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormatValueUtility.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormatValueUtility.java index e6f27564b519..8515b4997d53 100755 --- a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormatValueUtility.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormatValueUtility.java @@ -32,6 +32,7 @@ package com.sun.star.report.pentaho.layoutprocessor; import java.text.SimpleDateFormat; import java.util.Date; +import java.sql.Time; import com.sun.star.report.pentaho.OfficeNamespaces; import com.sun.star.report.OfficeToken; @@ -58,6 +59,7 @@ public class FormatValueUtility public static final String VALUE_TYPE = "value-type"; private static SimpleDateFormat dateFormat; + private static SimpleDateFormat timeFormat; private FormatValueUtility() { @@ -66,12 +68,24 @@ public class FormatValueUtility public static String applyValueForVariable(final Object value, final AttributeMap variableSection) { String ret = null; - if (value instanceof Date) + if (value instanceof Time) + { + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, VALUE_TYPE, "time"); + ret = formatTime((Time) value); + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, "time-value", ret); + } + else if (value instanceof java.sql.Date ) { variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, VALUE_TYPE, "date"); ret = formatDate((Date) value); variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, "date-value", ret); } + else if (value instanceof Date) + { + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, VALUE_TYPE, "float"); + ret = HSSFDateUtil.getExcelDate((Date)value,false,2).toString(); + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, "value", ret); + } else if (value instanceof Number) { variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, VALUE_TYPE, "float"); @@ -104,19 +118,20 @@ public class FormatValueUtility public static void applyValueForCell(final Object value, final AttributeMap variableSection,final String valueType) { - if (value instanceof Date ) + if (value instanceof Time) { - if ( "date".equals(valueType) ) - { - variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, "date-value", formatDate((Date) value)); - } - else - { - variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, "value", String.valueOf(HSSFDateUtil.getExcelDate((Date)value))); - } - + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, "time-value", formatTime((Time) value)); } - else if (value instanceof Number ) + else if (value instanceof java.sql.Date ) + { + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, "date-value", formatDate((Date) value)); + } + else if (value instanceof Date) + { + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, VALUE_TYPE, "float"); + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, "value", HSSFDateUtil.getExcelDate((Date)value,false,2).toString()); + } + else if (value instanceof Number) { variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, "value", String.valueOf(value)); } @@ -166,6 +181,14 @@ public class FormatValueUtility } return dateFormat.format(date); } + private static synchronized String formatTime(final Date date) + { + if (timeFormat == null) + { + timeFormat = new SimpleDateFormat("'PT'HH'H'mm'M'ss'S'"); + } + return timeFormat.format(date); + } public static DataFlags computeDataFlag(final FormattedTextElement element, final FlowController flowController) diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/VariablesDeclarationLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/VariablesDeclarationLayoutController.java index 6a6b6f19d1f0..55f4f2999aab 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/VariablesDeclarationLayoutController.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/VariablesDeclarationLayoutController.java @@ -44,6 +44,7 @@ import org.jfree.report.flow.ReportTarget; import org.jfree.report.flow.layoutprocessor.AbstractLayoutController; import org.jfree.report.flow.layoutprocessor.LayoutController; import org.jfree.report.flow.layoutprocessor.LayoutControllerUtil; +import org.pentaho.reporting.libraries.formula.util.HSSFDateUtil; import org.jfree.report.structure.Element; import java.util.Date; import java.text.SimpleDateFormat; @@ -150,13 +151,14 @@ public class VariablesDeclarationLayoutController String formula = FormatValueUtility.applyValueForVariable(value, variableSection); if ( formula == null ) formula = "" + value; - if (value instanceof Date) + if (value instanceof java.sql.Date) { final Date date = (Date)value; final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy;MM;dd"); formula = "Date(" + dateFormat.format(date) + ")"; } variableSection.setAttribute(OfficeNamespaces.TEXT_NS, "formula", "ooow:" + formula); + return variableSection; } diff --git a/reportbuilder/java/com/sun/star/report/pentaho/parser/data/DataStyleReadHandler.java b/reportbuilder/java/com/sun/star/report/pentaho/parser/data/DataStyleReadHandler.java index eaf6d4a2d7b8..b4787ca63cb9 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/parser/data/DataStyleReadHandler.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/parser/data/DataStyleReadHandler.java @@ -70,7 +70,7 @@ public class DataStyleReadHandler extends ElementReadHandler { if (OfficeNamespaces.DATASTYLE_NS.equals(uri) || OfficeNamespaces.STYLE_NS.equals(uri)) { - final DataStyleReadHandler xrh = new DataStyleReadHandler("text".equals(tagName) || "currency-symbol".equals(tagName)); + final DataStyleReadHandler xrh = new DataStyleReadHandler("text".equals(tagName) || "currency-symbol".equals(tagName) || "embedded-text".equals(tagName)); children.add(xrh); return xrh; } |