update
This commit is contained in:
parent
b4c4af198f
commit
097ec94001
Binary file not shown.
@ -204,6 +204,12 @@
|
||||
<Compile Include="Controls\FormContact.Designer.cs">
|
||||
<DependentUpon>FormContact.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\FormLoading.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\FormLoading.Designer.cs">
|
||||
<DependentUpon>FormLoading.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\FormLogin.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@ -241,6 +247,9 @@
|
||||
<EmbeddedResource Include="Controls\FormContact.resx">
|
||||
<DependentUpon>FormContact.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Controls\FormLoading.resx">
|
||||
<DependentUpon>FormLoading.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Controls\FormLogin.resx">
|
||||
<DependentUpon>FormLogin.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
@ -8,6 +8,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using UtilLib;
|
||||
@ -163,6 +164,19 @@ namespace AIProofread
|
||||
return Tools.GetJSONString(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取文档原始文件并转换成base64
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string getDocumentFileData()
|
||||
{
|
||||
var doc = Globals.ThisAddIn.Application.ActiveDocument.FullName;
|
||||
FileStream fs = new FileStream(doc, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
byte[] bytes = new byte[fs.Length];
|
||||
fs.Read(bytes, 0, bytes.Length);
|
||||
return Convert.ToBase64String(bytes);
|
||||
}
|
||||
|
||||
public void ShowUpgrade(string data)
|
||||
{
|
||||
var upgradeData = JsonConvert.DeserializeObject<UpgradeData>(data);
|
||||
@ -468,12 +482,18 @@ namespace AIProofread
|
||||
int index = 0;
|
||||
foreach (var item in correct.Diffs)
|
||||
{
|
||||
var mark = AddBookmark(item, index, correct.Sentence_offset, correct.Insert_len, correct.Paragraph_offset);
|
||||
var mark = AddBookmark(item, index, correct.Sentence_offset, correct.Insert_len, correct.Paragraph_num);
|
||||
if (item.tag != "i") index++;
|
||||
var msg = new Dictionary<string, object>{
|
||||
{"message",mark == null ? "没有找到标记对象":"标记对象" + mark.Name },
|
||||
{ "origin",item }
|
||||
};
|
||||
if (mark != null)
|
||||
{
|
||||
marks.Add(item.id, new ProofreadItem(item, mark));
|
||||
}
|
||||
|
||||
Logger.LogToWeb(JsonConvert.SerializeObject(msg));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -492,7 +512,8 @@ namespace AIProofread
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception ex)
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log("Initial Content error:" + ex.Message + "\n" + ex.StackTrace + "\n\n");
|
||||
}
|
||||
|
88
AIProofread/Controls/FormLoading.Designer.cs
generated
Normal file
88
AIProofread/Controls/FormLoading.Designer.cs
generated
Normal file
@ -0,0 +1,88 @@
|
||||
namespace AIProofread.Controls
|
||||
{
|
||||
partial class FormLoading
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.lblInfo = new System.Windows.Forms.Label();
|
||||
this.lblLoading = new System.Windows.Forms.Label();
|
||||
this.panel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Controls.Add(this.lblInfo);
|
||||
this.panel1.Controls.Add(this.lblLoading);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(390, 179);
|
||||
this.panel1.TabIndex = 0;
|
||||
//
|
||||
// lblInfo
|
||||
//
|
||||
this.lblInfo.AutoEllipsis = true;
|
||||
this.lblInfo.Location = new System.Drawing.Point(14, 88);
|
||||
this.lblInfo.Name = "lblInfo";
|
||||
this.lblInfo.Size = new System.Drawing.Size(364, 23);
|
||||
this.lblInfo.TabIndex = 1;
|
||||
this.lblInfo.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// lblLoading
|
||||
//
|
||||
this.lblLoading.Location = new System.Drawing.Point(12, 49);
|
||||
this.lblLoading.Name = "lblLoading";
|
||||
this.lblLoading.Size = new System.Drawing.Size(366, 23);
|
||||
this.lblLoading.TabIndex = 0;
|
||||
this.lblLoading.Text = "Loading...";
|
||||
this.lblLoading.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// FormLoading
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(390, 179);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "FormLoading";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Loading";
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.Label lblLoading;
|
||||
private System.Windows.Forms.Label lblInfo;
|
||||
}
|
||||
}
|
19
AIProofread/Controls/FormLoading.cs
Normal file
19
AIProofread/Controls/FormLoading.cs
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AIProofread.Controls
|
||||
{
|
||||
public partial class FormLoading : Form
|
||||
{
|
||||
public FormLoading()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public void SetLoadingText(string text)
|
||||
{
|
||||
lblLoading.Text = text;
|
||||
}
|
||||
public void SetInfoText(string text) { lblInfo.Text = text; }
|
||||
}
|
||||
|
||||
}
|
120
AIProofread/Controls/FormLoading.resx
Normal file
120
AIProofread/Controls/FormLoading.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -35,5 +35,13 @@ namespace AIProofread
|
||||
{
|
||||
Log(tag + "\n" + e.StackTrace);
|
||||
}
|
||||
|
||||
public static void LogToWeb(string msg)
|
||||
{
|
||||
if (Config.RUN_IN_DEBUG)
|
||||
{
|
||||
Globals.ThisAddIn.SendMessageToWeb("DEBUG-LOG", msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
20
AIProofread/Ribbon1.Designer.cs
generated
20
AIProofread/Ribbon1.Designer.cs
generated
@ -52,6 +52,8 @@ namespace AIProofread
|
||||
this.btnShowPane = this.Factory.CreateRibbonButton();
|
||||
this.btnHidePane = this.Factory.CreateRibbonButton();
|
||||
this.btnTestLocation = this.Factory.CreateRibbonButton();
|
||||
this.btnSelectionPosition = this.Factory.CreateRibbonButton();
|
||||
this.button1 = this.Factory.CreateRibbonButton();
|
||||
this.tabAIProofread.SuspendLayout();
|
||||
this.group1.SuspendLayout();
|
||||
this.grpDebug.SuspendLayout();
|
||||
@ -169,6 +171,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.button1);
|
||||
this.grpDebug.Label = "开发调试";
|
||||
this.grpDebug.Name = "grpDebug";
|
||||
this.grpDebug.Visible = false;
|
||||
@ -189,8 +193,22 @@ namespace AIProofread
|
||||
//
|
||||
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.Name = "btnSelectionPosition";
|
||||
this.btnSelectionPosition.Visible = false;
|
||||
this.btnSelectionPosition.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btnSelectionPosition_Click);
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Label = "button1";
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.button1_Click);
|
||||
//
|
||||
// Ribbon1
|
||||
//
|
||||
this.Name = "Ribbon1";
|
||||
@ -225,6 +243,8 @@ namespace AIProofread
|
||||
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 button1;
|
||||
}
|
||||
|
||||
partial class ThisRibbonCollection
|
||||
|
@ -158,5 +158,73 @@ namespace AIProofread
|
||||
TestStr(3, "针");
|
||||
TestStr(22, "疏");
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
Paragraphs paragraphs = doc.Paragraphs;
|
||||
Range range = sel.Range;
|
||||
Paragraph paragraph = range.Paragraphs.First;
|
||||
int paragraphIndex = -1;
|
||||
for (int i = 1; i <= paragraphs.Count; i++)
|
||||
{
|
||||
|
||||
var para = paragraphs[i];
|
||||
if (para.Range.Start >= paragraph.Range.Start && para.Range.End <= paragraph.Range.End)
|
||||
{
|
||||
paragraphIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
||||
//public bool IsParagraphInTableOfContents(Document doc, Paragraph para)
|
||||
//{
|
||||
// // 检查文档和段落是否为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 button1_Click(object sender, RibbonControlEventArgs e)
|
||||
{
|
||||
var doc = Globals.ThisAddIn.Application.ActiveDocument;
|
||||
var styles = doc.Styles["TOC Heading"];
|
||||
|
||||
Console.WriteLine(styles.Font.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ using Microsoft.Office.Interop.Word;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace AIProofread
|
||||
{
|
||||
@ -292,6 +293,7 @@ namespace AIProofread
|
||||
Application.WindowActivate += Application_WindowActivate;
|
||||
Application.WindowDeactivate += Application_WindowDeactivate;
|
||||
(Application as ApplicationEvents4_Event).NewDocument += Application_NewDocument;
|
||||
//Application.DocumentChange +=
|
||||
// 选区发生变化事件
|
||||
//this.Application.WindowSelectionChange += Application_WindowSelectionChange;
|
||||
|
||||
|
@ -6,16 +6,24 @@ namespace AIProofread
|
||||
{
|
||||
public string Hash { get; set; }
|
||||
public string Text { get; set; }
|
||||
public int ParagraphNumber { get; set; }
|
||||
|
||||
public DocumentText() { }
|
||||
public DocumentText(string text)
|
||||
public DocumentText(string text, int paragraphNumber)
|
||||
{
|
||||
this.Text = text;
|
||||
this.ParagraphNumber = paragraphNumber;
|
||||
}
|
||||
public DocumentText(byte[] hash, string text)
|
||||
{
|
||||
this.Hash = BitConverter.ToString(hash).ToLower().Replace("-", "");
|
||||
this.Text = text;
|
||||
}
|
||||
public DocumentText(byte[] hash, string text, int paragraphNumber)
|
||||
{
|
||||
this.Hash = BitConverter.ToString(hash).ToLower().Replace("-", "");
|
||||
this.Text = text;
|
||||
this.ParagraphNumber = paragraphNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,13 @@
|
||||
using Newtonsoft.Json;
|
||||
using AIProofread.Controls;
|
||||
using Microsoft.Office.Interop.Word;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace AIProofread
|
||||
@ -14,30 +17,57 @@ namespace AIProofread
|
||||
private static readonly string[] paragSplitor = new string[] { "\r", "\n", "\r\n" };
|
||||
public static Dictionary<string, object> GetAllText()
|
||||
{
|
||||
var doc = Globals.ThisAddIn.Application.ActiveDocument;
|
||||
// 获取当前文档所有文本
|
||||
string allText = Globals.ThisAddIn.Application.ActiveDocument.Range().Text;
|
||||
string allText = doc.Range().Text;
|
||||
List<DocumentText> list = new List<DocumentText>();
|
||||
// // 开始分割
|
||||
MD5 md5 = new MD5CryptoServiceProvider();
|
||||
|
||||
if (allText != null && allText.Trim().Length > 0)
|
||||
//if (allText != null && allText.Trim().Length > 0)
|
||||
//{
|
||||
|
||||
// List<string> lines = allText.Split(paragSplitor, StringSplitOptions.None).ToList();//StringUtil.CutTextToSentences(allText);
|
||||
// foreach (string text in lines)
|
||||
// {
|
||||
// if(text.Trim().Length > 0)
|
||||
// {
|
||||
// byte[] hash = md5.ComputeHash(Encoding.Default.GetBytes(text));
|
||||
// list.Add(new DocumentText(hash, text + "\n"));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
|
||||
// list.Add(new DocumentText(text + "\n"));
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
Paragraphs paragraphs = doc.Paragraphs;
|
||||
int total = paragraphs.Count;
|
||||
//FormLoading frm = new FormLoading();
|
||||
//frm.Show();
|
||||
for (int paragraphNumber = 1; paragraphNumber <= total; paragraphNumber++)
|
||||
{
|
||||
// 开始分割
|
||||
MD5 md5 = new MD5CryptoServiceProvider();
|
||||
|
||||
List<string> lines = allText.Split(paragSplitor, StringSplitOptions.None).ToList();//StringUtil.CutTextToSentences(allText);
|
||||
foreach (string text in lines)
|
||||
Paragraph p = paragraphs[paragraphNumber];
|
||||
Range r = p.Range;
|
||||
if (r.ListFormat.ListType == WdListType.wdListPictureBullet
|
||||
|| r.Tables.Count > 0
|
||||
|| p.Range.Text.Trim().Length == 0)
|
||||
{
|
||||
if(text.Trim().Length > 0)
|
||||
{
|
||||
byte[] hash = md5.ComputeHash(Encoding.Default.GetBytes(text));
|
||||
list.Add(new DocumentText(hash, text + "\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
list.Add(new DocumentText(text + "\n"));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
string text = p.Range.Text;
|
||||
//Logger.LogToWeb(string.Format("get paragraph {0}", paragraphNumber));
|
||||
//frm.SetLoadingText(text);
|
||||
if (text.Trim().Length > 0)
|
||||
{
|
||||
//byte[] hash = md5.ComputeHash(Encoding.Default.GetBytes(text));
|
||||
list.Add(new DocumentText(text,paragraphNumber));
|
||||
}
|
||||
|
||||
}
|
||||
//frm.Close();
|
||||
var map = new Dictionary<string, object>
|
||||
{
|
||||
{ "list", list },
|
||||
|
Binary file not shown.
@ -1 +1 @@
|
||||
45c1006d89b86a8263132b8f944b694a4253831b72578a761854fd2065ca7135
|
||||
79ea390e4d68eda54ffacc73a1e70c811a130e7954fbba3a2df5692e3b3c6464
|
||||
|
@ -52,3 +52,4 @@ C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.
|
||||
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
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -10,6 +10,7 @@ namespace UtilLib
|
||||
public int Insert_len { get; set; }
|
||||
public int Offset { get; set; }
|
||||
public int Paragraph_offset { get; set; }
|
||||
public int Paragraph_num { get; set; }
|
||||
public int Sentence_offset { get; set; }
|
||||
public List<CorrectedContent> Diffs { get; set; }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user