word table base font

This commit is contained in:
melekhin
2026-09-01 15:45:39 +07:00
parent 7fec0ea1bf
commit 11b4d4674a
3 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ public interface IWordWriter : IWordReader
void ReplaceString(IEnumerable<KeyValuePair<string, string>> replacements); void ReplaceString(IEnumerable<KeyValuePair<string, string>> replacements);
void ReplaceString(string oldValue, IEnumerable<string> newValues); void ReplaceString(string oldValue, IEnumerable<string> newValues);
void ReplaceString(string oldValue, params string[] newValues); void ReplaceString(string oldValue, params string[] newValues);
void ReplaceToTable(string oldValue, Action<ITable> buildTable); void ReplaceToTable(string oldValue, Action<ITable> buildTable, FontProps? baseFont = null);
void ReplaceToText(string oldValue, Action<IText> buildText); void ReplaceToText(string oldValue, Action<IText> buildText);
void Save(); void Save();
void SaveTo(string path); void SaveTo(string path);
+3 -3
View File
@@ -44,7 +44,7 @@ internal static class ReplaceToTableExt
/// Заменяет все параграфы, содержащие указанный текст, на таблицы /// Заменяет все параграфы, содержащие указанный текст, на таблицы
/// </summary> /// </summary>
internal static void ReplaceParagraphsContainingTextToTable(Body body, internal static void ReplaceParagraphsContainingTextToTable(Body body,
string oldValue, Action<TableBuilder> buildTable) string oldValue, Action<TableBuilder> buildTable, FontProps? baseFont = null)
{ {
if (body is null || string.IsNullOrEmpty(oldValue) || buildTable is null) if (body is null || string.IsNullOrEmpty(oldValue) || buildTable is null)
return; return;
@@ -64,10 +64,10 @@ internal static class ReplaceToTableExt
continue; continue;
// Извлекаем свойства шрифта для передачи в TableBuilder // Извлекаем свойства шрифта для передачи в TableBuilder
var fontProps = ExtractFontPropsFromParagraph(paragraph, oldValue); baseFont ??= ExtractFontPropsFromParagraph(paragraph, oldValue);
// Заменяем параграф на таблицу // Заменяем параграф на таблицу
ReplaceWithTableBuilder(paragraph, buildTable, fontProps); ReplaceWithTableBuilder(paragraph, buildTable, baseFont);
} }
} }
+2 -2
View File
@@ -382,7 +382,7 @@ internal sealed class WordWriter : WordReader, IWordWriter
/// </summary> /// </summary>
/// <param name="oldValue">Текст для поиска в параграфах</param> /// <param name="oldValue">Текст для поиска в параграфах</param>
/// <param name="buildTable">Действие для настройки таблицы через TableBuilder</param> /// <param name="buildTable">Действие для настройки таблицы через TableBuilder</param>
public void ReplaceToTable(string oldValue, Action<ITable> buildTable) public void ReplaceToTable(string oldValue, Action<ITable> buildTable, FontProps? baseFont = null)
{ {
ThrowIfDisposed(); ThrowIfDisposed();
@@ -398,7 +398,7 @@ internal sealed class WordWriter : WordReader, IWordWriter
lock (_syncLock) lock (_syncLock)
{ {
// Используем метод расширения для Body с TableBuilder // Используем метод расширения для Body с TableBuilder
ReplaceToTableExt.ReplaceParagraphsContainingTextToTable(_body, oldValue, buildTable); ReplaceToTableExt.ReplaceParagraphsContainingTextToTable(_body, oldValue, buildTable, baseFont);
_isModified = true; _isModified = true;
} }
} }