Commit fb3ec5ad authored by Igor.Zotov's avatar Igor.Zotov Committed by Alexander.Trofimov

корректировал функции, отвечающие за вставку бинарника из редактора документов

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55595 954022d7-b5bf-4e40-9824-e11837661b57
parent bb68cd91
...@@ -3228,6 +3228,7 @@ ...@@ -3228,6 +3228,7 @@
} }
} }
} }
if(childrens[i].children.length == 0) if(childrens[i].children.length == 0)
{ {
//if parent - cell of table //if parent - cell of table
...@@ -3293,9 +3294,9 @@ ...@@ -3293,9 +3294,9 @@
_parseParagraph: function(paragraph, activeRange, row, col, rowSpan, colSpan) _parseParagraph: function(paragraph, activeRange, row, col, rowSpan, colSpan)
{ {
var content = paragraph.Content; var content = paragraph.Content;
var row, colorText, cTextPr, fontFamily = "Arial"; var row, cTextPr, fontFamily = "Arial";
var text = null; var text = null;
var oNewItem = []; var oNewItem = [], cloneNewItem;
var paraRunContent; var paraRunContent;
var aResult = this.aResult; var aResult = this.aResult;
...@@ -3319,10 +3320,11 @@ ...@@ -3319,10 +3320,11 @@
oNewItem.colSpan = this.aResult[row][col][0].colSpan; oNewItem.colSpan = this.aResult[row][col][0].colSpan;
} }
delete this.aResult[row][col]; delete this.aResult[row][col];
} };
if(!aResult[row]) if(!aResult[row])
aResult[row] = []; aResult[row] = [];
var s = 0; var s = 0;
var c1 = col !== undefined ? col : activeRange.c1; var c1 = col !== undefined ? col : activeRange.c1;
...@@ -3336,67 +3338,96 @@ ...@@ -3336,67 +3338,96 @@
if(backgroundColor) if(backgroundColor)
oNewItem.bc = backgroundColor; oNewItem.bc = backgroundColor;
//настройки параграфа
paragraph.CompiledPr.NeedRecalc = true; paragraph.CompiledPr.NeedRecalc = true;
var paraPr = paragraph.Get_CompiledPr(); var paraPr = paragraph.Get_CompiledPr();
var paragraphFontFamily = paraPr.TextPr.FontFamily.Name; var paragraphFontFamily = paraPr.TextPr.FontFamily.Name;
var paragraphFontSize = paraPr.TextPr.FontSize;
var paragraphBold = paraPr.TextPr.Bold;
var paragraphItalic = paraPr.TextPr.Italic;
var paragraphStrikeout = paraPr.TextPr.Strikeout;
var paragraphUnderline = paraPr.TextPr.Underline;
var paragraphVertAlign = "none";
if(paraPr.TextPr.VertAlign == 1)
paragraphVertAlign = "superscript";
else if(paraPr.TextPr.VertAlign == 2)
paragraphVertAlign = "subscript";
var colorParagraph = new RgbColor(this.clipboard._getBinaryColor("rgb(" + paraPr.TextPr.Color.r + "," + paraPr.TextPr.Color.g + "," + paraPr.TextPr.Color.b + ")"));
var cTextPr, formatText;
//проходимся по контенту paragraph //проходимся по контенту paragraph
for(var n = 0; n < content.length; n++) for(var n = 0; n < content.length; n++)
{ {
//s - меняется в зависимости от табуляции //s - меняется в зависимости от табуляции
if(!aResult[row][s + c1]) if(!aResult[row][s + c1])
{
aResult[row][s + c1] = []; aResult[row][s + c1] = [];
}
if(text == null) if(text == null)
text = ""; text = "";
//*paraRun*
if(content[n] instanceof ParaRun) if(content[n] instanceof ParaRun)
{ {
paraRunContent = content[n].Content; paraRunContent = content[n].Content;
cTextPr = content[n].Get_CompiledPr();
if(cTextPr && !(paraRunContent.length == 1 && paraRunContent[0] instanceof ParaEnd))//settings for text
formatText = this._getPrParaRun(paraPr, cTextPr);
else if(!formatText)
formatText = this._getPrParaRun(paraPr, cTextPr);
for(var pR = 0; pR < paraRunContent.length; pR++) for(var pR = 0; pR < paraRunContent.length; pR++)
{ {
if(paraRunContent[pR] instanceof ParaTextPr)//settings for text
if(paraRunContent[pR] instanceof ParaText)//text
{
text += paraRunContent[pR].Value;
}
else if(paraRunContent[pR] instanceof ParaSpace)
{
text += " ";
}
else if(paraRunContent[pR] instanceof ParaTab || paraRunContent[pR] instanceof ParaEnd)//tab
{ {
if(text !== null && oNewItem[oNewItem.length - 1])//oNewItem - массив, аналогичный value2 if(!oNewItem.length)
oNewItem[oNewItem.length - 1].text = text;
else if(text !== null && oNewItem.length == 0)
{ {
this.fontsNew["Arial"] = 1; fontFamily = paragraphFontFamily;
colorText = new RgbColor(this.clipboard._getBinaryColor("rgb(0, 0, 0)")); this.fontsNew[fontFamily] = 1;
var calcValue = paraRunContent[pR].CalcValue; oNewItem.push(formatText);
oNewItem.push({
format: {
fn: calcValue.FontFamily && calcValue.FontFamily.Name ? calcValue.FontFamily.Name : paragraphFontFamily,
fs: calcValue.FontSize ? calcValue.FontSize : paragraphFontSize,
c: colorParagraph ? colorParagraph : colorText,
b: paragraphBold,
i: paragraphItalic,
u: paragraphUnderline,
s: paragraphStrikeout,
va: "none"
} }
});
if(text !== null)
oNewItem[oNewItem.length - 1].text = text; oNewItem[oNewItem.length - 1].text = text;
cloneNewItem = this._getCloneNewItem(oNewItem);
//переходим в следующую ячейку
if(typeof aResult[row][s + c1] == "object")
aResult[row][s + c1][aResult[row][s + c1].length] = cloneNewItem;
else
{
aResult[row][s + c1] = [];
aResult[row][s + c1][0] = cloneNewItem;
} }
text = ""; text = "";
oNewItem = [];
s++;
}
};
};
};
},
_getPrParaRun: function(paraPr, cTextPr)
{
var formatText, fontFamily, colorText;
cTextPr = paraRunContent[pR].CalcValue; var paragraphFontSize = paraPr.TextPr.FontSize;
var paragraphBold = paraPr.TextPr.Bold;
var paragraphItalic = paraPr.TextPr.Italic;
var paragraphStrikeout = paraPr.TextPr.Strikeout;
var paragraphUnderline = paraPr.TextPr.Underline ? Asc.EUnderline.underlineSingle : Asc.EUnderline.underlineNone;
var paragraphVertAlign = "none";
if(paraPr.TextPr.VertAlign == 1)
paragraphVertAlign = "superscript";
else if(paraPr.TextPr.VertAlign == 2)
paragraphVertAlign = "subscript";
var colorParagraph = new RgbColor(this.clipboard._getBinaryColor("rgb(" + paraPr.TextPr.Color.r + "," + paraPr.TextPr.Color.g + "," + paraPr.TextPr.Color.b + ")"));
if(cTextPr.Color) if(cTextPr.Color)
colorText = new RgbColor(this.clipboard._getBinaryColor("rgb(" + cTextPr.Color.r + "," + cTextPr.Color.g + "," + cTextPr.Color.b + ")")); colorText = new RgbColor(this.clipboard._getBinaryColor("rgb(" + cTextPr.Color.r + "," + cTextPr.Color.g + "," + cTextPr.Color.b + ")"));
...@@ -3412,104 +3443,37 @@ ...@@ -3412,104 +3443,37 @@
else if(cTextPr.VertAlign == 1) else if(cTextPr.VertAlign == 1)
verticalAlign = "superscript"; verticalAlign = "superscript";
formatText = {
oNewItem.push({
format: { format: {
fn: fontFamily, fn: fontFamily,
fs: cTextPr.FontSize ? cTextPr.FontSize : paragraphFontSize, fs: cTextPr.FontSize ? cTextPr.FontSize : paragraphFontSize,
c: colorText ? colorText : colorParagraph, c: colorText ? colorText : colorParagraph,
b: cTextPr.Bold ? cTextPr.Bold : paragraphBold, b: cTextPr.Bold ? cTextPr.Bold : paragraphBold,
i: cTextPr.Italic ? cTextPr.Italic : paragraphItalic, i: cTextPr.Italic ? cTextPr.Italic : paragraphItalic,
u: cTextPr.Underline ? cTextPr.Underline : paragraphUnderline, u: cTextPr.Underline ? Asc.EUnderline.underlineSingle : paragraphUnderline,
s: cTextPr.Strikeout ? cTextPr.Strikeout : paragraphStrikeout, s: cTextPr.Strikeout ? cTextPr.Strikeout : paragraphStrikeout,
va: verticalAlign ? verticalAlign : paragraphVertAlign va: verticalAlign ? verticalAlign : paragraphVertAlign
} }
}); };
}
else if(paraRunContent[pR] instanceof ParaText)//text
{
text += paraRunContent[pR].Value;
}
else if(paraRunContent[pR] instanceof ParaSpace)
{
text += " ";
}
else if(paraRunContent[pR] instanceof ParaTab)//tab
{
if(!oNewItem.length)
{
fontFamily = paragraphFontFamily;
this.fontsNew[fontFamily] = 1;
colorText = colorParagraph ? colorParagraph : new RgbColor(this.clipboard._getBinaryColor("rgb(0, 0, 0)"));
oNewItem.push({ return formatText;
format: { },
fn: fontFamily,
fs: paragraphFontSize,
c: colorText,
b: paragraphBold,
i: paragraphItalic,
u: paragraphUnderline,
s: paragraphStrikeout,
va: paragraphVertAlign
}
});
}
if(text !== null)
oNewItem[oNewItem.length - 1].text = text;
//переходим в следующую ячейку
if(typeof aResult[row][s + c1] == "object")
aResult[row][s + c1][aResult[row][s + c1].length] = oNewItem;
else
{
aResult[row][s + c1] = [];
aResult[row][s + c1][0] = oNewItem;
}
text = ""; _getCloneNewItem: function(oNewItem)
oNewItem = [];
s++;
}
else if(paraRunContent[pR] instanceof ParaEnd)//end
{
if(!oNewItem.length)
{ {
fontFamily = paragraphFontFamily; var result = [];
this.fontsNew[fontFamily] = 1;
colorText = colorParagraph ? colorParagraph : new RgbColor(this.clipboard._getBinaryColor("rgb(0, 0, 0)"));
oNewItem.push({ for(var item = 0; item < oNewItem.length; item++)
format: {
fn: fontFamily,
fs: paragraphFontSize,
c: colorText,
b: paragraphBold,
i: paragraphItalic,
u: paragraphUnderline,
s: paragraphStrikeout,
va: paragraphVertAlign
}
});
}
if(text !== null)
oNewItem[oNewItem.length - 1].text = text;
text = "";
if(typeof aResult[row][s + c1] == "object")
aResult[row][s + c1][aResult[row][s + c1].length] = oNewItem;
else
{
aResult[row][s + c1] = [];
aResult[row][s + c1][0] = oNewItem;
}
}
else if(n == paraRunContent[pR].length - 1)//end of row
{ {
text = ""; result[item] = {text: oNewItem[item].text, format: oNewItem[item].format};
oNewItem = [];
}
};
}
}; };
result.borders = oNewItem.borders;
result.rowSpan = oNewItem.rowSpan;
result.colSpan = oNewItem.colSpan;
result.bc = oNewItem.bc;
return result;
} }
}; };
......
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