更新查找模式;更新查找(出发)标记模式

This commit is contained in:
LittleBoy 2024-08-20 22:44:20 +08:00
parent cdcbf03d92
commit 93b46c16bf
30 changed files with 1232 additions and 246 deletions

Binary file not shown.

View File

@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestConsoleApp", "TestConso
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "util-lib", "util-lib\util-lib.csproj", "{FF204E99-82F8-405E-847B-88FC6DF07715}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "updater", "updater\updater.csproj", "{73AC658D-CD49-4731-8491-A7BDBC811559}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -34,6 +36,12 @@ Global
{FF204E99-82F8-405E-847B-88FC6DF07715}.Release|Any CPU.Build.0 = Release|Any CPU
{FF204E99-82F8-405E-847B-88FC6DF07715}.Test|Any CPU.ActiveCfg = Test|Any CPU
{FF204E99-82F8-405E-847B-88FC6DF07715}.Test|Any CPU.Build.0 = Test|Any CPU
{73AC658D-CD49-4731-8491-A7BDBC811559}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{73AC658D-CD49-4731-8491-A7BDBC811559}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73AC658D-CD49-4731-8491-A7BDBC811559}.Release|Any CPU.ActiveCfg = Release|Any CPU
{73AC658D-CD49-4731-8491-A7BDBC811559}.Release|Any CPU.Build.0 = Release|Any CPU
{73AC658D-CD49-4731-8491-A7BDBC811559}.Test|Any CPU.ActiveCfg = Debug|Any CPU
{73AC658D-CD49-4731-8491-A7BDBC811559}.Test|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -125,6 +125,24 @@
-->
<ItemGroup>
<Reference Include="Accessibility" />
<Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938, processorArchitecture=MSIL">
<HintPath>..\packages\BouncyCastle.Cryptography.2.3.1\lib\net461\BouncyCastle.Cryptography.dll</HintPath>
</Reference>
<Reference Include="Enums.NET, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7ea1c1650d506225, processorArchitecture=MSIL">
<HintPath>..\packages\Enums.NET.4.0.1\lib\net45\Enums.NET.dll</HintPath>
</Reference>
<Reference Include="ExtendedNumerics.BigDecimal, Version=2025.1001.2.129, Culture=neutral, PublicKeyToken=65f1315a45ad8949, processorArchitecture=MSIL">
<HintPath>..\packages\ExtendedNumerics.BigDecimal.2025.1001.2.129\lib\net46\ExtendedNumerics.BigDecimal.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpZipLib, Version=1.4.2.13, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
<HintPath>..\packages\SharpZipLib.1.4.2\lib\netstandard2.0\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="MathNet.Numerics, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cd8b63ad3d691a37, processorArchitecture=MSIL">
<HintPath>..\packages\MathNet.Numerics.Signed.5.0.0\lib\net461\MathNet.Numerics.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IO.RecyclableMemoryStream, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IO.RecyclableMemoryStream.3.0.0\lib\netstandard2.0\Microsoft.IO.RecyclableMemoryStream.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.WebView2.Core, Version=1.0.2210.55, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Web.WebView2.1.0.2210.55\lib\net45\Microsoft.Web.WebView2.Core.dll</HintPath>
</Reference>
@ -137,15 +155,83 @@
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NPOI.Core, Version=2.7.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
<HintPath>..\packages\NPOI.2.7.1\lib\netstandard2.0\NPOI.Core.dll</HintPath>
</Reference>
<Reference Include="NPOI.OOXML, Version=2.7.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
<HintPath>..\packages\NPOI.2.7.1\lib\netstandard2.0\NPOI.OOXML.dll</HintPath>
</Reference>
<Reference Include="NPOI.OpenXml4Net, Version=2.7.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
<HintPath>..\packages\NPOI.2.7.1\lib\netstandard2.0\NPOI.OpenXml4Net.dll</HintPath>
</Reference>
<Reference Include="NPOI.OpenXmlFormats, Version=2.7.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
<HintPath>..\packages\NPOI.2.7.1\lib\netstandard2.0\NPOI.OpenXmlFormats.dll</HintPath>
</Reference>
<Reference Include="SixLabors.Fonts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d998eea7b14cab13, processorArchitecture=MSIL">
<HintPath>..\packages\SixLabors.Fonts.1.0.1\lib\netstandard2.0\SixLabors.Fonts.dll</HintPath>
</Reference>
<Reference Include="SixLabors.ImageSharp, Version=2.0.0.0, Culture=neutral, PublicKeyToken=d998eea7b14cab13, processorArchitecture=MSIL">
<HintPath>..\packages\SixLabors.ImageSharp.2.1.8\lib\netstandard2.0\SixLabors.ImageSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration.ConfigurationManager, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Configuration.ConfigurationManager.6.0.0\lib\net461\System.Configuration.ConfigurationManager.dll</HintPath>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Data.OracleClient" />
<Reference Include="System.Drawing" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Net" />
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Security" />
<Reference Include="System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.AccessControl.6.0.0\lib\net461\System.Security.AccessControl.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.Pkcs, Version=6.0.0.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Pkcs.6.0.3\lib\net461\System.Security.Cryptography.Pkcs.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.Xml, Version=6.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Xml.6.0.1\lib\net461\System.Security.Cryptography.Xml.dll</HintPath>
</Reference>
<Reference Include="System.Security.Permissions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Permissions.6.0.0\lib\net461\System.Security.Permissions.dll</HintPath>
</Reference>
<Reference Include="System.Security.Principal.Windows, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
</Reference>
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Text.Encoding.CodePages, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encoding.CodePages.5.0.0\lib\net461\System.Text.Encoding.CodePages.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Transactions" />
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Office.Tools.v4.0.Framework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
@ -234,16 +320,22 @@
<Compile Include="Controls\ProofreadMainControl.Designer.cs">
<DependentUpon>ProofreadMainControl.cs</DependentUpon>
</Compile>
<Compile Include="core\BridgeResult.cs" />
<Compile Include="core\CorrectionCharacter.cs" />
<Compile Include="core\CorrectionFragmentAbstract.cs" />
<Compile Include="core\CorrectionRangeAbstract.cs" />
<Compile Include="core\DocumentText.cs" />
<Compile Include="core\DocumentUtil.cs" />
<Compile Include="core\EventForwarder.cs" />
<Compile Include="core\StringUtil.cs" />
<Compile Include="core\Tools.cs" />
<Compile Include="core\MainPanelWebMessage.cs" />
<Compile Include="Logger.cs" />
<Compile Include="ProofreadItem.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Util\HostHelper.cs" />
<EmbeddedResource Include="Controls\FormContact.resx">
<DependentUpon>FormContact.cs</DependentUpon>
</EmbeddedResource>
@ -304,6 +396,10 @@
<None Include="AIProofread_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\updater\updater.csproj">
<Project>{73ac658d-cd49-4731-8491-a7bdbc811559}</Project>
<Name>updater</Name>
</ProjectReference>
<ProjectReference Include="..\util-lib\util-lib.csproj">
<Project>{ff204e99-82f8-405e-847b-88fc6df07715}</Project>
<Name>util-lib</Name>

View File

@ -8,6 +8,6 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<StartAction>Project</StartAction>
<StartProgram>C:\Soft\Kingsoft\WPS Office\12.1.0.16929\office6\wps.exe</StartProgram>
<StartProgram>C:\Soft\Kingsoft\WPS Office\12.1.0.17827\office6\wps.exe</StartProgram>
</PropertyGroup>
</Project>

View File

@ -1,4 +1,5 @@
using AIProofread.Controls;
using AIProofread.core;
using AIProofread.Util;
using Microsoft.Office.Interop.Word;
using Microsoft.Office.Tools.Word;
@ -13,6 +14,7 @@ using System.IO;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using UtilLib;
using Document = Microsoft.Office.Interop.Word.Document;
using Task = System.Threading.Tasks.Task;
@ -162,43 +164,11 @@ namespace AIProofread
data.Add("fullName", doc.FullName);
data.Add("wordsCount", doc.Words.Count);
data.Add("charactersCount", doc.Characters.Count);
data.Add("content", Tools.GetAllText(doc));
Application app = new Application();
object missing = System.Reflection.Missing.Value;
object saveOption = WdSaveOptions.wdDoNotSaveChanges;
// 创建临时文件
string path = CreateTempDocumentFile(doc);
Document tmpDoc = app.Documents.Open(path, false, true, false);
data.Add("content", Tools.GetAllText(tmpDoc));
// 关闭并释放对象
tmpDoc.Close(ref saveOption, ref missing, ref missing);
Marshal.ReleaseComObject(tmpDoc);
app.Quit(ref saveOption,ref missing,ref missing);
Marshal.ReleaseComObject(app);
// 显式回收一下吧
GC.Collect();
File.Delete(path);
return Tools.GetJSONString(data);
}
private string CreateTempDocumentFile(Document doc)
{
// 先转成临时文件
FileStream fs = new FileStream(doc.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
//
var tmpFile = Path.GetTempFileName();
byte[] bytes = new byte[fs.Length];
fs.Read(bytes, 0, bytes.Length);
FileStream tmp = new FileStream(tmpFile, FileMode.OpenOrCreate,FileAccess.ReadWrite);
tmp.Write(bytes, 0, bytes.Length);
// 关闭吧
tmp.Close();
fs.Close();
return tmpFile;
}
public string getParagraphTextByRange(int start, int end)
{
@ -244,7 +214,7 @@ namespace AIProofread
}
public void getParagraphTextByRangeSync(int start,int end)
public void getParagraphTextByRangeSync(int start, int end)
{
//var list = Tools.GetTextListByParagraphRange(start, end);
//return Tools.GetJSONString(list);
@ -309,33 +279,40 @@ namespace AIProofread
public async static void InitWebEnvAsync(string name, WebView2 webView)
{
webView.Name = name;
if (webViewDict.ContainsKey(webView.Name))
try
{
webViewDict[name] = webView;
webView.Name = name;
if (webViewDict.ContainsKey(webView.Name))
{
webViewDict[name] = webView;
}
else
{
webViewDict.Add(name, webView);
}
// 禁用web安全允许跨域 否则需要web编译为umd加载模式
var ops = new CoreWebView2EnvironmentOptions("--disable-web-security");
var env = await CoreWebView2Environment.CreateAsync(null, Config.WEB_DATA_PATH, ops);
await webView.EnsureCoreWebView2Async(env);
//webView.CoreWebView2.Settings.AreDevToolsEnabled = false;
//webView.CoreWebView2.Settings.AreDefaultScriptDialogsEnabled = false;
//webView.CoreWebView2.Settings.AreHostObjectsAllowed = true;
// 添加 js与客户端代理
webView.CoreWebView2.AddHostObjectToScript("bridge", bridge);
}
else
catch (Exception ex)
{
webViewDict.Add(name, webView);
Logger.Log(ex);
}
// 禁用web安全允许跨域 否则需要web编译为umd加载模式
var ops = new CoreWebView2EnvironmentOptions("--disable-web-security");
var env = await CoreWebView2Environment.CreateAsync(null, Config.WEB_DATA_PATH, ops);
await webView.EnsureCoreWebView2Async(env);
//webView.CoreWebView2.Settings.AreDevToolsEnabled = false;
//webView.CoreWebView2.Settings.AreDefaultScriptDialogsEnabled = false;
//webView.CoreWebView2.Settings.AreHostObjectsAllowed = true;
// 添加 js与客户端代理
webView.CoreWebView2.AddHostObjectToScript("bridge", bridge);
}
// 清除所有标记
public void clearAllProofreadMark()
{
// 设置当前文档数据
// 标记当前文档所有书签数据
Globals.ThisAddIn.ActiveCurrentDocumentMarks();
try
{
@ -542,7 +519,7 @@ namespace AIProofread
marks[proofreadId].Select();
//Globals.ThisAddIn.SendMessageToWeb("select", proofreadId);
}
Globals.ThisAddIn.SendMessageToWeb("select_proofread", proofreadId);
Globals.ThisAddIn.SendMessageToWeb("select-proofread", proofreadId);
}
public void processMark(int proofreadId, int status)
@ -553,7 +530,17 @@ namespace AIProofread
}
}
public void InitContent(string content)
private Document _currentDocument;
public Document CurrentDocument
{
get => _currentDocument ?? Globals.ThisAddIn.Application.ActiveDocument;
set
{
_currentDocument = value;
}
}
public string InitContent(string content)
{
try
{
@ -564,25 +551,19 @@ namespace AIProofread
//var app = Globals.ThisAddIn.Application;
//var cur = app.Selection;
//
List<int> disabledList = new List<int>();
foreach (var correct in list)
{
//cur.TypeText(correct.Insert);
//var rng = cur.Range;
if (correct.Diffs != null && correct.Diffs.Count > 0)
{
//var diffs = correct.Diffs.OrderBy(it =>
//{
// if (it.tag != "i") return it.start;
// return it.start + correct.Insert_len;
//}).ToList();
int index = 0;
foreach (var item in correct.Diffs)
{
if (item.idx == 3330)
if(item.id == 187117)
{
Console.WriteLine("xx");
}
var mark = AddBookmark(item, index, correct.Sentence_offset, correct.Insert_len, correct.Paragraph_num);
var mark = FindRangeAndCreateBookmark(correct.Insert, item, index, correct.Sentence_offset, correct.Insert_len, correct.Paragraph_num);
if (item.tag != "i") index++;
if (mark != null)
{
@ -590,6 +571,7 @@ namespace AIProofread
}
else
{
disabledList.Add(item.id);
var msg = new Dictionary<string, object>{
{"message","没有找到标记对象" },
{ "origin",item },
@ -599,7 +581,6 @@ namespace AIProofread
};
Logger.Log(JsonConvert.SerializeObject(msg));
}
}
}
}
@ -618,28 +599,37 @@ namespace AIProofread
}
}
}
// 隐藏面板对应校对项
MainPanelWebMessage.DisabledProofreadItem(disabledList);
}
catch (Exception ex)
{
Logger.Log("Initial Content error:" + ex.Message + "\n" + ex.StackTrace + "\n\n");
return "false";
}
return "true";
}
void SendMessageToPanel()
{
}
public string GetParagraph(int index)
{
var document = Globals.ThisAddIn.Application.ActiveDocument;
try
{
var paragraphs = document.Paragraphs;
var paragraphs = CurrentDocument.Paragraphs;
var total = paragraphs.Count;
// 判断索引是否超出范围
if (index > total)
{
return null;
}
var paragraph = document.Paragraphs[index];
var paragraph = CurrentDocument.Paragraphs[index];
return paragraph.Range.Text;
}
catch (Exception ex)
@ -648,12 +638,27 @@ namespace AIProofread
}
}
public Microsoft.Office.Tools.Word.Bookmark AddBookmark(CorrectedContent item, int findIndex, int offset, int length, int paragraphIndex)
/// <summary>
/// 新增校对项 查找时的偏移量
/// </summary>
private static readonly int INSERT_FIND_OFFSET = 5;
/// <summary>
/// 根据校对项查找文档对应的位置 并创建书签
/// </summary>
/// <param name="originText">接口原始文档</param>
/// <param name="item">校对项</param>
/// <param name="findIndex"></param>
/// <param name="offset"></param>
/// <param name="length"></param>
/// <param name="paragraphIndex"></param>
/// <returns></returns>
public Microsoft.Office.Tools.Word.Bookmark FindRangeAndCreateBookmark(string originText, CorrectedContent item, int findIndex, int offset, int length, int paragraphIndex)
{
Microsoft.Office.Tools.Word.Bookmark bookmark = null;
try
{
var document = Globals.ThisAddIn.Application.ActiveDocument;
var document = CurrentDocument;
ControlCollection controls = Globals.Factory.GetVstoObject(document).Controls;
var markName = Config.BuildBookmarkName(item.id);
@ -669,27 +674,77 @@ namespace AIProofread
Range findRange = null;
if (paragraphIndex > document.Paragraphs.Count) return null;
var paragraph = document.Paragraphs[paragraphIndex];
var paragraphStart = paragraph.Range.Start;
offset += paragraphStart;
Range paragraphRange = paragraph.Range;
var paragraphStart = paragraphRange.Start;
//offset += paragraphStart;
var Start = offset;
var Start = paragraphStart + offset;
var End = Start + length - 1;
if (End > paragraph.Range.End)
if (End > paragraphRange.End)
{
End = paragraph.Range.End;
End = paragraphRange.End;
}
// 当前句子的选区
var fullRange = document.Range(Start, End);
string fullText = fullRange.Text ?? paragraph.Range.Text;
Start = offset + item.start;
End = offset + item.end;
// 如果选择有文本就用文本
string fullText = fullRange.Text ?? paragraphRange.Text;
// 当前段落文本
string paragraphText = paragraphRange.Text;
End = Start + item.end;
Start = Start + item.start;
// 如果是新增 则查找定位
if (item.tag == "i")
{
// s1. 通过接口的位置 和 文档内容进行比对
try
{
if (paragraphText.Substring(offset, length) == originText)
{
// 直接使用接口定位
findRange = document.Range(Start, End);
}
}
catch (Exception exif)
{
Logger.Log(exif);
}
// s2. 位置不匹配 则采用搜索定位
if (findRange == null)
{
// 找前缀
var prefix = item.start > 2 ? (
item.start > INSERT_FIND_OFFSET
? originText.Substring(item.start - INSERT_FIND_OFFSET, INSERT_FIND_OFFSET)
: originText.Substring(0, item.start)
) : null;
// 找后缀
var suffix = prefix == null ? (
item.end + INSERT_FIND_OFFSET < originText.Length
? originText.Substring(item.start, INSERT_FIND_OFFSET)
: originText.Substring(item.start, originText.Length - item.start)
) : null;
// 偏移量
var start = prefix != null || suffix != null
? paragraphText.IndexOf(prefix ?? suffix, offset) // item.start +
: -1;
if (start != -1)
{
var findOffset = paragraphStart + start + (prefix != null ? prefix.Length : 0);
findRange = document.Range(findOffset, findOffset);
}
}
}
else
{
findRange = document.Range(Start, End);
}
// 如果是新增 只能使用接口数据
findRange = document.Range(Start, End);
if (item.tag != "i" && findRange.Text != item.origin)
{
findRange = DocumentUtil.FindRange(paragraphIndex, item.origin, item.start, item.end);
findRange = DocumentUtil.FindRange(paragraphIndex, offset, originText, item.origin, item.start, item.end);
}
if (findRange != null)

View File

@ -6,7 +6,7 @@ namespace AIProofread
public class Config
{
public static readonly string APP_NAME = "AI校对王";
public static readonly string APP_VERSION = "1.0.7";
public static readonly string APP_VERSION = "1.0.11";
public static bool IS_WPS = false;
public static readonly string CONFIG_FILE = AppDomain.CurrentDomain.BaseDirectory + "app.json";

View File

@ -30,7 +30,10 @@ namespace AIProofread
streamWriter.Close();
streamWriter.Dispose();
}
public static void Log( Exception e)
{
Log(e.StackTrace);
}
public static void Log(string tag, Exception e)
{
Log(tag + "\n" + e.StackTrace);

View File

@ -38,7 +38,7 @@ namespace UtilLib
originSize = bookmark.Range.Font.Size;
originBackgroundColor = bookmark.Shading.BackgroundPatternColor;
originColor = bookmark.Shading.ForegroundPatternColor;
mark.Selected += OnMarkSelected;
//mark.Selected += OnMarkSelected;
}
SetMarkName();
//InitBookMark(bookmark);

View File

@ -51,8 +51,8 @@ namespace AIProofread
this.grpDebug = this.Factory.CreateRibbonGroup();
this.btnShowPane = this.Factory.CreateRibbonButton();
this.btnHidePane = this.Factory.CreateRibbonButton();
this.btnTestLocation = this.Factory.CreateRibbonButton();
this.btnSelectionPosition = this.Factory.CreateRibbonButton();
this.BtnOpenLog = this.Factory.CreateRibbonButton();
this.button1 = this.Factory.CreateRibbonButton();
this.tabAIProofread.SuspendLayout();
this.group1.SuspendLayout();
@ -170,8 +170,8 @@ namespace AIProofread
//
this.grpDebug.Items.Add(this.btnShowPane);
this.grpDebug.Items.Add(this.btnHidePane);
this.grpDebug.Items.Add(this.btnTestLocation);
this.grpDebug.Items.Add(this.btnSelectionPosition);
this.grpDebug.Items.Add(this.BtnOpenLog);
this.grpDebug.Items.Add(this.button1);
this.grpDebug.Label = "开发调试";
this.grpDebug.Name = "grpDebug";
@ -189,23 +189,21 @@ namespace AIProofread
this.btnHidePane.Name = "btnHidePane";
this.btnHidePane.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btnHidePane_Click);
//
// btnTestLocation
//
this.btnTestLocation.Label = "文本位置";
this.btnTestLocation.Name = "btnTestLocation";
this.btnTestLocation.Visible = false;
this.btnTestLocation.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btnTestLocation_Click);
//
// btnSelectionPosition
//
this.btnSelectionPosition.Label = "选中位置";
this.btnSelectionPosition.Label = "测试分段速度";
this.btnSelectionPosition.Name = "btnSelectionPosition";
this.btnSelectionPosition.Visible = false;
this.btnSelectionPosition.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btnSelectionPosition_Click);
//
// BtnOpenLog
//
this.BtnOpenLog.Label = "打开日志目录";
this.BtnOpenLog.Name = "BtnOpenLog";
this.BtnOpenLog.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnOpenLog_Click);
//
// button1
//
this.button1.Label = "button1";
this.button1.Label = "更新测试版本";
this.button1.Name = "button1";
this.button1.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.button1_Click);
//
@ -242,8 +240,8 @@ namespace AIProofread
internal Microsoft.Office.Tools.Ribbon.RibbonGroup grpDebug;
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnShowPane;
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnHidePane;
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnTestLocation;
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnSelectionPosition;
internal Microsoft.Office.Tools.Ribbon.RibbonButton BtnOpenLog;
internal Microsoft.Office.Tools.Ribbon.RibbonButton button1;
}

View File

@ -6,6 +6,15 @@ using UtilLib;
using System.Drawing;
using System.Security.Cryptography;
using Microsoft.Office.Interop.Word;
using System.IO;
using System.Threading.Tasks;
using AIProofread.Util;
using Microsoft.Office.Tools.Word;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AIProofread.core;
using System.Windows.Forms;
namespace AIProofread
{
@ -124,8 +133,12 @@ namespace AIProofread
private void btnClear_Click(object sender, RibbonControlEventArgs e)
{
//DocumentUtil.ClearProofreadMarks();
Bridge.bridge.clearAllProofreadMark();
Globals.ThisAddIn.SendMessageToWeb("clear-tips", null);
var result = MessageBox.Show("请确认是否清除此文档的所有校对标注?", "提示", MessageBoxButtons.OKCancel);
if(result == DialogResult.OK)
{
Bridge.bridge.clearAllProofreadMark();
Globals.ThisAddIn.SendMessageToWeb("clear-tips", null);
}
}
private void btnShowPane_Click(object sender, RibbonControlEventArgs e)
@ -138,93 +151,289 @@ namespace AIProofread
Globals.ThisAddIn.HidePanel();
}
void TestStr(int p, string str)
{
var doc = Globals.ThisAddIn.Application.ActiveDocument;
var p1 = doc.Paragraphs[p];
var text = p1.Range.Text;
var index = text.IndexOf(str);
var r = DocumentUtil.FindRange(p, str, index, index + str.Length);
System.Windows.Forms.MessageBox.Show("段落:" + p + str + ":" + index + (r == null ? "" : r.Text));
//var findRange = FindRange(p, findIndex, str, index, index + str.Length);
}
private void btnTestLocation_Click(object sender, RibbonControlEventArgs e)
{
TestStr(2, "销");
TestStr(3, "针");
TestStr(22, "疏");
}
private Microsoft.Office.Interop.Word.Document CurrentDocument;
private void btnSelectionPosition_Click(object sender, RibbonControlEventArgs e)
{
var doc = Globals.ThisAddIn.Application.ActiveDocument;
var sel = Globals.ThisAddIn.Application.Selection;
if (sel != null && sel.Range != null)
// 测试加快速度处理 段落
//CurrentDocument = Globals.ThisAddIn.Application.ActiveDocument;
//var tables = CurrentDocument.Tables;
//var tableCount = tables.Count;
//System.Windows.Forms.MessageBox.Show("tables "+ tableCount);
//var footNotes = CurrentDocument.Footnotes;
//System.Windows.Forms.MessageBox.Show("footNotes " + footNotes.Count);
//var endNotes = CurrentDocument.Endnotes;
//System.Windows.Forms.MessageBox.Show("endNotes " + endNotes.Count);
//Bridge.bridge.getDocumentData();
CurrentDocument = Globals.ThisAddIn.Application.ActiveDocument;
string path = Tools.GetReadDocumentFilePath(CurrentDocument);
Debug.WriteLine(path);
Logger.Log(path);
System.Windows.Forms.MessageBox.Show("Test");
}
private void TestSplit()
{
//try
//{
// this.CurrentDocument = Globals.ThisAddIn.Application.ActiveDocument;
// string rangeText = GetRangeText(CurrentDocument.Content);
// // 获取所有数学公式吗
// foreach (OMath oMath in CurrentDocument.OMaths)
// {
// Console.WriteLine("xx");
// }
// // 形状哟
// int count = CurrentDocument.Shapes.Count;
// System.Windows.Forms.MessageBox.Show(string.Format("Shapes总计:{0}", count));
// foreach (Microsoft.Office.Interop.Word.Shape shape in CurrentDocument.Shapes)
// {
// }
// int count2 = CurrentDocument.InlineShapes.Count;
// System.Windows.Forms.MessageBox.Show(string.Format("InlineShapes总计:{0}", count2));
// foreach (InlineShape inlineShape in CurrentDocument.InlineShapes)
// {
// }
// string text5 = rangeText;
// Logger.Log($"Removed unuseable section article: {text5}");
// string text6 = HostHelper.ReplaceSpecialChars(rangeText, isReplaceMultSpaceLine: true);
// Logger.Log($"Removed unuseable section upload: {text6}");
// int end = CurrentDocument.Content.End;
// // 分割
// string[] separator = new string[5] { "\r\a", "\a", "\r", "\v", "\f" };
// string[] array4 = text5.Split(separator, StringSplitOptions.None);
// string[] array5 = text6.Split('\n');
// object Start = 0;
// object End = 1;
// //int pagenumber = GetIndexPageNumber(CurrentDocument.Range(ref Start, ref End));
// int start = 0;
// int start2 = 0;
// int start3 = 0;
// string empty = string.Empty;
// string empty2 = string.Empty;
// string empty3 = string.Empty;
// Range lastRange = null;
// for (int j = 0; j < array5.Length; j++)
// {
// empty3 = string.Empty;
// List<CorrectionCharacter> characters = new List<CorrectionCharacter>();
// CorrectionFragmentAbstract correctionFragmentAbstract = null;
// //Logger.Instance.Info($"Handling {j + 1} upload part");
// empty2 = array5[j];
// if (string.IsNullOrEmpty(empty2))
// {
// continue;
// }
// int num4 = start + empty2.Length + 1;
// for (; string.IsNullOrEmpty(HostHelper.RemoveInvisibleCharas(array4[i])); i++)
// {
// num4 += array4[i].Length + 1;
// }
// empty = array4[i];
// //Logger.Instance.Info($"Upload part is {empty2}");
// End = start;
// Start = num4;
// Range range3 = CurrentDocument.Range(ref End, ref Start);
// string rangeText3 = GetRangeText(range3);
// //Logger.Instance.Info($"Text is {rangeText3}");
// StringBuilder stringBuilder = new StringBuilder();
// string text7 = (string.IsNullOrEmpty(rangeText3) ? "" : rangeText3.Last().ToString());
// if (HostHelper.RemoveInvisibleCharas(rangeText3) != empty2 || (text7 != "\r" && text7 != "\r\a" && text7 != "\a" && text7 != "\f" && text7 != "\v"))
// {
// int articleIndex = start;
// Start = articleIndex;
// End = articleIndex + 1;
// Range range4 = CurrentDocument.Range(ref Start, ref End);
// text7 = GetRangeText(range4);
// bool flag = true;
// while ((text7 != "\r" && text7 != "\r\a" && text7 != "\a" && text7 != "\f" && text7 != "\v") || flag)
// {
// if (flag)
// {
// //Logger.Instance.Info(string.Format("Special text default logic.", rangeText3));
// GetInvisibleCharacters(ref articleIndex, empty2, end, stringBuilder, characters, flag);
// }
// else
// {
// //Logger.Instance.Info(string.Format("Text not contains \\r.", rangeText3));
// GetInvisibleCharacters(ref articleIndex, "\r", end, stringBuilder, characters, flag);
// }
// End = articleIndex;
// Start = articleIndex + 1;
// range4 = CurrentDocument.Range(ref End, ref Start);
// text7 = GetRangeText(range4);
// flag = false;
// }
// stringBuilder.Append(text7);
// string text8 = stringBuilder.ToString();
// empty = text8.Replace("\a", "");
// num4 = range4.End;
// //Logger./*Instance*/.Info($"Article part is {empty}");
// if (empty.ToUpper().Contains("PAGEREF _TOC"))
// {
// start = num4;
// //Logger.Instance.Info("String Contains 'PAGEREF _TOC' Struct.");
// continue;
// }
// }
// else
// {
// empty = rangeText3.Replace("\a", "");
// int tempIndex = start;
// empty.ToCharArray().ToList().ForEach(delegate (char x)
// {
// characters.Add(new CorrectionCharacter(x, _v: true, tempIndex));
// tempIndex++;
// });
// }
// }
//}
//catch (Exception ex)
//{
// System.Windows.Forms.MessageBox.Show("出现了异常:" + ex.Message);
//}
}
private string GetInvisibleCharacters(ref int articleIndex, string articlePart, int end, StringBuilder stringBuilder, List<CorrectionCharacter> characters, bool isFirst = true)
{
int num = articleIndex;
if (!isFirst)
{
Paragraphs paragraphs = doc.Paragraphs;
Range range = sel.Range;
Paragraph paragraph = range.Paragraphs.First;
int paragraphIndex = -1;
for (int i = 1; i <= paragraphs.Count; i++)
articlePart = HostHelper.RemoveInvisibleCharas(articlePart);
}
int num2 = ((articlePart.Length + articleIndex < end) ? articlePart.Length : (end - articleIndex));
Range range = null;
string empty = string.Empty;
if (string.IsNullOrEmpty(articlePart))
{
string[] source = new string[4] { "\r", "\r\a", "\v", "\f" };
empty = string.Empty;
while (range == null || range.Text == null || !source.Contains(empty))
{
var para = paragraphs[i];
if (para.Range.Start >= paragraph.Range.Start && para.Range.End <= paragraph.Range.End)
if (!string.IsNullOrEmpty(empty))
{
paragraphIndex = i;
break;
stringBuilder.Append(empty);
num++;
}
if (num >= end)
{
//Logger.Instance.Error($"Correction dictionary over length{stringBuilder.ToString()}");
throw new ArgumentOutOfRangeException($"Not pair character: \\r \\f \\v \\r\\a, position {articleIndex}");
}
object Start = num;
object End = num + 1;
range = CurrentDocument.Range(ref Start, ref End);
empty = GetRangeText(range);
string text = empty;
string text2 = text;
if (text2 != null && (text2 == null || text2.Length != 0))
{
if (text2 == "\u001e")
{
empty = "-";
}
}
else
{
empty = "\n";
}
characters.Add(new CorrectionCharacter(empty.First(), source.Contains(empty), range.Start));
}
int startInParagraph = range.Start - paragraph.Range.Start;
int endInParagraph = range.End - paragraph.Range.Start;
System.Windows.Forms.MessageBox.Show($"Selected text in {paragraphIndex} starts at position {startInParagraph} and ends at position {endInParagraph} in the paragraph.");
}
else
{
System.Windows.Forms.MessageBox.Show("No text selected.");
for (int i = 0; i < num2; i++)
{
string text3 = articlePart[i].ToString();
empty = string.Empty;
while (range == null || range.Text == null || !empty.Contains(text3))
{
if (num >= end)
{
//Logger.Instance.Error($"Correction dictionary over length{stringBuilder.ToString()}");
throw new ArgumentOutOfRangeException($"Not pair character: {text3}, position {articleIndex}");
}
object End = num;
object Start = num + 1;
range = CurrentDocument.Range(ref End, ref Start);
empty = GetRangeText(range);
string text4 = empty;
string text5 = text4;
if (text5 != null && (text5 == null || text5.Length != 0))
{
if (text5 == "\u001e")
{
empty = "-";
}
}
else
{
empty = "\n";
}
stringBuilder.Append(empty);
num++;
characters.Add(new CorrectionCharacter(empty.First(), empty.Contains(text3), range.Start));
}
}
}
articleIndex = num;
return stringBuilder.ToString();
}
//public bool IsParagraphInTableOfContents(Document doc, Paragraph para)
public static int GetIndexPageNumber(Range range)
{
int result = -1;
try
{
result = int.Parse(range.get_Information(WdInformation.wdActiveEndPageNumber).ToString());
}
catch (Exception exception)
{
Logger.Log(exception);
}
return result;
}
protected string GetRangeText(Range range)
{
return string.IsNullOrEmpty(range.Text) ? "" : range.Text;
}
//private async Task ProcessCorrectCut()
//{
// // 检查文档和段落是否为null
// if (doc == null || para == null)
// return false;
// // 获取文档中的目录范围
// Range tocRange = null;
// foreach (Range range in .)
// {
// if (range.InlineShapes.Count > 0) // 假设目录包含字段代码
// {
// tocRange = range;
// break;
// }
// }
// // 如果没有找到目录范围则返回false
// if (tocRange == null)
// return false;
// // 获取段落范围
// Word.Range paraRange = para.Range;
// // 检查段落是否在目录范围内
// return paraRange.StoryLength > 0 && tocRange.StoryLength > 0 &&
// paraRange.Start >= tocRange.Start && paraRange.End <= tocRange.End;
//}
private void BtnOpenLog_Click(object sender, RibbonControlEventArgs e)
{
// 打开日志目录
Process.Start(Config.APP_LOG_PATH);
}
private void button1_Click(object sender, RibbonControlEventArgs e)
{
var doc = Globals.ThisAddIn.Application.ActiveDocument;
var styles = doc.Styles["TOC Heading"];
Console.WriteLine(styles.Font.Name);
string applicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
string path = "updater.exe";
ProcessStartInfo processStartInfo = new ProcessStartInfo(Path.Combine(applicationBase, Path.GetFileName(path)));
processStartInfo.WorkingDirectory = applicationBase;
Process.Start(processStartInfo);
}
}
}

View File

@ -295,11 +295,11 @@ namespace AIProofread
(Application as ApplicationEvents4_Event).NewDocument += Application_NewDocument;
//Application.DocumentChange +=
// 选区发生变化事件
//this.Application.WindowSelectionChange += Application_WindowSelectionChange;
this.Application.WindowSelectionChange += Application_WindowSelectionChange;
try
{
if (Application.ActiveDocument != null)
if (Application.Documents.Count > 0 && Application.ActiveDocument != null)
{
// 默认直接打开文档 就直接创建panel
ShowPanel(Application.ActiveDocument, false);
@ -326,7 +326,7 @@ namespace AIProofread
if (s.Range.Start == s.Range.End) // 说明是点击呀
{
var count = s.Bookmarks.Count;
if (s.Bookmarks.Count == 1) // 只有这一个
if (s.Bookmarks.Count >= 1) // 只有这一个
{
foreach (Microsoft.Office.Interop.Word.Bookmark item in s.Bookmarks)
{

View File

@ -0,0 +1,9 @@
namespace AIProofread.core
{
public class BridgeResult<T>
{
public T Data { get; set; }
public int Code { get; set; }
public string Message { get; set; }
}
}

View File

@ -0,0 +1,63 @@
namespace AIProofread.core
{
public class CorrectionCharacter
{
private int position;
private char c;
private bool visible;
public int Position
{
get
{
return position;
}
set
{
position = value;
}
}
public char C
{
get
{
return c;
}
set
{
c = value;
}
}
public bool Visible
{
get
{
return visible;
}
set
{
visible = value;
}
}
public CorrectionCharacter()
{
}
public CorrectionCharacter(char _c, bool _v, int _p)
{
C = _c;
Visible = _v;
Position = _p;
}
public override string ToString()
{
return $"{Position}:{C}-{Visible}";
}
}
}

View File

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AIProofread.core
{
public abstract class CorrectionFragmentAbstract
{
private List<CorrectionCharacter> characters = new List<CorrectionCharacter>();
public List<CorrectionCharacter> Characters
{
get
{
return characters;
}
set
{
characters = value;
}
}
public abstract CorrectionRangeAbstract UploadRange { get; set; }
public abstract CorrectionRangeAbstract ArticleRange { get; set; }
public abstract CorrectionRangeAbstract FormatRange { get; set; }
public abstract void AddCorrectionRange(CorrectionRangeAbstract article, CorrectionRangeAbstract upload, CorrectionRangeAbstract format = null);
public abstract void RemoveCorrectionRange();
public abstract int[] SetCorrectionRange(int[] article, int[] upload);
public abstract int[] Relocate(string upload, int offset);
public abstract void ClearAll();
public abstract int GetFirstStartPosition(bool containUnvisibleCharacter);
public abstract int GetLastEndPosition(bool containUnvisibleCharacter);
}
}

View File

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AIProofread.core
{
public abstract class CorrectionRangeAbstract
{
protected List<char> chars = new List<char>();
public abstract string Text { get; set; }
public abstract int Start { get; set; }
public abstract int End { get; set; }
public abstract int Count { get; }
public CorrectionRangeAbstract(string text, int _s, int _e = -1)
{
Start = _s;
End = _e;
}
public CorrectionRangeAbstract()
{
}
public abstract int GetStartPosition(bool containUnvisibleCharacter);
public abstract int GetEndPosition(bool containUnvisibleCharacter);
public override string ToString()
{
return $"{Text}|{Start},{End}";
}
}
}

View File

@ -9,6 +9,7 @@ using System.Collections.Generic;
using Microsoft.Office.Tools.Word;
using System;
using System.Xml.Linq;
using Newtonsoft.Json;
namespace AIProofread
{
@ -159,20 +160,24 @@ namespace AIProofread
return list;
}
private static readonly int INSERT_FIND_OFFSET = 5;
/// <summary>
/// 查找对应段落的range
/// </summary>
/// <param name="paragraphsIndex">段落index从第1开始计数</param>
/// <param name="offset">当前偏移量</param>
/// <param name="findText">要查找字符串</param>
/// <param name="wordStart">字符串原始起始位置</param>
/// <param name="wordEnd">字符串原始结束位置</param>
/// <returns></returns>
public static Range FindRange(int paragraphsIndex, string findText, int wordStart, int wordEnd)
public static Range FindRange(int paragraphsIndex,int offset,string originText, string findText, int wordStart, int wordEnd)
{
// <param name="findIndex"></param> 暂时接口无法支持
var document = Globals.ThisAddIn.Application.ActiveDocument;
if (paragraphsIndex > document.Paragraphs.Count) return null;
var paragraph = document.Paragraphs[paragraphsIndex];
var range = paragraph.Range;
var paragraphText = range.Text;
try
{
//int num = 0;
@ -183,12 +188,12 @@ namespace AIProofread
object End = paragraph.Range.End;
// 段落选区
Range range = document.Range(ref Start, ref End);
//Range range = document.Range(ref Start, ref End);
var activeDocument = document;
// 查找对象位置
End = range.Start + wordStart;
Start = range.Start + wordEnd;
End = range.Start + offset + wordStart;
Start = range.Start + offset + wordEnd;
// 直接找到
var findRange = activeDocument.Range(ref End, ref Start);
// 判断对应选区是否是要找的文本
@ -196,81 +201,114 @@ namespace AIProofread
{
return findRange;
}
else
// 找前缀
var prefix = wordStart > 2 ? (
wordStart > INSERT_FIND_OFFSET
? originText.Substring(wordStart - INSERT_FIND_OFFSET, INSERT_FIND_OFFSET)
: originText.Substring(0, wordStart)
) : null;
// 找后缀
var suffix = prefix == null ? (
wordEnd + INSERT_FIND_OFFSET < originText.Length
? originText.Substring(wordStart, INSERT_FIND_OFFSET)
: originText.Substring(wordStart, originText.Length - wordStart)
) : null;
var start = prefix != null || suffix != null
? paragraphText.IndexOf(prefix ?? suffix, offset) // item.start +
: -1;
if (start != -1)
{
// 查找
range.Find.MatchByte = true;
// 使用选区查找功能
Find find = range.Find;
// 节约变量
End = findText;
Start = true;
var findOffset = range.Start + start + (prefix != null ? prefix.Length : 0);
findRange = document.Range(findOffset, findOffset + wordEnd - wordStart);
if(findRange.Text == findText) { return findRange; }
}
var msg = new Dictionary<string, object>{
{"message","后端接口位置不可用,开始执行查找" },
{ "origin_start",wordStart },
{ "origin_end",wordEnd },
{"find_text",findRange.Text },
{"origin_text", findText}
};
Logger.Log(JsonConvert.SerializeObject(msg));
// 查找
range.Find.MatchByte = true;
// 使用选区查找功能
Find find = range.Find;
// 节约变量
End = findText;
Start = true;
object MatchWholeWord = Type.Missing;
object MatchWildcards = Type.Missing;
object MatchSoundsLike = Type.Missing;
object MatchAllWordForms = Type.Missing;
object Forward = Type.Missing;
object Wrap = Type.Missing;
object Format = Type.Missing;
object ReplaceWith = Type.Missing;
object Replace = Type.Missing;
object MatchKashida = Type.Missing;
object MatchDiacritics = Type.Missing;
object MatchAlefHamza = Type.Missing;
object MatchControl = Type.Missing;
object MatchWholeWord = Type.Missing;
object MatchWildcards = Type.Missing;
object MatchSoundsLike = Type.Missing;
object MatchAllWordForms = Type.Missing;
object Forward = Type.Missing;
object Wrap = Type.Missing;
object Format = Type.Missing;
object ReplaceWith = Type.Missing;
object Replace = Type.Missing;
object MatchKashida = Type.Missing;
object MatchDiacritics = Type.Missing;
object MatchAlefHamza = Type.Missing;
object MatchControl = Type.Missing;
// 没有找到则执行查询
find.Execute(
ref End, ref Start, ref MatchWholeWord,
ref MatchWildcards, ref MatchSoundsLike,
ref MatchAllWordForms, ref Forward, ref Wrap,
ref Format, ref ReplaceWith, ref Replace,
ref MatchKashida, ref MatchDiacritics,
ref MatchAlefHamza, ref MatchControl
);
// 没有找到则执行查询
find.Execute(
ref End, ref Start, ref MatchWholeWord,
ref MatchWildcards, ref MatchSoundsLike,
ref MatchAllWordForms, ref Forward, ref Wrap,
ref Format, ref ReplaceWith, ref Replace,
ref MatchKashida, ref MatchDiacritics,
ref MatchAlefHamza, ref MatchControl
);
while (range.Find.Found)
var msg1 = new Dictionary<string, object>{
{"message",range.Find.Found?"搜索到可用位置":"没有搜索到可用位置" },
{ "search_start",range.Start },
{ "search_end",range.End },
{ "search_text",range.Text }
};
Logger.Log(JsonConvert.SerializeObject(msg1));
while (range.Find.Found)
{
var obj4 = range.Document;
MatchControl = range.Start;
MatchAlefHamza = range.End;
var range2 = obj4.Range(ref MatchControl, ref MatchAlefHamza);
num3 = range2.End;
if (range2.Text == findText)
{
var obj4 = range.Document;
MatchControl = range.Start;
MatchAlefHamza = range.End;
var range2 = obj4.Range(ref MatchControl, ref MatchAlefHamza);
num3 = range2.End;
if (range2.Text == findText)
{
return range2;
}
break;
//if (findIndex == num)
//{
return range2;
}
break;
//if (findIndex == num)
//{
//}
//num++;
//range.Find.MatchByte = true;
//Find find2 = range.Find;
//MatchAlefHamza = missword;
//MatchControl = true;
//MatchDiacritics = Type.Missing;
//MatchKashida = Type.Missing;
//Replace = Type.Missing;
//ReplaceWith = Type.Missing;
//Format = Type.Missing;
//Wrap = Type.Missing;
//Forward = Type.Missing;
//MatchAllWordForms = Type.Missing;
//MatchSoundsLike = Type.Missing;
//MatchWildcards = Type.Missing;
//MatchWholeWord = Type.Missing;
//Start = Type.Missing;
//End = Type.Missing;
//// 再次重复查找
//find2.Execute(ref MatchAlefHamza, ref MatchControl, ref MatchDiacritics, ref MatchKashida, ref Replace, ref ReplaceWith, ref Format, ref Wrap, ref Forward, ref MatchAllWordForms, ref MatchSoundsLike, ref MatchWildcards, ref MatchWholeWord, ref Start, ref End);
}
if (num3 == 0)
{
return null;
}
//}
//num++;
//range.Find.MatchByte = true;
//Find find2 = range.Find;
//MatchAlefHamza = missword;
//MatchControl = true;
//MatchDiacritics = Type.Missing;
//MatchKashida = Type.Missing;
//Replace = Type.Missing;
//ReplaceWith = Type.Missing;
//Format = Type.Missing;
//Wrap = Type.Missing;
//Forward = Type.Missing;
//MatchAllWordForms = Type.Missing;
//MatchSoundsLike = Type.Missing;
//MatchWildcards = Type.Missing;
//MatchWholeWord = Type.Missing;
//Start = Type.Missing;
//End = Type.Missing;
//// 再次重复查找
//find2.Execute(ref MatchAlefHamza, ref MatchControl, ref MatchDiacritics, ref MatchKashida, ref Replace, ref ReplaceWith, ref Format, ref Wrap, ref Forward, ref MatchAllWordForms, ref MatchSoundsLike, ref MatchWildcards, ref MatchWholeWord, ref Start, ref End);
}
if (num3 == 0)
{
return null;
}
}
catch (Exception)

View File

@ -0,0 +1,87 @@
using Microsoft.Office.Tools.Word;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AIProofread.core
{
public class MessageActionEnum
{
public string Action { get; set; }
public MessageActionEnum(string action)
{
this.Action = action;
}
/// <summary>
/// 开始校对
/// </summary>
public static readonly MessageActionEnum StartProofread = new MessageActionEnum("start");
/// <summary>
/// 插件升级
/// </summary>
public static readonly MessageActionEnum Upgrade = new MessageActionEnum("upgrade");
/// <summary>
/// 清除所有校对内容
/// </summary>
public static readonly MessageActionEnum ClearTips = new MessageActionEnum("clear-tips");
/// <summary>
/// 打开插件
/// </summary>
public static readonly MessageActionEnum ShowSetting = new MessageActionEnum("show-setting");
/// <summary>
/// 打开(显示)词库管理
/// </summary>
public static readonly MessageActionEnum ShowLexicon = new MessageActionEnum("show-lexicon");
/// <summary>
/// 选中校对项
/// </summary>
public static readonly MessageActionEnum SelectProofreadItem = new MessageActionEnum("select-proofread");
/// <summary>
/// 禁用(隐藏)校对项
/// </summary>
public static readonly MessageActionEnum DisableProofreadItem = new MessageActionEnum("disabled-proofread");
/// <summary>
/// 注销登录
/// </summary>
public static readonly MessageActionEnum Logout = new MessageActionEnum("logout");
/// <summary>
/// 同步注销登录
/// </summary>
public static readonly MessageActionEnum AsyncLogout = new MessageActionEnum("async-logout");
/// <summary>
/// 同步登录成功
/// </summary>
public static readonly MessageActionEnum AsyncLoginSuccess = new MessageActionEnum("async-login-success");
}
public class MainPanelWebMessage
{
public static void Send(MessageActionEnum action, object data)
{
Globals.ThisAddIn.SendMessageToWeb(action.Action, data);
}
public static void Send(MessageActionEnum action)
{
Globals.ThisAddIn.SendMessageToWeb(action.Action, null);
}
public static void SelectProofreadItem(int proofreadItemId)
{
Globals.ThisAddIn.SendMessageToWeb(MessageActionEnum.SelectProofreadItem.Action, proofreadItemId);
}
public static void DisabledProofreadItem(List<int> proofreadItemIdList)
{
Globals.ThisAddIn.SendMessageToWeb(MessageActionEnum.DisableProofreadItem.Action, proofreadItemIdList);
}
}
}

View File

@ -1,16 +1,155 @@
using Microsoft.Office.Interop.Word;
using Newtonsoft.Json;
using NPOI.XWPF.UserModel;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Security.Cryptography;
namespace AIProofread
{
public class Tools
{
private static readonly string[] paragSplitor = new string[] { "\r", "\n", "\r\n" };
public static Dictionary<string, object> GetAllText(Document doc)
private static readonly string[] paragSplitor = new string[] { "\r\n", "\r\f", "\r", "\n", "\f" };
/// <summary>
/// 采用NPOI进行文本读取
/// </summary>
/// <param name="docPath"></param>
/// <param name="doc"></param>
/// <returns></returns>
public static Dictionary<string, object> GetAllText(Microsoft.Office.Interop.Word.Document doc)
{
string ext = doc.FullName.ToLower();
// 如果是
if (ext.EndsWith(".wps") || doc.Paragraphs.Count < 200 || doc.Tables.Count < 20)
{
// 如果段落数小于200或表格小于20 则直接使用vsto 获取数据
return GetAllTextByVSTO(doc);
}
// 创建临时文件 方便数据读取
string docPath = Tools.GetReadDocumentFilePath(doc);
Debug.WriteLine("GetAllText Start ==>", DateTime.Now.ToLongTimeString());
// 获取当前文档所有文本
string allText = doc.Range().Text;
List<DocumentText> list = new List<DocumentText>();
using (FileStream stream = new FileStream(docPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XWPFDocument ndoc = new XWPFDocument(stream);
var paragraphs = ndoc.Paragraphs;
int paragraphNumber = 1;
foreach (var bodyElement in ndoc.BodyElements)
{
// normal paragraph
if (bodyElement is XWPFParagraph p)
{
// 处理普通段落
list.Add(new DocumentText(p.ParagraphText.Replace("\u0002", ""), paragraphNumber));
paragraphNumber++;
}
// table -- vsto对于每个单元格的分段也会有
else if (bodyElement is XWPFTable table)
{
foreach (var row in table.Rows)
{
foreach (var cell in row.GetTableCells())
{
foreach (var pc in cell.Paragraphs)
{
//list.Add(pc.ParagraphText);
paragraphNumber++;
}
}
//list.Add(string.Empty);
paragraphNumber++;
}
}
// 目录处理
else if (bodyElement is XWPFSDT sdt)
{
string tocText = sdt.Content.Text;
// 如果需要,可以进一步解析目录项// 例如,按换行符拆分目录内容
var tocEntries = tocText.Split(new string[] { "\n", "\r", "\r\n", "\f" }, StringSplitOptions.None);
foreach (string entry in tocEntries)
{
list.Add(new DocumentText(entry.Replace("\u0002", ""), paragraphNumber));
paragraphNumber++;
}
}
}
}
Debug.WriteLine("GetAllText End ==>", DateTime.Now.ToLongTimeString());
var map = new Dictionary<string, object>
{
{ "list", list },
{ "text", allText }
};
// 删除临时文件
File.Delete(docPath);
return map;
}
public static string GetReadDocumentFilePath(Microsoft.Office.Interop.Word.Document doc)
{
//
string docPath = doc.FullName;
string ext = Path.GetExtension(docPath);
string tmpFile = Path.GetTempFileName();
Debug.WriteLine("GetReadDocumentFilePath Start ==>", DateTime.Now.ToLongTimeString());
Debug.WriteLine("GetReadDocumentFilePath =>{0}", docPath);
// 先转成临时文件
FileStream fs = new FileStream(docPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
byte[] bytes = new byte[fs.Length];
fs.Read(bytes, 0, bytes.Length);
FileStream fsWriter = new FileStream(tmpFile, FileMode.OpenOrCreate, FileAccess.ReadWrite);
fsWriter.Write(bytes, 0, bytes.Length);
// 关闭吧
fsWriter.Close();
fs.Close();
// 判断是否是doc格式
if (ext.ToLower().EndsWith("doc"))
{
// doc格式文档 需要转换成docx
//
Application app = new Application();
// 打开临时文件
var tmpDoc = app.Documents.OpenNoRepairDialog(
FileName: tmpFile,
AddToRecentFiles: false,
ReadOnly: true,
Visible: false
);
string newTmpFile = docPath + ".docx";
// 将原始文档另存为docx格式文档
tmpDoc.SaveAs2(
FileName: newTmpFile,
FileFormat: WdSaveFormat.wdFormatXMLDocument,
AddToRecentFiles: false
);
// 释放资源
object missing = System.Reflection.Missing.Value;
object saveOption = WdSaveOptions.wdDoNotSaveChanges;
tmpDoc.Close(ref saveOption, ref missing, ref missing);
app.Quit(ref saveOption, ref missing, ref missing);
// 删除copy文件
File.Delete(tmpFile);
tmpFile = newTmpFile;
}
Debug.WriteLine("GetReadDocumentFilePath =>=>{0}", tmpFile);
Debug.WriteLine("GetReadDocumentFilePath End ==>", DateTime.Now.ToLongTimeString());
return tmpFile;
}
public static Dictionary<string, object> GetAllTextByVSTO(Microsoft.Office.Interop.Word.Document doc)
{
// 获取当前文档所有文本
string allText = doc.Range().Text;

View File

@ -1 +1 @@
79ea390e4d68eda54ffacc73a1e70c811a130e7954fbba3a2df5692e3b3c6464
fe1ae839bfb706b80f0b4718d7a4129a4057bf53be655076474daf866eae1d58

View File

@ -41,6 +41,7 @@ C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.We
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.Web.WebView2.Wpf.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.csproj.AssemblyReference.cache
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormContact.resources
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormLoading.resources
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormLogin.resources
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormMain.resources
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormSetting.resources
@ -49,7 +50,159 @@ C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Ribbon1.resources
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.csproj.GenerateResource.cache
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.csproj.CoreCompileInputs.cache
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofr.8811D769.Up2Date
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.pdb
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofr.8811D769.Up2Date
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormLoading.resources
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\updater.exe
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.Compression.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\updater.pdb
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\updater.exe.config
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.InteropServices.RuntimeInformation.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.Win32.Primitives.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\netstandard.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.AppContext.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Collections.Concurrent.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Collections.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Collections.NonGeneric.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Collections.Specialized.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.ComponentModel.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.ComponentModel.EventBasedAsync.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.ComponentModel.Primitives.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.ComponentModel.TypeConverter.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Console.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Data.Common.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Diagnostics.Contracts.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Diagnostics.Debug.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Diagnostics.FileVersionInfo.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Diagnostics.Process.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Diagnostics.StackTrace.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Diagnostics.TextWriterTraceListener.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Diagnostics.Tools.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Diagnostics.TraceSource.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Diagnostics.Tracing.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Drawing.Primitives.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Dynamic.Runtime.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Globalization.Calendars.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Globalization.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Globalization.Extensions.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.Compression.ZipFile.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.FileSystem.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.FileSystem.DriveInfo.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.FileSystem.Primitives.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.FileSystem.Watcher.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.IsolatedStorage.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.MemoryMappedFiles.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.Pipes.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.UnmanagedMemoryStream.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Linq.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Linq.Expressions.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Linq.Parallel.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Linq.Queryable.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.Http.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.NameResolution.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.NetworkInformation.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.Ping.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.Primitives.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.Requests.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.Security.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.Sockets.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.WebHeaderCollection.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.WebSockets.Client.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.WebSockets.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.ObjectModel.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Reflection.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Reflection.Extensions.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Reflection.Primitives.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Resources.Reader.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Resources.ResourceManager.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Resources.Writer.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.CompilerServices.VisualC.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.Extensions.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.Handles.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.InteropServices.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.Numerics.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.Serialization.Formatters.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.Serialization.Json.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.Serialization.Primitives.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.Serialization.Xml.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Claims.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Cryptography.Algorithms.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Cryptography.Csp.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Cryptography.Encoding.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Cryptography.Primitives.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Cryptography.X509Certificates.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Principal.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.SecureString.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Text.Encoding.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Text.Encoding.Extensions.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Text.RegularExpressions.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Threading.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Threading.Overlapped.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Threading.Tasks.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Threading.Tasks.Parallel.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Threading.Thread.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Threading.ThreadPool.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Threading.Timer.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.ValueTuple.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Xml.ReaderWriter.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Xml.XDocument.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Xml.XmlDocument.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Xml.XmlSerializer.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Xml.XPath.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Xml.XPath.XDocument.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\BouncyCastle.Cryptography.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Enums.NET.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\ExtendedNumerics.BigDecimal.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\ICSharpCode.SharpZipLib.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\MathNet.Numerics.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.IO.RecyclableMemoryStream.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.Core.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.OOXML.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.OpenXml4Net.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.OpenXmlFormats.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\SixLabors.Fonts.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\SixLabors.ImageSharp.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Buffers.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Configuration.ConfigurationManager.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Memory.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Numerics.Vectors.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.CompilerServices.Unsafe.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.AccessControl.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Cryptography.Pkcs.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Cryptography.Xml.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Permissions.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Principal.Windows.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Text.Encoding.CodePages.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Threading.Tasks.Extensions.dll
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\BouncyCastle.Cryptography.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Enums.NET.pdb
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Enums.NET.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\ExtendedNumerics.BigDecimal.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\ICSharpCode.SharpZipLib.pdb
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\ICSharpCode.SharpZipLib.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\MathNet.Numerics.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.IO.RecyclableMemoryStream.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.Core.pdb
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.Core.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.OOXML.pdb
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.OOXML.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.OpenXml4Net.pdb
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.OpenXml4Net.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.OpenXmlFormats.pdb
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.OpenXmlFormats.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\SixLabors.Fonts.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\SixLabors.ImageSharp.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Buffers.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Configuration.ConfigurationManager.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Memory.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Numerics.Vectors.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.CompilerServices.Unsafe.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.AccessControl.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Cryptography.Pkcs.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Cryptography.Xml.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Permissions.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Principal.Windows.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Text.Encoding.CodePages.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Threading.Tasks.Extensions.xml

View File

@ -1,4 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BouncyCastle.Cryptography" version="2.3.1" targetFramework="net462" />
<package id="Enums.NET" version="4.0.1" targetFramework="net462" />
<package id="ExtendedNumerics.BigDecimal" version="2025.1001.2.129" targetFramework="net462" />
<package id="MathNet.Numerics.Signed" version="5.0.0" targetFramework="net462" />
<package id="Microsoft.IO.RecyclableMemoryStream" version="3.0.0" targetFramework="net462" />
<package id="Microsoft.Web.WebView2" version="1.0.2210.55" targetFramework="net462" />
<package id="NPOI" version="2.7.1" targetFramework="net462" />
<package id="SharpZipLib" version="1.4.2" targetFramework="net462" />
<package id="SixLabors.Fonts" version="1.0.1" targetFramework="net462" />
<package id="SixLabors.ImageSharp" version="2.1.8" targetFramework="net462" />
<package id="System.Buffers" version="4.5.1" targetFramework="net462" />
<package id="System.Configuration.ConfigurationManager" version="6.0.0" targetFramework="net462" />
<package id="System.Memory" version="4.5.5" targetFramework="net462" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net462" />
<package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0" targetFramework="net462" />
<package id="System.Security.AccessControl" version="6.0.0" targetFramework="net462" />
<package id="System.Security.Cryptography.Pkcs" version="6.0.3" targetFramework="net462" />
<package id="System.Security.Cryptography.Xml" version="6.0.1" targetFramework="net462" />
<package id="System.Security.Permissions" version="6.0.0" targetFramework="net462" />
<package id="System.Security.Principal.Windows" version="5.0.0" targetFramework="net462" />
<package id="System.Text.Encoding.CodePages" version="5.0.0" targetFramework="net462" />
<package id="System.Threading.Tasks.Extensions" version="4.5.2" targetFramework="net462" />
<package id="System.ValueTuple" version="4.4.0" targetFramework="net462" />
</packages>

9
util-lib/UpdateModel.cs Normal file
View File

@ -0,0 +1,9 @@
namespace UtilLib
{
public class UpdateModel
{
public int Version { get; set; }
public string Log { get; set; }
public string UpdateFile { get; set; }
}
}

4
util-lib/packages.config Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net462" />
</packages>

View File

@ -40,6 +40,9 @@
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
@ -57,11 +60,15 @@
<Compile Include="CorrectedContent.cs" />
<Compile Include="DocumentCorrectItem.cs" />
<Compile Include="ProofreadType.cs" />
<Compile Include="UpdateModel.cs" />
<Compile Include="UpgradeData.cs" />
<Compile Include="Userinfo.cs" />
<Compile Include="ToolUtil.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WebMessage.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>