Commit 5e450121 authored by Sergey.Luzyanin's avatar Sergey.Luzyanin Committed by Alexander.Trofimov

Пересчет диаграмм при изменениии данных на листе. Селект текста в заголовках.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56623 954022d7-b5bf-4e40-9824-e11837661b57
parent d1a8f4ab
......@@ -4308,8 +4308,15 @@ function DrawingObjects() {
}
};
_this.rebuildChartGraphicObjects = function(data) {
_this.rebuildChartGraphicObjects = function(data)
{
for(var i = 0; i < aObjects.length; ++i)
{
if(aObjects[i].graphicObject.getObjectType() === historyitem_type_ChartSpace)
{
aObjects[i].graphicObject.rebuildSeries();
}
}
};
_this.updateDrawingObject = function(bInsert, operType, updateRange) {
......@@ -5333,7 +5340,7 @@ function DrawingObjects() {
// }
// }
if($("#chartPropsMenuDiv").length > 0) //TODO: убрать как будет всё готово в меню
/*if($("#chartPropsMenuDiv").length > 0) //TODO: убрать как будет всё готово в меню
{
var chart = _this.controller.getAscChartObject();
if ( !chart ) {
......@@ -5383,7 +5390,7 @@ function DrawingObjects() {
}();
}
return chart;
}
} */
var settings = _this.controller.getChartProps();
if ( !settings )
......
......@@ -138,13 +138,20 @@ function getTargetTextObject(controller)
{
return controller.selection.textSelection;
}
else if(controller.selection.groupSelection && controller.selection.groupSelection.selection.textSelection)
else if(controller.selection.groupSelection )
{
return controller.selection.groupSelection.selection.textSelection;
if(controller.selection.groupSelection.selection.textSelection)
{
return controller.selection.groupSelection.selection.textSelection;
}
else if(controller.selection.groupSelection.selection.chartSelection && controller.selection.groupSelection.selection.chartSelection.selection.textSelection)
{
return controller.selection.groupSelection.selection.chartSelection.selection.textSelection;
}
}
else if(controller.selection.chartSelection && controller.selection.chartSelection.textSelection)
else if(controller.selection.chartSelection && controller.selection.chartSelection.selection.textSelection)
{
return controller.selection.chartSelection.textSelection;
return controller.selection.chartSelection.selection.textSelection;
}
return null;
}
......@@ -360,7 +367,6 @@ DrawingObjectsController.prototype =
}
},
recalculateCurPos: function()
{
if(this.selection.textSelection)
......@@ -719,7 +725,43 @@ DrawingObjectsController.prototype =
}
}
else if(this.selection.groupSelection.selection.chartSelection)
{}
{
if(this.selection.groupSelection.selection.chartSelection.selectStartPage === pageIndex)
{
drawingDocument.DrawTrack(TYPE_TRACK_SHAPE, this.selection.groupSelection.selection.chartSelection.getTransformMatrix(), 0, 0, this.selection.groupSelection.selection.chartSelection.extX, this.selection.groupSelection.selection.chartSelection.extY, false, this.selection.groupSelection.selection.chartSelection.canRotate());
if(this.selection.groupSelection.selection.chartSelection.selection.textSelection)
{
drawingDocument.DrawTrack(TYPE_TRACK_TEXT, this.selection.groupSelection.selection.chartSelection.selection.textSelection.transform, 0, 0, this.selection.groupSelection.selection.chartSelection.selection.textSelection.extX, this.selection.groupSelection.selection.chartSelection.selection.textSelection.extY, false, false);
}
else if(this.selection.groupSelection.selection.chartSelection.selection.title)
{
drawingDocument.DrawTrack(TYPE_TRACK_SHAPE, this.selection.groupSelection.selection.chartSelection.selection.title.transform, 0, 0, this.selection.groupSelection.selection.chartSelection.selection.title.extX, this.selection.groupSelection.selection.chartSelection.selection.title.extY, false, false);
}
else if(this.selection.groupSelection.selection.chartSelection.selection.dataLbls)
{
for(i = 0; i < this.selection.groupSelection.selection.chartSelection.selection.dataLbls.length; ++i)
{
drawingDocument.DrawTrack(TYPE_TRACK_SHAPE, this.selection.groupSelection.selection.chartSelection.selection.dataLbls[i].transform, 0, 0, this.selection.groupSelection.selection.chartSelection.selection.dataLbls[i].extX, this.selection.groupSelection.selection.chartSelection.selection.dataLbls[i].extY, false, false);
}
}
else if(this.selection.groupSelection.selection.chartSelection.selection.dataLbl)
{
drawingDocument.DrawTrack(TYPE_TRACK_SHAPE, this.selection.groupSelection.selection.chartSelection.selection.dataLbl.transform, 0, 0, this.selection.groupSelection.selection.chartSelection.selection.dataLbl.extX, this.selection.groupSelection.selection.chartSelection.selection.dataLbl.extY, false, false);
}
else if(this.selection.groupSelection.selection.chartSelection.selection.legend)
{
drawingDocument.DrawTrack(TYPE_TRACK_SHAPE, this.selection.groupSelection.selection.chartSelection.selection.legend.transform, 0, 0, this.selection.groupSelection.selection.chartSelection.selection.legend.extX, this.selection.groupSelection.selection.chartSelection.selection.legend.extY, false, false);
}
else if(this.selection.groupSelection.selection.chartSelection.selection.legendEntry)
{
drawingDocument.DrawTrack(TYPE_TRACK_SHAPE, this.selection.groupSelection.selection.chartSelection.selection.legendEntry.transform, 0, 0, this.selection.groupSelection.selection.chartSelection.selection.legendEntry.extX, this.selection.groupSelection.selection.chartSelection.selection.legendEntry.extY, false, false);
}
else if(this.selection.groupSelection.selection.chartSelection.selection.axisLbls)
{
drawingDocument.DrawTrack(TYPE_TRACK_SHAPE, this.selection.groupSelection.selection.chartSelection.selection.axisLbls.transform, 0, 0, this.selection.groupSelection.selection.chartSelection.selection.axisLbls.extX, this.selection.groupSelection.selection.chartSelection.selection.axisLbls.extY, false, false);
}
}
}
else
{
for(i = 0; i < this.selection.groupSelection.selectedObjects.length ; ++i)
......@@ -771,7 +813,6 @@ DrawingObjectsController.prototype =
drawingDocument.DrawTrack(TYPE_TRACK_SHAPE, this.selection.chartSelection.selection.axisLbls.transform, 0, 0, this.selection.chartSelection.selection.axisLbls.extX, this.selection.chartSelection.selection.axisLbls.extY, false, false);
}
}
}
else if(this.selection.wrapPolygonSelection)
{
......@@ -1648,7 +1689,6 @@ DrawingObjectsController.prototype =
var sRange = chartSettings.getRange();
if(this.drawingObjects && this.drawingObjects.getWorksheet && typeof sRange === "string" && sRange.length > 0)
{
var ws_view = this.drawingObjects.getWorksheet();
var parsed_formula = parserHelp.parse3DRef(sRange);
var ws = ws_view.model.workbook.getWorksheetByName(parsed_formula.sheet);
......@@ -1661,12 +1701,12 @@ DrawingObjectsController.prototype =
if( parsed_formula && ws && new_bbox )
{
var b_equal_bbox = chart_space.bbox.seriesBBox.r1 === new_bbox.r1
var b_equal_bbox = chart_space.bbox && chart_space.bbox.seriesBBox.r1 === new_bbox.r1
&& chart_space.bbox.seriesBBox.r2 === new_bbox.r2
&& chart_space.bbox.seriesBBox.c1 === new_bbox.c1
&& chart_space.bbox.seriesBBox.c2 === new_bbox.c2;
var b_equal_ws = chart_space.bbox.worksheet === ws;
var b_equal_vert = chartSettings.getInColumns() === !chart_space.bbox.seriesBBox.bVert;
var b_equal_ws = chart_space.bbox && chart_space.bbox.worksheet === ws;
var b_equal_vert = chart_space.bbox && chartSettings.getInColumns() === !chart_space.bbox.seriesBBox.bVert;
if(!(chart_space.bbox && chart_space.bbox.seriesBBox && b_equal_ws
&& b_equal_bbox && b_equal_vert))
......@@ -1695,7 +1735,6 @@ DrawingObjectsController.prototype =
asc_chart.rebuildSeries();
chart_space.rebuildSeriesFromAsc(asc_chart);
}
}
}
......@@ -2614,7 +2653,18 @@ DrawingObjectsController.prototype =
}
else if(this.selection.groupSelection && this.selection.groupSelection.selection.textSelection)
{
text_object = this.selection.groupSelection.selection.textSelection;
if(this.selection.groupSelection.selection.textSelection)
{
text_object = this.selection.groupSelection.selection.textSelection;
}
else if(this.selection.groupSelection.chartSelection && this.selection.groupSelection.chartSelection.textSelection)
{
text_object = this.selection.groupSelection.chartSelection.textSelection;
}
}
else if(this.selection.chartSelection && this.selection.chartSelection.selection.textSelection)
{
text_object = this.selection.chartSelection.selection.textSelection;
}
if(isRealObject(text_object))
{
......@@ -3770,14 +3820,22 @@ DrawingObjectsController.prototype =
getTargetTransform: function()
{
var content;
if(this.selection.textSelection)
{
return this.selection.textSelection.transformText;
}
else if(this.selection.groupSelection && this.selection.groupSelection.selection.textSelection)
else if(this.selection.groupSelection )
{
if(this.selection.groupSelection.selection.textSelection)
return this.selection.groupSelection.selection.textSelection.transformText;
else if(this.selection.groupSelection.selection.chartSelection && this.selection.groupSelection.selection.chartSelection.selection.textSelection)
{
return this.selection.groupSelection.selection.chartSelection.selection.textSelection.transformText;
}
}
else if(this.selection.chartSelection && this.selection.chartSelection.selection.textSelection)
{
return this.selection.groupSelection.selection.textSelection.transformText;
return this.selection.chartSelection.selection.textSelection.transformText;
}
return new CMatrix();
},
......
......@@ -227,6 +227,11 @@ function handleChart(drawing, drawingObjectsController, e, x, y, group, pageInde
}
}
if(drawing.chart.legend)
{
}
ret = handleShapeImage(drawing, drawingObjectsController, e, x, y, group, pageIndex, bWord);
if(ret)
return ret;
......
......@@ -12,6 +12,16 @@ function findPrAndRemove(arr, pr)
}
}
function removePtsFromLit(lit)
{
var i;
var start_idx = Array.isArray(lit.pts) ? lit.pts.length - 1 : (Array.isArray(lit.pt) ? lit.pt.length - 1 : -1);
for(i = start_idx; i > -1; --i)
{
lit.removeDPt(i);
}
}
function removeDPtsFromSeries(series)
{
......@@ -13571,6 +13581,15 @@ CNumLit.prototype =
{},
removeDPt: function(idx)
{
if(this.pts[idx])
{
History.Add(this, {Type: historyitem_CommonLit_RemoveDPt, idx: idx, pt: this.pts[idx]});
this.pts.splice(idx, 1);
}
},
createDuplicate: function()
{
var c = new CNumLit();
......@@ -13654,6 +13673,12 @@ CNumLit.prototype =
this.ptCount = data.oldPr;
break;
}
case historyitem_CommonLit_RemoveDPt:
{
this.pts.splice(data.idx, 0, data.pt);
break;
}
}
},
......@@ -13678,6 +13703,11 @@ CNumLit.prototype =
this.ptCount = data.newPr;
break;
}
case historyitem_CommonLit_RemoveDPt:
{
this.pts.splice(data.idx, 1);
break;
}
}
},
......@@ -13703,6 +13733,12 @@ CNumLit.prototype =
writeLong(w, data.newPr);
break;
}
case historyitem_CommonLit_RemoveDPt:
{
w.WriteLong(data.idx);
break;
}
}
},
......@@ -13732,6 +13768,12 @@ CNumLit.prototype =
this.ptCount = readLong(r);
break;
}
case historyitem_CommonLit_RemoveDPt:
{
var idx = r.GetLong();
this.pts.splice(idx, 1);
break;
}
}
}
};
......@@ -17580,6 +17622,16 @@ CStrCache.prototype =
Refresh_RecalcData: function()
{},
removeDPt: function(idx)
{
if(this.pt[idx])
{
History.Add(this, {Type: historyitem_CommonLit_RemoveDPt, idx: idx, pt: this.pt[idx]});
this.pt.splice(idx, 1);
}
},
createDuplicate: function()
{
var c = new CStrCache();
......@@ -17650,6 +17702,11 @@ CStrCache.prototype =
this.ptCount = data.oldPr;
break;
}
case historyitem_CommonLit_RemoveDPt:
{
this.pt.splice(data.idx, 0, data.pt);
break;
}
}
},
......@@ -17667,6 +17724,11 @@ CStrCache.prototype =
this.ptCount = data.newPr;
break;
}
case historyitem_CommonLit_RemoveDPt:
{
this.pt.splice(data.idx, 1);
break;
}
}
},
......@@ -17685,6 +17747,11 @@ CStrCache.prototype =
writeLong(w, data.newPr);
break;
}
case historyitem_CommonLit_RemoveDPt:
{
w.WriteLong(data.idx);
break;
}
}
},
......@@ -17707,6 +17774,13 @@ CStrCache.prototype =
this.ptCount = readLong(r);
break;
}
case historyitem_CommonLit_RemoveDPt:
{
var idx = r.GetLong();
this.pt.splice(idx, 1);
break;
}
}
}
};
......
......@@ -216,6 +216,8 @@ function CChartSpace()
plotArea: null
};
this.parsedFromulas = [];
this.setRecalculateInfo();
......@@ -233,6 +235,34 @@ CChartSpace.prototype =
select: CShape.prototype.select,
checkHitToBounds: CShape.prototype.checkHitToBounds,
getSelectionState: function()
{
return {
title: this.selection.title,
legend: this.selection.legend,
legendEntry: this.selection.legendEntry,
axisLbls: this.selection.axisLbls,
dataLbls: this.selection.dataLbls,
dataLbl: this.selection.dataLbl,
textSelection: this.selection.textSelection,
plotArea: this.selection.plotArea
}
},
setSelectionState: function(state)
{
this.selectiontitle = state.title;
this.selectionlegend = state.legend;
this.selectionlegendEntry = state.legendEntry;
this.selectionaxisLbls = state.axisLbls;
this.selectiondataLbls = state.dataLbls;
this.selectiondataLbl = state.dataLbl;
this.selectiontextSelection = state.textSelection;
this.selectionplotArea = state.plotArea;
},
resetInternalSelection: function()
{
if(this.selection.textSelection)
......@@ -256,7 +286,18 @@ CChartSpace.prototype =
this.selection.plotArea = null;
},
paragraphAdd: function(paraItem, bRecalculate)
{
if(paraItem.Type === para_TextPr)
{
//TODO
}
else
{
}
},
selectTitle: function(title, pageIndex)
{
......@@ -338,15 +379,211 @@ CChartSpace.prototype =
this.spPr.setLn(CorrectUniStroke(line, this.spPr.ln));
},
parseChartFormula: function(sFormula)
{
if(this.worksheet && typeof sFormula === "string" && sFormula.length > 0)
{
var ret = [];
var f1 = sFormula.replace(/\(|\)/g,"");
var arr_f = f1.split(",");
var i, j;
for(i = 0; i < arr_f.length; ++i)
{
var parsed_ref = parserHelp.parse3DRef(arr_f[i]);
if(parsed_ref)
{
var source_worksheet = this.worksheet.workbook.getWorksheetByName(parsed_ref.sheet);
var range1 = source_worksheet.getRange2(parsed_ref.range);
if(range1)
{
var range = range1.bbox;
ret.push({worksheet: source_worksheet, bbox: range});
}
}
}
return ret;
}
return null;
},
checkBBoxIntersection: function(bbox1, bbox2)
{
return !(bbox1.r1 > bbox2.r2 || bbox2.r1 > bbox1.r2 || bbox1.c1 > bbox2.c2 || bbox2.c1 > bbox1.c2)
},
checkSeriesIntersection: function(val, bbox, worksheet)
{
if(val && bbox && worksheet)
{
var parsed_formulas = val.parsedFormulas;
for(var i = 0; i < parsed_formulas.length; ++i)
{
if(parsed_formulas[i].worksheet === worksheet && this.checkBBoxIntersection(parsed_formulas[i].bbox, bbox))
{
return true;
}
}
}
return false;
},
checkVal: function(val)
{
if(val)
{
if(val.numRef)
{
val.numRef.parsedFormulas = this.parseChartFormula(val.numRef.f);
}
if(val.strRef)
{
val.strRef.parsedFormulas = this.parseChartFormula(val.strRef.f);
}
}
},
recalculateSeriesFormulas: function()
{
this.checkSeriesRefs(this.checkVal);
},
checkChartIntersection: function(bbox, worksheet)
{
return this.checkSeriesRefs(this.checkSeriesIntersection, bbox, worksheet);
},
checkSeriesRefs: function(callback, bbox, worksheet)
{
if(this.chart && this.chart.plotArea)
{
var charts = this.chart.plotArea.charts, i, j, series, ser;
for(i = 0; i < charts.length; ++i)
{
series = charts[i].series;
if(charts[i].getObjectType() === historyitem_type_ScatterChart)
{
for(j = 0; j < series.length; ++j)
{
ser = series[j];
if(callback(ser.xVal, bbox, worksheet))
return true;
if(callback(ser.yVal, bbox, worksheet))
return true;
if(callback(ser.tx, bbox, worksheet))
return true;
}
}
else
{
for(j = 0; j < series.length; ++j)
{
ser = series[j];
if(callback(ser.val, bbox, worksheet))
return true;
if(callback(ser.cat, bbox, worksheet))
return true;
if(callback(ser.tx, bbox, worksheet))
return true;
}
}
}
}
return false;
},
rebuildVal: function(val)
{
if(val)
{
var i, j, k, parsed_formula, idx, cell, pt, bbox, worksheet;
var buildCache = function (ref, cache, pointConstructor)
{
idx = 0;
removePtsFromLit(cache);
for(i = 0; i < ref.parsedFormulas.length; ++i)
{
parsed_formula = ref.parsedFormulas[i];
bbox = parsed_formula.bbox;
worksheet = parsed_formula.worksheet;
for(j = bbox.r1; j <= bbox.r2; ++j)
{
for(k = bbox.c1; k <= bbox.c2; ++k)
{
if(!worksheet._getCol(i).hd && !worksheet._getRow(row).hd)
{
cell = worksheet.getCell(new CellAddress(j, k, 0));
pt = new pointConstructor();
pt.setIdx(idx);
pt.setFormatCode(cell.getNumFormatStr());
pt.setVal(cell.getValue());
cache.addPt(pt);
}
++idx;
}
}
}
};
if(val.numRef)
{
if(!val.numRef.numCache)
{
val.numRef.setNumCache(new CNumLit());
}
if(Array.isArray(val.numRef.parsedFormulas))
{
buildCache(val.numRef, val.numRef.numCache, CNumericPoint);
}
}
if(val.strRef)
{
if(!val.strRef.strCache)
{
val.strRef.setStrCache(new CStrCache());
}
if(Array.isArray(val.strRef.parsedFormulas))
{
buildCache(val.strRef, val.strRef.strCache, CStringPoint);
}
}
}
},
clearCacheVal: function(val)
{
if(!val)
return;
if(val.numRef)
{
if(val.numRef.numCache)
{
val.numRef.setNumCache(null);
}
}
if(val.strRef)
{
if(val.strRef.strCache)
{
val.strRef.setStrCache(null);
}
}
},
rebuildSeries: function()
{
this.setRecalculateInfo();
this.checkSeriesRefs(this.clearCacheVal);
this.recalculate();
//this.checkSeriesRefs(this.rebuildVal);
},
getTypeSubType: function()
{
/*
*
*
normal: "normal",
stacked: "stacked",
stackedPer: "stackedPer"
*/
var type = null, subtype = null;
if(this.chart && this.chart.plotArea && this.chart.plotArea.chart)
{
......@@ -1859,7 +2096,7 @@ CChartSpace.prototype =
var range = range1.bbox;
if(range.r1 === range.r2)
{
for(j = range.c1; j < range.c2; ++j)
for(j = range.c1; j <= range.c2; ++j)
{
cell = source_worksheet.getCell( new CellAddress(range.r1, j, 0) );
pt = new CNumericPoint();
......@@ -1874,7 +2111,7 @@ CChartSpace.prototype =
}
else
{
for(j = range.r1; j < range.r2; ++j)
for(j = range.r1; j <= range.r2; ++j)
{
cell = source_worksheet.getCell( new CellAddress(j, range.c1, 0) );
pt = new CNumericPoint();
......@@ -1903,7 +2140,7 @@ CChartSpace.prototype =
var f1 = cat.strRef.f.replace(/\(|\)/g,"");
var arr_f = f1.split(",");
var str_cache = new CStrCache();
str_cache.setFormatCode("General");
//str_cache.setFormatCode("General");
var pt_index = 0, i, j, cell, pt;
for(i = 0; i < arr_f.length; ++i)
{
......@@ -1919,7 +2156,7 @@ CChartSpace.prototype =
var range = range1.bbox;
if(range.r1 === range.r2)
{
for(j = range.c1; j < range.c2; ++j)
for(j = range.c1; j <= range.c2; ++j)
{
cell = source_worksheet.getCell( new CellAddress(range.r1, j, 0) );
pt = new CStringPoint();
......@@ -1934,7 +2171,7 @@ CChartSpace.prototype =
}
else
{
for(j = range.r1; j < range.r2; ++j)
for(j = range.r1; j <= range.r2; ++j)
{
cell = source_worksheet.getCell(new CellAddress(j, range.c1, 0));
pt = new CStringPoint();
......@@ -1971,6 +2208,8 @@ CChartSpace.prototype =
//cat
checkValByNumRef(this, ser, ser.cat);
checkCatByNumRef(this, ser, ser.cat);
//tx
checkCatByNumRef(this, ser, ser.tx);
}
}
......@@ -1981,6 +2220,7 @@ CChartSpace.prototype =
ser = series[j];
checkValByNumRef(this, ser, ser.xVal);
checkValByNumRef(this, ser, ser.yVal);
checkCatByNumRef(this, ser, ser.tx);
}
}
}
......@@ -2055,9 +2295,6 @@ CChartSpace.prototype =
y_ax.labels.arrLabels.push(dlbl);
}
//пока расстояние между подписями и краем блока с подписями берем размер шрифта.
var hor_gap = y_ax.labels.arrLabels[0].tx.rich.content.Content[0].CompiledPr.Pr.TextPr.FontSize*(25.4/72);
y_ax.labels.extX = max_width + hor_gap;
......@@ -2507,9 +2744,6 @@ CChartSpace.prototype =
}
x_ax.xPoints = [];
for(i = 0; i < arr_x_val.length; ++i)
{
......@@ -2897,7 +3131,7 @@ CChartSpace.prototype =
for(i = 0; i < string_pts.length; ++i)
arr_cat_labels_points[i] = rect.x + val_ax.labels.extX + point_interval/2 + point_interval*i;
}
val_ax.posX = val_ax.labels.x + val_ax.labels.extX + point_interval*(crosses-1);;
val_ax.posX = val_ax.labels.x + val_ax.labels.extX + point_interval*(crosses-1);
}
else if(labels_pos === TICK_LABEL_POSITION_HIGH)//подписи справа от области построения
{
......
......@@ -6,6 +6,7 @@ var historyitem_AutoShapes_AddToDrawingObjects = 3;
var historyitem_AutoShapes_RemoveFromDrawingObjects = 4;
var historyitem_CommonChart_RemoveSeries = 5;
var historyitem_CommonSeries_RemoveDPt = 6;
var historyitem_CommonLit_RemoveDPt = 6;
var historyitem_ColorMod_SetName = 2001;
var historyitem_ColorMod_SetVal = 2002;
var historyitem_ColorModifiers_AddColorMod = 2003;
......
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