Commit 5fdce5ad 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@53430 954022d7-b5bf-4e40-9824-e11837661b57
parent c7652f03
......@@ -4,7 +4,7 @@ function CBandFmt()
this.spPr = null;
this.Id = g_oIdCounter.Get_NewId();
g_oIdCounter.Add(this, this.Id);
g_oTableId.Add(this, this.Id);
}
CBandFmt.prototype =
......
......@@ -19,7 +19,7 @@ function CChart()
this.view3D = null;
this.Id = g_oIdCounter.Get_NewId();
g_oIdCounter.Add(this, this.Id);
g_oTableId.Add(this, this.Id);
}
CChart.prototype =
......
......@@ -1711,8 +1711,7 @@ CPageSetup.prototype =
}
};
function CreateDefaultLineNormalChart(asc_series)
function CreateLineChart(asc_series, type)
{
var chart_space = new CChartSpace();
chart_space.setDate1904(false);
......@@ -1725,58 +1724,30 @@ function CreateDefaultLineNormalChart(asc_series)
chart.setPlotArea(new CPlotArea());
chart.setLegend(new CLegend());
chart.setPlotVisOnly(true);
chart.setDispBlanksAs(DISP_BLANKS_AS_GAP);
var disp_blanks_as;
if(type === GROUPING_STANDARD)
{
disp_blanks_as = DISP_BLANKS_AS_GAP;
}
else
{
disp_blanks_as = DISP_BLANKS_AS_ZERO;
}
chart.setDispBlanksAs(disp_blanks_as);
chart.setShowDLblsOverMax(false);
var plot_area = chart.plotArea;
plot_area.setLayout(new CLayout());
plot_area.setChart(new CLineChart());
plot_area.setCatAx(new CAxis());
plot_area.setValAx(new CAxis());
var cat_ax = plot_area.catAx;
cat_ax.setScaling(new CScaling());
cat_ax.setDelete(false);
cat_ax.setAxPos(AX_POS_B);
cat_ax.setMajorTickMark(TICK_MARK_OUT);
cat_ax.setMinorTickMark(TICK_MARK_NONE);
cat_ax.setTickLblPos(TICK_LABEL_POSITION_NEXT_TO);
cat_ax.setCrosses(CROSSES_AUTO_ZERO);
cat_ax.setAuto(true);
cat_ax.setLblAlgn(LBL_ALG_CTR);
cat_ax.setLblOffset(100);
cat_ax.setNoMultiLvlLbl(false);
var scaling = cat_ax.scaling;
scaling.setOrientation(ORIENTATION_MIN_MAX);
var val_ax = plot_area.valAx;
val_ax.setScaling(new CScaling());
val_ax.setDelete(false);
val_ax.setAxPos(AX_POS_L);
val_ax.setMajorGridlines(new CSpPr());
val_ax.setNumFmt(new CNumFmt());
val_ax.setMajorTickMark(TICK_MARK_OUT);
val_ax.setMinorTickMark(TICK_MARK_NONE);
val_ax.setTickLblPos(TICK_LABEL_POSITION_NEXT_TO);
val_ax.setCrossAx(cat_ax.Get_Id());
val_ax.setCrosses(CROSSES_AUTO_ZERO);
val_ax.setCrossBetween(CROSS_BETWEEN_BETWEEN);
cat_ax.setCrossAx(val_ax.Get_Id());
scaling = val_ax.scaling;
scaling.setOrientation(ORIENTATION_MIN_MAX);
var legend = chart.legend;
legend.setLegendPos(LEGEND_POS_R);
legend.setLayout(new CLayout());
legend.setOverlay(false);
var line_chart = plot_area.chart;
line_chart.setGrouping(GROUPING_STANDARD);
line_chart.setGrouping(type);
line_chart.setVaryColors(false);
line_chart.setDLbls(new CDLbls());
line_chart.setMarker(true);
line_chart.setSmooth(false);
line_chart.addAxId(cat_ax.Get_Id());
line_chart.addAxId(val_ax.Get_Id());
line_chart.addAxId(plot_area.catAx.Get_Id());
line_chart.addAxId(plot_area.valAx.Get_Id());
for(var i = 0; i < asc_series.length; ++i)
{
var series = new CLineSeries();
......@@ -1785,61 +1756,24 @@ function CreateDefaultLineNormalChart(asc_series)
series.setMarker(new CMarker());
series.marker.setSymbol(SYMBOL_NONE);
series.setSmooth(false);
series.setVal(new CYVal());
var val = series.val;
val.setNumRef(new CNumRef());
var num_ref = val.numRef;
num_ref.setF(asc_series[i].Val.Formula);
num_ref.setNumCache(new CNumLit());
var num_cache = num_ref.numCache;
num_cache.setPtCount(asc_series[i].Val.NumCache.length);
for(var j = 0; j < asc_series[i].Val.NumCache.length; ++j)
{
var pt = new CNumericPoint();
pt.setIdx(j);
pt.setFormatCode(asc_series[i].Val.NumCache[j].numFormatStr);
pt.setVal(asc_series[i].Val.NumCache[j].val);
num_cache.addPt(pt);
}
line_chart.addSer(series);
}
var d_lbls = line_chart.dLbls;
d_lbls.setShowLegendKey(false);
d_lbls.setShowVal(false);
d_lbls.setShowCatName(false);
d_lbls.setShowSerName(false);
d_lbls.setShowPercent(false);
d_lbls.setShowBubbleSize(false);
var print_settings = chart_space.printSettings;
print_settings.setHeaderFooter(new CHeaderFooterChart());
print_settings.setPageMargins(new CPageMarginsChart());
var page_margins = print_settings.pageMargins;
page_margins.setB(0.75);
page_margins.setL(0.7);
page_margins.setR(0.7);
page_margins.setT(0.75);
page_margins.setHeader(0.3);
page_margins.setFooter(0.3);
page_margins.setPageSetup(new CPageSetup());
return chart_space;
}
function CreateDefaultLineStackedChart()
{
var chart_space = new CChartSpace();
chart_space.setDate1904(false);
chart_space.setLang("ru-RU");
chart_space.setRoundedCorners(false);
chart_space.setChart(new CChart());
chart_space.setPrintSettings(new CPrintSettings());
var chart = chart_space.chart;
chart.setAutoTitleDeleted(false);
chart.setPlotArea(new CPlotArea());
chart.setLegend(new CLegend());
chart.setPlotVisOnly(true);
chart.setDispBlanksAs(DISP_BLANKS_AS_ZERO);
chart.setShowDLblsOverMax(false);
var plot_area = chart.plotArea;
plot_area.setLayout(new CLayout());
plot_area.setChart(new CLineChart());
plot_area.setCatAx(new CAxis());
plot_area.setValAx(new CAxis());
var line_chart = plot_area.chart;
line_chart.setGrouping(GROUPING_STACKED);
line_chart.setVaryColors(false);
line_chart.setDLbls(new CDLbls());
line_chart.setMarker(true);
line_chart.setSmooth(false);
line_chart.addAxId(plot_area.catAx);
line_chart.addAxId(plot_area.valAx);
var d_lbls = line_chart.dLbls;
d_lbls.setShowLegendKey(false);
d_lbls.setShowVal(false);
......@@ -1847,15 +1781,14 @@ function CreateDefaultLineStackedChart()
d_lbls.setShowSerName(false);
d_lbls.setShowPercent(false);
d_lbls.setShowBubbleSize(false);
var cat_ax = plot_area.catAx;
cat_ax.setScaling(new CScaling());
cat_ax.setDelete(false);
cat_ax.setAxPos(AX_POS_B);
cat_ax.setMajorTickMark(TICK_MARK_OUT);
cat_ax.setMinorTickMark(TICK_MARK_NONE);
cat_ax.setMinorTickMark(TICK_MARK_OUT);
cat_ax.setTickLblPos(TICK_LABEL_POSITION_NEXT_TO);
cat_ax.setCrossAx(line_chart.valAx.Get_Id());
cat_ax.setCrossAx(plot_area.valAx.Get_Id());
cat_ax.setCrosses(CROSSES_AUTO_ZERO);
cat_ax.setAuto(true);
cat_ax.setLblAlgn(LBL_ALG_CTR);
......@@ -1863,7 +1796,6 @@ function CreateDefaultLineStackedChart()
cat_ax.setNoMultiLvlLbl(false);
var scaling = cat_ax.scaling;
scaling.setOrientation(ORIENTATION_MIN_MAX);
var val_ax = plot_area.valAx;
val_ax.setScaling(new CScaling());
val_ax.setDelete(false);
......@@ -1873,18 +1805,36 @@ function CreateDefaultLineStackedChart()
val_ax.setMajorTickMark(TICK_MARK_OUT);
val_ax.setMinorTickMark(TICK_MARK_NONE);
val_ax.setTickLblPos(TICK_LABEL_POSITION_NEXT_TO);
val_ax.setCrossAx(cat_ax.Get_Id());
val_ax.setCrossAx(plot_area.catAx);
val_ax.setCrosses(CROSSES_AUTO_ZERO);
val_ax.setCrossBetween(CROSS_BETWEEN_BETWEEN);
scaling = val_ax.scaling;
scaling.setOrientation(ORIENTATION_MIN_MAX);
var num_fmt = val_ax.numFmt;
num_fmt.setFormatCode("General");
var format_code;
if(type === GROUPING_PERCENT_STACKED)
{
format_code = "0%";
}
else
{
format_code = "General";
}
num_fmt.setFormatCode(format_code);
num_fmt.setSourceLinked(true);
var legend = chart.legend;
legend.setLegendPos(LEGEND_POS_R);
legend.setLayout(new CLayout());
legend.setOverlay(false);
return chart_space;
var print_settings = chart_space.printSettings;
print_settings.setHeaderFooter(new CHeaderFooterChart());
print_settings.setPageMargins(new CPageMarginsChart());
print_settings.setPageSetup(new CPageSetup());
var page_margins = print_settings.pageMargins;
page_margins.setB(0.75);
page_margins.setL(0.7);
page_margins.setR(0.7);
page_margins.setT(0.75);
page_margins.setHeader(0.3);
page_margins.setFooter(0.3);
}
\ No newline at end of file
......@@ -302,7 +302,7 @@ var historyitem_ErrBars_SetVal = 2296;
var historyitem_MinusPlus_SetnNumLit = 2297;
var historyitem_MinusPlus_SetnNumRef = 2298;
var historyitem_NumLit_SetFormatCode = 2299;
var historyitem_NumLit_SetPt = 2300;
var historyitem_NumLit_AddPt = 2300;
var historyitem_NumLit_SetPtCount = 2301;
var historyitem_NumericPoint_SetFormatCode = 2302;
var historyitem_NumericPoint_SetIdx = 2303;
......@@ -466,7 +466,7 @@ var historyitem_SpPr_SetXfrm = 2458;
var historyitem_SpPr_SetGeometry = 2459;
var historyitem_SpPr_SetFill = 2460;
var historyitem_SpPr_SetLn = 2461;
var historyitem_ClrScheme_SetClr = 2462;
var historyitem_ClrScheme_AddClr = 2462;
var historyitem_ClrScheme_SetName = 2463;
var historyitem_ClrMap_SetClr = 2464;
var historyitem_ExtraClrScheme_SetClrScheme = 2465;
......@@ -523,6 +523,13 @@ var historyitem_PageSetupSetPaperSize = 2515;
var historyitem_PageSetupSetPaperWidth = 2516;
var historyitem_PageSetupSetUseFirstPageNumb = 2517;
var historyitem_PageSetupSetVerticalDpi = 2518;
var historyitem_ShapeSetNvSpPr = 2519;
var historyitem_ShapeSetSpPr = 2520;
var historyitem_ShapeSetStyle = 2521;
var historyitem_ShapeSetTxBody = 2522;
var historyitem_ShapeSetTextBoxContent = 2523;
var historyitem_ShapeSetParent = 2524;
var historyitem_ShapeSetGroup = 2525;
var historyitem_type_ColorMod = 1001;
var historyitem_type_ColorModifiers = 1002;
......@@ -627,6 +634,7 @@ var historyitem_type_PrintSettings = 1099;
var historyitem_type_HeaderFooterChart = 1100;
var historyitem_type_PageMarginsChart = 1101;
var historyitem_type_PageSetup = 1102;
var historyitem_type_Shape = 1103;
......
......@@ -1492,11 +1492,11 @@ CUniColor.prototype =
{
if(r.GetBool())
{
this.Mods = = g_oTableId.Get_ById(r.GetString2());
this.Mods = g_oTableId.Get_ById(r.GetString2());
}
else
{
thos.Mods = null;
this.Mods = null;
}
break;
}
......@@ -3813,7 +3813,7 @@ EndArrow.prototype =
Read_FromBinary2: function (r)
{
this.Id = r.GetString2();
}
},
getObjectType: function()
{
......@@ -4726,7 +4726,7 @@ DefaultShapeDefinition.prototype=
Undo: function(data)
{
switch()
switch(data.Type)
{
case historyitem_DefaultShapeDefinition_SetSpPr:
{
......@@ -4753,7 +4753,7 @@ DefaultShapeDefinition.prototype=
Redo: function(data)
{
switch()
switch(data.Type)
{
case historyitem_DefaultShapeDefinition_SetSpPr:
{
......@@ -6742,7 +6742,7 @@ function CSpPr()
this.Geometry = null;//new Geometry();
this.Fill = null;
this.ln = null;
this.parent = null;
this.merge = function(spPr)
{
/*if(spPr.xfrm != null)
......@@ -7063,9 +7063,9 @@ ClrScheme.prototype =
this.name = name;
},
setColor: function(index, color)
addColor: function(index, color)
{
History.Add(this, {Type: historyitem_ClrScheme_SetClr, index: index, newColor: color, oldColor: this.colors[index]});
History.Add(this, {Type: historyitem_ClrScheme_AddClr, index: index, newColor: color, oldColor: this.colors[index]});
this.colors[index] = color;
},
......@@ -7078,7 +7078,7 @@ ClrScheme.prototype =
this.name = data.oldPr;
break;
}
case historyitem_ClrScheme_SetClr:
case historyitem_ClrScheme_AddClr:
{
this.colors[data.index] = data.oldColor;
}
......@@ -7094,7 +7094,7 @@ ClrScheme.prototype =
this.name = data.newPr;
break;
}
case historyitem_ClrScheme_SetClr:
case historyitem_ClrScheme_AddClr:
{
this.colors[data.index] = data.newColor;
}
......@@ -7111,7 +7111,7 @@ ClrScheme.prototype =
writeString(w, data.newPr);
break;
}
case historyitem_ClrScheme_SetClr:
case historyitem_ClrScheme_AddClr:
{
writeLong(w, data.index);
writeOject(w, data.newColor);
......@@ -7129,7 +7129,7 @@ ClrScheme.prototype =
this.name = readString(r);
break;
}
case historyitem_ClrScheme_SetClr:
case historyitem_ClrScheme_AddClr:
{
var index = readLong(r);
var color = readObject(r);
......@@ -7161,6 +7161,9 @@ function ClrMap()
return _copy;
};
this.Id = g_oIdCounter.Get_NewId();
g_oTableId.Add(this, this.Id);
}
ClrMap.prototype =
......
......@@ -14,7 +14,6 @@ function CLineChart()
this.upDownBars = null;
this.varyColors = null;
this.Id = g_oIdCounter.Get_NewId();
g_oTableId.Add(this, this.Id);
}
......@@ -136,24 +135,31 @@ CLineChart.prototype =
this.marker = data.oldPr;
break
}
case historyitem_LineChart_SetSer:
case historyitem_LineChart_AddSer:
{
for(var i = this.series.length - 1; i > -1; --i)
{
if(this.series[i] === data.ser)
{
this.series = data.oldPr;
this.series.splice(i, 1);
break;
}
}
break
}
case historyitem_LineChart_SetSmooth:
{
this.axId = data.oldPr;
this.smooth = data.oldPr;
break
}
case historyitem_LineChart_SetUpDownBars:
{
this.axId = data.oldPr;
this.upDownBars = data.oldPr;
break
}
case historyitem_LineChart_SetVaryColors:
{
this.axId = data.oldPr;
this.varyColors = data.oldPr;
break
}
}
......@@ -195,22 +201,22 @@ CLineChart.prototype =
}
case historyitem_LineChart_AddSer:
{
this.series = data.newPr;
this.series.push(data.ser);
break
}
case historyitem_LineChart_SetSmooth:
{
this.axId = data.newPr;
this.smooth = data.newPr;
break
}
case historyitem_LineChart_SetUpDownBars:
{
this.axId = data.newPr;
this.upDownBars = data.newPr;
break
}
case historyitem_LineChart_SetVaryColors:
{
this.axId = data.newPr;
this.varyColors = data.newPr;
break
}
}
......
function CNumLit()
{
this.formatCode = null;
this.pt = null;
this.pts = [];
this.ptCount = null;
this.Id = g_oIdCounter.Get_NewId();
......@@ -37,15 +37,15 @@ CNumLit.prototype =
this.formatCode = pr;
},
setPt: function(pr)
addPt: function(pr)
{
History.Add(this, {Type:historyitem_NumLit_SetPt, oldPr: this.pt, newPr: pr});
this.pt = pr;
History.Add(this, {Type:historyitem_NumLit_AddPt, pt: pr});
this.pts.push(pr);
},
setPtCount: function(pr)
{
History.Add(this, {Type:historyitem_NumLit_SetPt, oldPr: this.pt, newPr: pr});
History.Add(this, {Type:historyitem_NumLit_SetPtCount, oldPr: this.pts, newPr: pr});
this.ptCount = pr;
},
......@@ -59,9 +59,15 @@ CNumLit.prototype =
break;
}
case historyitem_NumLit_SetPt:
case historyitem_NumLit_AddPt:
{
this.pt = data.oldPr;
for(var i = this.pts.length - 1; i > -1; --i)
{
if(this.pts[i] === data.pt)
{
this.pts.splice(i, 1);
}
}
break;
}
......@@ -83,9 +89,9 @@ CNumLit.prototype =
break;
}
case historyitem_NumLit_SetPt:
case historyitem_NumLit_AddPt:
{
this.pt = data.newPr;
this.pts.push(data.newPr);
break;
}
......@@ -104,31 +110,19 @@ CNumLit.prototype =
{
case historyitem_NumLit_SetFormatCode:
{
w.WriteBool(typeof data.newPr === "string");
if(typeof data.newPr === "string")
{
w.WriteString2(data.newPr);
}
writeString(w, data.newPr);
break;
}
case historyitem_NumLit_SetPt:
case historyitem_NumLit_AddPt:
{
w.WriteBool(isRealObject(data.newPr));
if(isRealObject(data.newPr))
{
w.WriteString2(data.newPr.Get_Id());
}
writeObject(w, data.pt);
break;
}
case historyitem_NumLit_SetPtCount:
{
w.WriteBool(isRealNumber(data.newPr));
if(isRealNumber(data.newPr))
{
w.WriteLong(data.newPr);
}
writeLong(w, data.newPr);
break;
}
}
......@@ -141,40 +135,23 @@ CNumLit.prototype =
{
case historyitem_NumLit_SetFormatCode:
{
if(r.GetBool())
{
this.formatCode = r.GetString2();
}
else
{
this.formatCode = null;
}
this.formatCode = readString(r);
break;
}
case historyitem_NumLit_SetPt:
{
if(r.GetBool())
case historyitem_NumLit_AddPt:
{
this.pt = g_oTableId.Get_ById(r.GetString2());
}
else
var pt = readObject(r);
if(isRealObject(pt))
{
this.pt = null;
this.pts.push(pt);
}
break;
}
case historyitem_NumLit_SetPtCount:
{
if(r.GetBool())
{
this.ptCount = r.GetLong();
}
else
{
this.ptCount = null;
}
this.ptCount = readLong(r);
break;
}
}
......
......@@ -11,7 +11,7 @@ function CPictureOptions()
this.pictureStackUnit = null;
this.Id = g_oIdCounter.Get_NewId();
g_oIdCounter.Add(this, this.Id);
g_oTableId.Add(this, this.Id);
}
CPictureOptions.prototype =
......
This diff is collapsed.
......@@ -798,6 +798,28 @@ DrawingObjectsController.prototype =
addChartDrawingObject: function(chart, options)
{
switch (chart.type)
{
case "Line":
{
switch (chart.subType)
{
case "normal":
{
return CreateLineChart(chart.series, GROUPING_STANDARD);
}
case "stacked":
{
return CreateLineChart(chart.series, GROUPING_STACKED);
}
case "stackedPer":
{
return CreateLineChart(chart.series, GROUPING_PERCENT_STACKED);
}
}
break;
}
}
var chart_as_group = new CChartAsGroup(null, this.drawingObjects);
chart_as_group.initFromChartObject(chart, options);
this.resetSelectionState();
......
......@@ -29,6 +29,13 @@ function CChartAsGroup(drawingBase, drawingObjects)
this.invertTransform = new CMatrix();
this.group = null;
this.rot = 0;
this.bounds =
{
x: 0,
y: 0,
w: 0,
h: 0
};
this.recalculateInfo =
{
recalculateAll: true
......@@ -46,7 +53,6 @@ function CChartAsGroup(drawingBase, drawingObjects)
}
}
CChartAsGroup.prototype =
{
calculateContent: function()
......@@ -89,6 +95,8 @@ CChartAsGroup.prototype =
return ret;
},
getBoundsInGroup: function()
{
......@@ -148,6 +156,22 @@ CChartAsGroup.prototype =
this.recalculate();
},
recalculateBounds: function()
{
try
{
var boundsChecker = new CSlideBoundsChecker();
this.draw(boundsChecker);
boundsChecker.CorrectBounds();
this.bounds.x = boundsChecker.Bounds.min_x;
this.bounds.y = boundsChecker.Bounds.min_y;
this.bounds.w = boundsChecker.Bounds.max_x - boundsChecker.Bounds.min_x;
this.bounds.h = boundsChecker.Bounds.max_y - boundsChecker.Bounds.min_y;
}
catch(e)
{}
},
isChart: function()
{
return true;
......@@ -1375,6 +1399,7 @@ CChartAsGroup.prototype =
this.brush.fill.canvas= this.drawingObjects.getChartRender().insertChart(this.chart, this.drawingObjects.convertMetric(this.extX, 3, 0),this.drawingObjects.convertMetric(this.extY, 3, 0));
this.brush.fill.RasterImageId = "";
this.updateDrawingBaseCoordinates();
this.recalculateBounds();
//this.drawingObjects.loadImageRedraw(this.brush.fill.RasterImageId);
},
......
......@@ -19,6 +19,7 @@ function CGroupShape(drawingBase, drawingObjects)
recalculateArrGraphicObjects: true
};
this.x = null;
this.y = null;
this.x = null;
......@@ -33,7 +34,13 @@ function CGroupShape(drawingBase, drawingObjects)
this.transformText = null;
this.invertTransformText = null;
this.cursorTypes = [];
this.bounds =
{
x: 0,
y: 0,
w: 0,
h: 0
};
this.brush = null;
this.pen = null;
this.selected = false;
......@@ -81,6 +88,22 @@ CGroupShape.prototype =
},
recalculateBounds: function()
{
try
{
var boundsChecker = new CSlideBoundsChecker();
this.draw(boundsChecker);
boundsChecker.CorrectBounds();
this.bounds.x = boundsChecker.Bounds.min_x;
this.bounds.y = boundsChecker.Bounds.min_y;
this.bounds.w = boundsChecker.Bounds.max_x - boundsChecker.Bounds.min_x;
this.bounds.h = boundsChecker.Bounds.max_y - boundsChecker.Bounds.min_y;
}
catch(e)
{}
},
setDrawingObjects: function(drawingObjects)
{
if ( isRealObject(drawingObjects) && drawingObjects.getWorksheet() )
......@@ -642,6 +665,7 @@ CGroupShape.prototype =
{
this.arrGraphicObjects[i].recalculate(aImages);
}
this.recalculateBounds();
},
recalculateArrGraphicObjects: function()
......@@ -713,6 +737,7 @@ CGroupShape.prototype =
if(typeof this.spTree[i].calculateTransformTextMatrix === "function")
this.spTree[i].calculateTransformTextMatrix();
}
this.recalculateBounds();
},
setPaddings: function(paddings)
......
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