diff --git a/QWERTYkez.WordProcessor/Builders/FontProps.cs b/QWERTYkez.WordProcessor/Builders/FontProps.cs index 5fc1573..381eb9b 100644 --- a/QWERTYkez.WordProcessor/Builders/FontProps.cs +++ b/QWERTYkez.WordProcessor/Builders/FontProps.cs @@ -16,9 +16,9 @@ public record FontProps } uint? _SizeD; - public bool? IsItalic { get; init; } = false; + public bool? IsItalic { get; init; } - public bool? IsBold { get; init; } = false; + public bool? IsBold { get; init; } public UnderlineValues? Underline { get; init; } diff --git a/QWERTYkez.WordProcessor/Builders/Interfaces.cs b/QWERTYkez.WordProcessor/Builders/Interfaces.cs index 6b1cb72..790ab3a 100644 --- a/QWERTYkez.WordProcessor/Builders/Interfaces.cs +++ b/QWERTYkez.WordProcessor/Builders/Interfaces.cs @@ -8,24 +8,24 @@ public interface ITable /// Добавляет строку в таблицу, настраиваемую с помощью . /// Делегат для конфигурации строки через . /// Тот же экземпляр для цепочки вызовов. - ITable AddRow(Action configure); + ITable Row(Action configure); /// Добавляет строку с указанной высотой, настраиваемую с помощью . /// Высота строки в сантиметрах. /// Делегат для конфигурации строки через . /// Тот же экземпляр для цепочки вызовов. - ITable AddRow(double height, Action configure); + ITable Row(double height, Action configure); /// Добавляет строку с ячейками, содержащими заданные тексты, используя указанный шрифт. /// Шрифт для всех ячеек строки. /// Массив текстов для ячеек. /// Тот же экземпляр для цепочки вызовов. - ITable AddRowWithCells(FontProps font, params string[] cellTexts); + ITable RowWithCells(FontProps font, params string[] cellTexts); /// Добавляет строку с ячейками, содержащими заданные тексты, используя базовый шрифт таблицы. /// Массив текстов для ячеек. /// Тот же экземпляр для цепочки вызовов. - ITable AddRowWithCells(params string[] cellTexts); + ITable RowWithCells(params string[] cellTexts); /// Задаёт свойства таблицы: ширину и стиль границ, выравнивание. /// Ширина границ в пунктах (1/8 pt). По умолчанию 8. @@ -47,47 +47,47 @@ public interface IRow /// Добавляет ячейку, настраиваемую с помощью . /// Делегат для конфигурации ячейки через . /// Тот же экземпляр для цепочки вызовов. - IRow AddCell(Action configure); + IRow Cell(Action configure); /// Добавляет ячейку с заданными свойствами (без текста). /// Свойства ячейки (ширина, объединение, вертикальное выравнивание). /// Тот же экземпляр для цепочки вызовов. - IRow AddCell(CellProps cellProps); + IRow Cell(CellProps cellProps); /// Добавляет ячейку с заданными свойствами и текстом (используется базовый шрифт). /// Свойства ячейки. /// Текст ячейки. /// Тот же экземпляр для цепочки вызовов. - IRow AddCell(CellProps cellProps, string text); + IRow Cell(CellProps cellProps, string text); /// Добавляет ячейку с заданными свойствами, текстом и указанным шрифтом. /// Свойства ячейки. /// Текст ячейки. /// Шрифт для текста. Если , используется базовый шрифт. /// Тот же экземпляр для цепочки вызовов. - IRow AddCell(CellProps cellProps, string text, FontProps font); + IRow Cell(CellProps cellProps, string text, FontProps font); /// Добавляет ячейку с простым текстом (используется базовый шрифт). /// Текст ячейки. /// Тот же экземпляр для цепочки вызовов. - IRow AddCell(string text); + IRow Cell(string text); /// Добавляет ячейку с простым текстом и указанным шрифтом. /// Текст ячейки. /// Шрифт для текста. Если , используется базовый шрифт. /// Тот же экземпляр для цепочки вызовов. - IRow AddCell(string text, FontProps font); + IRow Cell(string text, FontProps font); /// Добавляет ячейку, содержащую один абзац, построенный с помощью . /// Делегат для конфигурации абзаца через . /// Тот же экземпляр для цепочки вызовов. - IRow AddCellWithPara(Action configure); + IRow CellWithPara(Action configure); /// Добавляет ячейку с указанными свойствами, содержащую один абзац, построенный с помощью . /// Свойства ячейки. /// Делегат для конфигурации абзаца через . /// Тот же экземпляр для цепочки вызовов. - IRow AddCellWithPara(CellProps cellProps, Action configure); + IRow CellWithPara(CellProps cellProps, Action configure); /// Устанавливает точную высоту строки (свойство Exact). /// Высота в сантиметрах. @@ -117,23 +117,23 @@ public interface ICell /// Добавляет в ячейку абзац, содержащий математическую формулу. /// Делегат для конфигурации формулы через . /// Тот же экземпляр для цепочки вызовов. - ICell AddFormula(Action configure); + ICell Formula(Action configure); /// Добавляет в ячейку абзац, построенный с помощью . /// Делегат для конфигурации абзаца через . /// Тот же экземпляр для цепочки вызовов. - ICell AddParagraph(Action configure); + ICell Paragraph(Action configure); /// Добавляет в ячейку абзац, состоящий из нескольких строк текста (разделённых переносами). /// Массив строк, каждая строка будет размещена на новой строке абзаца. /// Тот же экземпляр для цепочки вызовов. - ICell AddParagraph(params string[] lines); + ICell Paragraph(params string[] lines); /// Добавляет в ячейку абзац с указанным текстом и опциональным шрифтом. /// Текст абзаца. /// Шрифт для текста. Если , используется базовый шрифт. /// Тот же экземпляр для цепочки вызовов. - ICell AddParagraph(string text, FontProps? font = null); + ICell Paragraph(string text, FontProps? font = null); /// Устанавливает свойства ячейки (ширина, объединение, вертикальное выравнивание). /// Свойства ячейки. @@ -153,25 +153,25 @@ public interface IText /// Добавляет в документ абзац, содержащий математическую формулу. /// Делегат для конфигурации формулы через . /// Тот же экземпляр для цепочки вызовов. - IText AddFormula(Action configure); + IText Formula(Action configure); /// Добавляет абзац, построенный с помощью . /// Делегат для конфигурации абзаца через . /// Тот же экземпляр для цепочки вызовов. - IText AddParagraph(Action configure); + IText Paragraph(Action configure); /// Добавляет абзац, состоящий из нескольких строк текста (разделённых переносами). /// Массив строк, каждая строка будет размещена на новой строке абзаца. /// Тот же экземпляр для цепочки вызовов. - IText AddParagraph(params string[] lines); + IText Paragraph(params string[] lines); /// Добавляет абзац с указанным текстом и опциональным шрифтом. /// Текст абзаца. /// Шрифт для текста. Если , используется базовый шрифт. /// Тот же экземпляр для цепочки вызовов. - IText AddParagraph(string text, FontProps? font = null); + IText Paragraph(string text, FontProps? font = null); - /// Создаёт список абзацев на основе выполненных настроек. + /// Создаёт список абзацев на основе выполненных настроек. /// Список готовых абзацев для вставки в документ. internal List Build(); } @@ -181,15 +181,15 @@ public interface IParagraph /// Базовый шрифт, используемый по умолчанию для содержимого абзаца. FontProps BaseFont { get; } - /// Добавляет в абзац математическую формулу (внутри отдельного ). + /// Добавляет в абзац математическую формулу (внутри отдельного ). /// Делегат для конфигурации формулы через . /// Тот же экземпляр для цепочки вызовов. - IParagraph AddFormula(Action configure); + IParagraph Formula(Action configure); - /// Добавляет в абзац математическую формулу (внутри отдельного ) и разрыв строки () в текущий абзац. + /// Добавляет в абзац математическую формулу (внутри отдельного ) и разрыв строки () в текущий абзац. /// Делегат для конфигурации формулы через . /// Тот же экземпляр для цепочки вызовов. - IParagraph AddFormulaBreak(Action configure); + IParagraph FormulaBreak(Action configure); /// Добавляет разрыв строки () в текущий абзац. /// Тот же экземпляр для цепочки вызовов. @@ -199,35 +199,35 @@ public interface IParagraph /// Тот же экземпляр для цепочки вызовов. IParagraph BreakPage(); - /// Добавляет текстовый фрагмент () с указанным текстом и опциональным шрифтом. + /// Добавляет текстовый фрагмент () с указанным текстом и опциональным шрифтом. /// Текст фрагмента. /// Шрифт для текста. Если , используется базовый шрифт. /// Тот же экземпляр для цепочки вызовов. - IParagraph AddRun(string text, FontProps? font = null); + IParagraph Run(string text, FontProps? font = null); - /// Добавляет текстовый фрагмент () с указанным текстом и опциональным шрифтом и разрыв строки () в текущий абзац. + /// Добавляет текстовый фрагмент () с указанным текстом и опциональным шрифтом и разрыв строки () в текущий абзац. /// Текст фрагмента. /// Шрифт для текста. Если , используется базовый шрифт. /// Тот же экземпляр для цепочки вызовов. - IParagraph AddRunBreak(string text, FontProps? font = null); + IParagraph RunBreak(string text, FontProps? font = null); /// Добавляет текстовый фрагмент с полным контролем над свойствами . /// Текст фрагмента. /// Делегат для настройки свойств фрагмента. /// Тот же экземпляр для цепочки вызовов. - IParagraph AddRunWithCustomProps(string text, Action configure); + IParagraph RunWithCustomProps(string text, Action configure); /// Добавляет текстовый фрагмент, отформатированный как нижний индекс (). /// Текст фрагмента. /// Базовый шрифт (свойства будут переопределены). /// Тот же экземпляр для цепочки вызовов. - IParagraph AddSubRun(string text, FontProps? font = null); + IParagraph Sub(string text, FontProps? font = null); /// Добавляет текстовый фрагмент, отформатированный как верхний индекс (). /// Текст фрагмента. /// Базовый шрифт (свойства будут переопределены). /// Тот же экземпляр для цепочки вызовов. - IParagraph AddSupRun(string text, FontProps? font = null); + IParagraph Sup(string text, FontProps? font = null); /// Устанавливает выравнивание абзаца. /// Тип выравнивания (лево, право, центр, по ширине). diff --git a/QWERTYkez.WordProcessor/Builders/ParagraphBuilderBase.cs b/QWERTYkez.WordProcessor/Builders/ParagraphBuilderBase.cs index edc5773..fe0dd23 100644 --- a/QWERTYkez.WordProcessor/Builders/ParagraphBuilderBase.cs +++ b/QWERTYkez.WordProcessor/Builders/ParagraphBuilderBase.cs @@ -69,7 +69,7 @@ abstract class ParagraphBuilderBase : IParagraph, IFormula } // Добавление текста - public IParagraph AddRun(string text, FontProps? font = null) + public IParagraph Run(string text, FontProps? font = null) { // Заменяем обычные пробелы на неразрывные для сохранения видимости string processedText = text.Replace(' ', '\u00A0'); @@ -91,7 +91,7 @@ abstract class ParagraphBuilderBase : IParagraph, IFormula } // Добавление текста - public IParagraph AddRunBreak(string text, FontProps? font = null) + public IParagraph RunBreak(string text, FontProps? font = null) { // Заменяем обычные пробелы на неразрывные для сохранения видимости string processedText = text.Replace(' ', '\u00A0'); @@ -116,7 +116,7 @@ abstract class ParagraphBuilderBase : IParagraph, IFormula } // Добавление текста - public IParagraph AddSupRun(string text, FontProps? font = null) + public IParagraph Sup(string text, FontProps? font = null) { var effectiveFont = GetEffectiveFont(font); Run run; @@ -135,7 +135,7 @@ abstract class ParagraphBuilderBase : IParagraph, IFormula } // Добавление текста - public IParagraph AddSubRun(string text, FontProps? font = null) + public IParagraph Sub(string text, FontProps? font = null) { var effectiveFont = GetEffectiveFont(font); Run run; @@ -153,7 +153,7 @@ abstract class ParagraphBuilderBase : IParagraph, IFormula return this; } - public IParagraph AddRunWithCustomProps(string text, Action configure) + public IParagraph RunWithCustomProps(string text, Action configure) { var props = new RunProperties(); configure(props); @@ -175,8 +175,8 @@ abstract class ParagraphBuilderBase : IParagraph, IFormula return this; } - // Метод AddFormula для IParagraphBuilder - IParagraph IParagraph.AddFormula(Action configure) + // Метод Formula для IParagraphBuilder + IParagraph IParagraph.Formula(Action configure) { var math = new MathOfficeMath(); try @@ -195,8 +195,8 @@ abstract class ParagraphBuilderBase : IParagraph, IFormula return this; } - // Метод AddFormula для IParagraphBuilder - IParagraph IParagraph.AddFormulaBreak(Action configure) + // Метод Formula для IParagraphBuilder + IParagraph IParagraph.FormulaBreak(Action configure) { var math = new MathOfficeMath(); try diff --git a/QWERTYkez.WordProcessor/Builders/TableBuilder.cs b/QWERTYkez.WordProcessor/Builders/TableBuilder.cs index 91155be..7a66061 100644 --- a/QWERTYkez.WordProcessor/Builders/TableBuilder.cs +++ b/QWERTYkez.WordProcessor/Builders/TableBuilder.cs @@ -40,7 +40,7 @@ internal sealed class TableBuilder : ParagraphBuilderBase, ITable, IRow, ICell } // Добавление строк с использованием IRowBuilder - public ITable AddRow(Action configure) + public ITable Row(Action configure) { var IRowBuilder = RowBuilder; configure(this); @@ -48,7 +48,7 @@ internal sealed class TableBuilder : ParagraphBuilderBase, ITable, IRow, ICell return this; } - public ITable AddRow(double height, Action configure) + public ITable Row(double height, Action configure) { var IRowBuilder = RowBuilder.SetHeight(height); configure(this); @@ -57,25 +57,25 @@ internal sealed class TableBuilder : ParagraphBuilderBase, ITable, IRow, ICell } // Быстрые методы для добавления строк с ячейками - public ITable AddRowWithCells(params string[] cellTexts) + public ITable RowWithCells(params string[] cellTexts) { - AddRow(row => + Row(row => { foreach (var text in cellTexts) { - row.AddCell(text); + row.Cell(text); } }); return this; } - public ITable AddRowWithCells(FontProps font, params string[] cellTexts) + public ITable RowWithCells(FontProps font, params string[] cellTexts) { - AddRow(row => + Row(row => { foreach (var text in cellTexts) { - row.AddCell(text, font); + row.Cell(text, font); } }); return this; @@ -155,7 +155,7 @@ internal sealed class TableBuilder : ParagraphBuilderBase, ITable, IRow, ICell } // Добавление ячеек - public IRow AddCell(Action configure) + public IRow Cell(Action configure) { var cellBuilder = CellBuilder; configure(this); @@ -163,47 +163,47 @@ internal sealed class TableBuilder : ParagraphBuilderBase, ITable, IRow, ICell return this; } - public IRow AddCell(string text) + public IRow Cell(string text) { var cellBuilder = CellBuilder; - cellBuilder.AddParagraph(p => p.AddRun(text)); + cellBuilder.Paragraph(p => p.Run(text)); _row.AppendChild(cellBuilder.Build()); return this; } - public IRow AddCell(string text, FontProps font) + public IRow Cell(string text, FontProps font) { var cellBuilder = CellBuilder; if (font is not null) - cellBuilder.AddParagraph(p => p.AddRun(text, font)); - else cellBuilder.AddParagraph(p => p.AddRun(text)); + cellBuilder.Paragraph(p => p.Run(text, font)); + else cellBuilder.Paragraph(p => p.Run(text)); _row.AppendChild(cellBuilder.Build()); return this; } - public IRow AddCell(CellProps cellProps, string text, FontProps font) + public IRow Cell(CellProps cellProps, string text, FontProps font) { var cellBuilder = CellBuilder.SetCellProps(cellProps); if (font is not null) - cellBuilder.AddParagraph(p => p.AddRun(text, font)); - else cellBuilder.AddParagraph(p => p.AddRun(text)); + cellBuilder.Paragraph(p => p.Run(text, font)); + else cellBuilder.Paragraph(p => p.Run(text)); _row.AppendChild(cellBuilder.Build()); return this; } - public IRow AddCell(CellProps cellProps, string text) + public IRow Cell(CellProps cellProps, string text) { var cellBuilder = CellBuilder.SetCellProps(cellProps); - cellBuilder.AddParagraph(p => p.AddRun(text)); + cellBuilder.Paragraph(p => p.Run(text)); _row.AppendChild(cellBuilder.Build()); return this; } - public IRow AddCell(CellProps cellProps) + public IRow Cell(CellProps cellProps) { var cellBuilder = CellBuilder.SetCellProps(cellProps); _row.AppendChild(cellBuilder.Build()); @@ -219,17 +219,17 @@ internal sealed class TableBuilder : ParagraphBuilderBase, ITable, IRow, ICell } - public IRow AddCellWithPara(Action configure) + public IRow CellWithPara(Action configure) { var cellBuilder = CellBuilder; - cellBuilder.AddParagraph(configure); + cellBuilder.Paragraph(configure); _row.AppendChild(cellBuilder.Build()); return this; } - public IRow AddCellWithPara(CellProps cellProps, Action configure) + public IRow CellWithPara(CellProps cellProps, Action configure) { var cellBuilder = CellBuilder.SetCellProps(cellProps); - cellBuilder.AddParagraph(configure); + cellBuilder.Paragraph(configure); _row.AppendChild(cellBuilder.Build()); return this; } @@ -276,7 +276,7 @@ internal sealed class TableBuilder : ParagraphBuilderBase, ITable, IRow, ICell } // Добавление параграфов - public ICell AddParagraph(Action configure) + public ICell Paragraph(Action configure) { var paraBuilder = ParagraphBuilder; configure(paraBuilder); @@ -284,44 +284,44 @@ internal sealed class TableBuilder : ParagraphBuilderBase, ITable, IRow, ICell return this; } - public ICell AddParagraph(string text, FontProps? font = null) + public ICell Paragraph(string text, FontProps? font = null) { var paraBuilder = ParagraphBuilder; if (font is not null) { - paraBuilder.AddRun(text, font); + paraBuilder.Run(text, font); } else { - paraBuilder.AddRun(text); + paraBuilder.Run(text); } _paragraphs.Add(paraBuilder.Build()); return this; } - public ICell AddParagraph(params string[] lines) + public ICell Paragraph(params string[] lines) { var paraBuilder = ParagraphBuilder; if (lines.Length > 0) { - paraBuilder.AddRun(lines[0]); + paraBuilder.Run(lines[0]); for (int i = 1; i < lines.Length; i++) { paraBuilder.Break(); - paraBuilder.AddRun(lines[i]); + paraBuilder.Run(lines[i]); } } _paragraphs.Add(paraBuilder.Build()); return this; } - // Метод AddFormula для ICellBuilder - ICell ICell.AddFormula(Action configure) + // Метод Formula для ICellBuilder + ICell ICell.Formula(Action configure) { var paraBuilder = ParagraphBuilder; - paraBuilder.AddFormula(configure); + paraBuilder.Formula(configure); _paragraphs.Add(paraBuilder.Build()); return this; } diff --git a/QWERTYkez.WordProcessor/Builders/TextBuilder.cs b/QWERTYkez.WordProcessor/Builders/TextBuilder.cs index 16995af..da26507 100644 --- a/QWERTYkez.WordProcessor/Builders/TextBuilder.cs +++ b/QWERTYkez.WordProcessor/Builders/TextBuilder.cs @@ -58,16 +58,16 @@ internal sealed class TextBuilder : ParagraphBuilderBase, IText private readonly List _paragraphs = []; public List Build() => _paragraphs; - IText IText.AddFormula(Action configure) + IText IText.Formula(Action configure) { var paraBuilder = ParagraphBuilder; - paraBuilder.AddFormula(configure); + paraBuilder.Formula(configure); _paragraphs.Add(paraBuilder.Build()); return this; } // Добавление параграфов - public IText AddParagraph(Action configure) + public IText Paragraph(Action configure) { var paraBuilder = ParagraphBuilder; configure(paraBuilder); @@ -75,33 +75,33 @@ internal sealed class TextBuilder : ParagraphBuilderBase, IText return this; } - public IText AddParagraph(string text, FontProps? font = null) + public IText Paragraph(string text, FontProps? font = null) { var paraBuilder = ParagraphBuilder; if (font is not null) { - paraBuilder.AddRun(text, font); + paraBuilder.Run(text, font); } else { - paraBuilder.AddRun(text); + paraBuilder.Run(text); } _paragraphs.Add(paraBuilder.Build()); return this; } - public IText AddParagraph(params string[] lines) + public IText Paragraph(params string[] lines) { var paraBuilder = ParagraphBuilder; if (lines.Length > 0) { - paraBuilder.AddRun(lines[0]); + paraBuilder.Run(lines[0]); for (int i = 1; i < lines.Length; i++) { paraBuilder.Break(); - paraBuilder.AddRun(lines[i]); + paraBuilder.Run(lines[i]); } } _paragraphs.Add(paraBuilder.Build()); diff --git a/QWERTYkez.WordProcessor/ReplaceToTableExt.cs b/QWERTYkez.WordProcessor/ReplaceToTableExt.cs index 6a39ea8..5ed0e58 100644 --- a/QWERTYkez.WordProcessor/ReplaceToTableExt.cs +++ b/QWERTYkez.WordProcessor/ReplaceToTableExt.cs @@ -67,7 +67,7 @@ internal static class ReplaceToTableExt var fontProps = ExtractFontPropsFromParagraph(paragraph, oldValue); if (fontProps is { } props) - props.Override(baseFont); + fontProps = props.Override(baseFont); // Заменяем параграф на таблицу ReplaceWithTableBuilder(paragraph, buildTable, fontProps);