This commit is contained in:
csh 2024-03-21 16:34:38 +08:00
parent fa8800e20d
commit 72554969bb
8 changed files with 128 additions and 11 deletions

Binary file not shown.

View File

@ -1,4 +1,4 @@
// Version 1.6.6
// Version 1.6.7
Function TOfficeObj(n);
Begin
case lowercase(n) of
@ -246,6 +246,8 @@ Begin
return new TPageBorders();
"tpage":
return new TPage();
"tpagenumtype":
return new TPageNumType();
"tdocsection":
return new TDocSection();
"tcellmerge":
@ -7922,6 +7924,47 @@ type TPage=class(NodeInfo)
//Nodes
End;
///////////////////////////////////////////////////////////////
/// TPageNumType
///////////////////////////////////////////////////////////////
type TPageNumType=class(NodeInfo)
Function Create(); overload;
Begin
Create(nil, 'w:pgNumType');
End;
Function Create(p, name); overload;
Begin
Class(NodeInfo).Create(p, name);
Init();
End;
Function Init();
Begin
//TODO...
End;
Function InitRootNode(node);
Begin
RootObj := node;
End;
Function GetAttrs(); override;
Begin
return array(("Start", "w:start", Start, "起始页码")) union ExtAttr;
End;
Function GetChildren(); override;
Begin
return ExtNodes;
End;
//Attributes
Start;
//Nodes
End;
///////////////////////////////////////////////////////////////
/// TDocSectionImpl
///////////////////////////////////////////////////////////////
@ -7944,6 +7987,7 @@ type TDocSectionImpl=class(NodeInfo)
cols := new TCols(self, 'w:cols');
docGrid := new TDocGrid(self, 'w:docGrid');
pgMar := new TPageMargin(self, 'w:pgMar');
pgNumType := new TPageNumType(self, 'w:pgNumType');
Page := new TPage(self, 'w:pgSz');
Borders := new TPageBorders(self, 'w:pgBorders');
//TODO...
@ -7957,6 +8001,7 @@ type TDocSectionImpl=class(NodeInfo)
cols.InitRootNode(node);
docGrid.InitRootNode(node);
pgMar.InitRootNode(node);
pgNumType.InitRootNode(node);
Page.InitRootNode(node);
Borders.InitRootNode(node);
End;
@ -7974,6 +8019,7 @@ type TDocSectionImpl=class(NodeInfo)
,('field':'cols','name':cols.NodeName,'obj':cols,'attrEx':'','nodeType':'','attrName':'', 'desc':'Column Definitions', 'class':'TCols')
,('field':'docGrid','name':docGrid.NodeName,'obj':docGrid,'attrEx':'','nodeType':'','attrName':'', 'desc':'Document Grid', 'class':'TDocGrid')
,('field':'pgMar','name':pgMar.NodeName,'obj':pgMar,'attrEx':'','nodeType':'','attrName':'', 'desc':'Page Margin设置', 'class':'TPageMargin')
,('field':'pgNumType','name':pgNumType.NodeName,'obj':pgNumType,'attrEx':'','nodeType':'','attrName':'', 'desc':'Page NumType设置', 'class':'TPageNumType')
,('field':'Page','name':Page.NodeName,'obj':Page,'attrEx':'','nodeType':'','attrName':'', 'desc':'页面设置', 'class':'TPage')
,('field':'Borders','name':Borders.NodeName,'obj':Borders,'attrEx':'','nodeType':'','attrName':'', 'desc':'页面边框属性', 'class':'TPageBorders')
,('field':'titlePg','name':'w:titlePg','obj':titlePg,'attrEx':'','nodeType':'empty','attrName':'', 'desc':'第一页是否有不同的页眉和页脚.', 'class':'')
@ -7983,6 +8029,36 @@ type TDocSectionImpl=class(NodeInfo)
) union ExtNodes;
End;
Function AppendReference(name);
Begin
lname := lowercase(name);
node_name := lname = "header" ? "w:headerReference" : "w:footerReference";
obj := nil;
if ifObj(RootObj) then
begin
curNode := class(TSXml).GetNode(RootObj, NodeUri, "last");
if ifObj(curNode) then
begin
node := curNode.InsertFirstChild("element", node_name);
obj := new TReference(nil, node_name);
obj.InitRootNode(node);
end
end
return obj;
End;
///添加一个页脚页脚的TReference对象
///name: "header", "footer"
///注TOfficeObj("TDocSection")创建的新对象有效
Function AddReference(name);
Begin
lname := lowercase(name);
node_name := lname = "header" ? "w:headerReference" : "w:footerReference";
o := new TReference(nil, node_name);
NewChildNode( array("field":"", "name":node_name, "obj":o, "attrEx":"", "nodeType":""));
return o;
End;
//Attributes
//Nodes
@ -7992,6 +8068,7 @@ type TDocSectionImpl=class(NodeInfo)
cols;
docGrid;
pgMar;
pgNumType;
Page;
Borders;
titlePg;

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
// Version 1.6.6
// Version 1.6.7
Type TSDocxFile = Class
///Version: V1.0 2022-09-20
///适用于 Microsoft Word docx格式文件

View File

@ -35,7 +35,7 @@ public
self.Update("end");
End;
Function Delete();
Function Delete();overload;
Begin
if ifObj(RootObj) then
begin
@ -44,6 +44,35 @@ public
end
End;
Function Delete(name);overload;
Begin
if not ifObj(RootObj) then return false;
node := NodeUri <> '' ? class(TSXml).GetNode(RootObj, NodeUri) : RootObj;
attrs := GetAttrsEx();
lName := lowerCase(name);
r := sselect * from attrs where lName = lowerCase([0]) end;
if istable(r) then
begin
node.DeleteAttribute(r[1]);
return true;
end
children := GetChildren();
r := select * from children where lName = lowerCase(['field']) end;
if istable(r) then Begin
r := r[0];
delete_node := node.FirstChildElement(r['name']);
if ifObj(delete_node) then
begin
node.DeleteChild(delete_node);
return true;
end
End;
return false;
End;
Function GetAttrs(); virtual;
Begin
return ExtAttr;

View File

@ -1,4 +1,4 @@
// Version 1.6.6
// Version 1.6.7
Type TSXlsxFile = Class
///Version: V1.0 2022-08-08
///适用于 Microsoft Excel? 2007 及以上版本创建的电子表格文档。支持 XLSX / XLSM / XLTM / XLTX 等多种文档格式。

View File

@ -118,7 +118,7 @@ Type TTableContent = class
tab := TOfficeObj('TTabStop');
tab.Val := 'right';
tab.leader := 'dot';
tab.Position := 8640;
tab.Position := 9628;
p.Format.Tabs.Add(0, tab);
if first then Begin
//fldCharType

View File

@ -1,12 +1,22 @@
# 更新日志
## 2023-3-21
### V1.6.7
#### word
1. 新增对象的`Delete`方法,可以通过`Delete(name)`删除对象的指定属性
2. 新增`TPageNumType`对象
3. 扩展`TDocSection`方法,`AppendReference`和`AddReference`,前者是对已有的`Section`对象添加`TReference`对象,而后者是对新的`Section`对象添加
## 2023-3-14
### V1.6.6
#### word
1. 修复TDocSection节点获取错误
1. 修复`TDocSection`节点获取错误
2. 支持分栏自定义宽度
## 2023-3-4
@ -52,7 +62,7 @@
#### excel
1. 修复excel文件单元格原有类型与tsl类型转换报错问题(trystrtofloat)
1. 修复 excel 文件单元格原有类型与 tsl 类型转换报错问题(trystrtofloat)
## 2023-2-5