Skip to content

Commit 1c05cd2

Browse files
committed
Fix naming conflict
1 parent 1c7aec0 commit 1c05cd2

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

src/DocSharp.Common/Primitives/PageMargins.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace DocSharp;
1+
namespace DocSharp.Primitives;
22

33
public class PageMargins
44
{

src/DocSharp.Common/Primitives/PageSize.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Globalization;
22

3-
namespace DocSharp;
3+
namespace DocSharp.Primitives;
44

55
public class PageSize
66
{

src/DocSharp.Epub/EpubToDocxConverter.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
using System.Threading.Tasks;
99
using System.Xml.Linq;
1010
using DocSharp.Helpers;
11-
using DocSharp;
11+
using DocSharp.Primitives;
1212
using DocumentFormat.OpenXml;
1313
using DocumentFormat.OpenXml.Packaging;
14-
using DocumentFormat.OpenXml.Wordprocessing;
1514
using W = DocumentFormat.OpenXml.Wordprocessing;
1615
using EpubCore;
1716
using HtmlToOpenXml;
@@ -104,9 +103,9 @@ public async Task BuildDocxAsync(Stream input, WordprocessingDocument targetDocu
104103
{
105104
// Initialize document
106105
var mainPart = targetDocument.MainDocumentPart ?? targetDocument.AddMainDocumentPart();
107-
mainPart.Document ??= new Document();
106+
mainPart.Document ??= new W.Document();
108107
mainPart.Document.RemoveAllChildren();
109-
var body = mainPart.Document.AppendChild(new Body());
108+
var body = mainPart.Document.AppendChild(new W.Body());
110109

111110
// Initialize HTML to DOCX converter
112111
var converter = new HtmlConverter(mainPart)
@@ -152,9 +151,9 @@ public async Task BuildDocxAsync(Stream input, WordprocessingDocument targetDocu
152151
// Before each chapter, add a bookmark in DOCX to make internal links work
153152
string anchorName = $"_{fileName.Replace(' ', '_')}";
154153
int id = new Random().Next(100000, 999999); // TODO: improve id generation
155-
body.AppendChild(new Paragraph([
156-
new BookmarkStart() { Name = anchorName, Id = id.ToString() },
157-
new BookmarkEnd() { Id = id.ToString() }
154+
body.AppendChild(new W.Paragraph([
155+
new W.BookmarkStart() { Name = anchorName, Id = id.ToString() },
156+
new W.BookmarkEnd() { Id = id.ToString() }
158157
]));
159158

160159
// Parse the HTML body, convert to Open XML and append to the DOCX.
@@ -163,18 +162,18 @@ public async Task BuildDocxAsync(Stream input, WordprocessingDocument targetDocu
163162
if (PageBreakAfterChapters)
164163
{
165164
// Add a page break after each chapter if desired.
166-
body.AppendChild(new Paragraph(new Run(new Break() { Type = BreakValues.Page })));
165+
body.AppendChild(new W.Paragraph(new W.Run(new W.Break() { Type = W.BreakValues.Page })));
167166
}
168167
}
169168

170169
// Add default section properties
171-
body.AppendChild(new SectionProperties(
170+
body.AppendChild(new W.SectionProperties(
172171
new W.PageSize()
173172
{
174173
Width = (uint)((PageSize ?? PageSize.Default).WidthTwips()),
175174
Height = (uint)((PageSize ?? PageSize.Default).HeightTwips()),
176175
},
177-
new PageMargin()
176+
new W.PageMargin()
178177
{
179178
// Notes:
180179
// - PageMargin uses uint for Left and Right margins, and int for top and bottom (enforced by Open XML SDK)

src/DocSharp.Markdown/MarkdownConverter.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
using Markdig.Renderers.Docx;
99
using Markdig.Renderers.Rtf;
1010
using DocSharp.Writers;
11-
using DocSharp;
11+
using DocSharp.Primitives;
1212
using System;
1313
using System.Linq;
14-
using DocumentFormat.OpenXml.Wordprocessing;
1514
using W = DocumentFormat.OpenXml.Wordprocessing;
1615

1716
namespace DocSharp.Markdown;
@@ -331,10 +330,10 @@ private void ApplyPageSettingsToDocx(WordprocessingDocument document)
331330
{
332331
if (document?.MainDocumentPart == null) return;
333332

334-
var sect = document.MainDocumentPart.Document.Body.Elements<SectionProperties>().LastOrDefault();
333+
var sect = document.MainDocumentPart.Document.Body.Elements<W.SectionProperties>().LastOrDefault();
335334
if (sect == null)
336335
{
337-
sect = new SectionProperties();
336+
sect = new W.SectionProperties();
338337
document.MainDocumentPart.Document.Body.AppendChild(sect);
339338
}
340339

@@ -353,12 +352,12 @@ private void ApplyPageSettingsToDocx(WordprocessingDocument document)
353352
// Page margins
354353
if (PageMargins != null)
355354
{
356-
var pm = sect.GetFirstChild<PageMargin>() ?? new PageMargin();
355+
var pm = sect.GetFirstChild<W.PageMargin>() ?? new W.PageMargin();
357356
pm.Left = (uint)PageMargins.LeftTwips();
358357
pm.Right = (uint)PageMargins.RightTwips();
359358
pm.Top = (int)PageMargins.TopTwips();
360359
pm.Bottom = (int)PageMargins.BottomTwips();
361-
if (sect.GetFirstChild<PageMargin>() == null)
360+
if (sect.GetFirstChild<W.PageMargin>() == null)
362361
sect.AppendChild(pm);
363362
}
364363
}

0 commit comments

Comments
 (0)