From a17e888901e2d06ff7b2fa11a2fc6ab6681ccb4e Mon Sep 17 00:00:00 2001 From: kotcheshir73 Date: Mon, 19 Dec 2022 11:16:24 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=BE=20=D0=BF=D0=B0=D0=BA=D0=B5=D1=82=D1=83=20word?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WordOpenXML/BuilderWordDocumentOpenXML.cs | 10 -- .../Extensions/WordDocumentExtension.cs | 100 ------------------ .../WordOpenXML/Models/WordCreateDocument.cs | 18 ---- .../WordOpenXML/Models/WordDocumentParts.cs | 17 --- 4 files changed, 145 deletions(-) delete mode 100644 DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Models/WordCreateDocument.cs delete mode 100644 DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Models/WordDocumentParts.cs diff --git a/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/BuilderWordDocumentOpenXML.cs b/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/BuilderWordDocumentOpenXML.cs index 4e500cc..d570d02 100644 --- a/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/BuilderWordDocumentOpenXML.cs +++ b/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/BuilderWordDocumentOpenXML.cs @@ -3,7 +3,6 @@ using DocumentFormat.OpenXml.Packaging; using DocumentFormat.OpenXml.Wordprocessing; using System.IO; using ToolsOffice.Implements.WordOpenXML.Extensions; -using ToolsOffice.Implements.WordOpenXML.Models; using ToolsOffice.Interfaces.Word; using ToolsOffice.Interfaces.Word.Models; @@ -19,20 +18,11 @@ namespace ToolsOffice.Implements.WordOpenXML public override void CreateDocument(ModelWordDocument model) { - var doc = WordCreateDocument.Create(model); - if (doc == null) - { - return; - } _memoryStream = new MemoryStream(); _wordDocument = WordprocessingDocument.Create(_memoryStream, WordprocessingDocumentType.Document); var mainPart = _wordDocument.AddMainDocumentPart(); mainPart.Document = new Document(); _docBody = mainPart.Document.AppendChild(new Body()); - if (doc != null) - { - mainPart.AddParts(doc.WordDocumentParts); - } } public override void CreateParagraph(ModelWordParagraph model) diff --git a/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Extensions/WordDocumentExtension.cs b/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Extensions/WordDocumentExtension.cs index 4830972..4132b88 100644 --- a/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Extensions/WordDocumentExtension.cs +++ b/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Extensions/WordDocumentExtension.cs @@ -1,34 +1,12 @@ using DocumentFormat.OpenXml; -using DocumentFormat.OpenXml.Packaging; using DocumentFormat.OpenXml.Wordprocessing; using System; -using ToolsModule.ManagmentExtension; -using ToolsOffice.Implements.WordOpenXML.Models; using ToolsOffice.Interfaces.Word.Models; namespace ToolsOffice.Implements.WordOpenXML.Extensions { public static class WordDocumentExtension { - /// - /// Добавление общих элементов документа - /// - /// - /// - public static void AddParts(this MainDocumentPart mainPart, WordDocumentParts parts) - { - if (parts == null) - { - return; - } - CreateDocumentSettingsPart(parts, mainPart); - CreateFontTablesPart(parts, mainPart); - CreateNumberingsPart(parts, mainPart); - CreateStyleDefinitionsPart(parts, mainPart); - CreateThemePart(parts, mainPart); - CreateWebSetting(parts, mainPart); - } - /// /// Добавление общих настроек документа /// @@ -87,83 +65,5 @@ namespace ToolsOffice.Implements.WordOpenXML.Extensions body.AppendChild(properties); } - - private static void CreateDocumentSettingsPart(WordDocumentParts parts, MainDocumentPart mainPart) - { - if (parts.DocumentSettings.IsNotEmpty()) - { - var settings = mainPart.AddNewPart(); - settings.Settings = new Settings - { - InnerXml = parts.DocumentSettings - }; - settings.Settings.Save(); - } - } - - private static void CreateFontTablesPart(WordDocumentParts parts, MainDocumentPart mainPart) - { - if (parts.FontTable.IsNotEmpty()) - { - var fonts = mainPart.AddNewPart(); - fonts.Fonts = new Fonts - { - InnerXml = parts.FontTable - }; - fonts.Fonts.Save(); - } - } - - private static void CreateNumberingsPart(WordDocumentParts parts, MainDocumentPart mainPart) - { - if (parts.NumberingDefinitions.IsNotEmpty()) - { - var numbering = mainPart.AddNewPart(); - numbering.Numbering = new Numbering - { - InnerXml = parts.NumberingDefinitions - }; - numbering.Numbering.Save(); - } - } - - private static void CreateStyleDefinitionsPart(WordDocumentParts parts, MainDocumentPart mainPart) - { - if (parts.StyleDefinitions.IsNotEmpty()) - { - var styles = mainPart.AddNewPart(); - styles.Styles = new Styles - { - InnerXml = parts.StyleDefinitions - }; - styles.Styles.Save(); - } - } - - private static void CreateThemePart(WordDocumentParts parts, MainDocumentPart mainPart) - { - if (parts.Theme.IsNotEmpty()) - { - var thems = mainPart.AddNewPart(); - thems.Theme = new DocumentFormat.OpenXml.Drawing.Theme - { - InnerXml = parts.Theme - }; - thems.Theme.Save(); - } - } - - private static void CreateWebSetting(WordDocumentParts parts, MainDocumentPart mainPart) - { - if (parts.WebSettings.IsNotEmpty()) - { - var settings = mainPart.AddNewPart(); - settings.WebSettings = new WebSettings - { - InnerXml = parts.WebSettings - }; - settings.WebSettings.Save(); - } - } } } \ No newline at end of file diff --git a/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Models/WordCreateDocument.cs b/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Models/WordCreateDocument.cs deleted file mode 100644 index a2a5df9..0000000 --- a/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Models/WordCreateDocument.cs +++ /dev/null @@ -1,18 +0,0 @@ -using ToolsOffice.Interfaces.Word.Models; - -namespace ToolsOffice.Implements.WordOpenXML.Models -{ - public class WordCreateDocument - { - public WordDocumentParts WordDocumentParts { get; set; } - - public static WordCreateDocument Create(ModelWordDocument model) - { - if (model == null) - { - return null; - } - return new WordCreateDocument(); - } - } -} \ No newline at end of file diff --git a/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Models/WordDocumentParts.cs b/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Models/WordDocumentParts.cs deleted file mode 100644 index 47bfcfb..0000000 --- a/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Models/WordDocumentParts.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace ToolsOffice.Implements.WordOpenXML.Models -{ - public class WordDocumentParts - { - public string DocumentSettings { get; set; } - - public string FontTable { get; set; } - - public string NumberingDefinitions { get; set; } - - public string StyleDefinitions { get; set; } - - public string Theme { get; set; } - - public string WebSettings { get; set; } - } -} \ No newline at end of file