From 2229f0f276a49a9f18e0682ff0d361844f263f5a Mon Sep 17 00:00:00 2001 From: melekhin Date: Mon, 7 Sep 2026 15:52:23 +0700 Subject: [PATCH] $|$ --- QWERTYkez.WordProcessor/Extension.cs | 20 ++++++++++++++++++++ QWERTYkez.WordProcessor/IWordWriter.cs | 23 ++++++++++++++++++++--- QWERTYkez.WordProcessor/globals.cs | 3 ++- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/QWERTYkez.WordProcessor/Extension.cs b/QWERTYkez.WordProcessor/Extension.cs index 229efc7..3b602e2 100644 --- a/QWERTYkez.WordProcessor/Extension.cs +++ b/QWERTYkez.WordProcessor/Extension.cs @@ -28,4 +28,24 @@ internal static class Extension size.Width = new(h.Value); } } + + + /// + /// Возвращает индекс указанного элемента в коллекции. + /// + /// Коллекция элементов. + /// Элемент для поиска. + /// Индекс элемента, или -1, если элемент не найден. + public static int IndexOf(this OpenXmlElementList list, OpenXmlElement element) + { + if (list == null || element == null) + return -1; + + for (int i = 0; i < list.Count; i++) + { + if (list[i] == element) + return i; + } + return -1; + } } \ No newline at end of file diff --git a/QWERTYkez.WordProcessor/IWordWriter.cs b/QWERTYkez.WordProcessor/IWordWriter.cs index b664166..2fe8d3a 100644 --- a/QWERTYkez.WordProcessor/IWordWriter.cs +++ b/QWERTYkez.WordProcessor/IWordWriter.cs @@ -1,6 +1,4 @@ -using QWERTYkez.WordProcessor; - -namespace QWERTYkez.WordProcessor; +namespace QWERTYkez.WordProcessor; public interface IWordWriter : IWordReader { @@ -23,6 +21,25 @@ public interface IWordWriter : IWordReader void ReplaceToTable(string oldValue, Action buildTable); void ReplaceToTable(string oldValue, FontProps baseFont, Action buildTable); void ReplaceToText(string oldValue, Action buildText); + + + + + void ReplaceString(string oldValue, Func newValues); + void ReplaceString(string oldValue, Func> newValues); + void ReplaceString(string oldValue, Func newValues); + + void ReplaceItem(string oldValue, Func newValues); + void ReplaceItem(string oldValue, Func> newValues); + void ReplaceItem(string oldValue, Func newValues); + + void ReplaceToTable(string oldValue, Action buildTable); + void ReplaceToTable(string oldValue, FontProps baseFont, Action buildTable); + void ReplaceToText(string oldValue, Action buildText); + + + + void Save(); void SaveTo(string path); Task SaveToAsync(string path, CancellationToken cancellationToken = default); diff --git a/QWERTYkez.WordProcessor/globals.cs b/QWERTYkez.WordProcessor/globals.cs index f5f56eb..16c8030 100644 --- a/QWERTYkez.WordProcessor/globals.cs +++ b/QWERTYkez.WordProcessor/globals.cs @@ -8,4 +8,5 @@ global using System.IO; global using System.Linq; global using System.Text; global using System.Threading; -global using System.Threading.Tasks; \ No newline at end of file +global using System.Threading.Tasks; +global using System.Text.RegularExpressions; \ No newline at end of file