Commit 3127f59b authored by Sergey Luzyanin's avatar Sergey Luzyanin

inserting ole objects in presentation

parent b37073dd
......@@ -386,7 +386,8 @@
if (pluginData.getAttribute("recalculate") == true)
{
var editorId = window.g_asc_plugins.api.getEditorId();
if (AscCommon.c_oEditorId.Word === editorId)
if (AscCommon.c_oEditorId.Word === editorId ||
AscCommon.c_oEditorId.Presentation === editorId)
{
var oLogicDocument = window.g_asc_plugins.api.WordControl ?
window.g_asc_plugins.api.WordControl.m_oLogicDocument : null;
......
......@@ -1507,6 +1507,28 @@ CPresentation.prototype =
}
},
Add_OleObject: function(fWidth, fHeight, nWidthPix, nHeightPix, sLocalUrl, sData, sApplicationId){
if(this.Slides[this.CurPage]){
var fPosX = (this.Width - fWidth)/2;
var fPosY = (this.Height - fHeight)/2;
var Image = this.Slides[this.CurPage].graphicObjects.createOleObject(sData, sApplicationId, sLocalUrl, fPosX, fPosY, fWidth, fHeight, nWidthPix, nHeightPix);
Image.setParent(this.Slides[this.CurPage]);
Image.addToDrawingObjects();
this.Slides[this.CurPage].graphicObjects.resetSelection();
this.Slides[this.CurPage].graphicObjects.selectObject(Image, 0);
this.Recalculate();
this.Document_UpdateInterfaceState();
}
},
Edit_OleObject: function(oOleObject, sData, sImageUrl, nPixWidth, nPixHeight){
oOleObject.setData(sData);
var _blipFill = new AscFormat.CBlipFill();
_blipFill.RasterImageId = sImageUrl;
oOleObject.setBlipFill(_blipFill);
oOleObject.setPixSizes(nPixWidth, nPixHeight);
},
addChart: function(binary)
{
var _this = this;
......@@ -3332,6 +3354,23 @@ CPresentation.prototype =
},
Get_AllImageUrls: function(aImages){
if(!Array.isArray(aImages)){
aImages = [];
}
for(var i = 0; i < this.Slides.length; ++i){
this.Slides[i].getAllRasterImages(aImages);
}
return aImages;
},
Reassign_ImageUrls : function (images_rename) {
for(var i = 0; i < this.Slides.length; ++i){
this.Slides[i].Reassign_ImageUrls(images_rename);
}
},
Get_GraphicObjectsProps : function()
{
if(this.Slides[this.CurPage])
......
......@@ -117,6 +117,12 @@ Slide.prototype =
return editor.WordControl.m_oLogicDocument.DrawingDocument;
},
Reassign_ImageUrls: function(images_rename){
for(var i = 0; i < this.cSld.spTree.length; ++i){
this.cSld.spTree[i].Reassign_ImageUrls(images_rename);
}
},
createDuplicate: function()
{
var copy = new Slide(this.presentation, this.Layout, 0), i;
......@@ -942,7 +948,7 @@ Slide.prototype =
return oRet;
},
getAllImages: function(images)
Get_AllImageUrls: function(images)
{
if(this.cSld.Bg && this.cSld.Bg.bgPr && this.cSld.Bg.bgPr.Fill && this.cSld.Bg.bgPr.Fill.fill instanceof AscFormat.CBlipFill && typeof this.cSld.Bg.bgPr.Fill.fill.RasterImageId === "string" )
{
......@@ -957,6 +963,20 @@ Slide.prototype =
}
},
getAllRasterImages: function(images){
if(this.cSld.Bg && this.cSld.Bg.bgPr && this.cSld.Bg.bgPr.Fill && this.cSld.Bg.bgPr.Fill.fill instanceof AscFormat.CBlipFill && typeof this.cSld.Bg.bgPr.Fill.fill.RasterImageId === "string" )
{
images.push(AscCommon.getFullImageSrc2(this.cSld.Bg.bgPr.Fill.fill.RasterImageId));
}
for(var i = 0; i < this.cSld.spTree.length; ++i)
{
if(typeof this.cSld.spTree[i].getAllRasterImages === "function")
{
this.cSld.spTree[i].getAllRasterImages(images);
}
}
},
changeSize: function(width, height)
{
var kw = width/this.Width, kh = height/this.Height;
......
......@@ -3661,6 +3661,37 @@ background-repeat: no-repeat;\
}
};
asc_docs_api.prototype.asc_addOleObjectAction = function(sLocalUrl, sData, sApplicationId, fWidth, fHeight, nWidthPix, nHeightPix)
{
var _image = this.ImageLoader.LoadImage(AscCommon.getFullImageSrc2(sLocalUrl), 1);
if (null != _image)//картинка уже должна быть загружена
{
if (false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Drawing_Props))
{
this.WordControl.m_oLogicDocument.Create_NewHistoryPoint(AscDFH.historydescription_Document_AddOleObject);
this.WordControl.m_oLogicDocument.Add_OleObject(fWidth, fHeight, nWidthPix, nHeightPix, sLocalUrl, sData, sApplicationId);
}
}
};
asc_docs_api.prototype.asc_editOleObjectAction = function(bResize, oOleObject, sImageUrl, sData, nPixWidth, nPixHeight)
{
if (oOleObject)
{
if (!bResize)
{
this.WordControl.m_oLogicDocument.Create_NewHistoryPoint(AscDFH.historydescription_Document_EditOleObject);
this.WordControl.m_oLogicDocument.Edit_OleObject(oOleObject, sData, sImageUrl, nPixWidth, nPixHeight);
this.WordControl.m_oLogicDocument.Recalculate();
}
else
{
this.WordControl.m_oLogicDocument.Edit_OleObject(oOleObject, sData, sImageUrl, nPixWidth, nPixHeight);
this.WordControl.m_oLogicDocument.Recalculate();
}
}
};
asc_docs_api.prototype.AddTextArt = function(nStyle)
{
if (editor.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(changestype_Drawing_Props) === false)
......@@ -6042,6 +6073,26 @@ background-repeat: no-repeat;\
};
asc_docs_api.prototype.asc_Recalculate = function(bIsUpdateInterface)
{
if (!this.WordControl.m_oLogicDocument)
return;
this.WordControl.m_oLogicDocument.Recalculate({Drawings : {All : true, Map : {}}});
this.WordControl.m_oLogicDocument.DrawingDocument.OnEndRecalculate();
};
asc_docs_api.prototype.asc_canPaste = function()
{
if (!this.WordControl ||
!this.WordControl.m_oLogicDocument ||
this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Drawing_Props))
return false;
this.WordControl.m_oLogicDocument.Create_NewHistoryPoint(AscDFH.historydescription_Document_AddSectionBreak);
return true;
};
// input
asc_docs_api.prototype.Begin_CompositeInput = function()
{
......
......@@ -728,6 +728,16 @@
}
};
/**
* Create new history point.
*/
ApiPresentation.prototype.CreateNewHistoryPoint = function()
{
this.Presentation.Create_NewHistoryPoint(AscDFH.historydescription_Document_ApiBuilder);
};
/**
//------------------------------------------------------------------------------------------------------------------
//
......@@ -783,6 +793,27 @@
this.Slide.changeBackground(bg);
}
};
/**
* Getting slide width
* */
ApiSlide.prototype.GetWidth = function(){
if(this.Slide){
return this.Slide.Width*36000;
}
return 0;
};
/**
* Getting slide height
* */
ApiSlide.prototype.GetHeight = function(){
if(this.Slide){
return this.Slide.Height*36000;
}
return 0;
};
//------------------------------------------------------------------------------------------------------------------
//
// ApiDrawingContent
......@@ -1605,11 +1636,14 @@
ApiPresentation.prototype["GetSlideByIndex"] = ApiPresentation.prototype.GetSlideByIndex;
ApiPresentation.prototype["GetCurrentSlide"] = ApiPresentation.prototype.GetCurrentSlide;
ApiPresentation.prototype["AddSlide"] = ApiPresentation.prototype.AddSlide;
ApiPresentation.prototype["CreateNewHistoryPoint"] = ApiPresentation.prototype.CreateNewHistoryPoint;
ApiSlide.prototype["GetClassType"] = ApiSlide.prototype.GetClassType;
ApiSlide.prototype["RemoveAllObjects"] = ApiSlide.prototype.RemoveAllObjects;
ApiSlide.prototype["AddObject"] = ApiSlide.prototype.AddObject;
ApiSlide.prototype["SetBackground"] = ApiSlide.prototype.SetBackground;
ApiSlide.prototype["GetWidth"] = ApiSlide.prototype.GetWidth;
ApiSlide.prototype["GetHeight"] = ApiSlide.prototype.GetHeight;
ApiDrawingContent.prototype["GetClassType"] = ApiDrawingContent.prototype.GetClassType;
ApiDrawingContent.prototype["GetElementsCount"] = ApiDrawingContent.prototype.GetElementsCount;
......
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