1<!-- 2 Licensed to the Apache Software Foundation (ASF) under one 3 or more contributor license agreements. See the NOTICE file 4 distributed with this work for additional information 5 regarding copyright ownership. The ASF licenses this file 6 to you under the Apache License, Version 2.0 (the 7 "License"); you may not use this file except in compliance 8 with the License. You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, 13 software distributed under the License is distributed on an 14 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 KIND, either express or implied. See the License for the 16 specific language governing permissions and limitations 17 under the License. 18--> 19 20# Apache OpenOffice — OpenFormula Milestone C Report 21 22## 1. Commit Information 23 24- Branch: `openformula` (rebased onto `trunk`) 25- Baseline commit: `fd13af33ac` (end of Milestone B.2) 26- Final commit: Milestone C changes (this commit) 27- Repository: <https://github.com/pgiffuni/openoffice> 28 29## 2. Source-Mining Findings 30 31### CONVERT Implementation Architecture 32 33The CONVERT function is implemented in the Analysis Add-in at 34`main/scaddins/source/analysis/analysishelper.cxx`. The architecture consists of: 35 36- **ConvertData** class: Represents a single unit with a name, conversion factor 37 (`fConst`, units per base unit), class (e.g. CDC_Pressure, CDC_Length), and 38 prefix support flag (`bPrefixSupport`). 39- **ConvertDataLinear** subclass: Handles temperature units with offset 40 (Celsius, Fahrenheit, etc.). 41- **ConvertDataList**: Maintains the registered unit table and performs 42 conversions via `ConvertDataList::Convert()`. 43- **GetMatchingLevel()**: Resolves unit names including prefix matching, 44 squared/cubed suffixes (`^2`, `^3`), and the `da`/`e` deca legacy forms. 45- **AnalysisAddIn::getConvert()**: Exposes CONVERT to the formula engine. 46 47### Key Design Observations 48 49- Conversion factors are stored as **units per base unit** (reciprocal of 50 base-units-per-unit). For pressure, base = Pascal; for length, base = Meter; 51 for area, base = m²; for volume, base = Liter. 52- Prefix exponents on squared/cubed units are multiplied by 2 or 3 53 (lines 2266-2273: "cm3" is 10⁻⁶ m³, not 10⁻² m³). 54- Binary prefixes (Table 26) are only accepted for CDC_Information class 55 (bit, byte). 56- `da` (two-char) is deca (+1), `d` (one-char) is deci (-1), `e` is legacy deca (+1). 57 58## 3. Unit-Table Comparison Against ODF 1.4 Table 24 59 60All units in ODF 1.4 Tables 24-26 were audited against the registered table. 61Categories: 62 63| Category | Count | Details | 64|----------|-------|---------| 65| Required symbols implemented correctly | Most | Pa, m, in, ft, yd, g, N, J, W, T, C, F, K, bit, byte, etc. | 66| Required symbols with corrected constants | 2 | `atm`, `Torr` (pressure constants were off) | 67| Required symbols with missing aliases | 4 | `picapt`, `pica`, `pica2`, `pica3` (Pica family) | 68| Required symbols missing entirely | 0 | All Table 24 required symbols present after fixes | 69| Prefix handling correct | Yes | All decimal prefixes (Table 25), all binary prefixes (Table 26) | 70| AOO/Excel extensions retained | Yes | All `***` marked extensions preserved | 71 72### Specific Unit Comparisons 73 74**Pressure (Table 24):** 75 76| Unit | ODF 1.4 Value | Before Fix | After Fix | Status | 77|------|--------------|------------|-----------|--------| 78| Pa | 1 Pa | 1.0 | 1.0 | Correct | 79| atm | 101325.1 Pa | 101324.996... Pa | 101325.1 Pa | Corrected | 80| at | deprecated | 101324.996... Pa | unchanged | Legacy retained | 81| SI_at | 98066.5 Pa | 98066.5 Pa | 98066.5 Pa | Already correct | 82| Torr | 101325/760 Pa | 133.32237... Pa | 133.322368... Pa | Corrected | 83 84**Pica family (Table 24):** 85 86| Unit | Definition | Before | After | 87|------|-----------|--------|-------| 88| Pica / picapt | 1/72 inch | Present (Pica only) | Present + picapt alias | 89| pica | 1/6 inch | Missing | Added | 90| Pica² / picapt² / Pica^2 / picapt^2 | (1/72 in)² | Present (Pica2) | Present + picapt2 alias | 91| pica² / pica^2 | (1/6 in)² | Missing | Added | 92| Pica³ / picapt³ / Pica^3 / picapt^3 | (1/72 in)³ | Present (Pica3) | Present + picapt3 alias | 93| pica³ / pica^3 | (1/6 in)³ | Missing | Added | 94 95## 4. Constants Changed and Their Derivation 96 97### Pressure (factors are units per Pascal) 98 99**atm:** ODF 1.4 defines 1 atm = 101325.1 Pa. 100 101- Factor = 1/101325.1 = 9.86922292699439618e-06 102- Before: 9.8692329999819300E-06 (corresponds to 101324.996... Pa) 103- Relative error before fix: ~1.0e-06 104 105**Torr:** ODF 1.4 defines 1 Torr = 101325/760 Pa. 106 107- Factor = 760/101325 = 7.50061682704169716e-03 108- Before: 7.5006380000000000E-03 109- Relative error before fix: ~2.8e-06 110 111**SI_at:** Already correct: 1/98066.5 = 1.01971621297792819e-05 112**at:** Preserved at legacy value (9.8692329999819300E-06, matches old atm). 113ODF 1.4 marks `at` as deprecated and historically ambiguous; AOO retains the 114standard-atmosphere interpretation for compatibility. 115 116### Pica family (factors are units per base unit) 117 118**Pica / picapt:** 1/72 inch = 0.0254/72 m. 119 120- Factor = 72/0.0254 = 2.83464566929133889e+03 per meter 121- Minor precision improvement from 2.8346456692913386E03. 122 123**Pica² / picapt²:** (1/72 in)² per m² = 8.03521607043214142e+06. 124**Pica³ / picapt³:** (1/72 in)³ per Liter = 2.27769904358706400e+07. 125 126**pica:** 1/6 inch = 0.0254/6 m. 127 128- Factor = 6/0.0254 = 2.36220472440944917e+02 per meter. 129 130**pica²:** (1/6 in)² per m² = 5.58001116002232156e+04. 131**pica³:** (1/6 in)³ per Liter = 1.31811287244621799e+04. 132 133## 5. Prefix Behavior Audited (Tables 25-26) 134 135**Decimal prefixes (Table 25):** All 20 prefixes (yocto through yotta) 136recognized with correct exponents. `da` = deca (+1), `d` = deci (-1), 137`e` = legacy deca (+1). No changes needed. 138 139**Binary prefixes (Table 26):** All 8 prefixes (kibi through yobi) 140recognized for CDC_Information class only (bit, byte). Rejected for other 141classes. No changes needed. 142 143**Squared/cubed prefix exponent multiplication:** Verified at lines 2266-2273. 144`cm3` → exponent ×3 (10⁻⁶ m³), `cm2` → exponent ×2 (10⁻⁴ m²). Correct. 145 146**Case sensitivity:** Unit name matching uses `equals()` which is case-sensitive. 147`ATM` ≠ `atm`. No changes needed. 148 149## 6. Tests Added to calcval-cases14.tsv 150 15121 new test cases added: 152 153**Pressure (1 case):** 154 155| ID | Formula | Expected | Purpose | 156|----|---------|----------|---------| 157| CONVERT.Torr | =CONVERT(1;"Torr";"Pa") | 133.32236842105263 | Torr = 101325/760 Pa exactly | 158 159**Pica family (15 cases):** 160 161| ID | Formula | Expected | Purpose | 162|----|---------|----------|---------| 163| CONVERT.Pica.in | =CONVERT(1;"Pica";"in") | 0.013888888888888888 | Pica point = 1/72 in | 164| CONVERT.picapt.in | =CONVERT(1;"picapt";"in") | 0.013888888888888888 | picapt alias = 1/72 in | 165| CONVERT.pica.in | =CONVERT(1;"pica";"in") | 0.16666666666666666 | Pica = 1/6 in | 166| CONVERT.Pica2.in2 | =CONVERT(1;"Pica2";"in2") | 0.00019290123456790123 | Square Pica point | 167| CONVERT.pica2.in2 | =CONVERT(1;"pica2";"in2") | 0.027777777777777776 | Square Pica | 168| CONVERT.Pica3.in3 | =CONVERT(1;"Pica3";"in3") | 0.0000026791838134430725 | Cubic Pica point | 169| CONVERT.pica3.in3 | =CONVERT(1;"pica3";"in3") | 0.004629629629629629 | Cubic Pica | 170| CONVERT.picapt2.in2 | =CONVERT(1;"picapt2";"in2") | 0.00019290123456790123 | picapt2 alias = square Pica point | 171| CONVERT.picapt3.in3 | =CONVERT(1;"picapt3";"in3") | 0.0000026791838134430725 | picapt3 alias = cubic Pica point | 172| CONVERT.Pica^2.in2 | =CONVERT(1;"Pica^2";"in2") | 0.00019290123456790123 | caret exponent spelling Pica^2 | 173| CONVERT.picapt^2.in2 | =CONVERT(1;"picapt^2";"in2") | 0.00019290123456790123 | caret exponent spelling picapt^2 | 174| CONVERT.pica^2.in2 | =CONVERT(1;"pica^2";"in2") | 0.027777777777777776 | caret exponent spelling pica^2 | 175| CONVERT.Pica^3.in3 | =CONVERT(1;"Pica^3";"in3") | 0.0000026791838134430725 | caret exponent spelling Pica^3 | 176| CONVERT.picapt^3.in3 | =CONVERT(1;"picapt^3";"in3") | 0.0000026791838134430725 | caret exponent spelling picapt^3 | 177| CONVERT.pica^3.in3 | =CONVERT(1;"pica^3";"in3") | 0.004629629629629629 | caret exponent spelling pica^3 | 178 179**Prefixes (3 cases):** 180 181| ID | Formula | Expected | Purpose | 182|----|---------|----------|---------| 183| CONVERT.km.m | =CONVERT(1;"km";"m") | 1000 | Decimal prefix | 184| CONVERT.cm2.m2 | =CONVERT(1;"cm2";"m2") | 0.0001 | Centi on squared unit | 185| CONVERT.Kibyte.bit | =CONVERT(1;"Kibyte";"bit") | 8192 | Binary prefix | 186 187**Invalid conversions (2 cases):** 188 189| ID | Formula | Expected | Purpose | 190|----|---------|----------|---------| 191| CONVERT.km.Pa | =CONVERT(1;"km";"Pa") | #ERR | Different unit groups | 192| CONVERT.ATM.Pa | =CONVERT(1;"ATM";"Pa") | #ERR | Case-sensitive unit names | 193 194## 7. Static Checks Performed 195 196- Brace balance: 0 for analysishelper.cxx 197- All fConst values verified by independent Python computation 198- Pica point factor matches existing value within precision improvement 199- Pica²/Pica³ factors match existing values within precision improvement 200- atm/Torr corrections use exact ODF 1.4 definitions (101325.1 Pa, 101325/760 Pa) 201- Pica/pica factors derived from exact inch definition (0.0254 m, exact) 202- Test expected values independently calculated from unit definitions 203 204## 8. Build and Test Status 205 206**No build or runtime tests were executed.** Per milestone instructions: 207 208- The AOO `sc` and `scaddins` modules are not configured for build in this 209 environment (no `Module_*.mk` makefiles, no generated build tree). 210- `dmake` cannot build without the gbuild configure step. 211- The calcval test harness requires a built office and runs on macOS. 212 213**For validation in a configured AOO build environment:** 214 2151. Configure AOO (`autogen.sh`/`configure`, then `build.pl --all`) 2162. Build the `scaddins` module (Analysis Add-in) 2173. Run `test/odf-validate/start.sh calcval <port>` and 218 `test/odf-validate/runpy.sh calcval.py <port> calcval-cases14.tsv <out.json>` 219 on macOS, then `python3 -I calcval.py --compare ...` 220 221## 9. Milestone B Report Correction 222 223The B.2 section of the Milestone B report previously stated that B.2 added six 224test cases. B.2 actually added four cases relative to B.1: 225 226- IFNA.ref.text, IFNA.range, SKEW.text, SKEW.err (4 cases, not 6). 227The B.1 baseline had IFNA.ref and SKEWP.two (2 cases). 228 229## 10. Remaining Known Deviations 230 231- **Build/runtime validation deferred:** No execution of the new CONVERT tests 232 against a built office was possible in this environment. 233- **`at` deprecated unit:** Retained at legacy standard-atmosphere value 234 (9.8692329999819300E-06 units/Pa) for Excel compatibility. ODF 1.4 marks it 235 as deprecated/ambiguous; no redefinition was made. 236- **Pica precision:** Pica point factor updated from 2.8346456692913386E03 to 237 2.83464566929133889E03 (full double precision of 72/0.0254). This is a 238 precision improvement, not a semantic change. 239 240## 11. Normative vs Implementation Choices 241 242| Aspect | ODF 1.4 Normative | AOO Implementation | 243|--------|-------------------|-------------------| 244| atm = 101325.1 Pa | Mandatory | Corrected to match | 245| Torr = 101325/760 Pa | Mandatory | Corrected to match | 246| SI_at = 98066.5 Pa | Mandatory | Already matched | 247| at = deprecated | Optional/legacy | Retained at standard-atmosphere value | 248| Pica/picapt = 1/72 in | Mandatory | Implemented | 249| pica = 1/6 in | Mandatory | Implemented | 250| Pica²/pica² etc. | Mandatory | Implemented | 251| Decimal prefixes | Mandatory | Implemented | 252| Binary prefixes on bit/byte | Mandatory | Implemented | 253| Case-sensitive unit names | Mandatory | Implemented | 254| Extension units (`***`) | Not specified | Retained for compatibility | 255