summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-01-05 19:13:54 +0100
committerEike Rathke <erack@redhat.com>2016-01-05 20:55:45 +0100
commitefeef720de31fe0fab9013f954eac63fe49fa59d (patch)
tree6e87324e730a61e51d443b41deb08e0e5c25e904 /sc/source
parent02148691fdd839da0fa26cd49105d0a002d04154 (diff)
tdf#96198 add WEEKNUM_OOO compatibility function, tdf#50950 follow-up
The remaining cases when loading old and wrong ISOWEEKNUM that can't be mapped to either new WEEKNUM or ISOWEEKNUM now are mapped to WEEKNUM_OOO(date,mode) with calculations identical to the old and wrong OOo WEEKNUM. These WEEKNUM_OOO cases are still wrongly saved as ISOWEEKNUM so can be read by 5.0 or earlier versions as the old WEEKNUM, which should be changed for 5.3 or later. WEEKNUM_OOO is not offered in the Function Wizard to prevent deliberate usage. Also reverts the interim unit test change to sc/qa/unit/data/contentCSV/date-time-functions.csv that was necessary to catch the error generated by ISOWEEKNUM with two arguments. (cherry picked from commit 902c593196741ffec2d096855369313f6bbe756e) Conflicts: include/formula/compiler.hrc sc/inc/helpids.h sc/source/filter/excel/xlformula.cxx Change-Id: I874c4c7225900f03b879f2947512ae02270cbd4f
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/inc/interpre.hxx1
-rw-r--r--sc/source/core/tool/interpr2.cxx12
-rw-r--r--sc/source/core/tool/interpr4.cxx1
-rw-r--r--sc/source/filter/excel/xlformula.cxx3
4 files changed, 16 insertions, 1 deletions
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 9bdb46135506..c2686e915c7f 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -619,6 +619,7 @@ void ScGetDay();
void ScGetDayOfWeek();
void ScGetWeekOfYear();
void ScGetIsoWeekOfYear();
+void ScWeeknumOOo();
void ScEasterSunday();
sal_uInt16 GetWeekendAndHolidayMasks( const sal_uInt8 nParamCount, const sal_uInt32 nNullDate,
::std::vector<double>& rSortArray, bool bWeekendMask[ 7 ] );
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 1777230b1142..ef2277ada4bd 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -205,6 +205,18 @@ void ScInterpreter::ScGetDayOfWeek()
}
}
+void ScInterpreter::ScWeeknumOOo()
+{
+ if ( MustHaveParamCount( GetByte(), 2 ) )
+ {
+ 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 ));
+ }
+}
+
void ScInterpreter::ScGetWeekOfYear()
{
sal_uInt8 nParamCount = GetByte();
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index d6b969425e8a..cc0b4bcefabc 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3701,6 +3701,7 @@ StackVar ScInterpreter::Interpret()
case ocGetDayOfWeek : ScGetDayOfWeek(); break;
case ocWeek : ScGetWeekOfYear(); break;
case ocIsoWeeknum : ScGetIsoWeekOfYear(); break;
+ case ocWeeknumOOo : ScWeeknumOOo(); break;
case ocEasterSunday : ScEasterSunday(); break;
case ocNetWorkdays : ScNetWorkdays( false); break;
case ocNetWorkdays_MS : ScNetWorkdays( true ); break;
diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx
index 5d060cf739ba..e320c6f9cfb0 100644
--- a/sc/source/filter/excel/xlformula.cxx
+++ b/sc/source/filter/excel/xlformula.cxx
@@ -587,7 +587,8 @@ static const XclFunctionInfo saFuncTable_Odf[] =
static const XclFunctionInfo saFuncTable_OOoLO[] =
{
EXC_FUNCENTRY_OOO( ocConvert, 3, 3, 0, "ORG.OPENOFFICE.CONVERT" ),
- EXC_FUNCENTRY_OOO( ocColor, 3, 4, 0, "ORG.LIBREOFFICE.COLOR" )
+ EXC_FUNCENTRY_OOO( ocColor, 3, 4, 0, "ORG.LIBREOFFICE.COLOR" ),
+ EXC_FUNCENTRY_OOO( ocWeeknumOOo, 2, 2, 0, "ORG.LIBREOFFICE.WEEKNUM_OOO" )
};
#undef EXC_FUNCENTRY_OOO