feat: 添加并适配政务校对
This commit is contained in:
parent
d37882d6dd
commit
e04d6104b2
@ -747,6 +747,11 @@ namespace AIProofread
|
||||
Globals.ThisAddIn.ActiveDocument.FocusToPanel();
|
||||
}
|
||||
|
||||
public string GetProofreadOriginData()
|
||||
{
|
||||
return Tools.GetJSONString(Globals.ThisAddIn.ActiveDocument.GetProofreadOriginData());
|
||||
}
|
||||
|
||||
public string SaveCache(int documentId, string cache, bool silent)
|
||||
{
|
||||
var document = Globals.ThisAddIn.GetDocumentById(documentId);
|
||||
@ -833,12 +838,13 @@ namespace AIProofread
|
||||
return BridgeResult.Success(result == DialogResult.Yes ? "yes" : "no");
|
||||
}
|
||||
|
||||
public string InitProofreadCacheList(string content)
|
||||
public string InitProofreadCacheList(string content,string originData)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<CorrectContext> list = JsonConvert.DeserializeObject<List<CorrectContext>>(content);
|
||||
Globals.ThisAddIn.InitProofreadCacheList(list);
|
||||
Dictionary<int,ProofreadRangeInfo> dics = string.IsNullOrEmpty(originData) ? null : JsonConvert.DeserializeObject<Dictionary<int, ProofreadRangeInfo>>(originData);
|
||||
Globals.ThisAddIn.InitProofreadCacheList(list, dics);
|
||||
return BridgeResult.Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -20,7 +20,7 @@ namespace AIProofread
|
||||
/// <summary>
|
||||
/// 文本背景色
|
||||
/// </summary>
|
||||
public static readonly string TextBackgroundColor = "#D6AA69";
|
||||
public static readonly string TextBackgroundColor = "#E9DABB"; // e9dabb D6AA69
|
||||
public static string DeviceId = "";
|
||||
#if DEBUG
|
||||
/// <summary>
|
||||
|
@ -4,12 +4,15 @@ using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AIProofread.Controls
|
||||
{
|
||||
[ClassInterface(ClassInterfaceType.AutoDual)]
|
||||
[ComVisible(true)]
|
||||
public partial class FormContact : BaseWinForm
|
||||
{
|
||||
public FormContact()
|
||||
|
@ -745,7 +745,7 @@ namespace AIProofread.Model
|
||||
}
|
||||
|
||||
|
||||
public void InitProofreadCache(List<CorrectContext> list)
|
||||
public void InitProofreadCache(List<CorrectContext> list,Dictionary<int, ProofreadRangeInfo> itemInfoDic)
|
||||
{
|
||||
marks.Clear();
|
||||
|
||||
@ -757,6 +757,19 @@ namespace AIProofread.Model
|
||||
if (mark != null)
|
||||
{
|
||||
var pi = new ProofreadItem(item, correct.Insert, mark, Id);
|
||||
// 是否存在样式信息
|
||||
if (itemInfoDic!= null && itemInfoDic.ContainsKey(item.Id))
|
||||
{
|
||||
// 获取样式信息并还原
|
||||
var info = itemInfoDic[item.Id];
|
||||
try
|
||||
{
|
||||
pi.originColor = info.Color;
|
||||
pi.originBackgroundColor = info.Background;
|
||||
pi.originSize = info.Size;
|
||||
}
|
||||
catch (Exception ex) { }
|
||||
}
|
||||
marks.Add(item.Id, pi);
|
||||
}
|
||||
});
|
||||
@ -971,5 +984,25 @@ namespace AIProofread.Model
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public Dictionary<int, ProofreadRangeInfo> GetProofreadOriginData()
|
||||
{
|
||||
Dictionary<int,ProofreadRangeInfo> dic = new Dictionary<int, ProofreadRangeInfo>();
|
||||
// 变量文档所有marks 记录mark对应range的背景、大小、颜色
|
||||
foreach (var item in marks)
|
||||
{
|
||||
if (item.Value.mark != null)
|
||||
{
|
||||
// 添加到数据
|
||||
dic.Add(item.Key, new ProofreadRangeInfo()
|
||||
{
|
||||
Background = item.Value.originBackgroundColor,
|
||||
Color = item.Value.originColor,
|
||||
Size = item.Value.originSize
|
||||
});
|
||||
}
|
||||
}
|
||||
return dic;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
11
AIProofread/Model/ProofreadRangeInfo.cs
Normal file
11
AIProofread/Model/ProofreadRangeInfo.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using Microsoft.Office.Interop.Word;
|
||||
|
||||
namespace AIProofread.Model
|
||||
{
|
||||
public class ProofreadRangeInfo
|
||||
{
|
||||
public float Size { get; set; }
|
||||
public WdColor Background { get; set; }
|
||||
public WdColor Color { get; set; }
|
||||
}
|
||||
}
|
@ -14,9 +14,9 @@ namespace UtilLib
|
||||
public Bookmark mark;
|
||||
public string OriginSentence { get; set; }
|
||||
public CorrectItem content;
|
||||
private float originSize;
|
||||
private WdColor originColor;
|
||||
private WdColor originBackgroundColor;
|
||||
public float originSize;
|
||||
public WdColor originColor;
|
||||
public WdColor originBackgroundColor;
|
||||
public string Name { get; set; }
|
||||
public int DocumentId { get; set; }
|
||||
|
||||
@ -145,7 +145,6 @@ namespace UtilLib
|
||||
Math.Min(range.End + 2, fullRange.End)
|
||||
);
|
||||
var comments = checkRange.Comments;
|
||||
Logger.Log("判断是否有批注");
|
||||
// 判断当前书签选区内容是否有评论
|
||||
if (comments != null && comments.Count > 0)
|
||||
{
|
||||
@ -161,10 +160,6 @@ namespace UtilLib
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Log("没有批注");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -224,7 +219,6 @@ namespace UtilLib
|
||||
var paragraphEnd = mark.Paragraphs.Last.Range.End;
|
||||
var end = mark.End + 2 > paragraphEnd ? paragraphEnd : mark.End + 2;
|
||||
var rng = Globals.ThisAddIn.ActiveDocument.Range(mark.End, end);
|
||||
Logger.Log($"开始处理百分号问题:位置({mark.End},{end}) => 内容:{rng.Text}");
|
||||
|
||||
// 判断书签范围内是否有批注
|
||||
|
||||
|
@ -181,7 +181,11 @@ namespace AIProofread
|
||||
|
||||
private void BtnGetContact_Click(object sender, RibbonControlEventArgs e)
|
||||
{
|
||||
(new FormContact()).ShowDialog();
|
||||
var frm = new FormContact();
|
||||
Globals.ThisAddIn.ActiveDocument.RunInMainThread(() =>
|
||||
{
|
||||
frm.ShowDialog();
|
||||
});
|
||||
}
|
||||
|
||||
private void BtnUpdate_Click(object sender, RibbonControlEventArgs e)
|
||||
|
@ -563,7 +563,7 @@ namespace AIProofread
|
||||
|
||||
public DocumentInfo GetDocumentById(int id)
|
||||
{
|
||||
return documentList.GetById(id);
|
||||
return id <= 0 ? ActiveDocument : documentList.GetById(id);
|
||||
}
|
||||
|
||||
|
||||
@ -609,9 +609,9 @@ namespace AIProofread
|
||||
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
|
||||
}
|
||||
|
||||
public void InitProofreadCacheList(System.Collections.Generic.List<CorrectContext> list)
|
||||
public void InitProofreadCacheList(List<CorrectContext> list, Dictionary<int, ProofreadRangeInfo> dics)
|
||||
{
|
||||
ActiveDocument?.InitProofreadCache(list);
|
||||
ActiveDocument?.InitProofreadCache(list, dics);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -31,7 +31,7 @@ namespace UtilLib
|
||||
/// <summary>
|
||||
/// 标识类型index(字符型数字)
|
||||
/// </summary>
|
||||
public int Index { get; set; }
|
||||
public string Index { get; set; }
|
||||
/// <summary>
|
||||
/// 标识类型(校对所属分类)
|
||||
/// </summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user