Bugzilla – Attachment 70309 Details for
Bug 50950
modify calc functions WEEKNUM, WEEKNUM_ADD to comply with ODFF1.2
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
patch sofar, not intended for submitting
fdo50950-20121120.diff (text/plain), 16.23 KB, created by
Winfried Donkers
on 2012-11-20 12:27:57 UTC
(
hide
)
Description:
patch sofar, not intended for submitting
Filename:
MIME Type:
Creator:
Winfried Donkers
Created:
2012-11-20 12:27:57 UTC
Size:
16.23 KB
patch
obsolete
>diff --git a/formula/inc/formula/compiler.hrc b/formula/inc/formula/compiler.hrc >index 6b595ce..000a3d8 100644 >--- a/formula/inc/formula/compiler.hrc >+++ b/formula/inc/formula/compiler.hrc >@@ -187,7 +187,8 @@ > #define SC_OPCODE_UNICODE 159 > #define SC_OPCODE_UNICHAR 160 > #define SC_OPCODE_GAMMA 161 >-#define SC_OPCODE_STOP_1_PAR 162 >+#define SC_OPCODE_ISOWEEKNUM 162 >+#define SC_OPCODE_STOP_1_PAR 163 > > /*** Functions with more than one parameters ***/ > #define SC_OPCODE_START_2_PAR 201 >@@ -355,7 +356,6 @@ > #define SC_OPCODE_TABLE_OP 362 > #define SC_OPCODE_BETA_DIST 363 > #define SC_OPCODE_BETA_INV 364 >-#define SC_OPCODE_WEEK 365 /* miscellaneous */ > #define SC_OPCODE_GET_DAY_OF_WEEK 366 > #define SC_OPCODE_NO_NAME 367 > #define SC_OPCODE_STYLE 368 >diff --git a/formula/inc/formula/opcode.hxx b/formula/inc/formula/opcode.hxx >index 14f862f..9ec4bfe 100644 >--- a/formula/inc/formula/opcode.hxx >+++ b/formula/inc/formula/opcode.hxx >@@ -367,7 +367,7 @@ enum OpCodeEnum > ocBitRshift = SC_OPCODE_BITRSHIFT, > ocBitLshift = SC_OPCODE_BITLSHIFT, > // miscellaneous >- ocWeek = SC_OPCODE_WEEK, >+ ocIsoWeeknum = SC_OPCODE_ISOWEEKNUM, > ocGetDayOfWeek = SC_OPCODE_GET_DAY_OF_WEEK, > ocNoName = SC_OPCODE_NO_NAME, > ocStyle = SC_OPCODE_STYLE, >diff --git a/formula/source/core/resource/core_resource.src b/formula/source/core/resource/core_resource.src >index 5d4615b..abd5df2 100644 >--- a/formula/source/core/resource/core_resource.src >+++ b/formula/source/core/resource/core_resource.src >@@ -317,7 +317,7 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF > String SC_OPCODE_TABLE_OP { Text = "MULTIPLE.OPERATIONS" ; }; > String SC_OPCODE_BETA_DIST { Text = "BETADIST" ; }; > String SC_OPCODE_BETA_INV { Text = "BETAINV" ; }; >- String SC_OPCODE_WEEK { Text = "ISOWEEKNUM" ; }; >+ String SC_OPCODE_ISOWEEKNUM { Text = "ISOWEEKNUM" ; }; > String SC_OPCODE_EASTERSUNDAY { Text = "ORG.OPENOFFICE.EASTERSUNDAY" ; }; > String SC_OPCODE_GET_DAY_OF_WEEK { Text = "WEEKDAY" ; }; > String SC_OPCODE_NO_NAME { Text = "#NAME!" ; }; >@@ -650,7 +650,7 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH > String SC_OPCODE_TABLE_OP { Text = "TABLE" ; }; > String SC_OPCODE_BETA_DIST { Text = "BETADIST" ; }; > String SC_OPCODE_BETA_INV { Text = "BETAINV" ; }; >- String SC_OPCODE_WEEK { Text = "WEEKNUM" ; }; >+ String SC_OPCODE_ISOWEEKNUM { Text = "WEEKNUM" ; }; > String SC_OPCODE_EASTERSUNDAY { Text = "EASTERSUNDAY" ; }; > String SC_OPCODE_GET_DAY_OF_WEEK { Text = "WEEKDAY" ; }; > String SC_OPCODE_NO_NAME { Text = "#NAME!" ; }; >@@ -1794,9 +1794,9 @@ Resource RID_STRLIST_FUNCTION_NAMES > { > Text [ en-US ] = "BETAINV" ; > }; >- String SC_OPCODE_WEEK >+ String SC_OPCODE_ISOWEEKNUM > { >- Text [ en-US ] = "WEEKNUM" ; >+ Text [ en-US ] = "ISOWEEKNUM" ; > }; > String SC_OPCODE_EASTERSUNDAY > { >diff --git a/helpcontent2 b/helpcontent2 >--- a/helpcontent2 >+++ b/helpcontent2 >@@ -1 +1 @@ >-Subproject commit c3cfcf7098787f11ca987ef8db65fbb670d8da6e >+Subproject commit c3cfcf7098787f11ca987ef8db65fbb670d8da6e-dirty >diff --git a/sc/inc/helpids.h b/sc/inc/helpids.h >index 8695891..3586dcd 100644 >--- a/sc/inc/helpids.h >+++ b/sc/inc/helpids.h >@@ -396,7 +396,8 @@ > #define HID_FUNC_JAHR "SC_HID_FUNC_JAHR" > #define HID_FUNC_TAGE "SC_HID_FUNC_TAGE" > #define HID_FUNC_DATEDIF "SC_HID_FUNC_DATEDIF" >-#define HID_FUNC_KALENDERWOCHE "SC_HID_FUNC_KALENDERWOCHE" >+#define HID_FUNC_ISOWEEKNUM "SC_HID_FUNC_ISOWEEKNUM" >+#define HID_FUNC_WEEKNUM "SC_HID_FUNC_WEEKNUM" > #define HID_FUNC_OSTERSONNTAG "SC_HID_FUNC_OSTERSONNTAG" > > #define HID_FUNC_BW "SC_HID_FUNC_BW" >diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx >index 59a70f8..6e4d487 100644 >--- a/sc/qa/unit/ucalc.cxx >+++ b/sc/qa/unit/ucalc.cxx >@@ -3859,6 +3859,7 @@ void Test::testFunctionLists() > "DAYS360", > "EASTERSUNDAY", > "HOUR", >+ "ISOWEEKNUM", > "MINUTE", > "MONTH", > "NOW", >@@ -3867,7 +3868,6 @@ void Test::testFunctionLists() > "TIMEVALUE", > "TODAY", > "WEEKDAY", >- "WEEKNUM", > "YEAR", > 0 > }; >diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx >index b0cfa6a..fedf356 100644 >--- a/sc/source/core/inc/interpre.hxx >+++ b/sc/source/core/inc/interpre.hxx >@@ -569,7 +569,7 @@ void ScGetYear(); > void ScGetMonth(); > void ScGetDay(); > void ScGetDayOfWeek(); >-void ScGetWeekOfYear(); >+void ScGetIsoWeekOfYear(); > void ScEasterSunday(); > void ScGetHour(); > void ScGetMin(); >diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx >index 9e50563..7cbbd15 100644 >--- a/sc/source/core/tool/interpr2.cxx >+++ b/sc/source/core/tool/interpr2.cxx >@@ -225,16 +225,15 @@ void ScInterpreter::ScGetDayOfWeek() > } > } > >-void ScInterpreter::ScGetWeekOfYear() >+//fdo50950 calc function for ISOWEEKNUM, in complete compliance with ODFF1.2 >+void ScInterpreter::ScGetIsoWeekOfYear() > { >- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScGetWeekOfYear" ); >- if ( MustHaveParamCount( GetByte(), 2 ) ) >+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScGetIsoWeekOfYear" ); >+ if ( MustHaveParamCount( GetByte(), 1 ) ) > { >- short nFlag = (short) ::rtl::math::approxFloor(GetDouble()); >- > Date aDate = *(pFormatter->GetNullDate()); > aDate += (long)::rtl::math::approxFloor(GetDouble()); >- PushInt( (int) aDate.GetWeekOfYear( nFlag == 1 ? SUNDAY : MONDAY )); >+ PushInt( (int) aDate.GetWeekOfYear( MONDAY, 4 ) ); > } > } > >diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx >index fc519c7..a8ba303 100644 >--- a/sc/source/core/tool/interpr4.cxx >+++ b/sc/source/core/tool/interpr4.cxx >@@ -2721,7 +2721,7 @@ void ScInterpreter::ScExternal() > } > else if ( ( aUnoName = ScGlobal::GetAddInCollection()->FindFunction(aFuncName, false) ).Len() ) > { >- // bLocalFirst=false in FindFunction, cFunc should be the stored >+ // bLocalFirst=false in FindFunction, cFunc should be the stored > // internal name > > ScUnoAddInCall aCall( *ScGlobal::GetAddInCollection(), aUnoName, nParamCount ); >@@ -3933,7 +3933,7 @@ StackVar ScInterpreter::Interpret() > case ocGetMonth : ScGetMonth(); break; > case ocGetDay : ScGetDay(); break; > case ocGetDayOfWeek : ScGetDayOfWeek(); break; >- case ocWeek : ScGetWeekOfYear(); break; >+ case ocIsoWeeknum : ScGetIsoWeekOfYear(); break; > case ocEasterSunday : ScEasterSunday(); break; > case ocGetHour : ScGetHour(); break; > case ocGetMin : ScGetMin(); break; >diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx >index d299aa2..d52249b 100644 >--- a/sc/source/filter/excel/xlformula.cxx >+++ b/sc/source/filter/excel/xlformula.cxx >@@ -391,7 +391,7 @@ static const XclFunctionInfo saFuncTable_Odf[] = > EXC_FUNCENTRY_ODF( ocGauss, 1, 1, 0, "GAUSS" ), > EXC_FUNCENTRY_ODF( ocNoName, 2, 2, 0, "IFNA" ), > EXC_FUNCENTRY_ODF( ocIsFormula, 1, 1, 0, "ISFORMULA" ), >- EXC_FUNCENTRY_ODF( ocWeek, 1, 2, 0, "ISOWEEKNUM" ), >+ EXC_FUNCENTRY_ODF( ocIsoWeeknum, 1, 1, 0, "ISOWEEKNUM" ), > EXC_FUNCENTRY_ODF( ocMatrixUnit, 1, 1, 0, "MUNIT" ), > EXC_FUNCENTRY_ODF( ocNumberValue, 2, 2, 0, "NUMBERVALUE" ), > EXC_FUNCENTRY_ODF( ocLaufz, 3, 3, 0, "PDURATION" ), >diff --git a/sc/source/ui/src/scfuncs.src b/sc/source/ui/src/scfuncs.src >index d05a075..024694b 100644 >--- a/sc/source/ui/src/scfuncs.src >+++ b/sc/source/ui/src/scfuncs.src >@@ -1018,19 +1018,19 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS1 > Text [ en-US ] = "Interval to be calculated. Can be \"d\", \"m\", \"y\", \"ym\", \"md\" or \"yd\"."; > }; > }; >- // -=*# Resource for function KALENDERWOCHE #*=- >- Resource SC_OPCODE_WEEK >+ // -=*# Resource for function ISOWEEKNUM #*=- >+ Resource SC_OPCODE_ISOWEEKNUM > { > String 1 // Description > { >- Text [ en-US ] = "Calculates the calendar week corresponding to the given date." ; >+ Text [ en-US ] = "Calculates the ISO 8601 calender week for the given date: first day of week is Monday and week 1 is the week where the first Thursday of the year occurs)." ; > }; > ExtraData = > { > 0; > ID_FUNCTION_GRP_DATETIME; >- U2S( HID_FUNC_KALENDERWOCHE ); >- 2; 0; 0; >+ U2S( HID_FUNC_ISOWEEKNUM ); >+ 1; 0; 0; > 0; > }; > String 2 // Name of Parameter 1 >@@ -1041,14 +1041,6 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS1 > { > Text [ en-US ] = "The internal number of the date." ; > }; >- String 4 // Name of Parameter 2 >- { >- Text [ en-US ] = "mode" ; >- }; >- String 5 // Description of Parameter 2 >- { >- Text [ en-US ] = "Indicates the first day of the week (1 = Sunday, other values = Monday)." ; >- }; > }; > // -=*# Resource for function OSTERSONNTAG #*=- > Resource SC_OPCODE_EASTERSUNDAY >@@ -5518,7 +5510,7 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2 > { > String 1 // Description > { >- Text [ en-US ] = "Returns the discrete probability of an interval." ; >+ Text [ en-US ] = "Returns the discreet probability of an interval." ; > }; > ExtraData = > { >diff --git a/sc/util/hidother.src b/sc/util/hidother.src >index 9b3c3fb..a897c9e 100644 >--- a/sc/util/hidother.src >+++ b/sc/util/hidother.src >@@ -114,7 +114,7 @@ hidspecial HID_FUNC_WOCHENTAG { HelpID = HID_FUNC_WOCHENTAG; }; > hidspecial HID_FUNC_JAHR { HelpID = HID_FUNC_JAHR; }; > hidspecial HID_FUNC_TAGE { HelpID = HID_FUNC_TAGE; }; > hidspecial HID_FUNC_DATEDIF { HelpID = HID_FUNC_DATEDIF; }; >-hidspecial HID_FUNC_KALENDERWOCHE { HelpID = HID_FUNC_KALENDERWOCHE; }; >+hidspecial HID_FUNC_ISOWEEKNUM { HelpID = HID_FUNC_ISOWEEKNUM; }; > hidspecial HID_FUNC_OSTERSONNTAG { HelpID = HID_FUNC_OSTERSONNTAG; }; > hidspecial HID_FUNC_BW { HelpID = HID_FUNC_BW; }; > hidspecial HID_FUNC_ZW { HelpID = HID_FUNC_ZW; }; >diff --git a/scaddins/idl/com/sun/star/sheet/addin/XAnalysis.idl b/scaddins/idl/com/sun/star/sheet/addin/XAnalysis.idl >index e349284..40b5394 100644 >--- a/scaddins/idl/com/sun/star/sheet/addin/XAnalysis.idl >+++ b/scaddins/idl/com/sun/star/sheet/addin/XAnalysis.idl >@@ -60,7 +60,7 @@ module addin > /// weeknum. > long getWeeknum( > [in] com::sun::star::beans::XPropertySet xOptions, >- [in] long nStartDate, [in] long nMode ) >+ [in] long nStartDate, [in] any rMode ) > raises( com::sun::star::lang::IllegalArgumentException ); > > /// eomonth. >diff --git a/scaddins/source/analysis/analysis.cxx b/scaddins/source/analysis/analysis.cxx >index bf1ef36..9f67a53 100644 >--- a/scaddins/source/analysis/analysis.cxx >+++ b/scaddins/source/analysis/analysis.cxx >@@ -29,6 +29,7 @@ > > #include <tools/resmgr.hxx> > #include <tools/rcid.h> >+#include <tools/date.hxx> > #include "analysis.hrc" > #include "bessel.hxx" > >@@ -588,17 +589,44 @@ sal_Int32 SAL_CALL AnalysisAddIn::getEdate( constREFXPS& xOpt, sal_Int32 nStartD > } > > >-sal_Int32 SAL_CALL AnalysisAddIn::getWeeknum( constREFXPS& xOpt, sal_Int32 nDate, sal_Int32 nMode ) THROWDEF_RTE_IAE >+//fdo50950 calc function WEEKNUM, in complete compliance with ODFF1.2 >+sal_Int32 SAL_CALL AnalysisAddIn::getWeeknum( constREFXPS& xOpt, sal_Int32 nDate, const ANY& rMode ) THROWDEF_RTE_IAE > { > nDate += GetNullDate( xOpt ); >- > sal_uInt16 nDay, nMonth, nYear; > DaysToDate( nDate, nDay, nMonth, nYear ); > >- sal_Int32 nFirstInYear = DateToDays( 1, 1, nYear ); >- sal_uInt16 nFirstDayInYear = GetDayOfWeek( nFirstInYear ); >+ nDate = 10000 * nYear + 100 * nMonth + nDay; >+ Date aDate( nDate ); > >- return ( nDate - nFirstInYear + ( ( nMode == 1 )? ( nFirstDayInYear + 1 ) % 7 : nFirstDayInYear ) ) / 7 + 1; >+ sal_Int32 nMinimumNumberOfDaysInWeek; >+ DayOfWeek eFirstDayOfWeek; >+ sal_Int32 nMode = aAnyConv.getInt32( xOpt, rMode, 1 ); >+ switch ( nMode ) >+ { >+ case 1 : >+ case 11 : >+ case 2 : >+ case 12 : >+ case 13 : >+ case 14 : >+ case 15 : >+ case 16 : >+ case 17 : >+ eFirstDayOfWeek = (DayOfWeek) ( ( nMode - 1 ) % 10 ); >+ nMinimumNumberOfDaysInWeek = 1; //the week containing January 1 is week 1 >+ break; >+ case 21 : >+ case 150 : >+ // ISO 8601 >+ eFirstDayOfWeek = MONDAY; >+ nMinimumNumberOfDaysInWeek = 4; >+ break; >+ default : >+ //incorrect argument >+ throw lang::IllegalArgumentException(); >+ } >+ return ( aDate.GetWeekOfYear( eFirstDayOfWeek, nMinimumNumberOfDaysInWeek ) ); > } > > >diff --git a/scaddins/source/analysis/analysis.hxx b/scaddins/source/analysis/analysis.hxx >index d89cbe2..64afdc6 100644 >--- a/scaddins/source/analysis/analysis.hxx >+++ b/scaddins/source/analysis/analysis.hxx >@@ -116,7 +116,7 @@ public: > virtual sal_Int32 SAL_CALL getWorkday( constREFXPS&, sal_Int32 nStartDate, sal_Int32 nDays, const ANY& aHDay ) THROWDEF_RTE_IAE; > virtual double SAL_CALL getYearfrac( constREFXPS&, sal_Int32 nStartDate, sal_Int32 nEndDate, const ANY& aMode ) THROWDEF_RTE_IAE; > virtual sal_Int32 SAL_CALL getEdate( constREFXPS&, sal_Int32 nStartDate, sal_Int32 nMonths ) THROWDEF_RTE_IAE; >- virtual sal_Int32 SAL_CALL getWeeknum( constREFXPS&, sal_Int32 nStartDate, sal_Int32 nMode ) THROWDEF_RTE_IAE; >+ virtual sal_Int32 SAL_CALL getWeeknum( constREFXPS& xOpt, sal_Int32 nStartDate, const ANY& rMode ) THROWDEF_RTE_IAE; > virtual sal_Int32 SAL_CALL getEomonth( constREFXPS&, sal_Int32 nStartDate, sal_Int32 nMonths ) THROWDEF_RTE_IAE; > virtual sal_Int32 SAL_CALL getNetworkdays( constREFXPS&, sal_Int32 nStartDate, sal_Int32 nEndDate, const ANY& aHDay ) THROWDEF_RTE_IAE; > >diff --git a/scaddins/source/analysis/analysis.src b/scaddins/source/analysis/analysis.src >index 87368f6..e089574 100644 >--- a/scaddins/source/analysis/analysis.src >+++ b/scaddins/source/analysis/analysis.src >@@ -126,29 +126,25 @@ Resource RID_ANALYSIS_FUNCTION_DESCRIPTIONS > > Resource ANALYSIS_Weeknum > { >- String 1 // description Weeknum_add >+ String 1 // Description for WEEKNUM > { >- Text [ en-US ] = "Returns the number of the calendar week in which the specified date occurs."; >+ Text [ en-US ] = "Calculates the calendar week corresponding to the given date." ; > }; >- >- String 2 // name of parameter 1 Weeknum_add >+ String 2 // Name of Parameter 1 > { >- Text [ en-US ] = "Date"; >+ Text [ en-US ] = "Number" ; > }; >- >- String 3 // description of parameter 1 Weeknum_add >+ String 3 // Description of Parameter 1 > { >- Text [ en-US ] = "The date"; >+ Text [ en-US ] = "The internal number of the date." ; > }; >- >- String 4 // name of parameter 2 Weeknum_add >+ String 4 // Name of Parameter 2 > { >- Text [ en-US ] = "Return type"; >+ Text [ en-US ] = "mode" ; > }; >- >- String 5 // description of parameter 2 Weeknum_add >+ String 5 // Description of Parameter 2 > { >- Text [ en-US ] = "A number from 1 to 3 that specifies the day with which a week begins"; >+ Text [ en-US ] = "Indicates the first day of the week (1, 11=Sunday, 2, 12=Monday, 13-17=Tuesday-Saturday. 21 or 150 calculate according to ISO 8601)." ; > }; > }; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 50950
:
63254
|
63255
|
64112
|
64113
|
64281
| 70309