summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2018-01-03 13:24:32 +0100
committerAndras Timar <andras.timar@collabora.com>2018-02-14 09:59:28 +0100
commit326c9766281e6f80abc042420f1d4be3a27b8aa9 (patch)
tree7c284290087ed15ba638217108ce45ce0ed93d81 /oox
parent615f4846751fb669ea28cc092eadfd3842ab3220 (diff)
tdf#114821 calculate better label position
Positioning hack was improved. It calculates position depending on direct chart size factor. Preffered label positions are: top - vertical, and center - horizontal Change-Id: Ic25f08cd0bc3105fe34841dbc3f8aacacb694d43 Reviewed-on: https://gerrit.libreoffice.org/48909 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/48928 Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/chart/seriesconverter.cxx34
1 files changed, 24 insertions, 10 deletions
diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx
index a1f2cb737c7f..c2a183363a21 100644
--- a/oox/source/drawingml/chart/seriesconverter.cxx
+++ b/oox/source/drawingml/chart/seriesconverter.cxx
@@ -54,13 +54,30 @@ using namespace ::com::sun::star::uno;
namespace {
-/** nested-up sgn function - employs some gratuity around 0 - values
- smaller than 0.33 are clamped to 0
+/** Function to get vertical position of label from chart height factor.
+ Value can be negative, prefer top placement.
*/
-int lclSgn( double nVal )
+int lclGetPositionY( double nVal )
{
- const int intVal=nVal*3;
- return intVal == 0 ? 0 : (intVal < 0 ? -1 : 1);
+ if( nVal <= 0.1 )
+ return -1;
+ else if( nVal <= 0.6 )
+ return 0;
+ else
+ return 1;
+}
+
+/** Function to get horizontal position of label from chart width factor.
+ Value can be negative, prefer center placement.
+*/
+int lclGetPositionX( double nVal )
+{
+ if( nVal <= -0.2 )
+ return -1;
+ else if( nVal <= 0.2 )
+ return 0;
+ else
+ return 1;
}
Reference< XLabeledDataSequence > lclCreateLabeledDataSequence(
@@ -236,11 +253,8 @@ void DataLabelConverter::convertFromModel( const Reference< XDataSeries >& rxDat
csscd::LEFT, csscd::CENTER, csscd::RIGHT,
csscd::BOTTOM_LEFT, csscd::BOTTOM, csscd::BOTTOM_RIGHT
};
- const double nMax=std::max(
- fabs(mrModel.mxLayout->mfX),
- fabs(mrModel.mxLayout->mfY));
- const int simplifiedX=lclSgn(mrModel.mxLayout->mfX/nMax);
- const int simplifiedY=lclSgn(mrModel.mxLayout->mfY/nMax);
+ const int simplifiedX = lclGetPositionX(mrModel.mxLayout->mfX);
+ const int simplifiedY = lclGetPositionY(mrModel.mxLayout->mfY);
aPropSet.setProperty( PROP_LabelPlacement,
aPositionsLookupTable[ simplifiedX+1 + 3*(simplifiedY+1) ] );
}