tdf#161800 - I/O of '# of values in second plot' parameter not supported

Add support for input and output of 'split position' parameter (number of entries
in second plot) for of-pie charts. In OOXML this uses the supported split-pos
tag. For ODF I added an extension in loext namespace for this parameter.
This commit also includes simple tests for the I/O functionality in OOXML and
ODF.

Change-Id: I00ff59db721867fa836eb99b6677350040d005dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170666
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
Kurt Nordback 2024-07-17 17:07:05 -06:00 committed by Tomaž Vajngerl
parent 7c7e7da153
commit b10d331c1c
30 changed files with 218 additions and 53 deletions

View File

@ -546,6 +546,28 @@ CPPUNIT_TEST_FIXTURE(Chart2ExportTest, testBarOfPieChart)
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:ofPieChart/c:ofPieType[1]", "val", u"bar");
}
CPPUNIT_TEST_FIXTURE(Chart2ExportTest, testPieOfPieSplitPos)
{
loadFromFile(u"xlsx/pieOfPieChart2.xlsx");
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pXmlDoc = parseExport(u"xl/charts/chart1.xml"_ustr);
CPPUNIT_ASSERT(pXmlDoc);
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:ofPieChart");
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:ofPieChart/c:splitPos[1]", "val", u"4");
}
CPPUNIT_TEST_FIXTURE(Chart2ExportTest, testBarOfPieSplitPos)
{
loadFromFile(u"xlsx/barOfPieChart2.xlsx");
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pXmlDoc = parseExport(u"xl/charts/chart1.xml"_ustr);
CPPUNIT_ASSERT(pXmlDoc);
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:ofPieChart");
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:ofPieChart/c:splitPos[1]", "val", u"5");
}
CPPUNIT_TEST_FIXTURE(Chart2ExportTest, testDisplayUnits)
{
loadFromFile(u"docx/DisplayUnits.docx");
@ -1133,6 +1155,49 @@ CPPUNIT_TEST_FIXTURE(Chart2ExportTest, tdf50934_pieOfPie)
CPPUNIT_ASSERT_EQUAL(chart2::PieChartSubType_PIE, subPieType);
}
CPPUNIT_TEST_FIXTURE(Chart2ExportTest, tdf161800_barOfPie_split_pos)
{
loadFromFile(u"ods/tdf161800_barOfPie_split_pos.ods");
saveAndReload(u"calc8"_ustr);
uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0 );
CPPUNIT_ASSERT(xChartDoc.is());
Reference< chart2::XChartType > xChartType = getChartTypeFromDoc( xChartDoc, 0 );
CPPUNIT_ASSERT(xChartType.is());
// Verify that it saves and loads with the correct split position
Reference< beans::XPropertySet > xPropSet( xChartType, uno::UNO_QUERY_THROW );
uno::Any aAny = xPropSet->getPropertyValue(u"SplitPos"_ustr);
CPPUNIT_ASSERT(aAny.hasValue());
double nSplitPos;
aAny >>= nSplitPos;
CPPUNIT_ASSERT_EQUAL(4.0, nSplitPos);
}
CPPUNIT_TEST_FIXTURE(Chart2ExportTest, tdf161800_pieOfPie_split_pos)
{
loadFromFile(u"ods/tdf161800_pieOfPie_split_pos.ods");
saveAndReload(u"calc8"_ustr);
uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0 );
CPPUNIT_ASSERT(xChartDoc.is());
Reference< chart2::XChartType > xChartType = getChartTypeFromDoc( xChartDoc, 0 );
CPPUNIT_ASSERT(xChartType.is());
CPPUNIT_ASSERT_EQUAL(u"com.sun.star.chart2.PieChartType"_ustr,
xChartType->getChartType());
// Verify that it saves and loads with the correct split position
Reference< beans::XPropertySet > xPropSet( xChartType, uno::UNO_QUERY_THROW );
uno::Any aAny = xPropSet->getPropertyValue(u"SplitPos"_ustr);
CPPUNIT_ASSERT(aAny.hasValue());
double nSplitPos;
aAny >>= nSplitPos;
CPPUNIT_ASSERT_EQUAL(3.0, nSplitPos);
}
CPPUNIT_TEST_FIXTURE(Chart2ExportTest, testChartCrash)
{
loadFromFile(u"docx/FDO75975.docx");

Binary file not shown.

Binary file not shown.

View File

@ -104,7 +104,7 @@ enum
PROP_DIAGRAM_STARTING_ANGLE,
PROP_DIAGRAM_OF_PIE_TYPE,
PROP_DIAGRAM_COMPOSITE_SIZE,
PROP_DIAGRAM_SPLIT_POS,
PROP_DIAGRAM_RIGHT_ANGLED_AXES,
PROP_DIAGRAM_PERSPECTIVE,
@ -236,8 +236,8 @@ void lcl_AddPropertiesToVector(
cppu::UnoType<chart2::PieChartSubType>::get(),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEDEFAULT );
rOutProperties.emplace_back( "CompositeSize",
PROP_DIAGRAM_COMPOSITE_SIZE,
rOutProperties.emplace_back( "SplitPos",
PROP_DIAGRAM_SPLIT_POS,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEDEFAULT );

View File

@ -305,7 +305,8 @@ rtl::Reference< ChartTypeTemplate > ChartTypeDialogController::getCurrentTemplat
}
void ChartTypeDialogController::commitToModel( const ChartTypeParameter& rParameter
, const rtl::Reference<::chart::ChartModel>& xChartModel )
, const rtl::Reference<::chart::ChartModel>& xChartModel
, const uno::Reference<beans::XPropertySet>& xTemplateProps)
{
rtl::Reference< ::chart::ChartTypeManager > xTemplateManager = xChartModel->getTypeManager();
rtl::Reference< ::chart::ChartTypeTemplate > xTemplate( getCurrentTemplate( rParameter, xTemplateManager ) );
@ -329,6 +330,20 @@ void ChartTypeDialogController::commitToModel( const ChartTypeParameter& rParame
if (xDiagram.is())
{
xDiagram->setPropertyValue(CHART_UNONAME_SORT_BY_XVALUES, uno::Any(rParameter.bSortByXValues));
sal_Int32 nSplitPos;
try {
if (xTemplateProps.is()) {
xTemplateProps->getPropertyValue(u"SplitPos"_ustr) >>= nSplitPos;
xDiagram->setPropertyValue(u"SplitPos"_ustr, uno::Any(nSplitPos));
}
}
catch( uno::Exception & ex )
{
//not all templates need to support SplitPos
ex.Context.is();//to have debug information without compilation warnings
}
}
}
void ChartTypeDialogController::fillSubTypeList( ValueSet& rSubTypeList, const ChartTypeParameter& /*rParameter*/ )
@ -763,7 +778,7 @@ void OfPieChartDialogController::fillExtraControls(
{
try
{
xTemplateProps->getPropertyValue( u"CompositeSize"_ustr ) >>= nCompositeSize;
xTemplateProps->getPropertyValue( u"SplitPos"_ustr ) >>= nCompositeSize;
}
catch( const uno::Exception & )
{
@ -801,7 +816,7 @@ void OfPieChartDialogController::setTemplateProperties( const uno::Reference< be
if( xTemplateProps.is())
{
sal_Int32 nCompositeSize = m_xMF_CompositeSize->get_value();
xTemplateProps->setPropertyValue( u"CompositeSize"_ustr , uno::Any(nCompositeSize) );
xTemplateProps->setPropertyValue( u"SplitPos"_ustr , uno::Any(nCompositeSize) );
}
}

View File

@ -166,7 +166,8 @@ void ChartTypeTabPage::commitToModel( const ChartTypeParameter& rParameter )
return;
m_aTimerTriggeredControllerLock.startTimer();
m_pCurrentMainType->commitToModel( rParameter, m_xChartModel );
uno::Reference< beans::XPropertySet > xTemplateProps( static_cast<cppu::OWeakObject*>(getCurrentTemplate().get()), uno::UNO_QUERY );
m_pCurrentMainType->commitToModel( rParameter, m_xChartModel, xTemplateProps );
}
void ChartTypeTabPage::stateChanged()

View File

@ -391,7 +391,9 @@ void ChartTypePanel::commitToModel(const ChartTypeParameter& rParameter)
return;
m_aTimerTriggeredControllerLock.startTimer();
m_pCurrentMainType->commitToModel(rParameter, m_xChartModel);
uno::Reference<beans::XPropertySet> xTemplateProps(
static_cast<cppu::OWeakObject*>(getCurrentTemplate().get()), uno::UNO_QUERY);
m_pCurrentMainType->commitToModel(rParameter, m_xChartModel, xTemplateProps);
}
void ChartTypePanel::selectMainType()

View File

@ -43,7 +43,7 @@ enum
PROP_PIECHARTTYPE_USE_RINGS,
PROP_PIECHARTTYPE_3DRELATIVEHEIGHT,
PROP_PIECHARTTYPE_SUBTYPE, // none, of-bar, of-pie
PROP_PIECHARTTYPE_COMPOSITESIZE
PROP_PIECHARTTYPE_SPLIT_POS
};

View File

@ -130,8 +130,10 @@ public:
virtual void adjustParameterToSubType(ChartTypeParameter& rParameter);
virtual void adjustParameterToMainType(ChartTypeParameter& rParameter);
OUString getServiceNameForParameter(const ChartTypeParameter& rParameter) const;
void commitToModel(const ChartTypeParameter& rParameter,
const rtl::Reference<::chart::ChartModel>& xChartModel);
void
commitToModel(const ChartTypeParameter& rParameter,
const rtl::Reference<::chart::ChartModel>& xChartModel,
const css::uno::Reference<com::sun::star::beans::XPropertySet>& xTemplateProps);
rtl::Reference<::chart::ChartTypeTemplate>
getCurrentTemplate(const ChartTypeParameter& rParameter,
const rtl::Reference<::chart::ChartTypeManager>& xTemplateManager) const;

View File

@ -98,6 +98,7 @@ enum
PROP_DIAGRAM_3DRELATIVEHEIGHT,
PROP_DIAGRAM_DATATABLEHBORDER,
PROP_DIAGRAM_OF_PIE_TYPE,
PROP_DIAGRAM_SPLIT_POS,
PROP_DIAGRAM_DATATABLEVBORDER,
PROP_DIAGRAM_DATATABLEOUTLINE,
PROP_DIAGRAM_EXTERNALDATA
@ -188,6 +189,10 @@ void lcl_AddPropertiesToVector(
PROP_DIAGRAM_OF_PIE_TYPE,
cppu::UnoType<chart2::PieChartSubType>::get(),
beans::PropertyAttribute::MAYBEVOID );
rOutProperties.emplace_back( "SplitPos",
PROP_DIAGRAM_SPLIT_POS,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::MAYBEVOID );
rOutProperties.emplace_back( "ExternalData",
PROP_DIAGRAM_EXTERNALDATA,
cppu::UnoType<OUString>::get(),
@ -209,6 +214,7 @@ const ::chart::tPropertyValueMap& StaticDiagramDefaults()
::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aMap, PROP_DIAGRAM_3DRELATIVEHEIGHT, 100 );
::chart::PropertyHelper::setPropertyValueDefault< chart2::PieChartSubType >( aMap, PROP_DIAGRAM_OF_PIE_TYPE,
chart2::PieChartSubType_NONE);
::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aMap, PROP_DIAGRAM_SPLIT_POS, 2 );
::chart::SceneProperties::AddDefaultsToMap( aMap );
return aMap;
}();

View File

@ -396,52 +396,52 @@ rtl::Reference< ::chart::ChartTypeTemplate > ChartTypeManager::createTemplate(
case TEMPLATE_PIE:
xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
chart2::PieChartOffsetMode_NONE, false,
chart2::PieChartSubType_NONE, 2 ));
chart2::PieChartSubType_NONE, 3, 2));
break;
case TEMPLATE_PIEALLEXPLODED:
xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
chart2::PieChartOffsetMode_ALL_EXPLODED, false,
chart2::PieChartSubType_NONE, 2 ));
chart2::PieChartSubType_NONE, 3, 2 ));
break;
case TEMPLATE_DONUT:
xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
chart2::PieChartOffsetMode_NONE, true,
chart2::PieChartSubType_NONE, 2 ));
chart2::PieChartSubType_NONE, 3, 2 ));
break;
case TEMPLATE_DONUTALLEXPLODED:
xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
chart2::PieChartOffsetMode_ALL_EXPLODED, true,
chart2::PieChartSubType_NONE, 2 ));
chart2::PieChartSubType_NONE, 3, 2 ));
break;
case TEMPLATE_BAROFPIE:
xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
chart2::PieChartOffsetMode_NONE, false,
chart2::PieChartSubType_BAR, 2 ));
chart2::PieChartSubType_BAR, 3, 2 ));
break;
case TEMPLATE_PIEOFPIE:
xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
chart2::PieChartOffsetMode_NONE, false,
chart2::PieChartSubType_PIE, 2 ));
chart2::PieChartSubType_PIE, 3, 2 ));
break;
case TEMPLATE_THREEDPIE:
xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
chart2::PieChartOffsetMode_NONE, false,
chart2::PieChartSubType_NONE, 3 ));
chart2::PieChartSubType_NONE, 3, 3 ));
break;
case TEMPLATE_THREEDPIEALLEXPLODED:
xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
chart2::PieChartOffsetMode_ALL_EXPLODED, false,
chart2::PieChartSubType_NONE, 3 ));
chart2::PieChartSubType_NONE, 3, 3 ));
break;
case TEMPLATE_THREEDDONUT:
xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
chart2::PieChartOffsetMode_NONE, true,
chart2::PieChartSubType_NONE, 3 ));
chart2::PieChartSubType_NONE, 3, 3 ));
break;
case TEMPLATE_THREEDDONUTALLEXPLODED:
xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
chart2::PieChartOffsetMode_ALL_EXPLODED, true,
chart2::PieChartSubType_NONE, 3 ));
chart2::PieChartSubType_NONE, 3, 3 ));
break;
case TEMPLATE_SCATTERLINESYMBOL:

View File

@ -47,7 +47,7 @@ namespace
::chart::PropertyHelper::setPropertyValueDefault( aOutMap, ::chart::PROP_PIECHARTTYPE_USE_RINGS, false );
::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, ::chart::PROP_PIECHARTTYPE_3DRELATIVEHEIGHT, 100 );
::chart::PropertyHelper::setPropertyValueDefault( aOutMap, ::chart::PROP_PIECHARTTYPE_SUBTYPE, chart2::PieChartSubType_NONE );
::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, ::chart::PROP_PIECHARTTYPE_COMPOSITESIZE, 2 );
::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, ::chart::PROP_PIECHARTTYPE_SPLIT_POS, 2 );
return aOutMap;
}();
return aStaticDefaults;
@ -72,8 +72,8 @@ namespace
::chart::PROP_PIECHARTTYPE_SUBTYPE,
cppu::UnoType<chart2::PieChartSubType>::get(),
beans::PropertyAttribute::MAYBEDEFAULT },
{ u"CompositeSize"_ustr,
::chart::PROP_PIECHARTTYPE_COMPOSITESIZE,
{ u"SplitPos"_ustr,
::chart::PROP_PIECHARTTYPE_SPLIT_POS,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::MAYBEVOID }
};

View File

@ -56,7 +56,7 @@ enum
PROP_PIE_TEMPLATE_DIMENSION,
PROP_PIE_TEMPLATE_USE_RINGS,
PROP_PIE_TEMPLATE_SUB_PIE_TYPE,
PROP_PIE_TEMPLATE_COMPOSITE_SIZE
PROP_PIE_TEMPLATE_SPLIT_POS
};
::chart::tPropertyValueMap& StaticPieChartTypeTemplateDefaults()
@ -69,7 +69,8 @@ enum
::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_PIE_TEMPLATE_DIMENSION, 2 );
::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_PIE_TEMPLATE_USE_RINGS, false );
::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_PIE_TEMPLATE_SUB_PIE_TYPE, chart2::PieChartSubType_NONE );
::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_PIE_TEMPLATE_COMPOSITE_SIZE, 2 );
::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >(
aOutMap, PROP_PIE_TEMPLATE_SPLIT_POS, 2 );
return aOutMap;
}();
return aStaticDefaults;
@ -106,8 +107,8 @@ enum
cppu::UnoType<chart2::PieChartSubType>::get(),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEDEFAULT },
{ u"CompositeSize"_ustr,
PROP_PIE_TEMPLATE_COMPOSITE_SIZE,
{ u"SplitPos"_ustr,
PROP_PIE_TEMPLATE_SPLIT_POS,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEDEFAULT }
@ -140,6 +141,7 @@ PieChartTypeTemplate::PieChartTypeTemplate(
chart2::PieChartOffsetMode eMode,
bool bRings,
chart2::PieChartSubType eSubType,
sal_Int32 nCompositeSize,
sal_Int32 nDim /* = 2 */ ) :
ChartTypeTemplate( xContext, rServiceName )
{
@ -147,7 +149,7 @@ PieChartTypeTemplate::PieChartTypeTemplate(
setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_DIMENSION, uno::Any( nDim ));
setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_USE_RINGS, uno::Any( bRings ));
setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_SUB_PIE_TYPE, uno::Any( eSubType ));
setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_COMPOSITE_SIZE, uno::Any( sal_Int32(2) ));
setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_SPLIT_POS, uno::Any( nCompositeSize ));
}
PieChartTypeTemplate::~PieChartTypeTemplate()
@ -274,7 +276,8 @@ void PieChartTypeTemplate::createChartTypes(
xCT->setFastPropertyValue(
PROP_PIECHARTTYPE_SUBTYPE, getFastPropertyValue( PROP_PIE_TEMPLATE_SUB_PIE_TYPE )); // "SubType"
xCT->setFastPropertyValue(
PROP_PIECHARTTYPE_COMPOSITESIZE, getFastPropertyValue( PROP_PIE_TEMPLATE_COMPOSITE_SIZE )); // "CompositeSize"
PROP_PIECHARTTYPE_SPLIT_POS, getFastPropertyValue(
PROP_PIE_TEMPLATE_SPLIT_POS )); // "CompositeSize"
rCoordSys[0]->setChartTypes( std::vector{xCT} );
if( !aSeriesSeq.empty() )

View File

@ -39,6 +39,7 @@ public:
css::chart2::PieChartOffsetMode eMode,
bool bRings,
css::chart2::PieChartSubType eSubType,
sal_Int32 nCompositeSize,
sal_Int32 nDim );
virtual ~PieChartTypeTemplate() override;

View File

@ -195,7 +195,7 @@ PieChart::PieChart( const rtl::Reference<ChartType>& xChartTypeModel
, m_bUseRings(false)
, m_bSizeExcludesLabelsAndExplodedSegments(bExcludingPositioning)
, m_eSubType(PieChartSubType_NONE)
, m_nCompositeSize(2)
, m_nSplitPos(2)
, m_fMaxOffset(std::numeric_limits<double>::quiet_NaN())
{
PlotterBase::m_pPosHelper = &m_aPosHelper;
@ -230,7 +230,7 @@ PieChart::PieChart( const rtl::Reference<ChartType>& xChartTypeModel
}
try
{
xChartTypeModel->getFastPropertyValue(PROP_PIECHARTTYPE_COMPOSITESIZE) >>= m_nCompositeSize; // "CompositeSize"
xChartTypeModel->getFastPropertyValue(PROP_PIECHARTTYPE_SPLIT_POS) >>= m_nSplitPos; // "CompositeSize"
}
catch( const uno::Exception& )
{
@ -1050,7 +1050,7 @@ void PieChart::createShapes()
PieDataSrcBase *pDataSrc = nullptr;
PieDataSrc normalPieSrc;
OfPieDataSrc ofPieSrc(m_nCompositeSize);
OfPieDataSrc ofPieSrc(m_nSplitPos);
// Default to regular pie if too few points for of-pie
::css::chart2::PieChartSubType eSubType =
@ -2303,26 +2303,25 @@ uno::Reference< beans::XPropertySet > PieDataSrc::getProps(
// class OfPieDataSrc
//=======================
// For now, just implement the default Excel behavior, which is that the
// right pie consists of the last three entries in the series. Other
// behaviors should be supported later.
// Support data splits only of the type "last n entries go in right subchart",
// for now.
// TODO
sal_Int32 OfPieDataSrc::getNPoints(const VDataSeries* pSeries,
enum SubPieType eType) const
{
if (eType == SubPieType::LEFT) {
return pSeries->getTotalPointCount() - m_nCompositeSize + 1;
return pSeries->getTotalPointCount() - m_nSplitPos + 1;
} else {
assert(eType == SubPieType::RIGHT);
return m_nCompositeSize;
return m_nSplitPos;
}
}
double OfPieDataSrc::getData(const VDataSeries* pSeries, sal_Int32 nPtIdx,
enum SubPieType eType) const
{
const sal_Int32 n = pSeries->getTotalPointCount() - m_nCompositeSize;
const sal_Int32 n = pSeries->getTotalPointCount() - m_nSplitPos;
if (eType == SubPieType::LEFT) {
// nPtIdx should be in [0, n]
if (nPtIdx < n) {
@ -2331,7 +2330,7 @@ double OfPieDataSrc::getData(const VDataSeries* pSeries, sal_Int32 nPtIdx,
// composite wedge
assert(nPtIdx == n);
double total = 0;
for (sal_Int32 i = n; i < n + m_nCompositeSize; ++i) {
for (sal_Int32 i = n; i < n + m_nSplitPos; ++i) {
total += pSeries->getYValue(i);
}
return total;
@ -2347,7 +2346,7 @@ uno::Reference< beans::XPropertySet > OfPieDataSrc::getProps(
enum SubPieType eType) const
{
const sal_Int32 nPts = pSeries->getTotalPointCount();
const sal_Int32 n = nPts - m_nCompositeSize;
const sal_Int32 n = nPts - m_nSplitPos;
if (eType == SubPieType::LEFT) {
// nPtIdx should be in [0, n]
if (nPtIdx < n) {

View File

@ -101,8 +101,8 @@ public:
class OfPieDataSrc : public PieDataSrcBase
{
public:
OfPieDataSrc(sal_Int32 nCompositeSize):
m_nCompositeSize(nCompositeSize)
OfPieDataSrc(sal_Int32 nSplitPos):
m_nSplitPos(nSplitPos)
{}
// Minimum sensible number of data points
@ -118,7 +118,7 @@ public:
const VDataSeries* pSeries, sal_Int32 nPtIdx,
enum SubPieType eType) const;
private:
sal_Int32 m_nCompositeSize;
double m_nSplitPos;
};
//=======================
@ -276,7 +276,7 @@ private: //member
bool m_bSizeExcludesLabelsAndExplodedSegments;
::css::chart2::PieChartSubType m_eSubType;
// Number of entries in an of-pie composite wedge
sal_Int32 m_nCompositeSize;
double m_nSplitPos;
struct PieLabelInfo
{

View File

@ -154,6 +154,7 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(ChartModel& rChart
sal_Int32 nStartingAngle = 90;
sal_Int32 n3DRelativeHeight = 100;
PieChartSubType ePieChartSubType = PieChartSubType_NONE;
double nSplitPos = 2;
try
{
xDiagram->getPropertyValue(CHART_UNONAME_SORT_BY_XVALUES) >>= bSortByXValues;
@ -167,6 +168,8 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(ChartModel& rChart
xDiagram->getPropertyValue(u"3DRelativeHeight"_ustr) >>= n3DRelativeHeight;
}
xDiagram->getPropertyValue(u"SubPieType"_ustr) >>= ePieChartSubType;
xDiagram->getPropertyValue(u"SplitPos"_ustr) >>= nSplitPos;
}
catch (const uno::Exception&)
{
@ -234,6 +237,9 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(ChartModel& rChart
uno::Any(ePieChartSubType));
// Reset the diagram-level property so it's not persistent.
xDiagram->setPropertyValue(u"SubPieType"_ustr, uno::Any(PieChartSubType_NONE));
xChartType->setFastPropertyValue(PROP_PIECHARTTYPE_SPLIT_POS, uno::Any(nSplitPos));
//xDiagram->setPropertyValue(u"SplitPos"_ustr, uno::Any(nSplitPos));
}
if (nT == 0)

View File

@ -195,7 +195,7 @@ private:
void exportDoughnutChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
void exportLineChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
void exportOfPieChart( const css::uno::Reference< css::chart2::XChartType >&
xChartType, const char* s_subtype );
xChartType, const char* s_subtype, double nSplitPos );
void exportPieChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
void exportRadarChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
void exportScatterChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );

View File

@ -296,7 +296,7 @@ ContextHandlerRef OfPieTypeGroupContext::onCreateContext( sal_Int32 nElement, co
case C_TOKEN( serLines ):
return new ShapePrWrapperContext( *this, mrModel.mxSerLines.create() );
case C_TOKEN( splitPos ):
mrModel.mfSplitPos = rAttribs.getDouble( XML_val, 0.0 );
mrModel.mfSplitPos = rAttribs.getDouble( XML_val, 2.0 );
return nullptr;
case C_TOKEN( splitType ):
mrModel.mnSplitType = rAttribs.getToken( XML_val, XML_auto );

View File

@ -358,6 +358,10 @@ void TypeGroupConverter::convertFromModel( const Reference< XDiagram >& rxDiagra
if (maTypeInfo.meTypeId == TYPEID_OFPIE) {
aDiaProp.setProperty(PROP_SubPieType,
convertOfPieType(mrModel.mnOfPieType));
if (mrModel.mnSplitType == XML_auto ||
mrModel.mnSplitType == XML_pos) {
aDiaProp.setProperty(PROP_SplitPos, mrModel.mfSplitPos);
}
} else {
aDiaProp.setProperty(PROP_SubPieType, PieChartSubType_NONE);
}

View File

@ -32,7 +32,7 @@ UpDownBarsModel::~UpDownBarsModel()
}
TypeGroupModel::TypeGroupModel( sal_Int32 nTypeId, bool bMSO2007Doc ) :
mfSplitPos( 0.0 ),
mfSplitPos( 2.0 ),
mnBarDir( XML_col ),
mnBubbleScale( 100 ),
mnFirstAngle( 0 ),

View File

@ -1764,8 +1764,13 @@ void ChartExport::exportPlotArea(const Reference< css::chart::XChartDocument >&
default:
assert(false);
}
double fSplitPos;
if (!xChartTypeProp.getProperty(fSplitPos,
PROP_SplitPos)) {
fSplitPos = 2;
}
exportOfPieChart(xChartType, sSubType);
exportOfPieChart(xChartType, sSubType, fSplitPos);
} else {
exportPieChart( xChartType );
}
@ -2323,7 +2328,8 @@ void ChartExport::exportDoughnutChart( const Reference< chart2::XChartType >& xC
void ChartExport::exportOfPieChart(
const Reference< chart2::XChartType >& xChartType,
const char* sSubType )
const char* sSubType,
double fSplitPos)
{
FSHelperPtr pFS = GetFS();
pFS->startElement(FSNS(XML_c, XML_ofPieChart));
@ -2335,6 +2341,9 @@ void ChartExport::exportOfPieChart(
bool bPrimaryAxes = true;
exportAllSeries(xChartType, bPrimaryAxes);
pFS->singleElement(FSNS(XML_c, XML_splitType), XML_val, "pos");
pFS->singleElement(FSNS(XML_c, XML_splitPos), XML_val, OString::number(fSplitPos));
pFS->endElement( FSNS( XML_c, XML_ofPieChart ) );
}

View File

@ -555,6 +555,7 @@ SpinIncrement
SpinValue
SpinValueMax
SpinValueMin
SplitPos
StackCharacters
StackingDirection
StartPosition

View File

@ -2762,6 +2762,15 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
</rng:optional>
</rng:define>
<!-- TODO no proposal -->
<rng:define name="chart-chart-attlist" combine="interleave">
<rng:optional>
<rng:attribute name="loext:split-position">
<rng:ref name="string"/>
</rng:attribute>
</rng:optional>
</rng:define>
<!-- TODO no proposal -->
<rng:define name="chart-chart-attlist" combine="interleave">
<rng:optional>

View File

@ -595,6 +595,7 @@ inline constexpr OUString PROP_Speed = u"Speed"_ustr;
inline constexpr OUString PROP_SplineOrder = u"SplineOrder"_ustr;
inline constexpr OUString PROP_SplineResolution = u"SplineResolution"_ustr;
inline constexpr OUString PROP_SplineType = u"SplineType"_ustr;
inline constexpr OUString PROP_SplitPos = u"SplitPos"_ustr;
inline constexpr OUString PROP_Stacked = u"Stacked"_ustr;
inline constexpr OUString PROP_StackedBarsConnected = u"StackedBarsConnected"_ustr;
inline constexpr OUString PROP_StackedText = u"StackedText"_ustr;

View File

@ -232,7 +232,8 @@ SchXMLChartContext::SchXMLChartContext( SchXMLImportHelper& rImpHelper,
mbRowHasLabels( false ),
meDataRowSource( chart::ChartDataRowSource_COLUMNS ),
mbIsStockChart( false ),
mPieSubType(css::chart2::PieChartSubType_NONE)
mPieSubType(css::chart2::PieChartSubType_NONE),
mfPieSplitPos(2.0)
{
}
@ -400,6 +401,9 @@ void SchXMLChartContext::startFastElement( sal_Int32 /*nElement*/,
mPieSubType = css::chart2::PieChartSubType_PIE;
}
break;
case XML_ELEMENT(LO_EXT, XML_SPLIT_POSITION):
mfPieSplitPos = aIter.toDouble();
break;
default:
XMLOFF_WARN_UNKNOWN("xmloff", aIter);
}
@ -748,12 +752,13 @@ void SchXMLChartContext::endFastElement(sal_Int32 )
// cleanup: remove empty chart type groups
lcl_removeEmptyChartTypeGroups( xNewDoc );
// Handle sub-pie type. Is this the right place to do this?
// Handle of-pie paramters. Is this the right place to do this?
if (maChartTypeServiceName == "com.sun.star.chart2.PieChartType") {
Reference< chart2::XDiagram> xDia(xNewDoc->getFirstDiagram());
uno::Reference< beans::XPropertySet > xDiaProp( xDia, uno::UNO_QUERY );
if( xDiaProp.is()) {
xDiaProp->setPropertyValue(u"SubPieType"_ustr, uno::Any(mPieSubType));
xDiaProp->setPropertyValue(u"SplitPos"_ustr, uno::Any(mfPieSplitPos));
}
}

View File

@ -101,6 +101,7 @@ private:
css::chart::ChartDataRowSource meDataRowSource;
bool mbIsStockChart;
css::chart2::PieChartSubType mPieSubType;
double mfPieSplitPos;
OUString msCategoriesAddress;
OUString msChartAddress;

View File

@ -114,7 +114,6 @@ using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Any;
using ::std::vector;
namespace
{
/**
@ -1287,11 +1286,47 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >
XML_NAMESPACE_CHART, GetXMLToken(eXMLChartType )) );
}
bool bIsOfPie = false;
// Handle subtype for of-pie charts
if (sChartType == u"com.sun.star.chart.BarOfPieDiagram") {
mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_SUB_BAR, OUString::boolean(true));
bIsOfPie = true;
} else if (sChartType == u"com.sun.star.chart.PieOfPieDiagram") {
mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_SUB_PIE, OUString::boolean(true));
bIsOfPie = true;
}
if (bIsOfPie) {
// Find the split position. We have to dig deep into the
// structure tree to get it, which is awkward. Part of the
// problem is that the split position is sort of a series-level
// parameter, but is generally handled at the chart level since
// of-pie charts have only a single series.
double fSplitPos = 2.0;
Reference< chart2::XCoordinateSystemContainer > xBCooSysCnt( xNewDiagram, uno::UNO_QUERY );
if (xBCooSysCnt.is()) {
const Sequence< Reference< chart2::XCoordinateSystem > >
aCooSysSeq( xBCooSysCnt->getCoordinateSystems());
for (const auto& rCooSys : aCooSysSeq ) {
Reference< chart2::XChartTypeContainer > xCTCnt( rCooSys, uno::UNO_QUERY );
if( ! xCTCnt.is())
continue;
const Sequence< Reference< chart2::XChartType > > aCTSeq( xCTCnt->getChartTypes());
for (const auto& rChartType : aCTSeq ) {
Reference< beans::XPropertySet > xCTProp( rChartType, uno::UNO_QUERY );
if (xCTProp.is()) {
xCTProp->getPropertyValue(u"SplitPos"_ustr) >>= fSplitPos;
}
}
}
}
// Insert split position for of-pie chart
mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_SPLIT_POSITION,
OUString::number(fSplitPos));
}
//column-mapping or row-mapping