This is an automated email from the ASF dual-hosted git repository.

jimjag pushed a commit to branch odf13-devel
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 9b08c22aafe8b966a05d47cec1650018ca0c5ad0
Author: Jim Jagielski <[email protected]>
AuthorDate: Fri Oct 30 09:57:17 2026 -0400

    sc, scaddins, formula: WEEKDAY types 11-17, RECEIVED, FTEST, DCOUNT field 
number, empty IF parameters and array mode for the lookup and regression 
arguments (ODF 1.3)
---
 main/formula/inc/formula/FormulaCompiler.hxx     |  6 +++++-
 main/formula/source/core/api/FormulaCompiler.cxx |  9 ++++++++-
 main/sc/source/core/tool/interpr1.cxx            |  4 ++++
 main/sc/source/core/tool/interpr2.cxx            |  2 ++
 main/sc/source/core/tool/interpr3.cxx            | 17 +++--------------
 main/sc/source/core/tool/interpr4.cxx            |  7 +++++++
 main/scaddins/source/analysis/financial.cxx      |  2 +-
 7 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/main/formula/inc/formula/FormulaCompiler.hxx 
b/main/formula/inc/formula/FormulaCompiler.hxx
index e70765788a..27a085797f 100644
--- a/main/formula/inc/formula/FormulaCompiler.hxx
+++ b/main/formula/inc/formula/FormulaCompiler.hxx
@@ -319,7 +319,11 @@ private:
 
     static inline void ForceArrayOperator( FormulaTokenRef& rCurr, const 
FormulaTokenRef& rPrev )
         {
-            if ( rPrev.Is() && rPrev->HasForceArray() &&
+            // ODF 1.3: the lookup and regression functions take array-mode 
arguments, but only the
+            // tokens nested in them are marked, not the function itself (its 
scalar parameters keep the implicit intersection)
+            if ( rPrev.Is() && ( rPrev->HasForceArray() || ( rPrev.get() != 
rCurr.get() && ( rPrev->GetOpCode() == ocHLookup ||
+                        rPrev->GetOpCode() == ocVLookup || rPrev->GetOpCode() 
== ocMatch || rPrev->GetOpCode() == ocRGP ||
+                        rPrev->GetOpCode() == ocRKP ) ) ) &&
                     rCurr->GetType() == svByte && rCurr->GetOpCode() != ocPush
                     && !rCurr->HasForceArray() )
                 rCurr->SetForceArray( true);
diff --git a/main/formula/source/core/api/FormulaCompiler.cxx 
b/main/formula/source/core/api/FormulaCompiler.cxx
index 46ed22cd0a..bb40ce20d2 100644
--- a/main/formula/source/core/api/FormulaCompiler.cxx
+++ b/main/formula/source/core/api/FormulaCompiler.cxx
@@ -1097,7 +1097,14 @@ void FormulaCompiler::Factor()
                 if ( ++nJumpCount <= nJumpMax )
                     pFacToken->GetJump()[nJumpCount] = pc-1;
                 NextToken();
-                eOp = Expression();
+                if ( pFacToken->GetOpCode() == ocIf && pToken->GetOpCode() == 
ocClose )
+                {   // ODF 1.3: IF(c;), IF(c;;) and IF(c;T;) have an empty 
last parameter
+                    FormulaTokenRef xMissing( new FormulaMissingToken );
+                    PutCode( xMissing );
+                    eOp = ocClose;
+                }
+                else
+                    eOp = Expression();
                 // ocSep or ocClose terminate the subexpression
                 PutCode( pToken );
             }
diff --git a/main/sc/source/core/tool/interpr1.cxx 
b/main/sc/source/core/tool/interpr1.cxx
index 51d7277357..b04831694b 100644
--- a/main/sc/source/core/tool/interpr1.cxx
+++ b/main/sc/source/core/tool/interpr1.cxx
@@ -6601,7 +6601,11 @@ ScDBQueryParamBase* ScInterpreter::GetDBParams( 
sal_Bool& rMissingField )
         if (rMissingField)
             ; // special case
         else if (bByVal)
+        {
+            if (nVal > pDBRef->getColSize())
+                return NULL;    // ODF 1.3 4.11.10: a field that does not 
exist is an error
             nField = pDBRef->findFieldColumn(static_cast<SCCOL>(nVal));
+        }
         else
         {
             sal_uInt16 nErr = 0;
diff --git a/main/sc/source/core/tool/interpr2.cxx 
b/main/sc/source/core/tool/interpr2.cxx
index a26b2d9872..32ac4abf4b 100644
--- a/main/sc/source/core/tool/interpr2.cxx
+++ b/main/sc/source/core/tool/interpr2.cxx
@@ -218,6 +218,8 @@ void ScInterpreter::ScGetDayOfWeek()
         }
         else if (nFlag == 2)
             nVal += 1;
+        else if (nFlag >= 11 && nFlag <= 17)    // ODF 1.3: week starts on 
Monday (11) to Sunday (17), numbered 1-7
+            nVal = ((nVal + (18 - nFlag)) % 7) + 1;
         PushInt( nVal );
     }
 }
diff --git a/main/sc/source/core/tool/interpr3.cxx 
b/main/sc/source/core/tool/interpr3.cxx
index b327c2f8cb..74f60fb7b9 100644
--- a/main/sc/source/core/tool/interpr3.cxx
+++ b/main/sc/source/core/tool/interpr3.cxx
@@ -2584,20 +2584,9 @@ void ScInterpreter::ScFTest()
         PushNoValue();
         return;
     }
-    double fF, fF1, fF2;
-    if (fS1 > fS2)
-    {
-        fF = fS1/fS2;
-        fF1 = fCount1-1.0;
-        fF2 = fCount2-1.0;
-    }
-    else
-    {
-        fF = fS2/fS1;
-        fF1 = fCount2-1.0;
-        fF2 = fCount1-1.0;
-    }
-    PushDouble(2.0*GetFDist(fF, fF1, fF2));
+    // ODF 1.3: two-tailed, from the right tail of F(n1-1, n2-1) beyond the 
ratio of the first to the second variance
+    double fRightTail = GetFDist(fS1/fS2, fCount1-1.0, fCount2-1.0);
+    PushDouble(2.0*(fRightTail < 0.5 ? fRightTail : 1.0-fRightTail));
 /*
     double Z = (pow(fF,1.0/3.0)*(1.0-2.0/(9.0*fF2)) - (1.0-2.0/(9.0*fF1))) /
                sqrt(2.0/(9.0*fF1) + pow(fF,2.0/3.0)*2.0/(9.0*fF2));
diff --git a/main/sc/source/core/tool/interpr4.cxx 
b/main/sc/source/core/tool/interpr4.cxx
index b07bb09e82..8896eabe42 100644
--- a/main/sc/source/core/tool/interpr4.cxx
+++ b/main/sc/source/core/tool/interpr4.cxx
@@ -4001,6 +4001,13 @@ StackVar ScInterpreter::Interpret()
                     SetError( errUnknownStackVariable);
             }
         }
+        else if( pCur->GetOpCode() == ocMissing )
+        {   // ODF 1.3: an empty IfTrue or IfFalse of IF is 0
+            Pop();
+            PushDouble( 0.0 );
+            nRetTypeExpr = NUMBERFORMAT_NUMBER;
+            nRetIndexExpr = 0;
+        }
         else
             SetError( errUnknownStackVariable);
     }
diff --git a/main/scaddins/source/analysis/financial.cxx 
b/main/scaddins/source/analysis/financial.cxx
index a5d811c6ef..b6744bc9a7 100644
--- a/main/scaddins/source/analysis/financial.cxx
+++ b/main/scaddins/source/analysis/financial.cxx
@@ -81,7 +81,7 @@ double SAL_CALL AnalysisAddIn::getAccrintm( constREFXPS& xOpt,
 double SAL_CALL AnalysisAddIn::getReceived( constREFXPS& xOpt,
        sal_Int32 nSettle, sal_Int32 nMat, double fInvest, double fDisc, const 
ANY& rOB )
 {
-       if( fInvest <= 0.0 || fDisc <= 0.0 )
+       if( fInvest <= 0.0 || fDisc <= 0.0 || nSettle >= nMat )
                THROW_IAE;
 
     double fRet = fInvest / ( 1.0 - ( fDisc * GetYearDiff( GetNullDate( xOpt 
), nSettle, nMat, getDateMode( xOpt, rOB ) ) ) );

Reply via email to