diff options
author | Winfried Donkers <osc@dci-electronics.nl> | 2012-06-09 12:43:30 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2012-06-12 22:30:00 +0200 |
commit | 033cce3e0fbb72a9400836923be96c5036aaacb0 (patch) | |
tree | 9436b0e5e28152fc0dce036e89fa0722babebe46 /sc | |
parent | a741932eb4e83148a341cfd5c6a30ff1878e3149 (diff) |
fdo#50822 add function XOR to calc as in ODFF1.2
Change-Id: I994119c0520658775d07f776237d31a03f53ab52
Diffstat (limited to 'sc')
-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 | 1 | ||||
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 101 | ||||
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 1 | ||||
-rw-r--r-- | sc/source/core/tool/parclass.cxx | 1 | ||||
-rw-r--r-- | sc/source/filter/oox/formulabase.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/src/scfuncs.src | 24 | ||||
-rw-r--r-- | sc/source/ui/vba/vbawsfunction.cxx | 2 | ||||
-rw-r--r-- | sc/util/hidother.src | 1 |
10 files changed, 133 insertions, 1 deletions
diff --git a/sc/inc/helpids.h b/sc/inc/helpids.h index 7c5955c240c4..e2f6e0612468 100644 --- a/sc/inc/helpids.h +++ b/sc/inc/helpids.h @@ -487,6 +487,7 @@ #define HID_FUNC_WENN "SC_HID_FUNC_WENN" #define HID_FUNC_ODER "SC_HID_FUNC_ODER" #define HID_FUNC_UND "SC_HID_FUNC_UND" +#define HID_FUNC_XOR "SC_HID_FUNC_XOR" #define HID_FUNC_ABS "SC_HID_FUNC_ABS" #define HID_FUNC_POTENZ "SC_HID_FUNC_POTENZ" diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index d37e3f15ba55..1db6294caec1 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -3276,6 +3276,7 @@ void Test::testFunctionLists() "NOT", "OR", "TRUE", + "XOR", 0 }; diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index c92ad0c95a0e..de577ca9a99e 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -393,6 +393,7 @@ void ScLessEqual(); void ScGreaterEqual(); void ScAnd(); void ScOr(); +void ScXor(); void ScNot(); void ScNeg(); void ScPercentSign(); diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 3d62b5140ba0..fd44da1336ec 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -1383,6 +1383,107 @@ void ScInterpreter::ScOr() } +void ScInterpreter::ScXor() +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScXor" ); + + nFuncFmtType = NUMBERFORMAT_LOGICAL; + short nParamCount = GetByte(); + if ( MustHaveParamCountMin( nParamCount, 1 ) ) + { + bool bHaveValue = false; + short nRes = false; + size_t nRefInList = 0; + while( nParamCount-- > 0) + { + if ( !nGlobalError ) + { + switch ( GetStackType() ) + { + case svDouble : + bHaveValue = true; + nRes ^= ( PopDouble() != 0.0 ); + break; + case svString : + Pop(); + SetError( errNoValue ); + break; + case svSingleRef : + { + ScAddress aAdr; + PopSingleRef( aAdr ); + if ( !nGlobalError ) + { + ScBaseCell* pCell = GetCell( aAdr ); + if ( HasCellValueData( pCell ) ) + { + bHaveValue = true; + nRes ^= ( GetCellValue( aAdr, pCell ) != 0.0 ); + } + // else: Xcl raises no error here + } + } + break; + case svDoubleRef: + case svRefList: + { + ScRange aRange; + PopDoubleRef( aRange, nParamCount, nRefInList); + if ( !nGlobalError ) + { + double fVal; + sal_uInt16 nErr = 0; + ScValueIterator aValIter( pDok, aRange ); + if ( aValIter.GetFirst( fVal, nErr ) ) + { + bHaveValue = true; + do + { + nRes ^= ( fVal != 0.0 ); + } while ( (nErr == 0) && + aValIter.GetNext( fVal, nErr ) ); + } + SetError( nErr ); + } + } + break; + case svExternalSingleRef: + case svExternalDoubleRef: + case svMatrix: + { + bHaveValue = true; + ScMatrixRef pMat = GetMatrix(); + if ( pMat ) + { + bHaveValue = true; + double fVal = pMat->Or(); + sal_uInt16 nErr = GetDoubleErrorValue( fVal ); + if ( nErr ) + { + SetError( nErr ); + } + else + nRes ^= ( fVal != 0.0 ); + } + // else: GetMatrix did set errIllegalParameter + } + break; + default: + Pop(); + SetError( errIllegalParameter); + } + } + else + Pop(); + } + if ( bHaveValue ) + PushInt( nRes ); + else + PushNoValue(); + } +} + + void ScInterpreter::ScNeg() { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScNeg" ); diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 217dfa0a7f76..a6d169315926 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -3808,6 +3808,7 @@ StackVar ScInterpreter::Interpret() case ocGreaterEqual : ScGreaterEqual(); break; case ocAnd : ScAnd(); break; case ocOr : ScOr(); break; + case ocXor : ScXor(); break; case ocIntersect : ScIntersect(); break; case ocRange : ScRangeFunc(); break; case ocUnion : ScUnionFunc(); break; diff --git a/sc/source/core/tool/parclass.cxx b/sc/source/core/tool/parclass.cxx index 4d516e1ea125..03775bf34016 100644 --- a/sc/source/core/tool/parclass.cxx +++ b/sc/source/core/tool/parclass.cxx @@ -191,6 +191,7 @@ const ScParameterClassification::RawData ScParameterClassification::pRawData[] = { ocVarP, {{ Reference }, true }}, { ocVarPA, {{ Reference }, true }}, { ocVLookup, {{ Value, Reference, Value, Value }, false }}, + { ocXor, {{ Reference }, true }}, { ocZTest, {{ Reference, Value, Value }, false }}, // Excel doubts: // ocT: Excel says (and handles) Reference, error? This means no position diff --git a/sc/source/filter/oox/formulabase.cxx b/sc/source/filter/oox/formulabase.cxx index b80dbfaaf7b2..381d74d1df54 100644 --- a/sc/source/filter/oox/formulabase.cxx +++ b/sc/source/filter/oox/formulabase.cxx @@ -669,6 +669,7 @@ static const FunctionData saFuncTableBiff5[] = { 0, "DATESTRING", 352, 352, 1, 1, V, { VR }, FUNCFLAG_IMPORTONLY }, // not supported in Calc, missing in OOXML spec { 0, "NUMBERSTRING", 353, 353, 2, 2, V, { VR }, FUNCFLAG_IMPORTONLY }, // not supported in Calc, missing in OOXML spec { "ROMAN", "ROMAN", 354, 354, 1, 2, V, { VR }, 0 }, + { "XOR", "XOR", 355, 355, 1, MX, V, { RX }, 0 }, // *** EuroTool add-in *** diff --git a/sc/source/ui/src/scfuncs.src b/sc/source/ui/src/scfuncs.src index 53780de1be65..60f8fcac85f6 100644 --- a/sc/source/ui/src/scfuncs.src +++ b/sc/source/ui/src/scfuncs.src @@ -2682,6 +2682,30 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS1 Text [ en-US ] = "Logical value 1, logical value 2,... are 1 to 30 conditions to be tested and which return either TRUE or FALSE." ; }; }; + // -=*# Resource for function XOR (EXKLUSIV ODER) #*=- + Resource SC_OPCODE_XOR + { + String 1 // Description + { + Text [ en-US ] = "Returns TRUE if one argument is TRUE, but not both." ; + }; + ExtraData = + { + 0; + ID_FUNCTION_GRP_LOGIC; + U2S( HID_FUNC_XOR ); + VAR_ARGS; 0; + 0; + }; + String 2 // Name of Parameter 1 + { + Text [ en-US ] = "Logical value " ; + }; + String 3 // Description of Parameter 1 + { + Text [ en-US ] = "Logical value 1, logical value 2, ... are 1 to 30 conditions to be tested and which returns either TRUE or FALSE." ; + }; + }; // -=*# Resource for function UND #*=- Resource SC_OPCODE_AND { diff --git a/sc/source/ui/vba/vbawsfunction.cxx b/sc/source/ui/vba/vbawsfunction.cxx index 0692afb21a20..3a236b388386 100644 --- a/sc/source/ui/vba/vbawsfunction.cxx +++ b/sc/source/ui/vba/vbawsfunction.cxx @@ -201,7 +201,7 @@ ScVbaWSFunction::invoke(const rtl::OUString& FunctionName, const uno::Sequence< if( (eOpCode == ocIsEmpty) || (eOpCode == ocIsString) || (eOpCode == ocIsNonString) || (eOpCode == ocIsLogical) || (eOpCode == ocIsRef) || (eOpCode == ocIsValue) || (eOpCode == ocIsFormula) || (eOpCode == ocIsNA) || (eOpCode == ocIsErr) || (eOpCode == ocIsError) || (eOpCode == ocIsEven) || (eOpCode == ocIsOdd) || - (eOpCode == ocAnd) || (eOpCode == ocOr) || (eOpCode == ocNot) || (eOpCode == ocTrue) || (eOpCode == ocFalse) ) + (eOpCode == ocAnd) || (eOpCode == ocOr) || (eOpCode == ocXor) || (eOpCode == ocNot) || (eOpCode == ocTrue) || (eOpCode == ocFalse) ) { if( aRet.has< AnySeqSeq >() ) { diff --git a/sc/util/hidother.src b/sc/util/hidother.src index 85d36f913977..6a56a8188c6a 100644 --- a/sc/util/hidother.src +++ b/sc/util/hidother.src @@ -160,6 +160,7 @@ hidspecial HID_FUNC_WAHR { HelpID = HID_FUNC_WAHR; }; hidspecial HID_FUNC_WENN { HelpID = HID_FUNC_WENN; }; hidspecial HID_FUNC_ODER { HelpID = HID_FUNC_ODER; }; hidspecial HID_FUNC_UND { HelpID = HID_FUNC_UND; }; +hidspecial HID_FUNC_XOR { HelpID = HID_FUNC_XOR; }; hidspecial HID_FUNC_ABS { HelpID = HID_FUNC_ABS; }; hidspecial HID_FUNC_POTENZ { HelpID = HID_FUNC_POTENZ; }; hidspecial HID_FUNC_ANZAHLLEEREZELLEN { HelpID = HID_FUNC_ANZAHLLEEREZELLEN; }; |