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

asf-gitbox-commits pushed a commit to branch openformula
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit cf30ea8b32426d16608748e67b170cdaddf2d323
Author: Pedro Giffuni <[email protected]>
AuthorDate: Tue Nov 17 15:40:09 2026 -0500

    H.4: Fix ERROR.TYPE error-code mapping, add help and tests
    
    - Add MapErrorType() mapping internal AOO error codes to ODF 1-7
    - Update ScErrorType() to return ERROR.TYPE values per ODF 1.4
    - Add English help topic func_errortype.xhp
    - Add calcval test cases SG.ERRTYPE-01..12
    - Update audit records
---
 .../function-gap-inventory.md                      |   2 +-
 .../function-gap-summary.tsv                       |   2 +-
 .../function-implementation-roadmap.md             |  22 ++--
 .../function-semantic-test-plan.md                 |  25 ++---
 .../function-source-audit.md                       |  26 +++--
 .../helpcontent2/source/text/scalc/01/04060102.xhp |   5 +
 .../source/text/scalc/01/func_errortype.xhp        | 115 +++++++++++++++++++++
 main/helpcontent2/source/text/scalc/01/makefile.mk |   1 +
 main/sc/source/core/tool/interpr1.cxx              |  28 ++++-
 test/odf-validate/calcval-cases14.tsv              |  12 +++
 10 files changed, 200 insertions(+), 38 deletions(-)

diff --git a/audit/openformula-function-gaps/function-gap-inventory.md 
b/audit/openformula-function-gaps/function-gap-inventory.md
index f95d070f37..1414a2780e 100644
--- a/audit/openformula-function-gaps/function-gap-inventory.md
+++ b/audit/openformula-function-gaps/function-gap-inventory.md
@@ -18,7 +18,7 @@ Summary table of all 15 audited functions.
 | ODDFPRICE | Present (AddIn) | None | getOddfprice() (AddIn) | Yes 
(HID_AAI_FUNC_ODDFPRICE) | No | N/A | No | No | No | No | Analysis AddIn, not 
native | P2 | HIGH |
 | ODDFYIELD | Present (AddIn) | None | getOddfyield() (AddIn) | Yes 
(HID_AAI_FUNC_ODDFYIELD) | No | N/A | No | No | No | No | Analysis AddIn, not 
native | P2 | HIGH |
 | RRI | Present (validation gaps) | ocZGZ | ScZGZ() | German only (ZGZ) | No | 
N/A | No | Yes (ODF table, import-only) | No | _xlfnodf.RRI | No input 
validation (zero/neg PV, zero periods, overflow); German help only | P2 | HIGH |
-| ERROR.TYPE | Present (mapping gap) | ocErrorType (151) | ScErrorType() | 
German only (FEHLERTYP) | Yes | Verify (likely Large Group) | No | No | No | No 
| Internal error codes not mapped to ODF return values (1–7); German help only 
| P1 | MEDIUM |
+| ERROR.TYPE | Present | ocErrorType (151) | ScErrorType() | Yes 
(HID_FUNC_FEHLERTYP) | Yes | Large Group | Yes(BIFF4,ID261,ocErrorType) | No | 
No | No | H.4 fixed: MapErrorType() maps internal codes to ODF 1–7 | 
Resolved/H.4 (was P1) | HIGH |
 | NUMBERVALUE | Present | ocNumberValue (392) | ScNumberValue() | Yes 
(HID_FUNC_NUMBERVALUE) | Yes | Verify (likely Large Group) | No | Yes (ODF 
table, import-only) | No | _xlfnodf.NUMBERVALUE | None — implementation 
complete at source level | Resolved (was P1) | HIGH |
 | GETPIVOTDATA | Present | ocGetPivotData (390) | ScGetPivotData() | Yes 
(HID_FUNC_GETPIVOTDATA) | No | N/A | Yes (BIFF8, ID 358) | No | Yes (BIFF8) | 
No | DataPilot-dependent; XLSX import/export mapping missing | P2 | HIGH |
 | FDIST | Present | ocFDist (315) | ScFDist() | German only (FVERT) | No | N/A 
| No | Yes (ODF table, import-only) | No | _xlfnodf.FDIST | Param count (3 vs 
ODF 3–4); German help only; _xlfnodf export naming | P2 | HIGH |
diff --git a/audit/openformula-function-gaps/function-gap-summary.tsv 
b/audit/openformula-function-gaps/function-gap-summary.tsv
index a4c157aa8b..dfcde23ac0 100644
--- a/audit/openformula-function-gaps/function-gap-summary.tsv
+++ b/audit/openformula-function-gaps/function-gap-summary.tsv
@@ -8,7 +8,7 @@ DDE     No      N/A     ocDde(369)      DDE     ScDde() Yes 
(HID_FUNC_DDE)      No      No      No      No      Platform-depend
 ODDFPRICE      No      N/A     None    ODDFPRICE       getOddfprice() (AddIn)  
Yes (HID_AAI_FUNC_ODDFPRICE)    No      No      No      No      Analysis AddIn, 
not native      P2      HIGH    odffmap.cxx:127; financial.cxx:404; AddIn 
mechanism only
 ODDFYIELD      No      N/A     None    ODDFYIELD       getOddfyield() (AddIn)  
Yes (HID_AAI_FUNC_ODDFYIELD)    No      No      No      No      Analysis AddIn, 
not native      P2      HIGH    odffmap.cxx:128; financial.cxx:416; AddIn 
mechanism only
 RRI    No      N/A     ocZGZ   RRI     ScZGZ() German only (ZGZ)       No      
Yes(ODF table,import-only)      No      _xlfnodf.RRI    No input validation 
(zero/neg PV, zero periods, overflow); German help only     P2      HIGH    
interpr2.cxx:1198 ScZGZ(); pow(fV/fP,1/n)-1 with no validation
-ERROR.TYPE     Yes     Verify (likely Large Group)     ocErrorType(151)        
ERROR.TYPE / ORG.OPENOFFICE.ERRORTYPE   ScErrorType()   German only (FEHLERTYP) 
No      No      No      No      Internal error codes not mapped to ODF return 
values (1–7)      P1      MEDIUM  interpr1.cxx:8377; mapping from internal err 
codes to ODF 1–7 not evident in source
+ERROR.TYPE     Yes     Large Group     ocErrorType(151)        
ORG.OPENOFFICE.ERRORTYPE/ERRORTYPE      ScErrorType()   Yes 
(HID_FUNC_FEHLERTYP)        Yes(BIFF4,ID261,ocErrorType)    No      No      No  
    H.4 fixed: MapErrorType() maps internal codes to ODF 1–7; English 
help+tests added      Resolved/H.4 (was P1)   HIGH    compiler.hrc:151; 
xlformula.cxx:257 BIFF4 import; interpr1.cxx:8574 MapErrorType(); help 
func_errortype.xhp; SG.ERRTYPE-01..12 tests
 NUMBERVALUE    Yes     Verify (likely Large Group)     ocNumberValue(392)      
NUMBERVALUE     ScNumberValue() Yes (HID_FUNC_NUMBERVALUE)      No      Yes(ODF 
table,import-only)      No      _xlfnodf.NUMBERVALUE    None — implementation 
complete at source level  Resolved (was P1)       HIGH    compiler.hrc:388; 
interpr4.cxx:3559 dispatch, interpr4.cxx:4066+ evaluator; ODF 6.13.28 conformant
 GETPIVOTDATA   No      N/A     ocGetPivotData(390)     GETPIVOTDATA    
ScGetPivotData()        Yes (HID_FUNC_GETPIVOTDATA)     Yes(BIFF8,ID358)        
No      Yes(BIFF8)      No      DataPilot-dependent; XLSX import/export mapping 
missing P2      HIGH    interpr2.cxx:2972; xlformula.cxx:351 (BIFF8 only); not 
in saFuncTable_Oox
 FDIST  No      N/A     ocFDist(315)    FDIST / LEGACY.FDIST    ScFDist()       
German only (FVERT)     No      Yes(ODF table,import-only)      No      
_xlfnodf.FDIST  Param count (3 vs ODF 3–4); German help only; _xlfnodf export 
naming    P2      HIGH    interpr3.cxx:1588; GetFDist at interpr3.cxx:665; 
Enforces exactly 3 params
diff --git a/audit/openformula-function-gaps/function-implementation-roadmap.md 
b/audit/openformula-function-gaps/function-implementation-roadmap.md
index 19673e682e..3cc1b74117 100644
--- a/audit/openformula-function-gaps/function-implementation-roadmap.md
+++ b/audit/openformula-function-gaps/function-implementation-roadmap.md
@@ -132,18 +132,18 @@ Rationale: Implementation exists but lacks validation. 
Help only in
 Group 5 — ERROR.TYPE
 --------------------
 
-Recommended sequence:
-  1. Map AOO internal error codes (errNoValue, errNoRef, errDivZero,
-     errIllegalArgument, errNoName, errNoValue, errNotAvailable, etc.)
-     to ODF ERROR.TYPE return values:
-        1=#NULL!, 2=#DIV/0!, 3=#VALUE!, 4=#REF!, 5=#NAME!, 6=#NUM!, 7=#N/A.
-     Verify ScErrorType() (interpr1.cxx:8377) produces correct values.
-  2. Add English help entry (currently German FEHLERTYP only).
-  3. Verify ODF namespace name ORG.OPENOFFICE.ERRORTYPE works.
-  4. Add test cases.
+Status: COMPLETED in H.4 (commit on openformula branch).
 
-Rationale: Implementation exists but error-code-to-ODF-number mapping
-  is not evident in source. This is a potential semantic gap.
+Changes:
+  1. Added MapErrorType() helper in interpr1.cxx mapping internal error codes
+     to ODF ERROR.TYPE return values (1–7).
+  2. Modified ScErrorType() to use MapErrorType() before pushing result.
+  3. Added English help topic func_errortype.xhp and registered in makefile
+     and 04060102.xhp index.
+  4. Added calcval test cases SG.ERRTYPE-01 through SG.ERRTYPE-12.
+
+Rationale: Implementation existed but error-code-to-ODF-number mapping
+  was missing. Now resolved at source level.
 
 
 Group 6 — NUMBERVALUE (Critical Gap) — COMPLETED
diff --git a/audit/openformula-function-gaps/function-semantic-test-plan.md 
b/audit/openformula-function-gaps/function-semantic-test-plan.md
index ce3c74d2f6..438149be86 100644
--- a/audit/openformula-function-gaps/function-semantic-test-plan.md
+++ b/audit/openformula-function-gaps/function-semantic-test-plan.md
@@ -194,27 +194,28 @@ Purpose: Confirm validation gaps in RRI implementation.
 
 ODF 1.4: Returns error number (1=#NULL!, 2=#DIV/0!, ..., 7=#N/A).
 
-Test cases:
-  a) =ERROR.TYPE(#DIV/0!) — expected: 2
+Test cases (implemented as `SG.ERRTYPE-*` in 
`test/odf-validate/calcval-cases14.tsv`):
+  a) =ERROR.TYPE(1/0) — expected: 2 (#DIV/0!)
   b) =ERROR.TYPE(#VALUE!) — expected: 3
   c) =ERROR.TYPE(#REF!) — expected: 4
-  d) =ERROR.TYPE(#NAME!) — expected: 5
+  d) =ERROR.TYPE(#NAME?) — expected: 5
   e) =ERROR.TYPE(#NUM!) — expected: 6
   f) =ERROR.TYPE(#N/A) — expected: 7
   g) =ERROR.TYPE(#NULL!) — expected: 1
-  h) =ERROR.TYPE(5) — no error → NA error
+  h) =ERROR.TYPE(5) — non-error → #N/A error
   i) =ERROR.TYPE(A1) where A1 contains #DIV/0! — reference to error cell (2)
-  j) =ERROR.TYPE(A1:B2) — multiple refs → errNoValue
+  j) =ERROR.TYPE(A1:B2) — multiple refs → #N/A error
   k) =ERROR.TYPE() — wrong arg count (error)
-  l) =ERROR.TYPE(ORG.OPENOFFICE.ERRORTYPE(#DIV/0!)) — ODF namespace name
+  l) =ERROR.TYPE(ORG.OPENOFFICE.ERRORTYPE(1/0)) — ODF namespace name
 
-Expected: ScErrorType() (interpr1.cxx:8377) pushes internal error code
-  as double. The mapping from internal error codes to ODF ERROR.TYPE
-  return values (1–7) is NOT evident in source. Tests (a)–(g) verify
-  whether the mapping is correct. Test (j) verifies multi-ref handling.
+Fixed: ScErrorType() (interpr1.cxx:8574) now maps internal AOO error codes
+  to ODF ERROR.TYPE return values via MapErrorType():
+  errNoCode(521)→1, errDivisionByZero(532)→2, errNoValue(519)→3,
+  errNoRef(524)→4, errNoName(525)→5, errIllegalFPOperation(503)→6,
+  NOTAVAILABLE(32767)→7. Other error codes / no error → #N/A.
 
-Purpose: Confirm error-code mapping to ODF return values. This is the
-  primary semantic gap for ERROR.TYPE.
+Purpose: Validate error-code mapping to ODF return values. Semantic gap
+  resolved in H.4; runtime validation pending build availability.
 
 
 11. NUMBERVALUE
diff --git a/audit/openformula-function-gaps/function-source-audit.md 
b/audit/openformula-function-gaps/function-source-audit.md
index 3843d84d8f..f7cb20479f 100644
--- a/audit/openformula-function-gaps/function-source-audit.md
+++ b/audit/openformula-function-gaps/function-source-audit.md
@@ -428,30 +428,34 @@ A. Function registration
   - Excel import mapping: Not in xlformula.cxx BIFF tables.
   - Excel export mapping: None.
 
-B. Actual implementation: ScErrorType() (interpr1.cxx:8377) examines
+B. Actual implementation: ScErrorType() (interpr1.cxx:8574) examines
   the stack type:
   - svRefList: gets error code from first cell in ref list;
     errNoRef if empty, errNoValue if >1 ref.
   - svDoubleRef/svSingleRef: gets cell error code via pDok->GetErrCode().
   - default: PopError(), pushes error number.
   If no error (nErr == 0), pushes NA (PushNA()).
-  Error codes are internal Aoo error codes (errNoValue, errNoRef,
-  etc.), not the ODF-specified ERROR.TYPE return values (1=#NULL!,
-  2=#DIV/0!, 3=#VALUE!, 4=#REF!, 5=#NAME!, 6=#NUM!, 7=#N/A).
-  Mapping from internal error codes to ODF error numbers is NOT
-  evident in the source — this is a potential semantic gap.
+  H.4 FIX: Added MapErrorType() helper that maps internal AOO error codes
+  to ODF ERROR.TYPE return values:
+    errNoCode(521) → 1 (#NULL!)
+    errDivisionByZero(532) → 2 (#DIV/0!)
+    errNoValue(519) → 3 (#VALUE!)
+    errNoRef(524) → 4 (#REF!)
+    errNoName(525) → 5 (#NAME?)
+    errIllegalFPOperation(503) → 6 (#NUM!)
+    NOTAVAILABLE(32767) → 7 (#N/A)
+  Other internal error codes or no error → #N/A error (ODF-compliant).
+  Semantic gap RESOLVED.
 
 C. Format compatibility: No BIFF/OOXML table mapping for ERROR.TYPE.
 
 D. Documentation: Help entry exists under German name FEHLERTYP only.
   No English ERROR.TYPE help entry found.
 
-Failure type: Implementation present but error-code mapping to ODF
-  ERROR.TYPE return values (1–7) not evident in source. Help only
-  in German.
+Failure type: Implementation present; H.4 resolved error-code mapping
+  to ODF ERROR.TYPE return values (1–7). Help added in English.
 Priority: P1 (ODF-defined function; error code mapping gap).
-Confidence: MEDIUM — implementation present but semantic mapping to
-            ODF error numbers unverified.
+Confidence: HIGH — implementation fixed and verified at source level.
 
 
 11. NUMBERVALUE
diff --git a/main/helpcontent2/source/text/scalc/01/04060102.xhp 
b/main/helpcontent2/source/text/scalc/01/04060102.xhp
index b71c7937af..78e9ab4469 100644
--- a/main/helpcontent2/source/text/scalc/01/04060102.xhp
+++ b/main/helpcontent2/source/text/scalc/01/04060102.xhp
@@ -152,6 +152,11 @@
 <embedvar href="text/scalc/01/func_eomonth.xhp#eomonth"/>
 </paragraph>
 </section>
+<section id="errortype">
+<paragraph role="paragraph" id="par_id3155541" xml-lang="en-US" l10n="NEW">
+<embedvar href="text/scalc/01/func_errortype.xhp#errortype"/>
+</paragraph>
+</section>
 <section id="networkdays">
 <paragraph role="paragraph" id="par_id8951384" xml-lang="en-US" l10n="NEW">
 <embedvar href="text/scalc/01/func_networkdays.xhp#networkdays"/>
diff --git a/main/helpcontent2/source/text/scalc/01/func_errortype.xhp 
b/main/helpcontent2/source/text/scalc/01/func_errortype.xhp
new file mode 100644
index 0000000000..111623e92c
--- /dev/null
+++ b/main/helpcontent2/source/text/scalc/01/func_errortype.xhp
@@ -0,0 +1,115 @@
+<?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_errortypexml" indexer="include" status="PUBLISH">
+<title id="tit" xml-lang="en-US">ERROR.TYPE</title>
+<filename>/text/scalc/01/func_errortype.xhp</filename>
+</topic>
+</meta>
+<body>
+<bookmark xml-lang="en-US" branch="index" id="bm_id3155541">
+<bookmark_value>ERROR.TYPE function</bookmark_value>
+<bookmark_value>error type</bookmark_value>
+</bookmark>
+<bookmark xml-lang="en-US" branch="hid/SC_HID_FUNC_FEHLERTYP" 
id="bm_id3155542" localize="false"/>
+<paragraph role="heading" id="hd_id3155540" xml-lang="en-US" level="2" 
l10n="U"><variable id="errortype"><link 
href="text/scalc/01/func_errortype.xhp">ERROR.TYPE</link>
+</variable></paragraph>
+<paragraph role="paragraph" id="par_id3155543" xml-lang="en-US" 
l10n="U"><ahelp hid="HID_FUNC_FEHLERTYP">Returns a number corresponding to the 
error type of the error value.</ahelp></paragraph>
+<paragraph role="heading" id="hd_id3155544" xml-lang="en-US" level="3" 
l10n="U">Syntax</paragraph>
+<paragraph role="code" id="par_id3155545" xml-lang="en-US" 
l10n="U">ERROR.TYPE(Reference)</paragraph>
+<paragraph role="paragraph" id="par_id3155546" xml-lang="en-US" 
l10n="U"><emph>Reference</emph> is the cell reference or error value to be 
checked.</paragraph>
+<paragraph role="heading" id="hd_id3155547" xml-lang="en-US" level="3" 
l10n="U">Return values</paragraph>
+<table id="tbl_id3155548">
+<tablerow>
+<tablecell>
+<paragraph role="tablehead" id="par_id3155549" xml-lang="en-US" 
l10n="U">Return value</paragraph>
+</tablecell>
+<tablecell>
+<paragraph role="tablehead" id="par_id3155550" xml-lang="en-US" l10n="U">Error 
type</paragraph>
+</tablecell>
+</tablerow>
+<tablerow>
+<tablecell>
+<paragraph role="tablecontent" id="par_id3155551" xml-lang="en-US" 
l10n="U">1</paragraph>
+</tablecell>
+<tablecell>
+<paragraph role="tablecontent" id="par_id3155552" xml-lang="en-US" 
l10n="U">#NULL!</paragraph>
+</tablecell>
+</tablerow>
+<tablerow>
+<tablecell>
+<paragraph role="tablecontent" id="par_id3155553" xml-lang="en-US" 
l10n="U">2</paragraph>
+</tablecell>
+<tablecell>
+<paragraph role="tablecontent" id="par_id3155554" xml-lang="en-US" 
l10n="U">#DIV/0!</paragraph>
+</tablecell>
+</tablerow>
+<tablerow>
+<tablecell>
+<paragraph role="tablecontent" id="par_id3155555" xml-lang="en-US" 
l10n="U">3</paragraph>
+</tablecell>
+<tablecell>
+<paragraph role="tablecontent" id="par_id3155556" xml-lang="en-US" 
l10n="U">#VALUE!</paragraph>
+</tablecell>
+</tablerow>
+<tablerow>
+<tablecell>
+<paragraph role="tablecontent" id="par_id3155557" xml-lang="en-US" 
l10n="U">4</paragraph>
+</tablecell>
+<tablecell>
+<paragraph role="tablecontent" id="par_id3155558" xml-lang="en-US" 
l10n="U">#REF!</paragraph>
+</tablecell>
+</tablerow>
+<tablerow>
+<tablecell>
+<paragraph role="tablecontent" id="par_id3155559" xml-lang="en-US" 
l10n="U">5</paragraph>
+</tablecell>
+<tablecell>
+<paragraph role="tablecontent" id="par_id3155560" xml-lang="en-US" 
l10n="U">#NAME?</paragraph>
+</tablecell>
+</tablerow>
+<tablerow>
+<tablecell>
+<paragraph role="tablecontent" id="par_id3155561" xml-lang="en-US" 
l10n="U">6</paragraph>
+</tablecell>
+<tablecell>
+<paragraph role="tablecontent" id="par_id3155562" xml-lang="en-US" 
l10n="U">#NUM!</paragraph>
+</tablecell>
+</tablerow>
+<tablerow>
+<tablecell>
+<paragraph role="tablecontent" id="par_id3155563" xml-lang="en-US" 
l10n="U">7</paragraph>
+</tablecell>
+<tablecell>
+<paragraph role="tablecontent" id="par_id3155564" xml-lang="en-US" 
l10n="U">#N/A</paragraph>
+</tablecell>
+</tablerow>
+</table>
+<paragraph role="paragraph" id="par_id3155565" xml-lang="en-US" l10n="U">If 
<emph>Reference</emph> is not an error value, the function returns the #N/A 
error.</paragraph>
+<paragraph role="heading" id="hd_id3155566" xml-lang="en-US" level="3" 
l10n="U">Examples</paragraph>
+<paragraph role="paragraph" id="par_id3155567" xml-lang="en-US" l10n="U"><item 
type="input">=ERROR.TYPE(1/0)</item> returns 2.</paragraph>
+<paragraph role="paragraph" id="par_id3155568" xml-lang="en-US" l10n="U"><item 
type="input">=ERROR.TYPE(#VALUE!)</item> returns 3.</paragraph>
+</body>
+</helpdocument>
diff --git a/main/helpcontent2/source/text/scalc/01/makefile.mk 
b/main/helpcontent2/source/text/scalc/01/makefile.mk
index de6b7b598f..604c2117d4 100644
--- a/main/helpcontent2/source/text/scalc/01/makefile.mk
+++ b/main/helpcontent2/source/text/scalc/01/makefile.mk
@@ -205,6 +205,7 @@ XHPFILES = \
    func_eastersunday.xhp \
    func_edate.xhp \
    func_eomonth.xhp \
+   func_errortype.xhp \
    func_hour.xhp \
    func_iferror.xhp \
    func_ifna.xhp \
diff --git a/main/sc/source/core/tool/interpr1.cxx 
b/main/sc/source/core/tool/interpr1.cxx
index 47e396f4dd..0f9ad8cd41 100644
--- a/main/sc/source/core/tool/interpr1.cxx
+++ b/main/sc/source/core/tool/interpr1.cxx
@@ -8571,6 +8571,29 @@ void ScInterpreter::ScConcat()
 }
 
 
+static sal_uInt16 MapErrorType( sal_uInt16 nInternalErr )
+{
+    switch ( nInternalErr )
+    {
+        case errNoCode:              // 521 → #NULL!
+            return 1;
+        case errDivisionByZero:      // 532 → #DIV/0!
+            return 2;
+        case errNoValue:             // 519 → #VALUE!
+            return 3;
+        case errNoRef:               // 524 → #REF!
+            return 4;
+        case errNoName:              // 525 → #NAME?
+            return 5;
+        case errIllegalFPOperation:  // 503 → #NUM!
+            return 6;
+        case NOTAVAILABLE:           // 0x7fff → #N/A
+            return 7;
+        default:
+            return 0; // Unknown error type → will produce #N/A error
+    }
+}
+
 void ScInterpreter::ScErrorType()
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", 
"ScInterpreter::ScErrorType" );
@@ -8640,10 +8663,11 @@ void ScInterpreter::ScErrorType()
             PopError();
             nErr = nGlobalError;
     }
-    if ( nErr )
+    sal_uInt16 nErrorType = MapErrorType( nErr );
+    if ( nErrorType )
     {
         nGlobalError = 0;
-        PushDouble( nErr );
+        PushDouble( nErrorType );
     }
     else
     {
diff --git a/test/odf-validate/calcval-cases14.tsv 
b/test/odf-validate/calcval-cases14.tsv
index 07794bcf59..f8a62f1fdd 100644
--- a/test/odf-validate/calcval-cases14.tsv
+++ b/test/odf-validate/calcval-cases14.tsv
@@ -340,3 +340,15 @@ SG.DATEDIF-038-multi-year  
=DATEDIF(DATE(2020;6;15);DATE(2024;8;20);"y")   cell    4       6
 SG.DATEDIF-039-multi-year-m    =DATEDIF(DATE(2020;6;15);DATE(2024;8;20);"m")   
cell    50      6.10.3 complete months over multi-year span
 SG.DATEDIF-040-multi-year-ym   =DATEDIF(DATE(2020;6;15);DATE(2024;8;20);"ym")  
cell    2       6.10.3 months ignoring years over multi-year span
 SG.DATEDIF-041-case-format     =DATEDIF(DATE(2024;1;1);DATE(2024;12;31);"D")   
cell    #ERR    6.10.3 format string is case-sensitive
+SG.ERRTYPE-01-div0     =ERROR.TYPE(1/0)        cell    2       6.13.x 
ERROR.TYPE of #DIV/0!
+SG.ERRTYPE-02-value    =ERROR.TYPE(#VALUE!)    cell    3       6.13.x 
ERROR.TYPE of #VALUE!
+SG.ERRTYPE-03-ref      =ERROR.TYPE(#REF!)      cell    4       6.13.x 
ERROR.TYPE of #REF!
+SG.ERRTYPE-04-name     =ERROR.TYPE(#NAME?)     cell    5       6.13.x 
ERROR.TYPE of #NAME?
+SG.ERRTYPE-05-num      =ERROR.TYPE(#NUM!)      cell    6       6.13.x 
ERROR.TYPE of #NUM!
+SG.ERRTYPE-06-na       =ERROR.TYPE(#N/A)       cell    7       6.13.x 
ERROR.TYPE of #N/A
+SG.ERRTYPE-07-null     =ERROR.TYPE(IF(FALSE();A1;B1))  cell    1       6.13.x 
ERROR.TYPE of #NULL! (empty intersection)
+SG.ERRTYPE-08-no-error =ERROR.TYPE(5)  cell    #N/A    6.13.x ERROR.TYPE of 
non-error returns #N/A
+SG.ERRTYPE-09-ref-error        =ERROR.TYPE(A1) cell    2       6.13.x 
ERROR.TYPE of cell with #DIV/0! (needs A1=1/0 setup)
+SG.ERRTYPE-10-multi-ref        =ERROR.TYPE(A1:B2)      cell    #N/A    6.13.x 
ERROR.TYPE of multi-ref returns #N/A (not error value)
+SG.ERRTYPE-11-wrong-args       =ERROR.TYPE()   cell    #ERR    6.13.x 
ERROR.TYPE wrong arg count
+SG.ERRTYPE-12-odf-name =ERROR.TYPE(ORG.OPENOFFICE.ERRORTYPE(1/0))      cell    
2       6.13.x ERROR.TYPE with ODF namespace name

Reply via email to