Issue 122603

Summary: Date field displays incorrect value as number text in Base report
Product: Base Reporter: fanyuzhen
Component: codeAssignee: hanya <hanya.runo>
Status: CLOSED FIXED QA Contact: hdu <hdu>
Severity: Critical    
Priority: P2 CC: hanya.runo, hdu, issues, jsc, kschenk, oooforum, rainerbielefeld_ooo_qa
Version: 4.0.0-devFlags: jsc: 4.0.0_release_blocker+
Target Milestone: 4.0.0   
Hardware: All   
OS: All   
Issue Type: DEFECT Latest Confirmation in: ---
Developer Difficulty: ---
Attachments:
Description Flags
Proposed patch to fix the problem.
none
Test case containing a table with number formatted columns none

Description fanyuzhen 2013-06-27 07:57:21 UTC
Steps:
1. Create a table with date field
2. Create a report based on this table and check the value of the date field

Actual result: the date value displays as number char, like "40716"
Expected result: the date value displays as date, like "11/06/22"
Comment 1 oooforum (fr) 2013-06-27 08:35:49 UTC
Maybe linked with https://issues.apache.org/ooo/show_bug.cgi?id=121492
Comment 2 fanyuzhen 2013-06-27 08:36:11 UTC
*** Issue 122602 has been marked as a duplicate of this issue. ***
Comment 3 hanya 2013-06-27 15:40:49 UTC
It seems not only for Date but also for other kind of data types.
As a workaround,
- open the report document to edit.
- Select a column and choose Table - Number Format in the main menu and apply format.
- Save the document.
Comment 4 hanya 2013-06-27 17:31:57 UTC
I got the following error during the new report creation using the report wizard.
Each cells of the created table on the report document takes the same 
number format with the bound column in NumberFormatter.setNumberFormat method. 
Before to set NumberFormat property to the cell, FormatsSupplier property 
is tried to set. But current cell in the table on the text document does not have 
FormatsSupplier property. The following error raised and NumberFormat is not set.


com.sun.star.beans.UnknownPropertyException: FormatsSupplier
	at com.sun.star.bridges.jni_uno.JNI_proxy.dispatch_call(Native Method)
	at com.sun.star.bridges.jni_uno.JNI_proxy.invoke(JNI_proxy.java:171)
	at sun.proxy.$Proxy6.setPropertyValue(Unknown Source)
	at com.sun.star.wizards.common.NumberFormatter.setNumberFormat(NumberFormatter.java:200)
	at com.sun.star.wizards.report.DBColumn.initializeNumberFormat(DBColumn.java:240)
	at com.sun.star.wizards.report.ReportTextDocument.insertColumnstoRecordTable(ReportTextDocument.java:456)
	at com.sun.star.wizards.report.ReportTextDocument.setupRecordSection(ReportTextDocument.java:340)
	at com.sun.star.wizards.report.ReportTextImplementation.layout_setupRecordSection(ReportTextImplementation.java:549)
	at com.sun.star.wizards.report.ReportLayouter.initialize(ReportLayouter.java:225)
	at com.sun.star.wizards.report.ReportWizard.leaveStep(ReportWizard.java:236)
	at com.sun.star.wizards.ui.WizardDialog.switchToStep(WizardDialog.java:359)
	at com.sun.star.wizards.ui.WizardDialog.switchToStep(WizardDialog.java:354)
	at com.sun.star.wizards.report.ReportWizard.finishWizard(ReportWizard.java:358)
	at com.sun.star.wizards.ui.WizardDialog.finishWizard_1(WizardDialog.java:692)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	at com.sun.star.wizards.ui.event.MethodInvocation.invoke(MethodInvocation.java:90)
	at com.sun.star.wizards.ui.event.AbstractListener.invoke(AbstractListener.java:86)
	at com.sun.star.wizards.ui.event.CommonListener.actionPerformed(CommonListener.java:45)
	at com.sun.star.bridges.jni_uno.JNI_proxy.dispatch_call(Native Method)
	at com.sun.star.bridges.jni_uno.JNI_proxy.invoke(JNI_proxy.java:171)
	at sun.proxy.$Proxy110.execute(Unknown Source)
	at com.sun.star.wizards.ui.UnoDialog.executeDialog(UnoDialog.java:730)
	at com.sun.star.wizards.report.ReportWizard.startReportWizard(ReportWizard.java:497)
	at com.sun.star.wizards.report.CallReportWizard$ReportWizardImplementation.trigger(CallReportWizard.java:120)
Comment 5 hanya 2013-06-27 17:42:55 UTC
Created attachment 80925 [details]
Proposed patch to fix the problem.

When setNumberFormat method is called from DBColumn::initializeNumberFormat method, 
the number formatter is the document's one. 
And the passed arguments are from the database column. 
Before the format key is set to the table cell, the format key from the 
column is used to generate new key on the number format supplier. 
Therefore to set FormatsSupplier property of the cell is not required 
(I mean, document's one is used).
The same setNumberFormat method is called from other wizard, so the line 
should not be removed, check the property existence before to set it.
Comment 6 hanya 2013-06-27 17:59:04 UTC
Created attachment 80926 [details]
Test case containing a table with number formatted columns

To verify: 
- Open the attached NumberFormatTest.odb file.
- Click Reports in Database and then click Use Wizard to Create Report...
- Push >> button to add all fields to the report.
- Push Finish button.
The result should be: 
ID DATE VALUE
0 01/01/2000 100.0200
1 02/02/2001 200.0001
2 02/02/2002 300.1000
...
for the following number formats: DATE: YYYY/MM/DD, VALUE: 0.0000
Comment 7 Kay 2013-06-30 22:54:54 UTC
Confirmed as well. Thanks for the patch. We'll check it out.
Comment 8 hdu@apache.org 2013-07-09 08:22:55 UTC
Confirming the original problem too and confirming that Hanya's patch works great (as always :-) ). Thanks for the patch!

Suggesting to include it in the imminent release: The patch fixes the problem and cannot have any impact on other areas.
Comment 9 jsc 2013-07-09 08:23:40 UTC
grant showstopper flag, patch available
Comment 10 SVN Robot 2013-07-09 08:49:00 UTC
"hdu" committed SVN revision 1501137 into trunk:
#i122603# fix database wizard's use of the Numberformatter
Comment 11 hdu@apache.org 2013-07-09 08:52:42 UTC
Applied Hanya's patch and updating the status to FIXED.
Comment 12 Rainer Bielefeld 2013-07-21 14:19:52 UTC
Changed "Assigned to" to patch submitter to ease reliable queries.