diff options
-rw-r--r-- | formula/source/core/resource/core_resource.src | 7 | ||||
-rw-r--r-- | include/formula/compiler.hrc | 3 | ||||
-rw-r--r-- | include/formula/opcode.hxx | 1 | ||||
-rw-r--r-- | sc/inc/helpids.h | 1 | ||||
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 1 | ||||
-rw-r--r-- | sc/source/core/inc/interpre.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 66 | ||||
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/excel/xlformula.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/oox/formulabase.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/src/scfuncs.src | 24 |
11 files changed, 109 insertions, 6 deletions
diff --git a/formula/source/core/resource/core_resource.src b/formula/source/core/resource/core_resource.src index 1e76de27c223..8a90a9cee238 100644 --- a/formula/source/core/resource/core_resource.src +++ b/formula/source/core/resource/core_resource.src @@ -145,6 +145,7 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF String SC_OPCODE_GAMMA_LN { Text = "GAMMALN" ; }; String SC_OPCODE_GAMMA_LN_MS { Text = "COM.MICROSOFT.GAMMALN.PRECISE" ; }; String SC_OPCODE_ERROR_TYPE { Text = "ORG.OPENOFFICE.ERRORTYPE" ; }; + String SC_OPCODE_ERROR_TYPE_ODF { Text = "ERROR.TYPE" ; }; String SC_OPCODE_FORMULA { Text = "FORMULA"; }; String SC_OPCODE_ARC_TAN_2 { Text = "ATAN2" ; }; String SC_OPCODE_CEIL { Text = "CEILING" ; }; @@ -552,6 +553,7 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_OOXML String SC_OPCODE_GAMMA_LN { Text = "GAMMALN" ; }; String SC_OPCODE_GAMMA_LN_MS { Text = "_xlfn.GAMMALN.PRECISE" ; }; String SC_OPCODE_ERROR_TYPE { Text = "ERRORTYPE" ; }; + String SC_OPCODE_ERROR_TYPE_ODF { Text = "ERROR.TYPE" ; }; String SC_OPCODE_FORMULA { Text = "_xlfn.FORMULATEXT"; }; String SC_OPCODE_ARC_TAN_2 { Text = "ATAN2" ; }; String SC_OPCODE_CEIL { Text = "CEILING" ; }; @@ -961,6 +963,7 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH String SC_OPCODE_GAMMA_LN { Text = "GAMMALN" ; }; String SC_OPCODE_GAMMA_LN_MS { Text = "GAMMALN.PRECISE" ; }; String SC_OPCODE_ERROR_TYPE { Text = "ERRORTYPE" ; }; + String SC_OPCODE_ERROR_TYPE_ODF { Text = "ERROR.TYPE" ; }; String SC_OPCODE_FORMULA { Text = "FORMULA"; }; String SC_OPCODE_ARC_TAN_2 { Text = "ATAN2" ; }; String SC_OPCODE_CEIL { Text = "CEILING" ; }; @@ -1659,6 +1662,10 @@ Resource RID_STRLIST_FUNCTION_NAMES { Text [ en-US ] = "ERRORTYPE" ; }; + String SC_OPCODE_ERROR_TYPE_ODF + { + Text [ en-US ] = "ERROR.TYPE" ; + }; String SC_OPCODE_FORMULA { Text [ en-US ] = "FORMULA" ; diff --git a/include/formula/compiler.hrc b/include/formula/compiler.hrc index 5686a8b21cbf..1d6b901f15ab 100644 --- a/include/formula/compiler.hrc +++ b/include/formula/compiler.hrc @@ -194,7 +194,8 @@ #define SC_OPCODE_GAMMA_LN_MS 162 #define SC_OPCODE_ERF_MS 163 #define SC_OPCODE_ERFC_MS 164 -#define SC_OPCODE_STOP_1_PAR 165 +#define SC_OPCODE_ERROR_TYPE_ODF 165 +#define SC_OPCODE_STOP_1_PAR 166 /*** Functions with more than one parameters ***/ #define SC_OPCODE_START_2_PAR 201 diff --git a/include/formula/opcode.hxx b/include/formula/opcode.hxx index c9e105d4787b..33cf54ce5427 100644 --- a/include/formula/opcode.hxx +++ b/include/formula/opcode.hxx @@ -178,6 +178,7 @@ enum OpCode : sal_uInt16 ocGammaLn_MS = SC_OPCODE_GAMMA_LN_MS, ocGamma = SC_OPCODE_GAMMA, ocErrorType = SC_OPCODE_ERROR_TYPE, + ocErrorType_ODF = SC_OPCODE_ERROR_TYPE_ODF, ocFormula = SC_OPCODE_FORMULA, ocArabic = SC_OPCODE_ARABIC, ocInfo = SC_OPCODE_INFO, diff --git a/sc/inc/helpids.h b/sc/inc/helpids.h index 1e820214e10e..9768806cdf7a 100644 --- a/sc/inc/helpids.h +++ b/sc/inc/helpids.h @@ -624,5 +624,6 @@ #define HID_FUNC_ERF_MS "SC_HID_FUNC_ERF_MS" #define HID_FUNC_ERFC_MS "SC_HID_FUNC_ERFC_MS" #define HID_FUNC_AGGREGATE "SC_HID_FUNC_AGGREGATE" +#define HID_FUNC_ERROR_TYPE_ODF "SC_HID_FUNC_ERROR_TYPE_ODF" /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index e5cb0508a546..cb9dda996ede 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -2638,6 +2638,7 @@ void Test::testFunctionLists() "COLUMN", "COLUMNS", "DDE", + "ERROR.TYPE", "ERRORTYPE", "GETPIVOTDATA", "HLOOKUP", diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index 9904cbcb9d22..d7710edb35c6 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -571,7 +571,9 @@ void ScMissing(); void ScMacro(); bool SetSbxVariable( SbxVariable* pVar, const ScAddress& ); bool SetSbxVariable( SbxVariable* pVar, SCCOL nCol, SCROW nRow, SCTAB nTab ); +sal_uInt16 GetErrorType(); void ScErrorType(); +void ScErrorType_ODF(); void ScDBArea(); void ScColRowNameAuto(); void ScGetPivotData(); diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 9f620ec500f6..7d5975d4bba9 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -8242,7 +8242,7 @@ void ScInterpreter::ScConcat() PushString( aRes ); } -void ScInterpreter::ScErrorType() +sal_uInt16 ScInterpreter::GetErrorType() { sal_uInt16 nErr; sal_uInt16 nOldError = nGlobalError; @@ -8310,6 +8310,13 @@ void ScInterpreter::ScErrorType() PopError(); nErr = nGlobalError; } + nGlobalError = nOldError; + return nErr; +} + +void ScInterpreter::ScErrorType() +{ + sal_uInt16 nErr = GetErrorType(); if ( nErr ) { nGlobalError = 0; @@ -8317,11 +8324,66 @@ void ScInterpreter::ScErrorType() } else { - nGlobalError = nOldError; PushNA(); } } +void ScInterpreter::ScErrorType_ODF() +{ + sal_uInt16 nErr = GetErrorType(); + sal_uInt16 nErrType; + + switch ( nErr ) + { + case errParameterExpected : // #NULL! + nErrType = 1; + break; + case errDivisionByZero : // #DIV/0! + nErrType = 2; + break; + case errNoValue : // #VALUE! + nErrType = 3; + break; + case errNoRef : // #REF! + nErrType = 4; + break; + case errNoName : // #NAME? + nErrType = 5; + break; + case errIllegalFPOperation : // #NUM! + nErrType = 6; + break; + case NOTAVAILABLE : // #N/A + nErrType = 7; + break; + /* + #GETTING_DATA is a message that can appear in Excel when a large or + complex worksheet is being calculated. In Excel 2007 and newer, + operations are grouped so more complicated cells may finish after + earlier ones do. While the calculations are still processing, the + unfinished cells may display #GETTING_DATA. + Because the message is temporary and disappears when the calculations + complete, this isn’t a true error. + No calc error code known (yet). + + case : // GETTING_DATA + nErrType = 8; + break; + */ + default : + nErrType = 0; + break; + } + + if ( nErrType ) + { + nGlobalError = 0; + PushDouble( nErrType ); + } + else + PushNA(); +} + bool ScInterpreter::MayBeRegExp( const OUString& rStr, const ScDocument* pDoc ) { if ( pDoc && !pDoc->GetDocOptions().IsFormulaRegexEnabled() ) diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 8e66eaf6cde9..b276bf904195 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -4222,6 +4222,7 @@ StackVar ScInterpreter::Interpret() case ocTableOp : ScTableOp(); break; case ocStop : break; case ocErrorType : ScErrorType(); break; + case ocErrorType_ODF : ScErrorType_ODF(); break; case ocCurrent : ScCurrent(); break; case ocStyle : ScStyle(); break; case ocDde : ScDde(); break; @@ -4328,7 +4329,8 @@ StackVar ScInterpreter::Interpret() case ocN : \ case ocType : \ case ocIfError : \ - case ocIfNA : + case ocIfNA : \ + case ocErrorType_ODF : switch ( eOp ) { diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx index 31b70a47aa95..e4d28491c9cb 100644 --- a/sc/source/filter/excel/xlformula.cxx +++ b/sc/source/filter/excel/xlformula.cxx @@ -566,7 +566,8 @@ static const XclFunctionInfo saFuncTable_2013[] = EXC_FUNCENTRY_V_VR( ocUnichar, 1, 1, 0, "UNICHAR" ), EXC_FUNCENTRY_V_VR( ocUnicode, 1, 1, 0, "UNICODE" ), EXC_FUNCENTRY_V_VR( ocWebservice, 1, 1, 0, "WEBSERVICE" ), - EXC_FUNCENTRY_V_RX( ocXor, 1, MX, 0, "XOR" ) + EXC_FUNCENTRY_V_RX( ocXor, 1, MX, 0, "XOR" ), + EXC_FUNCENTRY_V_VR( ocErrorType_ODF, 1, 1, 0, "ERROR.TYPE" ) }; #define EXC_FUNCENTRY_ODF( opcode, minparam, maxparam, flags, asciiname ) \ diff --git a/sc/source/filter/oox/formulabase.cxx b/sc/source/filter/oox/formulabase.cxx index 831931360664..29361899e940 100644 --- a/sc/source/filter/oox/formulabase.cxx +++ b/sc/source/filter/oox/formulabase.cxx @@ -896,7 +896,8 @@ static const FunctionData saFuncTable2013[] = { "UNICHAR", "UNICHAR", NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_MACROCALL_NEW }, { "UNICODE", "UNICODE", NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_MACROCALL_NEW }, { "COM.MICROSOFT.WEBSERVICE","WEBSERVICE", NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_MACROCALL_NEW }, - { "XOR", "XOR", NOID, NOID, 1, MX, V, { RX }, FUNCFLAG_MACROCALL_NEW } + { "XOR", "XOR", NOID, NOID, 1, MX, V, { RX }, FUNCFLAG_MACROCALL_NEW }, + { "ERROR.TYPE", "ERROR.TYPE", NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_MACROCALL_NEW } }; /** Functions defined by OpenFormula, but not supported by Calc or by Excel. */ diff --git a/sc/source/ui/src/scfuncs.src b/sc/source/ui/src/scfuncs.src index 6757a627d20f..d6950dc9c798 100644 --- a/sc/source/ui/src/scfuncs.src +++ b/sc/source/ui/src/scfuncs.src @@ -10410,6 +10410,30 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2 Text [ en-US ] = "The reference (cell) in which the error occurred." ; }; }; + // -=*# Resource for function ERROR.TYPE #*=- + Resource SC_OPCODE_ERROR_TYPE_ODF + { + String 1 // Description + { + Text [ en-US ] = "Returns a number corresponding to one of the error values or #N/A if no error exists" ; + }; + ExtraData = + { + 0; + ID_FUNCTION_GRP_TABLE; + U2S( HID_FUNC_ERROR_TYPE_ODF ); + 1; 0; + 0; + }; + String 2 // Name of Parameter 1 + { + Text [ en-US ] = "expression" ; + }; + String 3 // Description of Parameter 1 + { + Text [ en-US ] = "The error value whose identifying number you want to find. Can be the actual error value or a reference to a cell that you want to test." ; + }; + }; // -=*# Resource for function VORLAGE #*=- Resource SC_OPCODE_STYLE { |