summaryrefslogtreecommitdiff
path: root/chart2/source/model/template
diff options
context:
space:
mode:
authorTünde Tóth <toth.tunde@nisz.hu>2020-08-10 10:26:06 +0200
committerLászló Németh <nemeth@numbertext.org>2020-08-24 12:08:10 +0200
commit22cd7d8b679d238559820d3c4cd5ff0b9153ffce (patch)
treedfddc9d167fa0e63c6bb72ace0d1253e5fe8de98 /chart2/source/model/template
parent738a50f1f4fc1e95a72912377c85fda0e9efc7dd (diff)
tdf#123218 tdf#108067 config key ReverseXAxisOrientationDoughnutChart
for OOXML compatibility of newly created doughnut charts. The X axis orientation of doughnut charts is the opposite of the primary writing direction in LibreOffice but not in Microsoft Office. Default value is "true" to keep current behavior. Using "false", the inner and outer data series of new doughnut charts are the same, as after DOCX export. Change-Id: If431d5717e70599f07231bd673cd90c196450ae6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100417 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'chart2/source/model/template')
-rw-r--r--chart2/source/model/template/PieChartTypeTemplate.cxx23
1 files changed, 20 insertions, 3 deletions
diff --git a/chart2/source/model/template/PieChartTypeTemplate.cxx b/chart2/source/model/template/PieChartTypeTemplate.cxx
index 964b5d96d5c2..ec08764a7509 100644
--- a/chart2/source/model/template/PieChartTypeTemplate.cxx
+++ b/chart2/source/model/template/PieChartTypeTemplate.cxx
@@ -32,6 +32,7 @@
#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <officecfg/Office/Compatibility.hxx>
#include <tools/diagnose_ex.h>
#include <rtl/math.hxx>
@@ -245,7 +246,12 @@ void PieChartTypeTemplate::adaptScales(
if( xAxis.is() )
{
chart2::ScaleData aScaleData( xAxis->getScaleData() );
- aScaleData.Orientation = chart2::AxisOrientation_REVERSE;
+
+ //tdf#123218 Don't reverse the orientation in OOXML-heavy environments
+ if( officecfg::Office::Compatibility::View::ReverseXAxisOrientationDoughnutChart::get() )
+ aScaleData.Orientation = chart2::AxisOrientation_REVERSE;
+ else
+ aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
xAxis->setScaleData( aScaleData );
}
}
@@ -316,15 +322,20 @@ sal_Bool SAL_CALL PieChartTypeTemplate::matchesTemplate(
{
double fOffset=0.0;
bool bAllOffsetsEqual = true;
+ sal_Int32 nOuterSeriesIndex = 0;
std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ //tdf#108067 The outer series is the last series in OOXML-heavy environments
+ if( !officecfg::Office::Compatibility::View::ReverseXAxisOrientationDoughnutChart::get() )
+ nOuterSeriesIndex = aSeriesVec.size() - 1;
+
//check offset of outer series
if( !aSeriesVec.empty() )
{
//@todo in future this will depend on Orientation of the radius axis scale
- Reference< chart2::XDataSeries > xSeries( aSeriesVec[0] );
+ Reference< chart2::XDataSeries > xSeries( aSeriesVec[nOuterSeriesIndex] );
Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY_THROW );
xProp->getPropertyValue( "Offset") >>= fOffset;
@@ -450,8 +461,14 @@ void SAL_CALL PieChartTypeTemplate::applyStyle(
uno::Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY_THROW );
bool bTemplateUsesRings = false;
+ sal_Int32 nOuterSeriesIndex = 0;
getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS ) >>= bTemplateUsesRings;
- if( nSeriesIndex == 0 ) //@todo in future this will depend on Orientation of the radius axis scale
+
+ //tdf#108067 The outer series is the last series in OOXML-heavy environments
+ if( !officecfg::Office::Compatibility::View::ReverseXAxisOrientationDoughnutChart::get() )
+ nOuterSeriesIndex = nSeriesCount - 1;
+
+ if( nSeriesIndex == nOuterSeriesIndex ) //@todo in future this will depend on Orientation of the radius axis scale
{
const OUString aOffsetPropName( "Offset" );
// get offset mode