diff --git a/QWERTYkez.WordProcessor/IWordWriter.cs b/QWERTYkez.WordProcessor/IWordWriter.cs index 6e45720..9f9079d 100644 --- a/QWERTYkez.WordProcessor/IWordWriter.cs +++ b/QWERTYkez.WordProcessor/IWordWriter.cs @@ -20,7 +20,7 @@ public interface IWordWriter : IWordReader void ReplaceString(IEnumerable> replacements); void ReplaceString(string oldValue, IEnumerable newValues); void ReplaceString(string oldValue, params string[] newValues); - void ReplaceToTable(string oldValue, Action buildTable); + void ReplaceToTable(string oldValue, Action buildTable, FontProps? baseFont = null); void ReplaceToText(string oldValue, Action buildText); void Save(); void SaveTo(string path); diff --git a/QWERTYkez.WordProcessor/ReplaceToTableExt.cs b/QWERTYkez.WordProcessor/ReplaceToTableExt.cs index b1f54f8..e8b9174 100644 --- a/QWERTYkez.WordProcessor/ReplaceToTableExt.cs +++ b/QWERTYkez.WordProcessor/ReplaceToTableExt.cs @@ -44,7 +44,7 @@ internal static class ReplaceToTableExt /// Заменяет все параграфы, содержащие указанный текст, на таблицы /// internal static void ReplaceParagraphsContainingTextToTable(Body body, - string oldValue, Action buildTable) + string oldValue, Action buildTable, FontProps? baseFont = null) { if (body is null || string.IsNullOrEmpty(oldValue) || buildTable is null) return; @@ -64,10 +64,10 @@ internal static class ReplaceToTableExt continue; // Извлекаем свойства шрифта для передачи в TableBuilder - var fontProps = ExtractFontPropsFromParagraph(paragraph, oldValue); + baseFont ??= ExtractFontPropsFromParagraph(paragraph, oldValue); // Заменяем параграф на таблицу - ReplaceWithTableBuilder(paragraph, buildTable, fontProps); + ReplaceWithTableBuilder(paragraph, buildTable, baseFont); } } diff --git a/QWERTYkez.WordProcessor/WordWriter.cs b/QWERTYkez.WordProcessor/WordWriter.cs index 0013cc0..42a21e8 100644 --- a/QWERTYkez.WordProcessor/WordWriter.cs +++ b/QWERTYkez.WordProcessor/WordWriter.cs @@ -382,7 +382,7 @@ internal sealed class WordWriter : WordReader, IWordWriter /// /// Текст для поиска в параграфах /// Действие для настройки таблицы через TableBuilder - public void ReplaceToTable(string oldValue, Action buildTable) + public void ReplaceToTable(string oldValue, Action buildTable, FontProps? baseFont = null) { ThrowIfDisposed(); @@ -398,7 +398,7 @@ internal sealed class WordWriter : WordReader, IWordWriter lock (_syncLock) { // Используем метод расширения для Body с TableBuilder - ReplaceToTableExt.ReplaceParagraphsContainingTextToTable(_body, oldValue, buildTable); + ReplaceToTableExt.ReplaceParagraphsContainingTextToTable(_body, oldValue, buildTable, baseFont); _isModified = true; } }