Commit 243be54d authored by SergeyLuzyanin's avatar SergeyLuzyanin

fix bugs with bullets; add to builder for chart style apply

parent 48552ab3
...@@ -440,7 +440,7 @@ ...@@ -440,7 +440,7 @@
settings.style = nStyleIndex; settings.style = nStyleIndex;
settings.inColumns = !bInRows; settings.inColumns = !bInRows;
settings.range = sDataRange; settings.range = sDataRange;
var oChart = AscFormat.DrawingObjectsController.prototype.getChartSpace(this.worksheet, settings); var oChart = AscFormat.DrawingObjectsController.prototype.getChartSpace(this.worksheet, settings, true);
if(arguments.length === 8){//support old variant if(arguments.length === 8){//support old variant
oChart.setBDeleted(false); oChart.setBDeleted(false);
oChart.setWorksheet(this.worksheet); oChart.setWorksheet(this.worksheet);
...@@ -1200,6 +1200,23 @@ ...@@ -1200,6 +1200,23 @@
ApiChart.prototype.SetVertAxisLablesFontSize = function(nFontSize){ ApiChart.prototype.SetVertAxisLablesFontSize = function(nFontSize){
AscFormat.builder_SetVerAxisFontSize(this.Chart, nFontSize); AscFormat.builder_SetVerAxisFontSize(this.Chart, nFontSize);
}; };
/**
* Apply set of visual settings for chart
* @param {number} nStyleIndex
*/
ApiChart.prototype.ApplyChartStyle = function(nStyleIndex){
if(this.Chart){
var chart = this.Chart.chart;
var plot_area = chart.plotArea;
var oCurChartSettings = AscFormat.DrawingObjectsController.prototype.getPropsFromChart.call(null, this.Chart);
var _cur_type = oCurChartSettings.type;
if(AscCommon.g_oChartPresets[_cur_type] && AscCommon.g_oChartPresets[_cur_type][nStyleIndex]){
plot_area.removeCharts(1, plot_area.charts.length - 1);
AscFormat.ApplyPresetToChartSpace(this.Chart, AscCommon.g_oChartPresets[_cur_type][nStyleIndex], false);
return;
}
}
};
/** /**
...@@ -1284,8 +1301,9 @@ ...@@ -1284,8 +1301,9 @@
ApiChart.prototype["SetMinorVerticalGridlines"] = ApiChart.prototype.SetMinorVerticalGridlines; ApiChart.prototype["SetMinorVerticalGridlines"] = ApiChart.prototype.SetMinorVerticalGridlines;
ApiChart.prototype["SetMajorHorizontalGridlines"] = ApiChart.prototype.SetMajorHorizontalGridlines; ApiChart.prototype["SetMajorHorizontalGridlines"] = ApiChart.prototype.SetMajorHorizontalGridlines;
ApiChart.prototype["SetMinorHorizontalGridlines"] = ApiChart.prototype.SetMinorHorizontalGridlines; ApiChart.prototype["SetMinorHorizontalGridlines"] = ApiChart.prototype.SetMinorHorizontalGridlines;
ApiChart.prototype["SetHorAxisLablesFontSize"] = ApiChart.prototype.SetHorAxisLablesFontSize; ApiChart.prototype["SetHorAxisLablesFontSize"] = ApiChart.prototype.SetHorAxisLablesFontSize;
ApiChart.prototype["SetVertAxisLablesFontSize"] = ApiChart.prototype.SetVertAxisLablesFontSize; ApiChart.prototype["SetVertAxisLablesFontSize"] = ApiChart.prototype.SetVertAxisLablesFontSize;
ApiChart.prototype["ApplyChartStyle"] = ApiChart.prototype.ApplyChartStyle;
ApiColor.prototype["GetClassType"] = ApiColor.prototype.GetClassType; ApiColor.prototype["GetClassType"] = ApiColor.prototype.GetClassType;
......
...@@ -347,7 +347,7 @@ DrawingObjectsController.prototype.handleOleObjectDoubleClick = function(drawing ...@@ -347,7 +347,7 @@ DrawingObjectsController.prototype.handleOleObjectDoubleClick = function(drawing
DrawingObjectsController.prototype.addChartDrawingObject = function(options) DrawingObjectsController.prototype.addChartDrawingObject = function(options)
{ {
History.Create_NewPoint(); History.Create_NewPoint();
var chart = this.getChartSpace(this.drawingObjects.getWorksheetModel(), options); var chart = this.getChartSpace(this.drawingObjects.getWorksheetModel(), options, true);
if(chart) if(chart)
{ {
chart.setWorksheet(this.drawingObjects.getWorksheetModel()); chart.setWorksheet(this.drawingObjects.getWorksheetModel());
......
...@@ -4879,10 +4879,10 @@ DrawingObjectsController.prototype = ...@@ -4879,10 +4879,10 @@ DrawingObjectsController.prototype =
return null; return null;
}, },
getChartSpace: function(worksheet, options) getChartSpace: function(worksheet, options, bUseCache)
{ {
var chartSeries = AscFormat.getChartSeries(worksheet, options); var chartSeries = AscFormat.getChartSeries(worksheet, options);
return this._getChartSpace(chartSeries, options); return this._getChartSpace(chartSeries, options, bUseCache);
}, },
getChartSpace2: function(chart, options) getChartSpace2: function(chart, options)
...@@ -10393,15 +10393,35 @@ function ApplyPresetToChartSpace(oChartSpace, aPreset, bCreate){ ...@@ -10393,15 +10393,35 @@ function ApplyPresetToChartSpace(oChartSpace, aPreset, bCreate){
} }
var oChart = oPlotArea.charts[0], base_fills; var oChart = oPlotArea.charts[0], base_fills;
var ser, lit = null, val = null;
ApplyDLblsProps(aPreset[10], oChart, oDrawingDocument, undefined, undefined, bCreate); ApplyDLblsProps(aPreset[10], oChart, oDrawingDocument, undefined, undefined, bCreate);
for(i = 0; i < oChart.series.length; ++i){ for(i = 0; i < oChart.series.length; ++i){
var pts = AscFormat.getPtsFromSeries(oChart.series[i]); lit = null;
ser = oChart.series[i];
val = ser.val || ser.yVal;
var pts = AscFormat.getPtsFromSeries(ser);
if(val){
if(val.numRef && val.numRef.numCache)
{
lit = val.numRef.numCache;
}
else if(val.numLit)
{
lit = val.numLit;
}
}
var ptCount;
if(lit && AscFormat.isRealNumber(lit.ptCount)){
ptCount = Math.max(lit.ptCount, AscFormat.getMaxIdx(pts));
}
else{
ptCount = AscFormat.getMaxIdx(pts);
}
var oDPt; var oDPt;
if(oChart.getObjectType() === AscDFH.historyitem_type_PieChart || oChart.getObjectType() === AscDFH.historyitem_type_DoughnutChart){ if(oChart.getObjectType() === AscDFH.historyitem_type_PieChart || oChart.getObjectType() === AscDFH.historyitem_type_DoughnutChart){
base_fills = AscFormat.getArrayFillsFromBase(style.fill2, AscFormat.getMaxIdx(pts)); base_fills = AscFormat.getArrayFillsFromBase(style.fill2, ptCount);
for(j = 0; j < pts.length; ++j){ for(j = 0; j < ptCount; ++j){
oDPt = null; oDPt = null;
if(oChart.series[i].getDptByIdx){ if(oChart.series[i].getDptByIdx){
oDPt = oChart.series[i].getDptByIdx(j); oDPt = oChart.series[i].getDptByIdx(j);
...@@ -10417,7 +10437,7 @@ function ApplyPresetToChartSpace(oChartSpace, aPreset, bCreate){ ...@@ -10417,7 +10437,7 @@ function ApplyPresetToChartSpace(oChartSpace, aPreset, bCreate){
oChart.series[i].addDPt(oDPt); oChart.series[i].addDPt(oDPt);
} }
for (j = 0; j < oChart.series[i].dPt.length; ++j ){ for (j = 0; j < oChart.series[i].dPt.length; ++j ){
if(oChart.series[i].dPt[j].idx >= pts.length){ if(oChart.series[i].dPt[j].idx >= ptCount){
oChart.series[i].removeDPt(j); oChart.series[i].removeDPt(j);
} }
} }
...@@ -10432,12 +10452,12 @@ function ApplyPresetToChartSpace(oChartSpace, aPreset, bCreate){ ...@@ -10432,12 +10452,12 @@ function ApplyPresetToChartSpace(oChartSpace, aPreset, bCreate){
if(oChart.getObjectType() === AscDFH.historyitem_type_PieChart || oChart.getObjectType() === AscDFH.historyitem_type_DoughnutChart){ if(oChart.getObjectType() === AscDFH.historyitem_type_PieChart || oChart.getObjectType() === AscDFH.historyitem_type_DoughnutChart){
ApplyDLblsProps(aPreset[12], oChart.series[i], oDrawingDocument, i, base_fills, true); ApplyDLblsProps(aPreset[12], oChart.series[i], oDrawingDocument, i, base_fills, true);
if(oChart.series[i].dLbls){ if(oChart.series[i].dLbls){
for(var j = 0; j < pts.length; ++j){ for(var j = 0; j < ptCount; ++j){
var oDLbl = oChart.series[i].dLbls.findDLblByIdx(pts[j].idx); var oDLbl = oChart.series[i].dLbls.findDLblByIdx(j);
if(!oDLbl){ if(!oDLbl){
oDLbl = new AscFormat.CDLbl(); oDLbl = new AscFormat.CDLbl();
oChart.series[i].dLbls.addDLbl(oDLbl); oChart.series[i].dLbls.addDLbl(oDLbl);
oDLbl.setIdx(pts[j].idx); oDLbl.setIdx(j);
ApplyTxPr(aPreset[12][0], oDLbl, oDrawingDocument, j, base_fills, bAccent1Background); ApplyTxPr(aPreset[12][0], oDLbl, oDrawingDocument, j, base_fills, bAccent1Background);
ApplySpPr(aPreset[12][1], oDLbl, j, base_fills, bAccent1Background); ApplySpPr(aPreset[12][1], oDLbl, j, base_fills, bAccent1Background);
oDLbl.setDLblPos(aPreset[12][2]); oDLbl.setDLblPos(aPreset[12][2]);
......
...@@ -1994,7 +1994,7 @@ Paragraph.prototype.Internal_Draw_4 = function(CurPage, pGraphics, Pr, BgColor, ...@@ -1994,7 +1994,7 @@ Paragraph.prototype.Internal_Draw_4 = function(CurPage, pGraphics, Pr, BgColor,
if (Pr.ParaPr.Ind.FirstLine < 0) if (Pr.ParaPr.Ind.FirstLine < 0)
NumberingItem.Draw(X, Y, pGraphics, this.Get_FirstTextPr(), PDSE); NumberingItem.Draw(X, Y, pGraphics, this.Get_FirstTextPr(), PDSE);
else else
NumberingItem.Draw(this.X + Pr.ParaPr.Ind.Left, Y, pGraphics, this.Get_FirstTextPr(), PDSE); NumberingItem.Draw(this.Pages[CurPage].X + Pr.ParaPr.Ind.Left, Y, pGraphics, this.Get_FirstTextPr(), PDSE);
} }
} }
......
...@@ -2995,9 +2995,9 @@ CParagraphRecalculateStateWrap.prototype = ...@@ -2995,9 +2995,9 @@ CParagraphRecalculateStateWrap.prototype =
if ( numbering_presentationnumfrmt_None != Bullet.Get_Type() ) if ( numbering_presentationnumfrmt_None != Bullet.Get_Type() )
{ {
if ( ParaPr.Ind.FirstLine < 0 ) if ( ParaPr.Ind.FirstLine < 0 )
NumberingItem.WidthVisible = Math.max( NumberingItem.Width, Para.X + ParaPr.Ind.Left + ParaPr.Ind.FirstLine - X, Para.X + ParaPr.Ind.Left - X ); NumberingItem.WidthVisible = Math.max( NumberingItem.Width, Para.Pages[CurPage].X + ParaPr.Ind.Left + ParaPr.Ind.FirstLine - X, Para.Pages[CurPage].X + ParaPr.Ind.Left - X );
else else
NumberingItem.WidthVisible = Math.max( Para.X + ParaPr.Ind.Left + NumberingItem.Width - X, Para.X + ParaPr.Ind.Left + ParaPr.Ind.FirstLine - X, Para.X + ParaPr.Ind.Left - X ); NumberingItem.WidthVisible = Math.max(Para.Pages[CurPage].X + ParaPr.Ind.Left + NumberingItem.Width - X, Para.Pages[CurPage].X + ParaPr.Ind.Left + ParaPr.Ind.FirstLine - X, Para.Pages[CurPage].X + ParaPr.Ind.Left - X );
} }
X += NumberingItem.WidthVisible; X += NumberingItem.WidthVisible;
......
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