Skip to content

Commit eeb30e2

Browse files
authored
Merge pull request #24 from dotnet-campus/t/lindexi/DocumentFormat.OpenXml.Flatten
开源 DocumentFormat.OpenXml.Flatten 库
2 parents 6dd135c + b7a83f5 commit eeb30e2

255 files changed

Lines changed: 48714 additions & 48 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/NuGet-master-publish.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/NuGet-tag-publish.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v1
1515

16+
- name: Setup .NET
17+
uses: actions/setup-dotnet@v1
18+
with:
19+
dotnet-version: |
20+
3.1.x
21+
5.0.x
22+
6.0.x
1623
1724
- name: Install dotnet tool
1825
run: dotnet tool install -g dotnetCampus.TagToVersion

.github/workflows/dotnetcore.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ jobs:
99

1010
steps:
1111
- uses: actions/checkout@v1
12-
12+
- name: Setup .NET
13+
uses: actions/setup-dotnet@v1
14+
with:
15+
dotnet-version: |
16+
3.1.x
17+
5.0.x
18+
6.0.x
1319
- name: Build with dotnet
1420
run: dotnet build --configuration Release
1521

1622
- name: Test
17-
run: dotnet test --configuration Release
23+
run: dotnet test --configuration Release --no-build

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
<Description>A dotnet tool to assist in editing Office document files</Description>
1212

1313
<RepositoryType>git</RepositoryType>
14-
<Copyright>Copyright © 2020 dotnet campus, All Rights Reserved.</Copyright>
14+
<Copyright>Copyright © 2020-2021 dotnet campus, All Rights Reserved.</Copyright>
1515
</PropertyGroup>
1616
</Project>

README.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ OfficeDocumentZipper
3636
|--|--|
3737
|dotnetCampus.OpenXMLUnitConverter|[![](https://img.shields.io/nuget/v/dotnetCampus.OpenXMLUnitConverter.svg)](https://www.nuget.org/packages/dotnetCampus.OpenXMLUnitConverter)|
3838
|dotnetCampus.OpenXMLUnitConverter.Source|[![](https://img.shields.io/nuget/v/dotnetCampus.OpenXMLUnitConverter.Source.svg)](https://www.nuget.org/packages/dotnetCampus.OpenXMLUnitConverter.Source)|
39-
39+
|dotnetCampus.DocumentFormat.OpenXml.Flatten|[![](https://img.shields.io/nuget/v/dotnetCampus.DocumentFormat.OpenXml.Flatten.svg)](https://www.nuget.org/packages/dotnetCampus.DocumentFormat.OpenXml.Flatten)|
40+
|dotnetCampus.DocumentFormat.OpenXml.Flatten.Source|[![](https://img.shields.io/nuget/v/dotnetCampus.DocumentFormat.OpenXml.Flatten.Source.svg)](https://www.nuget.org/packages/dotnetCampus.DocumentFormat.OpenXml.Flatten.Source)|
4041

4142
## dotnetCampus.OpenXMLUnitConverter
4243

@@ -47,13 +48,13 @@ Defining units for OpenXml properties and the unit conversion function.
4748
DLL Pakcage:
4849

4950
```xml
50-
<PackageReference Include="dotnetCampus.OpenXmlUnitConverter" Version="1.8.0" />
51+
<PackageReference Include="dotnetCampus.OpenXmlUnitConverter" Version="1.9.0" />
5152
```
5253

5354
[SouceYard](https://github.com/dotnet-campus/SourceYard) Package:
5455

5556
```xml
56-
<PackageReference Include="dotnetCampus.OpenXmlUnitConverter.Source" Version="1.8.0">
57+
<PackageReference Include="dotnetCampus.OpenXmlUnitConverter.Source" Version="1.9.0">
5758
<PrivateAssets>all</PrivateAssets>
5859
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
5960
</PackageReference>
@@ -72,6 +73,30 @@ void Foo(DocumentFormat.OpenXml.Drawing.Point2DType point)
7273
}
7374
```
7475

76+
## DocumentFormat.OpenXml.Flatten
77+
78+
### Install
79+
80+
DLL Pakcage:
81+
82+
```xml
83+
<PackageReference Include="dotnetCampus.DocumentFormat.OpenXml.Flatten" Version="2.0.0" />
84+
```
85+
86+
[SouceYard](https://github.com/dotnet-campus/SourceYard) Package:
87+
88+
```xml
89+
<PackageReference Include="dotnetCampus.DocumentFormat.OpenXml.Flatten.Source" Version="2.0.0">
90+
<PrivateAssets>all</PrivateAssets>
91+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
92+
</PackageReference>
93+
```
94+
95+
### Usage
96+
97+
See [DocumentFormat.OpenXml.Flatten README.md](src/DocumentFormat.OpenXml.Flatten/README.md)
98+
99+
75100
# Thanks
76101

77102
- [OfficeDev/Open-XML-SDK: Open XML SDK by Microsoft](https://github.com/OfficeDev/Open-XML-SDK/ )

README.zh-cn.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ OfficeDocumentZipper
5353
DLL 包:
5454

5555
```xml
56-
<PackageReference Include="dotnetCampus.OpenXmlUnitConverter" Version="1.8.0" />
56+
<PackageReference Include="dotnetCampus.OpenXmlUnitConverter" Version="1.9.0" />
5757
```
5858

5959
[SouceYard](https://github.com/dotnet-campus/SourceYard) 源代码包:
6060

6161
```xml
62-
<PackageReference Include="dotnetCampus.OpenXmlUnitConverter.Source" Version="1.8.0">
62+
<PackageReference Include="dotnetCampus.OpenXmlUnitConverter.Source" Version="1.9.0">
6363
<PrivateAssets>all</PrivateAssets>
6464
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
6565
</PackageReference>
@@ -80,6 +80,31 @@ void Foo(DocumentFormat.OpenXml.Drawing.Point2DType point)
8080

8181
详细请看 [Office Open XML 的测量单位](https://blog.lindexi.com/post/Office-Open-XML-%E7%9A%84%E6%B5%8B%E9%87%8F%E5%8D%95%E4%BD%8D.html )
8282

83+
## DocumentFormat.OpenXml.Flatten
84+
85+
提供继承的属性拍平的功能的库,包含常用处理逻辑和计算逻辑
86+
87+
### 安装方法
88+
89+
DLL 包:
90+
91+
```xml
92+
<PackageReference Include="dotnetCampus.DocumentFormat.OpenXml.Flatten" Version="2.0.0" />
93+
```
94+
95+
[SouceYard](https://github.com/dotnet-campus/SourceYard) 源代码包:
96+
97+
```xml
98+
<PackageReference Include="dotnetCampus.DocumentFormat.OpenXml.Flatten.Source" Version="2.0.0">
99+
<PrivateAssets>all</PrivateAssets>
100+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
101+
</PackageReference>
102+
```
103+
104+
### 使用方法
105+
106+
具体使用方法请参阅 [DocumentFormat.OpenXml.Flatten 使用文档](src/DocumentFormat.OpenXml.Flatten/README.md)
107+
83108
# 感谢
84109

85110
- [OfficeDev/Open-XML-SDK: Open XML SDK by Microsoft](https://github.com/OfficeDev/Open-XML-SDK/ )

dotnetCampus.OfficeDocumentZipper.sln

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.30204.135
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
55
MinimumVisualStudioVersion = 15.0.26124.0
6-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5D196596-756D-45C2-8A05-C8E4AB8A36E6}"
7-
EndProject
86
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnetCampus.OfficeDocumentZipper", "src\dotnetCampus.OfficeDocumentZipper\dotnetCampus.OfficeDocumentZipper.csproj", "{EF60ACE4-91B3-4731-8530-F3CD922E922D}"
97
EndProject
108
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A80DBE61-A86F-4F1E-B638-999F15ED9EE3}"
@@ -14,15 +12,25 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1412
CHANGELOG.md = CHANGELOG.md
1513
Directory.Build.props = Directory.Build.props
1614
README.md = README.md
15+
README.zh-cn.md = README.zh-cn.md
1716
build\Version.props = build\Version.props
1817
EndProjectSection
1918
EndProject
2019
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnetCampus.OpenXmlUnitConverter", "src\dotnetCampus.OpenXmlUnitConverter\dotnetCampus.OpenXmlUnitConverter.csproj", "{DFF5A479-FCEE-431D-85C6-8E0D03E64F46}"
2120
EndProject
22-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{66E18386-803A-464D-9006-2EFD364FE97C}"
23-
EndProject
2421
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnetCampus.OpenXMLUnitConverter.Tests", "tests\dotnetCampus.OpenXMLUnitConverter.Tests\dotnetCampus.OpenXMLUnitConverter.Tests.csproj", "{86010F5E-F7FD-40C9-96D7-491356A90139}"
2522
EndProject
23+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DocumentFormat.OpenXml.Flatten", "DocumentFormat.OpenXml.Flatten", "{1DCDA9B1-ED7A-4825-BBA3-E3561006E4AF}"
24+
ProjectSection(SolutionItems) = preProject
25+
src\DocumentFormat.OpenXml.Flatten\README.md = src\DocumentFormat.OpenXml.Flatten\README.md
26+
EndProjectSection
27+
EndProject
28+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnetCampus.DocumentFormat.OpenXml.Flatten", "src\DocumentFormat.OpenXml.Flatten\DocumentFormat.OpenXml.Flatten\dotnetCampus.DocumentFormat.OpenXml.Flatten.csproj", "{6003FD01-7DC7-4F99-8878-7AE3ABF40BE6}"
29+
EndProject
30+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tool", "Tool", "{8A1ED232-9A93-4D88-AC6D-3E3D4EA98FAD}"
31+
EndProject
32+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "OpenXmlUnitConverter", "OpenXmlUnitConverter", "{D0552FF1-B2AE-4878-B6B7-F792C326371C}"
33+
EndProject
2634
Global
2735
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2836
Debug|Any CPU = Debug|Any CPU
@@ -41,14 +49,19 @@ Global
4149
{86010F5E-F7FD-40C9-96D7-491356A90139}.Debug|Any CPU.Build.0 = Debug|Any CPU
4250
{86010F5E-F7FD-40C9-96D7-491356A90139}.Release|Any CPU.ActiveCfg = Release|Any CPU
4351
{86010F5E-F7FD-40C9-96D7-491356A90139}.Release|Any CPU.Build.0 = Release|Any CPU
52+
{6003FD01-7DC7-4F99-8878-7AE3ABF40BE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
53+
{6003FD01-7DC7-4F99-8878-7AE3ABF40BE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
54+
{6003FD01-7DC7-4F99-8878-7AE3ABF40BE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
55+
{6003FD01-7DC7-4F99-8878-7AE3ABF40BE6}.Release|Any CPU.Build.0 = Release|Any CPU
4456
EndGlobalSection
4557
GlobalSection(SolutionProperties) = preSolution
4658
HideSolutionNode = FALSE
4759
EndGlobalSection
4860
GlobalSection(NestedProjects) = preSolution
49-
{EF60ACE4-91B3-4731-8530-F3CD922E922D} = {5D196596-756D-45C2-8A05-C8E4AB8A36E6}
50-
{DFF5A479-FCEE-431D-85C6-8E0D03E64F46} = {5D196596-756D-45C2-8A05-C8E4AB8A36E6}
51-
{86010F5E-F7FD-40C9-96D7-491356A90139} = {66E18386-803A-464D-9006-2EFD364FE97C}
61+
{EF60ACE4-91B3-4731-8530-F3CD922E922D} = {8A1ED232-9A93-4D88-AC6D-3E3D4EA98FAD}
62+
{DFF5A479-FCEE-431D-85C6-8E0D03E64F46} = {D0552FF1-B2AE-4878-B6B7-F792C326371C}
63+
{86010F5E-F7FD-40C9-96D7-491356A90139} = {D0552FF1-B2AE-4878-B6B7-F792C326371C}
64+
{6003FD01-7DC7-4F99-8878-7AE3ABF40BE6} = {1DCDA9B1-ED7A-4825-BBA3-E3561006E4AF}
5265
EndGlobalSection
5366
GlobalSection(ExtensibilityGlobals) = postSolution
5467
SolutionGuid = {90F871FB-EAC2-449B-8601-3562C03CC566}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
using DocumentFormat.OpenXml.Flatten.ElementConverters.CommonElement;
2+
3+
using dotnetCampus.OpenXmlUnitConverter;
4+
5+
namespace DocumentFormat.OpenXml.Flatten.Contexts
6+
{
7+
/// <summary>
8+
/// 使用 Emu 单位的形状里的文本范围,对应 OpenXml Shape 的 a:rect 标签
9+
/// </summary>
10+
public readonly struct EmuShapeTextRectangle
11+
{
12+
/// <summary>
13+
/// 创建形状里的文本范围
14+
/// </summary>
15+
public EmuShapeTextRectangle(Emu left, Emu top, Emu right, Emu bottom)
16+
{
17+
var emuWidth = new Emu(right.Value - left.Value);
18+
var emuHeight = new Emu(bottom.Value - top.Value);
19+
20+
OriginPoint = new EmuPoint(left, top);
21+
Size = new EmuSize(emuWidth, emuHeight);
22+
}
23+
24+
/// <summary>
25+
/// 创建形状里的文本范围
26+
/// </summary>
27+
/// <param name="size">形状文本框的大小</param>
28+
/// <param name="originPoint">形状文本框的原点坐标</param>
29+
public EmuShapeTextRectangle(EmuSize size, EmuPoint originPoint)
30+
{
31+
Size = size;
32+
OriginPoint = originPoint;
33+
}
34+
35+
/// <summary>
36+
/// 形状文本框的坐标原点
37+
/// </summary>
38+
public EmuPoint OriginPoint { get; }
39+
40+
/// <summary>
41+
/// Rectangle的大小
42+
/// </summary>
43+
public EmuSize Size { get; }
44+
}
45+
46+
/// <summary>
47+
/// Emu单位的形状文本框的Margin
48+
/// </summary>
49+
public readonly struct EmuTextMargin
50+
{
51+
/// <summary>
52+
/// 创建EmuTextMargin
53+
/// </summary>
54+
/// <param name="emuLeftInset">emu单位的LeftInset</param>
55+
/// <param name="emuTopInset">emu单位的TopInset</param>
56+
/// <param name="emuRightInset">emu单位的RightInset</param>
57+
/// <param name="emuBottomInset">emu单位的BottomInset</param>
58+
public EmuTextMargin(double emuLeftInset, double emuTopInset, double emuRightInset, double emuBottomInset)
59+
{
60+
LeftInset = new Emu(emuLeftInset);
61+
TopInset = new Emu(emuTopInset);
62+
RightInset = new Emu(emuRightInset);
63+
BottomInset = new Emu(emuBottomInset);
64+
}
65+
66+
/// <summary>
67+
/// 对应 a:bodyPr lIns
68+
/// </summary>
69+
public Emu LeftInset { get; }
70+
71+
/// <summary>
72+
/// 对应 a:bodyPr rIns
73+
/// </summary>
74+
public Emu RightInset { get; }
75+
76+
/// <summary>
77+
/// 对应 a:bodyPr bIns
78+
/// </summary>
79+
public Emu BottomInset { get; }
80+
81+
/// <summary>
82+
/// 对应 a:bodyPr tIns
83+
/// </summary>
84+
public Emu TopInset { get; }
85+
}
86+
}

0 commit comments

Comments
 (0)