fix scatter chart conversion

This commit is contained in:
Viktor Andreev
2026-02-09 17:47:16 +06:00
parent 404748ec5a
commit 3a004e8495
2 changed files with 51 additions and 59 deletions

View File

@ -3018,6 +3018,17 @@ xmlns:c16r2=\"http://schemas.microsoft.com/office/drawing/2015/06/chart\"");
lnFmt.lineFormat = m_majorGridlines->m_spPr->ln->toXLS(); lnFmt.lineFormat = m_majorGridlines->m_spPr->ln->toXLS();
axs->m_AxisLine_Format.push_back(lnFmt); axs->m_AxisLine_Format.push_back(lnFmt);
} }
if(m_minorGridlines != nullptr)
{
auto axisline = new XLS::AxisLine;
axisline->id = 2;
XLS::AXS::_axis_line_format lnFmt;
lnFmt.axisLine = XLS::BaseObjectPtr(axisline);
if(m_minorGridlines->m_spPr.IsInit() && m_minorGridlines->m_spPr->ln.IsInit())
lnFmt.lineFormat = m_minorGridlines->m_spPr->ln->toXLS();
axs->m_AxisLine_Format.push_back(lnFmt);
}
auto tickPtr = new XLS::Tick; auto tickPtr = new XLS::Tick;
axs->m_Tick = XLS::BaseObjectPtr(tickPtr); axs->m_Tick = XLS::BaseObjectPtr(tickPtr);
if(m_tickLblPos.IsInit()) if(m_tickLblPos.IsInit())
@ -3276,7 +3287,10 @@ xmlns:c16r2=\"http://schemas.microsoft.com/office/drawing/2015/06/chart\"");
auto axis = new XLS::Axis; auto axis = new XLS::Axis;
auto axs = new XLS::AXS; auto axs = new XLS::AXS;
dvAxis->m_AXS = XLS::BaseObjectPtr(axs); dvAxis->m_AXS = XLS::BaseObjectPtr(axs);
axis->wType = 1; if(m_axPos.IsInit() && m_axPos->GetValue() == OOX::Spreadsheet::ST_AxPos::st_axposL)
axis->wType = 0;
else
axis->wType = 1;
dvAxis->m_Axis = XLS::BaseObjectPtr(axis); dvAxis->m_Axis = XLS::BaseObjectPtr(axis);
auto valSerRange = new XLS::ValueRange; auto valSerRange = new XLS::ValueRange;
valSerRange->fAutoMin = true; valSerRange->fAutoMin = true;
@ -3312,6 +3326,17 @@ xmlns:c16r2=\"http://schemas.microsoft.com/office/drawing/2015/06/chart\"");
lnFmt.lineFormat = m_majorGridlines->m_spPr->ln->toXLS(); lnFmt.lineFormat = m_majorGridlines->m_spPr->ln->toXLS();
axs->m_AxisLine_Format.push_back(lnFmt); axs->m_AxisLine_Format.push_back(lnFmt);
} }
if(m_minorGridlines != nullptr)
{
auto axisline = new XLS::AxisLine;
axisline->id = 2;
XLS::AXS::_axis_line_format lnFmt;
lnFmt.axisLine = XLS::BaseObjectPtr(axisline);
if(m_minorGridlines->m_spPr.IsInit() && m_minorGridlines->m_spPr->ln.IsInit())
lnFmt.lineFormat = m_minorGridlines->m_spPr->ln->toXLS();
axs->m_AxisLine_Format.push_back(lnFmt);
}
auto tickPtr = new XLS::Tick; auto tickPtr = new XLS::Tick;
axs->m_Tick = XLS::BaseObjectPtr(tickPtr); axs->m_Tick = XLS::BaseObjectPtr(tickPtr);
if(m_tickLblPos.IsInit()) if(m_tickLblPos.IsInit())
@ -7565,7 +7590,7 @@ xmlns:c16r2=\"http://schemas.microsoft.com/office/drawing/2015/06/chart\"");
series->cValy = m_yVal->m_numRef->m_numCache->m_pt.size(); series->cValy = m_yVal->m_numRef->m_numCache->m_pt.size();
{ {
auto ai2 = new XLS::BRAI; auto ai2 = new XLS::BRAI;
ai2->id = 1; ai2->id = 2;
if(m_xVal->m_numRef->m_f.IsInit()) if(m_xVal->m_numRef->m_f.IsInit())
{ {
ai2->rt = 2; ai2->rt = 2;
@ -7573,7 +7598,12 @@ xmlns:c16r2=\"http://schemas.microsoft.com/office/drawing/2015/06/chart\"");
} }
seriesFormat->m_arAI.push_back(XLS::BaseObjectPtr(ai2)); seriesFormat->m_arAI.push_back(XLS::BaseObjectPtr(ai2));
auto ai3 = new XLS::BRAI; auto ai3 = new XLS::BRAI;
ai3->id = 2; ai3->id = 1;
if(m_yVal->m_numRef->m_f.IsInit())
{
ai3->rt = 2;
ai3->formula.parseStringFormula(m_yVal->m_numRef->m_f.get(), L"");
}
auto ai4 = new XLS::BRAI; auto ai4 = new XLS::BRAI;
ai4->id = 3; ai4->id = 3;
seriesFormat->m_arAI.push_back(XLS::BaseObjectPtr(ai3)); seriesFormat->m_arAI.push_back(XLS::BaseObjectPtr(ai3));

View File

@ -308,8 +308,6 @@ namespace OOX
auto AxisParentUnion = new XLS::AXISPARENT; auto AxisParentUnion = new XLS::AXISPARENT;
auto axes = new XLS::AXES; auto axes = new XLS::AXES;
AxisParentUnion->m_AXES = XLS::BaseObjectPtr(axes); AxisParentUnion->m_AXES = XLS::BaseObjectPtr(axes);
_INT32 catAxId = -1;
_INT32 valAxId = -1;
ChartFormatsPtr->m_arAXISPARENT.push_back(XLS::BaseObjectPtr(AxisParentUnion)); ChartFormatsPtr->m_arAXISPARENT.push_back(XLS::BaseObjectPtr(AxisParentUnion));
auto axisPos = new XLS::Pos; auto axisPos = new XLS::Pos;
axisPos->x1 = -1000; axisPos->x1 = -1000;
@ -324,19 +322,11 @@ namespace OOX
{ {
auto barChart = static_cast<CT_BarChart*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items.at(chartIndex)); auto barChart = static_cast<CT_BarChart*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items.at(chartIndex));
AxisParentUnion->m_arCRT.push_back(barChart->toXLS(chartIndex, ptr->m_CHARTFORMATS)); AxisParentUnion->m_arCRT.push_back(barChart->toXLS(chartIndex, ptr->m_CHARTFORMATS));
if(barChart->m_axId.size() > 0)
catAxId = barChart->m_axId.at(0);
if(barChart->m_axId.size() > 1)
valAxId = barChart->m_axId.at(1);
} }
else if(*ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName0.at(chartIndex) == OOX::Spreadsheet::itemschoicetype5BAR3DCHART) else if(*ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName0.at(chartIndex) == OOX::Spreadsheet::itemschoicetype5BAR3DCHART)
{ {
auto barChart = static_cast<CT_Bar3DChart*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items.at(chartIndex)); auto barChart = static_cast<CT_Bar3DChart*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items.at(chartIndex));
AxisParentUnion->m_arCRT.push_back(barChart->toXLS(chartIndex, ptr->m_CHARTFORMATS)); AxisParentUnion->m_arCRT.push_back(barChart->toXLS(chartIndex, ptr->m_CHARTFORMATS));
if(barChart->m_axId.size() > 0)
catAxId = barChart->m_axId.at(0);
if(barChart->m_axId.size() > 1)
valAxId = barChart->m_axId.at(1);
} }
else if(*ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName0.at(chartIndex) == OOX::Spreadsheet::itemschoicetype5PIECHART) else if(*ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName0.at(chartIndex) == OOX::Spreadsheet::itemschoicetype5PIECHART)
{ {
@ -352,91 +342,64 @@ namespace OOX
{ {
auto LineChart = static_cast<CT_LineChart*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items.at(chartIndex)); auto LineChart = static_cast<CT_LineChart*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items.at(chartIndex));
AxisParentUnion->m_arCRT.push_back(LineChart->toXLS(chartIndex, ptr->m_CHARTFORMATS)); AxisParentUnion->m_arCRT.push_back(LineChart->toXLS(chartIndex, ptr->m_CHARTFORMATS));
if(LineChart->m_axId.size() > 0)
catAxId = LineChart->m_axId.at(0);
if(LineChart->m_axId.size() > 1)
valAxId = LineChart->m_axId.at(1);
} }
else if(*ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName0.at(chartIndex) == OOX::Spreadsheet::itemschoicetype5LINE3DCHART) else if(*ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName0.at(chartIndex) == OOX::Spreadsheet::itemschoicetype5LINE3DCHART)
{ {
auto LineChart = static_cast<CT_Line3DChart*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items.at(chartIndex)); auto LineChart = static_cast<CT_Line3DChart*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items.at(chartIndex));
AxisParentUnion->m_arCRT.push_back(LineChart->toXLS(chartIndex, ptr->m_CHARTFORMATS)); AxisParentUnion->m_arCRT.push_back(LineChart->toXLS(chartIndex, ptr->m_CHARTFORMATS));
if(LineChart->m_axId.size() > 0)
catAxId = LineChart->m_axId.at(0);
if(LineChart->m_axId.size() > 1)
valAxId = LineChart->m_axId.at(1);
} }
else if(*ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName0.at(chartIndex) == OOX::Spreadsheet::itemschoicetype5AREACHART) else if(*ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName0.at(chartIndex) == OOX::Spreadsheet::itemschoicetype5AREACHART)
{ {
auto AreaChart = static_cast<CT_AreaChart*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items.at(chartIndex)); auto AreaChart = static_cast<CT_AreaChart*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items.at(chartIndex));
AxisParentUnion->m_arCRT.push_back(AreaChart->toXLS(chartIndex, ptr->m_CHARTFORMATS)); AxisParentUnion->m_arCRT.push_back(AreaChart->toXLS(chartIndex, ptr->m_CHARTFORMATS));
if(AreaChart->m_axId.size() > 0)
catAxId = AreaChart->m_axId.at(0);
if(AreaChart->m_axId.size() > 1)
valAxId = AreaChart->m_axId.at(1);
} }
else if(*ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName0.at(chartIndex) == OOX::Spreadsheet::itemschoicetype5AREA3DCHART) else if(*ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName0.at(chartIndex) == OOX::Spreadsheet::itemschoicetype5AREA3DCHART)
{ {
auto AreaChart = static_cast<CT_Area3DChart*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items.at(chartIndex)); auto AreaChart = static_cast<CT_Area3DChart*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items.at(chartIndex));
AxisParentUnion->m_arCRT.push_back(AreaChart->toXLS(chartIndex, ptr->m_CHARTFORMATS)); AxisParentUnion->m_arCRT.push_back(AreaChart->toXLS(chartIndex, ptr->m_CHARTFORMATS));
if(AreaChart->m_axId.size() > 0)
catAxId = AreaChart->m_axId.at(0);
if(AreaChart->m_axId.size() > 1)
valAxId = AreaChart->m_axId.at(1);
} }
else if(*ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName0.at(chartIndex) == OOX::Spreadsheet::itemschoicetype5SURFACECHART) else if(*ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName0.at(chartIndex) == OOX::Spreadsheet::itemschoicetype5SURFACECHART)
{ {
auto SurfaceChart = static_cast<CT_SurfaceChart*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items.at(chartIndex)); auto SurfaceChart = static_cast<CT_SurfaceChart*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items.at(chartIndex));
AxisParentUnion->m_arCRT.push_back(SurfaceChart->toXLS(chartIndex, ptr->m_CHARTFORMATS)); AxisParentUnion->m_arCRT.push_back(SurfaceChart->toXLS(chartIndex, ptr->m_CHARTFORMATS));
if(SurfaceChart->m_axId.size() > 0)
catAxId = SurfaceChart->m_axId.at(0);
if(SurfaceChart->m_axId.size() > 1)
valAxId = SurfaceChart->m_axId.at(1);
} }
else if(*ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName0.at(chartIndex) == OOX::Spreadsheet::itemschoicetype5SCATTERCHART) else if(*ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName0.at(chartIndex) == OOX::Spreadsheet::itemschoicetype5SCATTERCHART)
{ {
auto ScatterChart = static_cast<CT_ScatterChart*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items.at(chartIndex)); auto ScatterChart = static_cast<CT_ScatterChart*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items.at(chartIndex));
AxisParentUnion->m_arCRT.push_back(ScatterChart->toXLS(chartIndex, ptr->m_CHARTFORMATS)); AxisParentUnion->m_arCRT.push_back(ScatterChart->toXLS(chartIndex, ptr->m_CHARTFORMATS));
if(ScatterChart->m_axId.size() > 0)
catAxId = ScatterChart->m_axId.at(0);
if(ScatterChart->m_axId.size() > 1)
valAxId = ScatterChart->m_axId.at(1);
} }
else if(*ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName0.at(chartIndex) == OOX::Spreadsheet::itemschoicetype5RADARCHART) else if(*ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName0.at(chartIndex) == OOX::Spreadsheet::itemschoicetype5RADARCHART)
{ {
auto ScatterChart = static_cast<CT_RadarChart*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items.at(chartIndex)); auto ScatterChart = static_cast<CT_RadarChart*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items.at(chartIndex));
AxisParentUnion->m_arCRT.push_back(ScatterChart->toXLS(chartIndex, ptr->m_CHARTFORMATS)); AxisParentUnion->m_arCRT.push_back(ScatterChart->toXLS(chartIndex, ptr->m_CHARTFORMATS));
if(ScatterChart->m_axId.size() > 0)
catAxId = ScatterChart->m_axId.at(0);
if(ScatterChart->m_axId.size() > 1)
valAxId = ScatterChart->m_axId.at(1);
} }
if(ChartFormatsPtr->m_arAXISPARENT.size() < 2) if(ChartFormatsPtr->m_arAXISPARENT.size() < 2)
{ for(auto axPose = 0; axPose < ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName1.size(); axPose++) {
for(auto axPose = 0; axPose < ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName1.size(); axPose++)
{
if(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName1[axPose] != nullptr && ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items1.size() > axPose)
{ {
if(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName1[axPose] != nullptr && ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items1.size() > axPose) auto AxType = *ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName1[axPose];
switch (AxType)
{ {
auto AxType = *ChartFile->m_oChartSpace.m_chart->m_plotArea->m_ItemsElementName1[axPose]; case ItemsChoiceType6::itemschoicetype6CATAX:
switch (AxType)
{ {
case ItemsChoiceType6::itemschoicetype6CATAX: auto ivAx = static_cast<CT_CatAx*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items1.at(axPose));
{ axes->m_arAxes.push_back(ivAx->toXLS());
auto ivAx = static_cast<CT_CatAx*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items1.at(axPose));
axes->m_arAxes.push_back(ivAx->toXLS());
break;
}
case ItemsChoiceType6::itemschoicetype6VALAX:
{
auto dvAx = static_cast<CT_ValAx*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items1.at(1));
axes->m_arAxes.push_back(dvAx->toXLS());
break;
}
default:
break; break;
} }
case ItemsChoiceType6::itemschoicetype6VALAX:
{
auto dvAx = static_cast<CT_ValAx*>(ChartFile->m_oChartSpace.m_chart->m_plotArea->m_Items1.at(axPose));
axes->m_arAxes.push_back(dvAx->toXLS());
break;
}
default:
break;
} }
} }
}
} }
if(ChartFile->m_oChartSpace.m_chart->m_legend != nullptr && !AxisParentUnion->m_arCRT.empty()) if(ChartFile->m_oChartSpace.m_chart->m_legend != nullptr && !AxisParentUnion->m_arCRT.empty())
{ {
@ -444,7 +407,6 @@ namespace OOX
crtPtr->m_LD = ChartFile->m_oChartSpace.m_chart->m_legend->toXLS(); crtPtr->m_LD = ChartFile->m_oChartSpace.m_chart->m_legend->toXLS();
} }
} }
} }
if(ChartFile->m_oChartSpace.m_chart->m_title != nullptr && ChartFile->m_oChartSpace.m_chart->m_title->m_tx != nullptr) if(ChartFile->m_oChartSpace.m_chart->m_title != nullptr && ChartFile->m_oChartSpace.m_chart->m_title->m_tx != nullptr)
{ {