mirror of
https://github.com/ONLYOFFICE/sdkjs.git
synced 2026-04-07 14:09:12 +08:00
[de] Refactor reading text from binary
This commit is contained in:
@ -12011,39 +12011,23 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, curNot
|
||||
return res;
|
||||
};
|
||||
this.ReadText = function(text, run, isInstrText){
|
||||
for (var i = 0; i < text.length; ++i)
|
||||
for (var it = text.getUnicodeIterator(); it.check(); it.next())
|
||||
{
|
||||
var nUnicode = null;
|
||||
var nCharCode = text.charCodeAt(i);
|
||||
if (AscCommon.isLeadingSurrogateChar(nCharCode))
|
||||
let nUnicode = it.value();
|
||||
if (isInstrText)
|
||||
{
|
||||
if(i + 1 < text.length)
|
||||
{
|
||||
i++;
|
||||
var nTrailingChar = text.charCodeAt(i);
|
||||
nUnicode = AscCommon.decodeSurrogateChar(nCharCode, nTrailingChar);
|
||||
}
|
||||
run.AddToContentToEnd(new AscWord.ParaInstrText(nUnicode));
|
||||
}
|
||||
else
|
||||
nUnicode = nCharCode;
|
||||
|
||||
if (null !== nUnicode) {
|
||||
if(isInstrText){
|
||||
run.AddToContentToEnd(new ParaInstrText(nUnicode));
|
||||
} else {
|
||||
if (AscCommon.IsSpace(nUnicode)) {
|
||||
run.AddToContentToEnd(new AscWord.CRunSpace(nUnicode));
|
||||
} else if (0x0D === nUnicode) {
|
||||
if (i + 1 < text.length && 0x0A === text.charCodeAt(i + 1)) {
|
||||
i++;
|
||||
}
|
||||
run.AddToContentToEnd(new AscWord.CRunSpace());
|
||||
} else if (0x09 === nUnicode) {
|
||||
run.AddToContentToEnd(new AscWord.CRunTab());
|
||||
} else {
|
||||
run.AddToContentToEnd(new AscWord.CRunText(nUnicode));
|
||||
}
|
||||
}
|
||||
{
|
||||
if (AscCommon.IsSpace(nUnicode))
|
||||
run.AddToContentToEnd(new AscWord.CRunSpace(nUnicode));
|
||||
else if (0x0D === nUnicode)
|
||||
run.AddToContentToEnd(new AscWord.CRunSpace());
|
||||
else if (0x09 === nUnicode)
|
||||
run.AddToContentToEnd(new AscWord.CRunTab());
|
||||
else
|
||||
run.AddToContentToEnd(new AscWord.CRunText(nUnicode));
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -13523,39 +13507,20 @@ function Binary_oMathReader(stream, oReadResult, curNote, openParams)
|
||||
if (c_oSerRunType.run === type)
|
||||
{
|
||||
var text = this.stream.GetString2LE(length);
|
||||
|
||||
for (var i = 0; i < text.length; ++i)
|
||||
for (var it = text.getUnicodeIterator(); it.check(); it.next())
|
||||
{
|
||||
var nUnicode = null;
|
||||
var nCharCode = text.charCodeAt(i);
|
||||
if (AscCommon.isLeadingSurrogateChar(nCharCode))
|
||||
{
|
||||
if(i + 1 < text.length)
|
||||
{
|
||||
i++;
|
||||
var nTrailingChar = text.charCodeAt(i);
|
||||
nUnicode = AscCommon.decodeSurrogateChar(nCharCode, nTrailingChar);
|
||||
}
|
||||
}
|
||||
else
|
||||
nUnicode = nCharCode;
|
||||
|
||||
if (null != nUnicode) {
|
||||
if (AscCommon.IsSpace(nUnicode)) {
|
||||
oPos.run.AddToContent(oPos.pos, new AscWord.CRunSpace(nUnicode), false);
|
||||
} else if (0x0D === nUnicode) {
|
||||
if (i + 1 < text.length && 0x0A === text.charCodeAt(i + 1)) {
|
||||
i++;
|
||||
}
|
||||
oPos.run.AddToContent(oPos.pos, new AscWord.CRunSpace(), false);
|
||||
} else if (0x09 === nUnicode) {
|
||||
oPos.run.AddToContent(oPos.pos, new AscWord.CRunTab(), false);
|
||||
} else {
|
||||
oPos.run.AddToContent(oPos.pos, new AscWord.CRunText(nUnicode), false);
|
||||
}
|
||||
oPos.pos++;
|
||||
}
|
||||
}
|
||||
let nUnicode = it.value();
|
||||
if (AscCommon.IsSpace(nUnicode)) {
|
||||
oPos.run.AddToContent(oPos.pos, new AscWord.CRunSpace(nUnicode), false);
|
||||
} else if (0x0D === nUnicode) {
|
||||
oPos.run.AddToContent(oPos.pos, new AscWord.CRunSpace(), false);
|
||||
} else if (0x09 === nUnicode) {
|
||||
oPos.run.AddToContent(oPos.pos, new AscWord.CRunTab(), false);
|
||||
} else {
|
||||
oPos.run.AddToContent(oPos.pos, new AscWord.CRunText(nUnicode), false);
|
||||
}
|
||||
oPos.pos++;
|
||||
}
|
||||
}
|
||||
else if (c_oSerRunType.tab === type)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user