ooo-build r11394 - in trunk: . patches/src680 patches/vba scratch/sc-vba/testvba/TestDocuments scratch/sc-vba/testvba/TestDocuments/logs/unix



Author: pflin
Date: Thu Jan 24 05:34:55 2008
New Revision: 11394
URL: http://svn.gnome.org/viewvc/ooo-build?rev=11394&view=rev

Log:
	*  patches/vba/n353254-dateserial.diff: fix for n353254
	*  patches/vba/n353260-datevalue-temp.diff: fix for n353260
	*  scratch/sc-vba/testvba/TestDocuments/353254-dateserial.xls
	*  scratch/sc-vba/testvba/TestDocuments/353260-datevalue.xls
	*  scratch/sc-vba/testvba/TestDocuments/log/unix/dateserial.log
	*  scratch/sc-vba/testvba/TestDocuments/log/unix/datevalue.log
	*  patches/src680/apply:



Added:
   trunk/patches/vba/n353254-dateserial.diff
   trunk/patches/vba/n353260-datevalue-temp.diff
   trunk/scratch/sc-vba/testvba/TestDocuments/353254-dateserial.xls   (contents, props changed)
   trunk/scratch/sc-vba/testvba/TestDocuments/353260-datevalue.xls   (contents, props changed)
   trunk/scratch/sc-vba/testvba/TestDocuments/logs/unix/dateserial.log
   trunk/scratch/sc-vba/testvba/TestDocuments/logs/unix/datevalue.log
Modified:
   trunk/ChangeLog
   trunk/patches/src680/apply

Modified: trunk/patches/src680/apply
==============================================================================
--- trunk/patches/src680/apply	(original)
+++ trunk/patches/src680/apply	Thu Jan 24 05:34:55 2008
@@ -1425,6 +1425,12 @@
 # Fomat function enhancement for VBA 
 vba-format-function.diff, n#294187, Fong
 
+# fix for n#353254
+n353254-dateserial.diff, n#353254, Fong
+# fix for n#353260
+n353260-datevalue-temp.diff, n#353260, Fong
+
+
 # Is function only valid for objects
 #vba-is-behaviour.diff
 # support static keyword for procedures and local variables

Added: trunk/patches/vba/n353254-dateserial.diff
==============================================================================
--- (empty file)
+++ trunk/patches/vba/n353254-dateserial.diff	Thu Jan 24 05:34:55 2008
@@ -0,0 +1,101 @@
+--- basic/source/runtime/methods.cxx.orig	2008-01-23 17:25:09.000000000 +0800
++++ basic/source/runtime/methods.cxx	2008-01-23 17:50:48.000000000 +0800
+@@ -1826,19 +1826,94 @@ INT16 implGetDateYear( double aDate )
+     return nRet;
+ }
+ 
++static USHORT aDaysInMonth[12] = { 31, 28, 31, 30, 31, 30,
++								   31, 31, 30, 31, 30, 31 };
++
++
++BOOL ImpIsLeapYear( USHORT nYear )
++{
++	return (((nYear % 4) == 0) && ((nYear % 100) != 0) || ((nYear % 400) == 0));
++}
++
++USHORT ImpDaysInMonth( USHORT nMonth, USHORT nYear )
++{
++	if ( nMonth != 2 )
++		return aDaysInMonth[nMonth-1];
++	else
++	{
++		if ( ((nYear % 4) == 0) && ((nYear % 100) != 0) ||
++			 ((nYear % 400) == 0) )
++			return aDaysInMonth[nMonth-1] + 1;
++		else
++			return aDaysInMonth[nMonth-1];
++	}
++}
++
+ BOOL implDateSerial( INT16 nYear, INT16 nMonth, INT16 nDay, double& rdRet )
+ {
+ 	if ( nYear < 100 )
+ 		nYear += 1900;
+-	if ((nYear < 100 || nYear > 9999)   ||
+-		(nMonth < 1 || nMonth > 12 )	||
+-		(nDay < 1 || nDay > 31 ))
++	if (nYear < 100 || nYear > 9999)
+ 	{
+ 		StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ 		return FALSE;
+ 	}
+ 
+-	Date aCurDate( nDay, nMonth, nYear );
++	// The value of nDay outside the range (1-31) are accepted in Visual Basic;
++	// Also the value of nMonth outside the range(1-12) are accepted.
++
++	// If Day is 0, the result is the last day of the previous month.
++	// If Day is -1, the result is the penultimate day of the previous month.
++
++	Date aCurDate( 0, 1, nYear );
++
++	long nDays = nDay;
++
++	// If Month is 0, the result is December of the previous year.
++	// If Month is -1, the result is November of the previous year.
++	// If Month is 13, the result is January of the following year.
++	if( nMonth > 0 )
++	{
++		USHORT nTemp = (nMonth-1)/12;
++		for( USHORT i=0; i < nTemp; i++ )
++		{
++			nDays += 365;
++			if( ImpIsLeapYear(nYear+i))
++				nDays++;
++		}
++
++		nMonth -= nTemp*12;
++		nYear += nTemp;
++		for( USHORT j=1; j< nMonth; j++ )
++		{
++			nDays += ImpDaysInMonth(j,nYear);
++		}
++	}
++
++	if( nMonth <= 0 )
++	{
++		nYear--;
++		nMonth *= -1;
++		nMonth++;
++		USHORT nTemp = nMonth/12;
++
++		for( USHORT i=0; i < nTemp; i++ )
++		{
++			nDays -= 365;
++			if( ImpIsLeapYear(nYear-i))
++				nDays--;
++		}
++
++		nMonth -= nTemp * 12;
++		nYear -= nTemp;
++		for( USHORT j=12; j > 12-nMonth; j--)
++		{
++			nDays -= ImpDaysInMonth(j, nYear);
++		}
++	}
++	
++	aCurDate += nDays;
++
+ 	long nDiffDays = GetDayDiff( aCurDate );
+     rdRet = (double)nDiffDays;
+     return TRUE;

Added: trunk/patches/vba/n353260-datevalue-temp.diff
==============================================================================
--- (empty file)
+++ trunk/patches/vba/n353260-datevalue-temp.diff	Thu Jan 24 05:34:55 2008
@@ -0,0 +1,30 @@
+--- basic/source/runtime/methods.cxx.dateserial	2008-01-23 22:38:41.000000000 +0800
++++ basic/source/runtime/methods.cxx	2008-01-23 22:42:42.000000000 +0800
+@@ -2039,17 +2039,16 @@ RTLFUNC(DateValue)
+ 		double fResult;
+ 		String aStr( rPar.Get(1)->GetString() );
+ 		BOOL bSuccess = pFormatter->IsNumberFormat( aStr, nIndex, fResult );
+-		short nType = pFormatter->GetType( nIndex );
+-		if(bSuccess && (nType==NUMBERFORMAT_DATE || nType==NUMBERFORMAT_DATETIME))
+-		{
+-			if ( nType == NUMBERFORMAT_DATETIME )
+-			{
+-				// Zeit abschneiden
+-				if ( fResult  > 0.0 )
+-					fResult = floor( fResult );
+-				else
+-					fResult = ceil( fResult );
+-			}
++
++		// not check the type of number format. For most number 
++		// can be treated as a date type
++		if(bSuccess)
++		{
++			// Zeit abschneiden
++			if ( fResult  > 0.0 )
++				fResult = floor( fResult );
++			else
++				fResult = ceil( fResult );
+ 			// fResult += 2.0; // Anpassung  StarCalcFormatter
+ 			rPar.Get(0)->PutDate( fResult ); // JSM
+ 		}

Added: trunk/scratch/sc-vba/testvba/TestDocuments/353254-dateserial.xls
==============================================================================
Binary file. No diff available.

Added: trunk/scratch/sc-vba/testvba/TestDocuments/353260-datevalue.xls
==============================================================================
Binary file. No diff available.

Added: trunk/scratch/sc-vba/testvba/TestDocuments/logs/unix/dateserial.log
==============================================================================
--- (empty file)
+++ trunk/scratch/sc-vba/testvba/TestDocuments/logs/unix/dateserial.log	Thu Jan 24 05:34:55 2008
@@ -0,0 +1,9 @@
+Test run started : 01/24/2008 01:24:50 PM
+BEGIN DateSerial
+ TEST START : Test DateSerial function
+  ITEM Assertion OK : the return date is: 06/15/1999
+  ITEM Assertion OK : the return date is: 06/15/1999
+  ITEM Assertion OK : the return date is: 06/15/1999
+ TEST OK : Test DateSerial function
+END  DateSerial
+Test run finished : 01/24/2008 01:24:50 PM

Added: trunk/scratch/sc-vba/testvba/TestDocuments/logs/unix/datevalue.log
==============================================================================
--- (empty file)
+++ trunk/scratch/sc-vba/testvba/TestDocuments/logs/unix/datevalue.log	Thu Jan 24 05:34:55 2008
@@ -0,0 +1,8 @@
+Test run started : 01/24/2008 01:24:41 PM
+BEGIN DateValue
+ TEST START : Test DateValue function
+  ITEM Assertion OK : the return date is: 02/12/1969
+  ITEM Assertion OK : the return date is: 01/21/2008
+ TEST OK : Test DateValue function
+END  DateValue
+Test run finished : 01/24/2008 01:24:41 PM



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]