Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Legacy reports (not Sun/Oracle Report Builder ones) wizard show date
columns as an integer days-since-epoch instead of e.g. nicely
formatted "DD-MM-YY" (day-month-year) in *newly* *created* reports.

Commit message is explanatory; shout if you have other question.

Please apply to libreoffice-3-5 and libreoffice-3-5-5 branch.

I ask for libreoffice-3-5-5 because the fix seems rather safe to me:

 1) Protects a setProperty with test for existence of this property

 2) Initializes values before they are used (see the code of
    getTyperelatedFieldData in the same file)

-- 
Lionel
From e834a95359738961037b7f747f55ac60a0b9e922 Mon Sep 17 00:00:00 2001
From: Lionel Elie Mamane <lionel@mamane.lu>
Date: Mon, 18 Jun 2012 16:28:14 +0200
Subject: [PATCH] fdo#43967 legacy report designer wizard formats dates
 improperly

1) Set FormatsSupplier property only if underlying object has one.
   Else, exception is thrown and the format is not set
2) getTyperelatedFieldData uses the format keys, so initialize them
   before call, not after.

Change-Id: I68c4c96a9da9a6afdc3ab8964e973588f53ee814
---
 .../com/sun/star/wizards/common/NumberFormatter.java   |    5 ++++-
 wizards/com/sun/star/wizards/db/FieldColumn.java       |   16 ++++++++--------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/wizards/com/sun/star/wizards/common/NumberFormatter.java 
b/wizards/com/sun/star/wizards/common/NumberFormatter.java
index 9c0feb5..bbf6385 100644
--- a/wizards/com/sun/star/wizards/common/NumberFormatter.java
+++ b/wizards/com/sun/star/wizards/common/NumberFormatter.java
@@ -201,7 +201,10 @@ public class NumberFormatter
             Locale oLocale = (Locale) Helper.getUnoPropertyValue(xNumberFormat, "Locale");
             int NewFormatKey = defineNumberFormat(FormatString, oLocale);
             XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, _xFormatObject);
-            xPSet.setPropertyValue("FormatsSupplier", 
_oNumberFormatter.xNumberFormatter.getNumberFormatsSupplier());
+            if (xPSet.getPropertySetInfo().hasPropertyByName("FormatsSupplier"))
+            {
+                xPSet.setPropertyValue("FormatsSupplier", 
_oNumberFormatter.xNumberFormatter.getNumberFormatsSupplier());
+            }
             if (xPSet.getPropertySetInfo().hasPropertyByName("NumberFormat"))
             {
                 xPSet.setPropertyValue("NumberFormat", new Integer(NewFormatKey));
diff --git a/wizards/com/sun/star/wizards/db/FieldColumn.java 
b/wizards/com/sun/star/wizards/db/FieldColumn.java
index ebedd22..47b37df 100644
--- a/wizards/com/sun/star/wizards/db/FieldColumn.java
+++ b/wizards/com/sun/star/wizards/db/FieldColumn.java
@@ -154,13 +154,8 @@ public class FieldColumn
     {
         try
         {
-            m_xColPropertySet = UnoRuntime.queryInterface(XPropertySet.class, 
_xColumns.getByName(m_sFieldName));
-            ColIndex = JavaTools.FieldInList(_xColumns.getElementNames(), m_sFieldName) + 1;
-            m_nFieldType = AnyConverter.toInt(m_xColPropertySet.getPropertyValue("Type"));
-            getTyperelatedFieldData();
-
-             if (!bFormatKeysInitialized)
-             {
+            if (!bFormatKeysInitialized)
+            {
                 final NumberFormatter aNumberFormatter = oCommandMetaData.getNumberFormatter();
 
                 iDateFormatKey = aNumberFormatter.getDateFormatKey();
@@ -170,7 +165,12 @@ public class FieldColumn
                 iTimeFormatKey = aNumberFormatter.getTimeFormatKey();
                 iLogicalFormatKey = aNumberFormatter.getLogicalFormatKey();
                 bFormatKeysInitialized = true;
-             }
+            }
+
+            m_xColPropertySet = UnoRuntime.queryInterface(XPropertySet.class, 
_xColumns.getByName(m_sFieldName));
+            ColIndex = JavaTools.FieldInList(_xColumns.getElementNames(), m_sFieldName) + 1;
+            m_nFieldType = AnyConverter.toInt(m_xColPropertySet.getPropertyValue("Type"));
+            getTyperelatedFieldData();
         }
         catch (Exception e)
         {
-- 
1.7.10


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.