This commit is contained in:
csh 2023-09-22 09:42:31 +08:00
parent 5f1064794d
commit d72d88d68a
5 changed files with 110 additions and 74 deletions

View File

@ -1,4 +1,4 @@
// Version 1.4.6
// Version 1.4.7
Function TOfficeObj(n);
Begin
@ -13922,14 +13922,11 @@ Type TDocumentBody = Class(DocObject)
p := new TParagraph(pNode);
//统计数字项目编号
numArr := array();
ilvl := -1;
numId := '';
numId := getNumPr('numId', docx, p);
ilvl := getNumPr('Level', docx, p);
if not ilvl then ilvl := 0;
if ifarray(numIds) then Begin
sectPr.Append(p);
numId := p.Format.NumPr.Value('numId');
lvlStr := p.Format.NumPr.Value('Level');
if not ifnil(numId) and not ifnil(lvlStr) then Begin
ilvl := Class(TSXml).SafeStrToIntDef(lvlStr, -1);
if ilvl >= 0 and ilvl < 10 then Begin
if not istable(numIds[numId]) then
numIds[numId] := array(0,0,0,0,0,0,0,0,0,0);
@ -13942,13 +13939,12 @@ Type TDocumentBody = Class(DocObject)
numArr := numIds[numId];
End;
End;
End;
if bHeadList then Begin //统计大纲显示(目录)
styleId := p.Format.Value('StyleId', 1);
if styleId <> '' then Begin
obj := docx.StyleObject().GetStyleById(styleId);
if ifObj(obj) then Begin
level := obj.HeadingLevel();
level := getHeadingLevel(docx, obj);
iLevel := Class(TSXml).SafeStrToIntDef(level, -1);
if p.Text() <> "" and iLevel+1 >= UpperHeadingLevel and iLevel+1 <= LowerHeadingLevel then Begin
r[ind]['Level'] := strtoint(level);
@ -13989,6 +13985,40 @@ Type TDocumentBody = Class(DocObject)
return r;
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();
Begin
id := 0;
@ -15314,4 +15344,3 @@ Begin
return true;
return false;
End;

View File

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

View File

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

View File

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

View File

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