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

- Undo/Redo для диаграмм

- Селект при блокировке картинок и диаграмм

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@48953 954022d7-b5bf-4e40-9824-e11837661b57
parent f0432281
......@@ -5,11 +5,6 @@
* Date: 13/08/2012
*/
var locktype_None = 1; // никто не залочил данный объект
var locktype_Mine = 2; // данный объект залочен текущим пользователем
var locktype_Other = 3; // данный объект залочен другим(не текущим) пользователем
var locktype_Other2 = 4; // данный объект залочен другим(не текущим) пользователем (обновления уже пришли)
var locktype_Other3 = 5; // данный объект был залочен (обновления пришли) и снова стал залочен
if ( !window["Asc"] ) { // Для вставки диаграмм в Word
window["Asc"] = {};
......@@ -617,7 +612,7 @@ function asc_CChart(object) {
var bCopy = isObject(object);
this.bChartEditor = bCopy ? object.bChartEditor : false;
this.worksheet = bCopy ? object.worksheet : null;
this.type = bCopy ? object.type : null;
this.subType = bCopy ? object.subType : c_oAscChartSubType.normal;
......@@ -653,6 +648,9 @@ function asc_CChart(object) {
this.series.push(ser);
}
}
this.Id = g_oIdCounter.Get_NewId();
g_oTableId.Add(this, this.Id);
}
asc_CChart.prototype = {
......@@ -841,6 +839,103 @@ asc_CChart.prototype = {
aInfo.push(info);
}
return aInfo;
},
Get_Id: function() {
return this.Id;
},
Undo: function(type, data) {
switch (type) {
case historyitem_Chart_ChangeType:
this.type = data.oldValue;
break;
case historyitem_Chart_ChangeSubType:
this.subType = data.oldValue;
break;
case historyitem_Chart_ChangeStyle:
this.styleId = data.oldValue;
break;
case historyitem_Chart_ChangeRange:
this.range = new asc_CChartRange(data.oldValue);
if ( this.worksheet ) {
this.range.intervalObject = convertFormula(this.range.interval, this.worksheet);
this.rebuildSeries();
}
break;
case historyitem_Chart_ChangeHeader:
this.header = new asc_CChartHeader(data.oldValue);
break;
case historyitem_Chart_ChangeAxisX:
this.xAxis = new asc_CChartAxisX(data.oldValue);
break;
case historyitem_Chart_ChangeAxisY:
this.yAxis = new asc_CChartAxisY(data.oldValue);
break;
case historyitem_Chart_ChangeLegend:
this.legend = new asc_CChartLegend(data.oldValue);
break;
}
if ( this.worksheet ) {
this.worksheet.objectRender.rebuildChartGraphicObjects();
this.worksheet.objectRender.showDrawingObjects(false);
}
},
Redo: function(type, data) {
switch (type) {
case historyitem_Chart_ChangeType:
this.type = data.newValue;
break;
case historyitem_Chart_ChangeSubType:
this.subType = data.newValue;
break;
case historyitem_Chart_ChangeStyle:
this.styleId = data.newValue;
break;
case historyitem_Chart_ChangeRange:
this.range = new asc_CChartRange(data.newValue);
if ( this.worksheet ) {
this.range.intervalObject = convertFormula(this.range.interval, this.worksheet);
this.rebuildSeries();
}
break;
case historyitem_Chart_ChangeHeader:
this.header = new asc_CChartHeader(data.newValue);
break;
case historyitem_Chart_ChangeAxisX:
this.xAxis = new asc_CChartAxisX(data.newValue);
break;
case historyitem_Chart_ChangeAxisY:
this.yAxis = new asc_CChartAxisY(data.newValue);
break;
case historyitem_Chart_ChangeLegend:
this.legend = new asc_CChartLegend(data.newValue);
break;
}
if ( this.worksheet ) {
this.worksheet.objectRender.rebuildChartGraphicObjects();
this.worksheet.objectRender.showDrawingObjects(false);
}
}
}
......@@ -903,6 +998,10 @@ function asc_CChartRange(object) {
asc_CChartRange.prototype = {
isEqual: function(object) {
return ( (this.interval == object.interval) && (this.rows == object.rows) && (this.columns == object.columns) );
},
asc_getInterval: function() { return this.interval; },
asc_setInterval: function(interval) { this.interval = interval; },
......@@ -948,6 +1047,11 @@ function asc_CChartHeader(object) {
}
asc_CChartHeader.prototype = {
isEqual: function(object) {
return ( (this.title == object.title) && (this.subTitle == object.subTitle) && (this.bDefaultTitle == object.bDefaultTitle) );
},
asc_getTitle: function() { return this.title; },
asc_setTitle: function(title) { this.title = title; },
......@@ -988,6 +1092,11 @@ function asc_CChartAxisX(object) {
}
asc_CChartAxisX.prototype = {
isEqual: function(object) {
return ( (this.title == object.title) && (this.bDefaultTitle == object.bDefaultTitle) && (this.bShow == object.bShow) && (this.bGrid == object.bGrid) );
},
asc_getTitle: function() { return this.title; },
asc_setTitle: function(title) { this.title = title; },
......@@ -1034,6 +1143,11 @@ function asc_CChartAxisY(object) {
}
asc_CChartAxisY.prototype = {
isEqual: function(object) {
return ( (this.title == object.title) && (this.bDefaultTitle == object.bDefaultTitle) && (this.bShow == object.bShow) && (this.bGrid == object.bGrid) );
},
asc_getTitle: function() { return this.title; },
asc_setTitle: function(title) { this.title = title; },
......@@ -1078,9 +1192,12 @@ function asc_CChartLegend(object) {
this.bOverlay = bCopy ? object.bOverlay : false;
}
asc_CChartLegend.prototype = {
isEqual: function(object) {
return ( (this.position == object.position) && (this.bShow = object.bShow) && (this.bOverlay == object.bOverlay) );
},
asc_CChartLegend.prototype = {
asc_getPosition: function() { return this.position; },
asc_setPosition: function(pos) { this.position = pos; },
......@@ -1091,6 +1208,24 @@ asc_CChartLegend.prototype = {
asc_setOverlayFlag: function(overlayFlag) { this.bOverlay = overlayFlag; }
}
//{ asc_CChartLegend export
window["Asc"].asc_CChartLegend = asc_CChartLegend;
window["Asc"]["asc_CChartLegend"] = asc_CChartLegend;
prot = asc_CChartLegend.prototype;
prot["asc_getPosition"] = prot.asc_getPosition;
prot["asc_setPosition"] = prot.asc_setPosition;
prot["asc_getShowFlag"] = prot.asc_getShowFlag;
prot["asc_setShowFlag"] = prot.asc_setShowFlag;
prot["asc_getOverlayFlag"] = prot.asc_getOverlayFlag;
prot["asc_setOverlayFlag"] = prot.asc_setOverlayFlag;
//}
//-----------------------------------------------------------------------------------
// Chart font
//-----------------------------------------------------------------------------------
function asc_CChartFont(object) {
......@@ -1191,21 +1326,6 @@ prot["asc_getUnderline"] = prot.asc_getUnderline;
prot["asc_setUnderline"] = prot.asc_setUnderline;
//}
//{ asc_CChartLegend export
window["Asc"].asc_CChartLegend = asc_CChartLegend;
window["Asc"]["asc_CChartLegend"] = asc_CChartLegend;
prot = asc_CChartLegend.prototype;
prot["asc_getPosition"] = prot.asc_getPosition;
prot["asc_setPosition"] = prot.asc_setPosition;
prot["asc_getShowFlag"] = prot.asc_getShowFlag;
prot["asc_setShowFlag"] = prot.asc_setShowFlag;
prot["asc_getOverlayFlag"] = prot.asc_getOverlayFlag;
prot["asc_setOverlayFlag"] = prot.asc_setOverlayFlag;
//}
//-----------------------------------------------------------------------------------
// Chart series
//-----------------------------------------------------------------------------------
......@@ -2482,12 +2602,6 @@ function DrawingObjects() {
var drawingObject = _this.cloneDrawingObject(currentSheet.model.Drawings[i]);
if ( drawingObject.imageUrl) {
aObjectsSync[aObjectsSync.length] = drawingObject;
aImagesSync[aImagesSync.length] = drawingObject.imageUrl;
}
if (drawingObject.graphicObject instanceof CChartAsGroup) {
_this.calcChartInterval(drawingObject.graphicObject.chart);
......@@ -2498,7 +2612,7 @@ function DrawingObjects() {
drawingObject.graphicObject.chartTitle.drawingObjects = _this;
drawingObject.graphicObject.chart.worksheet = worksheet;
drawingObject.graphicObject.init(aImagesSync);
drawingObject.graphicObject.init();
aObjects.push( drawingObject );
}
if (drawingObject.graphicObject instanceof CShape) {
......@@ -2512,6 +2626,7 @@ function DrawingObjects() {
}
if (drawingObject.graphicObject instanceof CImageShape) {
aObjectsSync[aObjectsSync.length] = drawingObject;
drawingObject.graphicObject.drawingBase = drawingObject;
drawingObject.graphicObject.drawingObjects = _this;
drawingObject.graphicObject.recalculate(aImagesSync);
......@@ -3098,7 +3213,7 @@ function DrawingObjects() {
}
}
_this.addChartDrawingObject = function(chart, bWithoutHistory, options) {
_this.addChartDrawingObject = function(chart, options) {
if ( _this.isViewerMode() )
return;
......@@ -3165,14 +3280,14 @@ function DrawingObjects() {
chart.rebuildSeries();
chart.worksheet = worksheet; // Для формул серий
return this.controller.addChartDrawingObject(chart, bWithoutHistory, options);
return this.controller.addChartDrawingObject(chart, options);
}
_this.editChartDrawingObject = function(chart) {
if ( chart ) {
_this.controller.editChartDrawingObjects(chart);
chart.rebuildSeries();
chart.range.intervalObject = convertFormula(chart.range.interval, worksheet);
_this.controller.editChartDrawingObjects(chart);
_this.showDrawingObjects(false);
}
}
......
......@@ -292,7 +292,7 @@ DrawingObjectsController.prototype =
{
if ( this.selectedObjects[0].isChart() ) {
this.selectedObjects[0].syncAscChart();
return this.selectedObjects[0].chart;
return new asc_CChart(this.selectedObjects[0].chart);
}
if ( isRealObject(this.curState.group) )
......@@ -301,7 +301,7 @@ DrawingObjectsController.prototype =
{
if ( this.curState.group.selectedObjects[0].isChart() ) {
this.curState.group.selectedObjects[0].syncAscChart();
return this.curState.group.selectedObjects[0].chart;
return new asc_CChart(this.curState.group.selectedObjects[0].chart);
}
}
}
......@@ -316,7 +316,7 @@ DrawingObjectsController.prototype =
{
if(this.selectedObjects[0].isChart())
{
this.selectedObjects[0].setChart(chart);
this.selectedObjects[0].setChart(chart, true);
this.selectedObjects[0].recalculate();
return;
......@@ -327,7 +327,7 @@ DrawingObjectsController.prototype =
{
if(this.curState.group.selectedObjects[0].isChart())
{
this.curState.group.selectedObjects[0].setChart(chart);
this.curState.group.selectedObjects[0].setChart(chart, true);
this.curState.group.selectedObjects[0].recalculate();
return;
}
......@@ -336,10 +336,10 @@ DrawingObjectsController.prototype =
}
},
addChartDrawingObject: function(chart, bWithoutHistory, options)
addChartDrawingObject: function(chart, options)
{
var chart_as_group = new CChartAsGroup(null, this.drawingObjects);
chart_as_group.initFromChartObject(chart, bWithoutHistory, options);
chart_as_group.initFromChartObject(chart, options);
},
changeCurrentState: function(newState)
......
......@@ -408,8 +408,53 @@ CChartAsGroup.prototype =
},
setChart: function(chart)
setChart: function(chart, bEdit)
{
if ( bEdit ) {
History.Create_NewPoint();
if ( this.chart.type != chart.type ) {
History.Add(g_oUndoRedoGraphicObjects, historyitem_Chart_ChangeType, null, null, new UndoRedoDataGraphicObjects(this.chart.Get_Id(), new UndoRedoDataGOSingleProp(this.chart.type, chart.type)));
this.chart.type = chart.type;
}
if ( this.chart.subType != chart.subType ) {
History.Add(g_oUndoRedoGraphicObjects, historyitem_Chart_ChangeSubType, null, null, new UndoRedoDataGraphicObjects(this.chart.Get_Id(), new UndoRedoDataGOSingleProp(this.chart.subType, chart.subType)));
this.chart.subType = chart.subType;
}
if ( this.chart.styleId != chart.styleId ) {
History.Add(g_oUndoRedoGraphicObjects, historyitem_Chart_ChangeStyle, null, null, new UndoRedoDataGraphicObjects(this.chart.Get_Id(), new UndoRedoDataGOSingleProp(this.chart.styleId, chart.styleId)));
this.chart.styleId = chart.styleId;
}
if ( !this.chart.range.isEqual(chart.range) ) {
History.Add(g_oUndoRedoGraphicObjects, historyitem_Chart_ChangeRange, null, null, new UndoRedoDataGraphicObjects(this.chart.Get_Id(), new UndoRedoDataGOSingleProp(this.chart.range, chart.range)));
this.chart.range = new asc_CChartRange(chart.range);
}
if ( !this.chart.header.isEqual(chart.header) ) {
History.Add(g_oUndoRedoGraphicObjects, historyitem_Chart_ChangeHeader, null, null, new UndoRedoDataGraphicObjects(this.chart.Get_Id(), new UndoRedoDataGOSingleProp(this.chart.header, chart.header)));
this.chart.header = new asc_CChartHeader(chart.header);
}
if ( !this.chart.xAxis.isEqual(chart.xAxis) ) {
History.Add(g_oUndoRedoGraphicObjects, historyitem_Chart_ChangeAxisX, null, null, new UndoRedoDataGraphicObjects(this.chart.Get_Id(), new UndoRedoDataGOSingleProp(this.chart.xAxis, chart.xAxis)));
this.chart.xAxis = new asc_CChartAxisX(chart.xAxis);
}
if ( !this.chart.yAxis.isEqual(chart.yAxis) ) {
History.Add(g_oUndoRedoGraphicObjects, historyitem_Chart_ChangeAxisY, null, null, new UndoRedoDataGraphicObjects(this.chart.Get_Id(), new UndoRedoDataGOSingleProp(this.chart.yAxis, chart.yAxis)));
this.chart.yAxis = new asc_CChartAxisY(chart.yAxis);
}
if ( !this.chart.legend.isEqual(chart.legend) ) {
History.Add(g_oUndoRedoGraphicObjects, historyitem_Chart_ChangeLegend, null, null, new UndoRedoDataGraphicObjects(this.chart.Get_Id(), new UndoRedoDataGOSingleProp(this.chart.legend, chart.legend)));
this.chart.legend = new asc_CChartAxisY(chart.legend);
}
}
else
this.chart = chart;
},
......@@ -422,7 +467,7 @@ CChartAsGroup.prototype =
}
},
initFromChartObject: function(chart, bWithoutHistory, options)
initFromChartObject: function(chart, options)
{
this.setChart(chart);
this.spPr.xfrm = new CXfrm();
......@@ -642,6 +687,23 @@ CChartAsGroup.prototype =
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape(this, graphics);
shape_drawer.draw(this.spPr.geometry);
if(graphics instanceof CGraphics)
{
var transform = this.transform;
var extX = this.extX;
var extY = this.extY;
if(!isRealObject(this.group))
{
graphics.SetIntegerGrid(false);
graphics.transform3(transform, false);
graphics.DrawLockObjectRect(this.lockType, 0, 0, extX, extY );
graphics.reset();
graphics.SetIntegerGrid(true);
}
}
graphics.reset();
graphics.SetIntegerGrid(true);
if(this.chartTitle)
......
......@@ -343,7 +343,7 @@ CImageShape.prototype =
this.brush.fill.RasterImageId = this.blipFill.fill.RasterImageId;
if(Array.isArray(aImagesSync))
{
aImagesSync.push(this.brush.fill.RasterImageId);
aImagesSync.push(getFullImageSrc(this.brush.fill.RasterImageId));
}
},
......@@ -731,6 +731,23 @@ CImageShape.prototype =
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape(this, graphics);
shape_drawer.draw(this.spPr.geometry);
if(graphics instanceof CGraphics)
{
var transform = this.transform;
var extX = this.extX;
var extY = this.extY;
if(!isRealObject(this.group))
{
graphics.SetIntegerGrid(false);
graphics.transform3(transform, false);
graphics.DrawLockObjectRect(this.lockType, 0, 0, extX, extY );
graphics.reset();
graphics.SetIntegerGrid(true);
}
}
graphics.reset();
graphics.SetIntegerGrid(true);
},
......
......@@ -1835,24 +1835,6 @@ CShape.prototype =
var extX = this.extX;
var extY = this.extY;
/*var callback = function(result)
{
var lockType = parseInt(result);
if ( !isNaN(lockType) )
{
graphics.SetIntegerGrid(false);
graphics.transform3(transform, false);
graphics.DrawLockObjectRect(lockType, 0, 0, extX, extY );
graphics.reset();
graphics.SetIntegerGrid(true);
}
}
if(!isRealObject(this.group))
{
this.drawingBase.isLocked(callback);
}*/
if(!isRealObject(this.group))
{
graphics.SetIntegerGrid(false);
......
......@@ -1709,10 +1709,10 @@ CGraphics.prototype =
DrawLockParagraph : function(lock_type, x, y1, y2)
{
if (lock_type == locktype_None || editor.WordControl.m_oDrawingDocument.IsLockObjectsEnable === false || editor.isViewMode)
if (lock_type == c_oAscLockTypes.kLockTypeNone || editor.WordControl.m_oDrawingDocument.IsLockObjectsEnable === false || editor.isViewMode)
return;
if (lock_type == locktype_Mine)
if (lock_type == c_oAscLockTypes.kLockTypeMine)
{
this.p_color(22, 156, 0, 255);
//this.p_color(155, 187, 277, 255);
......@@ -1801,10 +1801,10 @@ CGraphics.prototype =
DrawLockObjectRect : function(lock_type, x, y, w, h)
{
if (lock_type == locktype_None)
if (lock_type == c_oAscLockTypes.kLockTypeNone)
return;
if (lock_type == locktype_Mine)
if (lock_type == c_oAscLockTypes.kLockTypeMine)
{
this.p_color(22, 156, 0, 255);
//this.p_color(155, 187, 277, 255);
......
......@@ -73,7 +73,14 @@ var historyitem_Cell_SetQuotePrefix = 20;
var historyitem_Cell_Angle = 21;
var historyitem_Cell_Style = 22;
var historyitem_DrawingLayer = 1;
var historyitem_Chart_ChangeType = 1;
var historyitem_Chart_ChangeSubType = 2;
var historyitem_Chart_ChangeStyle = 3;
var historyitem_Chart_ChangeRange = 4;
var historyitem_Chart_ChangeHeader = 5;
var historyitem_Chart_ChangeAxisX = 6;
var historyitem_Chart_ChangeAxisY = 7;
var historyitem_Chart_ChangeLegend = 8;
var historyitem_AutoShapes_Offset = 1;
var historyitem_AutoShapes_Extents = 2;
......
......@@ -8141,10 +8141,7 @@
t.model.insertColsBefore(_updateRangeIns.c1, _updateRangeIns.c2 - _updateRangeIns.c1 + 1);
t.model.onEndTriggerAction();
t.autoFilters.insertColumn(t, prop, _updateRangeIns, arn);
//if ( !bUndoRedo ) {
t.objectRender.updateDrawingObject(true, val, _updateRangeIns);
//}
t.cellCommentator.updateCommentsDependencies(true, val, _updateRangeIns);
};
if(bUndoRedo)
......@@ -8161,10 +8158,7 @@
t.model.insertRowsBefore(_updateRangeIns.r1, _updateRangeIns.r2 - _updateRangeIns.r1 + 1);
t.model.onEndTriggerAction();
t.autoFilters.insertRows(t, prop,_updateRangeIns, arn);
//if ( !bUndoRedo ) {
t.objectRender.updateDrawingObject(true, val, _updateRangeIns);
//}
t.cellCommentator.updateCommentsDependencies(true, val, _updateRangeIns);
};
if(bUndoRedo)
......@@ -8221,9 +8215,7 @@
fullRecalc = true;
t.model.removeCols(_updateRangeDel.c1, _updateRangeDel.c2);
t.autoFilters.insertColumn(t, prop,_updateRangeDel, arn);
//if (!bUndoRedo) {
t.objectRender.updateDrawingObject(false, val, _updateRangeDel);
//}
t.cellCommentator.updateCommentsDependencies(false, val, _updateRangeDel);
};
if(bUndoRedo)
......@@ -8238,9 +8230,7 @@
fullRecalc = true;
t.model.removeRows(_updateRangeDel.r1, _updateRangeDel.r2);
t.autoFilters.insertRows(t, prop,_updateRangeDel, arn);
//if (!bUndoRedo) {
t.objectRender.updateDrawingObject(false, val, _updateRangeDel);
//}
t.cellCommentator.updateCommentsDependencies(false, val, _updateRangeDel);
};
if(bUndoRedo)
......
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