v1.4.8-patch1

This commit is contained in:
csh 2023-09-28 16:22:33 +08:00
parent 9c917cfb70
commit 8cd87118d5
3 changed files with 37 additions and 39 deletions

View File

@ -13921,7 +13921,7 @@ Type TDocumentBody = Class(DocObject)
return array(length(errArr), tslTagCount, errArr); return array(length(errArr), tslTagCount, errArr);
End; End;
Function GetHeadingListImpl(docx, posOpt, UpperHeadingLevel, LowerHeadingLevel, numIds, bHeadList); Function GetHeadingListImpl(docx, posOpt, UpperHeadingLevel, LowerHeadingLevel, numIds);
Begin Begin
r := array(); r := array();
if ifObj(posOpt) then if ifObj(posOpt) then
@ -13933,45 +13933,43 @@ Type TDocumentBody = Class(DocObject)
if name = 'w:p' and not ifObj(pNode.FirstChildElement('w:sectPr')) then if name = 'w:p' and not ifObj(pNode.FirstChildElement('w:sectPr')) then
begin begin
p := new TParagraph(pNode); p := new TParagraph(pNode);
//统计数字项目编号 styleId := p.Format.Value('StyleId', 1);
numArr := array(); if styleId <> '' and (obj := docx.StyleObject().GetStyleById(styleId)) and ifObj(obj) then
numId := getNumPr('numId', docx, p); begin
ilvl := getNumPr('Level', docx, p); level := getHeadingLevel(docx, obj);
if not ilvl then ilvl := 0; iLevel := Class(TSXml).SafeStrToIntDef(level, -1);
if ifarray(numIds) then Begin if iLevel+1 >= UpperHeadingLevel and iLevel+1 <= LowerHeadingLevel then Begin
if ilvl >= 0 and ilvl < 10 then Begin //统计数字项目编号
if not istable(numIds[numId]) then text := p.Text();
numIds[numId] := array(0,0,0,0,0,0,0,0,0,0); if text = "" then continue;
prev := numIds[numId, ilvl]; numArr := array();
if prev then Begin numId := getNumPr('numId', docx, p);
for i:=ilvl+1 to 9 do ilvl := getNumPr('Level', docx, p);
numIds[numId, i] := 0; if not ilvl then ilvl := 0;
End; if ifarray(numIds) then Begin
numIds[numId, ilvl]++; if ilvl >= 0 and ilvl < 10 then Begin
numArr := numIds[numId]; if not istable(numIds[numId]) then
End; numIds[numId] := array(0,0,0,0,0,0,0,0,0,0);
End; prev := numIds[numId, ilvl];
if bHeadList then Begin //统计大纲显示(目录) if prev then Begin
styleId := p.Format.Value('StyleId', 1); for i:=ilvl+1 to 9 do
if styleId <> '' then Begin numIds[numId, i] := 0;
obj := docx.StyleObject().GetStyleById(styleId); End;
if ifObj(obj) then Begin numIds[numId, ilvl]++;
level := getHeadingLevel(docx, obj); numArr := numIds[numId];
iLevel := Class(TSXml).SafeStrToIntDef(level, -1);
if p.Text() <> "" and iLevel+1 >= UpperHeadingLevel and iLevel+1 <= LowerHeadingLevel then Begin
r[ind]['Level'] := strtoint(level);
r[ind]['Paragraph'] := p;
r[ind]['Text'] := p.Text();
r[ind]['numId'] := ifnumber(numId) ? integer(numId) : 0; //数字项目编号
r[ind]['ilvl'] := ilvl; //级别
r[ind]['numArr'] := numArr; //累加数字编码
ind++;
End; End;
End; End;
r[ind]['Level'] := strtoint(level);
r[ind]['Paragraph'] := p;
r[ind]['Text'] := text;
r[ind]['numId'] := ifnumber(numId) ? integer(numId) : 0; //数字项目编号
r[ind]['ilvl'] := ilvl; //级别
r[ind]['numArr'] := numArr; //累加数字编码
ind++;
End; End;
End; end
End End
else if ifarray(numIds) and name = 'w:tbl' then Begin else if false and ifarray(numIds) and name = 'w:tbl' then Begin
tbl := TOfficeObj('TTable'); tbl := TOfficeObj('TTable');
tbl.Init(pNode); tbl.Init(pNode);
rows := tbl.Rows(); rows := tbl.Rows();
@ -13979,7 +13977,7 @@ Type TDocumentBody = Class(DocObject)
for i:=1 to rows do Begin for i:=1 to rows do Begin
for j:=1 to cols do Begin for j:=1 to cols do Begin
cell := tbl.Cell(i, j); cell := tbl.Cell(i, j);
if cell then [a, b] := cell.GetHeadingListImpl(docx, nil, UpperHeadingLevel, LowerHeadingLevel, numIds, false);//表格内递归查找,统计数字项目编号,但不显示在大纲中 if cell then [a, b] := cell.GetHeadingListImpl(docx, nil, UpperHeadingLevel, LowerHeadingLevel, numIds);//表格内递归查找,统计数字项目编号,但不显示在大纲中
End; End;
End; End;
End; End;

View File

@ -519,7 +519,7 @@ Type TSDocxFile = Class
///返回array((("Level":level,"Paragraph":"object","Text":title)); ///返回array((("Level":level,"Paragraph":"object","Text":title));
Function GetHeadingList(UpperHeadingLevel, LowerHeadingLevel); Function GetHeadingList(UpperHeadingLevel, LowerHeadingLevel);
Begin Begin
return document_.Body().GetHeadingListImpl(self, nil, UpperHeadingLevel, LowerHeadingLevel, nil, true); return document_.Body().GetHeadingListImpl(self, nil, UpperHeadingLevel, LowerHeadingLevel, nil);
End; End;
//返回Document对象 //返回Document对象

View File

@ -142,7 +142,7 @@ Type TTableContent = class
Begin Begin
///获取标题列表 array((("Level":level,"Paragraph":"object","Text":title,"numId":,"ilvl":,"numArr":)); ///获取标题列表 array((("Level":level,"Paragraph":"object","Text":title,"numId":,"ilvl":,"numArr":));
numMap := array(); numMap := array();
r := docx_.Document().Body().GetHeadingListImpl(docx_, nil, UpperHeadingLevel, LowerHeadingLevel, numMap, true); r := docx_.Document().Body().GetHeadingListImpl(docx_, nil, UpperHeadingLevel, LowerHeadingLevel, numMap);
for i:=0 to length(r)-1 do Begin for i:=0 to length(r)-1 do Begin
p := _AddItem(UpperHeadingLevel, LowerHeadingLevel, r[i]['Level'], i = 0 ? true: false); p := _AddItem(UpperHeadingLevel, LowerHeadingLevel, r[i]['Level'], i = 0 ? true: false);
//fldCharType //fldCharType