Commit 73ef635b authored by Sergey Luzyanin's avatar Sergey Luzyanin

Editing OleObjects

parent ba7d9f51
......@@ -323,7 +323,7 @@ function (window, undefined) {
case AscDFH.historydescription_Document_ApplyPrToMath : sString = "Document_ApplyPrToMath "; break;
case AscDFH.historydescription_Document_SetMathProps : sString = "Document_SetMathProps "; break;
case AscDFH.historydescription_Document_SetSectionProps : sString = "Document_SetColumnsProps "; break;
case AscDFH.historydescription_Document_ApiBuilder : sString = "Document_ApiBuilder "; break
case AscDFH.historydescription_Document_ApiBuilder : sString = "Document_ApiBuilder "; break;
}
return sString;
}
......@@ -891,6 +891,7 @@ window['AscDFH'].historyitem_ImageShapeSetGroup = 2539;
window['AscDFH'].historyitem_ImageShapeSetStyle = 2540;
window['AscDFH'].historyitem_ImageShapeSetData = 2541;
window['AscDFH'].historyitem_ImageShapeSetApplicationId = 2542;
window['AscDFH'].historyitem_ImageShapeSetPixSizes = 2543;
window['AscDFH'].historyitem_GeometrySetParent = 2540;
window['AscDFH'].historyitem_GeometryAddAdj = 2541;
window['AscDFH'].historyitem_GeometryAddGuide = 2542;
......@@ -2004,5 +2005,6 @@ window['AscDFH'].historydescription_Document_SetMathProps
window['AscDFH'].historydescription_Document_ApplyPrToMath = 0x0135;
window['AscDFH'].historydescription_Document_ApiBuilder = 0x0136;
window['AscDFH'].historydescription_Document_AddOleObject = 0x0137;
window['AscDFH'].historydescription_Document_EditOleObject = 0x0138;
})(window);
......@@ -673,6 +673,12 @@ CImageShape.prototype.Undo = function(data)
this.m_sData = data.oldId;
break;
}
case AscDFH.historyitem_ImageShapeSetPixSizes:
{
this.m_nPixWidth = dara.oldPr.w;
this.m_nPixHeight = dara.oldPr.h;
break;
}
case AscDFH.historyitem_AutoShapes_SetBFromSerialize:
{
this.fromSerialize = data.oldPr;
......@@ -765,6 +771,13 @@ CImageShape.prototype.Redo = function(data)
this.m_sData = data.newId;
break;
}
case AscDFH.historyitem_ImageShapeSetPixSizes:
{
this.m_nPixWidth = dara.newPr.w;
this.m_nPixHeight = dara.newPr.h;
break;
}
case AscDFH.historyitem_AutoShapes_SetBFromSerialize:
{
this.fromSerialize = data.newPr;
......@@ -858,6 +871,12 @@ CImageShape.prototype.Save_Changes = function(data, w)
AscFormat.writeString(w, data.newId);
break;
}
case AscDFH.historyitem_ImageShapeSetPixSizes:
{
AscFormat.writeLong(w, data.newPr.w);
AscFormat.writeLong(w, dara.newPr.h);
break;
}
case AscDFH.historyitem_AutoShapes_SetBFromSerialize:
{
AscFormat.writeBool(w, data.newPr);
......@@ -942,6 +961,12 @@ CImageShape.prototype.Load_Changes = function(r)
this.m_sApplicationId = AscFormat.readString(r);
break;
}
case AscDFH.historyitem_ImageShapeSetPixSizes:
{
this.m_nPixWidth = AscFormat.readLong(r);
this.m_nPixHeight = AscFormat.readLong(r);
break;
}
case AscDFH.historyitem_AutoShapes_SetBFromSerialize:
{
this.fromSerialize = AscFormat.readBool(r);
......
......@@ -11,6 +11,8 @@ function (window, undefined) {
COleObject.superclass.constructor.call(this);
this.m_sData = null;
this.m_sApplicationId = null;
this.m_nPixWidth = null;
this.m_nPixHeight = null;
this.Id = AscCommon.g_oIdCounter.Get_NewId();
AscCommon.g_oTableId.Add( this, this.Id );
}
......@@ -29,6 +31,12 @@ function (window, undefined) {
{
AscCommon.History.Add(this, {Type:AscDFH.historyitem_ImageShapeSetApplicationId, oldId: this.m_sApplicationId, newId: sApplicationId});
this.m_sApplicationId = sApplicationId;
};
COleObject.prototype.setPixSizes = function(nPixWidth, nPixHeight)
{
AscCommon.History.Add(this, {Type: AscDFH.historyitem_ImageShapeSetPixSizes, oldPr: {w: this.m_nPixWidth, h: this.m_nPixHeight}, newPr: {w: nPixWidth, h: nPixHeight}});
this.m_nPixWidth = nPixWidth;
this.m_nPixHeight = nPixHeight;
};
window['AscFormat'] = window['AscFormat'] || {};
window['AscFormat'].COleObject = COleObject;
......
......@@ -609,10 +609,19 @@ baseEditorsApi.prototype._uploadCallback = function(error, files) {
baseEditorsApi.prototype.asc_addOleObject = function(sImageUrl, sData, sApplicationId){
var oThis = this;
this.asc_checkImageUrlAndAction(sImageUrl, function(oImage){oThis.asc_addOleObjectAction(AscCommon.g_oDocumentUrls.getImageLocal(oImage.src), sData, sApplicationId);});
this.asc_checkImageUrlAndAction(sImageUrl, function(oImage){oThis.asc_addOleObjectAction(AscCommon.g_oDocumentUrls.getImageLocal(oImage.src), sData, sApplicationId, oImage.width * AscCommon.g_dKoef_pix_to_mm, oImage.height * AscCommon.g_dKoef_pix_to_mm);});
};
baseEditorsApi.prototype.asc_addOleObjectAction = function(sLocalUrl, sData, sApplicationId)
baseEditorsApi.prototype.asc_editOleObject = function(bResize, sImageUrl, sData){
var oThis = this;
this.asc_checkImageUrlAndAction(sImageUrl, function(oImage){oThis.asc_editOleObjectAction(bResize, AscCommon.g_oDocumentUrls.getImageLocal(oImage.src), sData, oImage.width, oImage.height);});
};
baseEditorsApi.prototype.asc_addOleObjectAction = function(sLocalUrl, sData, sApplicationId, fWidth, fHeight)
{
};
baseEditorsApi.prototype.asc_editOleObjectAction = function(bResize, oOleObject, sImageUrl, sData, nPixWidth, nPixHeight)
{
};
......@@ -697,6 +706,8 @@ baseEditorsApi.prototype.asc_pluginResize = function(guid, data, width, height)
this.pluginsManager.runResize(guid, data, width, height);
};
//----------------------------------------------------------export----------------------------------------------------
window['AscCommon'] = window['AscCommon'] || {};
window['AscCommon'].baseEditorsApi = baseEditorsApi;
......
......@@ -2103,6 +2103,7 @@ CTableId.prototype.Read_Class_FromBinary = function(Reader)
case AscDFH.historyitem_type_DateAx : Element = new AscFormat.CDateAx(); break;
case AscDFH.historyitem_type_SerAx : Element = new AscFormat.CSerAx(); break;
case AscDFH.historyitem_type_Title : Element = new AscFormat.CTitle(); break;
case AscDFH.historyitem_type_OleObject : Element = new AscFormat.COleObject(); break;
case AscDFH.historyitem_type_Math : Element = new AscCommonWord.ParaMath(false); break;
case AscDFH.historyitem_type_MathContent : Element = new AscCommonWord.CMathContent(); break;
......
......@@ -4028,6 +4028,13 @@ CDocument.prototype.Add_OleObject = function(W, H, Img, Data, sAppl
}
};
CDocument.prototype.Edit_OleObject = function(oOleObject, sData, sImageUrl, nPixWidth, nPixHeight)
{
oOleObject.setData(sData);
oOleObject.setRasterImageId(sImageUrl);
oOleObject.setPixSizes(nPixWidth, nPixHeight);
};
CDocument.prototype.Add_TextArt = function(nStyle)
{
// Работаем с колонтитулом
......
......@@ -5546,24 +5546,36 @@ asc_docs_api.prototype.sync_ImgPropCallback = function(imgProp)
};
asc_docs_api.prototype.asc_addOleObjectAction = function(sLocalUrl, sData, sApplicationId)
asc_docs_api.prototype.asc_addOleObjectAction = function(sLocalUrl, sData, sApplicationId, fWidth, fHeight)
{
var _image = this.ImageLoader.LoadImage(AscCommon.getFullImageSrc2(sLocalUrl), 1);
if (null != _image)//картинка уже должна быть загружена
{
if (false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(changestype_Paragraph_Content))
{
var _w = Math.max(1, AscCommon.Page_Width - (AscCommon.X_Left_Margin + AscCommon.X_Right_Margin));
var _h = Math.max(1, AscCommon.Page_Height - (AscCommon.Y_Top_Margin + AscCommon.Y_Bottom_Margin));
if (_image.Image != null)
this.WordControl.m_oLogicDocument.Create_NewHistoryPoint(AscDFH.historydescription_Document_AddOleObject);
this.WordControl.m_oLogicDocument.Add_OleObject(fWidth, fHeight, sLocalUrl, sData, sApplicationId);
}
}
};
asc_docs_api.prototype.asc_editOleObjectAction = function(bResize, oOleObject, sImageUrl, sData, nPixWidth, nPixHeight)
{
if(oOleObject)
{
if(!bResize)
{
if (false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(changestype_Paragraph_Content))
{
var __w = Math.max(parseInt(_image.Image.width * AscCommon.g_dKoef_pix_to_mm), 1);
var __h = Math.max(parseInt(_image.Image.height * AscCommon.g_dKoef_pix_to_mm), 1);
_w = Math.max(5, Math.min(_w, __w));
_h = Math.max(5, Math.min(parseInt(_w * __h / __w)));
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();
}
this.WordControl.m_oLogicDocument.Create_NewHistoryPoint(AscDFH.historydescription_Document_AddOleObject);
this.WordControl.m_oLogicDocument.Add_OleObject(_w, _h, sLocalUrl, sData, sApplicationId);
}
else
{
this.WordControl.m_oLogicDocument.Edit_OleObject(oOleObject, sData, sImageUrl, nPixWidth, nPixHeight);
this.WordControl.m_oLogicDocument.Recalculate();
}
}
};
......
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