1- using DocumentFormat . OpenXml . Presentation ;
1+ using DocumentFormat . OpenXml . Flatten . ElementConverters . Text ;
2+ using DocumentFormat . OpenXml . Presentation ;
3+
4+ using Shape = DocumentFormat . OpenXml . Presentation . Shape ;
5+ using ShapeProperties = DocumentFormat . OpenXml . Presentation . ShapeProperties ;
6+ using ShapeStyle = DocumentFormat . OpenXml . Presentation . ShapeStyle ;
7+ using SmartArtShape = DocumentFormat . OpenXml . Office . Drawing . Shape ;
8+ using SmartArtShapeNonVisualProperties = DocumentFormat . OpenXml . Office . Drawing . ShapeNonVisualProperties ;
9+ using SmartArtShapeProperties = DocumentFormat . OpenXml . Office . Drawing . ShapeProperties ;
10+ using SmartArtShapeStyle = DocumentFormat . OpenXml . Office . Drawing . ShapeStyle ;
11+ using SmartArtTextBody = DocumentFormat . OpenXml . Office . Drawing . TextBody ;
12+ using TextBody = DocumentFormat . OpenXml . Presentation . TextBody ;
213
314namespace DocumentFormat . OpenXml . Flatten . ElementConverters
415{
@@ -11,39 +22,66 @@ public class ShapeAdapt
1122 /// 创建形状适配器
1223 /// </summary>
1324 /// <param name="shape"></param>
14- /// <param name="shapeProperties "></param>
15- /// <param name="shapeStyle "></param>
25+ /// <param name="shapePropertiesAdapt "></param>
26+ /// <param name="shapeStyleAdapt "></param>
1627 /// <param name="nonVisualShapeProperties"></param>
1728 /// <param name="useBackgroundFill"></param>
1829 /// <param name="textBody"></param>
19- public ShapeAdapt ( OpenXmlCompositeElement ? shape , ShapeProperties ? shapeProperties ,
20- ShapeStyle ? shapeStyle ,
30+ public ShapeAdapt ( OpenXmlCompositeElement ? shape , ShapeProperties ? shapePropertiesAdapt ,
31+ ShapeStyle ? shapeStyleAdapt ,
2132 NonVisualShapeProperties ? nonVisualShapeProperties = null ,
2233 bool ? useBackgroundFill = null ,
2334 TextBody ? textBody = null )
2435 {
25- ShapeProperties = shapeProperties ;
26- ShapeStyle = shapeStyle ;
36+ ShapePropertiesAdapt = shapePropertiesAdapt ;
37+ ShapeStyleAdapt = shapeStyleAdapt ;
2738 NonVisualShapeProperties = nonVisualShapeProperties ;
2839 UseBackgroundFill = useBackgroundFill ;
29- TextBody = textBody ;
40+ TextBodyAdapt = textBody ;
3041 Shape = shape ;
3142 }
3243
3344 /// <summary>
34- /// 形状元素,可能是 <see cref="ConnectionShape"/> 和 <see cref="DocumentFormat.OpenXml.Presentation.Shape"/>
45+ /// 适配SmartArt的形状构造
46+ /// </summary>
47+ /// <param name="smartArtShape"></param>
48+ /// <param name="smartArtShapeProperties"></param>
49+ /// <param name="shapeStyle"></param>
50+ /// <param name="smartArtShapeNonVisualProperties"></param>
51+ /// <param name="smartArtTextBody"></param>
52+ public ShapeAdapt ( SmartArtShape ? smartArtShape ,
53+ SmartArtShapeProperties ? smartArtShapeProperties ,
54+ SmartArtShapeStyle ? shapeStyle ,
55+ SmartArtShapeNonVisualProperties ? smartArtShapeNonVisualProperties = null ,
56+ SmartArtTextBody ? smartArtTextBody = null )
57+ {
58+ ShapePropertiesAdapt = smartArtShapeProperties ;
59+ ShapeStyleAdapt = shapeStyle ;
60+ SmartArtShapeNonVisualProperties = smartArtShapeNonVisualProperties ;
61+ TextBodyAdapt = smartArtTextBody ;
62+ Shape = smartArtShape ;
63+ }
64+
65+ /// <summary>
66+ /// 形状元素,可能是 <see cref="ConnectionShape"/> 和 <see cref="DocumentFormat.OpenXml.Presentation.Shape"/>和<see cref="DocumentFormat.OpenXml.Office.Drawing.Shape"/>
3567 /// </summary>
3668 public OpenXmlCompositeElement ? Shape { get ; }
3769
3870 /// <summary>
3971 /// 形状属性
4072 /// </summary>
41- public ShapeProperties ? ShapeProperties { get ; }
73+ public ShapePropertiesAdapt ? ShapePropertiesAdapt { get ; }
74+
75+ /// <summary>
76+ /// SmartArt形状不可见属性
77+ /// </summary>
78+ public SmartArtShapeNonVisualProperties ? SmartArtShapeNonVisualProperties { get ; }
4279
4380 /// <summary>
4481 /// 形状样式
4582 /// </summary>
46- public ShapeStyle ? ShapeStyle { get ; }
83+ public ShapeStyleAdapt ? ShapeStyleAdapt { get ; }
84+
4785
4886 /// <summary>
4987 /// 形状不可见属性
@@ -59,7 +97,7 @@ public ShapeAdapt(OpenXmlCompositeElement? shape, ShapeProperties? shapeProperti
5997 /// <summary>
6098 /// 形状里面的文本
6199 /// </summary>
62- public TextBody ? TextBody { get ; }
100+ public TextBodyAdapt ? TextBodyAdapt { get ; }
63101
64102 /// <summary>
65103 /// 转换为形状适配器
@@ -74,7 +112,7 @@ public ShapeAdapt(OpenXmlCompositeElement? shape, ShapeProperties? shapeProperti
74112 /// <summary>
75113 /// 转换为形状适配器
76114 /// </summary>
77- public static implicit operator ShapeAdapt ( DocumentFormat . OpenXml . Presentation . Shape shape ) =>
115+ public static implicit operator ShapeAdapt ( Shape shape ) =>
78116 new ShapeAdapt
79117 (
80118 shape ,
@@ -84,5 +122,18 @@ public static implicit operator ShapeAdapt(DocumentFormat.OpenXml.Presentation.S
84122 shape . UseBackgroundFill ? . Value ,
85123 shape . TextBody
86124 ) ;
125+
126+ /// <summary>
127+ /// 转换为形状适配器
128+ /// </summary>
129+ public static implicit operator ShapeAdapt ( DocumentFormat . OpenXml . Office . Drawing . Shape shape ) =>
130+ new ShapeAdapt
131+ (
132+ shape ,
133+ shape . ShapeProperties ,
134+ shape . ShapeStyle ,
135+ shape . ShapeNonVisualProperties ,
136+ shape . TextBody
137+ ) ;
87138 }
88139}
0 commit comments