Commit b92152bd authored by GoshaZotov's avatar GoshaZotov

changes into _convertTableToText

parent 822ba96b
...@@ -2390,42 +2390,33 @@ PasteProcessor.prototype = ...@@ -2390,42 +2390,33 @@ PasteProcessor.prototype =
_convertTableToText: function(table, obj) _convertTableToText: function(table, obj)
{ {
var oDoc = this.oLogicDocument; var oDoc = this.oLogicDocument;
var t = this;
if(!obj)
{
obj = [];
}
var addTextToRun = function(oCurRun, value) /*var parseDocumentContent = function(cDocumentContent, newParagraph, addPararunNum)
{ {
for(var k = 0, length = value.length; k < length; k++) for(var n = 0; n < cDocumentContent.Content.length; n++)
{ {
var nUnicode = null; if(cDocumentContent.Content[n] instanceof Paragraph)
var nCharCode = value.charCodeAt(k); {
if (AscCommon.isLeadingSurrogateChar(nCharCode)) { var value = cDocumentContent.Content[n].GetText();
if (k + 1 < length) { var newParaRun = new ParaRun();
k++;
var nTrailingChar = value.charCodeAt(k);
nUnicode = AscCommon.decodeSurrogateChar(nCharCode, nTrailingChar);
}
}
else
nUnicode = nCharCode;
if (null != nUnicode) {
var Item;
if (0x20 !== nUnicode && 0xA0 !== nUnicode && 0x2009 !== nUnicode) {
Item = new ParaText();
Item.Set_CharCode(nUnicode);
}
else
Item = new ParaSpace();
//add text t._addTextIntoRun(newParaRun, value);
oCurRun.Add_ToContent(k, Item, false);
newParagraph.Internal_Content_Add(addPararunNum, newParaRun, false);
} }
else if(cDocumentContent.Content[n] instanceof CTable)
{
t._convertTableToText(cDocumentContent.Content[n], obj);
} }
}; }
};*/
if(!obj)
{
obj = [];
}
//row //row
for(var i = 0; i < table.Content.length; i++) for(var i = 0; i < table.Content.length; i++)
{ {
...@@ -2436,44 +2427,42 @@ PasteProcessor.prototype = ...@@ -2436,44 +2427,42 @@ PasteProcessor.prototype =
{ {
//content //content
var cDocumentContent = table.Content[i].Content[j].Content; var cDocumentContent = table.Content[i].Content[j].Content;
var bIsPreviousTable = false; //parseDocumentContent(cDocumentContent, newParagraph, j);
var isAddParagraph = false;
//TODO нужно поправить проблему с внутренними таблицами
var createNewParagraph = false;
var previousTableAdd = false;
for(var n = 0; n < cDocumentContent.Content.length; n++) for(var n = 0; n < cDocumentContent.Content.length; n++)
{ {
if(bIsPreviousTable) previousTableAdd = false;
if(createNewParagraph)
{ {
newParagraph = new Paragraph(oDoc.DrawingDocument, oDoc); newParagraph = new Paragraph(oDoc.DrawingDocument, oDoc);
bIsPreviousTable = false; createNewParagraph = false;
} }
if(cDocumentContent.Content[n] instanceof Paragraph) if(cDocumentContent.Content[n] instanceof Paragraph)
{ {
var value = cDocumentContent.Content[n].GetText(); var value = cDocumentContent.Content[n].GetText();
var newParaRun = new ParaRun(); var newParaRun = new ParaRun();
addTextToRun(newParaRun, value); t._addTextIntoRun(newParaRun, value);
isAddParagraph = true;
newParagraph.Internal_Content_Add(j, newParaRun, false); newParagraph.Internal_Content_Add(j, newParaRun, false);
/*if(isAddParagraph)
{
obj.push(newParagraph);
isAddParagraph = false;
}
bIsPreviousTable = true;*/
} }
else if(cDocumentContent.Content[n] instanceof CTable) else if(cDocumentContent.Content[n] instanceof CTable)
{ {
if(isAddParagraph) t._convertTableToText(cDocumentContent.Content[n], obj);
previousTableAdd = true;
}
if(!previousTableAdd && cDocumentContent.Content.length > 1 && n !== cDocumentContent.Content.length - 1)
{ {
obj.push(newParagraph); obj.push(newParagraph);
isAddParagraph = false; createNewParagraph = true;
}
bIsPreviousTable = true;
this._convertTableToText(cDocumentContent.Content[n], obj);
} }
} }
} }
obj.push(newParagraph); obj.push(newParagraph);
...@@ -2482,6 +2471,36 @@ PasteProcessor.prototype = ...@@ -2482,6 +2471,36 @@ PasteProcessor.prototype =
return obj; return obj;
}, },
_addTextIntoRun: function(oCurRun, value)
{
for(var k = 0, length = value.length; k < length; k++)
{
var nUnicode = null;
var nCharCode = value.charCodeAt(k);
if (AscCommon.isLeadingSurrogateChar(nCharCode)) {
if (k + 1 < length) {
k++;
var nTrailingChar = value.charCodeAt(k);
nUnicode = AscCommon.decodeSurrogateChar(nCharCode, nTrailingChar);
}
}
else
nUnicode = nCharCode;
if (null != nUnicode) {
var Item;
if (0x20 !== nUnicode && 0xA0 !== nUnicode && 0x2009 !== nUnicode) {
Item = new ParaText();
Item.Set_CharCode(nUnicode);
}
else
Item = new ParaSpace();
//add text
oCurRun.Add_ToContent(k, Item, false);
}
}
},
InsertInPlacePresentation: function(aNewContent) InsertInPlacePresentation: function(aNewContent)
{ {
var presentation = editor.WordControl.m_oLogicDocument; var presentation = editor.WordControl.m_oLogicDocument;
......
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