summaryrefslogtreecommitdiff
path: root/formula
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 /formula
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 'formula')
-rw-r--r--formula/source/core/api/FormulaCompiler.cxx10
-rw-r--r--formula/source/core/api/token.cxx17
-rw-r--r--formula/source/core/resource/core_resource.src9
3 files changed, 30 insertions, 6 deletions
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index 457beeefb4b1..526f83f458df 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -1294,8 +1294,7 @@ void FormulaCompiler::Factor()
// literal double value and keep function. Anything else
// can not be resolved, there exists no "like ISO but week
// starts on Sunday" mode in WEEKNUM and for an expression
- // we can't determine, so let ISOWEEKNUM generate an error
- // for two arguments in these cases.
+ // we can't determine.
if (pc >= 2 && pArr->nIndex == nSepPos + 3 &&
pArr->pCode[nSepPos+1]->GetType() == svDouble &&
pArr->pCode[nSepPos+1]->GetDouble() != 1.0 &&
@@ -1309,10 +1308,9 @@ void FormulaCompiler::Factor()
}
else
{
- /* FIXME: introduce (hidden?) compatibility function? */
-#if 0
- pFacToken->NewOpCode( ocWeeknumCompat, FormulaToken::PrivateAccess());
-#endif
+ // For the remaining two arguments cases use the
+ // compatibility function.
+ pFacToken->NewOpCode( ocWeeknumOOo, FormulaToken::PrivateAccess());
}
}
PutCode( pFacToken );
diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx
index 53bc6204a464..2cd8decdd41a 100644
--- a/formula/source/core/api/token.cxx
+++ b/formula/source/core/api/token.cxx
@@ -1113,6 +1113,7 @@ inline bool MissingConventionODF::isRewriteNeeded( OpCode eOp ) const
case ocAddress:
case ocLogNormDist:
case ocNormDist:
+ case ocWeeknumOOo:
return true;
case ocMissing:
case ocLog:
@@ -1514,6 +1515,22 @@ FormulaTokenArray * FormulaTokenArray::RewriteMissing( const MissingConvention &
( pCur->GetOpCode() == ocCeil ? ocCeil_Math : ocFloor_Math ) );
pNewArr->AddToken( *pToken );
}
+ else if (pCur->GetOpCode() == ocWeeknumOOo &&
+ rConv.getConvention() == MissingConvention::FORMULA_MISSING_CONVENTION_ODFF)
+ {
+ /* XXX TODO FIXME: Remove this special handling (also
+ * ocWeeknumOOo in MissingConventionODF::isRewriteNeeded()
+ * above) in 5.3 or later, this still abuses the ODFF
+ * ISOWEEKNUM function to store the old WEEKNUM (now
+ * WEEKNUM_OOO) cases that can't be mapped to the new WEEKNUM
+ * or ISOWEEKNUM, as 5.0 and earlier always stored the old
+ * WEEKNUM as ISOWEEKNUM. Ugly nasty ...
+ * Later write ORG.LIBREOFFICE.WEEKNUM_OOO, see
+ * formula/source/core/resource/core_resource.src
+ * SC_OPCODE_WEEKNUM_OOO */
+ FormulaToken *pToken = new FormulaByteToken( ocIsoWeeknum, pCur->GetByte(), pCur->IsInForceArray());
+ pNewArr->AddToken( *pToken );
+ }
else
pNewArr->AddToken( *pCur );
}
diff --git a/formula/source/core/resource/core_resource.src b/formula/source/core/resource/core_resource.src
index 90cd6e5266c3..d5db65ec0d7b 100644
--- a/formula/source/core/resource/core_resource.src
+++ b/formula/source/core/resource/core_resource.src
@@ -391,6 +391,9 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF
String SC_OPCODE_BETA_INV_MS { Text = "COM.MICROSOFT.BETA.INV" ; };
String SC_OPCODE_WEEK { Text = "WEEKNUM" ; };
String SC_OPCODE_ISOWEEKNUM { Text = "ISOWEEKNUM" ; };
+ /* WEEKNUM_OOO currently (5.1) not written, see
+ * formula/source/core/api/token.cxx FormulaTokenArray::RewriteMissing() */
+ String SC_OPCODE_WEEKNUM_OOO { Text = "ORG.LIBREOFFICE.WEEKNUM_OOO" ; };
String SC_OPCODE_EASTERSUNDAY { Text = "ORG.OPENOFFICE.EASTERSUNDAY" ; };
String SC_OPCODE_GET_DAY_OF_WEEK { Text = "WEEKDAY" ; };
String SC_OPCODE_NETWORKDAYS { Text = "NETWORKDAYS" ; };
@@ -813,6 +816,7 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_OOXML
String SC_OPCODE_BETA_INV_MS { Text = "_xlfn.BETA.INV" ; };
String SC_OPCODE_WEEK { Text = "WEEKNUM" ; };
String SC_OPCODE_ISOWEEKNUM { Text = "_xlfn.ISOWEEKNUM" ; };
+ String SC_OPCODE_WEEKNUM_OOO { Text = "_xlfn.ORG.LIBREOFFICE.WEEKNUM_OOO" ; };
String SC_OPCODE_EASTERSUNDAY { Text = "EASTERSUNDAY" ; };
String SC_OPCODE_GET_DAY_OF_WEEK { Text = "WEEKDAY" ; };
String SC_OPCODE_NETWORKDAYS { Text = "NETWORKDAYS" ; };
@@ -1237,6 +1241,7 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH
String SC_OPCODE_BETA_INV_MS { Text = "BETA.INV" ; };
String SC_OPCODE_WEEK { Text = "WEEKNUM" ; };
String SC_OPCODE_ISOWEEKNUM { Text = "ISOWEEKNUM" ; };
+ String SC_OPCODE_WEEKNUM_OOO { Text = "WEEKNUM_OOO" ; };
String SC_OPCODE_EASTERSUNDAY { Text = "EASTERSUNDAY" ; };
String SC_OPCODE_GET_DAY_OF_WEEK { Text = "WEEKDAY" ; };
String SC_OPCODE_NETWORKDAYS { Text = "NETWORKDAYS" ; };
@@ -2705,6 +2710,10 @@ Resource RID_STRLIST_FUNCTION_NAMES
{
Text [ en-US ] = "ISOWEEKNUM" ;
};
+ String SC_OPCODE_WEEKNUM_OOO
+ {
+ Text [ en-US ] = "WEEKNUM_OOO" ;
+ };
String SC_OPCODE_EASTERSUNDAY
{
Text [ en-US ] = "EASTERSUNDAY" ;