This is an automated email from the ASF dual-hosted git repository.
jimjag pushed a commit to branch AOO50X
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/AOO50X by this push:
new 1bb5ce94f6 OpenFormula: IFNA, SKEWP, IFERROR, formula limits and Excel
filter fixes
1bb5ce94f6 is described below
commit 1bb5ce94f6c54e738b1a40a748a5586fd425dfd0
Author: Jim Jagielski <[email protected]>
AuthorDate: Mon Nov 16 14:27:59 2026 -0500
OpenFormula: IFNA, SKEWP, IFERROR, formula limits and Excel filter fixes
Backport of trunk PR #523, main/ only.
---
main/formula/inc/formula/FormulaCompiler.hxx | 2 +-
main/formula/inc/formula/compiler.hrc | 7 +-
main/formula/inc/formula/opcode.hxx | 3 +
main/formula/source/core/api/FormulaCompiler.cxx | 16 +-
main/formula/source/core/api/token.cxx | 12 +-
.../formula/source/core/resource/core_resource.src | 20 +-
.../helpcontent2/source/text/scalc/01/04060105.xhp | 10 +
.../helpcontent2/source/text/scalc/01/04060106.xhp | 25 ++
.../helpcontent2/source/text/scalc/01/04060185.xhp | 5 +
.../source/text/scalc/01/func_bitand.xhp | 51 ++++
.../source/text/scalc/01/func_bitlshift.xhp | 55 +++++
.../source/text/scalc/01/func_bitor.xhp | 51 ++++
.../source/text/scalc/01/func_bitrshift.xhp | 55 +++++
.../source/text/scalc/01/func_bitxor.xhp | 51 ++++
.../source/text/scalc/01/func_iferror.xhp | 55 +++++
.../source/text/scalc/01/func_ifna.xhp | 54 +++++
.../source/text/scalc/01/func_skewp.xhp | 54 +++++
main/helpcontent2/source/text/scalc/01/makefile.mk | 8 +
main/helpcontent2/util/scalc/makefile.mk | 8 +
main/oox/source/xls/formulabase.cxx | 24 +-
main/sc/inc/compiler.hxx | 14 +-
main/sc/inc/dociter.hxx | 5 +
main/sc/inc/helpids.h | 3 +
main/sc/source/core/data/dociter.cxx | 53 +++++
main/sc/source/core/inc/interpre.hxx | 6 +-
main/sc/source/core/inc/jumpmatrix.hxx | 5 +
main/sc/source/core/tool/compiler.cxx | 29 ++-
main/sc/source/core/tool/interpr1.cxx | 256 ++++++++++++++++-----
main/sc/source/core/tool/interpr3.cxx | 41 ++++
main/sc/source/core/tool/interpr4.cxx | 14 +-
main/sc/source/core/tool/parclass.cxx | 4 +-
main/sc/source/core/tool/token.cxx | 20 ++
main/sc/source/filter/excel/xlformula.cxx | 25 +-
main/sc/source/ui/src/scfuncs.src | 108 ++++++++-
main/sc/source/ui/view/viewfunc.cxx | 18 ++
main/sc/util/hidother.src | 3 +
36 files changed, 1066 insertions(+), 104 deletions(-)
diff --git a/main/formula/inc/formula/FormulaCompiler.hxx
b/main/formula/inc/formula/FormulaCompiler.hxx
index fde9001698..d548e8c35d 100644
--- a/main/formula/inc/formula/FormulaCompiler.hxx
+++ b/main/formula/inc/formula/FormulaCompiler.hxx
@@ -41,7 +41,7 @@
#define MAXJUMPCOUNT 32 /* maximum number of jumps (ocChose) */
-#define MAXCODE 512 /* maximum number of tokens in formula */
+#define MAXCODE 2048 /* maximum number of tokens in formula */
namespace com { namespace sun { namespace star {
diff --git a/main/formula/inc/formula/compiler.hrc
b/main/formula/inc/formula/compiler.hrc
index a1b3674604..9984e9b50c 100644
--- a/main/formula/inc/formula/compiler.hrc
+++ b/main/formula/inc/formula/compiler.hrc
@@ -402,10 +402,13 @@
#define SC_OPCODE_BITXOR 406
#define SC_OPCODE_BITLSHIFT 407
#define SC_OPCODE_BITRSHIFT 408
+#define SC_OPCODE_IFNA 409
+#define SC_OPCODE_SKEWP 410
+#define SC_OPCODE_IFERROR 411
-#define SC_OPCODE_STOP_2_PAR 409
+#define SC_OPCODE_STOP_2_PAR 412
-#define SC_OPCODE_LAST_OPCODE_ID 408 /* last OpCode */
+#define SC_OPCODE_LAST_OPCODE_ID 411 /* last OpCode */
/*** Interna ***/
#define SC_OPCODE_INTERNAL_BEGIN 9999
diff --git a/main/formula/inc/formula/opcode.hxx
b/main/formula/inc/formula/opcode.hxx
index c6d6270572..6a5d9bf432 100644
--- a/main/formula/inc/formula/opcode.hxx
+++ b/main/formula/inc/formula/opcode.hxx
@@ -399,6 +399,9 @@ enum OpCodeEnum
ocBitXor = SC_OPCODE_BITXOR,
ocBitLShift = SC_OPCODE_BITLSHIFT,
ocBitRShift = SC_OPCODE_BITRSHIFT,
+ ocIfna = SC_OPCODE_IFNA,
+ ocSkewP = SC_OPCODE_SKEWP,
+ ocIfError = SC_OPCODE_IFERROR,
// internal stuff
ocInternalBegin = SC_OPCODE_INTERNAL_BEGIN,
ocTTT = SC_OPCODE_TTT,
diff --git a/main/formula/source/core/api/FormulaCompiler.cxx
b/main/formula/source/core/api/FormulaCompiler.cxx
index 08aee41d6b..7c56e6d6f2 100644
--- a/main/formula/source/core/api/FormulaCompiler.cxx
+++ b/main/formula/source/core/api/FormulaCompiler.cxx
@@ -1011,7 +1011,8 @@ void FormulaCompiler::Factor()
PutCode( pFacToken );
eOp = NextToken();
}
- else if ((SC_OPCODE_START_2_PAR <= eOp && eOp < SC_OPCODE_STOP_2_PAR)
+ else if ((SC_OPCODE_START_2_PAR <= eOp && eOp < SC_OPCODE_STOP_2_PAR
+ && ((eOp != ocIfna && eOp != ocIfError) || bCompileForFAP))
|| eOp == ocExternal
|| eOp == ocMacro
|| eOp == ocAnd
@@ -1049,7 +1050,10 @@ void FormulaCompiler::Factor()
nSepCount++;
while ( (eOp == ocSep) && (!pArr->GetCodeError() ||
bIgnoreErrors) )
{
- nSepCount++;
+ if ( nSepCount == 255 )
+ SetError( errCodeOverflow ); // the count is kept
in a byte
+ else
+ nSepCount++;
NextToken();
eOp = Expression();
}
@@ -1070,12 +1074,14 @@ void FormulaCompiler::Factor()
pArr->SetRecalcModeAlways();
PutCode( pFacToken );
}
- else if (eOp == ocIf || eOp == ocChose)
+ else if (eOp == ocIf || eOp == ocChose || eOp == ocIfna || eOp ==
ocIfError)
{
// the PC counters are -1
pFacToken = pToken;
if ( eOp == ocIf )
pFacToken->GetJump()[ 0 ] = 3; // if, else, behind
+ else if ( eOp == ocIfna || eOp == ocIfError )
+ pFacToken->GetJump()[ 0 ] = 2; // fallback, behind
else
pFacToken->GetJump()[ 0 ] = MAXJUMPCOUNT+1;
eOp = NextToken();
@@ -1093,7 +1099,8 @@ void FormulaCompiler::Factor()
// ScRawToken::Clone() allocates the JumpBuffer according to
// nJump[0]*2+2, which is 3*2+2 on ocIf.
const short nJumpMax =
- (pFacToken->GetOpCode() == ocIf ? 3 : MAXJUMPCOUNT);
+ (pFacToken->GetOpCode() == ocIf ? 3 :
+ ((pFacToken->GetOpCode() == ocIfna || pFacToken->GetOpCode()
== ocIfError) ? 2 : MAXJUMPCOUNT));
while ( (nJumpCount < (MAXJUMPCOUNT - 1)) && (eOp == ocSep)
&& (!pArr->GetCodeError() || bIgnoreErrors) )
{
@@ -1120,6 +1127,7 @@ void FormulaCompiler::Factor()
if ( ++nJumpCount <= nJumpMax )
pFacToken->GetJump()[ nJumpCount ] = pc-1;
if ((pFacToken->GetOpCode() == ocIf && (nJumpCount > 3)) ||
+ ((pFacToken->GetOpCode() == ocIfna ||
pFacToken->GetOpCode() == ocIfError) && (nJumpCount != 2)) ||
(nJumpCount >= MAXJUMPCOUNT))
SetError(errIllegalParameter);
else
diff --git a/main/formula/source/core/api/token.cxx
b/main/formula/source/core/api/token.cxx
index 2be3942015..fe54da75bf 100644
--- a/main/formula/source/core/api/token.cxx
+++ b/main/formula/source/core/api/token.cxx
@@ -38,6 +38,7 @@
#include "formula/token.hxx"
#include "formula/tokenarray.hxx"
#include "formula/FormulaCompiler.hxx"
+#include "formula/errorcodes.hxx"
#include <formula/compiler.hrc>
//#include "rechead.hxx"
//#include "parclass.hxx"
@@ -124,7 +125,7 @@ sal_uInt8 FormulaToken::GetParamCount() const
return 0; // no parameter
else if (SC_OPCODE_START_1_PAR <= eOp && eOp < SC_OPCODE_STOP_1_PAR)
return 1; // one parameter
- else if ( eOp == ocIf || eOp == ocChose )
+ else if ( eOp == ocIf || eOp == ocChose || eOp == ocIfna || eOp ==
ocIfError )
return 1; // only the condition counts as parameter
else
return 0; // all the rest, no Parameter, or
@@ -323,6 +324,9 @@ bool FormulaTokenArray::Fill(const uno::Sequence<
sheet::FormulaToken >& _aSeque
{
bError |= AddFormulaToken( _aSequence[nPos] ,_pRef);
}
+ // Add() drops what does not fit; without an error the shorter formula
would be calculated
+ if ( nLen >= MAXCODE )
+ SetCodeError( errCodeOverflow );
return bError;
}
//////////////////////////////////////////////////////////////////////////
@@ -842,7 +846,7 @@ sal_Bool FormulaTokenArray::HasMatrixDoubleRefOps()
}
if ( eOp == ocPush || lcl_IsReference( eOp, t->GetType() ) )
pStack[sp++] = t;
- else if ( eOp == ocIf || eOp == ocChose )
+ else if ( eOp == ocIf || eOp == ocChose || eOp == ocIfna || eOp ==
ocIfError )
{ // Jumps ignorieren, vorheriges Result (Condition) poppen
if ( sp )
--sp;
@@ -1194,9 +1198,11 @@ FormulaToken* FormulaTokenArray::AddOpCode( OpCode eOp )
break;
case ocIf:
case ocChose:
+ case ocIfna:
+ case ocIfError:
{
short nJump[MAXJUMPCOUNT + 1];
- nJump[ 0 ] = ocIf == eOp ? 3 : MAXJUMPCOUNT+1;
+ nJump[ 0 ] = ocIf == eOp ? 3 : ((ocIfna == eOp || ocIfError ==
eOp) ? 2 : MAXJUMPCOUNT+1);
pRet = new FormulaJumpToken( eOp, (short*)nJump );
}
break;
diff --git a/main/formula/source/core/resource/core_resource.src
b/main/formula/source/core/resource/core_resource.src
index e6ea9cf91d..cd2911465c 100644
--- a/main/formula/source/core/resource/core_resource.src
+++ b/main/formula/source/core/resource/core_resource.src
@@ -354,6 +354,9 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF
String SC_OPCODE_BITXOR { Text= "BITXOR" ; };
String SC_OPCODE_BITLSHIFT { Text= "BITLSHIFT" ; };
String SC_OPCODE_BITRSHIFT { Text= "BITRSHIFT" ; };
+ String SC_OPCODE_IFNA { Text = "IFNA" ; };
+ String SC_OPCODE_IFERROR { Text = "IFERROR" ; };
+ String SC_OPCODE_SKEWP { Text = "SKEWP" ; };
/* BEGIN defined ERROR.TYPE() values. */
String SC_OPCODE_ERROR_NULL { Text = "#NULL!" ; };
@@ -696,6 +699,9 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH
String SC_OPCODE_BITXOR { Text = "BITXOR" ; };
String SC_OPCODE_BITLSHIFT { Text= "BITLSHIFT" ; };
String SC_OPCODE_BITRSHIFT { Text= "BITRSHIFT" ; };
+ String SC_OPCODE_IFNA { Text = "IFNA" ; };
+ String SC_OPCODE_IFERROR { Text = "IFERROR" ; };
+ String SC_OPCODE_SKEWP { Text = "SKEWP" ; };
/* BEGIN defined ERROR.TYPE() values. */
String SC_OPCODE_ERROR_NULL { Text = "#NULL!" ; };
@@ -1688,6 +1694,10 @@ Resource RID_STRLIST_FUNCTION_NAMES
{
Text [ en-US ] = "SKEW" ;
};
+ String SC_OPCODE_SKEWP
+ {
+ Text [ en-US ] = "SKEWP" ;
+ };
String SC_OPCODE_DEV_SQ
{
Text [ en-US ] = "DEVSQ" ;
@@ -1938,7 +1948,15 @@ Resource RID_STRLIST_FUNCTION_NAMES
};
String SC_OPCODE_BITRSHIFT
{
- Text [ en-US ] = "BITRSHIFT";
+ Text [ en-US ] = "BITRSHIFT";
+ };
+ String SC_OPCODE_IFNA
+ {
+ Text [ en-US ] = "IFNA";
+ };
+ String SC_OPCODE_IFERROR
+ {
+ Text [ en-US ] = "IFERROR";
};
/* BEGIN defined ERROR.TYPE() values. */
/* ERROR.TYPE( #NULL! ) == 1 */
diff --git a/main/helpcontent2/source/text/scalc/01/04060105.xhp
b/main/helpcontent2/source/text/scalc/01/04060105.xhp
index 7b18e67d84..bbad8ea29e 100644
--- a/main/helpcontent2/source/text/scalc/01/04060105.xhp
+++ b/main/helpcontent2/source/text/scalc/01/04060105.xhp
@@ -153,6 +153,16 @@ FALSE is returned if the result of this addition is
0.<comment>UFI: first try to
<paragraph xml-lang="en-US" id="par_id3155371K" role="paragraph"
l10n="U"><item type="input">=XOR(12<11;13>22;10)</item> returns TRUE
since this converts to (1+0+10) mod 2 = 0</paragraph>
<paragraph xml-lang="en-US" id="par_id3158412K" role="paragraph"
l10n="U"><item type="input">=XOR(FALSE;TRUE)</item> returns TRUE.</paragraph>
</section>
+<section id="iferror">
+<paragraph role="paragraph" id="par_idIFERROR01" xml-lang="en-US" l10n="NEW">
+<embedvar href="text/scalc/01/func_iferror.xhp#iferror"/>
+</paragraph>
+</section>
+<section id="ifna">
+<paragraph role="paragraph" id="par_idIFNA01" xml-lang="en-US" l10n="NEW">
+<embedvar href="text/scalc/01/func_ifna.xhp#ifna"/>
+</paragraph>
+</section>
</sort>
<section id="relatedtopics">
<embed href="text/scalc/01/04060100.xhp#drking"/>
diff --git a/main/helpcontent2/source/text/scalc/01/04060106.xhp
b/main/helpcontent2/source/text/scalc/01/04060106.xhp
index a80abfa7d4..7e7c130a96 100644
--- a/main/helpcontent2/source/text/scalc/01/04060106.xhp
+++ b/main/helpcontent2/source/text/scalc/01/04060106.xhp
@@ -1300,6 +1300,31 @@
<paragraph xml-lang="en-US" id="par_id5169225K" role="paragraph" l10n="NEW">
<item type="input">=COUNTIFS(A1:A10;">=2006";B1:B10;">=2006") </item>-
this returns 14</paragraph>
</section>
+<section id="bitand">
+<paragraph role="paragraph" id="par_idBIT0001" xml-lang="en-US" l10n="NEW">
+<embedvar href="text/scalc/01/func_bitand.xhp#bitand"/>
+</paragraph>
+</section>
+<section id="bitlshift">
+<paragraph role="paragraph" id="par_idBIT0002" xml-lang="en-US" l10n="NEW">
+<embedvar href="text/scalc/01/func_bitlshift.xhp#bitlshift"/>
+</paragraph>
+</section>
+<section id="bitor">
+<paragraph role="paragraph" id="par_idBIT0003" xml-lang="en-US" l10n="NEW">
+<embedvar href="text/scalc/01/func_bitor.xhp#bitor"/>
+</paragraph>
+</section>
+<section id="bitrshift">
+<paragraph role="paragraph" id="par_idBIT0004" xml-lang="en-US" l10n="NEW">
+<embedvar href="text/scalc/01/func_bitrshift.xhp#bitrshift"/>
+</paragraph>
+</section>
+<section id="bitxor">
+<paragraph role="paragraph" id="par_idBIT0005" xml-lang="en-US" l10n="NEW">
+<embedvar href="text/scalc/01/func_bitxor.xhp#bitxor"/>
+</paragraph>
+</section>
</sort>
<section id="relatedtopics">
<embed href="text/scalc/01/04060100.xhp#drking"/>
diff --git a/main/helpcontent2/source/text/scalc/01/04060185.xhp
b/main/helpcontent2/source/text/scalc/01/04060185.xhp
index e959826c49..3c9b873d1c 100644
--- a/main/helpcontent2/source/text/scalc/01/04060185.xhp
+++ b/main/helpcontent2/source/text/scalc/01/04060185.xhp
@@ -398,6 +398,11 @@
<paragraph xml-lang="en-US" id="par_id3146077" role="paragraph" l10n="U"><item
type="input">=WEIBULL(2;1;1;1)</item> returns 0.86.</paragraph>
<paragraph xml-lang="en-US" id="par_id0305200911372899" role="paragraph"
l10n="NEW">See also the <link
href="https://wiki.openoffice.org/wiki/Documentation/How_Tos/Calc:_WEIBULL_function">Wiki
page</link>.</paragraph>
</section>
+<section id="skewp">
+<paragraph role="paragraph" id="par_idSKEWP01" xml-lang="en-US" l10n="NEW">
+<embedvar href="text/scalc/01/func_skewp.xhp#skewp"/>
+</paragraph>
+</section>
</sort>
<section id="relatedtopics">
<embed href="text/scalc/01/04060100.xhp#drking"/>
diff --git a/main/helpcontent2/source/text/scalc/01/func_bitand.xhp
b/main/helpcontent2/source/text/scalc/01/func_bitand.xhp
new file mode 100644
index 0000000000..e4fe3491e8
--- /dev/null
+++ b/main/helpcontent2/source/text/scalc/01/func_bitand.xhp
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--***********************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ ***********************************************************-->
+
+<helpdocument version="1.0">
+<meta>
+<topic id="textscalc01func_bitandxml" indexer="include" status="PUBLISH">
+<title id="tit" xml-lang="en-US">BITAND</title>
+<filename>/text/scalc/01/func_bitand.xhp</filename>
+</topic>
+</meta>
+<body>
+<bookmark xml-lang="en-US" branch="index" id="bm_id3160201">
+<bookmark_value>BITAND function</bookmark_value>
+<bookmark_value>bitwise AND</bookmark_value>
+</bookmark>
+<bookmark xml-lang="en-US" branch="hid/SC_HID_FUNC_BITAND" id="bm_id3160202"
localize="false"/>
+<paragraph role="heading" id="hd_id3160201" xml-lang="en-US" level="2"
l10n="U"><variable id="bitand"><link
href="text/scalc/01/func_bitand.xhp">BITAND</link>
+</variable></paragraph>
+<paragraph role="paragraph" id="par_id3160203" xml-lang="en-US"
l10n="U"><ahelp hid="HID_FUNC_BITAND">Returns the bitwise AND of two
integers.</ahelp> Each bit of the result is 1 only if the corresponding bit of
both arguments is 1.</paragraph>
+<paragraph role="heading" id="hd_id3160204" xml-lang="en-US" level="3"
l10n="U">Syntax</paragraph>
+<paragraph role="code" id="par_id3160205" xml-lang="en-US"
l10n="U">BITAND(Number1; Number2)</paragraph>
+<paragraph role="paragraph" id="par_id3160206" xml-lang="en-US"
l10n="U"><emph>Number1</emph> and <emph>Number2</emph> are integers greater
than or equal to 0 and less than 2^48 (281474976710656).</paragraph>
+<paragraph role="heading" id="hd_id3160207" xml-lang="en-US" level="3"
l10n="U">Remarks</paragraph>
+<paragraph role="paragraph" id="par_id3160208" xml-lang="en-US"
l10n="U">Arguments are rounded down to integers before the operation. Values
that are negative after rounding down, greater than 2^48 - 1, or not finite
return an error (Err:502).</paragraph>
+<paragraph role="paragraph" id="par_id3160209" xml-lang="en-US"
l10n="U">Example: decimal 6 is binary <quote>110</quote>, decimal 3 is binary
<quote>011</quote>. BITAND(6; 3) returns 2 (binary
<quote>010</quote>).</paragraph>
+<paragraph role="heading" id="hd_id3160210" xml-lang="en-US" level="3"
l10n="U">Example</paragraph>
+<paragraph role="paragraph" id="par_id3160211" xml-lang="en-US" l10n="U"><item
type="input">=BITAND(6; 3)</item> returns 2.</paragraph>
+<embed href="text/shared/00/00000001.xhp#siehe"/>
+<paragraph role="paragraph" id="par_id3160212" xml-lang="en-US" l10n="U"><link
href="text/scalc/01/func_bitor.xhp" name="BITOR">BITOR</link>, <link
href="text/scalc/01/func_bitxor.xhp" name="BITXOR">BITXOR</link>.</paragraph>
+</body>
+</helpdocument>
diff --git a/main/helpcontent2/source/text/scalc/01/func_bitlshift.xhp
b/main/helpcontent2/source/text/scalc/01/func_bitlshift.xhp
new file mode 100644
index 0000000000..0139bdae19
--- /dev/null
+++ b/main/helpcontent2/source/text/scalc/01/func_bitlshift.xhp
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--***********************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ ***********************************************************-->
+
+<helpdocument version="1.0">
+<meta>
+<topic id="textscalc01func_bitlshiftxml" indexer="include" status="PUBLISH">
+<title id="tit" xml-lang="en-US">BITLSHIFT</title>
+<filename>/text/scalc/01/func_bitlshift.xhp</filename>
+</topic>
+</meta>
+<body>
+<bookmark xml-lang="en-US" branch="index" id="bm_id3160501">
+<bookmark_value>BITLSHIFT function</bookmark_value>
+<bookmark_value>bitwise left shift</bookmark_value>
+</bookmark>
+<bookmark xml-lang="en-US" branch="hid/SC_HID_FUNC_BITLSHIFT"
id="bm_id3160502" localize="false"/>
+<paragraph role="heading" id="hd_id3160501" xml-lang="en-US" level="2"
l10n="U"><variable id="bitlshift"><link
href="text/scalc/01/func_bitlshift.xhp">BITLSHIFT</link>
+</variable></paragraph>
+<paragraph role="paragraph" id="par_id3160503" xml-lang="en-US"
l10n="U"><ahelp hid="HID_FUNC_BITLSHIFT">Bitwise left shift of an integer
value.</ahelp> The bits of <emph>Number</emph> are shifted to the left by
<emph>Shift</emph> positions, equivalent to multiplying by 2 raised to the
power of <emph>Shift</emph>.</paragraph>
+<paragraph role="heading" id="hd_id3160504" xml-lang="en-US" level="3"
l10n="U">Syntax</paragraph>
+<paragraph role="code" id="par_id3160505" xml-lang="en-US"
l10n="U">BITLSHIFT(Number; Shift)</paragraph>
+<paragraph role="paragraph" id="par_id3160506" xml-lang="en-US"
l10n="U"><emph>Number</emph> is the integer value to be shifted. It must be
greater than or equal to 0 and less than 2^48 (281474976710656).</paragraph>
+<paragraph role="paragraph" id="par_id3160507" xml-lang="en-US"
l10n="U"><emph>Shift</emph> is the number of bit positions to shift. A positive
value shifts left; a negative value shifts right (the direction is
reversed).</paragraph>
+<paragraph role="heading" id="hd_id3160508" xml-lang="en-US" level="3"
l10n="U">Remarks</paragraph>
+<paragraph role="paragraph" id="par_id3160509" xml-lang="en-US" l10n="U">If
<emph>Shift</emph> is 0, <emph>Number</emph> is returned unchanged.</paragraph>
+<paragraph role="paragraph" id="par_id3160510" xml-lang="en-US" l10n="U">If
<emph>Shift</emph> is greater than or equal to 64 (or less than or equal to
-64), the result is 0.</paragraph>
+<paragraph role="paragraph" id="par_id3160511" xml-lang="en-US"
l10n="U"><emph>Number</emph> and <emph>Shift</emph> are rounded down to
integers before the operation. A <emph>Number</emph> that is negative after
rounding down, greater than 2^48 - 1, or not finite returns an error (Err:502),
as does a <emph>Shift</emph> that is not finite.</paragraph>
+<paragraph role="paragraph" id="par_id3160512" xml-lang="en-US"
l10n="U">Example: decimal 1 is binary <quote>1</quote>. BITLSHIFT(1; 2) shifts
left by 2, giving binary <quote>100</quote>, which is decimal 4.</paragraph>
+<paragraph role="heading" id="hd_id3160513" xml-lang="en-US" level="3"
l10n="U">Example</paragraph>
+<paragraph role="paragraph" id="par_id3160514" xml-lang="en-US" l10n="U"><item
type="input">=BITLSHIFT(1; 2)</item> returns 4.</paragraph>
+<paragraph role="paragraph" id="par_id3160515" xml-lang="en-US" l10n="U"><item
type="input">=BITLSHIFT(1; -2)</item> returns 0 because a negative shift
reverses direction and the value is shifted right, shifting the only bit
out.</paragraph>
+<embed href="text/shared/00/00000001.xhp#siehe"/>
+<paragraph role="paragraph" id="par_id3160516" xml-lang="en-US" l10n="U"><link
href="text/scalc/01/func_bitrshift.xhp"
name="BITRSHIFT">BITRSHIFT</link>.</paragraph>
+</body>
+</helpdocument>
diff --git a/main/helpcontent2/source/text/scalc/01/func_bitor.xhp
b/main/helpcontent2/source/text/scalc/01/func_bitor.xhp
new file mode 100644
index 0000000000..985a8b45b5
--- /dev/null
+++ b/main/helpcontent2/source/text/scalc/01/func_bitor.xhp
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--***********************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ ***********************************************************-->
+
+<helpdocument version="1.0">
+<meta>
+<topic id="textscalc01func_bitorxml" indexer="include" status="PUBLISH">
+<title id="tit" xml-lang="en-US">BITOR</title>
+<filename>/text/scalc/01/func_bitor.xhp</filename>
+</topic>
+</meta>
+<body>
+<bookmark xml-lang="en-US" branch="index" id="bm_id3160301">
+<bookmark_value>BITOR function</bookmark_value>
+<bookmark_value>bitwise OR</bookmark_value>
+</bookmark>
+<bookmark xml-lang="en-US" branch="hid/SC_HID_FUNC_BITOR" id="bm_id3160302"
localize="false"/>
+<paragraph role="heading" id="hd_id3160301" xml-lang="en-US" level="2"
l10n="U"><variable id="bitor"><link
href="text/scalc/01/func_bitor.xhp">BITOR</link>
+</variable></paragraph>
+<paragraph role="paragraph" id="par_id3160303" xml-lang="en-US"
l10n="U"><ahelp hid="HID_FUNC_BITOR">Returns the bitwise OR of two
integers.</ahelp> Each bit of the result is 1 if the corresponding bit of
either argument is 1.</paragraph>
+<paragraph role="heading" id="hd_id3160304" xml-lang="en-US" level="3"
l10n="U">Syntax</paragraph>
+<paragraph role="code" id="par_id3160305" xml-lang="en-US"
l10n="U">BITOR(Number1; Number2)</paragraph>
+<paragraph role="paragraph" id="par_id3160306" xml-lang="en-US"
l10n="U"><emph>Number1</emph> and <emph>Number2</emph> are integers greater
than or equal to 0 and less than 2^48 (281474976710656).</paragraph>
+<paragraph role="heading" id="hd_id3160307" xml-lang="en-US" level="3"
l10n="U">Remarks</paragraph>
+<paragraph role="paragraph" id="par_id3160308" xml-lang="en-US"
l10n="U">Arguments are rounded down to integers before the operation. Values
that are negative after rounding down, greater than 2^48 - 1, or not finite
return an error (Err:502).</paragraph>
+<paragraph role="paragraph" id="par_id3160309" xml-lang="en-US"
l10n="U">Example: decimal 6 is binary <quote>110</quote>, decimal 3 is binary
<quote>011</quote>. BITOR(6; 3) returns 7 (binary
<quote>111</quote>).</paragraph>
+<paragraph role="heading" id="hd_id3160310" xml-lang="en-US" level="3"
l10n="U">Example</paragraph>
+<paragraph role="paragraph" id="par_id3160311" xml-lang="en-US" l10n="U"><item
type="input">=BITOR(6; 3)</item> returns 7.</paragraph>
+<embed href="text/shared/00/00000001.xhp#siehe"/>
+<paragraph role="paragraph" id="par_id3160312" xml-lang="en-US" l10n="U"><link
href="text/scalc/01/func_bitand.xhp" name="BITAND">BITAND</link>, <link
href="text/scalc/01/func_bitxor.xhp" name="BITXOR">BITXOR</link>.</paragraph>
+</body>
+</helpdocument>
diff --git a/main/helpcontent2/source/text/scalc/01/func_bitrshift.xhp
b/main/helpcontent2/source/text/scalc/01/func_bitrshift.xhp
new file mode 100644
index 0000000000..93f1929524
--- /dev/null
+++ b/main/helpcontent2/source/text/scalc/01/func_bitrshift.xhp
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--***********************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ ***********************************************************-->
+
+<helpdocument version="1.0">
+<meta>
+<topic id="textscalc01func_bitrshiftxml" indexer="include" status="PUBLISH">
+<title id="tit" xml-lang="en-US">BITRSHIFT</title>
+<filename>/text/scalc/01/func_bitrshift.xhp</filename>
+</topic>
+</meta>
+<body>
+<bookmark xml-lang="en-US" branch="index" id="bm_id3160601">
+<bookmark_value>BITRSHIFT function</bookmark_value>
+<bookmark_value>bitwise right shift</bookmark_value>
+</bookmark>
+<bookmark xml-lang="en-US" branch="hid/SC_HID_FUNC_BITRSHIFT"
id="bm_id3160602" localize="false"/>
+<paragraph role="heading" id="hd_id3160601" xml-lang="en-US" level="2"
l10n="U"><variable id="bitrshift"><link
href="text/scalc/01/func_bitrshift.xhp">BITRSHIFT</link>
+</variable></paragraph>
+<paragraph role="paragraph" id="par_id3160603" xml-lang="en-US"
l10n="U"><ahelp hid="HID_FUNC_BITRSHIFT">Bitwise right shift of an integer
value.</ahelp> The bits of <emph>Number</emph> are shifted to the right by
<emph>Shift</emph> positions, equivalent to dividing by 2 raised to the power
of <emph>Shift</emph>.</paragraph>
+<paragraph role="heading" id="hd_id3160604" xml-lang="en-US" level="3"
l10n="U">Syntax</paragraph>
+<paragraph role="code" id="par_id3160605" xml-lang="en-US"
l10n="U">BITRSHIFT(Number; Shift)</paragraph>
+<paragraph role="paragraph" id="par_id3160606" xml-lang="en-US"
l10n="U"><emph>Number</emph> is the integer value to be shifted. It must be
greater than or equal to 0 and less than 2^48 (281474976710656).</paragraph>
+<paragraph role="paragraph" id="par_id3160607" xml-lang="en-US"
l10n="U"><emph>Shift</emph> is the number of bit positions to shift. A positive
value shifts right; a negative value shifts left (the direction is
reversed).</paragraph>
+<paragraph role="heading" id="hd_id3160608" xml-lang="en-US" level="3"
l10n="U">Remarks</paragraph>
+<paragraph role="paragraph" id="par_id3160609" xml-lang="en-US" l10n="U">If
<emph>Shift</emph> is 0, <emph>Number</emph> is returned unchanged.</paragraph>
+<paragraph role="paragraph" id="par_id3160610" xml-lang="en-US" l10n="U">If
<emph>Shift</emph> is greater than or equal to 64 (or less than or equal to
-64), the result is 0.</paragraph>
+<paragraph role="paragraph" id="par_id3160611" xml-lang="en-US"
l10n="U"><emph>Number</emph> and <emph>Shift</emph> are rounded down to
integers before the operation. A <emph>Number</emph> that is negative after
rounding down, greater than 2^48 - 1, or not finite returns an error (Err:502),
as does a <emph>Shift</emph> that is not finite.</paragraph>
+<paragraph role="paragraph" id="par_id3160612" xml-lang="en-US"
l10n="U">Example: decimal 8 is binary <quote>1000</quote>. BITRSHIFT(8; 2)
shifts right by 2, giving binary <quote>10</quote>, which is decimal
2.</paragraph>
+<paragraph role="heading" id="hd_id3160613" xml-lang="en-US" level="3"
l10n="U">Example</paragraph>
+<paragraph role="paragraph" id="par_id3160614" xml-lang="en-US" l10n="U"><item
type="input">=BITRSHIFT(8; 2)</item> returns 2.</paragraph>
+<paragraph role="paragraph" id="par_id3160615" xml-lang="en-US" l10n="U"><item
type="input">=BITRSHIFT(1; -2)</item> returns 4 because a negative shift
reverses direction and shifts left by 2.</paragraph>
+<embed href="text/shared/00/00000001.xhp#siehe"/>
+<paragraph role="paragraph" id="par_id3160616" xml-lang="en-US" l10n="U"><link
href="text/scalc/01/func_bitlshift.xhp"
name="BITLSHIFT">BITLSHIFT</link>.</paragraph>
+</body>
+</helpdocument>
diff --git a/main/helpcontent2/source/text/scalc/01/func_bitxor.xhp
b/main/helpcontent2/source/text/scalc/01/func_bitxor.xhp
new file mode 100644
index 0000000000..a7a330dd63
--- /dev/null
+++ b/main/helpcontent2/source/text/scalc/01/func_bitxor.xhp
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--***********************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ ***********************************************************-->
+
+<helpdocument version="1.0">
+<meta>
+<topic id="textscalc01func_bitxxml" indexer="include" status="PUBLISH">
+<title id="tit" xml-lang="en-US">BITXOR</title>
+<filename>/text/scalc/01/func_bitxor.xhp</filename>
+</topic>
+</meta>
+<body>
+<bookmark xml-lang="en-US" branch="index" id="bm_id3160401">
+<bookmark_value>BITXOR function</bookmark_value>
+<bookmark_value>bitwise XOR</bookmark_value>
+</bookmark>
+<bookmark xml-lang="en-US" branch="hid/SC_HID_FUNC_BITXOR" id="bm_id3160402"
localize="false"/>
+<paragraph role="heading" id="hd_id3160401" xml-lang="en-US" level="2"
l10n="U"><variable id="bitxor"><link
href="text/scalc/01/func_bitxor.xhp">BITXOR</link>
+</variable></paragraph>
+<paragraph role="paragraph" id="par_id3160403" xml-lang="en-US"
l10n="U"><ahelp hid="HID_FUNC_BITXOR">Returns the bitwise XOR (exclusive OR) of
two integers.</ahelp> Each bit of the result is 1 if the corresponding bits of
the two arguments differ.</paragraph>
+<paragraph role="heading" id="hd_id3160404" xml-lang="en-US" level="3"
l10n="U">Syntax</paragraph>
+<paragraph role="code" id="par_id3160405" xml-lang="en-US"
l10n="U">BITXOR(Number1; Number2)</paragraph>
+<paragraph role="paragraph" id="par_id3160406" xml-lang="en-US"
l10n="U"><emph>Number1</emph> and <emph>Number2</emph> are integers greater
than or equal to 0 and less than 2^48 (281474976710656).</paragraph>
+<paragraph role="heading" id="hd_id3160407" xml-lang="en-US" level="3"
l10n="U">Remarks</paragraph>
+<paragraph role="paragraph" id="par_id3160408" xml-lang="en-US"
l10n="U">Arguments are rounded down to integers before the operation. Values
that are negative after rounding down, greater than 2^48 - 1, or not finite
return an error (Err:502).</paragraph>
+<paragraph role="paragraph" id="par_id3160409" xml-lang="en-US"
l10n="U">Example: decimal 6 is binary <quote>110</quote>, decimal 3 is binary
<quote>011</quote>. BITXOR(6; 3) returns 5 (binary
<quote>101</quote>).</paragraph>
+<paragraph role="heading" id="hd_id3160410" xml-lang="en-US" level="3"
l10n="U">Example</paragraph>
+<paragraph role="paragraph" id="par_id3160411" xml-lang="en-US" l10n="U"><item
type="input">=BITXOR(6; 3)</item> returns 5.</paragraph>
+<embed href="text/shared/00/00000001.xhp#siehe"/>
+<paragraph role="paragraph" id="par_id3160412" xml-lang="en-US" l10n="U"><link
href="text/scalc/01/func_bitand.xhp" name="BITAND">BITAND</link>, <link
href="text/scalc/01/func_bitor.xhp" name="BITOR">BITOR</link>.</paragraph>
+</body>
+</helpdocument>
diff --git a/main/helpcontent2/source/text/scalc/01/func_iferror.xhp
b/main/helpcontent2/source/text/scalc/01/func_iferror.xhp
new file mode 100644
index 0000000000..7c361a918f
--- /dev/null
+++ b/main/helpcontent2/source/text/scalc/01/func_iferror.xhp
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--***********************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ ***********************************************************-->
+
+<helpdocument version="1.0">
+<meta>
+<topic id="textscalc01func_iferrorxml" indexer="include" status="PUBLISH">
+<title id="tit" xml-lang="en-US">IFERROR</title>
+<filename>/text/scalc/01/func_iferror.xhp</filename>
+</topic>
+</meta>
+<body>
+<bookmark xml-lang="en-US" branch="index" id="bm_id3170001">
+<bookmark_value>IFERROR function</bookmark_value>
+<bookmark_value>error handling;IFERROR</bookmark_value>
+</bookmark>
+<bookmark xml-lang="en-US" branch="hid/SC_HID_FUNC_IFERROR" id="bm_id3170002"
localize="false"/>
+<paragraph role="heading" id="hd_id3170001" xml-lang="en-US" level="2"
l10n="NEW"><variable id="iferror"><link
href="text/scalc/01/func_iferror.xhp">IFERROR</link>
+</variable></paragraph>
+<paragraph role="paragraph" id="par_id3170003" xml-lang="en-US"
l10n="NEW"><ahelp hid="HID_FUNC_IFERROR">Returns the value if it is not an
error value, otherwise it returns the alternative value.</ahelp> Every error
value is replaced, including #N/A; ordinary values pass through
unchanged.</paragraph>
+<paragraph role="heading" id="hd_id3170004" xml-lang="en-US" level="3"
l10n="NEW">Syntax</paragraph>
+<paragraph role="code" id="par_id3170005" xml-lang="en-US"
l10n="NEW">IFERROR(Value; Alternative)</paragraph>
+<paragraph role="paragraph" id="par_id3170006" xml-lang="en-US"
l10n="NEW"><emph>Value</emph> is the value or reference to be checked for an
error value.</paragraph>
+<paragraph role="paragraph" id="par_id3170007" xml-lang="en-US"
l10n="NEW"><emph>Alternative</emph> is the value returned when
<emph>Value</emph> is an error value. It is evaluated only when
<emph>Value</emph> is an error value; an error in <emph>Alternative</emph>
itself is returned.</paragraph>
+<paragraph role="heading" id="hd_id3170008" xml-lang="en-US" level="3"
l10n="NEW">Remarks</paragraph>
+<paragraph role="paragraph" id="par_id3170009" xml-lang="en-US" l10n="NEW">A
reference to an empty cell is not an error value, so <emph>Value</emph> is
returned and shows as 0.</paragraph>
+<paragraph role="paragraph" id="par_id3170010" xml-lang="en-US" l10n="NEW">In
an array formula, each element of <emph>Value</emph> that is an error value is
replaced on its own; if <emph>Alternative</emph> is also a range or array, the
matching element of <emph>Alternative</emph> is used.</paragraph>
+<paragraph role="paragraph" id="par_id3170011" xml-lang="en-US" l10n="NEW">To
replace only #N/A and keep other error values, use IFNA.</paragraph>
+<paragraph role="heading" id="hd_id3170012" xml-lang="en-US" level="3"
l10n="NEW">Example</paragraph>
+<paragraph role="paragraph" id="par_id3170013" xml-lang="en-US"
l10n="NEW"><item type="input">=IFERROR(1/0; "fallback")</item> returns
<quote>fallback</quote>.</paragraph>
+<paragraph role="paragraph" id="par_id3170014" xml-lang="en-US"
l10n="NEW"><item type="input">=IFERROR(SQRT(-1); 10)</item> returns 10, because
the square root of a negative number gives the error Err:502.</paragraph>
+<paragraph role="paragraph" id="par_id3170015" xml-lang="en-US"
l10n="NEW"><item type="input">=IFERROR(5; 1/0)</item> returns 5; the
alternative is not evaluated.</paragraph>
+<embed href="text/shared/00/00000001.xhp#siehe"/>
+<paragraph role="paragraph" id="par_id3170016" xml-lang="en-US"
l10n="NEW"><link href="text/scalc/01/func_ifna.xhp" name="IFNA">IFNA</link>,
<link href="text/scalc/01/04060104.xhp#iserror"
name="ISERROR">ISERROR</link>.</paragraph>
+</body>
+</helpdocument>
diff --git a/main/helpcontent2/source/text/scalc/01/func_ifna.xhp
b/main/helpcontent2/source/text/scalc/01/func_ifna.xhp
new file mode 100644
index 0000000000..edfef5e486
--- /dev/null
+++ b/main/helpcontent2/source/text/scalc/01/func_ifna.xhp
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--***********************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ ***********************************************************-->
+
+<helpdocument version="1.0">
+<meta>
+<topic id="textscalc01func_ifnaxml" indexer="include" status="PUBLISH">
+<title id="tit" xml-lang="en-US">IFNA</title>
+<filename>/text/scalc/01/func_ifna.xhp</filename>
+</topic>
+</meta>
+<body>
+<bookmark xml-lang="en-US" branch="index" id="bm_id3160001">
+<bookmark_value>IFNA function</bookmark_value>
+<bookmark_value>error handling;IFNA</bookmark_value>
+<bookmark_value>#N/A;IFNA</bookmark_value>
+</bookmark>
+<bookmark xml-lang="en-US" branch="hid/SC_HID_FUNC_IFNA" id="bm_id3160002"
localize="false"/>
+<paragraph role="heading" id="hd_id3160001" xml-lang="en-US" level="2"
l10n="U"><variable id="ifna"><link
href="text/scalc/01/func_ifna.xhp">IFNA</link>
+</variable></paragraph>
+<paragraph role="paragraph" id="par_id3160003" xml-lang="en-US"
l10n="U"><ahelp hid="HID_FUNC_IFNA">Returns the value if the cell does not
contain an #N/A error value, otherwise it returns the alternative
value.</ahelp> Only the #N/A error is substituted; all other error values and
ordinary values pass through unchanged.</paragraph>
+<paragraph role="heading" id="hd_id3160004" xml-lang="en-US" level="3"
l10n="U">Syntax</paragraph>
+<paragraph role="code" id="par_id3160005" xml-lang="en-US"
l10n="U">IFNA(Value; Alternative)</paragraph>
+<paragraph role="paragraph" id="par_id3160006" xml-lang="en-US"
l10n="U"><emph>Value</emph> is the value or reference to be checked for an #N/A
error.</paragraph>
+<paragraph role="paragraph" id="par_id3160007" xml-lang="en-US"
l10n="U"><emph>Alternative</emph> is the value returned when <emph>Value</emph>
produces an #N/A error. It is evaluated only when <emph>Value</emph> is
#N/A.</paragraph>
+<paragraph role="heading" id="hd_id3160008" xml-lang="en-US" level="3"
l10n="U">Remarks</paragraph>
+<paragraph role="paragraph" id="par_id3160009" xml-lang="en-US" l10n="U">IFNA
distinguishes #N/A from other error values. Other errors (for example Err:502,
Err:508, or DIV/0!) are not caught and are returned as-is.</paragraph>
+<paragraph role="paragraph" id="par_id3160010" xml-lang="en-US" l10n="U">When
<emph>Value</emph> is a matrix, only matrix elements containing #N/A are
replaced by <emph>Alternative</emph>; all other elements pass through
unchanged.</paragraph>
+<paragraph role="heading" id="hd_id3160011" xml-lang="en-US" level="3"
l10n="U">Example</paragraph>
+<paragraph role="paragraph" id="par_id3160012" xml-lang="en-US" l10n="U"><item
type="input">=IFNA(VLOOKUP("zzz";A1:B10;2;0); "Not found")</item> returns
<quote>Not found</quote> when the lookup value is not present and produces
#N/A.</paragraph>
+<paragraph role="paragraph" id="par_id3160013" xml-lang="en-US" l10n="U"><item
type="input">=IFNA(1/0; 0)</item> returns #DIV/0! because IFNA does not catch
errors other than #N/A.</paragraph>
+<embed href="text/shared/00/00000001.xhp#siehe"/>
+<paragraph role="paragraph" id="par_id3160014" xml-lang="en-US" l10n="U"><link
href="text/scalc/01/04060104.xhp#isna" name="ISNA">ISNA</link>.</paragraph>
+</body>
+</helpdocument>
diff --git a/main/helpcontent2/source/text/scalc/01/func_skewp.xhp
b/main/helpcontent2/source/text/scalc/01/func_skewp.xhp
new file mode 100644
index 0000000000..24e118412e
--- /dev/null
+++ b/main/helpcontent2/source/text/scalc/01/func_skewp.xhp
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--***********************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ ***********************************************************-->
+
+<helpdocument version="1.0">
+<meta>
+<topic id="textscalc01func_skewpxml" indexer="include" status="PUBLISH">
+<title id="tit" xml-lang="en-US">SKEWP</title>
+<filename>/text/scalc/01/func_skewp.xhp</filename>
+</topic>
+</meta>
+<body>
+<bookmark xml-lang="en-US" branch="index" id="bm_id3160101">
+<bookmark_value>SKEWP function</bookmark_value>
+<bookmark_value>skewness;population</bookmark_value>
+<bookmark_value>population skewness</bookmark_value>
+</bookmark>
+<bookmark xml-lang="en-US" branch="hid/SC_HID_FUNC_SKEWP" id="bm_id3160102"
localize="false"/>
+<paragraph role="heading" id="hd_id3160101" xml-lang="en-US" level="2"
l10n="U"><variable id="skewp"><link
href="text/scalc/01/func_skewp.xhp">SKEWP</link>
+</variable></paragraph>
+<paragraph role="paragraph" id="par_id3160103" xml-lang="en-US"
l10n="U"><ahelp hid="HID_FUNC_SKEWP">Returns the skewness of a distribution
using the population standard deviation.</ahelp> Skewness characterizes the
degree of asymmetry of a distribution around its mean.</paragraph>
+<paragraph role="heading" id="hd_id3160104" xml-lang="en-US" level="3"
l10n="U">Syntax</paragraph>
+<paragraph role="code" id="par_id3160105" xml-lang="en-US"
l10n="U">SKEWP(Number1; Number2; ...Number30)</paragraph>
+<paragraph role="paragraph" id="par_id3160106" xml-lang="en-US"
l10n="U"><emph>Number1, Number2, ... Number30</emph> are up to 30 numerical
values or ranges representing the entire population.</paragraph>
+<paragraph role="heading" id="hd_id3160107" xml-lang="en-US" level="3"
l10n="U">Remarks</paragraph>
+<paragraph role="paragraph" id="par_id3160108" xml-lang="en-US" l10n="U">SKEWP
calculates <emph>population</emph> skewness, using the population standard
deviation (dividing by N). Use <link href="text/scalc/01/04060185.xhp#skew"
name="SKEW">SKEW</link> for <emph>sample</emph> skewness, which uses the sample
standard deviation (dividing by N-1).</paragraph>
+<paragraph role="paragraph" id="par_id3160109" xml-lang="en-US" l10n="U">Text
and empty cells within referenced ranges are skipped. Errors encountered during
reference iteration propagate and cause the function to return an error. Scalar
text arguments cause an error (Err:504). At least one numeric value is
required.</paragraph>
+<paragraph role="paragraph" id="par_id3160110" xml-lang="en-US" l10n="U">If
the population variance is zero (for example, all values are identical, or only
one value is given), the result is undefined and the function returns an
error.</paragraph>
+<paragraph role="heading" id="hd_id3160111" xml-lang="en-US" level="3"
l10n="U">Example</paragraph>
+<paragraph role="paragraph" id="par_id3160112" xml-lang="en-US" l10n="U"><item
type="input">=SKEWP(1; 2; 3; 4; 5)</item> returns approximately <item
type="input">0</item> because the distribution is symmetric.</paragraph>
+<paragraph role="paragraph" id="par_id3160113" xml-lang="en-US" l10n="U"><item
type="input">=SKEWP(1; 1; 1; 2; 3)</item> returns a positive value because the
distribution has a longer tail toward higher values.</paragraph>
+<embed href="text/shared/00/00000001.xhp#siehe"/>
+<paragraph role="paragraph" id="par_id3160114" xml-lang="en-US" l10n="U"><link
href="text/scalc/01/04060185.xhp#skew" name="SKEW">SKEW</link>.</paragraph>
+</body>
+</helpdocument>
diff --git a/main/helpcontent2/source/text/scalc/01/makefile.mk
b/main/helpcontent2/source/text/scalc/01/makefile.mk
index 5caa16c514..5392e30a64 100644
--- a/main/helpcontent2/source/text/scalc/01/makefile.mk
+++ b/main/helpcontent2/source/text/scalc/01/makefile.mk
@@ -191,6 +191,11 @@ XHPFILES = \
12120200.xhp \
12120300.xhp \
format_graphic.xhp \
+ func_bitand.xhp \
+ func_bitlshift.xhp \
+ func_bitor.xhp \
+ func_bitrshift.xhp \
+ func_bitxor.xhp \
func_date.xhp \
func_datevalue.xhp \
func_day.xhp \
@@ -200,11 +205,14 @@ XHPFILES = \
func_edate.xhp \
func_eomonth.xhp \
func_hour.xhp \
+ func_iferror.xhp \
+ func_ifna.xhp \
func_minute.xhp \
func_month.xhp \
func_networkdays.xhp \
func_now.xhp \
func_second.xhp \
+ func_skewp.xhp \
func_time.xhp \
func_timevalue.xhp \
func_today.xhp \
diff --git a/main/helpcontent2/util/scalc/makefile.mk
b/main/helpcontent2/util/scalc/makefile.mk
index 89c6db165b..36d0aa61a7 100644
--- a/main/helpcontent2/util/scalc/makefile.mk
+++ b/main/helpcontent2/util/scalc/makefile.mk
@@ -236,6 +236,14 @@ LINKLINKFILES= \
text$/scalc$/01$/func_workday.xhp \
text$/scalc$/01$/func_year.xhp \
text$/scalc$/01$/func_yearfrac.xhp \
+ text$/scalc$/01$/func_bitand.xhp \
+ text$/scalc$/01$/func_bitlshift.xhp \
+ text$/scalc$/01$/func_bitrshift.xhp \
+ text$/scalc$/01$/func_bitor.xhp \
+ text$/scalc$/01$/func_bitxor.xhp \
+ text$/scalc$/01$/func_iferror.xhp \
+ text$/scalc$/01$/func_ifna.xhp \
+ text$/scalc$/01$/func_skewp.xhp \
text$/scalc$/01$/solver.xhp \
text$/scalc$/01$/solver_options.xhp \
text$/scalc$/01$/text2columns.xhp \
diff --git a/main/oox/source/xls/formulabase.cxx
b/main/oox/source/xls/formulabase.cxx
index 12b30e528a..9c7e041598 100644
--- a/main/oox/source/xls/formulabase.cxx
+++ b/main/oox/source/xls/formulabase.cxx
@@ -723,11 +723,18 @@ static const FunctionData saFuncTableOox[] =
{ 0, "CUBEKPIMEMBER", 477, NOID, 3, 4,
V, { VR }, 0 },
{ 0, "CUBESET", 478, NOID, 2, 5,
V, { VR, RX, VR }, 0 },
{ 0, "CUBESETCOUNT", 479, NOID, 1, 1,
V, { VR }, 0 },
- { 0, "IFERROR", 480, NOID, 2, 2,
V, { VO, RO }, 0 },
+ { "IFERROR", "IFERROR", 480, NOID, 2, 2,
V, { VO, RO }, 0 },
{ "COUNTIFS", "COUNTIFS", 481, NOID, 2,
MX, V, { RO, VR }, FUNCFLAG_MACROCALL | FUNCFLAG_PARAMPAIRS },
{ "SUMIFS", "SUMIFS", 482, NOID, 3,
MX, V, { RO, RO, VR }, FUNCFLAG_MACROCALL | FUNCFLAG_PARAMPAIRS },
{ "AVERAGEIF", "AVERAGEIF", 483, NOID, 2, 3,
V, { RO, VR, RO }, FUNCFLAG_MACROCALL },
- { "AVERAGEIFS", "AVERAGEIFS", 484, NOID, 3,
MX, V, { RO, RO, VR }, FUNCFLAG_MACROCALL | FUNCFLAG_PARAMPAIRS }
+ { "AVERAGEIFS", "AVERAGEIFS", 484, NOID, 3,
MX, V, { RO, RO, VR }, FUNCFLAG_MACROCALL | FUNCFLAG_PARAMPAIRS },
+ { "IFNA", "IFNA", NOID, NOID, 2, 2,
V, { VR, RO }, FUNCFLAG_MACROCALL },
+ { "SKEWP", "SKEW.P", NOID, NOID, 1,
MX, V, { RX }, FUNCFLAG_MACROCALL },
+ { "BITAND", "BITAND", NOID, NOID, 2, 2,
V, { VR }, FUNCFLAG_MACROCALL },
+ { "BITOR", "BITOR", NOID, NOID, 2, 2,
V, { VR }, FUNCFLAG_MACROCALL },
+ { "BITXOR", "BITXOR", NOID, NOID, 2, 2,
V, { VR }, FUNCFLAG_MACROCALL },
+ { "BITLSHIFT", "BITLSHIFT", NOID, NOID, 2, 2,
V, { VR }, FUNCFLAG_MACROCALL },
+ { "BITRSHIFT", "BITRSHIFT", NOID, NOID, 2, 2,
V, { VR }, FUNCFLAG_MACROCALL }
};
/** Functions defined by OpenFormula, but not supported by Calc or by Excel. */
@@ -736,11 +743,6 @@ static const FunctionData saFuncTableOdf[] =
{ "ARABIC", 0, NOID, NOID, 1, 1,
V, { VR }, FUNCFLAG_MACROCALLODF },
{ "B", 0, NOID, NOID, 3, 4,
V, { VR }, FUNCFLAG_MACROCALLODF },
{ "BASE", 0, NOID, NOID, 2, 3,
V, { VR }, FUNCFLAG_MACROCALLODF },
- { "BITAND", 0, NOID, NOID, 2, 2,
V, { VR }, FUNCFLAG_MACROCALLODF },
- { "BITLSHIFT", 0, NOID, NOID, 2, 2,
V, { VR }, FUNCFLAG_MACROCALLODF },
- { "BITOR", 0, NOID, NOID, 2, 2,
V, { VR }, FUNCFLAG_MACROCALLODF },
- { "BITRSHIFT", 0, NOID, NOID, 2, 2,
V, { VR }, FUNCFLAG_MACROCALLODF },
- { "BITXOR", 0, NOID, NOID, 2, 2,
V, { VR }, FUNCFLAG_MACROCALLODF },
{ "CHISQDIST", 0, NOID, NOID, 2, 3,
V, { VR }, FUNCFLAG_MACROCALLODF },
{ "CHISQINV", 0, NOID, NOID, 2, 2,
V, { VR }, FUNCFLAG_MACROCALLODF },
{ "COMBINA", 0, NOID, NOID, 2, 2,
V, { VR }, FUNCFLAG_MACROCALLODF },
@@ -751,7 +753,6 @@ static const FunctionData saFuncTableOdf[] =
{ "FORMULA", 0, NOID, NOID, 1, 1,
V, { RO }, FUNCFLAG_MACROCALLODF },
{ "GAMMA", 0, NOID, NOID, 1, 1,
V, { VR }, FUNCFLAG_MACROCALLODF },
{ "GAUSS", 0, NOID, NOID, 1, 1,
V, { VR }, FUNCFLAG_MACROCALLODF },
- { "IFNA", 0, NOID, NOID, 2, 2,
V, { VR, RO }, FUNCFLAG_MACROCALLODF },
{ "ISFORMULA", 0, NOID, NOID, 1, 1,
V, { RO }, FUNCFLAG_MACROCALLODF },
{ "ISOWEEKNUM", 0, NOID, NOID, 1, 2,
V, { VR }, FUNCFLAG_MACROCALLODF },
{ "MUNIT", 0, NOID, NOID, 1, 1,
A, { VR }, FUNCFLAG_MACROCALLODF },
@@ -762,7 +763,6 @@ static const FunctionData saFuncTableOdf[] =
{ "RRI", 0, NOID, NOID, 3, 3,
V, { VR }, FUNCFLAG_MACROCALLODF },
{ "SHEET", 0, NOID, NOID, 0, 1,
V, { RO }, FUNCFLAG_MACROCALLODF },
{ "SHEETS", 0, NOID, NOID, 0, 1,
V, { RO }, FUNCFLAG_MACROCALLODF },
- { "SKEWP", 0, NOID, NOID, 1,
MX, V, { RX }, FUNCFLAG_MACROCALLODF },
{ "UNICHAR", 0, NOID, NOID, 1, 1,
V, { VR }, FUNCFLAG_MACROCALLODF },
{ "UNICODE", 0, NOID, NOID, 1, 1,
V, { VR }, FUNCFLAG_MACROCALLODF },
{ "XOR", 0, NOID, NOID, 1,
MX, V, { RX }, FUNCFLAG_MACROCALLODF }
@@ -1243,6 +1243,12 @@ bool OpCodeProviderImpl::initFuncOpCode( FunctionInfo&
orFuncInfo, const ApiToke
aEntry.Name = orFuncInfo.maOoxFuncName;
aEntry.Token = aIt->second;
maParserMap.push_back( aEntry );
+ // cell formulas spell macro call functions with the prefix
+ if( orFuncInfo.maBiffMacroName.getLength() > 0 )
+ {
+ aEntry.Name = orFuncInfo.maBiffMacroName;
+ maParserMap.push_back( aEntry );
+ }
}
}
else
diff --git a/main/sc/inc/compiler.hxx b/main/sc/inc/compiler.hxx
index c6d008b1d6..d96eecce85 100644
--- a/main/sc/inc/compiler.hxx
+++ b/main/sc/inc/compiler.hxx
@@ -56,8 +56,10 @@
// constants and data types also for external modules (ScInterpreter et al)
-#define MAXCODE 512 /* maximum number of tokens in formula */
+#define MAXCODE 2048 /* maximum number of tokens in formula */
#define MAXSTRLEN 1024 /* maximum length of input string of one symbol */
+#define MAXSTRLITLEN 32767 /* maximum length of a string literal in a formula
*/
+#define MAXSYMLEN (MAXSTRLITLEN+3) /* symbol buffer: quote, literal,
quote, 0 */
#define MAXJUMPCOUNT 32 /* maximum number of jumps (ocChose) */
// flag values of CharTable
@@ -200,6 +202,8 @@ public:
void SetExternal(const sal_Unicode* pStr);
ScRawToken* Clone() const; // real copy!
+ // Heap token sized to the string, so it may exceed MAXSTRLEN; free with
Delete().
+ static ScRawToken* NewString( const sal_Unicode* pStr, xub_StrLen nLen );
formula::FormulaToken* CreateToken() const; // create typified token
void Load( SvStream&, sal_uInt16 nVer );
@@ -310,7 +314,7 @@ private:
// For CONV_XL_OOX, may be set via API by MOOXML filter.
::com::sun::star::uno::Sequence< const
::com::sun::star::sheet::ExternalLinkInfo > maExternalLinks;
- sal_Unicode cSymbol[MAXSTRLEN]; // current Symbol
+ sal_Unicode* cSymbol; // current Symbol,
MAXSYMLEN characters
String aFormula; // formula source code
xub_StrLen nSrcPos; // tokenizer position
(source code)
ScRawTokenRef pRawToken;
@@ -354,6 +358,12 @@ public:
ScCompiler( ScDocument* pDocument, const ScAddress&,ScTokenArray& rArr);
+ virtual ~ScCompiler();
+
+private:
+ ScCompiler( const ScCompiler& ); // not implemented
+ ScCompiler& operator=( const ScCompiler& ); // not implemented
+
public:
static void DeInit(); /// all
diff --git a/main/sc/inc/dociter.hxx b/main/sc/inc/dociter.hxx
index 078e630bdb..15d5927928 100644
--- a/main/sc/inc/dociter.hxx
+++ b/main/sc/inc/dociter.hxx
@@ -155,6 +155,7 @@ private:
virtual bool getCurrent(Value& rValue) = 0;
virtual bool getFirst(Value& rValue) = 0;
virtual bool getNext(Value& rValue) = 0;
+ virtual SCSIZE countRecords() = 0;
protected:
const ScDBQueryDataIterator* mpParent;
};
@@ -167,6 +168,7 @@ private:
virtual bool getCurrent(Value& rValue);
virtual bool getFirst(Value& rValue);
virtual bool getNext(Value& rValue);
+ virtual SCSIZE countRecords();
private:
ScDBQueryParamInternal* mpParam;
@@ -191,6 +193,7 @@ private:
virtual bool getCurrent(Value& rValue);
virtual bool getFirst(Value& rValue);
virtual bool getNext(Value& rValue);
+ virtual SCSIZE countRecords();
private:
bool isValidQuery(SCROW mnRow, const ScMatrix& rMat) const;
@@ -210,6 +213,8 @@ public:
bool GetFirst(Value& rValue);
/// Does NOT reset rValue if no value found!
bool GetNext(Value& rValue);
+ /// Number of records matching the query, whatever their cells contain.
+ SCSIZE CountRecords();
};
// ============================================================================
diff --git a/main/sc/inc/helpids.h b/main/sc/inc/helpids.h
index b204e3f7c2..7bd4e35ee6 100644
--- a/main/sc/inc/helpids.h
+++ b/main/sc/inc/helpids.h
@@ -779,3 +779,6 @@
#define HID_FUNC_BITXOR
"SC_HID_FUNC_BITXOR"
#define HID_FUNC_BITLSHIFT
"SC_HID_FUNC_BITLSHIFT"
#define HID_FUNC_BITRSHIFT
"SC_HID_FUNC_BITRSHIFT"
+#define HID_FUNC_IFNA
"SC_HID_FUNC_IFNA"
+#define HID_FUNC_IFERROR
"SC_HID_FUNC_IFERROR"
+#define HID_FUNC_SKEWP
"SC_HID_FUNC_SKEWP"
diff --git a/main/sc/source/core/data/dociter.cxx
b/main/sc/source/core/data/dociter.cxx
index 388fb255e7..7f23ae0ecf 100644
--- a/main/sc/source/core/data/dociter.cxx
+++ b/main/sc/source/core/data/dociter.cxx
@@ -682,6 +682,39 @@ bool
ScDBQueryDataIterator::DataAccessInternal::getNext(Value& rValue)
return getCurrent(rValue);
}
+SCSIZE ScDBQueryDataIterator::DataAccessInternal::countRecords()
+{
+ // A record can match with an empty cell in a query column ("=", "<>5"),
+ // getCurrent() only visits rows that have a cell in column nCol.
+ ScQueryParam aParam(*mpParam);
+ SCROW nFirstRow = mpParam->bHasHeader ? mpParam->nRow1 + 1 :
mpParam->nRow1;
+ SCROW nLastRow = mpParam->nRow2;
+ if (nFirstRow > nLastRow)
+ return 0;
+ // A row without any content in the database columns is not a record.
+ ::std::vector<bool> aHasContent(nLastRow - nFirstRow + 1, false);
+ for (SCCOL nC = mpParam->nCol1; nC <= mpParam->nCol2; ++nC)
+ {
+ SCSIZE nCellCount = mpDoc->GetCellCount(nTab, nC);
+ for (SCSIZE i = ScDBQueryDataIterator::SearchColEntryIndex(*mpDoc,
nTab, nFirstRow, nC); i < nCellCount; ++i)
+ {
+ SCROW nThisRow =
ScDBQueryDataIterator::GetRowByColEntryIndex(*mpDoc, nTab, nC, i);
+ if (nThisRow > nLastRow)
+ break;
+ ScBaseCell* pCell =
ScDBQueryDataIterator::GetCellByColEntryIndex(*mpDoc, nTab, nC, i);
+ if (nThisRow >= nFirstRow && pCell && pCell->GetCellType() !=
CELLTYPE_NOTE)
+ aHasContent[nThisRow - nFirstRow] = true;
+ }
+ }
+ SCSIZE nCount = 0;
+ for (SCROW nR = nFirstRow; nR <= nLastRow; ++nR)
+ {
+ if (aHasContent[nR - nFirstRow] &&
ScDBQueryDataIterator::IsQueryValid(*mpDoc, aParam, nTab, nR, NULL))
+ ++nCount;
+ }
+ return nCount;
+}
+
// ----------------------------------------------------------------------------
ScDBQueryDataIterator::DataAccessMatrix::DataAccessMatrix(const
ScDBQueryDataIterator* pParent, ScDBQueryParamMatrix* pParam) :
@@ -737,6 +770,21 @@ bool
ScDBQueryDataIterator::DataAccessMatrix::getNext(Value& rValue)
return getCurrent(rValue);
}
+SCSIZE ScDBQueryDataIterator::DataAccessMatrix::countRecords()
+{
+ const ScMatrix& rMat = *mpParam->mpMatrix;
+ SCSIZE nCount = 0;
+ for (SCROW nR = mpParam->bHasHeader ? 1 : 0; nR < mnRows; ++nR)
+ {
+ bool bHasContent = false;
+ for (SCCOL nC = 0; nC < mnCols && !bHasContent; ++nC)
+ bHasContent = !rMat.IsEmpty(nC, nR);
+ if (bHasContent && isValidQuery(nR, rMat))
+ ++nCount;
+ }
+ return nCount;
+}
+
namespace {
bool lcl_isQueryByValue(const ScQueryEntry& rEntry, const ScMatrix& rMat,
SCSIZE nCol, SCSIZE nRow)
@@ -958,6 +1006,11 @@ bool ScDBQueryDataIterator::GetNext(Value& rValue)
return mpData->getNext(rValue);
}
+SCSIZE ScDBQueryDataIterator::CountRecords()
+{
+ return mpData->countRecords();
+}
+
// ============================================================================
ScCellIterator::ScCellIterator( ScDocument* pDocument,
diff --git a/main/sc/source/core/inc/interpre.hxx
b/main/sc/source/core/inc/interpre.hxx
index 74c3f8aa53..bc868204d3 100644
--- a/main/sc/source/core/inc/interpre.hxx
+++ b/main/sc/source/core/inc/interpre.hxx
@@ -90,7 +90,7 @@ private:
class ScToken;
-#define MAXSTACK (4096 / sizeof(formula::FormulaToken*))
+#define MAXSTACK (16384 / sizeof(formula::FormulaToken*))
class ScTokenStack
{
@@ -791,6 +791,10 @@ void ScHarMean();
void ScGeoMean();
void ScStandard();
void ScSkew();
+void ScSkewP();
+void ScIfna();
+void ScIfError();
+void ScIfnaOrError( bool bAnyError );
void ScMedian();
double GetMedian( ::std::vector<double> & rArray );
double GetPercentile( ::std::vector<double> & rArray, double fPercentile );
diff --git a/main/sc/source/core/inc/jumpmatrix.hxx
b/main/sc/source/core/inc/jumpmatrix.hxx
index 9af8cc4676..11a852697c 100644
--- a/main/sc/source/core/inc/jumpmatrix.hxx
+++ b/main/sc/source/core/inc/jumpmatrix.hxx
@@ -69,6 +69,7 @@ class ScJumpMatrix
SCSIZE nResMatCols;
SCSIZE nResMatRows;
bool bStarted;
+ bool bKeepNoPath;
// not implemented, prevent usage
ScJumpMatrix( const ScJumpMatrix& );
@@ -86,6 +87,7 @@ public:
, nResMatCols( nColsP )
, nResMatRows( nRowsP )
, bStarted( false )
+ , bKeepNoPath( false )
{
// Initialize result matrix in case of
// a premature end of the interpreter
@@ -154,6 +156,9 @@ public:
nNext, nStop);
}
}
+ /// Elements without a jump path keep the value already in the
result matrix.
+ void SetKeepNoPath() { bKeepNoPath = true; }
+ bool IsKeepNoPath() const { return bKeepNoPath; }
void SetJumpParameters( ScTokenVec* p )
{ pParams = p; }
const ScTokenVec* GetJumpParameters() const { return pParams; }
diff --git a/main/sc/source/core/tool/compiler.cxx
b/main/sc/source/core/tool/compiler.cxx
index 5dd6327b8e..3d93a8e448 100644
--- a/main/sc/source/core/tool/compiler.cxx
+++ b/main/sc/source/core/tool/compiler.cxx
@@ -1815,6 +1815,7 @@ ScCompiler::ScCompiler( ScDocument* pDocument, const
ScAddress& rPos,ScTokenArra
mbExtendedErrorDetection( false ),
mbRewind( false )
{
+ cSymbol = new sal_Unicode[ MAXSYMLEN ];
nMaxTab = pDoc ? pDoc->GetTableCount() - 1 : 0;
}
@@ -1831,9 +1832,15 @@ ScCompiler::ScCompiler( ScDocument* pDocument, const
ScAddress& rPos)
mbExtendedErrorDetection( false ),
mbRewind( false )
{
+ cSymbol = new sal_Unicode[ MAXSYMLEN ];
nMaxTab = pDoc ? pDoc->GetTableCount() - 1 : 0;
}
+ScCompiler::~ScCompiler()
+{
+ delete [] cSymbol;
+}
+
void ScCompiler::CheckTabQuotes( String& rString,
const FormulaGrammar::AddressConvention eConv
)
{
@@ -1969,7 +1976,7 @@ sal_Unicode* lcl_UnicodeStrNCpy( sal_Unicode* pDst, const
sal_Unicode* pSrc, xub
xub_StrLen ScCompiler::NextSymbol(bool bInArray)
{
- cSymbol[MAXSTRLEN-1] = 0; // Stopper
+ cSymbol[MAXSYMLEN-1] = 0; // Stopper
sal_Unicode* pSym = cSymbol;
const sal_Unicode* const pStart = aFormula.GetBuffer();
const sal_Unicode* pSrc = pStart + nSrcPos;
@@ -2239,7 +2246,7 @@ Label_MaskStateMachine:
}
if ( !bQuote )
{
- if( pSym == &cSymbol[ MAXSTRLEN-1 ] )
+ if( pSym == &cSymbol[ MAXSYMLEN-1 ] )
{
SetError(errStringOverflow);
eState = ssSkipString;
@@ -2695,7 +2702,7 @@ sal_Bool ScCompiler::IsString()
p++;
xub_StrLen nLen = sal::static_int_cast<xub_StrLen>( p - cSymbol - 1 );
sal_Bool bQuote = ((cSymbol[0] == '"') && (cSymbol[nLen] == '"'));
- if ((bQuote ? nLen-2 : nLen) > MAXSTRLEN-1)
+ if ((bQuote ? nLen-1 > MAXSTRLITLEN : nLen >= MAXSTRLEN-1))
{
SetError(errStringOverflow);
return sal_False;
@@ -2703,9 +2710,7 @@ sal_Bool ScCompiler::IsString()
if ( bQuote )
{
cSymbol[nLen] = '\0';
- ScRawToken aToken;
- aToken.SetString( cSymbol+1 );
- pRawToken = aToken.Clone();
+ pRawToken = ScRawToken::NewString( cSymbol+1, nLen ? nLen-1 : 0 );
// lone quote: nLen is 0
return sal_True;
}
return sal_False;
@@ -3386,8 +3391,8 @@ void ScCompiler::AutoCorrectParsedSymbol()
((GetCharTableFlags( aCorrectedSymbol.GetChar(nPos) ) &
(SC_COMPILER_C_WORD | SC_COMPILER_C_CHAR_DONTCARE)) == 0))
)
nPos--;
- if ( nPos == MAXSTRLEN - 2 )
- aCorrectedSymbol.SetChar( nPos, cQuote ); // '"' the 255th
character
+ if ( nPos == MAXSYMLEN - 2 )
+ aCorrectedSymbol.SetChar( nPos, cQuote ); // '"' the last
character
else
aCorrectedSymbol.Insert( cQuote, nPos + 1 );
bCorrected = sal_True;
@@ -3979,6 +3984,14 @@ ScTokenArray* ScCompiler::CompileString( const String&
rFormula )
aCorrectedFormula += mxSymbols->getSymbol(ocClose);
}
}
+ if ( aArr.GetLen() >= MAXCODE )
+ {
+ // keep the whole text, the tokens that fit would be written back as a
shorter formula
+ aArr.Clear();
+ aArr.AddBad( aFormula.Copy( nForced ) );
+ aArr.SetCodeError( errCodeOverflow );
+ bCorrected = sal_False; // the corrected text stops where the
tokens did
+ }
if ( nForced >= 2 )
pArr->SetRecalcModeForced();
diff --git a/main/sc/source/core/tool/interpr1.cxx
b/main/sc/source/core/tool/interpr1.cxx
index f52909a33e..2c7a56b6a1 100644
--- a/main/sc/source/core/tool/interpr1.cxx
+++ b/main/sc/source/core/tool/interpr1.cxx
@@ -321,6 +321,133 @@ void ScInterpreter::ScChoseJump()
aCode.Jump( pJump[ nJumpCount ], pJump[ nJumpCount ] );
}
+static bool lcl_IsIfnaHit( sal_uInt16 nErr, bool bAnyError )
+{
+ return bAnyError ? (nErr != 0) : (nErr == NOTAVAILABLE);
+}
+
+void ScInterpreter::ScIfna()
+{
+ ScIfnaOrError( false );
+}
+
+void ScInterpreter::ScIfError()
+{
+ ScIfnaOrError( true );
+}
+
+void ScInterpreter::ScIfnaOrError( bool bAnyError )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er",
"ScInterpreter::ScIfnaOrError" );
+ const short* pJump = pCur->GetJump();
+ bool bIsNA = false;
+ MatrixDoubleRefToMatrix();
+ // the value path keeps the format of the value
+ nFuncFmtType = nCurFmtType;
+ nFuncFmtIndex = nCurFmtIndex;
+
+ switch ( GetStackType() )
+ {
+ case svSingleRef :
+ case svDoubleRef :
+ {
+ ScAddress aAdr;
+ PopDoubleRefOrSingleRef( aAdr );
+ if ( lcl_IsIfnaHit( nGlobalError, bAnyError ) )
+ bIsNA = true;
+ else if ( nGlobalError )
+ PushError( nGlobalError );
+ else if ( lcl_IsIfnaHit( GetCellErrCode( GetCell( aAdr ) ),
bAnyError ) )
+ bIsNA = true;
+ else
+ PushCellResultToken( false, aAdr, &nFuncFmtType,
&nFuncFmtIndex );
+ }
+ break;
+ case svRefList :
+ // No per-element #N/A substitution, the value passes through.
+ break;
+ case svMatrix :
+ {
+ ScMatrixRef pMat = PopMatrix();
+ SCSIZE nCols = 0, nRows = 0;
+ if ( pMat )
+ pMat->GetDimensions( nCols, nRows );
+ if ( !nCols || !nRows )
+ {
+ PushIllegalParameter();
+ aCode.Jump( pJump[ 2 ], pJump[ 2 ] );
+ return;
+ }
+ FormulaTokenRef xNew;
+ ScTokenMatrixMap::const_iterator aMapIter;
+ if ( pTokenMatrixMap && ((aMapIter = pTokenMatrixMap->find( pCur
)) != pTokenMatrixMap->end()) )
+ xNew = (*aMapIter).second;
+ else
+ {
+ bool bAnyNA = false;
+ for ( SCSIZE nC = 0; nC < nCols && !bAnyNA; ++nC )
+ for ( SCSIZE nR = 0; nR < nRows && !bAnyNA; ++nR )
+ bAnyNA = pMat->IsValue( nC, nR ) && lcl_IsIfnaHit(
pMat->GetError( nC, nR ), bAnyError );
+ if ( !bAnyNA )
+ {
+ // nothing to substitute, the fallback is not evaluated
+ PushMatrix( pMat );
+ aCode.Jump( pJump[ 2 ], pJump[ 2 ] );
+ return;
+ }
+ // DoubleError handled by JumpMatrix
+ pMat->SetErrorInterpreter( NULL );
+ ScJumpMatrix* pJumpMat = new ScJumpMatrix( nCols, nRows );
+ pJumpMat->SetKeepNoPath();
+ ScMatrix* pRes = pJumpMat->GetResultMatrix();
+ for ( SCSIZE nC = 0; nC < nCols; ++nC )
+ {
+ for ( SCSIZE nR = 0; nR < nRows; ++nR )
+ {
+ if ( pMat->IsValue( nC, nR ) && lcl_IsIfnaHit(
pMat->GetError( nC, nR ), bAnyError ) )
+ pJumpMat->SetJump( nC, nR, 1.0, pJump[ 1 ], pJump[
2 ] );
+ else
+ {
+ ScMatValType nType = 0;
+ const ScMatrixValue* pMatVal = pMat->Get( nC, nR,
nType );
+ if ( ScMatrix::IsValueType( nType ) )
+ pRes->PutDouble( pMatVal->fVal, nC, nR );
+ else if ( ScMatrix::IsRealStringType( nType ) )
+ pRes->PutString( pMat->GetString( nC, nR ),
nC, nR );
+ else
+ pRes->PutEmpty( nC, nR );
+ pJumpMat->SetJump( nC, nR, 1.0, pJump[ 2 ], pJump[
2 ] );
+ }
+ }
+ }
+ xNew = new ScJumpMatrixToken( pJumpMat );
+ GetTokenMatrixMap().insert( ScTokenMatrixMap::value_type(
pCur, xNew ) );
+ }
+ PushTempToken( xNew );
+ // set endpoint of path for main code line
+ aCode.Jump( pJump[ 2 ], pJump[ 2 ] );
+ return;
+ }
+ default:
+ if ( lcl_IsIfnaHit( nGlobalError, bAnyError ) || (GetStackType()
== svError &&
+ lcl_IsIfnaHit( pStack[ sp - 1 ]->GetError(), bAnyError
)) )
+ {
+ Pop();
+ bIsNA = true;
+ }
+ }
+
+ if ( bIsNA )
+ {
+ nGlobalError = 0;
+ nFuncFmtType = NUMBERFORMAT_NUMBER;
+ nFuncFmtIndex = 0;
+ aCode.Jump( pJump[ 1 ], pJump[ 2 ] );
+ }
+ else
+ aCode.Jump( pJump[ 2 ], pJump[ 2 ] );
+}
+
void lcl_AdjustJumpMatrix( ScJumpMatrix* pJumpM, ScMatrixRef& pResMat, SCSIZE
nParmCols, SCSIZE nParmRows )
{
SCSIZE nJumpCols, nJumpRows;
@@ -585,7 +712,9 @@ bool ScInterpreter::JumpMatrix( short nStackLevel )
if ( pResMat )
{
// a sal_False without path results in an empty path value
- if ( fBool == 0.0 )
+ if ( pJumpMatrix->IsKeepNoPath() )
+ ; // result already in place
+ else if ( fBool == 0.0 )
pResMat->PutEmptyPath( nC, nR );
else
pResMat->PutDouble( fBool, nC, nR );
@@ -1174,34 +1303,43 @@ void
ScInterpreter::ScBitArithmeticOps(bitOperations::bitArithmetic bitOp)
{
nFuncFmtType = NUMBERFORMAT_NUMBER;
short nParamCount = GetByte();
- static const sal_uInt64 max_val = SAL_CONST_UINT64( 281474976710656 );
+ static const sal_uInt64 max_val = SAL_CONST_UINT64( 281474976710655 );
static const int NUMBER_OF_ARGUMENTS = 2;
if ( MustHaveParamCount( nParamCount, NUMBER_OF_ARGUMENTS ) )
{
double *arguments = new double[NUMBER_OF_ARGUMENTS];
+ sal_Bool bValid = sal_True;
for (int i=0; i<NUMBER_OF_ARGUMENTS; i++)
{
arguments[i] = ::rtl::math::approxFloor( GetDouble() );
- if ( arguments[i] < 0 || arguments[i] > max_val )
+ if ( !::rtl::math::isFinite( arguments[i] )
+ || arguments[i] < 0
+ || arguments[i] > max_val )
{
- PushIllegalArgument();
+ bValid = sal_False;
}
}
- sal_uInt64 res = 0;
- sal_Bool first = sal_True;
+ if ( bValid )
+ {
+ sal_uInt64 res = 0;
+ sal_Bool first = sal_True;
+ for (int i=0; i<NUMBER_OF_ARGUMENTS; i++)
+ {
+ doOperation( ( sal_uInt64 )arguments[i], bitOp, res, first );
+ }
- for (int i=0; i<NUMBER_OF_ARGUMENTS; i++)
+ delete[] arguments;
+ PushDouble( (double) res );
+ }
+ else
{
- doOperation( ( sal_uInt64 )arguments[i], bitOp, res, first );
+ delete[] arguments;
+ PushIllegalArgument();
}
-
- delete[] arguments;
- PushDouble( (double) res );
-
}
}
@@ -1219,29 +1357,44 @@ void
ScInterpreter::ScBitShiftOps(bitOperations::bitShift bitOp) {
double n = ::rtl::math::approxFloor( GetDouble() );
double val = ::rtl::math::approxFloor( GetDouble() );
- if ( val < 0 )
+ static const sal_uInt64 max_val = SAL_CONST_UINT64( 281474976710655 );
+
+ if ( !::rtl::math::isFinite( n )
+ || !::rtl::math::isFinite( val )
+ || val < 0.0
+ || static_cast<double>( max_val ) < val )
{
PushIllegalArgument();
}
else
{
double result;
- if (n < 0)
+ const sal_uInt64 uVal = static_cast<sal_uInt64>( val );
+ const sal_uInt64 nShift = ( n >= 64.0 || n <= -64.0 )
+ ? SAL_CONST_UINT64( 64 )
+ : ( n < 0.0 ? static_cast<sal_uInt64>( -n )
+ : static_cast<sal_uInt64>( n ) );
+ if ( nShift == 0 )
{
- if (bitOp == bitOperations::BITLSHIFT)
- result = (sal_uInt64) val >> (sal_uInt64) -n;
+ result = static_cast<double>( uVal );
+ }
+ else if ( nShift >= 64 )
+ {
+ result = 0.0;
+ }
+ else if ( n < 0.0 )
+ {
+ if ( bitOp == bitOperations::BITLSHIFT )
+ result = static_cast<double>( uVal >> nShift );
else
- result = (sal_uInt64) val << (sal_uInt64) -n;
+ result = static_cast<double>( uVal << nShift );
}
- else if( n == 0)
- result = val;
else
{
- if (bitOp == bitOperations::BITLSHIFT)
- result = (sal_uInt64) val << (sal_uInt64) n;
+ if ( bitOp == bitOperations::BITLSHIFT )
+ result = static_cast<double>( uVal << nShift );
else
- result = (sal_uInt64) val >> (sal_uInt64) n;
-
+ result = static_cast<double>( uVal >> nShift );
}
PushDouble( result );
}
@@ -4603,13 +4756,28 @@ void ScInterpreter::ScMatch()
}
+// A formula cell returning the empty string counts as blank, as in other
spreadsheets.
+static bool lcl_IsCountBlankEmpty( ScBaseCell* pCell )
+{
+ CellType eCellType = pCell ? pCell->GetCellType() : CELLTYPE_NONE;
+ if (eCellType == CELLTYPE_NONE || eCellType == CELLTYPE_NOTE)
+ return true;
+ if (eCellType != CELLTYPE_FORMULA)
+ return false;
+ ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
+ if (pFCell->GetErrCode() || pFCell->IsValue())
+ return false;
+ String aStr;
+ pFCell->GetString( aStr );
+ return aStr.Len() == 0;
+}
+
void ScInterpreter::ScCountEmptyCells()
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er",
"ScInterpreter::ScCountEmptyCells" );
if ( MustHaveParamCount( GetByte(), 1 ) )
{
sal_uLong nMaxCount = 0, nCount = 0;
- CellType eCellType;
switch (GetStackType())
{
case svSingleRef :
@@ -4617,8 +4785,7 @@ void ScInterpreter::ScCountEmptyCells()
nMaxCount = 1;
ScAddress aAdr;
PopSingleRef( aAdr );
- eCellType = GetCellType( GetCell( aAdr ) );
- if (eCellType != CELLTYPE_NONE && eCellType != CELLTYPE_NOTE)
+ if (!lcl_IsCountBlankEmpty( GetCell( aAdr ) ))
nCount = 1;
}
break;
@@ -4641,8 +4808,7 @@ void ScInterpreter::ScCountEmptyCells()
{
do
{
- if ((eCellType = pCell->GetCellType()) !=
CELLTYPE_NONE
- && eCellType != CELLTYPE_NOTE)
+ if (!lcl_IsCountBlankEmpty( pCell ))
nCount++;
} while ( (pCell = aDocIter.GetNext()) != NULL );
}
@@ -6725,30 +6891,10 @@ void ScInterpreter::ScDBCount()
if (pQueryParam.get())
{
sal_uLong nCount = 0;
- if ( bMissingField && pQueryParam->GetType() ==
ScDBQueryParamBase::INTERNAL )
- { // count all matching records
- // TODO: currently the QueryIterators only return cell pointers of
- // existing cells, so if a query matches an empty cell there's
- // nothing returned, and therefor not counted!
- // Since this has ever been the case and this code here only came
- // into existence to fix #i6899 and it never worked before we'll
- // have to live with it until we reimplement the iterators to also
- // return empty cells, which would mean to adapt all callers of
- // iterators.
- ScDBQueryParamInternal* p =
static_cast<ScDBQueryParamInternal*>(pQueryParam.get());
- SCTAB nTab = p->nTab;
- // ScQueryCellIterator doesn't make use of
ScDBQueryParamBase::mnField,
- // so the source range has to be restricted, like before the
introduction
- // of ScDBQueryParamBase.
- p->nCol1 = p->nCol2 = p->mnField;
- ScQueryCellIterator aCellIter( pDok, nTab, *p);
- if ( aCellIter.GetFirst() )
- {
- do
- {
- nCount++;
- } while ( aCellIter.GetNext() );
- }
+ if ( bMissingField )
+ { // count all matching records, whatever their cells contain
+ ScDBQueryDataIterator aRecIter( pDok, pQueryParam.release());
+ nCount = aRecIter.CountRecords();
}
else
{ // count only matching records with a value in the "result" field
@@ -6779,6 +6925,12 @@ void ScInterpreter::ScDBCount2()
if (pQueryParam.get())
{
sal_uLong nCount = 0;
+ if ( bMissingField )
+ { // count all matching records, whatever their cells contain
+ ScDBQueryDataIterator aRecIter( pDok, pQueryParam.release());
+ PushDouble( aRecIter.CountRecords() );
+ return;
+ }
pQueryParam->mbSkipString = false;
ScDBQueryDataIterator aValIter( pDok, pQueryParam.release());
ScDBQueryDataIterator::Value aValue;
diff --git a/main/sc/source/core/tool/interpr3.cxx
b/main/sc/source/core/tool/interpr3.cxx
index 74f60fb7b9..15c320718f 100644
--- a/main/sc/source/core/tool/interpr3.cxx
+++ b/main/sc/source/core/tool/interpr3.cxx
@@ -3103,6 +3103,47 @@ void ScInterpreter::ScSkew()
PushDouble(((xcube * fCount) / (fCount - 1.0)) / (fCount - 2.0));
}
+void ScInterpreter::ScSkewP()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScSkewP"
);
+ double fSum,fCount,vSum;
+ std::vector<double> values;
+ if ( !CalculateSkew(fSum,fCount,vSum,values) )
+ return;
+
+ // Population skewness requires at least one numeric observation.
+ if (fCount < 1.0)
+ {
+ PushIllegalArgument();
+ return;
+ }
+
+ double fMean = fSum / fCount;
+
+ for (size_t i = 0; i < values.size(); i++)
+ vSum += (values[i] - fMean) * (values[i] - fMean);
+
+ // Population standard deviation: sigma = sqrt( sum((xi-mean)^2) / N )
+ double fSigma = sqrt(vSum / fCount);
+
+ // Zero variance (including a single observation) is undefined.
+ if (fSigma == 0.0)
+ {
+ PushIllegalArgument();
+ return;
+ }
+
+ double xcube = 0.0;
+ for (size_t i = 0; i < values.size(); i++)
+ {
+ double dx = (values[i] - fMean) / fSigma;
+ xcube = xcube + (dx * dx * dx);
+ }
+
+ // Population skewness: (1/N) * sum( ((xi-mean)/sigma)^3 )
+ PushDouble(xcube / fCount);
+}
+
double ScInterpreter::GetMedian( vector<double> & rArray )
{
size_t nSize = rArray.size();
diff --git a/main/sc/source/core/tool/interpr4.cxx
b/main/sc/source/core/tool/interpr4.cxx
index dd24fff23d..600b2ae3f1 100644
--- a/main/sc/source/core/tool/interpr4.cxx
+++ b/main/sc/source/core/tool/interpr4.cxx
@@ -3398,7 +3398,7 @@ StackVar ScInterpreter::Interpret()
// RPN code push without error
PushWithoutError( (FormulaToken&) *pCur );
}
- else if (pTokenMatrixMap && !(eOp == ocIf || eOp == ocChose) &&
+ else if (pTokenMatrixMap && !(eOp == ocIf || eOp == ocChose || eOp ==
ocIfna || eOp == ocIfError) &&
((aTokenMatrixMapIter = pTokenMatrixMap->find( pCur)) !=
pTokenMatrixMap->end()) &&
(*aTokenMatrixMapIter).second->GetType() != svJumpMatrix)
@@ -3419,7 +3419,7 @@ StackVar ScInterpreter::Interpret()
nFuncFmtType = NUMBERFORMAT_NUMBER;
nFuncFmtIndex = 0;
- if ( eOp == ocIf || eOp == ocChose )
+ if ( eOp == ocIf || eOp == ocChose || eOp == ocIfna || eOp ==
ocIfError )
nStackBase = sp; // don't mess around with the jumps
else
{
@@ -3448,6 +3448,8 @@ StackVar ScInterpreter::Interpret()
// separated case ocPush : Push( (ScToken&) *pCur ); break;
case ocExternalRef : ScExternalRef(); break;
case ocIf : ScIfJump(); break;
+ case ocIfna : ScIfna(); break;
+ case ocIfError : ScIfError(); break;
case ocChose : ScChoseJump(); break;
case ocAdd : ScAdd(); break;
case ocSub : ScSub(); break;
@@ -3691,6 +3693,7 @@ StackVar ScInterpreter::Interpret()
case ocDevSq : ScDevSq(); break;
case ocKurt : ScKurt(); break;
case ocSchiefe : ScSkew(); break;
+ case ocSkewP : ScSkewP(); break;
case ocModalValue : ScModalValue(); break;
case ocMedian : ScMedian(); break;
case ocGeoMean : ScGeoMean(); break;
@@ -3852,6 +3855,8 @@ StackVar ScInterpreter::Interpret()
case ocIsEmpty : \
case ocIsErr : \
case ocIsError : \
+ case ocIfna : \
+ case ocIfError : \
case ocIsFormula : \
case ocIsLogical : \
case ocIsNA : \
@@ -4031,7 +4036,12 @@ StackVar ScInterpreter::Interpret()
nRetFmtIndex = 0;
if (nGlobalError && GetStackType() != svError )
+ {
+ // after errStackOverflow the push would fail and a stale value become
the result
+ if ( sp >= MAXSTACK )
+ Pop();
PushError( nGlobalError);
+ }
// THE final result.
xResult = PopToken();
diff --git a/main/sc/source/core/tool/parclass.cxx
b/main/sc/source/core/tool/parclass.cxx
index 3595278065..972874478d 100644
--- a/main/sc/source/core/tool/parclass.cxx
+++ b/main/sc/source/core/tool/parclass.cxx
@@ -59,9 +59,11 @@ const ScParameterClassification::RawData
ScParameterClassification::pRawData[] =
// IF() and CHOOSE() are somewhat special, since the ScJumpMatrix is
// created inside those functions and ConvertMatrixParameters() is not
- // called for them.
+ // called for them. The same goes for IFNA().
{ ocIf, {{ Array, Reference, Reference
}, 0 }},
{ ocChose, {{ Array, Reference
}, 1 }},
+ { ocIfna, {{ Reference, Reference
}, 0 }},
+ { ocIfError, {{ Reference, Reference
}, 0 }},
// Other specials.
{ ocOpen, {{ Bounds
}, 0 }},
{ ocClose, {{ Bounds
}, 0 }},
diff --git a/main/sc/source/core/tool/token.cxx
b/main/sc/source/core/tool/token.cxx
index 40073e5794..8e3d9e6348 100644
--- a/main/sc/source/core/tool/token.cxx
+++ b/main/sc/source/core/tool/token.cxx
@@ -160,6 +160,11 @@ void ScRawToken::SetOpCode( OpCode e )
eType = svJump;
nJump[ 0 ] = MAXJUMPCOUNT+1;
break;
+ case ocIfna:
+ case ocIfError:
+ eType = svJump;
+ nJump[ 0 ] = 2; // Fallback, Behind
+ break;
case ocMissing:
eType = svMissing;
break;
@@ -381,6 +386,21 @@ ScRawToken* ScRawToken::Clone() const
}
+ScRawToken* ScRawToken::NewString( const sal_Unicode* pStr, xub_StrLen nLen )
+{
+ static sal_uInt16 nOffset = lcl_ScRawTokenOffset(); // offset of sbyte
and cStr
+ size_t n = nOffset + GetStrLenBytes( nLen ) + GetStrLenBytes( 1 );
+ ScRawToken* p = (ScRawToken*) new sal_uInt8[ n ];
+ p->eOp = ocPush;
+ p->eType = svString;
+ p->nRefCnt = 0;
+ p->bRaw = sal_False;
+ memcpy( p->cStr, pStr, GetStrLenBytes( nLen ) );
+ p->cStr[ nLen ] = 0;
+ return p;
+}
+
+
FormulaToken* ScRawToken::CreateToken() const
{
#ifdef DBG_UTIL
diff --git a/main/sc/source/filter/excel/xlformula.cxx
b/main/sc/source/filter/excel/xlformula.cxx
index 533b177e64..2ff4d7925b 100644
--- a/main/sc/source/filter/excel/xlformula.cxx
+++ b/main/sc/source/filter/excel/xlformula.cxx
@@ -373,7 +373,23 @@ static const XclFunctionInfo saFuncTable_Oox[] =
{ ocAverageIf, NOID, 2, 3, V, { RO, VR, RO },
EXC_FUNCFLAG_IMPORTONLY, EXC_FUNCNAME( "AVERAGEIF" ) },
{ ocAverageIf, 255, 3, 4, V, { RO_E, RO, VR, RO },
EXC_FUNCFLAG_EXPORTONLY, EXC_FUNCNAME( "AVERAGEIF" ) },
{ ocAverageIfs, NOID, 3, MX, V, { RO, RO, VR },
EXC_FUNCFLAG_IMPORTONLY|EXC_FUNCFLAG_PARAMPAIRS, EXC_FUNCNAME( "AVERAGEIFS" ) },
- { ocAverageIfs, 255, 4, MX, V, { RO_E, RO, RO, VR },
EXC_FUNCFLAG_EXPORTONLY|EXC_FUNCFLAG_PARAMPAIRS, EXC_FUNCNAME( "AVERAGEIFS" ) }
+ { ocAverageIfs, 255, 4, MX, V, { RO_E, RO, RO, VR },
EXC_FUNCFLAG_EXPORTONLY|EXC_FUNCFLAG_PARAMPAIRS, EXC_FUNCNAME( "AVERAGEIFS" ) },
+ { ocIfna, NOID, 2, 2, V, { VR },
EXC_FUNCFLAG_IMPORTONLY, EXC_FUNCNAME( "IFNA" ) },
+ { ocIfna, 255, 3, 3, V, { RO_E, VO, RO },
EXC_FUNCFLAG_EXPORTONLY, EXC_FUNCNAME( "IFNA" ) },
+ { ocIfError, NOID, 2, 2, V, { VR },
EXC_FUNCFLAG_IMPORTONLY, EXC_FUNCNAME( "IFERROR" ) },
+ { ocIfError, 255, 3, 3, V, { RO_E, VO, RO },
EXC_FUNCFLAG_EXPORTONLY, EXC_FUNCNAME( "IFERROR" ) },
+ { ocSkewP, NOID, 1, MX, V, { VR },
EXC_FUNCFLAG_IMPORTONLY, EXC_FUNCNAME( "SKEW.P" ) },
+ { ocSkewP, 255, 2, MX, V, { RO_E, RO },
EXC_FUNCFLAG_EXPORTONLY, EXC_FUNCNAME( "SKEW.P" ) },
+ { ocBitAnd, NOID, 2, 2, V, { VR },
EXC_FUNCFLAG_IMPORTONLY, EXC_FUNCNAME( "BITAND" ) },
+ { ocBitAnd, 255, 3, 3, V, { RO_E, RO },
EXC_FUNCFLAG_EXPORTONLY, EXC_FUNCNAME( "BITAND" ) },
+ { ocBitOr, NOID, 2, 2, V, { VR },
EXC_FUNCFLAG_IMPORTONLY, EXC_FUNCNAME( "BITOR" ) },
+ { ocBitOr, 255, 3, 3, V, { RO_E, RO },
EXC_FUNCFLAG_EXPORTONLY, EXC_FUNCNAME( "BITOR" ) },
+ { ocBitXor, NOID, 2, 2, V, { VR },
EXC_FUNCFLAG_IMPORTONLY, EXC_FUNCNAME( "BITXOR" ) },
+ { ocBitXor, 255, 3, 3, V, { RO_E, RO },
EXC_FUNCFLAG_EXPORTONLY, EXC_FUNCNAME( "BITXOR" ) },
+ { ocBitLShift, NOID, 2, 2, V, { VR },
EXC_FUNCFLAG_IMPORTONLY, EXC_FUNCNAME( "BITLSHIFT" ) },
+ { ocBitLShift, 255, 3, 3, V, { RO_E, RO },
EXC_FUNCFLAG_EXPORTONLY, EXC_FUNCNAME( "BITLSHIFT" ) },
+ { ocBitRShift, NOID, 2, 2, V, { VR },
EXC_FUNCFLAG_IMPORTONLY, EXC_FUNCNAME( "BITRSHIFT" ) },
+ { ocBitRShift, 255, 3, 3, V, { RO_E, RO },
EXC_FUNCFLAG_EXPORTONLY, EXC_FUNCNAME( "BITRSHIFT" ) }
};
#define EXC_FUNCENTRY_ODF( opcode, minparam, maxparam, flags, asciiname ) \
@@ -386,11 +402,6 @@ static const XclFunctionInfo saFuncTable_Odf[] =
EXC_FUNCENTRY_ODF( ocArabic, 1, 1, 0, "ARABIC" ),
EXC_FUNCENTRY_ODF( ocB, 3, 4, 0, "B" ),
EXC_FUNCENTRY_ODF( ocBase, 2, 3, 0, "BASE" ),
- EXC_FUNCENTRY_ODF( ocNoName, 2, 2, 0, "BITAND" ),
- EXC_FUNCENTRY_ODF( ocNoName, 2, 2, 0, "BITLSHIFT" ),
- EXC_FUNCENTRY_ODF( ocNoName, 2, 2, 0, "BITOR" ),
- EXC_FUNCENTRY_ODF( ocNoName, 2, 2, 0, "BITRSHIFT" ),
- EXC_FUNCENTRY_ODF( ocNoName, 2, 2, 0, "BITXOR" ),
EXC_FUNCENTRY_ODF( ocChiSqDist, 2, 3, 0, "CHISQDIST" ),
EXC_FUNCENTRY_ODF( ocChiSqInv, 2, 2, 0, "CHISQINV" ),
EXC_FUNCENTRY_ODF( ocKombin2, 2, 2, 0, "COMBINA" ),
@@ -401,7 +412,6 @@ static const XclFunctionInfo saFuncTable_Odf[] =
EXC_FUNCENTRY_ODF( ocFormula, 1, 1, 0, "FORMULA" ),
EXC_FUNCENTRY_ODF( ocGamma, 1, 1, 0, "GAMMA" ),
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( ocMatrixUnit, 1, 1, 0, "MUNIT" ),
@@ -412,7 +422,6 @@ static const XclFunctionInfo saFuncTable_Odf[] =
EXC_FUNCENTRY_ODF( ocZGZ, 3, 3, 0, "RRI" ),
EXC_FUNCENTRY_ODF( ocTable, 0, 1, 0, "SHEET" ),
EXC_FUNCENTRY_ODF( ocTables, 0, 1, 0, "SHEETS" ),
- EXC_FUNCENTRY_ODF( ocNoName, 1, MX, 0, "SKEWP" ),
EXC_FUNCENTRY_ODF( ocUnichar, 1, 1, 0, "UNICHAR" ),
EXC_FUNCENTRY_ODF( ocUnicode, 1, 1, 0, "UNICODE" ),
EXC_FUNCENTRY_ODF( ocXor, 1, MX, 0, "XOR" )
diff --git a/main/sc/source/ui/src/scfuncs.src
b/main/sc/source/ui/src/scfuncs.src
index 1a1e5dc059..bdc41be4b2 100644
--- a/main/sc/source/ui/src/scfuncs.src
+++ b/main/sc/source/ui/src/scfuncs.src
@@ -1024,6 +1024,70 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS1
Text [ en-US ] = "An integer between 1583 and 9956, or
0 and 99 (19xx or 20xx depending on the option set). If omitted, the next
Easter Sunday on or after today is returned." ;
};
};
+ // -=*# Resource for function IFNA #*=-
+ Resource SC_OPCODE_IFNA
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the value if the cell does
not contain an #N/A error value, otherwise it returns the alternative value." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_LOGIC;
+ U2S( HID_FUNC_IFNA );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be checked for an #N/A
error." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Value_if_na" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The value to be returned if Value is
an #N/A error." ;
+ };
+ };
+ // -=*# Resource for function IFERROR #*=-
+ Resource SC_OPCODE_IFERROR
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the value if it is not an
error value, otherwise it returns the alternative value." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_LOGIC;
+ U2S( HID_FUNC_IFERROR );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be checked for an error
value." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Alternative" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The value to be returned if Value is
an error value." ;
+ };
+ };
// -=*# Resource for function BW #*=-
Resource SC_OPCODE_BW
{
@@ -5265,6 +5329,30 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
Text [ en-US ] = "Number 1, number 2, ... are 1 to 30
numerical arguments portraying a sample of the distribution." ;
};
};
+ // -=*# Resource for function SKEWP #*=-
+ Resource SC_OPCODE_SKEWP
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the skewness of a
distribution using the population standard deviation." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_SKEWP );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Number 1, number 2, ... are 1 to 30
numerical arguments portraying the population." ;
+ };
+ };
// -=*# Resource for function KURT #*=-
Resource SC_OPCODE_KURT
{
@@ -9453,7 +9541,7 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
};
String 3 // Description of Parameter 1
{
- Text [ en-US ] = "Positive integer less than 2^48." ;
+ Text [ en-US ] = "Integer greater than or equal to 0
and less than 2^48 (281474976710656)." ;
};
String 4 // Name of Parameter 2
{
@@ -9461,7 +9549,7 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
};
String 5 // Description of Parameter 2
{
- Text [ en-US ] = "Positive integer less than 2^48." ;
+ Text [ en-US ] = "Integer greater than or equal to 0
and less than 2^48 (281474976710656)." ;
};
};
@@ -9486,7 +9574,7 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
};
String 3 // Description of Parameter 1
{
- Text [ en-US ] = "Positive integer less than 2^48." ;
+ Text [ en-US ] = "Integer greater than or equal to 0
and less than 2^48 (281474976710656)." ;
};
String 4 // Name of Parameter 2
{
@@ -9494,7 +9582,7 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
};
String 5 // Description of Parameter 2
{
- Text [ en-US ] = "Positive integer less than 2^48." ;
+ Text [ en-US ] = "Integer greater than or equal to 0
and less than 2^48 (281474976710656)." ;
};
};
@@ -9519,7 +9607,7 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
};
String 3 // Description of Parameter 1
{
- Text [ en-US ] = "Positive integer less than 2^48." ;
+ Text [ en-US ] = "Integer greater than or equal to 0
and less than 2^48 (281474976710656)." ;
};
String 4 // Name of Parameter 2
{
@@ -9527,7 +9615,7 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
};
String 5 // Description of Parameter 2
{
- Text [ en-US ] = "Positive integer less than 2^48." ;
+ Text [ en-US ] = "Integer greater than or equal to 0
and less than 2^48 (281474976710656)." ;
};
};
@@ -9551,7 +9639,7 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
};
String 3 // Description of Parameter 1
{
- Text [ en-US ] = "The value to be shifted. Positive
integer." ;
+ Text [ en-US ] = "The value to be shifted. Integer
greater than or equal to 0 and less than 2^48 (281474976710656)." ;
};
String 4 // Name of Parameter 2
{
@@ -9559,7 +9647,7 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
};
String 5 // Description of Parameter 2
{
- Text [ en-US ] = "The number of bits the first argument
is to be shifted by." ;
+ Text [ en-US ] = "The number of bit positions the first
argument is shifted by. A positive value shifts left; a negative value shifts
right." ;
};
};
@@ -9583,7 +9671,7 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
};
String 3 // Description of Parameter 1
{
- Text [ en-US ] = "The value to be shifted. Positive
integer." ;
+ Text [ en-US ] = "The value to be shifted. Integer
greater than or equal to 0 and less than 2^48 (281474976710656)." ;
};
String 4 // Name of Parameter 2
{
@@ -9591,7 +9679,7 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
};
String 5 // Description of Parameter 2
{
- Text [ en-US ] = "The number of bits the first argument
is to be shifted by." ;
+ Text [ en-US ] = "The number of bit positions the first
argument is shifted by. A positive value shifts right; a negative value shifts
left." ;
};
};
diff --git a/main/sc/source/ui/view/viewfunc.cxx
b/main/sc/source/ui/view/viewfunc.cxx
index 0d53e5d2e8..89627526b2 100644
--- a/main/sc/source/ui/view/viewfunc.cxx
+++ b/main/sc/source/ui/view/viewfunc.cxx
@@ -525,6 +525,24 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB
nTab, const String& rS
}
}
} while ( bAgain );
+ if ( pArr->GetCodeError() == errCodeOverflow )
+ {
+ // refuse a formula that cannot be held, as
other spreadsheets do
+ delete pArr;
+ if ( bRecord )
+ {
+ for ( SCTAB k = 0; k < nUndoPos; k++ )
+ if ( ppOldCells[k] )
+ ppOldCells[k]->Delete();
+ delete[] ppOldCells;
+ delete[] pHasFormat;
+ delete[] pOldFormats;
+ delete[] pTabs;
+ delete pUndoData;
+ }
+ ErrorMessage( STR_LONG_ERR_CODE_OVF );
+ return;
+ }
// um in mehreren Tabellen eingesetzt zu werden, muss
die Formel
// via ScFormulaCell copy-ctor evtl. wegen RangeNames
neu kompiliert
// werden, gleiches Code-Array fuer alle Zellen geht
nicht.
diff --git a/main/sc/util/hidother.src b/main/sc/util/hidother.src
index 866acc9b0b..2d6a034435 100644
--- a/main/sc/util/hidother.src
+++ b/main/sc/util/hidother.src
@@ -491,3 +491,6 @@ hidspecial HID_FUNC_BITOR { HelpID =
HID_FUNC_BITOR; };
hidspecial HID_FUNC_BITXOR { HelpID = HID_FUNC_BITXOR; };
hidspecial HID_FUNC_BITLSHIFT { HelpID = HID_FUNC_BITLSHIFT; };
hidspecial HID_FUNC_BITRSHIFT { HelpID = HID_FUNC_BITRSHIFT; };
+hidspecial HID_FUNC_IFNA { HelpID = HID_FUNC_IFNA; };
+hidspecial HID_FUNC_IFERROR { HelpID = HID_FUNC_IFERROR; };
+hidspecial HID_FUNC_SKEWP { HelpID = HID_FUNC_SKEWP; };