diff --git a/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Extensions/WordDocumentExtension.cs b/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Extensions/WordDocumentExtension.cs index d6019fb..c2e8712 100644 --- a/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Extensions/WordDocumentExtension.cs +++ b/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Extensions/WordDocumentExtension.cs @@ -1,6 +1,7 @@ using DocumentFormat.OpenXml; using DocumentFormat.OpenXml.Wordprocessing; using System; +using ToolsOffice.Interfaces; using ToolsOffice.Interfaces.Word.Models; namespace ToolsOffice.Implements.WordOpenXML.Extensions @@ -8,6 +9,7 @@ namespace ToolsOffice.Implements.WordOpenXML.Extensions public static class WordDocumentExtension { private static readonly int _coefToPoins = 567; + /// /// Добавление общих настроек документа /// @@ -70,5 +72,16 @@ namespace ToolsOffice.Implements.WordOpenXML.Extensions body.AppendChild(properties); } + + /// + /// Получение шрифта из FontNames + /// + /// + /// + public static (string Ascii, string HighAnsi, string ComplexScript) GetFontName(FontNames fn) => fn switch + { + FontNames.TimesNewRoman => ("Times New Roman", "Times New Roman", "Times New Roman"), + _ => default, + }; } } \ No newline at end of file diff --git a/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Extensions/WordParagraphExtension.cs b/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Extensions/WordParagraphExtension.cs index 82e011c..afc0759 100644 --- a/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Extensions/WordParagraphExtension.cs +++ b/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Extensions/WordParagraphExtension.cs @@ -2,7 +2,6 @@ using DocumentFormat.OpenXml.Wordprocessing; using System; using ToolsModule.ManagmentExtension; -using ToolsOffice.Interfaces; using ToolsOffice.Interfaces.Word.Models; namespace ToolsOffice.Implements.WordOpenXML.Extensions @@ -96,7 +95,7 @@ namespace ToolsOffice.Implements.WordOpenXML.Extensions var paragraphMarkRunProperties = new ParagraphMarkRunProperties(); if (model.FontName.HasValue) { - var font = GetFontName(model.FontName.Value); + var font = WordDocumentExtension.GetFontName(model.FontName.Value); paragraphMarkRunProperties.AppendChild(new RunFonts { Ascii = new StringValue(font.Ascii), @@ -138,37 +137,26 @@ namespace ToolsOffice.Implements.WordOpenXML.Extensions if (model.Text.IsNotEmpty()) { var text = new ModelWordText { Text = model.Text }; - CheckRunProps(model, text); + SyncRunProps(model, text); paragraph.AddRun(text); } else if (model.WordTexts != null) { foreach (var text in model.WordTexts) { - CheckRunProps(model, text); + SyncRunProps(model, text); paragraph.AddRun(text); } } return paragraph; } - /// - /// Получение шрифта из FontNames - /// - /// - /// - private static (string Ascii, string HighAnsi, string ComplexScript) GetFontName(FontNames fn) => fn switch - { - FontNames.TimesNewRoman => ("Times New Roman", "Times New Roman", "Times New Roman"), - _ => default, - }; - /// /// Пеоедача параметров текста из параметров абзаца, если не заданы параметры текста /// /// /// - private static void CheckRunProps(ModelWordParagraph paragraph, ModelWordText run) + private static void SyncRunProps(ModelWordParagraph paragraph, ModelWordText run) { if (run == null) { diff --git a/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Extensions/WordRunExtension.cs b/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Extensions/WordRunExtension.cs index b01b3dc..b8821d2 100644 --- a/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Extensions/WordRunExtension.cs +++ b/DepartmentPortal/Common/ToolsOffice/Implements/WordOpenXML/Extensions/WordRunExtension.cs @@ -1,6 +1,5 @@ using DocumentFormat.OpenXml; using DocumentFormat.OpenXml.Wordprocessing; -using ToolsOffice.Interfaces; using ToolsOffice.Interfaces.Word.Models; namespace ToolsOffice.Implements.WordOpenXML.Extensions @@ -52,7 +51,7 @@ namespace ToolsOffice.Implements.WordOpenXML.Extensions var properties = new RunProperties(); if (model.FontName.HasValue) { - var font = GetFontName(model.FontName.Value); + var font = WordDocumentExtension.GetFontName(model.FontName.Value); properties.AppendChild(new RunFonts { Ascii = new StringValue(font.Ascii), @@ -80,16 +79,5 @@ namespace ToolsOffice.Implements.WordOpenXML.Extensions run.AppendChild(properties); } } - - /// - /// Получение шрифта из FontNames - /// - /// - /// - private static (string Ascii, string HighAnsi, string ComplexScript) GetFontName(FontNames fn) => fn switch - { - FontNames.TimesNewRoman => ("Times New Roman", "Times New Roman", "Times New Roman"), - _ => default, - }; } } \ No newline at end of file diff --git a/DepartmentPortal/Common/ToolsOffice/Interfaces/Word/BuilderWordDocument.cs b/DepartmentPortal/Common/ToolsOffice/Interfaces/Word/BuilderWordDocument.cs index fbdf8a3..6e9c2b9 100644 --- a/DepartmentPortal/Common/ToolsOffice/Interfaces/Word/BuilderWordDocument.cs +++ b/DepartmentPortal/Common/ToolsOffice/Interfaces/Word/BuilderWordDocument.cs @@ -6,6 +6,11 @@ namespace ToolsOffice.Interfaces.Word { public abstract class BuilderWordDocument { + /// + /// Создание документа с заголовком и таблицей + /// + /// + /// public Stream CreateDocumentWithTable(ModelWordDocumentWithHeaderAndTable model) { if (model == null || model.Document == null || model.Header == null || model.Table == null) diff --git a/DepartmentPortal/Common/ToolsOffice/Interfaces/Word/Models/Cases/ModelWordDocumentWithHeaderAndTable.cs b/DepartmentPortal/Common/ToolsOffice/Interfaces/Word/Models/Cases/ModelWordDocumentWithHeaderAndTable.cs index 24bc2ef..f965a90 100644 --- a/DepartmentPortal/Common/ToolsOffice/Interfaces/Word/Models/Cases/ModelWordDocumentWithHeaderAndTable.cs +++ b/DepartmentPortal/Common/ToolsOffice/Interfaces/Word/Models/Cases/ModelWordDocumentWithHeaderAndTable.cs @@ -1,14 +1,23 @@ namespace ToolsOffice.Interfaces.Word.Models.Cases { /// - /// Модель для создания простого документа с шапкой и таблицей + /// Модель для создания простого документа с заголовком и таблицей /// public class ModelWordDocumentWithHeaderAndTable { + /// + /// Информация по документу + /// public ModelWordDocument Document { get; set; } + /// + /// Заголовок + /// public ModelWordParagraph Header { get; set; } + /// + /// Таблица + /// public ModelWordTable Table { get; set; } } } \ No newline at end of file diff --git a/DepartmentPortal/Common/ToolsOffice/Interfaces/Word/PageSizes.cs b/DepartmentPortal/Common/ToolsOffice/Interfaces/Word/WordPageSizes.cs similarity index 88% rename from DepartmentPortal/Common/ToolsOffice/Interfaces/Word/PageSizes.cs rename to DepartmentPortal/Common/ToolsOffice/Interfaces/Word/WordPageSizes.cs index 54bfe7d..71f4279 100644 --- a/DepartmentPortal/Common/ToolsOffice/Interfaces/Word/PageSizes.cs +++ b/DepartmentPortal/Common/ToolsOffice/Interfaces/Word/WordPageSizes.cs @@ -3,7 +3,10 @@ using System.Linq; namespace ToolsOffice.Interfaces.Word { - public class PageSizes + /// + /// Размеры страниц документов (портретная ориентация) + /// + public class WordPageSizes { private static readonly Dictionary _sizes = new() @@ -17,7 +20,7 @@ namespace ToolsOffice.Interfaces.Word private readonly string _key; - public PageSizes(string key) + public WordPageSizes(string key) { _hasKey = _sizes.ContainsKey(key); _key = key; diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/GenericBusinessLogic/StudentGroupBusinessLogic.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/GenericBusinessLogic/StudentGroupBusinessLogic.cs index 8295a6f..a994c5e 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/GenericBusinessLogic/StudentGroupBusinessLogic.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/GenericBusinessLogic/StudentGroupBusinessLogic.cs @@ -149,7 +149,7 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic rowIndex++; } - var pageSize = new PageSizes("А4"); + var pageSize = new WordPageSizes("А4"); var docModel = new ModelWordDocumentWithHeaderAndTable { Document = new ModelWordDocument