Commit aebbb827 authored by GoshaZotov's avatar GoshaZotov

changes for paste into cell editor

parent aa9b1036
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
*/ */
var g_fontApplication = AscFonts.g_fontApplication; var g_fontApplication = AscFonts.g_fontApplication;
var c_oAscBorderStyles = AscCommon.c_oAscBorderStyles; var c_oAscBorderStyles = AscCommon.c_oAscBorderStyles;
var c_oAscMaxCellOrCommentLength = AscCommon.c_oAscMaxCellOrCommentLength; var c_oAscMaxCellOrCommentLength = Asc.c_oAscMaxCellOrCommentLength;
var doc = window.document; var doc = window.document;
var copyPasteUseBinary = true; var copyPasteUseBinary = true;
var CopyPasteCorrectString = AscCommon.CopyPasteCorrectString; var CopyPasteCorrectString = AscCommon.CopyPasteCorrectString;
...@@ -1242,7 +1242,7 @@ ...@@ -1242,7 +1242,7 @@
if(node == undefined) if(node == undefined)
return; return;
var aResult, binaryResult, pasteFragment = node, t = this, localStorageResult; var binaryResult, pasteFragment = node, t = this, localStorageResult;
t.alreadyLoadImagesOnServer = false; t.alreadyLoadImagesOnServer = false;
//****binary**** //****binary****
...@@ -1493,10 +1493,10 @@ ...@@ -1493,10 +1493,10 @@
var result = false; var result = false;
var isChange = false; var isChange = false;
var currentCellData = aResult[r][c]; var currentCellData = aResult.content[r][c];
if(currentCellData && currentCellData[0]) if(currentCellData && currentCellData.content)
{ {
currentCellData = currentCellData[0]; currentCellData = currentCellData.content;
for(var i = 0; i < currentCellData.length; i++) for(var i = 0; i < currentCellData.length; i++)
{ {
if(currentCellData[i] && currentCellData[i].text && currentCellData[i].text.length > c_oAscMaxCellOrCommentLength) if(currentCellData[i] && currentCellData[i].text && currentCellData[i].text.length > c_oAscMaxCellOrCommentLength)
...@@ -1510,15 +1510,15 @@ ...@@ -1510,15 +1510,15 @@
for(var j = 0; j < iterCount; j++) for(var j = 0; j < iterCount; j++)
{ {
splitText = text.substr(c_oAscMaxCellOrCommentLength * j, c_oAscMaxCellOrCommentLength * (j + 1)); splitText = text.substr(c_oAscMaxCellOrCommentLength * j, c_oAscMaxCellOrCommentLength * (j + 1));
if(!aResult[r]) if(!aResult.content[r])
aResult[r] = []; aResult.content[r] = [];
if(!aResult[r][c]) if(!aResult.content[r][c])
aResult[r][c] = []; aResult.content[r][c] = [];
if(!aResult[r][c][0]) if(!aResult.content[r][c].content)
aResult[r][c][0] = []; aResult.content[r][c].content = [];
aResult[r][c][0] = currentCellData; aResult.content[r][c].content[0] = currentCellData[0];
aResult[r][c][0][0].text = splitText; aResult.content[r][c].content[0].text = splitText;
if(iterCount !== j + 1) if(iterCount !== j + 1)
r++; r++;
...@@ -1574,7 +1574,7 @@ ...@@ -1574,7 +1574,7 @@
History.StartTransaction(); History.StartTransaction();
var api = window["Asc"]["editor"]; var api = window["Asc"]["editor"];
var addImagesFromWord = data.addImagesFromWord; var addImagesFromWord = data.props.addImagesFromWord;
//определяем стартовую позицию, если изображений несколько вставляется //определяем стартовую позицию, если изображений несколько вставляется
for(var i = 0; i < addImagesFromWord.length; i++) for(var i = 0; i < addImagesFromWord.length; i++)
{ {
...@@ -1961,19 +1961,8 @@ ...@@ -1961,19 +1961,8 @@
return; return;
} }
var aResult = []; var aResult = new excelPasteContent();
aResult[this.activeRange.r1] = []; aResult = aResult.getDefaultPasteContent(worksheet, this.activeRange.r1, this.activeRange.c1, text);
var oNewItem = [];
oNewItem[0] = this._getDefaultCell(worksheet);
aResult[this.activeRange.r1][this.activeRange.c1] = oNewItem;
oNewItem[0][0].text = text;
aResult.fontsNew = [];
aResult.rowSpanSpCount = 0;
aResult.cellCount = 1;
aResult._images = undefined;
aResult._aPastedImages = undefined;
if(aResult && !(aResult.onlyImages && window["Asc"]["editor"] && window["Asc"]["editor"].isChartEditor)) if(aResult && !(aResult.onlyImages && window["Asc"]["editor"] && window["Asc"]["editor"].isChartEditor))
{ {
...@@ -1981,28 +1970,6 @@ ...@@ -1981,28 +1970,6 @@
} }
}, },
_getDefaultCell: function (worksheet)
{
var res = [];
var fn = worksheet.model.workbook.getDefaultFont();
var fs = worksheet.model.workbook.getDefaultSize();
res.push({
format: {
fn: fn,
fs: fs,
b: false,
i: false,
u: Asc.EUnderline.underlineNone,
s: false,
va: 'none'
},
text: ''});
return res;
},
_getTextFromWorksheet: function(worksheet) _getTextFromWorksheet: function(worksheet)
{ {
var res = ""; var res = "";
...@@ -2095,11 +2062,137 @@ ...@@ -2095,11 +2062,137 @@
}; };
/** @constructor */
function excelPasteContent()
{
this.content = [];
this.props = {};
return this;
}
excelPasteContent.prototype = {
constructor: excelPasteContent,
getDefaultPasteContent: function(worksheet, row, col, text)
{
var pasteCell = this.getCell(row, col);
pasteCell.setDefaultCell(worksheet);
pasteCell.content[0].text = text;
this.props.fontsNew = [];
this.props.rowSpanSpCount = 0;
this.props.cellCount = 1;
this.props._images = undefined;
this.props._aPastedImages = undefined;
return this;
},
setCellContent: function(row, col, data)
{
if(!this.content[row])
{
this.content[row] = [];
}
if(!this.content[row][col])
{
this.content[row][col] = [];
}
this.content[row][col] = data;
},
getCell: function(row, col)
{
if(!this.content[row])
{
this.content[row] = [];
}
if(!this.content[row][col])
{
this.content[row][col] = new pasteCell();
}
return this.content[row][col];
},
deleteCell: function(row, col)
{
delete this.content[row][col];
}
};
/** @constructor */
function pasteCell()
{
this.content = [];
this.rowSpan = null;
this.colSpan = null;
this.bc = null;
this.borders = null;
this.toolTip = null;
this.hyperLink = null;
return this;
}
pasteCell.prototype = {
constructor: pasteCell,
addContentItem: function(item)
{
this.content.push(item);
},
clone: function()
{
var result = new pasteCell();
for(var item = 0; item < this.content.length; item++)
{
result.content[item] = {text: this.content[item].text, format: this.content[item].format};
};
result.borders = this.borders;
result.rowSpan = this.rowSpan;
result.colSpan = this.colSpan;
result.toolTip = this.toolTip;
result.bc = this.bc;
result.hyperLink = this.hyperLink;
return result;
},
setDefaultCell: function (worksheet)
{
var fn = worksheet.model.workbook.getDefaultFont();
var fs = worksheet.model.workbook.getDefaultSize();
this.content.push({
format: {
fn: fn,
fs: fs,
b: false,
i: false,
u: Asc.EUnderline.underlineNone,
s: false,
va: 'none'
},
text: ''});
}
};
/** @constructor */ /** @constructor */
function pasteFromBinaryWord(clipboard, ws) { function pasteFromBinaryWord(clipboard, ws)
{
this.aResult = new excelPasteContent();
this.fontsNew = {}; this.fontsNew = {};
this.aResult = [];
this.clipboard = clipboard; this.clipboard = clipboard;
this.ws = ws; this.ws = ws;
this.isUsuallyPutImages = null; this.isUsuallyPutImages = null;
...@@ -2126,18 +2219,18 @@ ...@@ -2126,18 +2219,18 @@
var coverDocument = documentContentBounds.getBounds(0,0, documentContent); var coverDocument = documentContentBounds.getBounds(0,0, documentContent);
this._parseChildren(coverDocument, activeRange); this._parseChildren(coverDocument, activeRange);
this.aResult.fontsNew = this.fontsNew;
this.aResult.rowSpanSpCount = 0; this.aResult.props.fontsNew = this.fontsNew;
this.aResult.cellCount = coverDocument.width; this.aResult.props.rowSpanSpCount = 0;
this.aResult._images = pasteData.images ? pasteData.images : this.aResult._images; this.aResult.props.cellCount = coverDocument.width;
this.aResult._aPastedImages = pasteData.aPastedImages ? pasteData.aPastedImages : this.aResult._aPastedImages; this.aResult.props._images = pasteData.images ? pasteData.images : this.aResult.props._images;
this.aResult.props._aPastedImages = pasteData.aPastedImages ? pasteData.aPastedImages : this.aResult.props._aPastedImages;
worksheet.setSelectionInfo('paste', this.aResult, this); worksheet.setSelectionInfo('paste', this.aResult, this);
}, },
_parseChildren: function(children, activeRange) _parseChildren: function(children, activeRange)
{ {
var backgroundColor;
var childrens = children.children; var childrens = children.children;
for(var i = 0; i < childrens.length; i++) for(var i = 0; i < childrens.length; i++)
{ {
...@@ -2145,15 +2238,8 @@ ...@@ -2145,15 +2238,8 @@
{ {
for(var row = childrens[i].top; row < childrens[i].top + childrens[i].height; row++) for(var row = childrens[i].top; row < childrens[i].top + childrens[i].height; row++)
{ {
if(!this.aResult[row + activeRange.r1])
this.aResult[row + activeRange.r1] = [];
for(var col = childrens[i].left; col < childrens[i].left + childrens[i].width; col++) for(var col = childrens[i].left; col < childrens[i].left + childrens[i].width; col++)
{ {
if(!this.aResult[row + activeRange.r1][col + activeRange.c1])
this.aResult[row + activeRange.r1][col + activeRange.c1] = [];
if(!this.aResult[row + activeRange.r1][col + activeRange.c1][0])
this.aResult[row + activeRange.r1][col + activeRange.c1][0] = [];
var isCtable = false; var isCtable = false;
var tempChildren = childrens[i].children[0].children; var tempChildren = childrens[i].children[0].children;
var colSpan = null; var colSpan = null;
...@@ -2173,16 +2259,21 @@ ...@@ -2173,16 +2259,21 @@
rowSpan = childrens[i].height; rowSpan = childrens[i].height;
colSpan = childrens[i].width; colSpan = childrens[i].width;
} }
this.aResult[row + activeRange.r1][col + activeRange.c1][0].rowSpan = rowSpan;
this.aResult[row + activeRange.r1][col + activeRange.c1][0].colSpan = colSpan; var newCell = this.aResult.getCell(row + activeRange.r1, col + activeRange.c1)
newCell.rowSpan = rowSpan;
newCell.colSpan = colSpan;
//backgroundColor //backgroundColor
backgroundColor = this.getBackgroundColorTCell(childrens[i]); var backgroundColor = this.getBackgroundColorTCell(childrens[i]);
if(backgroundColor) if(backgroundColor)
this.aResult[row + activeRange.r1][col + activeRange.c1][0].bc = backgroundColor; {
newCell.bc = backgroundColor;
}
this.aResult[row + activeRange.r1][col + activeRange.c1][0].borders = this._getBorders(childrens[i], row, col, this.aResult[row + activeRange.r1][col + activeRange.c1][0].borders); var borders = this._getBorders(childrens[i], row, col, newCell.borders);
newCell.borders = borders;
} }
} }
} }
...@@ -2200,67 +2291,18 @@ ...@@ -2200,67 +2291,18 @@
} }
}, },
_getBorders: function(cellTable, top, left, oldBorders)
{
var borders = cellTable.elem.Get_Borders();
var widthCell = cellTable.width;
var heigthCell = cellTable.height;
var defaultStyle = "solid";
var borderStyleName;
var formatBorders = oldBorders ? oldBorders : new AscCommonExcel.Border();
//top border for cell
if(top == cellTable.top && !formatBorders.t.s && borders.Top.Value !== 0/*border_None*/)
{
borderStyleName = this.clipboard._getBorderStyleName(defaultStyle, this.ws.objectRender.convertMetric(borders.Top.Size,3,1));
if (null !== borderStyleName) {
formatBorders.t.setStyle(borderStyleName);
formatBorders.t.c = new AscCommonExcel.RgbColor(this.clipboard._getBinaryColor("rgb(" + borders.Top.Color.r + "," + borders.Top.Color.g + "," + borders.Top.Color.b + ")"));
}
}
//left border for cell
if(left == cellTable.left && !formatBorders.l.s && borders.Left.Value !== 0/*border_None*/)
{
borderStyleName = this.clipboard._getBorderStyleName(defaultStyle, this.ws.objectRender.convertMetric(borders.Left.Size,3,1));
if (null !== borderStyleName) {
formatBorders.l.setStyle(borderStyleName);
formatBorders.l.c = new AscCommonExcel.RgbColor(this.clipboard._getBinaryColor("rgb(" + borders.Left.Color.r + "," + borders.Left.Color.g + "," + borders.Left.Color.b + ")"));
}
}
//bottom border for cell
if(top == cellTable.top + heigthCell - 1 && !formatBorders.b.s && borders.Bottom.Value !== 0/*border_None*/)
{
borderStyleName = this.clipboard._getBorderStyleName(defaultStyle, this.ws.objectRender.convertMetric(borders.Bottom.Size,3,1));
if (null !== borderStyleName) {
formatBorders.b.setStyle(borderStyleName);
formatBorders.b.c = new AscCommonExcel.RgbColor(this.clipboard._getBinaryColor("rgb(" + borders.Bottom.Color.r + "," + borders.Bottom.Color.g + "," + borders.Bottom.Color.b + ")"));
}
}
//right border for cell
if(left == cellTable.left + widthCell - 1 && !formatBorders.r.s && borders.Right.Value !== 0/*border_None*/)
{
borderStyleName = this.clipboard._getBorderStyleName(defaultStyle, this.ws.objectRender.convertMetric(borders.Right.Size,3,1));
if (null !== borderStyleName) {
formatBorders.r.setStyle(borderStyleName);
formatBorders.r.c = new AscCommonExcel.RgbColor(this.clipboard._getBinaryColor("rgb(" + borders.Right.Color.r + "," + borders.Right.Color.g + "," + borders.Right.Color.b + ")"));
}
}
return formatBorders;
},
_parseParagraph: function(paragraph, activeRange, row, col, rowSpan, colSpan) _parseParagraph: function(paragraph, activeRange, row, col, rowSpan, colSpan)
{ {
var content = paragraph.elem.Content; var content = paragraph.elem.Content;
var row, cTextPr, fontFamily = "Arial"; var row, cTextPr, fontFamily = "Arial";
var text = null; var text = null;
var oNewItem = [], cloneNewItem; var oNewItem = new pasteCell(), cloneNewItem;
var paraRunContent; var paraRunContent;
var aResult = this.aResult; var aResult = this.aResult;
if(row === undefined) if(row === undefined)
{ {
if(aResult.length == 0) if(aResult.content.length == 0)
{ {
row = activeRange.r1; row = activeRange.r1;
} }
...@@ -2268,20 +2310,24 @@ ...@@ -2268,20 +2310,24 @@
row = aResult.length; row = aResult.length;
} }
if(this.aResult[row + this.maxLengthRowCount] && this.aResult[row + this.maxLengthRowCount][col] && this.aResult[row + this.maxLengthRowCount][col][0] && this.aResult[row + this.maxLengthRowCount][col][0].length === 0 && (this.aResult[row + this.maxLengthRowCount][col][0].borders || this.aResult[row + this.maxLengthRowCount][col][0].rowSpan != null)) var cell = this.aResult.getCell(row + this.maxLengthRowCount, col);
if(cell && cell.length === 0 && (cell.borders || cell.rowSpan != null))
{ {
if(this.aResult[row + this.maxLengthRowCount][col][0].borders) if(cell.borders)
oNewItem.borders = this.aResult[row + this.maxLengthRowCount][col][0].borders; {
if(this.aResult[row + this.maxLengthRowCount][col][0].rowSpan != null) oNewItem.borders = cell.borders;
}
if(cell.rowSpan != null)
{ {
oNewItem.rowSpan = this.aResult[row + this.maxLengthRowCount][col][0].rowSpan; oNewItem.rowSpan = cell.rowSpan;
oNewItem.colSpan = this.aResult[row + this.maxLengthRowCount][col][0].colSpan; oNewItem.colSpan = cell.colSpan;
} }
delete this.aResult[row + this.maxLengthRowCount][col]; this.aResult.deleteCell(row + this.maxLengthRowCount, 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;
...@@ -2336,10 +2382,10 @@ ...@@ -2336,10 +2382,10 @@
fontFamily = formatText.format.fn; fontFamily = formatText.format.fn;
this.fontsNew[fontFamily] = 1; this.fontsNew[fontFamily] = 1;
oNewItem.push(formatText); oNewItem.content.push(formatText);
if(text !== null) if(text !== null)
oNewItem[oNewItem.length - 1].text = text; oNewItem.content[oNewItem.content.length - 1].text = text;
text = ""; text = "";
}; };
...@@ -2348,17 +2394,11 @@ ...@@ -2348,17 +2394,11 @@
//проходимся по контенту paragraph //проходимся по контенту paragraph
for(var n = 0; n < content.length; n++) for(var n = 0; n < content.length; n++)
{ {
if(!aResult[row + this.maxLengthRowCount]) this.aResult.getCell(row + this.maxLengthRowCount, s + c1);
aResult[row + this.maxLengthRowCount] = [];
//s - меняется в зависимости от табуляции
if(!aResult[row + this.maxLengthRowCount][s + c1])
aResult[row + this.maxLengthRowCount][s + c1] = [];
if(text == null) if(text == null)
text = ""; text = "";
switch(content[n].Type) switch(content[n].Type)
{ {
case para_Run://*paraRun* case para_Run://*paraRun*
...@@ -2402,79 +2442,6 @@ ...@@ -2402,79 +2442,6 @@
}, },
_getAlignHorisontal: function(paraPr)
{
var result;
var settings = paraPr.ParaPr;
if(!settings)
return;
switch(settings.Jc)
{
case 0:
{
result = "right";
break;
}
case 1:
{
result = "left";
break;
}
case 2:
{
result = "center";
break;
}
case 3:
{
result = null;
break;
}
};
return result;
},
getBackgroundColorTCell: function(elem)
{
var compiledPrCell, color;
var backgroundColor = null;
//TODO внутреннии таблицы без стиля - цвет фона белый
var tableCell = this._getParentByTag(elem, c_oAscBoundsElementType.Cell);
if(tableCell)
{
compiledPrCell = tableCell.elem.Get_CompiledPr();
if(compiledPrCell && compiledPrCell.Shd.Value !== 1/*shd_Nil*/)
{
var color = compiledPrCell.Shd.Color;
backgroundColor = new AscCommonExcel.RgbColor(this.clipboard._getBinaryColor("rgb(" + color.r + "," + color.g + "," + color.b + ")"));
};
};
return backgroundColor;
},
_getParentByTag: function(elem, tag)
{
var result;
if(!elem)
return null;
if(elem.type == tag)
result = elem;
else if(elem.parent)
result = this._getParentByTag(elem.parent, tag);
else if(!elem.parent)
result = null;
return result;
},
_parseParaRun: function(paraRun, oNewItem, paraPr, s, row, c1, text) _parseParaRun: function(paraRun, oNewItem, paraPr, s, row, c1, text)
{ {
var paraRunContent = paraRun.Content; var paraRunContent = paraRun.Content;
...@@ -2508,38 +2475,30 @@ ...@@ -2508,38 +2475,30 @@
case para_Tab://*paraEnd / paraTab* case para_Tab://*paraEnd / paraTab*
{ {
//if(!oNewItem.length) this.fontsNew[paragraphFontFamily] = 1;
//{ oNewItem.content.push(formatText);
this.fontsNew[paragraphFontFamily] = 1;
oNewItem.push(formatText);
//}
if(text !== null) if(text !== null)
oNewItem[oNewItem.length - 1].text = text; oNewItem.content[oNewItem.content.length - 1].text = text;
cloneNewItem = this._getCloneNewItem(oNewItem); cloneNewItem = oNewItem.clone();
//переходим в следующую ячейку //переходим в следующую ячейку
if(typeof aResult[row + this.maxLengthRowCount][s + c1] == "object") var cell = aResult.getCell(row + this.maxLengthRowCount, s + c1);
aResult[row + this.maxLengthRowCount][s + c1][aResult[row + this.maxLengthRowCount][s + c1].length] = cloneNewItem; aResult.setCellContent(row + this.maxLengthRowCount, s + c1, cloneNewItem);
else
{
aResult[row + this.maxLengthRowCount][s + c1] = [];
aResult[row + this.maxLengthRowCount][s + c1][0] = cloneNewItem;
}
text = ""; text = "";
oNewItem = []; oNewItem = new pasteCell();
s++; s++;
break; break;
}; };
case para_Drawing: case para_Drawing:
{ {
if(!aResult.addImagesFromWord) if(!aResult.props.addImagesFromWord)
aResult.addImagesFromWord = []; aResult.props.addImagesFromWord = [];
aResult.addImagesFromWord[aResult.addImagesFromWord.length] = {image: paraRunContent[pR], col: s + c1, row: row}; aResult.props.addImagesFromWord.push({image: paraRunContent[pR], col: s + c1, row: row});
if(null === this.isUsuallyPutImages) if(null === this.isUsuallyPutImages)
this._addImageToMap(paraRunContent[pR]); this._addImageToMap(paraRunContent[pR]);
...@@ -2547,18 +2506,13 @@ ...@@ -2547,18 +2506,13 @@
case para_End: case para_End:
{ {
if(typeof aResult[row][s + c1] == "object") var cell = aResult.getCell(row, s + c1);
aResult[row][s + c1][aResult[row][s + c1].length] = oNewItem; aResult.setCellContent(row, s + c1, oNewItem);
else
{
aResult[row][s + c1] = [];
aResult[row][s + c1][0] = oNewItem;
}
var checkMaxTextLength = this.clipboard._checkMaxTextLength(this.aResult, row + this.maxLengthRowCount, s + c1); var checkMaxTextLength = this.clipboard._checkMaxTextLength(this.aResult, row + this.maxLengthRowCount, s + c1);
if(checkMaxTextLength) if(checkMaxTextLength)
{ {
aResult = checkMaxTextLength.aResult; aResult.content = checkMaxTextLength.aResult.content;
this.maxLengthRowCount += checkMaxTextLength.r - row; this.maxLengthRowCount += checkMaxTextLength.r - row;
} }
}; };
...@@ -2569,13 +2523,13 @@ ...@@ -2569,13 +2523,13 @@
{ {
this.fontsNew[paragraphFontFamily] = 1; this.fontsNew[paragraphFontFamily] = 1;
oNewItem.push(formatText); oNewItem.content.push(formatText);
if(text !== null) if(text !== null)
oNewItem[oNewItem.length - 1].text = text; oNewItem.content[oNewItem.content.length - 1].text = text;
cloneNewItem = this._getCloneNewItem(oNewItem); cloneNewItem = oNewItem.clone();
text = ""; text = "";
}; };
...@@ -2586,18 +2540,141 @@ ...@@ -2586,18 +2540,141 @@
_addImageToMap: function(paraDrawing) _addImageToMap: function(paraDrawing)
{ {
var aResult = this.aResult; var aResult = this.aResult;
if(!aResult._aPastedImages) if(!aResult.props._aPastedImages)
aResult._aPastedImages = []; aResult.props._aPastedImages = [];
if(!aResult._images) if(!aResult.props._images)
aResult._images = []; aResult.props._images = [];
var oGraphicObj = paraDrawing.GraphicObj; var oGraphicObj = paraDrawing.GraphicObj;
if(!oGraphicObj || (oGraphicObj && !oGraphicObj.blipFill) || (oGraphicObj && oGraphicObj.blipFill && !oGraphicObj.blipFill.RasterImageId)) if(!oGraphicObj || (oGraphicObj && !oGraphicObj.blipFill) || (oGraphicObj && oGraphicObj.blipFill && !oGraphicObj.blipFill.RasterImageId))
return; return;
var sImageUrl = oGraphicObj.blipFill.RasterImageId; var sImageUrl = oGraphicObj.blipFill.RasterImageId;
aResult._aPastedImages[aResult._aPastedImages.length] = new AscCommon.CBuilderImages(oGraphicObj.blipFill, sImageUrl, oGraphicObj, oGraphicObj.spPr, null); aResult.props._aPastedImages.push(new AscCommon.CBuilderImages(oGraphicObj.blipFill, sImageUrl, oGraphicObj, oGraphicObj.spPr, null));
aResult._images[aResult._images.length] = sImageUrl; aResult.props._images.push(sImageUrl);
},
_getBorders: function(cellTable, top, left, oldBorders)
{
var borders = cellTable.elem.Get_Borders();
var widthCell = cellTable.width;
var heigthCell = cellTable.height;
var defaultStyle = "solid";
var borderStyleName;
var formatBorders = oldBorders ? oldBorders : new AscCommonExcel.Border();
//top border for cell
if(top == cellTable.top && !formatBorders.t.s && borders.Top.Value !== 0/*border_None*/)
{
borderStyleName = this.clipboard._getBorderStyleName(defaultStyle, this.ws.objectRender.convertMetric(borders.Top.Size,3,1));
if (null !== borderStyleName) {
formatBorders.t.setStyle(borderStyleName);
formatBorders.t.c = new AscCommonExcel.RgbColor(this.clipboard._getBinaryColor("rgb(" + borders.Top.Color.r + "," + borders.Top.Color.g + "," + borders.Top.Color.b + ")"));
}
}
//left border for cell
if(left == cellTable.left && !formatBorders.l.s && borders.Left.Value !== 0/*border_None*/)
{
borderStyleName = this.clipboard._getBorderStyleName(defaultStyle, this.ws.objectRender.convertMetric(borders.Left.Size,3,1));
if (null !== borderStyleName) {
formatBorders.l.setStyle(borderStyleName);
formatBorders.l.c = new AscCommonExcel.RgbColor(this.clipboard._getBinaryColor("rgb(" + borders.Left.Color.r + "," + borders.Left.Color.g + "," + borders.Left.Color.b + ")"));
}
}
//bottom border for cell
if(top == cellTable.top + heigthCell - 1 && !formatBorders.b.s && borders.Bottom.Value !== 0/*border_None*/)
{
borderStyleName = this.clipboard._getBorderStyleName(defaultStyle, this.ws.objectRender.convertMetric(borders.Bottom.Size,3,1));
if (null !== borderStyleName) {
formatBorders.b.setStyle(borderStyleName);
formatBorders.b.c = new AscCommonExcel.RgbColor(this.clipboard._getBinaryColor("rgb(" + borders.Bottom.Color.r + "," + borders.Bottom.Color.g + "," + borders.Bottom.Color.b + ")"));
}
}
//right border for cell
if(left == cellTable.left + widthCell - 1 && !formatBorders.r.s && borders.Right.Value !== 0/*border_None*/)
{
borderStyleName = this.clipboard._getBorderStyleName(defaultStyle, this.ws.objectRender.convertMetric(borders.Right.Size,3,1));
if (null !== borderStyleName) {
formatBorders.r.setStyle(borderStyleName);
formatBorders.r.c = new AscCommonExcel.RgbColor(this.clipboard._getBinaryColor("rgb(" + borders.Right.Color.r + "," + borders.Right.Color.g + "," + borders.Right.Color.b + ")"));
}
}
return formatBorders;
},
_getAlignHorisontal: function(paraPr)
{
var result;
var settings = paraPr.ParaPr;
if(!settings)
return;
switch(settings.Jc)
{
case 0:
{
result = "right";
break;
}
case 1:
{
result = "left";
break;
}
case 2:
{
result = "center";
break;
}
case 3:
{
result = null;
break;
}
};
return result;
},
getBackgroundColorTCell: function(elem)
{
var compiledPrCell, color;
var backgroundColor = null;
//TODO внутреннии таблицы без стиля - цвет фона белый
var tableCell = this._getParentByTag(elem, c_oAscBoundsElementType.Cell);
if(tableCell)
{
compiledPrCell = tableCell.elem.Get_CompiledPr();
if(compiledPrCell && compiledPrCell.Shd.Value !== 1/*shd_Nil*/)
{
var color = compiledPrCell.Shd.Color;
backgroundColor = new AscCommonExcel.RgbColor(this.clipboard._getBinaryColor("rgb(" + color.r + "," + color.g + "," + color.b + ")"));
};
};
return backgroundColor;
},
_getParentByTag: function(elem, tag)
{
var result;
if(!elem)
return null;
if(elem.type == tag)
result = elem;
else if(elem.parent)
result = this._getParentByTag(elem.parent, tag);
else if(!elem.parent)
result = null;
return result;
}, },
_getAllNumberingText: function(Lvl, numberingText) _getAllNumberingText: function(Lvl, numberingText)
...@@ -2647,22 +2724,6 @@ ...@@ -2647,22 +2724,6 @@
NumTextPr.Merge( TextPr_temp ); NumTextPr.Merge( TextPr_temp );
NumTextPr.Merge( NumLvl.TextPr ); NumTextPr.Merge( NumLvl.TextPr );
/*var X_start = X;
if ( align_Right === NumJc )
X_start = X - NumberingItem.WidthNum;
else if ( align_Center === NumJc )
X_start = X - NumberingItem.WidthNum / 2;
NumTextPr.Unifill.check(PDSE.Theme, PDSE.ColorMap);
var RGBA = NumTextPr.Unifill.getRGBAColor();
if ( true === NumTextPr.Color.Auto )
pGraphics.b_color1( AutoColor.r, AutoColor.g, AutoColor.b, 255);
else
pGraphics.b_color1(RGBA.R, RGBA.G, RGBA.B, 255 );*/
// Рисуется только сам символ нумерации
var oNumPr = paragraph.Numbering_Get(); var oNumPr = paragraph.Numbering_Get();
var LvlPr, Lvl; var LvlPr, Lvl;
...@@ -2904,25 +2965,6 @@ ...@@ -2904,25 +2965,6 @@
}; };
return formatText; return formatText;
},
_getCloneNewItem: function(oNewItem)
{
var result = [];
for(var item = 0; item < oNewItem.length; item++)
{
result[item] = {text: oNewItem[item].text, format: oNewItem[item].format};
};
result.borders = oNewItem.borders;
result.rowSpan = oNewItem.rowSpan;
result.colSpan = oNewItem.colSpan;
result.toolTip = result.toolTip;
result.bc = oNewItem.bc;
result.hyperLink = oNewItem.hyperLink;
return result;
} }
}; };
......
...@@ -9164,7 +9164,7 @@ ...@@ -9164,7 +9164,7 @@
break; break;
case "paste": case "paste":
// Вставляем текст из локального буфера или нет // Вставляем текст из локального буфера или нет
isLocal ? t._pasteFromLocalBuff( isLargeRange, isLocal, val, bIsUpdate, canChangeColWidth ) : t._pasteFromGlobalBuff( isLargeRange, isLocal, val, bIsUpdate, canChangeColWidth ); isLocal ? t._pasteData(isLargeRange, isLocal, val, bIsUpdate, canChangeColWidth) : t._loadDataBeforePaste(isLargeRange, isLocal, val, bIsUpdate, canChangeColWidth);
bIsUpdate = false; bIsUpdate = false;
break; break;
case "hyperlink": case "hyperlink":
...@@ -9207,7 +9207,7 @@ ...@@ -9207,7 +9207,7 @@
t._updateCellsRange( arn, canChangeColWidth ); t._updateCellsRange( arn, canChangeColWidth );
} }
//в случае, если вставляем из глобального буфера, транзакцию закрываем внутри функции _pasteFromGlobalBuff на callbacks от загрузки шрифтов и картинок //в случае, если вставляем из глобального буфера, транзакцию закрываем внутри функции _loadDataBeforePaste на callbacks от загрузки шрифтов и картинок
if ( prop !== "paste" || (prop === "paste" && isLocal) ) { if ( prop !== "paste" || (prop === "paste" && isLocal) ) {
History.EndTransaction(); History.EndTransaction();
} }
...@@ -9218,7 +9218,7 @@ ...@@ -9218,7 +9218,7 @@
checkRange = t._pasteFromBinary( val, true ); checkRange = t._pasteFromBinary( val, true );
} }
else { else {
checkRange = t._setInfoAfterPaste( val, true ); checkRange = t._pasteFromHTML( val, true );
} }
} }
if ( "paste" === prop && val.onlyImages === true ) { if ( "paste" === prop && val.onlyImages === true ) {
...@@ -9229,45 +9229,54 @@ ...@@ -9229,45 +9229,54 @@
} }
}; };
WorksheetView.prototype._pasteFromLocalBuff = function ( isLargeRange, isLocal, val, bIsUpdate, canChangeColWidth ) { WorksheetView.prototype._pasteData = function ( isLargeRange, isLocal, val, bIsUpdate, canChangeColWidth ) {
var t = this; var t = this;
var callTrigger = false; var callTrigger = false;
if ( isLargeRange ) { if ( isLargeRange )
{
callTrigger = true; callTrigger = true;
t.handlers.trigger( "slowOperation", true ); t.handlers.trigger( "slowOperation", true );
} }
t.model.workbook.lockDraw(); t.model.workbook.lockDraw();
var selectData; var selectData;
if ( isLocal === 'binary' ) { if ( isLocal === 'binary' )
{
selectData = t._pasteFromBinary( val ); selectData = t._pasteFromBinary( val );
} }
else { else
selectData = t._setInfoAfterPaste( val ); {
selectData = t._pasteFromHTML( val );
} }
t.model.autoFilters.renameTableColumn( t.activeRange ); t.model.autoFilters.renameTableColumn( t.activeRange );
if ( !selectData ) { if ( !selectData )
{
bIsUpdate = false; bIsUpdate = false;
t.model.workbook.unLockDraw(); t.model.workbook.unLockDraw();
t.model.workbook.buildRecalc(); t.model.workbook.buildRecalc();
if ( callTrigger ) { if ( callTrigger )
{
t.handlers.trigger( "slowOperation", false ); t.handlers.trigger( "slowOperation", false );
} }
return; return;
} }
this.expandColsOnScroll(false, true); this.expandColsOnScroll(false, true);
this.expandRowsOnScroll(false, true); this.expandRowsOnScroll(false, true);
var arrFormula = selectData[1]; var arrFormula = selectData[1];
for ( var i = 0; i < arrFormula.length; ++i ) {//!!! for ( var i = 0; i < arrFormula.length; ++i )
{
var rangeF = arrFormula[i].range; var rangeF = arrFormula[i].range;
var valF = arrFormula[i].val; var valF = arrFormula[i].val;
if ( rangeF.isOneCell() ) { if ( rangeF.isOneCell() )
{
rangeF.setValue( valF, null, true ); rangeF.setValue( valF, null, true );
} }
else { else
{
var oBBox = rangeF.getBBox0(); var oBBox = rangeF.getBBox0();
t.model._getCell( oBBox.r1, oBBox.c1 ).setValue( valF, null, true ); t.model._getCell( oBBox.r1, oBBox.c1 ).setValue( valF, null, true );
} }
...@@ -9279,27 +9288,8 @@ ...@@ -9279,27 +9288,8 @@
var selectionRange = arn.clone( true ); var selectionRange = arn.clone( true );
//добавляем автофильтры и форматированные таблицы //добавляем автофильтры и форматированные таблицы
if ( isLocal === true && val.lStorage && val.lStorage.autoFilters && val.lStorage.autoFilters.length ) { if ( isLocal === 'binary' && val.TableParts && val.TableParts.length )
var aFilters = val.lStorage.autoFilters; {
var range;
for ( var aF = 0; aF < aFilters.length; aF++ ) {
range = t.model.getRange3( aFilters[aF].range.r1 + selectionRange.r1, aFilters[aF].range.c1 + selectionRange.c1, aFilters[aF].range.r2 + selectionRange.r1, aFilters[aF].range.c2 + selectionRange.c1 );
//если область вставки содержит форматированную таблицу, которая пересекается с вставляемой форматированной таблицей
var intersectionRangeWithTableParts = t.model.autoFilters._intersectionRangeWithTableParts( range.bbox );
if ( intersectionRangeWithTableParts )
continue;
if ( aFilters[aF].style ) {
range.cleanFormat();
}
t.model.autoFilters.addAutoFilter( aFilters[aF].style, range.bbox, true, true );
if ( !aFilters[aF].autoFilter ) {
t.model.autoFilters.addAutoFilter( null, range.bbox, true, true );
}
}
}
else if ( isLocal === 'binary' && val.TableParts && val.TableParts.length ) {
var aFilters = val.TableParts; var aFilters = val.TableParts;
var range; var range;
var tablePartRange; var tablePartRange;
...@@ -9345,16 +9335,20 @@ ...@@ -9345,16 +9335,20 @@
//делаем unmerge ф/т //делаем unmerge ф/т
var arnToRange = t.activeRange; var arnToRange = t.activeRange;
var intersectionRangeWithTableParts = t.model.autoFilters._intersectionRangeWithTableParts( arnToRange ); var intersectionRangeWithTableParts = t.model.autoFilters._intersectionRangeWithTableParts( arnToRange );
if ( intersectionRangeWithTableParts && intersectionRangeWithTableParts.length ) { if ( intersectionRangeWithTableParts && intersectionRangeWithTableParts.length )
{
var tablePart; var tablePart;
for ( var i = 0; i < intersectionRangeWithTableParts.length; i++ ) { for ( var i = 0; i < intersectionRangeWithTableParts.length; i++ )
{
tablePart = intersectionRangeWithTableParts[i]; tablePart = intersectionRangeWithTableParts[i];
this.model.getRange3( tablePart.Ref.r1, tablePart.Ref.c1, tablePart.Ref.r2, tablePart.Ref.c2 ).unmerge(); this.model.getRange3( tablePart.Ref.r1, tablePart.Ref.c1, tablePart.Ref.r2, tablePart.Ref.c2 ).unmerge();
} }
} }
if ( bIsUpdate ) { if ( bIsUpdate )
if ( callTrigger ) { {
if ( callTrigger )
{
t.handlers.trigger( "slowOperation", false ); t.handlers.trigger( "slowOperation", false );
} }
t.isChanged = true; t.isChanged = true;
...@@ -9362,7 +9356,8 @@ ...@@ -9362,7 +9356,8 @@
} }
var oSelection = History.GetSelection(); var oSelection = History.GetSelection();
if ( null != oSelection ) { if ( null != oSelection )
{
oSelection = oSelection.clone(); oSelection = oSelection.clone();
oSelection.assign( selectionRange.c1, selectionRange.r1, selectionRange.c2, selectionRange.r2 ); oSelection.assign( selectionRange.c1, selectionRange.r1, selectionRange.c2, selectionRange.r2 );
History.SetSelection( oSelection ); History.SetSelection( oSelection );
...@@ -9370,28 +9365,25 @@ ...@@ -9370,28 +9365,25 @@
} }
}; };
WorksheetView.prototype._pasteFromGlobalBuff = function ( isLargeRange, isLocal, val, bIsUpdate, canChangeColWidth ) { WorksheetView.prototype._loadDataBeforePaste = function ( isLargeRange, isLocal, pasteContent, bIsUpdate, canChangeColWidth ) {
var t = this; var t = this;
//загрузка шрифтов, в случае удачи на callback вставляем текст //загрузка шрифтов, в случае удачи на callback вставляем текст
t._loadFonts( val.fontsNew, function () { t._loadFonts( pasteContent.props.fontsNew, function () {
var api = asc["editor"]; var api = asc["editor"];
var isEndTransaction = false; var isEndTransaction = false;
if ( val.addImages && val.addImages.length != 0 && !(window["Asc"]["editor"] && window["Asc"]["editor"].isChartEditor) ) {
if ( val.onlyImages !== true ) { if ( pasteContent.props.addImagesFromWord && pasteContent.props.addImagesFromWord.length != 0 && !(window["Asc"]["editor"] && window["Asc"]["editor"].isChartEditor) )
t._pasteFromLocalBuff( isLargeRange, isLocal, val, bIsUpdate, canChangeColWidth ); {
} var oObjectsForDownload = AscCommon.GetObjectsForImageDownload( pasteContent.props._aPastedImages );
api.wb.clipboard.pasteProcessor._insertImagesFromHTML( t, val );
isEndTransaction = true;
}
else if ( val.addImagesFromWord && val.addImagesFromWord.length != 0 && !(window["Asc"]["editor"] && window["Asc"]["editor"].isChartEditor) ) {
var oObjectsForDownload = AscCommon.GetObjectsForImageDownload( val._aPastedImages );
//if already load images on server //if already load images on server
if ( api.wb.clipboard.pasteProcessor.alreadyLoadImagesOnServer === true ) { if ( api.wb.clipboard.pasteProcessor.alreadyLoadImagesOnServer === true )
{
var oImageMap = {}; var oImageMap = {};
for ( var i = 0, length = oObjectsForDownload.aBuilderImagesByUrl.length; i < length; ++i ) { for ( var i = 0, length = oObjectsForDownload.aBuilderImagesByUrl.length; i < length; ++i )
{
var url = oObjectsForDownload.aUrls[i]; var url = oObjectsForDownload.aUrls[i];
//get name from array already load on server urls //get name from array already load on server urls
...@@ -9413,52 +9405,56 @@ ...@@ -9413,52 +9405,56 @@
} }
} }
if ( val.onlyImages !== true ) { if ( pasteContent.props.onlyImages !== true )
t._pasteFromLocalBuff( isLargeRange, isLocal, val, bIsUpdate, canChangeColWidth ); {
t._pasteData( isLargeRange, isLocal, pasteContent, bIsUpdate, canChangeColWidth );
} }
api.wb.clipboard.pasteProcessor._insertImagesFromBinaryWord( t, val, oImageMap ); api.wb.clipboard.pasteProcessor._insertImagesFromBinaryWord( t, pasteContent, oImageMap );
isEndTransaction = true; isEndTransaction = true;
} }
else { else
{
AscCommon.sendImgUrls( api, oObjectsForDownload.aUrls, function ( data ) { AscCommon.sendImgUrls( api, oObjectsForDownload.aUrls, function ( data ) {
var oImageMap = {}; var oImageMap = {};
AscCommon.ResetNewUrls( data, oObjectsForDownload.aUrls, oObjectsForDownload.aBuilderImagesByUrl, oImageMap ); AscCommon.ResetNewUrls( data, oObjectsForDownload.aUrls, oObjectsForDownload.aBuilderImagesByUrl, oImageMap );
if ( val.onlyImages !== true ) { if ( pasteContent.props.onlyImages !== true ) {
t._pasteFromLocalBuff( isLargeRange, isLocal, val, bIsUpdate, canChangeColWidth ); t._pasteData( isLargeRange, isLocal, pasteContent, bIsUpdate, canChangeColWidth );
} }
api.wb.clipboard.pasteProcessor._insertImagesFromBinaryWord( t, val, oImageMap ); api.wb.clipboard.pasteProcessor._insertImagesFromBinaryWord( t, pasteContent, oImageMap );
//закрываем транзакцию, поскольку в setSelectionInfo она не закроется //закрываем транзакцию, поскольку в setSelectionInfo она не закроется
History.EndTransaction(); History.EndTransaction();
}, true ); }, true );
} }
} }
else if ( val.onlyImages !== true ) { else if ( pasteContent.props.onlyImages !== true )
t._pasteFromLocalBuff( isLargeRange, isLocal, val, bIsUpdate, canChangeColWidth ); {
t._pasteData( isLargeRange, isLocal, pasteContent, bIsUpdate, canChangeColWidth );
isEndTransaction = true; isEndTransaction = true;
} }
//закрываем транзакцию, поскольку в setSelectionInfo она не закроется //закрываем транзакцию, поскольку в setSelectionInfo она не закроется
if ( isEndTransaction ) { if ( isEndTransaction )
{
History.EndTransaction(); History.EndTransaction();
} }
} ); } );
}; };
WorksheetView.prototype._setInfoAfterPaste = function ( values, isCheckSelection ) { WorksheetView.prototype._pasteFromHTML = function ( pasteContent, isCheckSelection ) {
var t = this; var t = this;
var wb = window["Asc"]["editor"].wb; var wb = window["Asc"]["editor"].wb;
var arn = wb && wb.clipboard && wb.clipboard.pasteProcessor && wb.clipboard.pasteProcessor.activeRange ? wb.clipboard.pasteProcessor.activeRange : t.activeRange.clone( true ); var arn = wb && wb.clipboard && wb.clipboard.pasteProcessor && wb.clipboard.pasteProcessor.activeRange ? wb.clipboard.pasteProcessor.activeRange : t.activeRange.clone( true );
var arrFormula = []; var arrFormula = [];
var numFor = 0; var numFor = 0;
var rMax = values.length + values.rowSpanSpCount; var rMax = pasteContent.content.length + pasteContent.props.rowSpanSpCount;
if ( values.rowCount && values.rowCount !== 0 && values.isOneTable ) { if ( pasteContent.props.rowCount && pasteContent.props.rowCount !== 0 && pasteContent.props.isOneTable )
rMax = values.rowCount + arn.r1; {
rMax = pasteContent.props.rowCount + arn.r1;
} }
var cMax = values.cellCount + arn.c1; var cMax = pasteContent.props.cellCount + arn.c1;
var isMultiple = false; var isMultiple = false;
var firstCell = t.model.getRange3( arn.r1, arn.c1, arn.r1, arn.c1 ); var firstCell = t.model.getRange3( arn.r1, arn.c1, arn.r1, arn.c1 );
...@@ -9468,47 +9464,60 @@ ...@@ -9468,47 +9464,60 @@
//если вставляем в мерженную ячейку, диапазон которой больше или равен //если вставляем в мерженную ячейку, диапазон которой больше или равен
if ( arn.c2 >= cMax - 1 && arn.r2 >= rMax - 1 && isMergedFirstCell && isMergedFirstCell.c1 === arn.c1 && isMergedFirstCell.c2 === arn.c2 && isMergedFirstCell.r1 === arn.r1 && isMergedFirstCell.r2 === arn.r2 && cMax - arn.c1 === values[arn.r1][arn.c1][0].colSpan && rMax - arn.r1 === values[arn.r1][arn.c1][0].rowSpan ) { if ( arn.c2 >= cMax - 1 && arn.r2 >= rMax - 1 && isMergedFirstCell && isMergedFirstCell.c1 === arn.c1 && isMergedFirstCell.c2 === arn.c2 && isMergedFirstCell.r1 === arn.r1 && isMergedFirstCell.r2 === arn.r2 && cMax - arn.c1 === pasteContent.content[arn.r1][arn.c1].colSpan && rMax - arn.r1 === pasteContent.content[arn.r1][arn.c1].rowSpan )
if ( !isCheckSelection ) { {
values[arn.r1][arn.c1][0].colSpan = isMergedFirstCell.c2 - isMergedFirstCell.c1 + 1; if ( !isCheckSelection )
values[arn.r1][arn.c1][0].rowSpan = isMergedFirstCell.r2 - isMergedFirstCell.r1 + 1; {
pasteContent.content[arn.r1][arn.c1].colSpan = isMergedFirstCell.c2 - isMergedFirstCell.c1 + 1;
pasteContent.content[arn.r1][arn.c1].rowSpan = isMergedFirstCell.r2 - isMergedFirstCell.r1 + 1;
} }
isOneMerge = true; isOneMerge = true;
} }
else if ( arn.c2 >= cMax - 1 && arn.r2 >= rMax - 1 && values.isOneTable ) { else if ( arn.c2 >= cMax - 1 && arn.r2 >= rMax - 1 && pasteContent.props.isOneTable )
{
//если область кратная куску вставки //если область кратная куску вставки
var widthArea = arn.c2 - arn.c1 + 1; var widthArea = arn.c2 - arn.c1 + 1;
var heightArea = arn.r2 - arn.r1 + 1; var heightArea = arn.r2 - arn.r1 + 1;
var widthPasteFr = cMax - arn.c1; var widthPasteFr = cMax - arn.c1;
var heightPasteFr = rMax - arn.r1; var heightPasteFr = rMax - arn.r1;
//если кратны, то обрабатываем //если кратны, то обрабатываем
if ( widthArea % widthPasteFr === 0 && heightArea % heightPasteFr === 0 ) { if ( widthArea % widthPasteFr === 0 && heightArea % heightPasteFr === 0 )
{
isMultiple = true; isMultiple = true;
} }
else if ( firstCell.hasMerged() !== null )//в противном случае ошибка else if ( firstCell.hasMerged() !== null )//в противном случае ошибка
{ {
if ( isCheckSelection ) { if ( isCheckSelection )
{
return arn; return arn;
} }
else { else
{
this.handlers.trigger( "onError", c_oAscError.ID.PastInMergeAreaError, c_oAscError.Level.NoCritical ); this.handlers.trigger( "onError", c_oAscError.ID.PastInMergeAreaError, c_oAscError.Level.NoCritical );
return; return;
} }
} }
} }
else { else
{
//проверка на наличие части объединённой ячейки в области куда осуществляем вставку //проверка на наличие части объединённой ячейки в области куда осуществляем вставку
for ( var rFirst = arn.r1; rFirst < rMax; ++rFirst ) { for ( var rFirst = arn.r1; rFirst < rMax; ++rFirst )
for ( var cFirst = arn.c1; cFirst < cMax; ++cFirst ) { {
for ( var cFirst = arn.c1; cFirst < cMax; ++cFirst )
{
range = t.model.getRange3( rFirst, cFirst, rFirst, cFirst ); range = t.model.getRange3( rFirst, cFirst, rFirst, cFirst );
var merged = range.hasMerged(); var merged = range.hasMerged();
if ( merged ) { if ( merged )
if ( merged.r1 < arn.r1 || merged.r2 > rMax - 1 || merged.c1 < arn.c1 || merged.c2 > cMax - 1 ) { {
if ( merged.r1 < arn.r1 || merged.r2 > rMax - 1 || merged.c1 < arn.c1 || merged.c2 > cMax - 1 )
{
//ошибка в случае если вставка происходит в часть объедененной ячейки //ошибка в случае если вставка происходит в часть объедененной ячейки
if ( isCheckSelection ) { if ( isCheckSelection )
{
return arn; return arn;
} }
else { else
{
this.handlers.trigger( "onErrorEvent", c_oAscError.ID.PastInMergeAreaError, c_oAscError.Level.NoCritical ); this.handlers.trigger( "onErrorEvent", c_oAscError.ID.PastInMergeAreaError, c_oAscError.Level.NoCritical );
return; return;
} }
...@@ -9517,29 +9526,33 @@ ...@@ -9517,29 +9526,33 @@
} }
} }
} }
var rMax2 = rMax; var rMax2 = rMax;
var cMax2 = cMax; var cMax2 = cMax;
var rMax = values.length; var rMax = pasteContent.content.length;
var trueArn = t.activeRange; var trueArn = t.activeRange;
if ( isCheckSelection ) { if ( isCheckSelection )
{
var newArr = arn.clone( true ); var newArr = arn.clone( true );
newArr.r2 = rMax2 - 1; newArr.r2 = rMax2 - 1;
newArr.c2 = cMax2 - 1; newArr.c2 = cMax2 - 1;
if ( isMultiple || isOneMerge ) { if ( isMultiple || isOneMerge )
{
newArr.r2 = trueArn.r2; newArr.r2 = trueArn.r2;
newArr.c2 = trueArn.c2; newArr.c2 = trueArn.c2;
} }
return newArr; return newArr;
} }
//если не возникает конфликт, делаем unmerge //если не возникает конфликт, делаем unmerge
rangeUnMerge.unmerge(); rangeUnMerge.unmerge();
if ( !isOneMerge ) {
if ( !isOneMerge )
{
arn.r2 = (rMax2 - 1 > 0) ? (rMax2 - 1) : 0; arn.r2 = (rMax2 - 1 > 0) ? (rMax2 - 1) : 0;
arn.c2 = (cMax2 - 1 > 0) ? (cMax2 - 1) : 0; arn.c2 = (cMax2 - 1 > 0) ? (cMax2 - 1) : 0;
} }
var mergeArr = [];
var n = 0; var n = 0;
if ( isMultiple )//случай автозаполнения сложных форм if ( isMultiple )//случай автозаполнения сложных форм
{ {
...@@ -9549,39 +9562,51 @@ ...@@ -9549,39 +9562,51 @@
var plRow = (rMax2 - arn.r1); var plRow = (rMax2 - arn.r1);
var plCol = (arn.c2 - arn.c1) + 1; var plCol = (arn.c2 - arn.c1) + 1;
} }
else { else
{
var maxARow = 1; var maxARow = 1;
var maxACol = 1; var maxACol = 1;
var plRow = 0; var plRow = 0;
var plCol = 0; var plCol = 0;
} }
if ( isMultiple ) {
if ( values[arn.r1] && values[arn.r1][arn.c1] ) { if ( isMultiple )
var currentObj = values[arn.r1][arn.c1][0]; {
if ( pasteContent.content[arn.r1] && pasteContent.content[arn.r1][arn.c1] )
{
var currentObj = pasteContent.content[arn.r1][arn.c1].content[0];
var valFormat = ''; var valFormat = '';
if ( currentObj[0] !== undefined ) { if ( currentObj[0] !== undefined )
{
valFormat = currentObj[0].text; valFormat = currentObj[0].text;
} }
} }
} }
for ( var autoR = 0; autoR < maxARow; ++autoR ) {
for ( var autoC = 0; autoC < maxACol; ++autoC ) { var mergeArr = [];
for ( var r = arn.r1; r < rMax; ++r ) { for ( var autoR = 0; autoR < maxARow; ++autoR )
for ( var c = arn.c1; c < values[r].length; ++c ) { {
if ( undefined !== values[r][c] ) { for ( var autoC = 0; autoC < maxACol; ++autoC )
{
for ( var r = arn.r1; r < rMax; ++r )
{
for ( var c = arn.c1; c < pasteContent.content[r].length; ++c )
{
if ( undefined !== pasteContent.content[r][c] ) {
var range = t.model.getRange3( r + autoR * plRow, c + autoC * plCol, r + autoR * plRow, c + autoC * plCol ); var range = t.model.getRange3( r + autoR * plRow, c + autoC * plCol, r + autoR * plRow, c + autoC * plCol );
var currentObj = values[r][c][0]; var currentObj = pasteContent.content[r][c].content;
if ( currentObj.length === 1 ) { if ( currentObj.length === 1 )
//if(!isMultiple) {
//{
var valFormat = currentObj[0].text; var valFormat = currentObj[0].text;
var nameFormat = false; var nameFormat = false;
//}
if ( currentObj[0].cellFrom ) { if ( currentObj[0].cellFrom )
{
var offset = range.getCells()[0].getOffset2( currentObj[0].cellFrom ), assemb, _p_ = new AscCommonExcel.parserFormula( currentObj[0].text.substring( 1 ), "", range.worksheet ); var offset = range.getCells()[0].getOffset2( currentObj[0].cellFrom ), assemb, _p_ = new AscCommonExcel.parserFormula( currentObj[0].text.substring( 1 ), "", range.worksheet );
if ( _p_.parse() ) { if ( _p_.parse() )
{
assemb = _p_.changeOffset( offset ).assemble(); assemb = _p_.changeOffset( offset ).assemble();
//range.setValue("="+assemb); //range.setValue("="+assemb);
arrFormula[numFor] = {}; arrFormula[numFor] = {};
...@@ -9590,16 +9615,20 @@ ...@@ -9590,16 +9615,20 @@
numFor++; numFor++;
} }
} }
else { else
{
range.setValue( valFormat ); range.setValue( valFormat );
} }
if ( nameFormat ) {
if ( nameFormat )
{
range.setNumFormat( nameFormat ); range.setNumFormat( nameFormat );
} }
range.setBold( currentObj[0].format.b ); range.setBold( currentObj[0].format.b );
range.setItalic( currentObj[0].format.i ); range.setItalic( currentObj[0].format.i );
range.setStrikeout( currentObj[0].format.s ); range.setStrikeout( currentObj[0].format.s );
if ( !isOneMerge && currentObj[0].format && currentObj[0].format.c != null && currentObj[0].format.c != undefined ) { if ( !isOneMerge && currentObj[0].format && currentObj[0].format.c != null && currentObj[0].format.c != undefined )
{
range.setFontcolor( currentObj[0].format.c ); range.setFontcolor( currentObj[0].format.c );
} }
range.setUnderline( currentObj[0].format.u ); range.setUnderline( currentObj[0].format.u );
...@@ -9607,54 +9636,68 @@ ...@@ -9607,54 +9636,68 @@
range.setFontname( currentObj[0].format.fn ); range.setFontname( currentObj[0].format.fn );
range.setFontsize( currentObj[0].format.fs ); range.setFontsize( currentObj[0].format.fs );
} }
else { else
{
range.setValue2( currentObj ); range.setValue2( currentObj );
range.setAlignVertical( currentObj.va ); range.setAlignVertical( currentObj.va );
} }
if ( currentObj.length === 1 && currentObj[0].format.fs !== '' && currentObj[0].format.fs !== null && currentObj[0].format.fs !== undefined ) { if ( currentObj.length === 1 && currentObj[0].format.fs !== '' && currentObj[0].format.fs !== null && currentObj[0].format.fs !== undefined )
{
range.setFontsize( currentObj[0].format.fs ); range.setFontsize( currentObj[0].format.fs );
} }
if ( !isOneMerge ) { if ( !isOneMerge )
{
range.setAlignHorizontal( currentObj.a ); range.setAlignHorizontal( currentObj.a );
} }
var isMerged = false; var isMerged = false;
for ( var mergeCheck = 0; mergeCheck < mergeArr.length; ++mergeCheck ) { for ( var mergeCheck = 0; mergeCheck < mergeArr.length; ++mergeCheck )
if ( r + 1 + autoR * plRow <= mergeArr[mergeCheck].r2 && r + 1 + autoR * plRow >= mergeArr[mergeCheck].r1 && c + autoC * plCol + 1 <= mergeArr[mergeCheck].c2 && c + 1 + autoC * plCol >= mergeArr[mergeCheck].c1 ) { {
if ( r + 1 + autoR * plRow <= mergeArr[mergeCheck].r2 && r + 1 + autoR * plRow >= mergeArr[mergeCheck].r1 && c + autoC * plCol + 1 <= mergeArr[mergeCheck].c2 && c + 1 + autoC * plCol >= mergeArr[mergeCheck].c1 )
{
isMerged = true; isMerged = true;
} }
} }
//обработка для мерженных ячеек //обработка для мерженных ячеек
if ( (currentObj.colSpan > 1 || currentObj.rowSpan > 1) && !isMerged ) { if ( (currentObj.colSpan > 1 || currentObj.rowSpan > 1) && !isMerged )
{
range.setOffsetLast( {offsetCol: currentObj.colSpan - 1, offsetRow: currentObj.rowSpan - 1} ); range.setOffsetLast( {offsetCol: currentObj.colSpan - 1, offsetRow: currentObj.rowSpan - 1} );
mergeArr[n] = { mergeArr[n] = {
r1: range.first.row, r2: range.last.row, c1: range.first.col, c2: range.last.col r1: range.first.row, r2: range.last.row, c1: range.first.col, c2: range.last.col
}; };
n++; n++;
if ( currentObj[0] == undefined ) { if ( currentObj[0] == undefined )
{
range.setValue( '' ); range.setValue( '' );
} }
range.merge( c_oAscMergeOptions.Merge ); range.merge( c_oAscMergeOptions.Merge );
} }
if ( !isOneMerge ) {
if ( !isOneMerge )
{
range.setBorderSrc( currentObj.borders ); range.setBorderSrc( currentObj.borders );
} }
range.setWrap( currentObj.wrap ); range.setWrap( currentObj.wrap );
if ( currentObj.bc && currentObj.bc.rgb ) { if ( currentObj.bc && currentObj.bc.rgb )
{
range.setFill( currentObj.bc ); range.setFill( currentObj.bc );
} }
var link = values[r][c][0].hyperLink;
if ( link ) { var link = pasteContent.content[r][c].hyperLink;
if ( link )
{
var newHyperlink = new AscCommonExcel.Hyperlink(); var newHyperlink = new AscCommonExcel.Hyperlink();
if ( values[r][c][0].hyperLink.search( '#' ) === 0 ) { if ( pasteContent.content[r][c].hyperLink.search( '#' ) === 0 )
{
newHyperlink.setLocation( link.replace( '#', '' ) ); newHyperlink.setLocation( link.replace( '#', '' ) );
} }
else { else
{
newHyperlink.Hyperlink = link; newHyperlink.Hyperlink = link;
} }
newHyperlink.Ref = range; newHyperlink.Ref = range;
newHyperlink.Tooltip = values[r][c][0].toolTip; newHyperlink.Tooltip = pasteContent.content[r][c].toolTip;
range.setHyperlink( newHyperlink ); range.setHyperlink( newHyperlink );
} }
} }
...@@ -9662,7 +9705,9 @@ ...@@ -9662,7 +9705,9 @@
} }
} }
} }
if ( isMultiple ) {
if ( isMultiple )
{
arn.r2 = trueArn.r2; arn.r2 = trueArn.r2;
arn.c2 = trueArn.c2; arn.c2 = trueArn.c2;
} }
......
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