ReplaceToTable signatures
This commit is contained in:
@@ -20,7 +20,8 @@ public interface IWordWriter : IWordReader
|
||||
void ReplaceString(IEnumerable<KeyValuePair<string, string>> replacements);
|
||||
void ReplaceString(string oldValue, IEnumerable<string> newValues);
|
||||
void ReplaceString(string oldValue, params string[] newValues);
|
||||
void ReplaceToTable(string oldValue, Action<ITable> buildTable, FontProps? baseFont = null);
|
||||
void ReplaceToTable(string oldValue, Action<ITable> buildTable);
|
||||
void ReplaceToTable(string oldValue, FontProps baseFont, Action<ITable> buildTable);
|
||||
void ReplaceToText(string oldValue, Action<IText> buildText);
|
||||
void Save();
|
||||
void SaveTo(string path);
|
||||
|
||||
@@ -382,7 +382,7 @@ internal sealed class WordWriter : WordReader, IWordWriter
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Текст для поиска в параграфах</param>
|
||||
/// <param name="buildTable">Действие для настройки таблицы через TableBuilder</param>
|
||||
public void ReplaceToTable(string oldValue, Action<ITable> buildTable, FontProps? baseFont = null)
|
||||
public void ReplaceToTable(string oldValue, FontProps baseFont, Action<ITable> buildTable)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
|
||||
@@ -403,6 +403,32 @@ internal sealed class WordWriter : WordReader, IWordWriter
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Заменяет параграф, содержащий указанный текст, на таблицу, созданную с помощью TableBuilder
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Текст для поиска в параграфах</param>
|
||||
/// <param name="buildTable">Действие для настройки таблицы через TableBuilder</param>
|
||||
public void ReplaceToTable(string oldValue, Action<ITable> buildTable)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
|
||||
if (string.IsNullOrEmpty(oldValue))
|
||||
throw new ArgumentException("Old value cannot be null or empty", nameof(oldValue));
|
||||
|
||||
if (buildTable is null) return;
|
||||
|
||||
#if DEBUG
|
||||
Debug.WriteLine($"[DEBUG] [WordProcessor.ReplaceToTable] Looking for '{oldValue}' to replace with custom table");
|
||||
#endif
|
||||
|
||||
lock (_syncLock)
|
||||
{
|
||||
// Используем метод расширения для Body с TableBuilder
|
||||
ReplaceToTableExt.ReplaceParagraphsContainingTextToTable(_body, oldValue, buildTable);
|
||||
_isModified = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Replace to text
|
||||
|
||||
Reference in New Issue
Block a user