Commit 548c98e5 authored by alexey.musinov's avatar alexey.musinov

Merge branch 'develop' of https://github.com/ONLYOFFICE/sdkjs into develop

parents bc00f866 2874c966
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
var c_oAscMaxCellOrCommentLength = AscCommon.c_oAscMaxCellOrCommentLength; var c_oAscMaxCellOrCommentLength = AscCommon.c_oAscMaxCellOrCommentLength;
var doc = window.document; var doc = window.document;
var copyPasteUseBinary = true; var copyPasteUseBinary = true;
var CopyPasteCorrectString = AscCommon.CopyPasteCorrectString; var CopyPasteCorrectString = AscCommon.CopyPasteCorrectString;
function number2color(n) { function number2color(n) {
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
/** @constructor */ /** @constructor */
function Clipboard() function Clipboard()
{ {
this.copyProcessor = new CopyProcessorExcel(); this.copyProcessor = new CopyProcessorExcel();
this.pasteProcessor = new PasteProcessorExcel(); this.pasteProcessor = new PasteProcessorExcel();
...@@ -837,47 +837,15 @@ ...@@ -837,47 +837,15 @@
_pasteFromBinaryWord: function(worksheet, base64, isIntoShape) _pasteFromBinaryWord: function(worksheet, base64, isIntoShape)
{ {
var pasteData = this.ReadFromBinaryWord(base64, worksheet); var pasteData = this.ReadFromBinaryWord(base64, worksheet);
var oPasteFromBinaryWord = new pasteFromBinaryWord(this, worksheet);
//insert binary from word into SHAPE //insert binary from word into SHAPE
if(isIntoShape) if(isIntoShape)
{ {
var insertContent = new CSelectedContent(); this._insertBinaryIntoShapeContent(worksheet, pasteData.content, true);
var target_doc_content = isIntoShape;
var elements = [], selectedElement, element, drawings = [], pDrawings = [], drawingCopyObject;
for(var i = 0; i < pasteData.content.length; ++i)
{
selectedElement = new CSelectedElement();
element = pasteData.content[i];
if(type_Paragraph == element.GetType())//paragraph
{
selectedElement.Element = AscFormat.ConvertParagraphToPPTX(element);
elements.push(selectedElement);
}
else if(type_Table == element.GetType())//table
{
//TODO вырезать из таблицы параграфы
}
}
insertContent.Elements = elements;
var paragraph = target_doc_content.Content[target_doc_content.CurPos.ContentPos];
if (null != paragraph && type_Paragraph == paragraph.GetType())
{
var NearPos = {Paragraph: paragraph, ContentPos: paragraph.Get_ParaContentPos(false, false)};
paragraph.Check_NearestPos(NearPos);
target_doc_content.Insert_Content(insertContent, NearPos);
var oTargetTextObject = AscFormat.getTargetTextObject(worksheet.objectRender.controller);
oTargetTextObject && oTargetTextObject.checkExtentsByDocContent && oTargetTextObject.checkExtentsByDocContent();
worksheet.objectRender.controller.startRecalculate();
}
} }
else else
{ {
var oPasteFromBinaryWord = new pasteFromBinaryWord(this, worksheet);
oPasteFromBinaryWord._paste(worksheet, pasteData); oPasteFromBinaryWord._paste(worksheet, pasteData);
} }
...@@ -902,48 +870,16 @@ ...@@ -902,48 +870,16 @@
{ {
case "Content": case "Content":
{ {
var docContent = this.ReadPresentationText(stream, worksheet, isIntoShape);
if(isIntoShape) if(isIntoShape)
{ {
var pasteData = this.ReadPresentationText(stream, worksheet); this._insertBinaryIntoShapeContent(worksheet, docContent)
var insertContent = new CSelectedContent();
var target_doc_content = isIntoShape;
var elements = [], selectedElement, element;
for(var i = 0; i < pasteData.length; ++i)
{
selectedElement = new CSelectedElement();
element = pasteData[i];
if(type_Paragraph == element.GetType())//paragraph
{
selectedElement.Element = element;
elements.push(selectedElement);
}
else if(type_Table == element.GetType())//table
{
//TODO вырезать из таблицы параграфы
}
}
insertContent.Elements = elements;
var paragraph = target_doc_content.Content[target_doc_content.CurPos.ContentPos];
if (null != paragraph && type_Paragraph == paragraph.GetType())
{
var NearPos = {Paragraph: paragraph, ContentPos: paragraph.Get_ParaContentPos(false, false)};
paragraph.Check_NearestPos(NearPos);
target_doc_content.Insert_Content(insertContent, NearPos);
var oTargetTextObject = AscFormat.getTargetTextObject(worksheet.objectRender.controller);
oTargetTextObject && oTargetTextObject.checkExtentsByDocContent && oTargetTextObject.checkExtentsByDocContent();
worksheet.objectRender.controller.startRecalculate();
}
return true; return true;
} }
else else
{ {
var docContent = this.ReadPresentationText(stream, worksheet);
var oPasteFromBinaryWord = new pasteFromBinaryWord(this, worksheet); var oPasteFromBinaryWord = new pasteFromBinaryWord(this, worksheet);
var oTempDrawingDocument = worksheet.model.DrawingDocument; var oTempDrawingDocument = worksheet.model.DrawingDocument;
...@@ -1012,6 +948,72 @@ ...@@ -1012,6 +948,72 @@
return false; return false;
}, },
_insertBinaryIntoShapeContent: function(worksheet, content, isConvertToPPTX)
{
History.Create_NewPoint();
History.StartTransaction();
//ещё раз вызваем getTargetDocContent с флагом true после создания точки в истории(getTargetDocContent добавляет данные в историю)
var isIntoShape = worksheet.objectRender.controller.getTargetDocContent(true);
var insertContent = new CSelectedContent();
var target_doc_content = isIntoShape;
insertContent.Elements = this._convertBeforeInsertIntoShapeContent(worksheet, content, isConvertToPPTX, target_doc_content);
this._insertSelectedContentIntoShapeContent(worksheet, insertContent, target_doc_content);
History.EndTransaction();
},
_convertBeforeInsertIntoShapeContent: function(worksheet, content, isConvertToPPTX, target_doc_content)
{
var elements = [], selectedElement, element;
for(var i = 0; i < content.length; i++)
{
selectedElement = new CSelectedElement();
element = content[i];
if(type_Paragraph == element.GetType())//paragraph
{
if(isConvertToPPTX)
{
selectedElement.Element = AscFormat.ConvertParagraphToPPTX(element, worksheet.model.DrawingDocument, target_doc_content);
}
else
{
selectedElement.Element = element;
}
elements.push(selectedElement);
}
else if(type_Table == element.GetType())//table
{
//TODO вырезать из таблицы параграфы
}
}
return elements;
},
_insertSelectedContentIntoShapeContent: function(worksheet, selectedContent, target_doc_content)
{
var paragraph = target_doc_content.Content[target_doc_content.CurPos.ContentPos];
if (null != paragraph && type_Paragraph == paragraph.GetType() && selectedContent.Elements && selectedContent.Elements.length)
{
var NearPos = {Paragraph: paragraph, ContentPos: paragraph.Get_ParaContentPos(false, false)};
paragraph.Check_NearestPos(NearPos);
target_doc_content.Insert_Content(selectedContent, NearPos);
worksheet.objectRender.controller.cursorMoveRight(false, false)
var oTargetTextObject = AscFormat.getTargetTextObject(worksheet.objectRender.controller);
oTargetTextObject && oTargetTextObject.checkExtentsByDocContent && oTargetTextObject.checkExtentsByDocContent();
worksheet.objectRender.controller.startRecalculate();
}
},
_insertImagesFromBinary: function(ws, data, isIntoShape) _insertImagesFromBinary: function(ws, data, isIntoShape)
{ {
var activeRange = ws.activeRange; var activeRange = ws.activeRange;
...@@ -1705,7 +1707,7 @@ ...@@ -1705,7 +1707,7 @@
return {arrShapes: arr_shapes, arrImages: loader.End_UseFullUrl(), arrTransforms: arr_transforms}; return {arrShapes: arr_shapes, arrImages: loader.End_UseFullUrl(), arrTransforms: arr_transforms};
}, },
ReadPresentationText: function(stream, worksheet) ReadPresentationText: function(stream, worksheet, cDocumentContent)
{ {
History.TurnOff(); History.TurnOff();
...@@ -1722,7 +1724,7 @@ ...@@ -1722,7 +1724,7 @@
for(var i = 0; i < count; ++i) for(var i = 0; i < count; ++i)
{ {
loader.stream.Skip2(1); // must be 0 loader.stream.Skip2(1); // must be 0
paragraph = loader.ReadParagraph(worksheet.model); paragraph = loader.ReadParagraph(cDocumentContent);
elements.push(paragraph); elements.push(paragraph);
} }
......
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