Branch: openformula Starting commit: 6a2f742073 (CONVERT atm/Torr fix) PR #523 merge: 1354dfcdad Audit type: Read-only source inspection (no build, no runtime execution)
This document records source-level findings for 15 Calc functions. All file paths and line numbers are relative to the repository root (/home/pedro/projects/aoo).
Updated 2026-11-18 to match the code after the post-merge review. Line numbers are those of the 2026-11-18 working tree. “Run” means the working tree was built on macOS and Linux and the case was run; “Excel 16” means it was also compared with Excel. Sections 6, 12 and 15 were only re-read.
ODF 1.4: Defined (§6.7.2 in ODF 1.2 and 1.4: “The same as FIND, but using byte positions”). Byte positions are implementation-dependent. ODF group: not checked.
A. Function registration
case ocFindB : ScFindB(); at interpr4.cxx:3774.B. Actual implementation: ScInterpreter::ScFindB() at interpr1.cxx:8260. Implements case-sensitive byte-oriented search using DBCS byte semantics (1 byte for ASCII/non-DBCS, 2 bytes for DBCS characters per IsDBCS()). Uses lcl_BytePosToCharIndex() and lcl_CharIndexToBytePos() helpers to convert between byte positions (1-based) and character indices (0-based). Returns byte position of match, or #VALUE! (PushNoValue) if not found or start invalid. Until 2026-11-18 the two text arguments were popped in the wrong order, so FINDB(“b”;“abc”) searched “b” for “abc”.
C. Format compatibility: XLS read and written as BIFF 205; an AOO xls opens in Excel 16 with the value (run). XLSX read (run, hand-made file). AOO has no xlsx export.
D. Documentation: Help topic func_findb.xhp, reachable through its help ID since helpcontent2/util/scalc/makefile.mk lists it (2026-11-18). Function Wizard entry exists in main/sc/source/ui/src/scfuncs.src (SC_OPCODE_FINDB resource block with parameter names and descriptions).
Failure type: None. Priority: Resolved (was P1). Confidence: HIGH — run; ASCII cases match Excel 16 (Excel counts CJK as 1 byte unless a DBCS language is set; AOO always 2).
ODF 1.4: Defined (§6.7.6: “As REPLACE, but using byte positions”). ODF group: not checked.
A. Function registration
case ocReplaceB : ScReplaceB(); at interpr4.cxx:3776.B. Actual implementation: ScInterpreter::ScReplaceB() at interpr1.cxx:8355. Implements byte-oriented replacement using DBCS byte semantics. Converts start byte position to character index, counts bytes forward to determine character count to erase (avoiding splitting DBCS characters), then Erase/Insert like ScReplace(). Clamps start position to string length + 1 (append at end) and clamps count to available bytes. Returns PushIllegalArgument() for invalid inputs.
C. Format compatibility: XLS read and written as BIFF 207 (source). XLSX read (run).
D. Documentation: Help topic func_replaceb.xhp (help ID resolves since 2026-11-18). Function Wizard entry exists in scfuncs.src.
Failure type: None. Priority: Resolved (was P1). Confidence: HIGH — run; ASCII cases match Excel 16.
ODF 1.4: Defined (§6.7.8: “As SEARCH, but using byte positions”). ODF group: not checked.
A. Function registration
case ocSearchB : ScSearchB(); at interpr4.cxx:3775.B. Actual implementation: ScInterpreter::ScSearchB() at interpr1.cxx:8302. Implements case-insensitive byte-oriented search using DBCS byte semantics, following the same pattern as ScSearch() (utl::TextSearch with case-insensitive flag; regular expressions when enabled, no ? or * wildcards). Converts byte positions to/from character indices using lcl_BytePosToCharIndex() and lcl_CharIndexToBytePos(). Returns byte position of match, or #VALUE! (PushNoValue) if not found or start invalid. The text arguments were popped in the wrong order until 2026-11-18, as in FINDB.
C. Format compatibility: XLS read and written as BIFF 206 (source). XLSX read (run).
D. Documentation: Help topic func_searchb.xhp (the wildcard claim and its example were removed 2026-11-18). Function Wizard entry exists in scfuncs.src.
Failure type: None. Priority: Resolved (was P1). Confidence: HIGH — run; ASCII cases match Excel 16.
ODF 1.4: Defined by ODF 1.4 Part 4, Section 6.10.3. ODF group: Large Group (Excel compatibility function; not rechecked).
A. Function registration
case ocDateDif : ScDateDif(); at interpr4.cxx:3777.B. Actual implementation: ScInterpreter::ScDateDif() at interpr2.cxx:461. Implements ODF 1.4 §6.10.3 with all six formats (y, m, d, md, ym, yd). Since 2026-11-18 (Jim's decision) it follows Excel where ODF is silent: start after end is an error, the format ignores case, “md” borrows the month before the end month and “yd” moves the end date into the start year. The H.3 version negated reverse intervals, was case-sensitive and computed “yd” wrongly. Detailed algorithm in audit/openformula-function-gaps/datedif-semantic-design.md.
C. Format compatibility
D. Documentation: Help topic func_datedif.xhp (rewritten 2026-11-18). Function Wizard entry exists in main/sc/source/ui/src/scfuncs.src.
Failure type: None. One Excel difference (“yd” from Feb 29, 2020 to Mar 1, 2023). Priority: Resolved (was P1). Confidence: HIGH — run; 630 cases compared with Excel 16.
ODF 1.4: Defined (ODF 1.2 §6.10.11, ODF 1.4 §6.10.12): one argument, ISO 8601 week. No Mode parameter in either version. ODF group: not checked.
A. Function registration
_xlfn.ISOWEEKNUM in saFuncTable_Oox (xlformula.cxx lines 385-386), added 2026-11-18. WEEKNUM keeps the _xlfnodf.ISOWEEKNUM entry (line 422).B. Actual implementation: ISO 8601 (Monday start, week 1 holds the first Thursday). The Function Wizard resource had one ExtraData number too many; fixed 2026-11-18.
C. Format compatibility
_xlfn.ISOWEEKNUM and read back; Excel 16 calculates it (run)._xlfn.ISOWEEKNUM is read (run, 2026-11-18).D. Documentation: func_isoweeknum.xhp, embedded in 04060102.xhp; help ID resolves since 2026-11-18.
Failure type: None (xlsx import gap above). Priority: Resolved (was P1). Confidence: HIGH — run; 300 dates compared with Excel 16.
ODF 1.4: Not defined by ODF 1.4 Part 4 (not rechecked). Excel-specific / application-level. ODF group: Not applicable.
A. Function registration
B. Actual implementation: ScDde() (interpr2.cxx:2247) creates or finds an ScDdeLink via sfx2::LinkManager. Requires a document shell with a LinkManager (fails with PushNoValue() for temporary documents without DocShell). Sets recalc mode on load. Disables idle during evaluation. DDE is platform-dependent (implemented via sfx2/source/appl/impldde.cxx, appdde.cxx). DDE links can be created new (not just opening existing links). Updates are driven by the DDE link mechanism, not automatic per-recalc. External application failures are handled via error codes. Security: no user confirmation visible in source; DDE is disabled in server mode (appdde.cxx:494, 526: “Im Serverbetrieb ist DDE abgeklemmt!”).
C. Format compatibility: DDE is not a file-format function per se; no XLS/XLSX import/export mapping for the DDE function itself. DDE links (external references) are handled separately in Excel filters (xilink.cxx, xelink.cxx, xehelper.cxx).
D. Documentation: HID_FUNC_DDE help entry exists.
Failure type: Platform-dependent application-level feature. Not a pure formula function; requires DDE subsystem availability. Priority: DEFER — requires DDE service platform support; security and platform-appropriateness questions unresolved. Confidence: HIGH — source evidence clear; implementation exists but is platform-dependent.
ODF 1.4: Defined (§6.12.31 in ODF 1.2 and 1.4). The spec gives no formula. ODF group: not checked.
A. Function registration
B. Actual implementation: on trunk GetOddfprice() threw (THROW_RTE, #87380#). 8ce50c3485 (message “No production code changes”) brought in an unfinished version: the long-period terms were multiplied by 0 and a placeholder line did not compile. Jim chose to finish it; the 2026-11-18 version:
C. Format compatibility: AddIn function; not part of BIFF/OOXML function tables. Import/export via AddIn mechanism only.
D. Documentation: Help entry exists (AAI = Analysis AddIn).
Failure type: RESOLVED 2026-11-18 (was: throws unconditionally on trunk). 4524 random ODDFPRICE/ODDFYIELD cases compared with Excel 16: 14 differences in 4 classes (DFC equal to E where Excel gives #NUM!: 4; annual 30/360 US bonds with Feb-end coupons, 2/360 of a coupon: 5; Excel‘s yield less exact: 4; Excel’s yield wrong: 1). Priority: P2 (native opcode deferred). Confidence: HIGH — run, Excel 16.
ODF 1.4: Defined (§6.12.32 in ODF 1.2 and 1.4). ODF group: not checked.
A. Function registration
B. Actual Implementation: 2026-11-18. The price falls as the yield rises, so GetOddfyield() brackets the yield (above -frequency) and narrows it with the Illinois variant of regula falsi, stopping when the price is within 1e-12 relative. No bracket or no convergence: #NUM!.
C. Format compatibility: AddIn only; no BIFF/OOXML table mapping.
D. Documentation: Help entry exists.
Failure type: RESOLVED 2026-11-18 (was: throws unconditionally on trunk). See ODDFPRICE for the Excel comparison; where the yields differ, AOO‘s reproduces the price within 1e-10 in Excel’s own ODDFPRICE, Excel's within 1.8e-7. Priority: P2 (native opcode deferred). Confidence: HIGH — run, Excel 16.
ODF 1.4: Defined (§6.12.44 in ODF 1.2 and 1.4; constraint N > 0). ODF group: not checked.
A. Function registration
_xlfnodf.RRI.B. Actual implementation: ScZGZ() computes pow(Fv/Pv, 1/N) - 1 and checks nothing; ODF requires N > 0. 8ce50c3485 reclassified the earlier validation concern as a test-data error. The formula itself is right: RRI(10;100;200) = 0.0717734625362931, as Excel 16.
C. Format compatibility
_xlfnodf.RRI; AOO reads it back, Excel shows #NAME? (run)._xlfn.RRI is read (run, 2026-11-18).D. Documentation: English help (04060118.xhp, unchanged from trunk).
Failure type: No N > 0 check; xls/xlsx naming. Priority: P3. Confidence: HIGH — run.
ODF 1.4: Defined (§6.13.11 in ODF 1.2 and 1.4). Not propagating; a non-error gives an error; #NULL!..#N/A are 1..7. ODF group: Verify against final spec (likely Large Group).
A. Function registration
B. Actual implementation: ScErrorType() examines the stack type:
=ERROR.TYPE() is an error (calcval row ERROR.TYPE.args, run). H.4 had changed ScErrorType() itself, so ERRORTYPE returned 1-7 and lost the internal codes its help documents (Err:518 gives 518); Jim's decision: separate function, ERRORTYPE as on trunk.C. Format compatibility: xls ERROR.TYPE reads as ERROR.TYPE; ERRORTYPE is written as ERROR.TYPE and comes back as ERROR.TYPE (run). xlsx ERROR.TYPE read (run).
D. Documentation: English topics for both functions.
Failure type: None. ERROR.TYPE(SQRT(-1)) is 3 in AOO (Err:502) and 6 in Excel. Priority: Resolved (was P1). Confidence: HIGH — run, Excel 16.
ODF 1.4: Defined (§6.13.28 in ODF 1.2 and 1.4). ODF group: Verify against final spec (likely Large Group).
A. Function registration
case ocNumberValue : ScNumberValue(); at interpr4.cxx:3558.B. Actual implementation: the ODF steps in order: group separators removed only before the first decimal separator, that separator turned into ‘.’, whitespace removed, trailing percent signs stripped (each divides by 100), and the rest must be a plain xsd:float without INF/NaN (lcl_IsPlainFloat(), interpr1.cxx:3072). LEN(DecimalSeparator) must be 1 and it must not occur in GroupSeparator; omitted separators come from the locale, and the locale group separator is dropped when it equals the given decimal separator. The H.1 version removed group separators everywhere and replaced every decimal separator.
C. Format compatibility
_xlfnodf.NUMBERVALUE; AOO reads it back, Excel shows #NAME? (run)._xlfn.NUMBERVALUE is read (run, 2026-11-18).D. Documentation: func_numbervalue.xhp (rules added 2026-11-18).
Failure type: None. Differences from Excel 16 on purpose: empty text is an error (Excel 0), an empty GroupSeparator is accepted (Excel error), a two-character DecimalSeparator is an error (Excel uses the first). Priority: Resolved (was P1). Confidence: HIGH — run, Excel 16.
ODF 1.4: Not defined by ODF 1.4 Part 4. Excel-specific function. ODF group: Not applicable.
A. Function registration
B. Actual implementation: ScGetPivotData() parses target field name and field/item filter pairs, locates the DataPilot table via ScDPObject, calls GetPivotData(). Comment at interpr2.cxx:3035–3036 notes: “MS Excel docs claim to use the ‘most recent’ which is not exactly the same as what we do in ScDocument::GetDPAtBlock.” (not re-read 2026-11-18) The function depends entirely on the DataPilot subsystem (dptablecache.cxx:517 mentions GETPIVOTDATA disabling nested formula interpretation).
C. Format compatibility
D. Documentation: Help entry exists.
Failure type: Implementation present. DataPilot dependency makes it application-level. Priority: P3. Confidence: HIGH — source evidence clear; runtime unverified.
ODF 1.4: ODF FDIST (§6.18.22) is the left tail with optional Cumulative (default TRUE; 0 for x < 0; density error only at x = 0, r1 = 1). LEGACY.FDIST (§6.18.23) is the right tail, three arguments. ODF group: Not applicable.
A. Function registration
_xlfn.F.DIST; _xlfnodf.FDIST imports as FDIST (line 421). Help HID_FUNC_F_DIST_LEFT (helpids.h:689, hidother.src:285), F.DIST section in 04060182.xhp.B. History: H.8/H.8.1 changed ocFDist itself into the left tail (with a 4th argument popped after the others) and added ocLegacyFDist. That changed FDIST typed in every UI language, in macros and in .sxc files, and f4f3de4f92 then dropped the SC_OPCODE_LEGACY_F_* defines, so the branch did not build. Jim's decision: keep FDIST, add F.DIST. ScFDistLeft() computes the left tail with GetBetaDist() at r1x/(r1x+r2) and the density with GetBetaDistPDF().
C. Format compatibility
_xlfn.F.DIST, Excel calculates the 4-argument form (run); _xlfnodf.FDIST from an older xls reads as FDIST (run)._xlfn.F.DIST is read (run, 2026-11-18).D. Documentation: FDIST help as on trunk; F.DIST section added.
Failure type: None. Priority: Resolved. Confidence: HIGH — run; F.DIST and FDIST match Excel 16 on 300 and 263 random cases.
ODF 1.4: ODF FINV (§6.18.24) inverts FDIST (left tail); LEGACY.FINV (§6.18.25) inverts LEGACY.FDIST. ODF group: Not applicable.
A. Function registration
_xlfnodf.FINV (saFuncTable_Odf line 417). Help HID_FUNC_F_INV_LEFT, F.INV section in 04060182.xhp.B. Actual implementation: F.INV accepts 0 <= p < 1 (0 gives 0).
C. Format compatibility: as FDIST/F.DIST.
D. Documentation: FINV help as on trunk; F.INV section added.
Failure type: None. Priority: Resolved. Confidence: HIGH — run; FINV matches Excel 16 on 300 random cases, F.INV on 298 (the other two within 3e-10 at p = 0.999, r2 = 1).
ODF 1.4: Defined by ODF 1.4 Part 4 (statistical function). ODF group: Verify against final spec (likely Large Group).
A. Function registration
B. Actual implementation: ScHarMean() implements H = n / Σ(1/xᵢ) counting only positive values. Zero or negative values trigger errIllegalArgument. Text values and empty cells are skipped (handled by the switch's default case / HasCellValueData check). Error values propagate via nGlobalError.
C. Format compatibility: BIFF 320 and xlsx (source; not run).
D. Documentation: English help in 04060182.xhp.
Failure type: None found. Priority: P3. Confidence: HIGH — source.
compiler.hrc defines SC_OPCODE_LENB=400, SC_OPCODE_RIGHTB=401, SC_OPCODE_LEFTB=402, SC_OPCODE_MIDB=403, and since H.2 SC_OPCODE_FINDB=412, SC_OPCODE_SEARCHB=413, SC_OPCODE_REPLACEB=414. All seven map to Excel's BIFF IDs 205-211.