This commit is contained in:
csh 2023-09-22 09:15:38 +08:00
parent 5f1064794d
commit db71b8cd2c
5 changed files with 82 additions and 45 deletions

View File

@ -1,4 +1,4 @@
// Version 1.4.6 // Version 1.4.7
Function TOfficeObj(n); Function TOfficeObj(n);
Begin Begin
@ -13922,25 +13922,21 @@ Type TDocumentBody = Class(DocObject)
p := new TParagraph(pNode); p := new TParagraph(pNode);
//统计数字项目编号 //统计数字项目编号
numArr := array(); numArr := array();
ilvl := -1; numId := getNumPr('numId', docx, p);
numId := ''; ilvl := getNumPr('Level', docx, p);
if not ilvl then ilvl := 0;
if ifarray(numIds) then Begin if ifarray(numIds) then Begin
sectPr.Append(p); sectPr.Append(p);
numId := p.Format.NumPr.Value('numId'); if ilvl >= 0 and ilvl < 10 then Begin
lvlStr := p.Format.NumPr.Value('Level'); if not istable(numIds[numId]) then
if not ifnil(numId) and not ifnil(lvlStr) then Begin numIds[numId] := array(0,0,0,0,0,0,0,0,0,0);
ilvl := Class(TSXml).SafeStrToIntDef(lvlStr, -1); prev := numIds[numId, ilvl];
if ilvl >= 0 and ilvl < 10 then Begin if prev then Begin
if not istable(numIds[numId]) then for i:=ilvl+1 to 9 do
numIds[numId] := array(0,0,0,0,0,0,0,0,0,0); numIds[numId, i] := 0;
prev := numIds[numId, ilvl];
if prev then Begin
for i:=ilvl+1 to 9 do
numIds[numId, i] := 0;
End;
numIds[numId, ilvl]++;
numArr := numIds[numId];
End; End;
numIds[numId, ilvl]++;
numArr := numIds[numId];
End; End;
End; End;
if bHeadList then Begin //统计大纲显示(目录) if bHeadList then Begin //统计大纲显示(目录)
@ -13948,7 +13944,7 @@ Type TDocumentBody = Class(DocObject)
if styleId <> '' then Begin if styleId <> '' then Begin
obj := docx.StyleObject().GetStyleById(styleId); obj := docx.StyleObject().GetStyleById(styleId);
if ifObj(obj) then Begin if ifObj(obj) then Begin
level := obj.HeadingLevel(); level := getHeadingLevel(docx, obj);
iLevel := Class(TSXml).SafeStrToIntDef(level, -1); iLevel := Class(TSXml).SafeStrToIntDef(level, -1);
if p.Text() <> "" and iLevel+1 >= UpperHeadingLevel and iLevel+1 <= LowerHeadingLevel then Begin if p.Text() <> "" and iLevel+1 >= UpperHeadingLevel and iLevel+1 <= LowerHeadingLevel then Begin
r[ind]['Level'] := strtoint(level); r[ind]['Level'] := strtoint(level);
@ -13989,6 +13985,40 @@ Type TDocumentBody = Class(DocObject)
return r; return r;
End; End;
Function getNumPr(field, docx, p);
Begin
value := p.Format.NumPr.Value(field);
if value then return value;
styleId := p.Format.Value('StyleId', 1);
return getFieldByStyle(field, docx, docx.StyleObject().GetStyleById(styleid));
End;
Function getFieldByStyle(field, docx, obj);
Begin
if not ifObj(obj) then return '';
numId := obj.pPr.numPr.Value(field);
if numId = '' then
begin
id := o.Value('BasedOn');
return getNumIdByStyle(docx, docx.StyleObject().GetStyleById(id));
end
return numId;
End;
Function getHeadingLevel(docx, obj);
Begin
if not ifObj(obj) then return '';
o := obj;
level := obj.HeadingLevel();
if level = '' then
begin
id := o.Value('BasedOn');
return getHeadingLevel(docx, docx.StyleObject().GetStyleById(id));
end
return level;
End;
Function getPictureMaxId(); Function getPictureMaxId();
Begin Begin
id := 0; id := 0;

View File

@ -1,4 +1,4 @@
// Version 1.4.6 // Version 1.4.7
Type TSDocxFile = Class Type TSDocxFile = Class
///Version: V1.0 2022-09-20 ///Version: V1.0 2022-09-20

View File

@ -1,4 +1,4 @@
// Version 1.4.6 // Version 1.4.7
Type TSExcelFile = Class Type TSExcelFile = Class
///Version: V1.0 2022-08-08 ///Version: V1.0 2022-08-08

View File

@ -162,7 +162,7 @@ Type TTableContent = class
End End
if numStr <> '' then run_t := numStr + ' ' + r[i]['Text']; if numStr <> '' then run_t := numStr + ' ' + r[i]['Text'];
else run_t := r[i]['Text']; else run_t := r[i]['Text'];
r1.SetText(run_t); r1.SetText(run_t, 1);
r2 := h.AddRun(); r2 := h.AddRun();
r2.rPr.noProof := true; r2.rPr.noProof := true;
@ -203,7 +203,6 @@ Type TTableContent = class
r8.fldCharType := 'end'; r8.fldCharType := 'end';
_AddStdContent(p); _AddStdContent(p);
End; End;
p2 := TOfficeObj('TParagraph'); p2 := TOfficeObj('TParagraph');

View File

@ -1,5 +1,13 @@
# 更新日志 # 更新日志
## 2023-9-22
### V1.4.7
#### word
1. 修复项目符号属于样式时,生成目录无法识别出项目符号问题
## 2023-9-19 ## 2023-9-19
### V1.4.6 ### V1.4.6