Author: damjan
Date: Wed Aug 26 02:10:46 2015
New Revision: 1697807
URL: http://svn.apache.org/r1697807
Log:
#i117989# Basic functions Day(), Hour(), Minute(), and Second() return wrong
results for dates 1900-1-1
Also extended our spreadsheeet test to search through more columns, open
spreadsheets
with macros enabled, and added a test for the the Year(), Month(), Day(),
Hour(),
Minute(), and Second() functions comparing Calc's formulas vs StarBasic's
runtime functions.
Found-by: villeroy
Patch-by: Damjan Jovanovic
Added:
openoffice/trunk/test/testuno/data/uno/sc/fvt/StarBasicYearMonthDateHourMinuteSecondTests.ods
(with props)
Modified:
openoffice/trunk/main/basic/source/runtime/methods.cxx
openoffice/trunk/test/testuno/source/fvt/uno/sc/formula/TestFormulaDocs.java
Modified: openoffice/trunk/main/basic/source/runtime/methods.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/basic/source/runtime/methods.cxx?rev=1697807r1=1697806r2=1697807view=diff
==
--- openoffice/trunk/main/basic/source/runtime/methods.cxx (original)
+++ openoffice/trunk/main/basic/source/runtime/methods.cxx Wed Aug 26 02:10:46
2015
@@ -1789,17 +1789,9 @@ RTLFUNC(Val)
sal_Int16 implGetDateDay( double aDate )
{
aDate -= 2.0; // normieren: 1.1.1900 = 0.0
+ aDate = floor( aDate );
Date aRefDate( 1, 1, 1900 );
- if ( aDate = 0.0 )
- {
- aDate = floor( aDate );
- aRefDate += (sal_uIntPtr)aDate;
- }
- else
- {
- aDate = ceil( aDate );
- aRefDate -= (sal_uIntPtr)(-1.0 * aDate);
- }
+ aRefDate += (sal_uIntPtr)aDate;
sal_Int16 nRet = (sal_Int16)( aRefDate.GetDay() );
return nRet;
@@ -2110,8 +2102,6 @@ RTLFUNC(Year)
sal_Int16 implGetHour( double dDate )
{
- if( dDate 0.0 )
- dDate *= -1.0;
double nFrac = dDate - floor( dDate );
nFrac *= 86400.0;
sal_Int32 nSeconds = (sal_Int32)(nFrac + 0.5);
@@ -2136,8 +2126,6 @@ RTLFUNC(Hour)
sal_Int16 implGetMinute( double dDate )
{
- if( dDate 0.0 )
- dDate *= -1.0;
double nFrac = dDate - floor( dDate );
nFrac *= 86400.0;
sal_Int32 nSeconds = (sal_Int32)(nFrac + 0.5);
@@ -2177,8 +2165,6 @@ RTLFUNC(Month)
sal_Int16 implGetSecond( double dDate )
{
- if( dDate 0.0 )
- dDate *= -1.0;
double nFrac = dDate - floor( dDate );
nFrac *= 86400.0;
sal_Int32 nSeconds = (sal_Int32)(nFrac + 0.5);
Added:
openoffice/trunk/test/testuno/data/uno/sc/fvt/StarBasicYearMonthDateHourMinuteSecondTests.ods
URL:
http://svn.apache.org/viewvc/openoffice/trunk/test/testuno/data/uno/sc/fvt/StarBasicYearMonthDateHourMinuteSecondTests.ods?rev=1697807view=auto
==
Binary file - no diff available.
Propchange:
openoffice/trunk/test/testuno/data/uno/sc/fvt/StarBasicYearMonthDateHourMinuteSecondTests.ods
--
svn:mime-type = application/vnd.oasis.opendocument.spreadsheet
Modified:
openoffice/trunk/test/testuno/source/fvt/uno/sc/formula/TestFormulaDocs.java
URL:
http://svn.apache.org/viewvc/openoffice/trunk/test/testuno/source/fvt/uno/sc/formula/TestFormulaDocs.java?rev=1697807r1=1697806r2=1697807view=diff
==
---
openoffice/trunk/test/testuno/source/fvt/uno/sc/formula/TestFormulaDocs.java
(original)
+++
openoffice/trunk/test/testuno/source/fvt/uno/sc/formula/TestFormulaDocs.java
Wed Aug 26 02:10:46 2015
@@ -36,6 +36,8 @@ import org.openoffice.test.uno.UnoApp;
import testlib.uno.SCUtil;
import static testlib.uno.TestUtil.*;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.document.MacroExecMode;
import com.sun.star.lang.XComponent;
import com.sun.star.sheet.XSpreadsheet;
import com.sun.star.sheet.XSpreadsheetDocument;
@@ -76,12 +78,18 @@ public class TestFormulaDocs {
@Test
public void testFormulaDocs() throws Exception {
testOneDoc( uno/sc/fvt/FormulaTest1.ods);
+ testOneDoc(
uno/sc/fvt/StarBasicYearMonthDateHourMinuteSecondTests.ods);
}
public void testOneDoc( String filename) throws Exception {
// open the spreadsheet document
String sample = Testspace.prepareData( filename);
- XSpreadsheetDocument scDoc = SCUtil.openFile( sample, unoApp);
+ // enable macros
+ PropertyValue prop = new PropertyValue();
+ prop.Name = MacroExecutionMode;
+ prop.Value = MacroExecMode.ALWAYS_EXECUTE_NO_WARN;
+ XSpreadsheetDocument scDoc = (XSpreadsheetDocument)
UnoRuntime.queryInterface(
+ XSpreadsheetDocument.class,