Files
DoLuEdu-WordFileParse/java-src/utils/NumPr.java
Quentin 3271fee5cc init: WordFileParse docx→HTML 解析服务(含 Word EQ 域公式修复)
服务:Spring Boot 3.2 + docx4j 8.3.9,POST /api/v3/server_office_file/file/parse
      接受 .docx,返回 HTML(公式 → LaTeX,图片 → RustFS 外链)

公式支持三类来源:
- OMML(Word 2007+ 公式)      → Python omml_mathml2latex
- MathType OLE 对象            → Ruby mathtype2mathml → MathML → LaTeX
- Word EQ 域(老教辅主力)      → EqToLatexUtil(本次新增)

本次改动:
1. 新增 java-svc/.../core/EqToLatexUtil.java:
   移植自 jby backend-services office-core,EQ 语法 → LaTeX
   (\f→\dfrac、\r→\sqrt、\i→\int/\sum/\prod、\s→^{}/_{}、\b→\left\right、
     \a→array、\x→\boxed/\overline、\o\al 堆叠、圈码、化学符号、极限、连等式)
   品牌标记 JBYU* → WPU*,与采集端一致
2. CtoMathFinder:接上 EQ 分支(原为 not-ported 桩),域代码经
   EqToLatexUtil.convert 转 LaTeX 写入 eqLatexMap(WPEQNUM 占位符)
3. WordParseUtil.dealPlaceholder:EQ 的 LaTeX 同样加 \( \) 包裹
   (原先因 WPEQNUM 例外不加包裹,前端/MathJax 不渲染)

修前症状:教辅 Word 里分式/方程组/上下标整段丢失(如 {−1/3, 1} 变成 {-,1})
修后实测:46 份教辅 2908 处 EQ 域全部还原,公式总数 2954 处、零未包裹残留

安全:application.yml(含 RustFS 密钥)不入库,提供 application.yml.example;
      OssService 的 @Value 默认密钥已清空
2026-09-29 09:43:13 +08:00

110 lines
3.1 KiB
Java

/*
* Decompiled with CFR 0.152.
*/
package com.jby.officecore.utils;
import java.math.BigInteger;
public class NumPr {
private BigInteger start;
private BigInteger current;
private String numFmt;
private String lvlText;
public NumPr() {
}
public NumPr(BigInteger start, BigInteger current, String numFmt, String lvlText) {
this.start = start;
this.current = current;
this.numFmt = numFmt;
this.lvlText = lvlText;
}
public BigInteger getStart() {
return this.start;
}
public BigInteger getCurrent() {
return this.current;
}
public String getNumFmt() {
return this.numFmt;
}
public String getLvlText() {
return this.lvlText;
}
public void setStart(BigInteger start) {
this.start = start;
}
public void setCurrent(BigInteger current) {
this.current = current;
}
public void setNumFmt(String numFmt) {
this.numFmt = numFmt;
}
public void setLvlText(String lvlText) {
this.lvlText = lvlText;
}
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof NumPr)) {
return false;
}
NumPr other = (NumPr)o;
if (!other.canEqual(this)) {
return false;
}
BigInteger this$start = this.getStart();
BigInteger other$start = other.getStart();
if (this$start == null ? other$start != null : !((Object)this$start).equals(other$start)) {
return false;
}
BigInteger this$current = this.getCurrent();
BigInteger other$current = other.getCurrent();
if (this$current == null ? other$current != null : !((Object)this$current).equals(other$current)) {
return false;
}
String this$numFmt = this.getNumFmt();
String other$numFmt = other.getNumFmt();
if (this$numFmt == null ? other$numFmt != null : !this$numFmt.equals(other$numFmt)) {
return false;
}
String this$lvlText = this.getLvlText();
String other$lvlText = other.getLvlText();
return !(this$lvlText == null ? other$lvlText != null : !this$lvlText.equals(other$lvlText));
}
protected boolean canEqual(Object other) {
return other instanceof NumPr;
}
public int hashCode() {
int PRIME = 59;
int result = 1;
BigInteger $start = this.getStart();
result = result * 59 + ($start == null ? 43 : ((Object)$start).hashCode());
BigInteger $current = this.getCurrent();
result = result * 59 + ($current == null ? 43 : ((Object)$current).hashCode());
String $numFmt = this.getNumFmt();
result = result * 59 + ($numFmt == null ? 43 : $numFmt.hashCode());
String $lvlText = this.getLvlText();
result = result * 59 + ($lvlText == null ? 43 : $lvlText.hashCode());
return result;
}
public String toString() {
return "NumPr(start=" + this.getStart() + ", current=" + this.getCurrent() + ", numFmt=" + this.getNumFmt() + ", lvlText=" + this.getLvlText() + ")";
}
}