diff options
30 files changed, 218 insertions, 53 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index c57c238ef3b0..3f37794e1d10 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -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"); diff --git a/chart2/qa/extras/data/ods/tdf161800_barOfPie_split_pos.ods b/chart2/qa/extras/data/ods/tdf161800_barOfPie_split_pos.ods Binary files differnew file mode 100644 index 000000000000..a87941bfa22d --- /dev/null +++ b/chart2/qa/extras/data/ods/tdf161800_barOfPie_split_pos.ods diff --git a/chart2/qa/extras/data/ods/tdf161800_pieOfPie_split_pos.ods b/chart2/qa/extras/data/ods/tdf161800_pieOfPie_split_pos.ods Binary files differnew file mode 100644 index 000000000000..9a08628a91e7 --- /dev/null +++ b/chart2/qa/extras/data/ods/tdf161800_pieOfPie_split_pos.ods diff --git a/chart2/qa/extras/data/xlsx/barOfPieChart2.xlsx b/chart2/qa/extras/data/xlsx/barOfPieChart2.xlsx Binary files differnew file mode 100644 index 000000000000..be24cd293915 --- /dev/null +++ b/chart2/qa/extras/data/xlsx/barOfPieChart2.xlsx diff --git a/chart2/qa/extras/data/xlsx/pieOfPieChart2.xlsx b/chart2/qa/extras/data/xlsx/pieOfPieChart2.xlsx Binary files differnew file mode 100644 index 000000000000..c80f0169cc89 --- /dev/null +++ b/chart2/qa/extras/data/xlsx/pieOfPieChart2.xlsx diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index 29618ddbfaf6..79eb36f41050 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -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 ); diff --git a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx index 308ff1930457..365df1c328f9 100644 --- a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx +++ b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx @@ -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) ); } } diff --git a/chart2/source/controller/dialogs/tp_ChartType.cxx b/chart2/source/controller/dialogs/tp_ChartType.cxx index 811c4df19017..12fa0325cef4 100644 --- a/chart2/source/controller/dialogs/tp_ChartType.cxx +++ b/chart2/source/controller/dialogs/tp_ChartType.cxx @@ -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() diff --git a/chart2/source/controller/sidebar/ChartTypePanel.cxx b/chart2/source/controller/sidebar/ChartTypePanel.cxx index 38ea92912a19..fa85ded6d4a6 100644 --- a/chart2/source/controller/sidebar/ChartTypePanel.cxx +++ b/chart2/source/controller/sidebar/ChartTypePanel.cxx @@ -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() diff --git a/chart2/source/inc/ChartType.hxx b/chart2/source/inc/ChartType.hxx index 7b1fccfb159e..697b0d7ffc91 100644 --- a/chart2/source/inc/ChartType.hxx +++ b/chart2/source/inc/ChartType.hxx @@ -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 }; diff --git a/chart2/source/inc/ChartTypeDialogController.hxx b/chart2/source/inc/ChartTypeDialogController.hxx index cbeeb8b59406..1d36a433d96a 100644 --- a/chart2/source/inc/ChartTypeDialogController.hxx +++ b/chart2/source/inc/ChartTypeDialogController.hxx @@ -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; diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx index bbd5dd61fab2..c3c4e0be9cc6 100644 --- a/chart2/source/model/main/Diagram.cxx +++ b/chart2/source/model/main/Diagram.cxx @@ -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; }(); diff --git a/chart2/source/model/template/ChartTypeManager.cxx b/chart2/source/model/template/ChartTypeManager.cxx index b81e47ee3884..deb70d9aa03c 100644 --- a/chart2/source/model/template/ChartTypeManager.cxx +++ b/chart2/source/model/template/ChartTypeManager.cxx @@ -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: diff --git a/chart2/source/model/template/PieChartType.cxx b/chart2/source/model/template/PieChartType.cxx index 224b37a88865..36f9a59d0862 100644 --- a/chart2/source/model/template/PieChartType.cxx +++ b/chart2/source/model/template/PieChartType.cxx @@ -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 } }; diff --git a/chart2/source/model/template/PieChartTypeTemplate.cxx b/chart2/source/model/template/PieChartTypeTemplate.cxx index cc5c0c0ed09f..0cdeb48ecfce 100644 --- a/chart2/source/model/template/PieChartTypeTemplate.cxx +++ b/chart2/source/model/template/PieChartTypeTemplate.cxx @@ -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() ) diff --git a/chart2/source/model/template/PieChartTypeTemplate.hxx b/chart2/source/model/template/PieChartTypeTemplate.hxx index c7b3b9b6951c..d95b8c49d900 100644 --- a/chart2/source/model/template/PieChartTypeTemplate.hxx +++ b/chart2/source/model/template/PieChartTypeTemplate.hxx @@ -39,6 +39,7 @@ public: css::chart2::PieChartOffsetMode eMode, bool bRings, css::chart2::PieChartSubType eSubType, + sal_Int32 nCompositeSize, sal_Int32 nDim ); virtual ~PieChartTypeTemplate() override; diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 4bda2129817d..82ed7f32f6d4 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -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) { diff --git a/chart2/source/view/charttypes/PieChart.hxx b/chart2/source/view/charttypes/PieChart.hxx index c5cb1e535cc8..b2fa3b8982ec 100644 --- a/chart2/source/view/charttypes/PieChart.hxx +++ b/chart2/source/view/charttypes/PieChart.hxx @@ -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 { diff --git a/chart2/source/view/main/SeriesPlotterContainer.cxx b/chart2/source/view/main/SeriesPlotterContainer.cxx index 43b62ae747ad..8ad97c3d1717 100644 --- a/chart2/source/view/main/SeriesPlotterContainer.cxx +++ b/chart2/source/view/main/SeriesPlotterContainer.cxx @@ -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) diff --git a/include/oox/export/chartexport.hxx b/include/oox/export/chartexport.hxx index 1b708b83d479..e88bb05dc5d0 100644 --- a/include/oox/export/chartexport.hxx +++ b/include/oox/export/chartexport.hxx @@ -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 ); diff --git a/oox/source/drawingml/chart/typegroupcontext.cxx b/oox/source/drawingml/chart/typegroupcontext.cxx index 9604e58a2507..393073261533 100644 --- a/oox/source/drawingml/chart/typegroupcontext.cxx +++ b/oox/source/drawingml/chart/typegroupcontext.cxx @@ -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 ); diff --git a/oox/source/drawingml/chart/typegroupconverter.cxx b/oox/source/drawingml/chart/typegroupconverter.cxx index 9127e7d47006..71be134a9f03 100644 --- a/oox/source/drawingml/chart/typegroupconverter.cxx +++ b/oox/source/drawingml/chart/typegroupconverter.cxx @@ -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); } diff --git a/oox/source/drawingml/chart/typegroupmodel.cxx b/oox/source/drawingml/chart/typegroupmodel.cxx index 9479f93c4939..257237a8a57c 100644 --- a/oox/source/drawingml/chart/typegroupmodel.cxx +++ b/oox/source/drawingml/chart/typegroupmodel.cxx @@ -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 ), diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 78d3d4cbcebf..261b6c2a96e1 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -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 ) ); } diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index 0cb978129ccc..d73008a80539 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -555,6 +555,7 @@ SpinIncrement SpinValue SpinValueMax SpinValueMin +SplitPos StackCharacters StackingDirection StartPosition diff --git a/schema/libreoffice/OpenDocument-v1.4+libreoffice-schema.rng b/schema/libreoffice/OpenDocument-v1.4+libreoffice-schema.rng index 7ae65dc531ee..e874f15852fc 100644 --- a/schema/libreoffice/OpenDocument-v1.4+libreoffice-schema.rng +++ b/schema/libreoffice/OpenDocument-v1.4+libreoffice-schema.rng @@ -2765,6 +2765,15 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1. <!-- 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> <rng:attribute name="loext:sub-bar"> <rng:ref name="boolean"/> </rng:attribute> diff --git a/xmloff/inc/xmlprop.hxx b/xmloff/inc/xmlprop.hxx index 8f47e328ff44..dd48cb11ff63 100644 --- a/xmloff/inc/xmlprop.hxx +++ b/xmloff/inc/xmlprop.hxx @@ -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; diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx index c79071dac166..a6cd20a3d54f 100644 --- a/xmloff/source/chart/SchXMLChartContext.cxx +++ b/xmloff/source/chart/SchXMLChartContext.cxx @@ -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)); } } diff --git a/xmloff/source/chart/SchXMLChartContext.hxx b/xmloff/source/chart/SchXMLChartContext.hxx index b7f94fa6c986..563ae2ebe8e1 100644 --- a/xmloff/source/chart/SchXMLChartContext.hxx +++ b/xmloff/source/chart/SchXMLChartContext.hxx @@ -101,6 +101,7 @@ private: css::chart::ChartDataRowSource meDataRowSource; bool mbIsStockChart; css::chart2::PieChartSubType mPieSubType; + double mfPieSplitPos; OUString msCategoriesAddress; OUString msChartAddress; diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index 4e3fa02b7651..f58904997ce6 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -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 |