diff options
author | Balazs Varga <balazs.varga991@gmail.com> | 2020-01-15 16:31:35 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-01-30 10:43:02 +0100 |
commit | 4223ff2be69f03e571464b0b09ad0d278918631b (patch) | |
tree | 7205f05cf9773f53f0ad4433703055794eb3f997 /oox | |
parent | e265037d6c655675416116b19882c3c29bb7bf40 (diff) |
tdf#48436 Chart: add CustomLabelPosition UNO API property
and CUSTOM DataLabelPlacement to support custom data label positions,
and its initial implementation: only UI support with OOXML import
(tdf#130030), yet.
Change-Id: I01d986071d78ae3e2a5f43d5711e9f60b8410c21
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86859
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/chart/seriesconverter.cxx | 31 | ||||
-rw-r--r-- | oox/source/token/properties.txt | 1 |
2 files changed, 22 insertions, 10 deletions
diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx index 62f78a28e383..d47d897c5a91 100644 --- a/oox/source/drawingml/chart/seriesconverter.cxx +++ b/oox/source/drawingml/chart/seriesconverter.cxx @@ -20,6 +20,7 @@ #include <drawingml/chart/seriesconverter.hxx> #include <com/sun/star/chart/DataLabelPlacement.hpp> +#include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/chart/ErrorBarStyle.hpp> #include <com/sun/star/chart2/DataPointLabel.hpp> #include <com/sun/star/chart2/XDataPointCustomLabelField.hpp> @@ -273,22 +274,32 @@ void DataLabelConverter::convertFromModel( const Reference< XDataSeries >& rxDat lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, false, bMSO2007Doc ); const TypeGroupInfo& rTypeInfo = rTypeGroup.getTypeInfo(); bool bIsPie = rTypeInfo.meTypeCategory == TYPECATEGORY_PIE; - if( mrModel.mxLayout && !mrModel.mxLayout->mbAutoLayout && !bIsPie ) + + if( mrModel.mxLayout && !mrModel.mxLayout->mbAutoLayout ) { - // bnc#694340 - nasty hack - chart2 cannot individually - // place data labels, let's try to find a useful - // compromise instead - namespace csscd = ::com::sun::star::chart::DataLabelPlacement; - const sal_Int32 aPositionsLookupTable[] = + if( rTypeInfo.meTypeCategory == TYPECATEGORY_BAR ) + { + // It is only works for BAR Chart, yet!!! + RelativePosition aPos(mrModel.mxLayout->mfX, mrModel.mxLayout->mfY, css::drawing::Alignment_TOP_LEFT); + aPropSet.setProperty(PROP_CustomLabelPosition, aPos); + } + else if( !bIsPie ) + { + // bnc#694340 - nasty hack - chart2 cannot individually + // place data labels, let's try to find a useful + // compromise instead + namespace csscd = ::com::sun::star::chart::DataLabelPlacement; + const sal_Int32 aPositionsLookupTable[] = { csscd::TOP_LEFT, csscd::TOP, csscd::TOP_RIGHT, csscd::LEFT, csscd::CENTER, csscd::RIGHT, csscd::BOTTOM_LEFT, csscd::BOTTOM, csscd::BOTTOM_RIGHT }; - const int simplifiedX = lclGetPositionX(mrModel.mxLayout->mfX); - const int simplifiedY = lclGetPositionY(mrModel.mxLayout->mfY); - aPropSet.setProperty( PROP_LabelPlacement, - aPositionsLookupTable[ simplifiedX+1 + 3*(simplifiedY+1) ] ); + const int simplifiedX = lclGetPositionX(mrModel.mxLayout->mfX); + const int simplifiedY = lclGetPositionY(mrModel.mxLayout->mfY); + aPropSet.setProperty(PROP_LabelPlacement, + aPositionsLookupTable[simplifiedX + 1 + 3 * (simplifiedY + 1)]); + } } if (mrModel.mxShapeProp) diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index b7a76058d688..de9cd886643a 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -113,6 +113,7 @@ CursorPositionX CursorPositionY CurveName CurveStyle +CustomLabelPosition CustomShapeGeometry D3DSceneAmbientColor D3DSceneLightColor2 |