fixed: 勘误表原文过长导致截取异常
This commit is contained in:
parent
03e0ffdce8
commit
31ee6d4894
@ -1,5 +1,6 @@
|
||||
using Microsoft.Office.Interop.Word;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using UtilLib;
|
||||
|
||||
@ -30,6 +31,22 @@ namespace AIProofread.Model
|
||||
{
|
||||
return sentence;
|
||||
}
|
||||
// 截取中间位置
|
||||
var middlePosition = MAX_WORD_LENGTH / 2;
|
||||
var cutStart = item.content.Start - middlePosition;
|
||||
// 越界了
|
||||
if(cutStart < 0)
|
||||
{
|
||||
cutStart = 0;
|
||||
}
|
||||
var originText = sentence.Substring(cutStart, MAX_WORD_LENGTH);
|
||||
Debug.WriteLine($"{cutStart} {originText}");
|
||||
if (!isInsert)
|
||||
{
|
||||
item.content.Start = item.content.Start - cutStart;
|
||||
item.content.End = item.content.End - cutStart;
|
||||
return originText;
|
||||
}
|
||||
var range = item.mark.Range;
|
||||
|
||||
// 获取range所在句子
|
||||
@ -50,6 +67,7 @@ namespace AIProofread.Model
|
||||
}
|
||||
}
|
||||
var first = sentences.First;
|
||||
// 内容位置:用于后续标红
|
||||
item.content.Start = range.Start - first.Start;
|
||||
item.content.End = range.End - first.Start;
|
||||
return sb.ToString().Trim();
|
||||
|
Loading…
x
Reference in New Issue
Block a user