Skip to content

Commit

Permalink
Check other parts
Browse files Browse the repository at this point in the history
  • Loading branch information
rstm-sf committed Nov 26, 2022
1 parent 8138507 commit e8af583
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 30 deletions.
34 changes: 13 additions & 21 deletions OfficeIMO.VerifyTests/Word/AdvancedDocumentTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using System.Globalization;
using System.Text;
using System.Threading.Tasks;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
Expand All @@ -13,28 +13,20 @@ namespace OfficeIMO.VerifyTests.Word;
public class AdvancedDocumentTests : VerifyTestBase {

private static async Task DoTest(WordprocessingDocument wordprocessingDocument) {
var document = wordprocessingDocument.MainDocumentPart!.Document;

var i = 1;
foreach (var hyperlink in document.Descendants<Hyperlink>()) {
hyperlink.Id = "R" + i.ToString(CultureInfo.InvariantCulture);
i++;
}

i = 1;
foreach (var headerReference in document.Descendants<HeaderReference>()) {
headerReference.Id = "R" + i.ToString(CultureInfo.InvariantCulture);
i++;
}

i = 1;
foreach (var footerReference in document.Descendants<FooterReference>()) {
footerReference.Id = "R" + i.ToString(CultureInfo.InvariantCulture);
i++;
NormalizeWord(wordprocessingDocument);

var result = new StringBuilder();
foreach (var id in wordprocessingDocument.Parts) {
if (id.OpenXmlPart.RootElement is null)
continue;
var xml = FormatXml(id.OpenXmlPart.RootElement.OuterXml);
result.AppendLine(id.OpenXmlPart.Uri.ToString());
result.AppendLine("------------");
result.AppendLine(xml);
result.AppendLine("------------");
}

var xml = FormatXml(document.MainDocumentPart!.Document.OuterXml);
await Verifier.Verify(xml, GetSettings());
await Verifier.Verify(result.ToString(), GetSettings());
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-16"?>
/word/document.xml
------------
<?xml version="1.0" encoding="utf-16"?>
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:body>
<w:sdt>
Expand Down Expand Up @@ -666,7 +668,7 @@
<w:pPr>
<w:jc w:val="center" />
</w:pPr>
<w:hyperlink w:tooltip="URL with tooltip" w:history="true" r:id="R1" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<w:hyperlink w:tooltip="URL with tooltip" w:history="true" r:id="R00000001" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<w:r>
<w:rPr>
<w:rStyle w:val="Hyperlink" />
Expand Down Expand Up @@ -702,7 +704,7 @@
<w:rPr />
<w:t xml:space="preserve">4th element with hyperlink </w:t>
</w:r>
<w:hyperlink w:history="true" r:id="R2" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<w:hyperlink w:history="true" r:id="R00000002" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<w:r>
<w:rPr>
<w:rStyle w:val="Hyperlink" />
Expand Down Expand Up @@ -771,8 +773,8 @@
<w:p>
<w:pPr>
<w:sectPr>
<w:headerReference w:type="default" r:id="R1" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" />
<w:footerReference w:type="default" r:id="R1" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" />
<w:headerReference w:type="default" r:id="R00000001" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" />
<w:footerReference w:type="default" r:id="R00000001" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" />
</w:sectPr>
</w:pPr>
</w:p>
Expand Down Expand Up @@ -813,4 +815,27 @@
<w:pgSz w:w="8391" w:h="11906" w:code="11" />
</w:sectPr>
</w:body>
</w:document>
</w:document>
------------
/docProps/app.xml
------------
<?xml version="1.0" encoding="utf-16"?>
<ap:Properties xmlns:ap="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties">
<ap:Company>Evotec Services</ap:Company>
</ap:Properties>
------------
/docProps/custom.xml
------------
<?xml version="1.0" encoding="utf-16"?>
<op:Properties xmlns:op="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties">
<op:property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="TestProperty">
<vt:filetime xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">9999-12-31T23:59:59Z</vt:filetime>
</op:property>
<op:property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="3" name="MyName">
<vt:lpwstr xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">Some text</vt:lpwstr>
</op:property>
<op:property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="4" name="IsTodayGreatDay">
<vt:bool xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">true</vt:bool>
</op:property>
</op:Properties>
------------
2 changes: 2 additions & 0 deletions OfficeImo.sln
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
Directory.Build.props = Directory.Build.props
.editorconfig = .editorconfig
azure-pipelines-linux.yml = azure-pipelines-linux.yml
azure-pipelines-macos.yml = azure-pipelines-macos.yml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OfficeIMO.Excel", "OfficeIMO.Excel\OfficeIMO.Excel.csproj", "{80B77D75-D25C-4168-B6A3-FA58DB118EF8}"
Expand Down
6 changes: 3 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ steps:
version: '7.0.x'

- task: UseDotNet@2
displayName: Install .NET 3.1
displayName: 'Install .NET 3.1'
inputs:
version: '3.1.x'
packageType: sdk
packageType: 'sdk'
includePreviewVersions: false

# Add a Command To List the Current .NET SDKs (Sanity Check)
Expand Down Expand Up @@ -103,4 +103,4 @@ steps:
# displayName: 'Publish Code Coverage Report'
# inputs:
# codeCoverageTool: 'Cobertura'
# summaryFileLocation: '$(Agent.TempDirectory)/**/coverage.cobertura.xml'
# summaryFileLocation: '$(Agent.TempDirectory)/**/coverage.cobertura.xml'

0 comments on commit e8af583

Please sign in to comment.