From 4223ff2be69f03e571464b0b09ad0d278918631b Mon Sep 17 00:00:00 2001 From: Balazs Varga Date: Wed, 15 Jan 2020 16:31:35 +0100 Subject: tdf#48436 Chart: add CustomLabelPosition UNO API property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Tested-by: László Németh --- oox/source/drawingml/chart/seriesconverter.cxx | 31 +++++++++++++++++--------- oox/source/token/properties.txt | 1 + 2 files changed, 22 insertions(+), 10 deletions(-) (limited to 'oox') 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 #include +#include #include #include #include @@ -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 -- cgit