summaryrefslogtreecommitdiff
path: root/chart2/source
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2020-02-12 13:47:50 +0100
committerLászló Németh <nemeth@numbertext.org>2020-02-20 11:18:40 +0100
commit769433ad93040bc81f06672c8a2c01e2b76fece3 (patch)
treef2f12845bc7486d4d7af0d0303dc201ebd6db4a6 /chart2/source
parentc6f5e12ee3f91234b064222272d756670f3bb207 (diff)
tdf#90749 chart: add leader lines to custom data label positions
also export them as CustomXML extension for MSO interoperability. Note: pie chart is not yet supported. See commit 4223ff2be69f03e571464b0b09ad0d278918631b ( tdf#48436 Chart: add CustomLabelPosition UNO API property) Change-Id: Ia8142408414d4ad8f689d789386db50038ed13f6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88531 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'chart2/source')
-rw-r--r--chart2/source/view/charttypes/VSeriesPlotter.cxx36
1 files changed, 36 insertions, 0 deletions
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index b6382943b418..2c46743696f6 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -19,6 +19,7 @@
#include <memory>
#include <VSeriesPlotter.hxx>
+#include <BaseGFXHelper.hxx>
#include <VLineProperties.hxx>
#include <ShapeFactory.hxx>
@@ -86,6 +87,7 @@
namespace chart {
using namespace ::com::sun::star;
+using namespace ::com::sun::star::chart;
using namespace ::com::sun::star::chart2;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -721,7 +723,41 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re
{
awt::Point aRelPos = rDataSeries.getLabelPosition(aTextShapePos, nPointIndex);
if( aRelPos.X != -1 )
+ {
xTextShape->setPosition(aRelPos);
+ if( !m_xChartTypeModel->getChartType().equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
+ {
+ sal_Int32 nX1 = rScreenPosition2D.X;
+ sal_Int32 nY1 = rScreenPosition2D.Y;
+ sal_Int32 nX2 = nX1;
+ sal_Int32 nY2 = nY1;
+ ::basegfx::B2IRectangle aRect(BaseGFXHelper::makeRectangle(aRelPos, xTextShape->getSize()));
+ if (nX1 < aRelPos.X)
+ nX2 = aRelPos.X;
+ else if (nX1 > aRect.getMaxX())
+ nX2 = aRect.getMaxX();
+
+ if (nY1 < aRect.getMinY())
+ nY2 = aRect.getMinY();
+ else if (nY1 > aRect.getMaxY())
+ nY2 = aRect.getMaxY();
+
+ //when the line is very short compared to the page size don't create one
+ ::basegfx::B2DVector aLength(nX1 - nX2, nY1 - nY2);
+ double fPageDiagonaleLength = sqrt(double(m_aPageReferenceSize.Width)*double(m_aPageReferenceSize.Width) + double(m_aPageReferenceSize.Height)*double(m_aPageReferenceSize.Height));
+ if ((aLength.getLength() / fPageDiagonaleLength) >= 0.01)
+ {
+ drawing::PointSequenceSequence aPoints(1);
+ aPoints[0].realloc(2);
+ aPoints[0][0].X = nX1;
+ aPoints[0][0].Y = nY1;
+ aPoints[0][1].X = nX2;
+ aPoints[0][1].Y = nY2;
+
+ m_pShapeFactory->createLine2D(xTarget, aPoints, new VLineProperties);
+ }
+ }
+ }
}
// in case legend symbol has to be displayed, text shape position is