Commit b5e5aacd authored by Sergey Konovalov's avatar Sergey Konovalov

removed all stubs for FldChar

parent 97ac4291
...@@ -391,8 +391,8 @@ var c_oSerRunType = { ...@@ -391,8 +391,8 @@ var c_oSerRunType = {
image:6, image:6,
table:7, table:7,
Content:8, Content:8,
fldstart: 9, fldstart_deprecated: 9,
fldend: 10, fldend_deprecated: 10,
CommentReference: 11, CommentReference: 11,
pptxDrawing: 12, pptxDrawing: 12,
_LastRun: 13, //для копирования через бинарник _LastRun: 13, //для копирования через бинарник
...@@ -410,7 +410,10 @@ var c_oSerRunType = { ...@@ -410,7 +410,10 @@ var c_oSerRunType = {
endnoteRef: 25, endnoteRef: 25,
footnoteReference: 26, footnoteReference: 26,
endnoteReference: 27, endnoteReference: 27,
arPr: 28 arPr: 28,
fldChar: 29,
instrText: 30,
delInstrText: 31
}; };
var c_oSerImageType = { var c_oSerImageType = {
MediaId:0, MediaId:0,
...@@ -754,7 +757,8 @@ var c_oSer_HyperlinkType = { ...@@ -754,7 +757,8 @@ var c_oSer_HyperlinkType = {
var c_oSer_FldSimpleType = { var c_oSer_FldSimpleType = {
Content: 0, Content: 0,
Instr: 1, Instr: 1,
FFData: 2 FFData: 2,
CharType: 3
}; };
var c_oSerProp_RevisionType = { var c_oSerProp_RevisionType = {
Author: 0, Author: 0,
...@@ -4521,15 +4525,11 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa ...@@ -4521,15 +4525,11 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa
oThis.WriteParagraphContent(oHyperlink, bUseSelection, false); oThis.WriteParagraphContent(oHyperlink, bUseSelection, false);
}); });
} }
this.WriteText = function (sCurText, delText) this.WriteText = function (sCurText, type)
{ {
if("" != sCurText) if("" != sCurText)
{ {
if (delText) { this.memory.WriteByte(type);
this.memory.WriteByte(c_oSerRunType.delText);
} else {
this.memory.WriteByte(c_oSerRunType.run);
}
this.memory.WriteString2(sCurText.toString()); this.memory.WriteString2(sCurText.toString());
sCurText = ""; sCurText = "";
} }
...@@ -4611,12 +4611,20 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa ...@@ -4611,12 +4611,20 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa
oThis.WriteRun2(function () { oThis.WriteRun2(function () {
//todo не писать через fldsimple //todo не писать через fldsimple
var num = elem.pageNum.Type == para_PageCount ? elem.pageNum.GetPageCountValue() : elem.pageNum.GetPageNumValue(); var num = elem.pageNum.Type == para_PageCount ? elem.pageNum.GetPageCountValue() : elem.pageNum.GetPageNumValue();
oThis.WriteText(num.toString(), delText); var textType = delText ? c_oSerRunType.delText : c_oSerRunType.run;
oThis.WriteText(num.toString(), textType);
}, oRun); }, oRun);
});}); });});
} }
} }
} }
this.WriteFldChar = function (fldChar)
{
var oThis = this;
this.bs.WriteItem(c_oSer_FldSimpleType.CharType, function() {
oThis.memory.WriteByte(fldChar.CharType);
});
};
this.WriteFldSimple = function (Instr, oFFData, fWriteContent) this.WriteFldSimple = function (Instr, oFFData, fWriteContent)
{ {
var oThis = this; var oThis = this;
...@@ -4778,14 +4786,18 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa ...@@ -4778,14 +4786,18 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa
var Content = oRun.Content; var Content = oRun.Content;
var sCurText = ""; var sCurText = "";
var sCurInstrText = "";
var textType = delText ? c_oSerRunType.delText : c_oSerRunType.run;
var instrTextType = delText ? c_oSerRunType.delInstrText : c_oSerRunType.instrText;
for (var i = nStart; i < nEnd && i < Content.length; ++i) for (var i = nStart; i < nEnd && i < Content.length; ++i)
{ {
var item = Content[i]; var item = Content[i];
switch ( item.Type ) switch ( item.Type )
{ {
case para_Text: case para_Text:
sCurInstrText = this.WriteText(sCurInstrText, instrTextType);
if (item.Is_NoBreakHyphen()) { if (item.Is_NoBreakHyphen()) {
sCurText = this.WriteText(sCurText, delText); sCurText = this.WriteText(sCurText, textType);
oThis.memory.WriteByte(c_oSerRunType.nonBreakHyphen); oThis.memory.WriteByte(c_oSerRunType.nonBreakHyphen);
oThis.memory.WriteLong(c_oSerPropLenType.Null); oThis.memory.WriteLong(c_oSerPropLenType.Null);
} else { } else {
...@@ -4796,12 +4808,14 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa ...@@ -4796,12 +4808,14 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa
sCurText += " "; sCurText += " ";
break; break;
case para_Tab: case para_Tab:
sCurText = this.WriteText(sCurText, delText); sCurText = this.WriteText(sCurText, textType);
sCurInstrText = this.WriteText(sCurInstrText, instrTextType);
oThis.memory.WriteByte(c_oSerRunType.tab); oThis.memory.WriteByte(c_oSerRunType.tab);
oThis.memory.WriteLong(c_oSerPropLenType.Null); oThis.memory.WriteLong(c_oSerPropLenType.Null);
break; break;
case para_NewLine: case para_NewLine:
sCurText = this.WriteText(sCurText, delText); sCurText = this.WriteText(sCurText, textType);
sCurInstrText = this.WriteText(sCurInstrText, instrTextType);
switch (item.BreakType) { switch (item.BreakType) {
case break_Column: case break_Column:
oThis.memory.WriteByte(c_oSerRunType.columnbreak); oThis.memory.WriteByte(c_oSerRunType.columnbreak);
...@@ -4830,8 +4844,16 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa ...@@ -4830,8 +4844,16 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa
case para_FootnoteReference: case para_FootnoteReference:
oThis.bs.WriteItem(c_oSerRunType.footnoteReference, function() {oThis.WriteFootnoteRef(item);}); oThis.bs.WriteItem(c_oSerRunType.footnoteReference, function() {oThis.WriteFootnoteRef(item);});
break; break;
case para_FieldChar:
oThis.bs.WriteItem(c_oSerRunType.fldChar, function() {oThis.WriteFldChar(item);});
break;
case para_InstrText:
sCurText = this.WriteText(sCurText, textType);
sCurInstrText += AscCommon.encodeSurrogateChar(item.Value);
break;
case para_Drawing: case para_Drawing:
sCurText = this.WriteText(sCurText, delText); sCurText = this.WriteText(sCurText, textType);
sCurInstrText = this.WriteText(sCurInstrText, instrTextType);
//if (item.Extent && item.GraphicObj && item.GraphicObj.spPr && item.GraphicObj.spPr.xfrm) { //if (item.Extent && item.GraphicObj && item.GraphicObj.spPr && item.GraphicObj.spPr.xfrm) {
// item.Extent.W = item.GraphicObj.spPr.xfrm.extX; // item.Extent.W = item.GraphicObj.spPr.xfrm.extX;
// item.Extent.H = item.GraphicObj.spPr.xfrm.extY; // item.Extent.H = item.GraphicObj.spPr.xfrm.extY;
...@@ -4854,7 +4876,8 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa ...@@ -4854,7 +4876,8 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa
break; break;
} }
} }
sCurText = this.WriteText(sCurText, delText); sCurText = this.WriteText(sCurText, textType);
sCurInstrText = this.WriteText(sCurInstrText, instrTextType);
}; };
this.WriteFootnoteRef = function(footnoteReference) this.WriteFootnoteRef = function(footnoteReference)
{ {
...@@ -9456,6 +9479,17 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, curFoo ...@@ -9456,6 +9479,17 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, curFoo
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
return res; return res;
}; };
this.ReadFldChar = function (type, length, oPos) {
var res = c_oSerConstants.ReadOk;
var oThis = this;
if (c_oSer_FldSimpleType.CharType === type) {
oPos.run.Add_ToContent(oPos.pos, new ParaFieldChar(this.stream.GetUChar()), false);
oPos.pos++;
} else
res = c_oSerConstants.ReadUnknown;
return res;
}
this.ReadFldSimple = function (type, length, oFldSimpleObj, oParStruct) { this.ReadFldSimple = function (type, length, oFldSimpleObj, oParStruct) {
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
var oThis = this; var oThis = this;
...@@ -9652,6 +9686,34 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, curFoo ...@@ -9652,6 +9686,34 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, curFoo
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
return res; return res;
}; };
this.ReadText = function(text, oPos, isInstrText){
for (var i = 0; i < text.length; ++i)
{
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 (0x20 !== nUnicode || isInstrText) {
var oNewParaText = isInstrText ? new ParaInstrText() : new ParaText();
oNewParaText.Set_CharCode(nUnicode);
oPos.run.Add_ToContent(oPos.pos, oNewParaText, false);
}
else
oPos.run.Add_ToContent(oPos.pos, new ParaSpace(), false);
oPos.pos++;
}
}
};
this.ReadRunContent = function (type, length, oPos, oParStruct, oRes) this.ReadRunContent = function (type, length, oPos, oParStruct, oRes)
{ {
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
...@@ -9672,32 +9734,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, curFoo ...@@ -9672,32 +9734,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, curFoo
this.oCurComments[i] += text; this.oCurComments[i] += text;
} }
for (var i = 0; i < text.length; ++i) this.ReadText(text, oPos, false);
{
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 (0x20 != nUnicode) {
var oNewParaText = new ParaText();
oNewParaText.Set_CharCode(nUnicode);
oPos.run.Add_ToContent(oPos.pos, oNewParaText, false);
}
else
oPos.run.Add_ToContent(oPos.pos, new ParaSpace(), false);
oPos.pos++;
}
}
} }
else if (c_oSerRunType.tab === type) else if (c_oSerRunType.tab === type)
{ {
...@@ -9759,7 +9796,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, curFoo ...@@ -9759,7 +9796,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, curFoo
if(null != oDrawing.content.GraphicObj) if(null != oDrawing.content.GraphicObj)
oNewElem = oDrawing.content; oNewElem = oDrawing.content;
} }
else if(c_oSerRunType.fldstart === type) else if(c_oSerRunType.fldstart_deprecated === type)
{ {
oRes.bRes = false; oRes.bRes = false;
var sField = this.stream.GetString2LE(length); var sField = this.stream.GetString2LE(length);
...@@ -9769,7 +9806,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, curFoo ...@@ -9769,7 +9806,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, curFoo
} }
this.aFields.push(oField); this.aFields.push(oField);
} }
else if(c_oSerRunType.fldend === type) else if(c_oSerRunType.fldend_deprecated === type)
{ {
oRes.bRes = false; oRes.bRes = false;
var elem = this.aFields.pop(); var elem = this.aFields.pop();
...@@ -9777,6 +9814,16 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, curFoo ...@@ -9777,6 +9814,16 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, curFoo
oParStruct.commitElem(); oParStruct.commitElem();
} }
} }
else if(c_oSerRunType.fldChar === type)
{
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadFldChar(t,l,oPos);
});
}
else if(c_oSerRunType.instrText === type || c_oSerRunType.delInstrText === type)
{
this.ReadText(this.stream.GetString2LE(length), oPos, true);
}
else if (c_oSerRunType._LastRun === type) else if (c_oSerRunType._LastRun === type)
this.oReadResult.bLastRun = true; this.oReadResult.bLastRun = true;
else if (c_oSerRunType.object === type) else if (c_oSerRunType.object === type)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment