word table base font
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user