Commit 6bb23c53 authored by Sergey.Luzyanin's avatar Sergey.Luzyanin Committed by Alexander.Trofimov

Чтение диаграмм в класс CChartAsGroup

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@48310 954022d7-b5bf-4e40-9824-e11837661b57
parent ad582af7
...@@ -1254,7 +1254,7 @@ function BinaryChartWriter(memory) ...@@ -1254,7 +1254,7 @@ function BinaryChartWriter(memory)
}; };
} }
/** @constructor */ /** @constructor */
function Binary_ChartReader(stream, chart) function Binary_ChartReader(stream, chart, chartAsGroup)
{ {
this.stream = stream; this.stream = stream;
this.bcr = new Binary_CommonReader(this.stream); this.bcr = new Binary_CommonReader(this.stream);
...@@ -1262,6 +1262,7 @@ function Binary_ChartReader(stream, chart) ...@@ -1262,6 +1262,7 @@ function Binary_ChartReader(stream, chart)
this.chartType = null; this.chartType = null;
this.oLegendEntries = new Object(); this.oLegendEntries = new Object();
this.oSeriesByIndex = new Object(); this.oSeriesByIndex = new Object();
this.chartAsGroup = chartAsGroup;
this.PreRead = function() this.PreRead = function()
{ {
this.oLegendEntries = new Object(); this.oLegendEntries = new Object();
...@@ -1318,9 +1319,10 @@ function Binary_ChartReader(stream, chart) ...@@ -1318,9 +1319,10 @@ function Binary_ChartReader(stream, chart)
var oThis = this; var oThis = this;
if ( c_oSer_ChartType.Legend === type ) if ( c_oSer_ChartType.Legend === type )
{ {
this.chart.legend.bShow = true; this.chartAsGroup.chartLegend = new CChartLegend();
var legend = this.chartAsGroup.chartLegend;
res = this.bcr.Read1(length, function(t,l){ res = this.bcr.Read1(length, function(t,l){
return oThis.ReadLegend(t,l, this.oLegendEntries); return oThis.ReadLegend(t,l, legend);
}); });
} }
else if ( c_oSer_ChartType.Title === type ) else if ( c_oSer_ChartType.Title === type )
...@@ -1391,6 +1393,8 @@ function Binary_ChartReader(stream, chart) ...@@ -1391,6 +1393,8 @@ function Binary_ChartReader(stream, chart)
this.chart.xAxis = this.chart.yAxis; this.chart.xAxis = this.chart.yAxis;
this.chart.yAxis = oTemp; this.chart.yAxis = oTemp;
} }
this.chartAsGroup.hAxisTitle = xAxis.chartTitle;
this.chartAsGroup.vAxisTitle = yAxis.chartTitle;
} }
else if ( c_oSer_ChartType.Style === type ) else if ( c_oSer_ChartType.Style === type )
{ {
...@@ -1398,18 +1402,15 @@ function Binary_ChartReader(stream, chart) ...@@ -1398,18 +1402,15 @@ function Binary_ChartReader(stream, chart)
} }
else if ( c_oSer_ChartType.TitlePptx === type || c_oSer_ChartType.TitleTxPrPptx === type) else if ( c_oSer_ChartType.TitlePptx === type || c_oSer_ChartType.TitleTxPrPptx === type)
{ {
var oPresentationSimpleSerializer = new PresentationSimpleSerializer(); if(!isRealObject(this.chartAsGroup.chartTitle))
var textBody = oPresentationSimpleSerializer.ReadTextBody(this.stream); this.chartAsGroup.chartTitle = new CChartTitle(this.chartAsGroup, CHART_TITLE_TYPE_TITLE);
var oDefHeaderFont = new asc_CChartFont();
oDefHeaderFont.size = 18; var oPresentationSimpleSerializer = new CPPTXContentLoader();
oDefHeaderFont.bold = 1; var textBody = oPresentationSimpleSerializer.ReadTextBody(null, this.stream, this.chartAsGroup.chartTitle);
var params = this.ParsePptxParagraph(textBody, oDefHeaderFont); if(c_oSer_ChartType.TitlePptx === type)
if(c_oSer_ChartType.TitlePptx === type) this.chartAsGroup.chartTitle.txBody = textBody;
this.chart.header.title = params.text; else
else this.chartAsGroup.chartTitle.txPr = textBody;
this.chart.header.bDefaultTitle = true;
if(null != params.font)
this.chart.header.font = params.font;
} }
else if ( c_oSer_ChartType.ShowBorder === type ) else if ( c_oSer_ChartType.ShowBorder === type )
this.chart.bShowBorder = this.stream.GetBool(); this.chart.bShowBorder = this.stream.GetBool();
...@@ -1417,15 +1418,15 @@ function Binary_ChartReader(stream, chart) ...@@ -1417,15 +1418,15 @@ function Binary_ChartReader(stream, chart)
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
return res; return res;
}; };
this.ReadLegend = function(type, length, oLegendEntries) this.ReadLegend = function(type, length, chartLegend)
{ {
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
var oThis = this; var oThis = this;
if ( c_oSer_ChartLegendType.Layout === type ) if ( c_oSer_ChartLegendType.Layout === type )
{ {
var oLegendLayout = new Object(); chartLegend.layout = new CChartLayout();
res = this.bcr.Read2Spreadsheet(length, function(t,l){ res = this.bcr.Read2Spreadsheet(length, function(t,l){
return oThis.ReadLegendLayout(t,l, oLegendLayout); return oThis.ReadLegendLayout(t,l, chartLegend.layout);
}); });
} }
else if ( c_oSer_ChartLegendType.LegendPos === type ) else if ( c_oSer_ChartLegendType.LegendPos === type )
...@@ -1433,31 +1434,28 @@ function Binary_ChartReader(stream, chart) ...@@ -1433,31 +1434,28 @@ function Binary_ChartReader(stream, chart)
var byteLegendPos = this.stream.GetUChar(); var byteLegendPos = this.stream.GetUChar();
switch(byteLegendPos) switch(byteLegendPos)
{ {
case EChartLegendPos.chartlegendposLeft: this.chart.legend.position = c_oAscChartLegend.left;break; case EChartLegendPos.chartlegendposLeft: chartLegend.legendPos = c_oAscChartLegend.left;break;
case EChartLegendPos.chartlegendposTop: this.chart.legend.position = c_oAscChartLegend.top;break; case EChartLegendPos.chartlegendposTop: chartLegend.legendPos = c_oAscChartLegend.top;break;
case EChartLegendPos.chartlegendposRight: case EChartLegendPos.chartlegendposRight:
case EChartLegendPos.chartlegendposRightTop: this.chart.legend.position = c_oAscChartLegend.right;break; case EChartLegendPos.chartlegendposRightTop: chartLegend.legendPos = c_oAscChartLegend.right;break;
case EChartLegendPos.chartlegendposBottom: this.chart.legend.position = c_oAscChartLegend.bottom;break; case EChartLegendPos.chartlegendposBottom: chartLegend.legendPos = c_oAscChartLegend.bottom;break;
} }
} }
else if ( c_oSer_ChartLegendType.Overlay === type ) else if ( c_oSer_ChartLegendType.Overlay === type )
this.chart.legend.bOverlay = this.stream.GetBool(); chartLegend.overlay = this.stream.GetBool();
else if ( c_oSer_ChartLegendType.TxPrPptx === type ) else if ( c_oSer_ChartLegendType.TxPrPptx === type )
{ {
var oPresentationSimpleSerializer = new PresentationSimpleSerializer(); var oPresentationSimpleSerializer = new CPPTXContentLoader();
var textBody = oPresentationSimpleSerializer.ReadTextBody(this.stream); chartLegend.txPr = oPresentationSimpleSerializer.ReadTextBody(null, this.stream, chartLegend);
var params = this.ParsePptxParagraph(textBody);
if(null != params.font)
this.chart.legend.font = params.font;
} }
else if ( c_oSer_ChartLegendType.LegendEntry === type ) else if ( c_oSer_ChartLegendType.LegendEntry === type )
{ {
var oNewLegendEntry = {nIndex: null, bDelete: null, oTxPr: null}; var oNewLegendEntry = new CLegendEntry();
res = this.bcr.Read1(length, function(t,l){ res = this.bcr.Read1(length, function(t,l){
return oThis.ReadLegendEntry(t,l, oNewLegendEntry); return oThis.ReadLegendEntry(t,l, oNewLegendEntry);
}); });
if(null != oNewLegendEntry.nIndex) if(null != oNewLegendEntry.idx)
this.oLegendEntries[oNewLegendEntry.nIndex] = oNewLegendEntry; chartLegend.legendEntries[oNewLegendEntry.idx] = oNewLegendEntry;
} }
else else
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
...@@ -1468,41 +1466,67 @@ function Binary_ChartReader(stream, chart) ...@@ -1468,41 +1466,67 @@ function Binary_ChartReader(stream, chart)
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
var oThis = this; var oThis = this;
if(c_oSer_ChartLegendEntryType.Index === type) if(c_oSer_ChartLegendEntryType.Index === type)
oLegendEntry.nIndex = this.stream.GetULongLE(); oLegendEntry.idx = this.stream.GetULongLE();
else if(c_oSer_ChartLegendEntryType.Delete === type) else if(c_oSer_ChartLegendEntryType.Delete === type)
oLegendEntry.bDelete = this.stream.GetBool(); oLegendEntry.delete = this.stream.GetBool();
else if(c_oSer_ChartLegendEntryType.TxPrPptx === type) else if(c_oSer_ChartLegendEntryType.TxPrPptx === type)
{ {
var oPresentationSimpleSerializer = new PresentationSimpleSerializer(); var oPresentationSimpleSerializer = new CPPTXContentLoader();
var textBody = oPresentationSimpleSerializer.ReadTextBody(this.stream); oLegendEntry.txPr = oPresentationSimpleSerializer.ReadTextBody(null, this.stream, oLegendEntry);
oLegendEntry.oTxPr = this.ParsePptxParagraph(textBody);
} }
else else
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
return res; return res;
}; };
this.ReadLegendLayout = function(type, length, oLegendLayout) this.ReadLegendLayout = function(type, length, chartLayout)
{ {
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
var oThis = this; var oThis = this;
if(c_oSer_ChartLegendLayoutType.H === type) if(c_oSer_ChartLegendLayoutType.H === type)
oLegendLayout.H = stream.GetDoubleLE(); {
chartLayout.h = stream.GetDoubleLE();
chartLayout.isManual = true;
}
else if(c_oSer_ChartLegendLayoutType.HMode === type) else if(c_oSer_ChartLegendLayoutType.HMode === type)
oLegendLayout.HMode = this.stream.GetUChar(); {
chartLayout.hMode = this.stream.GetUChar();
chartLayout.isManual = true;
}
else if(c_oSer_ChartLegendLayoutType.LayoutTarget === type) else if(c_oSer_ChartLegendLayoutType.LayoutTarget === type)
oLegendLayout.LayoutTarget = this.stream.GetUChar(); {
chartLayout.layoutTarget = this.stream.GetUChar();
chartLayout.isManual = true;
}
else if(c_oSer_ChartLegendLayoutType.W === type) else if(c_oSer_ChartLegendLayoutType.W === type)
oLegendLayout.W = stream.GetDoubleLE(); {
chartLayout.w = stream.GetDoubleLE();
chartLayout.isManual = true;
}
else if(c_oSer_ChartLegendLayoutType.WMode === type) else if(c_oSer_ChartLegendLayoutType.WMode === type)
oLegendLayout.WMode = this.stream.GetUChar(); {
chartLayout.wMode = this.stream.GetUChar();
chartLayout.isManual = true;
}
else if(c_oSer_ChartLegendLayoutType.X === type) else if(c_oSer_ChartLegendLayoutType.X === type)
oLegendLayout.X = stream.GetDoubleLE(); {
chartLayout.x = stream.GetDoubleLE();
chartLayout.isManual = true;
}
else if(c_oSer_ChartLegendLayoutType.XMode === type) else if(c_oSer_ChartLegendLayoutType.XMode === type)
oLegendLayout.XMode = this.stream.GetUChar(); {
chartLayout.xMode = this.stream.GetUChar();
chartLayout.isManual = true;
}
else if(c_oSer_ChartLegendLayoutType.Y === type) else if(c_oSer_ChartLegendLayoutType.Y === type)
oLegendLayout.Y = stream.GetDoubleLE(); {
chartLayout.y = stream.GetDoubleLE();
chartLayout.isManual = true;
}
else if(c_oSer_ChartLegendLayoutType.YMode === type) else if(c_oSer_ChartLegendLayoutType.YMode === type)
oLegendLayout.YMode = this.stream.GetUChar(); {
chartLayout.yMode = this.stream.GetUChar();
chartLayout.isManual = true;
}
else else
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
return res; return res;
...@@ -1563,15 +1587,21 @@ function Binary_ChartReader(stream, chart) ...@@ -1563,15 +1587,21 @@ function Binary_ChartReader(stream, chart)
oAx.axPos = this.stream.GetUChar(); oAx.axPos = this.stream.GetUChar();
else if ( c_oSer_ChartCatAxType.TitlePptx === type || c_oSer_ChartCatAxType.TitleTxPrPptx === type) else if ( c_oSer_ChartCatAxType.TitlePptx === type || c_oSer_ChartCatAxType.TitleTxPrPptx === type)
{ {
var oPresentationSimpleSerializer = new PresentationSimpleSerializer(); if(!isRealObject(oAx.chartTitle))
var textBody = oPresentationSimpleSerializer.ReadTextBody(this.stream); oAx.chartTitle = new CChartTitle(this.chartAsGroup, CHART_TITLE_TYPE_TITLE);
var params = this.ParsePptxParagraph(textBody); var oPresentationSimpleSerializer = new CPPTXContentLoader();
var textBody = oPresentationSimpleSerializer.ReadTextBody(null, this.stream, oAx.chartTitle);
if(c_oSer_ChartCatAxType.TitlePptx === type)
oAx.chartTitle.txBody = textBody;
else
oAx.chartTitle.txPr = textBody;
/*var params = this.ParsePptxParagraph(textBody);
if(c_oSer_ChartCatAxType.TitlePptx === type) if(c_oSer_ChartCatAxType.TitlePptx === type)
oAx.title = params.text; oAx.title = params.text;
else else
oAx.bDefaultTitle = true; oAx.bDefaultTitle = true;
if(null != params.font) if(null != params.font)
oAx.titlefont = params.font; oAx.titlefont = params.font; */
} }
else if ( c_oSer_ChartCatAxType.TxPrPptx === type ) else if ( c_oSer_ChartCatAxType.TxPrPptx === type )
{ {
......
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