OfficeXml/迁移指南.md

48 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 迁移指南
## v2.0.0
该版本对基类做了调整
1. `OpenXmlElement` -> `OpenXmlElement`,类名不变,功能变更为基类
2. `OpenXmlPcdata` -> `OpenXmlTextElement`,类名变更,继承基类,使用方式不变
3. `OpenXmlEmpty` -> `OpenXmlSimpleType`,类名变更,继承基类,设计与使用方法需要调整
```pascal
// 弃用
rpr := new RPr();
rpr.B := true; // 启用BB是Empty元素对应xml <b/>
rpr.B.Val := 1; // <b w:val="1" />
// 读
echo rpr.B; // 判断是否启用了B
// 迁移
rpr := new RPr();
rpr.B.Enable := true; // 启用B不设置属性时候对应xml <b />
rpr.B.Val := "0"; // 会自动设置Enable为1对应xml <b w:val="0" />
// 只读
echo rpr.B.IsApplied; // 只读属性判断是否启用了B
```
4. 新增`OpenXmlCompositeElement`复杂类型的节点类,提供各种操作的方法,大部分有子节点的类均继承于该类。如`RPr`会有`B I Sz`等子节点元素,而`B I`这类的元素是`<x />`的`OpenXmlSimpleType`类型的
影响范围:列表暂无;具体可见对应类的`// simple_type property`下的属性
## v3.0.0
对`adapter`做了`break changes`的更新
1. `unit`文件更名为`adapters`复数结尾,如`DocxMLAdapter` -> `DocxMLAdapters`
2. 移除冗余的命名方式(移除每个类的`Adapter`后缀),`StylesAdapter` -> `Styles`
```pascal
// 弃用
uses DocxMLAdapter;
styles_adapter := DocxMLAdapter.StylesAdapter(styles);
// 迁移
uses DocxMLAdapters; // 复数s
styles_adapter := DocxMLAdapters.Styles(styles); // 移除冗余
```