This commit is contained in:
csh 2025-04-16 10:03:34 +08:00
parent 87c3aa75f7
commit f816e8b6e3
20 changed files with 27378 additions and 28116 deletions

View File

@ -1,5 +1,7 @@
# OfficeXml # OfficeXml
[迁移指南](./迁移指南.md)
## 概述 ## 概述
将 docx、pptx、xlsx 等文件中的 xml 转为 tsl 对象 将 docx、pptx、xlsx 等文件中的 xml 转为 tsl 对象
@ -50,7 +52,11 @@ echo p.Rs(1).T.Text; // 输出:(份)
## 基类 ## 基类
`OpenXmlElement.tsf`提供了一些常用的方法,具体可见`tsf`文件 `OpenXmlAttribute`是节点的属性类
`OpenXmlElement.tsf`是节点基类
`OpenXmlSimpleType`是简单类型的元素节点类,继承于`OpenXmlElement`,如`<b />`
`OpenXmlTextElement`是包含文本内容的元素节点类,继承于`OpenXmlElement`,如`<t>文本</t>`
`OpenXmlCompositeElement`是复杂节点的元素节点类,继承于`OpenXmlElement`,会包含一系列的属性或其他元素节点类
## Unit 单元 ## Unit 单元
@ -209,7 +215,7 @@ style := styles_adapter.GetStyleByStyleId("a6");
echo style.Name; // 输出的是"页脚 字符" echo style.Name; // 输出的是"页脚 字符"
``` ```
### 补充 ### 其他设计的补充
```xml ```xml
<m:r> <m:r>
@ -232,3 +238,8 @@ echo style.Name; // 输出的是"页脚 字符"
由于设计取对象时候不包含前缀,那么同时存在多个`rPr`时,如何区分是哪一个? 由于设计取对象时候不包含前缀,那么同时存在多个`rPr`时,如何区分是哪一个?
取`m:rPr`时,可通过`r.RPr`,这是因为它们的前缀都是`m`,所以可直接获取 取`m:rPr`时,可通过`r.RPr`,这是因为它们的前缀都是`m`,所以可直接获取
取`a:rPr`时,需要指定前缀`a`,通过`r.RPr('a')`,进行获取`RPr`对象 取`a:rPr`时,需要指定前缀`a`,通过`r.RPr('a')`,进行获取`RPr`对象
## TODO
- [ ] 命名空间不同,但是名字相同属性的读写访问
- [ ] 属性的删除操作

File diff suppressed because it is too large Load Diff

View File

@ -1184,14 +1184,6 @@ begin
{self.}RsidP := object_.XmlAttrRsidP.Value; {self.}RsidP := object_.XmlAttrRsidP.Value;
if not ifnil(object_.XmlChildPPr) then if not ifnil(object_.XmlChildPPr) then
{self.}XmlChildPPr := new PPrUnitDecorator(object_.XmlChildPPr); {self.}XmlChildPPr := new PPrUnitDecorator(object_.XmlChildPPr);
if not ifnil(object_.XmlChildOMathPara) then
{self.}XmlChildOMathPara := new OMathParaUnitDecorator(object_.XmlChildOMathPara);
if not ifnil(object_.XmlChildOMath) then
{self.}XmlChildOMath := new OMathUnitDecorator(object_.XmlChildOMath);
if not ifnil(object_.XmlChildIns) then
{self.}XmlChildIns := new InsUnitDecorator(object_.XmlChildIns);
if not ifnil(object_.XmlChildDel) then
{self.}XmlChildDel := new DelUnitDecorator(object_.XmlChildDel);
elems := object_.Sdts(); elems := object_.Sdts();
for _,elem in elems do for _,elem in elems do
{self.}AppendChild(new SdtUnitDecorator(elem)); {self.}AppendChild(new SdtUnitDecorator(elem));
@ -1216,6 +1208,14 @@ begin
elems := object_.FldSimples(); elems := object_.FldSimples();
for _,elem in elems do for _,elem in elems do
{self.}AppendChild(new FldSimpleUnitDecorator(elem)); {self.}AppendChild(new FldSimpleUnitDecorator(elem));
if not ifnil(object_.XmlChildOMathPara) then
{self.}XmlChildOMathPara := new OMathParaUnitDecorator(object_.XmlChildOMathPara);
if not ifnil(object_.XmlChildOMath) then
{self.}XmlChildOMath := new OMathUnitDecorator(object_.XmlChildOMath);
if not ifnil(object_.XmlChildIns) then
{self.}XmlChildIns := new InsUnitDecorator(object_.XmlChildIns);
if not ifnil(object_.XmlChildDel) then
{self.}XmlChildDel := new DelUnitDecorator(object_.XmlChildDel);
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
@ -1340,11 +1340,11 @@ begin
if not ifnil(object_.XmlChildTabs) then if not ifnil(object_.XmlChildTabs) then
{self.}XmlChildTabs := new TabsUnitDecorator(object_.XmlChildTabs); {self.}XmlChildTabs := new TabsUnitDecorator(object_.XmlChildTabs);
if not ifnil(object_.XmlChildBidi) then if not ifnil(object_.XmlChildBidi) then
{self.}Bidi.Copy(object_.XmlChildBidi); {self.}XmlChildBidi.Copy(object_.XmlChildBidi);
if not ifnil(object_.XmlChildWidowControl) then if not ifnil(object_.XmlChildWidowControl) then
{self.}WidowControl.Copy(object_.XmlChildWidowControl); {self.}XmlChildWidowControl.Copy(object_.XmlChildWidowControl);
if not ifnil(object_.XmlChildSnapToGrid) then if not ifnil(object_.XmlChildSnapToGrid) then
{self.}SnapToGrid.Copy(object_.XmlChildSnapToGrid); {self.}XmlChildSnapToGrid.Copy(object_.XmlChildSnapToGrid);
if not ifnil(object_.XmlChildPStyle) then if not ifnil(object_.XmlChildPStyle) then
{self.}XmlChildPStyle := new PureWValUnitDecorator(object_.XmlChildPStyle); {self.}XmlChildPStyle := new PureWValUnitDecorator(object_.XmlChildPStyle);
if not ifnil(object_.XmlChildNumPr) then if not ifnil(object_.XmlChildNumPr) then
@ -1354,21 +1354,21 @@ begin
if not ifnil(object_.XmlChildInd) then if not ifnil(object_.XmlChildInd) then
{self.}XmlChildInd := new IndUnitDecorator(object_.XmlChildInd); {self.}XmlChildInd := new IndUnitDecorator(object_.XmlChildInd);
if not ifnil(object_.XmlChildKeepNext) then if not ifnil(object_.XmlChildKeepNext) then
{self.}KeepNext.Copy(object_.XmlChildKeepNext); {self.}XmlChildKeepNext.Copy(object_.XmlChildKeepNext);
if not ifnil(object_.XmlChildKeepLines) then if not ifnil(object_.XmlChildKeepLines) then
{self.}KeepLines.Copy(object_.XmlChildKeepLines); {self.}XmlChildKeepLines.Copy(object_.XmlChildKeepLines);
if not ifnil(object_.XmlChildMirrorIndents) then if not ifnil(object_.XmlChildMirrorIndents) then
{self.}MirrorIndents.Copy(object_.XmlChildMirrorIndents); {self.}XmlChildMirrorIndents.Copy(object_.XmlChildMirrorIndents);
if not ifnil(object_.XmlChildKinsoku) then if not ifnil(object_.XmlChildKinsoku) then
{self.}XmlChildKinsoku := new PureWValUnitDecorator(object_.XmlChildKinsoku); {self.}XmlChildKinsoku := new PureWValUnitDecorator(object_.XmlChildKinsoku);
if not ifnil(object_.XmlChildPageBreakBefore) then if not ifnil(object_.XmlChildPageBreakBefore) then
{self.}PageBreakBefore.Copy(object_.XmlChildPageBreakBefore); {self.}XmlChildPageBreakBefore.Copy(object_.XmlChildPageBreakBefore);
if not ifnil(object_.XmlChildSuppressAutoHyphens) then if not ifnil(object_.XmlChildSuppressAutoHyphens) then
{self.}SuppressAutoHyphens.Copy(object_.XmlChildSuppressAutoHyphens); {self.}XmlChildSuppressAutoHyphens.Copy(object_.XmlChildSuppressAutoHyphens);
if not ifnil(object_.XmlChildSuppressLineNumbers) then if not ifnil(object_.XmlChildSuppressLineNumbers) then
{self.}SuppressLineNumbers.Copy(object_.XmlChildSuppressLineNumbers); {self.}XmlChildSuppressLineNumbers.Copy(object_.XmlChildSuppressLineNumbers);
if not ifnil(object_.XmlChildSuppressOverlap) then if not ifnil(object_.XmlChildSuppressOverlap) then
{self.}SuppressOverlap.Copy(object_.XmlChildSuppressOverlap); {self.}XmlChildSuppressOverlap.Copy(object_.XmlChildSuppressOverlap);
if not ifnil(object_.XmlChildOverflowPunct) then if not ifnil(object_.XmlChildOverflowPunct) then
{self.}XmlChildOverflowPunct := new PureWValUnitDecorator(object_.XmlChildOverflowPunct); {self.}XmlChildOverflowPunct := new PureWValUnitDecorator(object_.XmlChildOverflowPunct);
if not ifnil(object_.XmlChildAdjustRightInd) then if not ifnil(object_.XmlChildAdjustRightInd) then
@ -1386,7 +1386,7 @@ begin
if not ifnil(object_.XmlChildPBdr) then if not ifnil(object_.XmlChildPBdr) then
{self.}XmlChildPBdr := new PBdrUnitDecorator(object_.XmlChildPBdr); {self.}XmlChildPBdr := new PBdrUnitDecorator(object_.XmlChildPBdr);
if not ifnil(object_.XmlChildContextualSpacing) then if not ifnil(object_.XmlChildContextualSpacing) then
{self.}ContextualSpacing.Copy(object_.XmlChildContextualSpacing); {self.}XmlChildContextualSpacing.Copy(object_.XmlChildContextualSpacing);
if not ifnil(object_.XmlChildShd) then if not ifnil(object_.XmlChildShd) then
{self.}XmlChildShd := new ShdUnitDecorator(object_.XmlChildShd); {self.}XmlChildShd := new ShdUnitDecorator(object_.XmlChildShd);
if not ifnil(object_.XmlChildWordWrap) then if not ifnil(object_.XmlChildWordWrap) then
@ -1698,13 +1698,13 @@ begin
if not ifnil(object_.XmlChildKern) then if not ifnil(object_.XmlChildKern) then
{self.}XmlChildKern := new PureWValUnitDecorator(object_.XmlChildKern); {self.}XmlChildKern := new PureWValUnitDecorator(object_.XmlChildKern);
if not ifnil(object_.XmlChildI) then if not ifnil(object_.XmlChildI) then
{self.}I.Copy(object_.XmlChildI); {self.}XmlChildI.Copy(object_.XmlChildI);
if not ifnil(object_.XmlChildICs) then if not ifnil(object_.XmlChildICs) then
{self.}ICs.Copy(object_.XmlChildICs); {self.}XmlChildICs.Copy(object_.XmlChildICs);
if not ifnil(object_.XmlChildB) then if not ifnil(object_.XmlChildB) then
{self.}B.Copy(object_.XmlChildB); {self.}XmlChildB.Copy(object_.XmlChildB);
if not ifnil(object_.XmlChildBCs) then if not ifnil(object_.XmlChildBCs) then
{self.}BCs.Copy(object_.XmlChildBCs); {self.}XmlChildBCs.Copy(object_.XmlChildBCs);
if not ifnil(object_.XmlChildBdr) then if not ifnil(object_.XmlChildBdr) then
{self.}XmlChildBdr := new BdrUnitDecorator(object_.XmlChildBdr); {self.}XmlChildBdr := new BdrUnitDecorator(object_.XmlChildBdr);
if not ifnil(object_.XmlChildCaps) then if not ifnil(object_.XmlChildCaps) then
@ -1712,7 +1712,7 @@ begin
if not ifnil(object_.XmlChildDel) then if not ifnil(object_.XmlChildDel) then
{self.}XmlChildDel := new DelUnitDecorator(object_.XmlChildDel); {self.}XmlChildDel := new DelUnitDecorator(object_.XmlChildDel);
if not ifnil(object_.XmlChildStrike) then if not ifnil(object_.XmlChildStrike) then
{self.}Strike.Copy(object_.XmlChildStrike); {self.}XmlChildStrike.Copy(object_.XmlChildStrike);
if not ifnil(object_.XmlChildDStrike) then if not ifnil(object_.XmlChildDStrike) then
{self.}XmlChildDStrike := new PureWValUnitDecorator(object_.XmlChildDStrike); {self.}XmlChildDStrike := new PureWValUnitDecorator(object_.XmlChildDStrike);
if not ifnil(object_.XmlChildEffect) then if not ifnil(object_.XmlChildEffect) then
@ -1730,13 +1730,13 @@ begin
if not ifnil(object_.XmlChildEastAsianLayout) then if not ifnil(object_.XmlChildEastAsianLayout) then
{self.}XmlChildEastAsianLayout := new EastAsianLayoutUnitDecorator(object_.XmlChildEastAsianLayout); {self.}XmlChildEastAsianLayout := new EastAsianLayoutUnitDecorator(object_.XmlChildEastAsianLayout);
if not ifnil(object_.XmlChildCs) then if not ifnil(object_.XmlChildCs) then
{self.}Cs.Copy(object_.XmlChildCs); {self.}XmlChildCs.Copy(object_.XmlChildCs);
if not ifnil(object_.XmlChildSz) then if not ifnil(object_.XmlChildSz) then
{self.}XmlChildSz := new SzUnitDecorator(object_.XmlChildSz); {self.}XmlChildSz := new SzUnitDecorator(object_.XmlChildSz);
if not ifnil(object_.XmlChildSzCs) then if not ifnil(object_.XmlChildSzCs) then
{self.}XmlChildSzCs := new SzCsUnitDecorator(object_.XmlChildSzCs); {self.}XmlChildSzCs := new SzCsUnitDecorator(object_.XmlChildSzCs);
if not ifnil(object_.XmlChildU) then if not ifnil(object_.XmlChildU) then
{self.}U.Copy(object_.XmlChildU); {self.}XmlChildU.Copy(object_.XmlChildU);
if not ifnil(object_.XmlChildLang) then if not ifnil(object_.XmlChildLang) then
{self.}XmlChildLang := new LangUnitDecorator(object_.XmlChildLang); {self.}XmlChildLang := new LangUnitDecorator(object_.XmlChildLang);
if not ifnil(object_.XmlChildImprint) then if not ifnil(object_.XmlChildImprint) then
@ -1748,13 +1748,13 @@ begin
if not ifnil(object_.XmlChildRtl) then if not ifnil(object_.XmlChildRtl) then
{self.}XmlChildRtl := new PureWValUnitDecorator(object_.XmlChildRtl); {self.}XmlChildRtl := new PureWValUnitDecorator(object_.XmlChildRtl);
if not ifnil(object_.XmlChildOMath) then if not ifnil(object_.XmlChildOMath) then
{self.}OMath.Copy(object_.XmlChildOMath); {self.}XmlChildOMath.Copy(object_.XmlChildOMath);
if not ifnil(object_.XmlChildShadow) then if not ifnil(object_.XmlChildShadow) then
{self.}Shadow.Copy(object_.XmlChildShadow); {self.}XmlChildShadow.Copy(object_.XmlChildShadow);
if not ifnil(object_.XmlChildSpecVanish) then if not ifnil(object_.XmlChildSpecVanish) then
{self.}SpecVanish.Copy(object_.XmlChildSpecVanish); {self.}XmlChildSpecVanish.Copy(object_.XmlChildSpecVanish);
if not ifnil(object_.XmlChildVanish) then if not ifnil(object_.XmlChildVanish) then
{self.}Vanish.Copy(object_.XmlChildVanish); {self.}XmlChildVanish.Copy(object_.XmlChildVanish);
if not ifnil(object_.XmlChildShd) then if not ifnil(object_.XmlChildShd) then
{self.}XmlChildShd := new ShdUnitDecorator(object_.XmlChildShd); {self.}XmlChildShd := new ShdUnitDecorator(object_.XmlChildShd);
if not ifnil(object_.XmlChildSmallCaps) then if not ifnil(object_.XmlChildSmallCaps) then
@ -2133,8 +2133,8 @@ function RUnitDecorator.Convert();
begin begin
tslassigning_backup := tslassigning; tslassigning_backup := tslassigning;
tslassigning := 1; tslassigning := 1;
if not ifnil(object_.XmlAttrWRsidRPr) then if not ifnil(object_.XmlAttrRsidRPr) then
{self.}WRsidRPr := object_.XmlAttrWRsidRPr.Value; {self.}RsidRPr := object_.XmlAttrRsidRPr.Value;
if not ifnil(object_.XmlAttrAnchor) then if not ifnil(object_.XmlAttrAnchor) then
{self.}Anchor := object_.XmlAttrAnchor.Value; {self.}Anchor := object_.XmlAttrAnchor.Value;
if not ifnil(object_.XmlAttrHistory) then if not ifnil(object_.XmlAttrHistory) then
@ -2151,11 +2151,11 @@ begin
if not ifnil(object_.XmlChildInstrText) then if not ifnil(object_.XmlChildInstrText) then
{self.}XmlChildInstrText := new InstrTextUnitDecorator(object_.XmlChildInstrText); {self.}XmlChildInstrText := new InstrTextUnitDecorator(object_.XmlChildInstrText);
if not ifnil(object_.XmlChildSeparator) then if not ifnil(object_.XmlChildSeparator) then
{self.}Separator.Copy(object_.XmlChildSeparator); {self.}XmlChildSeparator.Copy(object_.XmlChildSeparator);
if not ifnil(object_.XmlChildContinuationSeparator) then if not ifnil(object_.XmlChildContinuationSeparator) then
{self.}ContinuationSeparator.Copy(object_.XmlChildContinuationSeparator); {self.}XmlChildContinuationSeparator.Copy(object_.XmlChildContinuationSeparator);
if not ifnil(object_.XmlChildLastRenderedPageBreak) then if not ifnil(object_.XmlChildLastRenderedPageBreak) then
{self.}LastRenderedPageBreak.Copy(object_.XmlChildLastRenderedPageBreak); {self.}XmlChildLastRenderedPageBreak.Copy(object_.XmlChildLastRenderedPageBreak);
if not ifnil(object_.XmlChildAlternateContent) then if not ifnil(object_.XmlChildAlternateContent) then
{self.}XmlChildAlternateContent := new AlternateContentUnitDecorator(object_.XmlChildAlternateContent); {self.}XmlChildAlternateContent := new AlternateContentUnitDecorator(object_.XmlChildAlternateContent);
if not ifnil(object_.XmlChildDrawing) then if not ifnil(object_.XmlChildDrawing) then
@ -2169,7 +2169,7 @@ begin
if not ifnil(object_.XmlChildFootnoteReference) then if not ifnil(object_.XmlChildFootnoteReference) then
{self.}XmlChildFootnoteReference := new FootnoteReferenceUnitDecorator(object_.XmlChildFootnoteReference); {self.}XmlChildFootnoteReference := new FootnoteReferenceUnitDecorator(object_.XmlChildFootnoteReference);
if not ifnil(object_.XmlChildFootnoteRef) then if not ifnil(object_.XmlChildFootnoteRef) then
{self.}FootnoteRef.Copy(object_.XmlChildFootnoteRef); {self.}XmlChildFootnoteRef.Copy(object_.XmlChildFootnoteRef);
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
@ -2697,7 +2697,7 @@ begin
if not ifnil(object_.XmlChildJc) then if not ifnil(object_.XmlChildJc) then
{self.}XmlChildJc := new PureWValUnitDecorator(object_.XmlChildJc); {self.}XmlChildJc := new PureWValUnitDecorator(object_.XmlChildJc);
if not ifnil(object_.XmlChildCantSplit) then if not ifnil(object_.XmlChildCantSplit) then
{self.}CantSplit.Copy(object_.XmlChildCantSplit); {self.}XmlChildCantSplit.Copy(object_.XmlChildCantSplit);
if not ifnil(object_.XmlChildCnfStyle) then if not ifnil(object_.XmlChildCnfStyle) then
{self.}XmlChildCnfStyle := new CnfStyleUnitDecorator(object_.XmlChildCnfStyle); {self.}XmlChildCnfStyle := new CnfStyleUnitDecorator(object_.XmlChildCnfStyle);
if not ifnil(object_.XmlChildIns) then if not ifnil(object_.XmlChildIns) then
@ -2853,11 +2853,11 @@ begin
if not ifnil(object_.XmlChildGridSpan) then if not ifnil(object_.XmlChildGridSpan) then
{self.}XmlChildGridSpan := new GridSpanUnitDecorator(object_.XmlChildGridSpan); {self.}XmlChildGridSpan := new GridSpanUnitDecorator(object_.XmlChildGridSpan);
if not ifnil(object_.XmlChildVMerge) then if not ifnil(object_.XmlChildVMerge) then
{self.}VMerge.Copy(object_.XmlChildVMerge); {self.}XmlChildVMerge.Copy(object_.XmlChildVMerge);
if not ifnil(object_.XmlChildVAlign) then if not ifnil(object_.XmlChildVAlign) then
{self.}XmlChildVAlign := new PureWValUnitDecorator(object_.XmlChildVAlign); {self.}XmlChildVAlign := new PureWValUnitDecorator(object_.XmlChildVAlign);
if not ifnil(object_.XmlChildHideMark) then if not ifnil(object_.XmlChildHideMark) then
{self.}HideMark.Copy(object_.XmlChildHideMark); {self.}XmlChildHideMark.Copy(object_.XmlChildHideMark);
if not ifnil(object_.XmlChildShd) then if not ifnil(object_.XmlChildShd) then
{self.}XmlChildShd := new ShdUnitDecorator(object_.XmlChildShd); {self.}XmlChildShd := new ShdUnitDecorator(object_.XmlChildShd);
if not ifnil(object_.XmlChildTcBorders) then if not ifnil(object_.XmlChildTcBorders) then
@ -3116,7 +3116,7 @@ begin
if not ifnil(object_.XmlChildCols) then if not ifnil(object_.XmlChildCols) then
{self.}XmlChildCols := new ColsUnitDecorator(object_.XmlChildCols); {self.}XmlChildCols := new ColsUnitDecorator(object_.XmlChildCols);
if not ifnil(object_.XmlChildTitlePg) then if not ifnil(object_.XmlChildTitlePg) then
{self.}TitlePg.Copy(object_.XmlChildTitlePg); {self.}XmlChildTitlePg.Copy(object_.XmlChildTitlePg);
if not ifnil(object_.XmlChildDocGrid) then if not ifnil(object_.XmlChildDocGrid) then
{self.}XmlChildDocGrid := new DocGridUnitDecorator(object_.XmlChildDocGrid); {self.}XmlChildDocGrid := new DocGridUnitDecorator(object_.XmlChildDocGrid);
if not ifnil(object_.XmlChildTextDirection) then if not ifnil(object_.XmlChildTextDirection) then
@ -3511,13 +3511,13 @@ begin
if not ifnil(object_.XmlChildZoom) then if not ifnil(object_.XmlChildZoom) then
{self.}XmlChildZoom := new ZoomUnitDecorator(object_.XmlChildZoom); {self.}XmlChildZoom := new ZoomUnitDecorator(object_.XmlChildZoom);
if not ifnil(object_.XmlChildBordersDoNotSurroundHeader) then if not ifnil(object_.XmlChildBordersDoNotSurroundHeader) then
{self.}BordersDoNotSurroundHeader.Copy(object_.XmlChildBordersDoNotSurroundHeader); {self.}XmlChildBordersDoNotSurroundHeader.Copy(object_.XmlChildBordersDoNotSurroundHeader);
if not ifnil(object_.XmlChildBordersDoNotSurroundFooter) then if not ifnil(object_.XmlChildBordersDoNotSurroundFooter) then
{self.}BordersDoNotSurroundFooter.Copy(object_.XmlChildBordersDoNotSurroundFooter); {self.}XmlChildBordersDoNotSurroundFooter.Copy(object_.XmlChildBordersDoNotSurroundFooter);
if not ifnil(object_.XmlChildDefaultTabStop) then if not ifnil(object_.XmlChildDefaultTabStop) then
{self.}XmlChildDefaultTabStop := new PureWValUnitDecorator(object_.XmlChildDefaultTabStop); {self.}XmlChildDefaultTabStop := new PureWValUnitDecorator(object_.XmlChildDefaultTabStop);
if not ifnil(object_.XmlChildEvenAndOddHeaders) then if not ifnil(object_.XmlChildEvenAndOddHeaders) then
{self.}EvenAndOddHeaders.Copy(object_.XmlChildEvenAndOddHeaders); {self.}XmlChildEvenAndOddHeaders.Copy(object_.XmlChildEvenAndOddHeaders);
if not ifnil(object_.XmlChildDrawingGridVerticalSpacing) then if not ifnil(object_.XmlChildDrawingGridVerticalSpacing) then
{self.}XmlChildDrawingGridVerticalSpacing := new PureWValUnitDecorator(object_.XmlChildDrawingGridVerticalSpacing); {self.}XmlChildDrawingGridVerticalSpacing := new PureWValUnitDecorator(object_.XmlChildDrawingGridVerticalSpacing);
if not ifnil(object_.XmlChildDisplayHorizontalDrawingGridEvery) then if not ifnil(object_.XmlChildDisplayHorizontalDrawingGridEvery) then
@ -3543,7 +3543,7 @@ begin
if not ifnil(object_.XmlChildClrSchemeMapping) then if not ifnil(object_.XmlChildClrSchemeMapping) then
{self.}XmlChildClrSchemeMapping := new ClrSchemeMappingUnitDecorator(object_.XmlChildClrSchemeMapping); {self.}XmlChildClrSchemeMapping := new ClrSchemeMappingUnitDecorator(object_.XmlChildClrSchemeMapping);
if not ifnil(object_.XmlChildDoNotIncludeSubdocsInStats) then if not ifnil(object_.XmlChildDoNotIncludeSubdocsInStats) then
{self.}DoNotIncludeSubdocsInStats.Copy(object_.XmlChildDoNotIncludeSubdocsInStats); {self.}XmlChildDoNotIncludeSubdocsInStats.Copy(object_.XmlChildDoNotIncludeSubdocsInStats);
if not ifnil(object_.XmlChildShapeDefaults) then if not ifnil(object_.XmlChildShapeDefaults) then
{self.}XmlChildShapeDefaults := new ShapeDefaults2UnitDecorator(object_.XmlChildShapeDefaults); {self.}XmlChildShapeDefaults := new ShapeDefaults2UnitDecorator(object_.XmlChildShapeDefaults);
if not ifnil(object_.XmlChildDecimalSymbol) then if not ifnil(object_.XmlChildDecimalSymbol) then
@ -3557,7 +3557,7 @@ begin
if not ifnil(object_.XmlChildDocId) then if not ifnil(object_.XmlChildDocId) then
{self.}XmlChildDocId := new PureWValUnitDecorator(object_.XmlChildDocId); {self.}XmlChildDocId := new PureWValUnitDecorator(object_.XmlChildDocId);
if not ifnil(object_.XmlChildChartTrackingRefBased) then if not ifnil(object_.XmlChildChartTrackingRefBased) then
{self.}ChartTrackingRefBased.Copy(object_.XmlChildChartTrackingRefBased); {self.}XmlChildChartTrackingRefBased.Copy(object_.XmlChildChartTrackingRefBased);
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
@ -3703,19 +3703,19 @@ begin
tslassigning_backup := tslassigning; tslassigning_backup := tslassigning;
tslassigning := 1; tslassigning := 1;
if not ifnil(object_.XmlChildSpaceForUL) then if not ifnil(object_.XmlChildSpaceForUL) then
{self.}SpaceForUL.Copy(object_.XmlChildSpaceForUL); {self.}XmlChildSpaceForUL.Copy(object_.XmlChildSpaceForUL);
if not ifnil(object_.XmlChildBalanceSingleByteDoubleByteWidth) then if not ifnil(object_.XmlChildBalanceSingleByteDoubleByteWidth) then
{self.}BalanceSingleByteDoubleByteWidth.Copy(object_.XmlChildBalanceSingleByteDoubleByteWidth); {self.}XmlChildBalanceSingleByteDoubleByteWidth.Copy(object_.XmlChildBalanceSingleByteDoubleByteWidth);
if not ifnil(object_.XmlChildDoNotLeaveBackslashAlone) then if not ifnil(object_.XmlChildDoNotLeaveBackslashAlone) then
{self.}DoNotLeaveBackslashAlone.Copy(object_.XmlChildDoNotLeaveBackslashAlone); {self.}XmlChildDoNotLeaveBackslashAlone.Copy(object_.XmlChildDoNotLeaveBackslashAlone);
if not ifnil(object_.XmlChildUlTrailSpace) then if not ifnil(object_.XmlChildUlTrailSpace) then
{self.}UlTrailSpace.Copy(object_.XmlChildUlTrailSpace); {self.}XmlChildUlTrailSpace.Copy(object_.XmlChildUlTrailSpace);
if not ifnil(object_.XmlChildDoNotExpandShiftReturn) then if not ifnil(object_.XmlChildDoNotExpandShiftReturn) then
{self.}DoNotExpandShiftReturn.Copy(object_.XmlChildDoNotExpandShiftReturn); {self.}XmlChildDoNotExpandShiftReturn.Copy(object_.XmlChildDoNotExpandShiftReturn);
if not ifnil(object_.XmlChildAdjustLineHeightInTable) then if not ifnil(object_.XmlChildAdjustLineHeightInTable) then
{self.}AdjustLineHeightInTable.Copy(object_.XmlChildAdjustLineHeightInTable); {self.}XmlChildAdjustLineHeightInTable.Copy(object_.XmlChildAdjustLineHeightInTable);
if not ifnil(object_.XmlChildUseFELayout) then if not ifnil(object_.XmlChildUseFELayout) then
{self.}UseFELayout.Copy(object_.XmlChildUseFELayout); {self.}XmlChildUseFELayout.Copy(object_.XmlChildUseFELayout);
elems := object_.CompatSettings(); elems := object_.CompatSettings();
for _,elem in elems do for _,elem in elems do
{self.}AppendChild(new CompatSettingUnitDecorator(elem)); {self.}AppendChild(new CompatSettingUnitDecorator(elem));
@ -4097,11 +4097,11 @@ begin
if not ifnil(object_.XmlChildUIPriority) then if not ifnil(object_.XmlChildUIPriority) then
{self.}XmlChildUIPriority := new PureWValUnitDecorator(object_.XmlChildUIPriority); {self.}XmlChildUIPriority := new PureWValUnitDecorator(object_.XmlChildUIPriority);
if not ifnil(object_.XmlChildSemiHidden) then if not ifnil(object_.XmlChildSemiHidden) then
{self.}SemiHidden.Copy(object_.XmlChildSemiHidden); {self.}XmlChildSemiHidden.Copy(object_.XmlChildSemiHidden);
if not ifnil(object_.XmlChildUnhideWhenUsed) then if not ifnil(object_.XmlChildUnhideWhenUsed) then
{self.}UnhideWhenUsed.Copy(object_.XmlChildUnhideWhenUsed); {self.}XmlChildUnhideWhenUsed.Copy(object_.XmlChildUnhideWhenUsed);
if not ifnil(object_.XmlChildQFormat) then if not ifnil(object_.XmlChildQFormat) then
{self.}QFormat.Copy(object_.XmlChildQFormat); {self.}XmlChildQFormat.Copy(object_.XmlChildQFormat);
if not ifnil(object_.XmlChildRsid) then if not ifnil(object_.XmlChildRsid) then
{self.}XmlChildRsid := new PureWValUnitDecorator(object_.XmlChildRsid); {self.}XmlChildRsid := new PureWValUnitDecorator(object_.XmlChildRsid);
if not ifnil(object_.XmlChildPPr) then if not ifnil(object_.XmlChildPPr) then
@ -4220,9 +4220,9 @@ begin
if not ifnil(object_.XmlAttrIgnorable) then if not ifnil(object_.XmlAttrIgnorable) then
{self.}Ignorable := object_.XmlAttrIgnorable.Value; {self.}Ignorable := object_.XmlAttrIgnorable.Value;
if not ifnil(object_.XmlChildOptimizeForBrowser) then if not ifnil(object_.XmlChildOptimizeForBrowser) then
{self.}OptimizeForBrowser.Copy(object_.XmlChildOptimizeForBrowser); {self.}XmlChildOptimizeForBrowser.Copy(object_.XmlChildOptimizeForBrowser);
if not ifnil(object_.XmlChildAllowPNG) then if not ifnil(object_.XmlChildAllowPNG) then
{self.}AllowPNG.Copy(object_.XmlChildAllowPNG); {self.}XmlChildAllowPNG.Copy(object_.XmlChildAllowPNG);
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;

File diff suppressed because it is too large Load Diff

View File

@ -862,9 +862,9 @@ begin
if not ifnil(object_.XmlChildThemeElements) then if not ifnil(object_.XmlChildThemeElements) then
{self.}XmlChildThemeElements := new ThemeElementsUnitDecorator(object_.XmlChildThemeElements); {self.}XmlChildThemeElements := new ThemeElementsUnitDecorator(object_.XmlChildThemeElements);
if not ifnil(object_.XmlChildObjectDefaults) then if not ifnil(object_.XmlChildObjectDefaults) then
{self.}ObjectDefaults.Copy(object_.XmlChildObjectDefaults); {self.}XmlChildObjectDefaults.Copy(object_.XmlChildObjectDefaults);
if not ifnil(object_.XmlChildExtraClrSchemeLst) then if not ifnil(object_.XmlChildExtraClrSchemeLst) then
{self.}ExtraClrSchemeLst.Copy(object_.XmlChildExtraClrSchemeLst); {self.}XmlChildExtraClrSchemeLst.Copy(object_.XmlChildExtraClrSchemeLst);
if not ifnil(object_.XmlChildExtLst) then if not ifnil(object_.XmlChildExtLst) then
{self.}XmlChildExtLst := new ExtLstUnitDecorator(object_.XmlChildExtLst); {self.}XmlChildExtLst := new ExtLstUnitDecorator(object_.XmlChildExtLst);
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
@ -1623,7 +1623,7 @@ begin
if not ifnil(object_.XmlChildLegendPos) then if not ifnil(object_.XmlChildLegendPos) then
{self.}XmlChildLegendPos := new PureValUnitDecorator(object_.XmlChildLegendPos); {self.}XmlChildLegendPos := new PureValUnitDecorator(object_.XmlChildLegendPos);
if not ifnil(object_.XmlChildLayout) then if not ifnil(object_.XmlChildLayout) then
{self.}Layout.Copy(object_.XmlChildLayout); {self.}XmlChildLayout.Copy(object_.XmlChildLayout);
if not ifnil(object_.XmlChildOverlay) then if not ifnil(object_.XmlChildOverlay) then
{self.}XmlChildOverlay := new PureValUnitDecorator(object_.XmlChildOverlay); {self.}XmlChildOverlay := new PureValUnitDecorator(object_.XmlChildOverlay);
if not ifnil(object_.XmlChildTxPr) then if not ifnil(object_.XmlChildTxPr) then
@ -1673,7 +1673,7 @@ begin
tslassigning_backup := tslassigning; tslassigning_backup := tslassigning;
tslassigning := 1; tslassigning := 1;
if not ifnil(object_.XmlChildLayout) then if not ifnil(object_.XmlChildLayout) then
{self.}Layout.Copy(object_.XmlChildLayout); {self.}XmlChildLayout.Copy(object_.XmlChildLayout);
if not ifnil(object_.XmlChildBarChart) then if not ifnil(object_.XmlChildBarChart) then
{self.}XmlChildBarChart := new BarChartUnitDecorator(object_.XmlChildBarChart); {self.}XmlChildBarChart := new BarChartUnitDecorator(object_.XmlChildBarChart);
if not ifnil(object_.XmlChildCatAx) then if not ifnil(object_.XmlChildCatAx) then
@ -1709,11 +1709,11 @@ begin
{self.}XmlChildGrouping := new PureValUnitDecorator(object_.XmlChildGrouping); {self.}XmlChildGrouping := new PureValUnitDecorator(object_.XmlChildGrouping);
if not ifnil(object_.XmlChildVaryColors) then if not ifnil(object_.XmlChildVaryColors) then
{self.}XmlChildVaryColors := new PureValUnitDecorator(object_.XmlChildVaryColors); {self.}XmlChildVaryColors := new PureValUnitDecorator(object_.XmlChildVaryColors);
if not ifnil(object_.XmlChildGapWidth) then
{self.}XmlChildGapWidth := new PureValUnitDecorator(object_.XmlChildGapWidth);
elems := object_.Sers(); elems := object_.Sers();
for _,elem in elems do for _,elem in elems do
{self.}AppendChild(new SerUnitDecorator(elem)); {self.}AppendChild(new SerUnitDecorator(elem));
if not ifnil(object_.XmlChildGapWidth) then
{self.}XmlChildGapWidth := new PureValUnitDecorator(object_.XmlChildGapWidth);
elems := object_.AxIds(); elems := object_.AxIds();
for _,elem in elems do for _,elem in elems do
{self.}AppendChild(new PureValUnitDecorator(elem)); {self.}AppendChild(new PureValUnitDecorator(elem));
@ -2094,7 +2094,7 @@ begin
if not ifnil(object_.XmlChildBodyPr) then if not ifnil(object_.XmlChildBodyPr) then
{self.}XmlChildBodyPr := new BodyPrUnitDecorator(object_.XmlChildBodyPr); {self.}XmlChildBodyPr := new BodyPrUnitDecorator(object_.XmlChildBodyPr);
if not ifnil(object_.XmlChildLstStyle) then if not ifnil(object_.XmlChildLstStyle) then
{self.}LstStyle.Copy(object_.XmlChildLstStyle); {self.}XmlChildLstStyle.Copy(object_.XmlChildLstStyle);
elems := object_.Ps(); elems := object_.Ps();
for _,elem in elems do for _,elem in elems do
{self.}AppendChild(new PUnitDecorator(elem)); {self.}AppendChild(new PUnitDecorator(elem));
@ -2120,7 +2120,7 @@ begin
if not ifnil(object_.XmlChildTx) then if not ifnil(object_.XmlChildTx) then
{self.}XmlChildTx := new TxUnitDecorator(object_.XmlChildTx); {self.}XmlChildTx := new TxUnitDecorator(object_.XmlChildTx);
if not ifnil(object_.XmlChildLayout) then if not ifnil(object_.XmlChildLayout) then
{self.}Layout.Copy(object_.XmlChildLayout); {self.}XmlChildLayout.Copy(object_.XmlChildLayout);
if not ifnil(object_.XmlChildOverlay) then if not ifnil(object_.XmlChildOverlay) then
{self.}XmlChildOverlay := new PureValUnitDecorator(object_.XmlChildOverlay); {self.}XmlChildOverlay := new PureValUnitDecorator(object_.XmlChildOverlay);
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
@ -2168,7 +2168,7 @@ begin
if not ifnil(object_.XmlChildBodyPr) then if not ifnil(object_.XmlChildBodyPr) then
{self.}XmlChildBodyPr := new BodyPrUnitDecorator(object_.XmlChildBodyPr); {self.}XmlChildBodyPr := new BodyPrUnitDecorator(object_.XmlChildBodyPr);
if not ifnil(object_.XmlChildLstStyle) then if not ifnil(object_.XmlChildLstStyle) then
{self.}LstStyle.Copy(object_.XmlChildLstStyle); {self.}XmlChildLstStyle.Copy(object_.XmlChildLstStyle);
elems := object_.Ps(); elems := object_.Ps();
for _,elem in elems do for _,elem in elems do
{self.}AppendChild(new PUnitDecorator(elem)); {self.}AppendChild(new PUnitDecorator(elem));
@ -2230,7 +2230,7 @@ begin
if not ifnil(object_.XmlChildPrstTxWrap) then if not ifnil(object_.XmlChildPrstTxWrap) then
{self.}XmlChildPrstTxWrap := new PrstTxWrapUnitDecorator(object_.XmlChildPrstTxWrap); {self.}XmlChildPrstTxWrap := new PrstTxWrapUnitDecorator(object_.XmlChildPrstTxWrap);
if not ifnil(object_.XmlChildNoAutofit) then if not ifnil(object_.XmlChildNoAutofit) then
{self.}NoAutofit.Copy(object_.XmlChildNoAutofit); {self.}XmlChildNoAutofit.Copy(object_.XmlChildNoAutofit);
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
@ -2253,7 +2253,7 @@ begin
if not ifnil(object_.XmlAttrPrst) then if not ifnil(object_.XmlAttrPrst) then
{self.}Prst := object_.XmlAttrPrst.Value; {self.}Prst := object_.XmlAttrPrst.Value;
if not ifnil(object_.XmlChildAvLst) then if not ifnil(object_.XmlChildAvLst) then
{self.}AvLst.Copy(object_.XmlChildAvLst); {self.}XmlChildAvLst.Copy(object_.XmlChildAvLst);
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
@ -2952,7 +2952,7 @@ begin
if not ifnil(object_.XmlChildPrstGeom) then if not ifnil(object_.XmlChildPrstGeom) then
{self.}XmlChildPrstGeom := new PrstGeomUnitDecorator(object_.XmlChildPrstGeom); {self.}XmlChildPrstGeom := new PrstGeomUnitDecorator(object_.XmlChildPrstGeom);
if not ifnil(object_.XmlChildNoFill) then if not ifnil(object_.XmlChildNoFill) then
{self.}NoFill.Copy(object_.XmlChildNoFill); {self.}XmlChildNoFill.Copy(object_.XmlChildNoFill);
if not ifnil(object_.XmlChildSolidFill) then if not ifnil(object_.XmlChildSolidFill) then
{self.}XmlChildSolidFill := new SolidFillUnitDecorator(object_.XmlChildSolidFill); {self.}XmlChildSolidFill := new SolidFillUnitDecorator(object_.XmlChildSolidFill);
if not ifnil(object_.XmlChildLn) then if not ifnil(object_.XmlChildLn) then
@ -3008,7 +3008,7 @@ begin
if not ifnil(object_.XmlAttrAlgn) then if not ifnil(object_.XmlAttrAlgn) then
{self.}Algn := object_.XmlAttrAlgn.Value; {self.}Algn := object_.XmlAttrAlgn.Value;
if not ifnil(object_.XmlChildNoFill) then if not ifnil(object_.XmlChildNoFill) then
{self.}NoFill.Copy(object_.XmlChildNoFill); {self.}XmlChildNoFill.Copy(object_.XmlChildNoFill);
if not ifnil(object_.XmlChildSolidFill) then if not ifnil(object_.XmlChildSolidFill) then
{self.}XmlChildSolidFill := new SolidFillUnitDecorator(object_.XmlChildSolidFill); {self.}XmlChildSolidFill := new SolidFillUnitDecorator(object_.XmlChildSolidFill);
if not ifnil(object_.XmlChildPrstDash) then if not ifnil(object_.XmlChildPrstDash) then
@ -3016,9 +3016,9 @@ begin
if not ifnil(object_.XmlChildMiter) then if not ifnil(object_.XmlChildMiter) then
{self.}XmlChildMiter := new MiterUnitDecorator(object_.XmlChildMiter); {self.}XmlChildMiter := new MiterUnitDecorator(object_.XmlChildMiter);
if not ifnil(object_.XmlChildHeadEnd) then if not ifnil(object_.XmlChildHeadEnd) then
{self.}HeadEnd.Copy(object_.XmlChildHeadEnd); {self.}XmlChildHeadEnd.Copy(object_.XmlChildHeadEnd);
if not ifnil(object_.XmlChildTailEnd) then if not ifnil(object_.XmlChildTailEnd) then
{self.}TailEnd.Copy(object_.XmlChildTailEnd); {self.}XmlChildTailEnd.Copy(object_.XmlChildTailEnd);
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
@ -3194,7 +3194,7 @@ begin
if not ifnil(object_.XmlChildEffectExtent) then if not ifnil(object_.XmlChildEffectExtent) then
{self.}XmlChildEffectExtent := new EffectExtentUnitDecorator(object_.XmlChildEffectExtent); {self.}XmlChildEffectExtent := new EffectExtentUnitDecorator(object_.XmlChildEffectExtent);
if not ifnil(object_.XmlChildWrapNone) then if not ifnil(object_.XmlChildWrapNone) then
{self.}WrapNone.Copy(object_.XmlChildWrapNone); {self.}XmlChildWrapNone.Copy(object_.XmlChildWrapNone);
if not ifnil(object_.XmlChildDocPr) then if not ifnil(object_.XmlChildDocPr) then
{self.}XmlChildDocPr := new DocPrUnitDecorator(object_.XmlChildDocPr); {self.}XmlChildDocPr := new DocPrUnitDecorator(object_.XmlChildDocPr);
if not ifnil(object_.XmlChildCNvGraphicFramePr) then if not ifnil(object_.XmlChildCNvGraphicFramePr) then

122
autounit/PptxML.tsf Normal file
View File

@ -0,0 +1,122 @@
unit PptxML;
interface
type SldLayoutId = class(OpenXmlCompositeElement)
public
function Create();overload;
function Create(_node: XmlNode);overload;
function Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
function Init();override;
function Copy(_obj: SldLayoutId);override;
public
// attributes property
property Id read ReadXmlAttrId write WriteXmlAttrId;
property Id read ReadXmlAttrId write WriteXmlAttrId;
property Id read ReadXmlAttrId write WriteXmlAttrId;
function ReadXmlAttrId();
function WriteXmlAttrId(_value);
function ReadXmlAttrId();
function WriteXmlAttrId(_value);
function ReadXmlAttrId();
function WriteXmlAttrId(_value);
public
// Attributes
XmlAttrId: OpenXmlAttribute;
XmlAttrId: OpenXmlAttribute;
XmlAttrId: OpenXmlAttribute;
end;
implementation
function SldLayoutId.Create();overload;
begin
{self.}Create(nil, "p", "sldLayoutId");
end;
function SldLayoutId.Create(_node: XmlNode);overload;
begin
class(OpenXmlCompositeElement).Create(_node: XmlNode);
end;
function SldLayoutId.Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
begin
setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200);
class(OpenXmlCompositeElement).Create(_parent, _prefix, _local_name);
end;
function SldLayoutId.Init();override;
begin
pre := {self.}Prefix ? {self.}Prefix + ":" : "";
attributes_ := array();
attributes_pf_ := array(
pre + "id": makeweakref(thisFunction(WriteXmlAttrId)),
"id": makeweakref(thisFunction(WriteXmlAttrId)),
"r:id": makeweakref(thisFunction(WriteXmlAttrId)),
);
sorted_child_ := array(
);
container_ := new TSOfficeContainer(sorted_child_);
end;
function SldLayoutId.Copy(_obj: SldLayoutId);override;
begin
tslassigning_backup := tslassigning;
tslassigning := 1;
class(OpenXmlCompositeElement).Copy(_obj);
if not ifnil(_obj.Id) then
{self.}Id := _obj.Id;
if not ifnil(_obj.Id) then
{self.}Id := _obj.Id;
if not ifnil(_obj.Id) then
{self.}Id := _obj.Id;
tslassigning := tslassigning_backup;
end;
function SldLayoutId.ReadXmlAttrId();
begin
return {self.}XmlAttrId.Value;
end;
function SldLayoutId.WriteXmlAttrId(_value);
begin
if ifnil({self.}XmlAttrId) then
begin
{self.}XmlAttrId := new OpenXmlAttribute({self.}Prefix, "id", nil);
attributes_[length(attributes_)] := {self.}XmlAttrId;
end
{self.}XmlAttrId.Value := _value;
end;
function SldLayoutId.ReadXmlAttrId();
begin
return {self.}XmlAttrId.Value;
end;
function SldLayoutId.WriteXmlAttrId(_value);
begin
if ifnil({self.}XmlAttrId) then
begin
{self.}XmlAttrId := new OpenXmlAttribute("", "id", nil);
attributes_[length(attributes_)] := {self.}XmlAttrId;
end
{self.}XmlAttrId.Value := _value;
end;
function SldLayoutId.ReadXmlAttrId();
begin
return {self.}XmlAttrId.Value;
end;
function SldLayoutId.WriteXmlAttrId(_value);
begin
if ifnil({self.}XmlAttrId) then
begin
{self.}XmlAttrId := new OpenXmlAttribute("r", "id", nil);
attributes_[length(attributes_)] := {self.}XmlAttrId;
end
{self.}XmlAttrId.Value := _value;
end;
end.

View File

@ -0,0 +1,6 @@
unit PptxMLAdapter;
interface
implementation
end.

File diff suppressed because it is too large Load Diff

View File

@ -371,7 +371,7 @@ begin
if not ifnil(object_.XmlChildSmallFrac) then if not ifnil(object_.XmlChildSmallFrac) then
{self.}XmlChildSmallFrac := new PureMValUnitDecorator(object_.XmlChildSmallFrac); {self.}XmlChildSmallFrac := new PureMValUnitDecorator(object_.XmlChildSmallFrac);
if not ifnil(object_.XmlChildDispDef) then if not ifnil(object_.XmlChildDispDef) then
{self.}DispDef.Copy(object_.XmlChildDispDef); {self.}XmlChildDispDef.Copy(object_.XmlChildDispDef);
if not ifnil(object_.XmlChildLMargin) then if not ifnil(object_.XmlChildLMargin) then
{self.}XmlChildLMargin := new PureMValUnitDecorator(object_.XmlChildLMargin); {self.}XmlChildLMargin := new PureMValUnitDecorator(object_.XmlChildLMargin);
if not ifnil(object_.XmlChildRMargin) then if not ifnil(object_.XmlChildRMargin) then
@ -474,14 +474,18 @@ begin
elems := object_.Ds(); elems := object_.Ds();
for _,elem in elems do for _,elem in elems do
{self.}AppendChild(new DUnitDecorator(elem)); {self.}AppendChild(new DUnitDecorator(elem));
if not ifnil(object_.XmlChildF) then elems := object_.Fs();
{self.}XmlChildF := new FUnitDecorator(object_.XmlChildF); for _,elem in elems do
if not ifnil(object_.XmlChildRad) then {self.}AppendChild(new FUnitDecorator(elem));
{self.}XmlChildRad := new RadUnitDecorator(object_.XmlChildRad); elems := object_.Rads();
if not ifnil(object_.XmlChildSSub) then for _,elem in elems do
{self.}XmlChildSSub := new SSubUnitDecorator(object_.XmlChildSSub); {self.}AppendChild(new RadUnitDecorator(elem));
if not ifnil(object_.XmlChildNary) then elems := object_.SSubs();
{self.}XmlChildNary := new NaryUnitDecorator(object_.XmlChildNary); for _,elem in elems do
{self.}AppendChild(new SSubUnitDecorator(elem));
elems := object_.Naries();
for _,elem in elems do
{self.}AppendChild(new NaryUnitDecorator(elem));
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;

View File

@ -2,7 +2,7 @@ unit VML;
interface interface
uses DocxML; uses DocxML;
type Shapetype = class(OpenXmlElement) type Shapetype = class(OpenXmlCompositeElement)
public public
function Create();overload; function Create();overload;
function Create(_node: XmlNode);overload; function Create(_node: XmlNode);overload;
@ -74,7 +74,7 @@ public
XmlChildLock: Lock; XmlChildLock: Lock;
end; end;
type Formulas = class(OpenXmlElement) type Formulas = class(OpenXmlCompositeElement)
public public
function Create();overload; function Create();overload;
function Create(_node: XmlNode);overload; function Create(_node: XmlNode);overload;
@ -93,7 +93,7 @@ public
// Children // Children
end; end;
type Lock = class(OpenXmlElement) type Lock = class(OpenXmlCompositeElement)
public public
function Create();overload; function Create();overload;
function Create(_node: XmlNode);overload; function Create(_node: XmlNode);overload;
@ -116,7 +116,7 @@ public
end; end;
type F = class(OpenXmlElement) type F = class(OpenXmlCompositeElement)
public public
function Create();overload; function Create();overload;
function Create(_node: XmlNode);overload; function Create(_node: XmlNode);overload;
@ -135,7 +135,7 @@ public
end; end;
type Stroke = class(OpenXmlElement) type Stroke = class(OpenXmlCompositeElement)
public public
function Create();overload; function Create();overload;
function Create(_node: XmlNode);overload; function Create(_node: XmlNode);overload;
@ -154,7 +154,7 @@ public
end; end;
type Path = class(OpenXmlElement) type Path = class(OpenXmlCompositeElement)
public public
function Create();overload; function Create();overload;
function Create(_node: XmlNode);overload; function Create(_node: XmlNode);overload;
@ -193,7 +193,7 @@ public
end; end;
type Textpath = class(OpenXmlElement) type Textpath = class(OpenXmlCompositeElement)
public public
function Create();overload; function Create();overload;
function Create(_node: XmlNode);overload; function Create(_node: XmlNode);overload;
@ -224,7 +224,7 @@ public
end; end;
type Handles = class(OpenXmlElement) type Handles = class(OpenXmlCompositeElement)
public public
function Create();overload; function Create();overload;
function Create(_node: XmlNode);overload; function Create(_node: XmlNode);overload;
@ -242,7 +242,7 @@ public
XmlChildH: H; XmlChildH: H;
end; end;
type H = class(OpenXmlElement) type H = class(OpenXmlCompositeElement)
public public
function Create();overload; function Create();overload;
function Create(_node: XmlNode);overload; function Create(_node: XmlNode);overload;
@ -265,7 +265,7 @@ public
end; end;
type Shape = class(OpenXmlElement) type Shape = class(OpenXmlCompositeElement)
public public
function Create();overload; function Create();overload;
function Create(_node: XmlNode);overload; function Create(_node: XmlNode);overload;
@ -338,7 +338,7 @@ public
XmlChildWrap: Wrap; XmlChildWrap: Wrap;
end; end;
type Wrap = class(OpenXmlElement) type Wrap = class(OpenXmlCompositeElement)
public public
function Create();overload; function Create();overload;
function Create(_node: XmlNode);overload; function Create(_node: XmlNode);overload;
@ -361,7 +361,7 @@ public
end; end;
type Fill = class(OpenXmlElement) type Fill = class(OpenXmlCompositeElement)
public public
function Create();overload; function Create();overload;
function Create(_node: XmlNode);overload; function Create(_node: XmlNode);overload;
@ -380,7 +380,7 @@ public
end; end;
type Imagedata = class(OpenXmlElement) type Imagedata = class(OpenXmlCompositeElement)
public public
function Create();overload; function Create();overload;
function Create(_node: XmlNode);overload; function Create(_node: XmlNode);overload;
@ -403,7 +403,7 @@ public
end; end;
type Textbox = class(OpenXmlElement) type Textbox = class(OpenXmlCompositeElement)
public public
function Create();overload; function Create();overload;
function Create(_node: XmlNode);overload; function Create(_node: XmlNode);overload;
@ -421,7 +421,7 @@ public
XmlChildTxbxContent: TxbxContent; XmlChildTxbxContent: TxbxContent;
end; end;
type OLEObject = class(OpenXmlElement) type OLEObject = class(OpenXmlCompositeElement)
public public
function Create();overload; function Create();overload;
function Create(_node: XmlNode);overload; function Create(_node: XmlNode);overload;
@ -469,13 +469,13 @@ end;
function Shapetype.Create(_node: XmlNode);overload; function Shapetype.Create(_node: XmlNode);overload;
begin begin
class(OpenXmlElement).Create(_node: XmlNode); class(OpenXmlCompositeElement).Create(_node: XmlNode);
end; end;
function Shapetype.Create(_parent: tslobj; _prefix: string; _local_name: string);overload; function Shapetype.Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
begin begin
setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200); setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200);
class(OpenXmlElement).Create(_parent, _prefix, _local_name); class(OpenXmlCompositeElement).Create(_parent, _prefix, _local_name);
end; end;
function Shapetype.Init();override; function Shapetype.Init();override;
@ -508,7 +508,7 @@ function Shapetype.Copy(_obj: Shapetype);override;
begin begin
tslassigning_backup := tslassigning; tslassigning_backup := tslassigning;
tslassigning := 1; tslassigning := 1;
class(OpenXmlElement).Copy(_obj); class(OpenXmlCompositeElement).Copy(_obj);
if not ifnil(_obj.AnchorId) then if not ifnil(_obj.AnchorId) then
{self.}AnchorId := _obj.AnchorId; {self.}AnchorId := _obj.AnchorId;
if not ifnil(_obj.Id) then if not ifnil(_obj.Id) then
@ -679,7 +679,7 @@ end;
function Shapetype.ReadXmlChildStroke(): Stroke; function Shapetype.ReadXmlChildStroke(): Stroke;
begin begin
if tslassigning and ifnil({self.}XmlChildStroke) then if tslassigning and (ifnil({self.}XmlChildStroke) or {self.}XmlChildStroke.Removed) then
begin begin
{self.}XmlChildStroke := new Stroke(self, {self.}Prefix, "stroke"); {self.}XmlChildStroke := new Stroke(self, {self.}Prefix, "stroke");
container_.Set({self.}XmlChildStroke); container_.Set({self.}XmlChildStroke);
@ -689,7 +689,7 @@ end;
function Shapetype.ReadXmlChildFormulas(): formulas; function Shapetype.ReadXmlChildFormulas(): formulas;
begin begin
if tslassigning and ifnil({self.}XmlChildFormulas) then if tslassigning and (ifnil({self.}XmlChildFormulas) or {self.}XmlChildFormulas.Removed) then
begin begin
{self.}XmlChildFormulas := new formulas(self, {self.}Prefix, "formulas"); {self.}XmlChildFormulas := new formulas(self, {self.}Prefix, "formulas");
container_.Set({self.}XmlChildFormulas); container_.Set({self.}XmlChildFormulas);
@ -699,7 +699,7 @@ end;
function Shapetype.ReadXmlChildPath(): Path; function Shapetype.ReadXmlChildPath(): Path;
begin begin
if tslassigning and ifnil({self.}XmlChildPath) then if tslassigning and (ifnil({self.}XmlChildPath) or {self.}XmlChildPath.Removed) then
begin begin
{self.}XmlChildPath := new Path(self, {self.}Prefix, "path"); {self.}XmlChildPath := new Path(self, {self.}Prefix, "path");
container_.Set({self.}XmlChildPath); container_.Set({self.}XmlChildPath);
@ -709,7 +709,7 @@ end;
function Shapetype.ReadXmlChildTextpath(): Textpath; function Shapetype.ReadXmlChildTextpath(): Textpath;
begin begin
if tslassigning and ifnil({self.}XmlChildTextpath) then if tslassigning and (ifnil({self.}XmlChildTextpath) or {self.}XmlChildTextpath.Removed) then
begin begin
{self.}XmlChildTextpath := new Textpath(self, {self.}Prefix, "textpath"); {self.}XmlChildTextpath := new Textpath(self, {self.}Prefix, "textpath");
container_.Set({self.}XmlChildTextpath); container_.Set({self.}XmlChildTextpath);
@ -719,7 +719,7 @@ end;
function Shapetype.ReadXmlChildHandles(): Handles; function Shapetype.ReadXmlChildHandles(): Handles;
begin begin
if tslassigning and ifnil({self.}XmlChildHandles) then if tslassigning and (ifnil({self.}XmlChildHandles) or {self.}XmlChildHandles.Removed) then
begin begin
{self.}XmlChildHandles := new Handles(self, {self.}Prefix, "handles"); {self.}XmlChildHandles := new Handles(self, {self.}Prefix, "handles");
container_.Set({self.}XmlChildHandles); container_.Set({self.}XmlChildHandles);
@ -729,7 +729,7 @@ end;
function Shapetype.ReadXmlChildLock(): Lock; function Shapetype.ReadXmlChildLock(): Lock;
begin begin
if tslassigning and ifnil({self.}XmlChildLock) then if tslassigning and (ifnil({self.}XmlChildLock) or {self.}XmlChildLock.Removed) then
begin begin
{self.}XmlChildLock := new Lock(self, "o", "lock"); {self.}XmlChildLock := new Lock(self, "o", "lock");
container_.Set({self.}XmlChildLock); container_.Set({self.}XmlChildLock);
@ -744,13 +744,13 @@ end;
function Formulas.Create(_node: XmlNode);overload; function Formulas.Create(_node: XmlNode);overload;
begin begin
class(OpenXmlElement).Create(_node: XmlNode); class(OpenXmlCompositeElement).Create(_node: XmlNode);
end; end;
function Formulas.Create(_parent: tslobj; _prefix: string; _local_name: string);overload; function Formulas.Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
begin begin
setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200); setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200);
class(OpenXmlElement).Create(_parent, _prefix, _local_name); class(OpenXmlCompositeElement).Create(_parent, _prefix, _local_name);
end; end;
function Formulas.Init();override; function Formulas.Init();override;
@ -769,7 +769,7 @@ function Formulas.Copy(_obj: Formulas);override;
begin begin
tslassigning_backup := tslassigning; tslassigning_backup := tslassigning;
tslassigning := 1; tslassigning := 1;
class(OpenXmlElement).Copy(_obj); class(OpenXmlCompositeElement).Copy(_obj);
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
@ -801,13 +801,13 @@ end;
function Lock.Create(_node: XmlNode);overload; function Lock.Create(_node: XmlNode);overload;
begin begin
class(OpenXmlElement).Create(_node: XmlNode); class(OpenXmlCompositeElement).Create(_node: XmlNode);
end; end;
function Lock.Create(_parent: tslobj; _prefix: string; _local_name: string);overload; function Lock.Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
begin begin
setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200); setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200);
class(OpenXmlElement).Create(_parent, _prefix, _local_name); class(OpenXmlCompositeElement).Create(_parent, _prefix, _local_name);
end; end;
function Lock.Init();override; function Lock.Init();override;
@ -827,7 +827,7 @@ function Lock.Copy(_obj: Lock);override;
begin begin
tslassigning_backup := tslassigning; tslassigning_backup := tslassigning;
tslassigning := 1; tslassigning := 1;
class(OpenXmlElement).Copy(_obj); class(OpenXmlCompositeElement).Copy(_obj);
if not ifnil(_obj.Ext) then if not ifnil(_obj.Ext) then
{self.}Ext := _obj.Ext; {self.}Ext := _obj.Ext;
if not ifnil(_obj.Aspectration) then if not ifnil(_obj.Aspectration) then
@ -872,13 +872,13 @@ end;
function F.Create(_node: XmlNode);overload; function F.Create(_node: XmlNode);overload;
begin begin
class(OpenXmlElement).Create(_node: XmlNode); class(OpenXmlCompositeElement).Create(_node: XmlNode);
end; end;
function F.Create(_parent: tslobj; _prefix: string; _local_name: string);overload; function F.Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
begin begin
setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200); setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200);
class(OpenXmlElement).Create(_parent, _prefix, _local_name); class(OpenXmlCompositeElement).Create(_parent, _prefix, _local_name);
end; end;
function F.Init();override; function F.Init();override;
@ -897,7 +897,7 @@ function F.Copy(_obj: F);override;
begin begin
tslassigning_backup := tslassigning; tslassigning_backup := tslassigning;
tslassigning := 1; tslassigning := 1;
class(OpenXmlElement).Copy(_obj); class(OpenXmlCompositeElement).Copy(_obj);
if not ifnil(_obj.Eqn) then if not ifnil(_obj.Eqn) then
{self.}Eqn := _obj.Eqn; {self.}Eqn := _obj.Eqn;
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
@ -925,13 +925,13 @@ end;
function Stroke.Create(_node: XmlNode);overload; function Stroke.Create(_node: XmlNode);overload;
begin begin
class(OpenXmlElement).Create(_node: XmlNode); class(OpenXmlCompositeElement).Create(_node: XmlNode);
end; end;
function Stroke.Create(_parent: tslobj; _prefix: string; _local_name: string);overload; function Stroke.Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
begin begin
setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200); setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200);
class(OpenXmlElement).Create(_parent, _prefix, _local_name); class(OpenXmlCompositeElement).Create(_parent, _prefix, _local_name);
end; end;
function Stroke.Init();override; function Stroke.Init();override;
@ -950,7 +950,7 @@ function Stroke.Copy(_obj: Stroke);override;
begin begin
tslassigning_backup := tslassigning; tslassigning_backup := tslassigning;
tslassigning := 1; tslassigning := 1;
class(OpenXmlElement).Copy(_obj); class(OpenXmlCompositeElement).Copy(_obj);
if not ifnil(_obj.Joinstyle) then if not ifnil(_obj.Joinstyle) then
{self.}Joinstyle := _obj.Joinstyle; {self.}Joinstyle := _obj.Joinstyle;
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
@ -978,13 +978,13 @@ end;
function Path.Create(_node: XmlNode);overload; function Path.Create(_node: XmlNode);overload;
begin begin
class(OpenXmlElement).Create(_node: XmlNode); class(OpenXmlCompositeElement).Create(_node: XmlNode);
end; end;
function Path.Create(_parent: tslobj; _prefix: string; _local_name: string);overload; function Path.Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
begin begin
setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200); setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200);
class(OpenXmlElement).Create(_parent, _prefix, _local_name); class(OpenXmlCompositeElement).Create(_parent, _prefix, _local_name);
end; end;
function Path.Init();override; function Path.Init();override;
@ -1008,7 +1008,7 @@ function Path.Copy(_obj: Path);override;
begin begin
tslassigning_backup := tslassigning; tslassigning_backup := tslassigning;
tslassigning := 1; tslassigning := 1;
class(OpenXmlElement).Copy(_obj); class(OpenXmlCompositeElement).Copy(_obj);
if not ifnil(_obj.Extrusionok) then if not ifnil(_obj.Extrusionok) then
{self.}Extrusionok := _obj.Extrusionok; {self.}Extrusionok := _obj.Extrusionok;
if not ifnil(_obj.Textpathok) then if not ifnil(_obj.Textpathok) then
@ -1121,13 +1121,13 @@ end;
function Textpath.Create(_node: XmlNode);overload; function Textpath.Create(_node: XmlNode);overload;
begin begin
class(OpenXmlElement).Create(_node: XmlNode); class(OpenXmlCompositeElement).Create(_node: XmlNode);
end; end;
function Textpath.Create(_parent: tslobj; _prefix: string; _local_name: string);overload; function Textpath.Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
begin begin
setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200); setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200);
class(OpenXmlElement).Create(_parent, _prefix, _local_name); class(OpenXmlCompositeElement).Create(_parent, _prefix, _local_name);
end; end;
function Textpath.Init();override; function Textpath.Init();override;
@ -1149,7 +1149,7 @@ function Textpath.Copy(_obj: Textpath);override;
begin begin
tslassigning_backup := tslassigning; tslassigning_backup := tslassigning;
tslassigning := 1; tslassigning := 1;
class(OpenXmlElement).Copy(_obj); class(OpenXmlCompositeElement).Copy(_obj);
if not ifnil(_obj._On) then if not ifnil(_obj._On) then
{self.}_On := _obj._On; {self.}_On := _obj._On;
if not ifnil(_obj.Fitshape) then if not ifnil(_obj.Fitshape) then
@ -1228,13 +1228,13 @@ end;
function Handles.Create(_node: XmlNode);overload; function Handles.Create(_node: XmlNode);overload;
begin begin
class(OpenXmlElement).Create(_node: XmlNode); class(OpenXmlCompositeElement).Create(_node: XmlNode);
end; end;
function Handles.Create(_parent: tslobj; _prefix: string; _local_name: string);overload; function Handles.Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
begin begin
setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200); setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200);
class(OpenXmlElement).Create(_parent, _prefix, _local_name); class(OpenXmlCompositeElement).Create(_parent, _prefix, _local_name);
end; end;
function Handles.Init();override; function Handles.Init();override;
@ -1253,7 +1253,7 @@ function Handles.Copy(_obj: Handles);override;
begin begin
tslassigning_backup := tslassigning; tslassigning_backup := tslassigning;
tslassigning := 1; tslassigning := 1;
class(OpenXmlElement).Copy(_obj); class(OpenXmlCompositeElement).Copy(_obj);
if not ifnil(_obj.XmlChildH) then if not ifnil(_obj.XmlChildH) then
{self.}H.Copy(_obj.XmlChildH); {self.}H.Copy(_obj.XmlChildH);
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
@ -1261,7 +1261,7 @@ end;
function Handles.ReadXmlChildH(): H; function Handles.ReadXmlChildH(): H;
begin begin
if tslassigning and ifnil({self.}XmlChildH) then if tslassigning and (ifnil({self.}XmlChildH) or {self.}XmlChildH.Removed) then
begin begin
{self.}XmlChildH := new H(self, {self.}Prefix, "h"); {self.}XmlChildH := new H(self, {self.}Prefix, "h");
container_.Set({self.}XmlChildH); container_.Set({self.}XmlChildH);
@ -1276,13 +1276,13 @@ end;
function H.Create(_node: XmlNode);overload; function H.Create(_node: XmlNode);overload;
begin begin
class(OpenXmlElement).Create(_node: XmlNode); class(OpenXmlCompositeElement).Create(_node: XmlNode);
end; end;
function H.Create(_parent: tslobj; _prefix: string; _local_name: string);overload; function H.Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
begin begin
setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200); setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200);
class(OpenXmlElement).Create(_parent, _prefix, _local_name); class(OpenXmlCompositeElement).Create(_parent, _prefix, _local_name);
end; end;
function H.Init();override; function H.Init();override;
@ -1302,7 +1302,7 @@ function H.Copy(_obj: H);override;
begin begin
tslassigning_backup := tslassigning; tslassigning_backup := tslassigning;
tslassigning := 1; tslassigning := 1;
class(OpenXmlElement).Copy(_obj); class(OpenXmlCompositeElement).Copy(_obj);
if not ifnil(_obj.Xrange) then if not ifnil(_obj.Xrange) then
{self.}Xrange := _obj.Xrange; {self.}Xrange := _obj.Xrange;
if not ifnil(_obj.Position) then if not ifnil(_obj.Position) then
@ -1347,13 +1347,13 @@ end;
function Shape.Create(_node: XmlNode);overload; function Shape.Create(_node: XmlNode);overload;
begin begin
class(OpenXmlElement).Create(_node: XmlNode); class(OpenXmlCompositeElement).Create(_node: XmlNode);
end; end;
function Shape.Create(_parent: tslobj; _prefix: string; _local_name: string);overload; function Shape.Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
begin begin
setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200); setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200);
class(OpenXmlElement).Create(_parent, _prefix, _local_name); class(OpenXmlCompositeElement).Create(_parent, _prefix, _local_name);
end; end;
function Shape.Init();override; function Shape.Init();override;
@ -1386,7 +1386,7 @@ function Shape.Copy(_obj: Shape);override;
begin begin
tslassigning_backup := tslassigning; tslassigning_backup := tslassigning;
tslassigning := 1; tslassigning := 1;
class(OpenXmlElement).Copy(_obj); class(OpenXmlCompositeElement).Copy(_obj);
if not ifnil(_obj.Id) then if not ifnil(_obj.Id) then
{self.}Id := _obj.Id; {self.}Id := _obj.Id;
if not ifnil(_obj.Style) then if not ifnil(_obj.Style) then
@ -1572,7 +1572,7 @@ end;
function Shape.ReadXmlChildFill(): Fill; function Shape.ReadXmlChildFill(): Fill;
begin begin
if tslassigning and ifnil({self.}XmlChildFill) then if tslassigning and (ifnil({self.}XmlChildFill) or {self.}XmlChildFill.Removed) then
begin begin
{self.}XmlChildFill := new Fill(self, {self.}Prefix, "fill"); {self.}XmlChildFill := new Fill(self, {self.}Prefix, "fill");
container_.Set({self.}XmlChildFill); container_.Set({self.}XmlChildFill);
@ -1582,7 +1582,7 @@ end;
function Shape.ReadXmlChildTextbox(): Textbox; function Shape.ReadXmlChildTextbox(): Textbox;
begin begin
if tslassigning and ifnil({self.}XmlChildTextbox) then if tslassigning and (ifnil({self.}XmlChildTextbox) or {self.}XmlChildTextbox.Removed) then
begin begin
{self.}XmlChildTextbox := new Textbox(self, {self.}Prefix, "textbox"); {self.}XmlChildTextbox := new Textbox(self, {self.}Prefix, "textbox");
container_.Set({self.}XmlChildTextbox); container_.Set({self.}XmlChildTextbox);
@ -1592,7 +1592,7 @@ end;
function Shape.ReadXmlChildTextpath(): Textpath; function Shape.ReadXmlChildTextpath(): Textpath;
begin begin
if tslassigning and ifnil({self.}XmlChildTextpath) then if tslassigning and (ifnil({self.}XmlChildTextpath) or {self.}XmlChildTextpath.Removed) then
begin begin
{self.}XmlChildTextpath := new Textpath(self, {self.}Prefix, "textpath"); {self.}XmlChildTextpath := new Textpath(self, {self.}Prefix, "textpath");
container_.Set({self.}XmlChildTextpath); container_.Set({self.}XmlChildTextpath);
@ -1602,7 +1602,7 @@ end;
function Shape.ReadXmlChildImagedata(): Imagedata; function Shape.ReadXmlChildImagedata(): Imagedata;
begin begin
if tslassigning and ifnil({self.}XmlChildImagedata) then if tslassigning and (ifnil({self.}XmlChildImagedata) or {self.}XmlChildImagedata.Removed) then
begin begin
{self.}XmlChildImagedata := new Imagedata(self, {self.}Prefix, "imagedata"); {self.}XmlChildImagedata := new Imagedata(self, {self.}Prefix, "imagedata");
container_.Set({self.}XmlChildImagedata); container_.Set({self.}XmlChildImagedata);
@ -1612,7 +1612,7 @@ end;
function Shape.ReadXmlChildWrap(): Wrap; function Shape.ReadXmlChildWrap(): Wrap;
begin begin
if tslassigning and ifnil({self.}XmlChildWrap) then if tslassigning and (ifnil({self.}XmlChildWrap) or {self.}XmlChildWrap.Removed) then
begin begin
{self.}XmlChildWrap := new Wrap(self, "w10", "wrap"); {self.}XmlChildWrap := new Wrap(self, "w10", "wrap");
container_.Set({self.}XmlChildWrap); container_.Set({self.}XmlChildWrap);
@ -1627,13 +1627,13 @@ end;
function Wrap.Create(_node: XmlNode);overload; function Wrap.Create(_node: XmlNode);overload;
begin begin
class(OpenXmlElement).Create(_node: XmlNode); class(OpenXmlCompositeElement).Create(_node: XmlNode);
end; end;
function Wrap.Create(_parent: tslobj; _prefix: string; _local_name: string);overload; function Wrap.Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
begin begin
setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200); setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200);
class(OpenXmlElement).Create(_parent, _prefix, _local_name); class(OpenXmlCompositeElement).Create(_parent, _prefix, _local_name);
end; end;
function Wrap.Init();override; function Wrap.Init();override;
@ -1653,7 +1653,7 @@ function Wrap.Copy(_obj: Wrap);override;
begin begin
tslassigning_backup := tslassigning; tslassigning_backup := tslassigning;
tslassigning := 1; tslassigning := 1;
class(OpenXmlElement).Copy(_obj); class(OpenXmlCompositeElement).Copy(_obj);
if not ifnil(_obj.Anchorx) then if not ifnil(_obj.Anchorx) then
{self.}Anchorx := _obj.Anchorx; {self.}Anchorx := _obj.Anchorx;
if not ifnil(_obj.Anchory) then if not ifnil(_obj.Anchory) then
@ -1698,13 +1698,13 @@ end;
function Fill.Create(_node: XmlNode);overload; function Fill.Create(_node: XmlNode);overload;
begin begin
class(OpenXmlElement).Create(_node: XmlNode); class(OpenXmlCompositeElement).Create(_node: XmlNode);
end; end;
function Fill.Create(_parent: tslobj; _prefix: string; _local_name: string);overload; function Fill.Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
begin begin
setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200); setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200);
class(OpenXmlElement).Create(_parent, _prefix, _local_name); class(OpenXmlCompositeElement).Create(_parent, _prefix, _local_name);
end; end;
function Fill.Init();override; function Fill.Init();override;
@ -1723,7 +1723,7 @@ function Fill.Copy(_obj: Fill);override;
begin begin
tslassigning_backup := tslassigning; tslassigning_backup := tslassigning;
tslassigning := 1; tslassigning := 1;
class(OpenXmlElement).Copy(_obj); class(OpenXmlCompositeElement).Copy(_obj);
if not ifnil(_obj.Opacity) then if not ifnil(_obj.Opacity) then
{self.}Opacity := _obj.Opacity; {self.}Opacity := _obj.Opacity;
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
@ -1751,13 +1751,13 @@ end;
function Imagedata.Create(_node: XmlNode);overload; function Imagedata.Create(_node: XmlNode);overload;
begin begin
class(OpenXmlElement).Create(_node: XmlNode); class(OpenXmlCompositeElement).Create(_node: XmlNode);
end; end;
function Imagedata.Create(_parent: tslobj; _prefix: string; _local_name: string);overload; function Imagedata.Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
begin begin
setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200); setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200);
class(OpenXmlElement).Create(_parent, _prefix, _local_name); class(OpenXmlCompositeElement).Create(_parent, _prefix, _local_name);
end; end;
function Imagedata.Init();override; function Imagedata.Init();override;
@ -1777,7 +1777,7 @@ function Imagedata.Copy(_obj: Imagedata);override;
begin begin
tslassigning_backup := tslassigning; tslassigning_backup := tslassigning;
tslassigning := 1; tslassigning := 1;
class(OpenXmlElement).Copy(_obj); class(OpenXmlCompositeElement).Copy(_obj);
if not ifnil(_obj.Id) then if not ifnil(_obj.Id) then
{self.}Id := _obj.Id; {self.}Id := _obj.Id;
if not ifnil(_obj.Title) then if not ifnil(_obj.Title) then
@ -1822,13 +1822,13 @@ end;
function Textbox.Create(_node: XmlNode);overload; function Textbox.Create(_node: XmlNode);overload;
begin begin
class(OpenXmlElement).Create(_node: XmlNode); class(OpenXmlCompositeElement).Create(_node: XmlNode);
end; end;
function Textbox.Create(_parent: tslobj; _prefix: string; _local_name: string);overload; function Textbox.Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
begin begin
setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200); setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200);
class(OpenXmlElement).Create(_parent, _prefix, _local_name); class(OpenXmlCompositeElement).Create(_parent, _prefix, _local_name);
end; end;
function Textbox.Init();override; function Textbox.Init();override;
@ -1847,7 +1847,7 @@ function Textbox.Copy(_obj: Textbox);override;
begin begin
tslassigning_backup := tslassigning; tslassigning_backup := tslassigning;
tslassigning := 1; tslassigning := 1;
class(OpenXmlElement).Copy(_obj); class(OpenXmlCompositeElement).Copy(_obj);
if not ifnil(_obj.XmlChildTxbxContent) then if not ifnil(_obj.XmlChildTxbxContent) then
{self.}TxbxContent.Copy(_obj.XmlChildTxbxContent); {self.}TxbxContent.Copy(_obj.XmlChildTxbxContent);
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
@ -1855,7 +1855,7 @@ end;
function Textbox.ReadXmlChildTxbxContent(): TxbxContent; function Textbox.ReadXmlChildTxbxContent(): TxbxContent;
begin begin
if tslassigning and ifnil({self.}XmlChildTxbxContent) then if tslassigning and (ifnil({self.}XmlChildTxbxContent) or {self.}XmlChildTxbxContent.Removed) then
begin begin
{self.}XmlChildTxbxContent := new DocxML.TxbxContent(self, "w", "txbxContent"); {self.}XmlChildTxbxContent := new DocxML.TxbxContent(self, "w", "txbxContent");
container_.Set({self.}XmlChildTxbxContent); container_.Set({self.}XmlChildTxbxContent);
@ -1870,13 +1870,13 @@ end;
function OLEObject.Create(_node: XmlNode);overload; function OLEObject.Create(_node: XmlNode);overload;
begin begin
class(OpenXmlElement).Create(_node: XmlNode); class(OpenXmlCompositeElement).Create(_node: XmlNode);
end; end;
function OLEObject.Create(_parent: tslobj; _prefix: string; _local_name: string);overload; function OLEObject.Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
begin begin
setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200); setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200);
class(OpenXmlElement).Create(_parent, _prefix, _local_name); class(OpenXmlCompositeElement).Create(_parent, _prefix, _local_name);
end; end;
function OLEObject.Init();override; function OLEObject.Init();override;
@ -1900,7 +1900,7 @@ function OLEObject.Copy(_obj: OLEObject);override;
begin begin
tslassigning_backup := tslassigning; tslassigning_backup := tslassigning;
tslassigning := 1; tslassigning := 1;
class(OpenXmlElement).Copy(_obj); class(OpenXmlCompositeElement).Copy(_obj);
if not ifnil(_obj.Type) then if not ifnil(_obj.Type) then
{self.}Type := _obj.Type; {self.}Type := _obj.Type;
if not ifnil(_obj.ProgID) then if not ifnil(_obj.ProgID) then

View File

@ -10,7 +10,6 @@ public
Prefix: string; Prefix: string;
ElementName: string; ElementName: string;
Value: any; Value: any;
end; end;
function OpenXmlAttribute.Create(_prefix: string; _local_name: string);overload; function OpenXmlAttribute.Create(_prefix: string; _local_name: string);overload;

View File

@ -0,0 +1,159 @@
type OpenXmlCompositeElement = class(OpenXmlElement)
public
function InitNode(_node: XmlNode);override;
function Deserialize();override;
function Serialize();override;
function Marshal(): tableArray;override;
public
function AppendChild(_element: OpenXmlElement);
function InsertAfter(_element: OpenXmlElement; _pos_element: OpenXmlElement);
function RemoveChild(_element: OpenXmlElement);
function RemoveAttribute(_attr: OpenXmlAttribute);
// function InsertBefore(_pos_obj: tslobj; _obj: tslobj);
// function PrependChild(_obj: tslobj);
// function SetAttribute(_obj: OpenXmlAttribute);
// function RemoveAttribute();
public
function GetOrCreateNode(_obj: tslobj);
end;
function OpenXmlCompositeElement.InitNode(_node: XmlNode);override;
begin
{self.}XmlNode := _node;
if not _node then return;
tslassigning_backup := tslassigning;
tslassigning := 1;
node := _node.FirstChild();
while ifObj(node) do
begin
node_name := node.GetName();
arr := sorted_child_[node_name];
if ifarray(arr) then
begin
pf := arr[1];
obj := pf.Do();
obj.InitNode(node);
end
node := node.NextElement();
end
tslassigning := tslassigning_backup;
end;
function OpenXmlCompositeElement.Deserialize();override;
begin
if not ifObj({self.}XmlNode) then return;
attrs := {self.}XmlNode.Attributes();
for k, v in attrs do
begin
pos := pos("xmlns", k);
if pos then
begin
xmlns_[k] := k = "xmlns" ? new OpenXmlAttribute("", "xmlns", v) : new OpenXmlattribute("xmlns", k[pos+6:], v);
continue;
end
pf := attributes_pf_[k];
if ifnil(pf) then continue;
pf.Do(v);
end
child_elements := container_.GetElements();
for k, v in child_elements do
v.Deserialize();
end;
function OpenXmlCompositeElement.Serialize();override;
begin
if {self.}DeleteSelf() then return;
// xmlns
for k, v in xmlns_ do
{self.}GetNode().SetAttribute(v.ElementName, v.Value);
// Attributes
for k, v in attributes_ do
if not ifnil(v.Value) then
{self.}GetNode().SetAttribute(v.ElementName, v.Value);
else if {self.}XmlNode then
{self.}XmlNode.DeleteAttribute(v.ElementName);
// Children
child_elements := container_.GetElements();
for k, v in child_elements do
v.Serialize();
end;
function OpenXmlCompositeElement.Marshal(): tableArray;override;
begin
child_elements := container_.GetElements(false);
child_arr := array();
for k, v in child_elements do
begin
arr := array("type": "element", "name": v.ElementName, "attributes": array());
if v is Class(OpenXmlTextElement) or v is Class(OpenXmlCompositeElement) then
begin
marshal := v.Marshal();
if length(marshal["children"]) = 0 and length(marshal["attributes"]) = 0 then continue;
arr["children"] := marshal["children"];
arr["attributes"] union= marshal["attributes"];
child_arr[length(child_arr)] := arr;
end
else if v is Class(OpenXmlSimpleType) then
begin
marshal := v.Marshal();
if length(marshal) > 0 then child_arr[length(child_arr)] := arr;
end
else begin
echo "error = marshal.\n";
end
end
tmp_arr := array("type": "element", "name": {self.}ElementName, "children": child_arr, "attributes": array());
for k,v in attributes_ do
begin
if not ifnil(v.Value) then tmp_arr["attributes"][v.ElementName] := v.Value;
end
return tmp_arr;
end;
function OpenXmlCompositeElement.GetOrCreateNode(_obj: tslobj);
begin
if not ifObj({self.}XmlNode) then {self.}XmlNode := {self.}Parent.GetOrCreateNode(self);
nearest_node := nil;
child_elements := container_.GetElements(false);
for k, v in child_elements do
begin
if ifObj(v.XmlNode) then nearest_node := v.XmlNode;
if v = _obj then
begin
if ifObj(v.XmlNode) then
return v.XmlNode;
if ifnil(nearest_node) then
return {self.}XmlNode.InsertFirstChild("element", _obj.ElementName);
else
return {self.}XmlNode.InsertAfterChild(nearest_node, "element", _obj.ElementName);
end
end
raise "No child.";
end;
function OpenXmlCompositeElement.AppendChild(_element: OpenXmlElement);
begin
container_.Append(_element);
end;
function OpenXmlCompositeElement.InsertAfter(_element: OpenXmlElement; _pos_element: OpenXmlElement);
begin
container_.InsertAfter(_element, _pos_element);
end;
function OpenXmlCompositeElement.RemoveChild(_element: OpenXmlElement);
begin
_element.Removed := true;
end;
function OpenXmlCompositeElement.RemoveAttribute(_attr: OpenXmlAttribute);
begin
_attr.Value := nil;
end;

View File

@ -5,23 +5,18 @@ public
function Init();virtual; function Init();virtual;
function InitNode(_node: XmlNode);virtual; function InitNode(_node: XmlNode);virtual;
function Copy(_obj: tslobj);virtual; function Copy(_obj: tslobj);virtual;
function Deserialize();virtual;
function Serialize();virtual;
function Marshal(): tableArray;virtual;
function Deserialize(); function Attribute(_attr: string; _ns: string): OpenXmlAttribute;
function Serialize();
function Marshal(): tableArray;
function GetOrCreateNode(_obj: tslobj);
function GetNode(): XmlNode;
function Elements(): array of tslobj;
function Attributes(): array of OpenXmlAttribute; function Attributes(): array of OpenXmlAttribute;
function Elements(): array of tslobj;
function Xmlns(_prefix: string): string; function Xmlns(_prefix: string): string;
public protected
function AppendChild(_obj: tslobj); // OpenXmlElement or OpenXmlPcdata function GetNode(): XmlNode;
function InsertAfter(_obj: tslobj; _pos_obj: tslobj); function DeleteSelf(): boolean;
// function InsertBefore(_pos_obj: tslobj; _obj: tslobj);
// function PrependChild(_obj: tslobj);
// function RemoveChild(_obj: tslobj);
// function SetAttribute(_obj: OpenXmlAttribute);
public public
LocalName: string; // 本地名称 LocalName: string; // 本地名称
@ -29,14 +24,14 @@ public
Prefix: string; // 前缀 Prefix: string; // 前缀
XmlNode: XmlNode; // XMLNode节点 XmlNode: XmlNode; // XMLNode节点
ElementName: string; ElementName: string;
Removed: boolean; // 节点删除标记最后Serialize时候统一删除
protected protected
attributes_: array of OpenXmlAttribute; // 属性 attributes_: array of OpenXmlAttribute; // 属性
attributes_pf_: tableArray; attributes_pf_: tableArray;
// child_elements_: array of tslobj; // 子节点元素 xmlns_: tableArray;
sorted_child_: tableArray; sorted_child_: tableArray;
container_: TSOfficeContainer; container_: TSOfficeContainer;
xmlns_: tableArray;
end; end;
function OpenXmlElement.Create(_node: XmlNode);overload; function OpenXmlElement.Create(_node: XmlNode);overload;
@ -46,7 +41,6 @@ begin
if pos then {self.}Create(nil, node_name[:pos-1], node_name[pos+1:]); if pos then {self.}Create(nil, node_name[:pos-1], node_name[pos+1:]);
else {self.}Create(nil, nil, node_name); else {self.}Create(nil, nil, node_name);
{self.}InitNode(_node); {self.}InitNode(_node);
xmlns_ := array();
end; end;
function OpenXmlElement.Create(_parent: tslobj; _prefix: string; _local_name: string);overload; function OpenXmlElement.Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
@ -56,122 +50,31 @@ begin
{self.}LocalName := _local_name; {self.}LocalName := _local_name;
{self.}XmlNode := nil; {self.}XmlNode := nil;
{self.}ElementName := ifString({self.}Prefix) and {self.}Prefix <> "" ? format("%s:%s", {self.}Prefix, {self.}LocalName) : {self.}LocalName; {self.}ElementName := ifString({self.}Prefix) and {self.}Prefix <> "" ? format("%s:%s", {self.}Prefix, {self.}LocalName) : {self.}LocalName;
{self.}Removed := false;
{self.}Init(); {self.}Init();
xmlns_ := array(); xmlns_ := array();
end; end;
function OpenXmlElement.InitNode(_node: XmlNode);virtual; function OpenXmlElement.Attribute(_attr: string; _ns: string): OpenXmlAttribute;
begin begin
{self.}XmlNode := _node; if ifnil(_ns) then
if not _node then return; attr_name := ifString({self.}Prefix) and {self.}Prefix <> "" ? format("%s:%%s", {self.}Prefix, _attr) : _attr;
tslassigning_backup := tslassigning; else
tslassigning := 1; attr_name := format("%s:%s", _ns, _attr);
node := _node.FirstChild(); return attributes_[attr_name];
while ifObj(node) do
begin
node_name := node.GetName();
arr := sorted_child_[node_name];
if ifarray(arr) then
begin
pf := arr[1];
obj := pf.Do();
obj.InitNode(node);
end
node := node.NextElement();
end
tslassigning := tslassigning_backup;
end; end;
function OpenXmlElement.GetOrCreateNode(_obj: tslobj); function OpenXmlElement.Attributes(): array of OpenXmlAttribute;
begin begin
if not ifObj({self.}XmlNode) then {self.}XmlNode := {self.}Parent.GetOrCreateNode(self); attrs := array();
nearest_node := nil;
child_elements := container_.Get();
for k, v in child_elements do
begin
if ifObj(v.XmlNode) then nearest_node := v.XmlNode;
if v = _obj then
begin
if ifObj(v.XmlNode) then return v.XmlNode;
if ifnil(nearest_node) then return {self.}XmlNode.InsertFirstChild("element", _obj.ElementName);
else return {self.}XmlNode.InsertAfterChild(nearest_node, "element", _obj.ElementName);
end
end
raise "No child.";
end;
function OpenXmlElement.GetNode(): XmlNode;
begin
if not ifObj({self.}XmlNode) then {self.}XmlNode := {self.}Parent.GetOrCreateNode(self);
return {self.}XmlNode;
end;
function OpenXmlElement.Deserialize();
begin
if not ifObj({self.}XmlNode) then return;
attrs := {self.}XmlNode.Attributes();
for k, v in attrs do
begin
pos := pos("xmlns", k);
if pos then
begin
xmlns_[k] := k = "xmlns" ? new OpenXmlAttribute("", "xmlns", v) : new OpenXmlattribute("xmlns", k[pos+6:], v);
continue;
end
pf := attributes_pf_[k];
if ifnil(pf) then continue;
pf.Do(v);
end
child_elements := container_.Get();
for k, v in child_elements do
v.Deserialize();
end;
function OpenXmlElement.Serialize();
begin
// xmlns
for k, v in xmlns_ do
{self.}GetNode().SetAttribute(v.ElementName, v.Value);
// Attributes
for k, v in attributes_ do for k, v in attributes_ do
if not ifnil(v.Value) then {self.}GetNode().SetAttribute(v.ElementName, v.Value); attrs[length(attrs)] := v;
// Children return attrs;
child_elements := container_.Get();
for k, v in child_elements do
v.Serialize();
end; end;
function OpenXmlElement.Marshal(): tableArray; function OpenXmlElement.Elements(): array of tslobj;
begin begin
child_elements := container_.Get(); return container_.GetElements(false);
child_arr := array();
for k, v in child_elements do
begin
arr := array("type": "element", "name": v.ElementName, "attributes": array());
if v is Class(OpenXmlPcdata) or v is Class(OpenXmlElement) then
begin
marshal := v.Marshal();
if length(marshal["children"]) = 0 and length(marshal["attributes"]) = 0 then continue;
arr["children"] := marshal["children"];
arr["attributes"] union= marshal["attributes"];
child_arr[length(child_arr)] := arr;
end
else if v is Class(OpenXmlEmpty) then
begin
marshal := v.Marshal();
if length(marshal) > 0 then child_arr[length(child_arr)] := arr;
end
else begin
echo "error = marshal.\n";
end
end
tmp_arr := array("type": "element", "name": {self.}ElementName, "children": child_arr, "attributes": array());
for k,v in attributes_ do
begin
if not ifnil(v.Value) then tmp_arr["attributes"][v.ElementName] := v.Value;
end
return tmp_arr;
end; end;
function OpenXmlElement.Xmlns(_prefix: string): string; function OpenXmlElement.Xmlns(_prefix: string): string;
@ -185,17 +88,20 @@ begin
return xmlns_[k]; return xmlns_[k];
end; end;
function OpenXmlElement.Elements(): array of tslobj; function OpenXmlElement.GetNode(): XmlNode;
begin begin
return container_.Get(); if not ifObj({self.}XmlNode) then {self.}XmlNode := {self.}Parent.GetOrCreateNode(self);
return {self.}XmlNode;
end; end;
function OpenXmlElement.InsertAfter(_obj: tslobj; _pos_obj: tslobj); function OpenXmlElement.DeleteSelf(): boolean;
begin begin
container_.InsertAfter(_obj, _pos_obj); if {self.}Removed then
begin
if {self.}XmlNode then
{self.}Parent.XmlNode.DeleteChild({self.}XmlNode);
return true;
end
return false;
end; end;
function OpenXmlElement.AppendChild(_obj: tslobj);
begin
container_.Append(_obj);
end;

View File

@ -1,119 +0,0 @@
type OpenXmlEmpty = class
public
function Create(_node: XmlNode);overload;
function Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
function InitNode(_node: XmlNode);
function Copy(_obj: tslobj);virtual;
function GetNode(): XmlNode;
function Marshal(): tableArray;
function BoolValue(): boolean;
function Deserialize();
function Serialize();
public
// attributes property
XmlAttrVal;
property Val read ReadXmlAttrVal write WriteXmlAttrVal;
function ReadXmlAttrVal();
function WriteXmlAttrVal(_value: any);
public
LocalName: string; // 本地名称
[weakref]Parent: tslobj; // 父类
Prefix: string; // 前缀
XmlNode: XmlNode; // XMLNode节点
ElementName: string;
Value: any;
end;
function OpenXmlEmpty.Create(_node: XmlNode);overload;
begin
node_name := _node.GetName();
pos := Pos(":", node_name);
if pos then {self.}Create(nil, node_name[:pos-1], node_name[pos+1:]);
else {self.}Create(nil, nil, node_name);
{self.}InitNode(_node);
end;
function OpenXmlEmpty.Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
begin
{self.}Parent := _parent;
{self.}Prefix := _prefix;
{self.}LocalName := _local_name;
{self.}XmlNode := nil;
{self.}ElementName := ifString({self.}Prefix) and {self.}Prefix <> "" ? format("%s:%s", {self.}Prefix, {self.}LocalName) : {self.}LocalName;
end;
function OpenXmlEmpty.InitNode(_node: XmlNode);
begin
{self.}XmlNode := ifObj(_node) ? _node : nil;
end;
function OpenXmlEmpty.Copy(_obj: tslobj);
begin
if not ifnil(_obj.Value) then {self.}Value := _obj.Value;
if not ifnil(_obj.XmlAttrVal.Value) then {self.}Val := _obj.XmlAttrVal.Value;
end;
function OpenXmlEmpty.Marshal(): tableArray;
begin
if not {self.}Value then return array();
attr := array();
if not inil({self.}XmlAttrVal.Value) then attr[{self.}XmlAttrVal.ElementName] := {self.}XmlAttrVal.Value;
arr := array("type": "element", "name": name_, "attributes": attr, "children": array());
return arr;
end;
function OpenXmlEmpty.Deserialize();
begin
if ifObj({self.}XmlNode) then
begin
attrs := {self.}XmlNode.Attributes();
if length(attrs) > 1 then raise "OpenXmlEmpty.Deserialize error.\n";
{self.}Val := nil;
for k,v in attrs do
{self.}Val := v;
{self.}Value := ifnil({self.}Val) ? true : {self.}Val = "0" ? false : true;
end
else begin
{self.}Value := nil;
{self.}XmlAttrVal := nil;
end
end;
function OpenXmlEmpty.GetNode(): XmlNode;
begin
if not ifObj({self.}XmlNode) then {self.}XmlNode := {self.}Parent.GetOrCreateNode(self);
return {self.}XmlNode;
end;
function OpenXmlEmpty.Serialize();
begin
if not ifObj({self.}XmlNode) then
begin
if not ifnil({self.}XmlAttrVal.Value) then {self.}GetNode().SetAttribute({self.}XmlAttrVal.ElementName, {self.}XmlAttrVal.Value);
end
else begin
if not ifnil({self.}XmlAttrVal.Value) then {self.}XmlNode.SetAttribute({self.}XmlAttrVal.ElementName, {self.}XmlAttrVal.Value);
else if not {self.}Value and ifObj({self.}Parent.XmlNode) then{self.}Parent.XmlNode.DeleteChild({self.}XmlNode);
end
end;
function OpenXmlEmpty.BoolValue(): boolean;
begin
return ifnil({self.}Val) ? {self.}Value ? true : false : {self.}Val;
end;
function OpenXmlEmpty.ReadXmlAttrVal();
begin
return {self.}XmlAttrVal.Value = "0" ? false : {self.}XmlAttrVal.Value = "1" ? true : {self.}XmlAttrVal.Value;
end;
function OpenXmlEmpty.WriteXmlAttrVal(_value: any);
begin
if ifnil({self.}XmlAttrVal) then
{self.}XmlAttrVal := new OpenXmlAttribute({self.}Prefix, "val", nil);
{self.}XmlAttrVal.Value := _value;
end;

View File

@ -1,87 +0,0 @@
type OpenXmlPcdata = class
public
function Create(_node: XmlNode);overload;
function Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
function Init();virtual;
function InitNode(_node: XmlNode);virtual;
function Copy(_obj: tslobj);virtual;
function GetNode(): XmlNode;
function Marshal(): tableArray;
function Deserialize();
function Serialize();
public
LocalName: string; // 本地名称
[weakref]Parent: tslobj; // 父类
Prefix: string; // 前缀
XmlNode: XmlNode; // XMLNode节点
ElementName: string;
Text: string; // 元素的文本内容
protected
attributes_: array of OpenXmlAttribute; // 属性
attributes_pf_: tableArray;
end;
function OpenXmlPcdata.Create(_node: XmlNode);overload;
begin
node_name := _node.GetName();
pos := Pos(":", node_name);
if pos then {self.}Create(nil, node_name[:pos-1], node_name[pos+1:]);
else {self.}Create(nil, nil, node_name);
{self.}InitNode(_node);
end;
function OpenXmlPcdata.Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
begin
{self.}Parent := _parent;
{self.}Prefix := _prefix;
{self.}LocalName := _local_name;
{self.}XmlNode := nil;
{self.}Text := nil;
{self.}ElementName := ifString({self.}Prefix) and {self.}Prefix <> "" ? format("%s:%s", {self.}Prefix, {self.}LocalName) : {self.}LocalName;
{self.}Init();
end;
function OpenXmlPcdata.InitNode(_node: XmlNode);virtual;
begin
{self.}XmlNode := ifObj(_node) ? _node : nil;
end;
function OpenXmlPcdata.Marshal(): tableArray;
begin
arr := array("type": "element", "name": name_, "attributes": array(), "children": array());
for k,v in attributes_ do
if not ifnil(v.Value) then arr["attributes"][v.ElementName] := v.Value;
if not ifnil({self.}Text) then arr["children"] := array(("type": "pcdata", "value": {self.}Text));
return arr;
end;
function OpenXmlPcdata.Deserialize();
begin
if not ifObj({self.}XmlNode) then return;
{self.}Text := {self.}XmlNode.GetText();
attrs := {self.}XmlNode.Attributes();
for k, v in attrs do
begin
pf := attributes_pf_[k];
if ifnil(pf) then continue;
pf.Do(v);
end
end;
function OpenXmlPcdata.GetNode(): XmlNode;
begin
if not ifObj({self.}XmlNode) then {self.}XmlNode := {self.}Parent.GetOrCreateNode(self);
return {self.}XmlNode;
end;
function OpenXmlPcdata.Serialize();
begin
if not ifnil({self.}Text) then {self.}GetNode().SetValue({self.}Text);
for k,v in attributes_ do
if not ifnil(v.Value) then {self.}GetNode().SetAttribute(v.ElementName, v.Value);
end;

View File

@ -0,0 +1,104 @@
type OpenXmlSimpleType = class(OpenXmlElement)
public
function Init();override;
function InitNode(_node: XmlNode);override;
function Copy(_obj: tslobj);override;
function Deserialize();override;
function Serialize();override;
function Marshal(): tableArray;override;
public
// attributes property
XmlAttrVal;
property Val read ReadXmlAttrVal write WriteXmlAttrVal;
function ReadXmlAttrVal();
function WriteXmlAttrVal(_value: any);
// 动态获取IsApplied
// IsApplied: boolean; // 是否已经应用和val值有关
property IsApplied read ReadIsApplied;
function ReadIsApplied();
public
Enable: boolean; // 是否启用 <b /> 没有属性需要通过val写属性
end;
function OpenXmlSimpleType.Init();override;
begin
{self.}Enable := false;
end;
function OpenXmlSimpleType.InitNode(_node: XmlNode);override;
begin
{self.}XmlNode := ifObj(_node) ? _node : nil;
end;
function OpenXmlSimpleType.Copy(_obj: tslobj);override;
begin
if not ifnil(_obj.Enable) then {self.}Enable := _obj.Enable;
if not ifnil(_obj.XmlAttrVal.Value) then {self.}Val := _obj.XmlAttrVal.Value;
end;
function OpenXmlSimpleType.Marshal(): tableArray;override;
begin
if not {self.}Enable then return array();
attr := array();
if not inil({self.}XmlAttrVal.Value) then attr[{self.}XmlAttrVal.ElementName] := {self.}XmlAttrVal.Value;
arr := array("type": "element", "name": name_, "attributes": attr, "children": array());
return arr;
end;
function OpenXmlSimpleType.Deserialize();override;
begin
if ifObj({self.}XmlNode) then
begin
attrs := {self.}XmlNode.Attributes();
if length(attrs) > 1 then
begin
echo "OpenXmlSimpleType.Deserialize error.\n";
return;
end
{self.}Val := nil;
for k,v in attrs do
{self.}Val := v;
{self.}Enable := true;
end
else begin
{self.}Enable := false;
{self.}XmlAttrVal := nil;
end
end;
function OpenXmlSimpleType.Serialize();override;
begin
if not ifObj({self.}XmlNode) then
begin
if not ifnil({self.}XmlAttrVal.Value) then {self.}GetNode().SetAttribute({self.}XmlAttrVal.ElementName, {self.}XmlAttrVal.Value);
end
else begin
if not {self.}Enable or {self.}Removed then
{self.}Parent.XmlNode.DeleteChild({self.}XmlNode);
else if not ifnil({self.}XmlAttrVal.Value) then
{self.}XmlNode.SetAttribute({self.}XmlAttrVal.ElementName, {self.}XmlAttrVal.Value);
end
end;
function OpenXmlSimpleType.ReadXmlAttrVal();
begin
return {self.}XmlAttrVal.Value;
end;
function OpenXmlSimpleType.WriteXmlAttrVal(_value: any);
begin
if ifnil({self.}XmlAttrVal) then
{self.}XmlAttrVal := new OpenXmlAttribute({self.}Prefix, "val", nil);
{self.}XmlAttrVal.Value := _value;
{self.}Enable := true;
end;
function OpenXmlSimpleType.ReadIsApplied();
begin
if {self.}Enable then
return {self.}XmlAttrVal.Value = "0" or {self.}XmlAttrVal.Value = "false" ? false : true;
return false;
end;

View File

@ -0,0 +1,59 @@
type OpenXmlTextElement = class(OpenXmlElement)
public
function InitNode(_node: XmlNode);override;
function Copy(_obj: tslobj);virtual;
function Deserialize();override;
function Serialize();override;
function Marshal(): tableArray;override;
public
Text: string; // 元素的文本内容
end;
function OpenXmlTextElement.InitNode(_node: XmlNode);override;
begin
{self.}XmlNode := ifObj(_node) ? _node : nil;
end;
function OpenXmlTextElement.Copy(_obj: tslobj);virtual;
begin
if not ifnil(_obj.Text) then {self.}Text := _obj.Text;
end;
function OpenXmlTextElement.Marshal(): tableArray;override;
begin
arr := array("type": "element", "name": name_, "attributes": array(), "children": array());
for k,v in attributes_ do
if not ifnil(v.Value) then arr["attributes"][v.ElementName] := v.Value;
if not ifnil({self.}Text) then arr["children"] := array(("type": "pcdata", "value": {self.}Text));
return arr;
end;
function OpenXmlTextElement.Deserialize();override;
begin
if not ifObj({self.}XmlNode) then return;
{self.}Text := {self.}XmlNode.GetText();
attrs := {self.}XmlNode.Attributes();
for k, v in attrs do
begin
pos := pos("xmlns", k);
if pos then
begin
xmlns_[k] := k = "xmlns" ? new OpenXmlAttribute("", "xmlns", v) : new OpenXmlattribute("xmlns", k[pos+6:], v);
continue;
end
pf := attributes_pf_[k];
if ifnil(pf) then continue;
pf.Do(v);
end
end;
function OpenXmlTextElement.Serialize();override;
begin
if {self.}DeleteSelf() then return;
if not ifnil({self.}Text) then {self.}GetNode().SetValue({self.}Text);
for k,v in attributes_ do
if not ifnil(v.Value) then {self.}GetNode().SetAttribute(v.ElementName, v.Value);
end;

View File

@ -6,8 +6,8 @@ public
function Append(data: any): boolean; function Append(data: any): boolean;
function Insert(data: any): boolean; function Insert(data: any): boolean;
function InsertAfter(data: any; pos_data: any); function InsertAfter(data: any; pos_data: any);
function Get(name: string; index: integer);overload; function Get(name: string; index: integer);
function Get(): array of tslobj;overload; function GetElements(include_removed: boolean): array of tslobj;
private private
function GetBucketObj(str: string): LinkList; function GetBucketObj(str: string): LinkList;
@ -24,6 +24,7 @@ public
function Create(name: string); function Create(name: string);
function Set(data: any); function Set(data: any);
function Add(data: any); function Add(data: any);
function Delete(data: any): boolean;
function InsertAfter(data: any; pos_data: any): boolean; function InsertAfter(data: any; pos_data: any): boolean;
function Name(): string; function Name(): string;
function Size(): integer; function Size(): integer;
@ -58,7 +59,7 @@ function TSOfficeContainer.Set(data: any): boolean;
begin begin
obj := {self.}GetBucketObj(data.ElementName); obj := {self.}GetBucketObj(data.ElementName);
if ifnil(obj) then return false; if ifnil(obj) then return false;
obj.Set(data); obj.Add(data);
return true; return true;
end; end;
@ -125,7 +126,7 @@ begin
end end
end; end;
function TSOfficeContainer.Get(): array of tslobj;overload; function TSOfficeContainer.GetElements(include_removed: boolean = true): array of tslobj;
begin begin
arr := array(); arr := array();
for i:=0 to current_index_ do for i:=0 to current_index_ do
@ -136,6 +137,7 @@ begin
node := obj.First(); node := obj.First();
while ifObj(node) do while ifObj(node) do
begin begin
if include_removed or not node.data.Removed then
arr[length(arr)] := node.data; arr[length(arr)] := node.data;
node := node.next; node := node.next;
end end
@ -144,7 +146,7 @@ begin
return arr; return arr;
end; end;
function TSOfficeContainer.Get(name: string; index: integer);overload; function TSOfficeContainer.Get(name: string; index: integer);
begin begin
ind := child_[name]; ind := child_[name];
arr := array(); arr := array();
@ -239,6 +241,25 @@ begin
return false; return false;
end; end;
function LinkList.Delete(data: any): boolean;
begin
node := {self.}First();
prev := nil;
while ifObj(node) do
begin
if node.data = data then
begin
if ifnil(prev) then head_.next := node.next;
else if tail_ = node then tail_ := prev;
else prev.next := node.next;
return true;
end
prev := node;
node := node.next;
end
return false;
end;
function LinkList.Name(): string; function LinkList.Name(): string;
begin begin
return name_; return name_;

29
迁移指南.md Normal file
View File

@ -0,0 +1,29 @@
# 迁移指南
## 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`下的属性