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);
End;
Function GetHeadingListImpl(docx, posOpt, UpperHeadingLevel, LowerHeadingLevel, numIds, bHeadList);
Function GetHeadingListImpl(docx, posOpt, UpperHeadingLevel, LowerHeadingLevel, numIds);
Begin
r := array();
if ifObj(posOpt) then
@ -13933,7 +13933,15 @@ Type TDocumentBody = Class(DocObject)
if name = 'w:p' and not ifObj(pNode.FirstChildElement('w:sectPr')) then
begin
p := new TParagraph(pNode);
styleId := p.Format.Value('StyleId', 1);
if styleId <> '' and (obj := docx.StyleObject().GetStyleById(styleId)) and ifObj(obj) then
begin
level := getHeadingLevel(docx, obj);
iLevel := Class(TSXml).SafeStrToIntDef(level, -1);
if iLevel+1 >= UpperHeadingLevel and iLevel+1 <= LowerHeadingLevel then Begin
//统计数字项目编号
text := p.Text();
if text = "" then continue;
numArr := array();
numId := getNumPr('numId', docx, p);
ilvl := getNumPr('Level', docx, p);
@ -13951,27 +13959,17 @@ Type TDocumentBody = Class(DocObject)
numArr := numIds[numId];
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 := 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);
r[ind]['Paragraph'] := p;
r[ind]['Text'] := p.Text();
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.Init(pNode);
rows := tbl.Rows();
@ -13979,7 +13977,7 @@ Type TDocumentBody = Class(DocObject)
for i:=1 to rows do Begin
for j:=1 to cols do Begin
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;

View File

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

View File

@ -142,7 +142,7 @@ Type TTableContent = class
Begin
///获取标题列表 array((("Level":level,"Paragraph":"object","Text":title,"numId":,"ilvl":,"numArr":));
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
p := _AddItem(UpperHeadingLevel, LowerHeadingLevel, r[i]['Level'], i = 0 ? true: false);
//fldCharType