Commit 5eef13ba authored by Dmitry.Vikulov's avatar Dmitry.Vikulov Committed by Alexander.Trofimov

- Исправлены баги с заливкой автофигур картинкой(file/url)

- Отправка эвента selectionChanged при добавлении объекта и изменении свойств

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@48304 954022d7-b5bf-4e40-9824-e11837661b57
parent aa30060c
......@@ -20,6 +20,10 @@ function isObject(what) {
return ( (what != null) && (typeof(what) == "object") );
}
function isNullOrEmptyString(str) {
return (str == undefined) || (str == null) || (str == "");
}
function convertFormula(formula, ws) {
var range = null;
......@@ -2458,6 +2462,10 @@ function DrawingObjects() {
return _this.drawingDocument.CanvasHitContext;
}
_t.setActive = function() {
worksheet._moveActiveCellToXY(_t.getVisibleLeftOffset(true) + 1, _t.getVisibleTopOffset(true) + 1);
}
// GraphicObject: x, y, extX, extY
_t.getGraphicObjectMetrics = function() {
......@@ -3211,11 +3219,8 @@ function DrawingObjects() {
var url = data["url"];
if (sheetId == worksheet.model.getId()) {
if ( api.isImageChangeUrl || api.isShapeImageChangeUrl ) {
_this.editImageDrawingObject(url, api.isImageChangeUrl);
api.isImageChangeUrl = false;
api.isShapeImageChangeUrl = false;
}
if ( api.isImageChangeUrl || api.isShapeImageChangeUrl )
_this.editImageDrawingObject(url);
else
_this.addImageDrawingObject(url, false, null);
}
......@@ -3672,13 +3677,18 @@ function DrawingObjects() {
obj.graphicObject = new CImage(obj, _this);
obj.graphicObject.initDefault( x, y, w, h, _image.src );
obj.graphicObject.select(_this.controller);
obj.setGraphicObjectCoords();
aObjects.push(obj);
obj.setGraphicObjectCoords();
obj.setActive();
worksheet.autoFilters.drawAutoF(worksheet);
worksheet.cellCommentator.drawCommentCells(false);
_this.showDrawingObjects(false);
_this.selectGraphicObject();
_this.sendGraphicObjectProps();
_this.lockDrawingObject(obj.id, bPackage ? false : true, bPackage ? false : true);
}
......@@ -3733,45 +3743,41 @@ function DrawingObjects() {
}
}
_this.editImageDrawingObject = function(imageUrl, isImageChangeUrl) {
_this.editImageDrawingObject = function(imageUrl) {
if ( imageUrl && (_this.controller.selectedObjects.length == 1) ) {
var drawingObject = _this.controller.selectedObjects[0].drawingBase;
if ( imageUrl ) {
var _image = api.ImageLoader.LoadImage(imageUrl, 1);
if (null != _image) {
addImageObject(_image, isImageChangeUrl);
addImageObject(_image);
}
else {
_this.asyncImageEndLoaded = function(_image) {
addImageObject(_image, isImageChangeUrl);
addImageObject(_image);
}
}
function addImageObject(_image, isImageChangeUrl) {
function addImageObject(_image) {
if ( !_image.Image ) {
worksheet.model.workbook.handlers.trigger("asc_onError", c_oAscError.ID.UplImageUrl, c_oAscError.Level.NoCritical);
}
else {
if ( isImageChangeUrl ) {
if ( drawingObject.graphicObject.isImage() )
drawingObject.graphicObject.setRasterImage(_image.src);
else if ( drawingObject.graphicObject.isShape() ) {
var imageProp = new asc_CImgProperty();
imageProp.ImageUrl = src;
_this.controller.setGraphicObjectProps(shapeProp);
}
if ( api.isImageChangeUrl ) {
var imageProp = new asc_CImgProperty();
imageProp.ImageUrl = _image.src;
_this.setGraphicObjectProps(imageProp);
api.isImageChangeUrl = false;
}
else { // isShapeImageChangeUrl
else if ( api.isShapeImageChangeUrl ) {
var shapeProp = new asc_CShapeProperty();
shapeProp.fill = new asc_CShapeFill();
shapeProp.fill.type = c_oAscFill.FILL_TYPE_BLIP;
shapeProp.fill.fill = new asc_CFillBlip();
shapeProp.fill.fill.asc_putUrl(_image.src);
_this.controller.setGraphicObjectProps(shapeProp);
_this.setGraphicObjectProps(shapeProp);
api.isShapeImageChangeUrl = false;
}
_this.showDrawingObjects(true);
_this.selectGraphicObject();
}
......@@ -4437,9 +4443,15 @@ function DrawingObjects() {
graphic.setDrawingBase(obj);
obj.graphicObject.select(_this.controller);
obj.setGraphicObjectCoords();
aObjects.push(obj);
obj.setGraphicObjectCoords();
obj.setActive();
_this.showDrawingObjects(false);
_this.selectGraphicObject();
_this.sendGraphicObjectProps();
worksheet.model.workbook.handlers.trigger("asc_onEndAddShape");
_this.lockDrawingObject(obj.id, true, true);
}
......@@ -4644,14 +4656,56 @@ function DrawingObjects() {
return new asc_CImageSize( 50, 50, false );
}
_this.sendSelectionChanged = function() {
_this.sendGraphicObjectProps = function() {
if ( worksheet )
worksheet._trigger("selectionChanged", worksheet.getSelectionInfo());
}
_this.setGraphicObjectProps = function(props) {
var objectProperties = props;
if ( !isNullOrEmptyString(objectProperties.ImageUrl) ) {
var _img = api.ImageLoader.LoadImage(objectProperties.ImageUrl, 1)
if (null != _img) {
objectProperties.ImageUrl = _img.src;
_this.controller.setGraphicObjectProps( objectProperties );
}
else {
_this.asyncImageEndLoaded = function(_image) {
objectProperties.ImageUrl = _image.src;
_this.controller.setGraphicObjectProps( objectProperties );
}
}
}
else if ( objectProperties.ShapeProperties && objectProperties.ShapeProperties.fill && objectProperties.ShapeProperties.fill.fill &&
!isNullOrEmptyString(objectProperties.ShapeProperties.fill.fill.url) ) {
var _img = api.ImageLoader.LoadImage(objectProperties.ShapeProperties.fill.fill.url, 1);
if ( null != _img ) {
objectProperties.ImageUrl = _img.src;
_this.controller.setGraphicObjectProps( objectProperties );
}
else {
_this.asyncImageEndLoaded = function(_image) {
objectProperties.ImageUrl = _image.src;
_this.controller.setGraphicObjectProps( objectProperties );
}
}
}
else {
objectProperties.ImageUrl = null;
_this.controller.setGraphicObjectProps( objectProperties );
}
_this.sendGraphicObjectProps();
}
_this.showChartSettings = function() {
api.wb.handlers.trigger("asc_onShowChartDialog", true);
}
//-----------------------------------------------------------------------------------
// Graphic object mouse events
//-----------------------------------------------------------------------------------
......
......@@ -2177,7 +2177,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
asc_setGraphicObjectProps: function(props) {
var ws = this.wb.getWorksheet();
return ws.objectRender.controller.setGraphicObjectProps(props);
return ws.objectRender.setGraphicObjectProps(props);
},
asc_getOriginalImageSize: function() {
......
......@@ -295,7 +295,7 @@ DrawingObjectsController.prototype =
{
var shape_props, image_props;
switch(this.curState.id)
switch (this.curState.id)
{
/*case STATES_ID_GROUP:
case STATES_ID_TEXT_ADD_IN_GROUP:
......@@ -537,39 +537,103 @@ DrawingObjectsController.prototype =
setGraphicObjectProps: function(props)
{
var properties;
if (props instanceof asc_CImgProperty)
if ( (props instanceof asc_CImgProperty) && props.ShapeProperties)
properties = props.ShapeProperties;
else
properties = props;
if (isRealObject(properties) || isRealObject(props))
{
if (props.ImageUrl != undefined && props.ImageUrl != null && props.ImageUrl != "")
{
if (isRealObject(props) && typeof props.verticalTextAlign === "number" && !isNaN(props.verticalTextAlign))
{
this.drawingObjects.editImageDrawingObject(props.ImageUrl);
if (this.curState.id === STATES_ID_TEXT_ADD)
{
if(typeof this.curState.textObject.GraphicObj.setTextVerticalAlign === "function")
this.curState.textObject.GraphicObj.setTextVerticalAlign(props.verticalTextAlign);
}
if (this.curState.id === STATES_ID_TEXT_ADD_IN_GROUP)
{
if (typeof this.curState.textObject.setTextVerticalAlign === "function")
this.curState.textObject.setTextVerticalAlign(props.verticalTextAlign);
}
}
else
if (!(this.curState.id === STATES_ID_GROUP || this.curState.id === STATES_ID_TEXT_ADD_IN_GROUP) && isRealObject(properties))
{
if (isRealObject(props) && typeof props.verticalTextAlign === "number" && !isNaN(props.verticalTextAlign))
var ArrGlyph = this.selectedObjects;
for (var i = 0; i< ArrGlyph.length; ++i)
{
if (this.curState.id === STATES_ID_TEXT_ADD)
if ( undefined != properties.Width || undefined != properties.Height )
{
var result_width, result_height;
var b_is_line = ArrGlyph[i].checkLine();
if (properties.Width != undefined)
if (properties.Width >= MIN_SHAPE_SIZE || b_is_line)
result_width = properties.Width;
else
result_width = MIN_SHAPE_SIZE;
else
result_width = ArrGlyph[i].extX;
if (properties.Height != undefined)
if(properties.Height >= MIN_SHAPE_SIZE || b_is_line)
result_height = properties.Height;
else
result_height = MIN_SHAPE_SIZE;
else
result_height = ArrGlyph[i].extY;
if (ArrGlyph[i].isShape() || ArrGlyph[i].isImage())
{
ArrGlyph[i].setAbsoluteTransform(null, null, result_width, result_height, null, false, false);
ArrGlyph[i].setXfrm(null, null, result_width, result_height, null, null, null);
ArrGlyph[i].calculateAfterResize();
}
}
else if (ArrGlyph[i].isImage())
{
ArrGlyph[i].setRasterImage(props.ImageUrl);
}
else if (((ArrGlyph[i].isShape()) || (ArrGlyph[i].isGroup())))
{
if(typeof this.curState.textObject.GraphicObj.setTextVerticalAlign === "function")
this.curState.textObject.GraphicObj.setTextVerticalAlign(props.verticalTextAlign);
if (properties.type != undefined && properties.type != -1)
{
ArrGlyph[i].changePresetGeometry(properties.type);
}
if (properties.fill)
{
ArrGlyph[i].changeFill(properties.fill);
}
if (properties.stroke)
{
ArrGlyph[i].changeLine(properties.stroke);
}
}
if (this.curState.id === STATES_ID_TEXT_ADD_IN_GROUP)
if (typeof props.verticalTextAlign === "number" && !isNaN(props.verticalTextAlign) && typeof ArrGlyph[i].setTextVerticalAlign === "function")
{
if (typeof this.curState.textObject.setTextVerticalAlign === "function")
this.curState.textObject.setTextVerticalAlign(props.verticalTextAlign);
ArrGlyph[i].setTextVerticalAlign(props.verticalTextAlign);
}
}
if (!(this.curState.id === STATES_ID_GROUP || this.curState.id === STATES_ID_TEXT_ADD_IN_GROUP) && isRealObject(properties))
}
else if (this.curState.id === STATES_ID_GROUP || this.curState.id === STATES_ID_TEXT_ADD_IN_GROUP)
{
if (false === this.document.Document_Is_SelectionLocked(changestype_Drawing_Props, {Type : changestype_2_Element_and_Type , Element : this.curState.group.parent.Parent, CheckType : changestype_Paragraph_Content} ))
{
var ArrGlyph = this.selectedObjects;
for (var i = 0; i< ArrGlyph.length; ++i)
if ( undefined != props.PositionH )
this.curState.group.parent.Set_PositionH( props.PositionH.RelativeFrom, props.PositionH.UseAlign, ( true === props.PositionH.UseAlign ? props.PositionH.Align : props.PositionH.Value ) );
if ( undefined != props.PositionV )
this.curState.group.parent.Set_PositionV( props.PositionV.RelativeFrom, props.PositionV.UseAlign, ( true === props.PositionV.UseAlign ? props.PositionV.Align : props.PositionV.Value ) );
ArrGlyph = this.curState.group.selectionInfo.selectionArray;
var b_change_diagram = false;
for (i = 0; i< ArrGlyph.length; ++i)
{
if (((ArrGlyph[i].isShape()) || (ArrGlyph[i].isGroup())))
if (ArrGlyph[i].isShape() && isRealObject(properties))
{
if (properties.type != undefined && properties.type != -1)
{
......@@ -584,75 +648,32 @@ DrawingObjectsController.prototype =
ArrGlyph[i].changeLine(properties.stroke);
}
}
else if (isRealObject(props) && typeof props.ImageUrl === "string" && ArrGlyph[i].isImage())
{
ArrGlyph[i].setRasterImage(props.ImageUrl);
}
if (typeof props.verticalTextAlign === "number" && !isNaN(props.verticalTextAlign) && typeof ArrGlyph[i].setTextVerticalAlign === "function")
{
ArrGlyph[i].setTextVerticalAlign(props.verticalTextAlign);
}
}
}
else if (this.curState.id === STATES_ID_GROUP || this.curState.id === STATES_ID_TEXT_ADD_IN_GROUP)
{
if (false === this.document.Document_Is_SelectionLocked(changestype_Drawing_Props, {Type : changestype_2_Element_and_Type , Element : this.curState.group.parent.Parent, CheckType : changestype_Paragraph_Content} ))
if (b_change_diagram)
{
if ( undefined != props.PositionH )
this.curState.group.parent.Set_PositionH( props.PositionH.RelativeFrom, props.PositionH.UseAlign, ( true === props.PositionH.UseAlign ? props.PositionH.Align : props.PositionH.Value ) );
if ( undefined != props.PositionV )
this.curState.group.parent.Set_PositionV( props.PositionV.RelativeFrom, props.PositionV.UseAlign, ( true === props.PositionV.UseAlign ? props.PositionV.Align : props.PositionV.Value ) );
ArrGlyph = this.curState.group.selectionInfo.selectionArray;
var b_change_diagram = false;
for (i = 0; i< ArrGlyph.length; ++i)
{
if (ArrGlyph[i].isShape() && isRealObject(properties))
{
if (properties.type != undefined && properties.type != -1)
{
ArrGlyph[i].changePresetGeometry(properties.type);
}
if (properties.fill)
{
ArrGlyph[i].changeFill(properties.fill);
}
if (properties.stroke)
{
ArrGlyph[i].changeLine(properties.stroke);
}
}
else if (isRealObject(props) && typeof props.ImageUrl === "string" && ArrGlyph[i].isImage() && ArrGlyph[i].chart == null)
{
ArrGlyph[i].setRasterImage2(props.ImageUrl);
}
else if (ArrGlyph[i].chart != null && isRealObject(props) && isRealObject(props.ChartProperties))
{
b_change_diagram = true;
ArrGlyph[i].setDiagram(props.ChartProperties)
}
if (typeof props.verticalTextAlign === "number" && !isNaN(props.verticalTextAlign) && typeof ArrGlyph[i].setTextVerticalAlign === "function")
{
ArrGlyph[i].setTextVerticalAlign(props.verticalTextAlign);
}
}
if (b_change_diagram)
{
this.curState.group.updateSizes();
this.curState.group.recalculate();
var bounds = this.curState.group.parent.getBounds();
if (!this.curState.group.parent.Is_Inline())
this.curState.group.parent.OnEnd_ChangeFlow(this.curState.group.absOffsetX, this.curState.group.absOffsetY, this.curState.group.pageIndex, bounds.r - bounds.l, bounds.b - bounds.t, null, true, true);
else
this.curState.group.parent.OnEnd_ResizeInline(bounds.r - bounds.l, bounds.b - bounds.t);
}
this.curState.group.updateSizes();
this.curState.group.recalculate();
var bounds = this.curState.group.parent.getBounds();
if (!this.curState.group.parent.Is_Inline())
this.curState.group.parent.OnEnd_ChangeFlow(this.curState.group.absOffsetX, this.curState.group.absOffsetY, this.curState.group.pageIndex, bounds.r - bounds.l, bounds.b - bounds.t, null, true, true);
else
this.curState.group.parent.OnEnd_ResizeInline(bounds.r - bounds.l, bounds.b - bounds.t);
}
}
}
}
this.drawingObjects.showDrawingObjects(true);
this.drawingObjects.selectGraphicObject();
this.drawingObjects.sendSelectionChanged();
this.drawingObjects.sendGraphicObjectProps();
}
};
......
......@@ -53,6 +53,7 @@ function CImage(drawingBase, drawingObjects)
this.rot = null;
this.flipH = null;
this.flipV = null;
this.mainGroup = null;
this.transform = new CMatrix();
this.invertTransform = null;
this.cursorTypes = [];
......@@ -180,6 +181,109 @@ CImage.prototype =
this.blipFill.RasterImageId = imageId;
},
setAbsoluteTransform: function(offsetX, offsetY, extX, extY, rot, flipH, flipV, bAfterOpen)
{
if(offsetX != null)
{
this.absOffsetX = offsetX;
}
if(offsetY != null)
{
this.absOffsetY = offsetY;
}
if(extX != null)
{
this.absExtX = extX;
}
if(extY != null)
{
this.absExtY = extY;
}
if(rot != null)
{
this.absRot = rot;
}
if(flipH != null)
{
this.absFlipH = flipH;
}
if(flipV != null)
{
this.absFlipV = flipV;
}
if(this.parent)
this.parent.setAbsoluteTransform(offsetX, offsetY, extX, extY, rot, flipH, flipV, true);
var b_change_size = extX != null || extY != null;
this.recalculate(b_change_size, bAfterOpen);
},
setXfrm: function(offsetX, offsetY, extX, extY, rot, flipH, flipV)
{
//var data = {Type: historyitem_SetXfrmShape};
var _xfrm = this.spPr.xfrm;
if(offsetX !== null)
{
//data.oldOffsetX = _xfrm.offX;
//data.newOffsetX = offsetX;
_xfrm.offX = offsetX;
}
if(offsetY !== null)
{
//data.oldOffsetY = _xfrm.offY;
//data.newOffsetY = offsetY;
_xfrm.offY = offsetY;
}
if(extX !== null)
{
//data.oldExtX = _xfrm.extX;
//data.newExtX = extX;
_xfrm.extX = extX;
}
if(extY !== null)
{
//data.oldExtY = _xfrm.extY;
//data.newExtY = extY;
_xfrm.extY = extY;
}
if(rot !== null)
{
//data.oldRot = _xfrm.rot == null ? 0 : _xfrm.rot;
//data.newRot = rot;
_xfrm.rot = rot;
}
if(flipH !== null)
{
//data.oldFlipH = _xfrm.flipH == null ? false : _xfrm.flipH;
//data.newFlipH = flipH;
_xfrm.flipH = flipH;
}
if(flipV !== null)
{
//data.oldFlipV = _xfrm.flipV == null ? false : _xfrm.flipV;
//data.newFlipV = flipV;
_xfrm.flipV = flipV;
}
//History.Add(this, data);
},
recalculate: function()
{
if(this.recalcInfo.recalculateTransform)
......@@ -250,6 +354,121 @@ CImage.prototype =
},
calculateAfterResize: function(transform, bChangeSize, bAfterOpen)
{
if(this.spPr.geometry !== null)
this.spPr.geometry.Recalculate(this.absExtX, this.absExtY);
this.calculateTransformMatrix(transform);
this.calculateTransformTextMatrix();
this.calculateLeftTopPoint();
if(isRealObject(this.chart) && (bChangeSize === true || this.chart.img == "")&& bAfterOpen !== true)
{
this.chart.width = this.drawingDocument.GetDotsPerMM(this.absExtX);
this.chart.height = this.drawingDocument.GetDotsPerMM(this.absExtY);
var chartRender = new ChartRender();
var chartBase64 = chartRender.insertChart(this.chart, null, this.chart.width, this.chart.height);
this.chart.img = chartBase64;
this.setRasterImage(this.chart.img);
editor.WordControl.m_oLogicDocument.DrawingObjects.urlMap.push(this.chart.img);
}
/*if(this.chart != null)
{
var chartRender = new ChartRender();
var width_pix = this.drawingDocument.GetDotsPerMM(this.absExtX);
var heght_pix = this.drawingDocument.GetDotsPerMM(this.absExtY);
var chartBase64 = chartRender.insertChart(this.chart, null, width_pix, heght_pix);
if ( !chartBase64 )
return;
var _image = editor.ImageLoader.LoadImage(_getFullImageSrc(chartBase64), 1);
var or_shp = this;
if (null != _image)
{
this.setRasterImage(chartBase64)
}
else
{
editor.sync_StartAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.LoadImage);
editor.asyncImageEndLoaded2 = function(_image)
{
or_shp.setRasterImage(_image.src);
editor.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.LoadImage);
if(or_shp.group == null)
{
var or_gr_obj = or_shp.parent;
var bounds_2 = or_gr_obj.getBounds();
if(!or_gr_obj.Is_Inline())
{
or_gr_obj.calculateOffset();
var pos_x = or_gr_obj.absOffsetX;
var pos_y = or_gr_obj.absOffsetY;
var near_pos = or_shp.document.Get_NearestPos(or_gr_obj.PageNum, bounds_2.l, bounds_2.t, true, or_gr_obj);
var W = bounds_2.r - bounds_2.l;
var H = bounds_2.b - bounds_2.t;
or_gr_obj.OnEnd_ChangeFlow(pos_x, pos_y, or_gr_obj.pageIndex, W, H, near_pos, false, true);
}
else
{
or_gr_obj.OnEnd_ResizeInline(bounds_2.r - bounds_2.l, bounds_2.b - bounds_2.t);
}
}
}
}
} */
},
calculateTransformMatrix: function(transform)
{
var _transform = new CMatrix();
var _horizontal_center = this.extX * 0.5;
var _vertical_center = this.extY * 0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.absFlipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.absFlipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.absRot);
global_MatrixTransformer.TranslateAppend(_transform, this.absOffsetX, this.absOffsetY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
if(this.mainGroup !== null)
{
global_MatrixTransformer.MultiplyAppend(_transform, this.mainGroup.getTransform());
}
if(isRealObject(transform))
{
global_MatrixTransformer.MultiplyPrepend(_transform, transform);
}
this.transform = _transform;
this.ownTransform = _transform.CreateDublicate();
},
calculateLeftTopPoint: function()
{
var _horizontal_center = this.extX * 0.5;
var _vertical_enter = this.extY * 0.5;
var _sin = Math.sin(this.absRot);
var _cos = Math.cos(this.absRot);
this.absXLT = -_horizontal_center*_cos + _vertical_enter*_sin +this.absOffsetX + _horizontal_center;
this.absYLT = -_horizontal_center*_sin - _vertical_enter*_cos +this.absOffsetY + _vertical_enter;
},
checkLine: function()
{
return false;
},
normalize: function()
{
var new_off_x, new_off_y, new_ext_x, new_ext_y;
......
......@@ -148,6 +148,7 @@ function CShape(drawingBase, drawingObjects)
this.rot = null;
this.flipH = null;
this.flipV = null;
this.mainGroup = null;
this.transform = new CMatrix();
this.invertTransform = null;
this.transformText = new CMatrix();
......@@ -381,6 +382,63 @@ CShape.prototype =
}
},
setXfrm: function(offsetX, offsetY, extX, extY, rot, flipH, flipV)
{
//var data = {Type: historyitem_SetXfrmShape};
var _xfrm = this.spPr.xfrm;
if(offsetX !== null)
{
//data.oldOffsetX = _xfrm.offX;
//data.newOffsetX = offsetX;
_xfrm.offX = offsetX;
}
if(offsetY !== null)
{
//data.oldOffsetY = _xfrm.offY;
//data.newOffsetY = offsetY;
_xfrm.offY = offsetY;
}
if(extX !== null)
{
//data.oldExtX = _xfrm.extX;
//data.newExtX = extX;
_xfrm.extX = extX;
}
if(extY !== null)
{
//data.oldExtY = _xfrm.extY;
//data.newExtY = extY;
_xfrm.extY = extY;
}
if(rot !== null)
{
//data.oldRot = _xfrm.rot == null ? 0 : _xfrm.rot;
//data.newRot = rot;
_xfrm.rot = rot;
}
if(flipH !== null)
{
//data.oldFlipH = _xfrm.flipH == null ? false : _xfrm.flipH;
//data.newFlipH = flipH;
_xfrm.flipH = flipH;
}
if(flipV !== null)
{
//data.oldFlipV = _xfrm.flipV == null ? false : _xfrm.flipV;
//data.newFlipV = flipV;
_xfrm.flipV = flipV;
}
//History.Add(this, data);
},
paragraphAdd: function(paraItem, bRecalculate)
{
......@@ -754,6 +812,30 @@ CShape.prototype =
this.invertTransformText = global_MatrixTransformer.Invert(this.transformText);
},
calculateAfterResize: function()
{
if(this.spPr.geometry !== null)
this.spPr.geometry.Recalculate(this.absExtX, this.absExtY);
this.calculateTransformMatrix();
this.calculateContent();
this.calculateTransformTextMatrix();
this.calculateLeftTopPoint();
},
calculateLeftTopPoint: function()
{
var _horizontal_center = this.extX * 0.5;
var _vertical_enter = this.extY * 0.5;
var _sin = Math.sin(this.absRot);
var _cos = Math.cos(this.absRot);
this.absXLT = -_horizontal_center*_cos + _vertical_enter*_sin +this.absOffsetX + _horizontal_center;
this.absYLT = -_horizontal_center*_sin - _vertical_enter*_cos +this.absOffsetY + _vertical_enter;
},
checkLine: function()
{
return (this.spPr.geometry && CheckLinePreset(this.spPr.geometry.preset));
},
addTextBody: function(textBody)
{
......@@ -815,6 +897,56 @@ CShape.prototype =
this.txBody.selectionSetEnd(e, t_x, t_y);
},
setAbsoluteTransform: function(offsetX, offsetY, extX, extY, rot, flipH, flipV, open)
{
if(offsetX != null)
{
this.absOffsetX = offsetX;
}
if(offsetY != null)
{
this.absOffsetY = offsetY;
}
if(extX != null)
{
this.absExtX = extX;
}
if(extY != null)
{
this.absExtY = extY;
}
/*if(extX != null || extY!=null)
{
if(this.spPr.geometry)
this.spPr.geometry.Recalculate(this.absExtX, this.absExtY);
} */
if(rot != null)
{
this.absRot = rot;
}
if(flipH != null)
{
this.absFlipH = flipH;
}
if(flipV != null)
{
this.absFlipV = flipV;
}
if(this.parent)
this.parent.setAbsoluteTransform(offsetX, offsetY, extX, extY, rot, flipH, flipV, true);
if(open !== false)
this.calculateContent();
this.recalculate(open);
},
recalculateTransform: function()
{
var xfrm = this.spPr.xfrm;
......@@ -1042,6 +1174,36 @@ CShape.prototype =
this.calculateLeftTopPoint();
},
calculateTransformMatrix: function()
{
var _transform = new CMatrix();
var _horizontal_center = this.extX * 0.5;
var _vertical_center = this.extY * 0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.absFlipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.absFlipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.absRot);
global_MatrixTransformer.TranslateAppend(_transform, this.absOffsetX, this.absOffsetY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
if(this.mainGroup !== null)
{
global_MatrixTransformer.MultiplyAppend(_transform, this.mainGroup.getTransform());
}
this.transform = _transform;
this.ownTransform = _transform.CreateDublicate();
},
calculateLeftTopPoint: function()
{
var _horizontal_center = this.absExtX*0.5;
......
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