tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / chart2 / source / view / charttypes / NetChart.cxx
blob3570fe2042a4782ccea4a3fdb2c0f848fa3bb708
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "NetChart.hxx"
21 #include <PlottingPositionHelper.hxx>
22 #include <ShapeFactory.hxx>
23 #include <ExplicitCategoriesProvider.hxx>
24 #include <CommonConverters.hxx>
25 #include <ObjectIdentifier.hxx>
26 #include <LabelPositionHelper.hxx>
27 #include <Clipping.hxx>
28 #include <PolarLabelPositionHelper.hxx>
29 #include <DateHelper.hxx>
30 #include <ChartType.hxx>
32 #include <com/sun/star/chart2/Symbol.hpp>
33 #include <com/sun/star/chart/DataLabelPlacement.hpp>
34 #include <com/sun/star/chart/MissingValueTreatment.hpp>
36 #include <o3tl/safeint.hxx>
37 #include <osl/diagnose.h>
39 #include <officecfg/Office/Compatibility.hxx>
41 #include <limits>
43 namespace chart
45 using namespace ::com::sun::star;
46 using namespace ::com::sun::star::chart2;
48 NetChart::NetChart( const rtl::Reference<ChartType>& xChartTypeModel
49 , sal_Int32 nDimensionCount
50 , bool bNoArea
51 , std::unique_ptr<PlottingPositionHelper> pPlottingPositionHelper
53 : VSeriesPlotter( xChartTypeModel, nDimensionCount, true )
54 , m_pMainPosHelper(std::move(pPlottingPositionHelper))
55 , m_bArea(!bNoArea)
56 , m_bLine(bNoArea)
58 // we only support 2D Net charts
59 assert(nDimensionCount == 2);
61 m_pMainPosHelper->AllowShiftXAxisPos(true);
62 m_pMainPosHelper->AllowShiftZAxisPos(true);
64 PlotterBase::m_pPosHelper = m_pMainPosHelper.get();
65 VSeriesPlotter::m_pMainPosHelper = m_pMainPosHelper.get();
68 NetChart::~NetChart()
72 double NetChart::getMaximumX()
74 double fMax = VSeriesPlotter::getMaximumX() + 1.0;
75 return fMax;
78 bool NetChart::isExpandIfValuesCloseToBorder( sal_Int32 )
80 return false;
83 bool NetChart::isSeparateStackingForDifferentSigns( sal_Int32 /*nDimensionIndex*/ )
85 // no separate stacking in all types of line/area charts
86 return false;
89 LegendSymbolStyle NetChart::getLegendSymbolStyle()
91 if( m_bArea )
92 return LegendSymbolStyle::Box;
93 return LegendSymbolStyle::Line;
96 uno::Any NetChart::getExplicitSymbol( const VDataSeries& rSeries, sal_Int32 nPointIndex )
98 uno::Any aRet;
100 Symbol* pSymbolProperties = rSeries.getSymbolProperties( nPointIndex );
101 if( pSymbolProperties )
103 aRet <<= *pSymbolProperties;
106 return aRet;
109 drawing::Direction3D NetChart::getPreferredDiagramAspectRatio() const
111 return drawing::Direction3D(1,1,1);
114 bool NetChart::impl_createLine( VDataSeries* pSeries
115 , const std::vector<std::vector<css::drawing::Position3D>>* pSeriesPoly
116 , PlottingPositionHelper const * pPosHelper )
118 //return true if a line was created successfully
119 rtl::Reference<SvxShapeGroupAnyD> xSeriesGroupShape_Shapes = getSeriesGroupShapeBackChild(pSeries, m_xSeriesTarget);
121 std::vector<std::vector<css::drawing::Position3D>> aPoly;
123 bool bIsClipped = false;
124 if( !ShapeFactory::isPolygonEmptyOrSinglePoint(*pSeriesPoly) )
126 // do NOT connect last and first point, if one is NAN, and NAN handling is NAN_AS_GAP
127 double fFirstY = pSeries->getYValue( 0 );
128 double fLastY = pSeries->getYValue( VSeriesPlotter::getPointCount() - 1 );
129 if( (pSeries->getMissingValueTreatment() != css::chart::MissingValueTreatment::LEAVE_GAP)
130 || (std::isfinite( fFirstY ) && std::isfinite( fLastY )) )
132 // connect last point in last polygon with first point in first polygon
133 ::basegfx::B2DRectangle aScaledLogicClipDoubleRect( pPosHelper->getScaledLogicClipDoubleRect() );
134 std::vector<std::vector<css::drawing::Position3D>> aTmpPoly(*pSeriesPoly);
135 drawing::Position3D aLast(aScaledLogicClipDoubleRect.getMaxX(),aTmpPoly[0][0].PositionY,aTmpPoly[0][0].PositionZ);
136 // add connector line to last polygon
137 AddPointToPoly( aTmpPoly, aLast, pSeriesPoly->size() - 1 );
138 Clipping::clipPolygonAtRectangle( aTmpPoly, aScaledLogicClipDoubleRect, aPoly );
139 bIsClipped = true;
143 if( !bIsClipped )
144 Clipping::clipPolygonAtRectangle( *pSeriesPoly, pPosHelper->getScaledLogicClipDoubleRect(), aPoly );
147 if(!ShapeFactory::hasPolygonAnyLines(aPoly))
148 return false;
150 //transformation 3) -> 4)
151 pPosHelper->transformScaledLogicToScene( aPoly );
153 //create line:
154 rtl::Reference<SvxShapePolyPolygon> xShape;
156 xShape = ShapeFactory::createLine2D( xSeriesGroupShape_Shapes, aPoly );
157 PropertyMapper::setMappedProperties( *xShape
158 , pSeries->getPropertiesOfSeries()
159 , PropertyMapper::getPropertyNameMapForLineSeriesProperties() );
160 //because of this name this line will be used for marking
161 ::chart::ShapeFactory::setShapeName(xShape, u"MarkHandles"_ustr);
163 return true;
166 bool NetChart::impl_createArea( VDataSeries* pSeries
167 , const std::vector<std::vector<css::drawing::Position3D>>* pSeriesPoly
168 , std::vector<std::vector<css::drawing::Position3D>> const * pPreviousSeriesPoly
169 , PlottingPositionHelper const * pPosHelper )
171 //return true if an area was created successfully
173 rtl::Reference<SvxShapeGroupAnyD> xSeriesGroupShape_Shapes = getSeriesGroupShapeBackChild(pSeries, m_xSeriesTarget);
174 double zValue = pSeries->m_fLogicZPos;
176 std::vector<std::vector<css::drawing::Position3D>> aPoly( *pSeriesPoly );
177 //add second part to the polygon (grounding points or previous series points)
178 if( !ShapeFactory::isPolygonEmptyOrSinglePoint(*pSeriesPoly) )
180 if( pPreviousSeriesPoly )
181 addPolygon( aPoly, *pPreviousSeriesPoly );
183 else if(!pPreviousSeriesPoly)
185 double fMinX = pSeries->m_fLogicMinX;
186 double fMaxX = pSeries->m_fLogicMaxX;
187 double fY = pPosHelper->getBaseValueY();//logic grounding
189 //clip to scale
190 if(fMaxX<pPosHelper->getLogicMinX() || fMinX>pPosHelper->getLogicMaxX())
191 return false;//no visible shape needed
192 pPosHelper->clipLogicValues( &fMinX, &fY, nullptr );
193 pPosHelper->clipLogicValues( &fMaxX, nullptr, nullptr );
195 //apply scaling
197 pPosHelper->doLogicScaling( &fMinX, &fY, &zValue );
198 pPosHelper->doLogicScaling( &fMaxX, nullptr, nullptr );
201 AddPointToPoly( aPoly, drawing::Position3D( fMaxX,fY,zValue) );
202 AddPointToPoly( aPoly, drawing::Position3D( fMinX,fY,zValue) );
204 else
206 appendPoly( aPoly, *pPreviousSeriesPoly );
208 ShapeFactory::closePolygon(aPoly);
210 //apply clipping
212 std::vector<std::vector<css::drawing::Position3D>> aClippedPoly;
213 Clipping::clipPolygonAtRectangle( aPoly, pPosHelper->getScaledLogicClipDoubleRect(), aClippedPoly, false );
214 ShapeFactory::closePolygon(aClippedPoly); //again necessary after clipping
215 aPoly = std::move(aClippedPoly);
218 if(!ShapeFactory::hasPolygonAnyLines(aPoly))
219 return false;
221 //transformation 3) -> 4)
222 pPosHelper->transformScaledLogicToScene( aPoly );
224 //create area:
225 rtl::Reference<SvxShapePolyPolygon>
226 xShape = ShapeFactory::createArea2D( xSeriesGroupShape_Shapes
227 , aPoly );
228 PropertyMapper::setMappedProperties( *xShape
229 , pSeries->getPropertiesOfSeries()
230 , PropertyMapper::getPropertyNameMapForFilledSeriesProperties() );
231 //because of this name this line will be used for marking
232 ::chart::ShapeFactory::setShapeName(xShape, u"MarkHandles"_ustr);
233 return true;
236 void NetChart::impl_createSeriesShapes()
238 //the polygon shapes for each series need to be created before
240 //iterate through all series again to create the series shapes
241 for( auto const& rZSlot : m_aZSlots )
243 for( auto const& rXSlot : rZSlot )
245 std::map< sal_Int32, std::vector<std::vector<css::drawing::Position3D>>* > aPreviousSeriesPolyMap;//a PreviousSeriesPoly for each different nAttachedAxisIndex
246 std::vector<std::vector<css::drawing::Position3D>>* pSeriesPoly = nullptr;
248 //iterate through all series
249 for( std::unique_ptr<VDataSeries> const & pSeries : rXSlot.m_aSeriesVector )
251 sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex();
252 m_pPosHelper = &getPlottingPositionHelper(nAttachedAxisIndex);
254 pSeriesPoly = &pSeries->m_aPolyPolygonShape3D;
255 if( m_bArea )
257 if (!impl_createArea(pSeries.get(), pSeriesPoly,
258 aPreviousSeriesPolyMap[nAttachedAxisIndex], m_pPosHelper))
259 continue;
261 if( m_bLine )
263 if (!impl_createLine(pSeries.get(), pSeriesPoly, m_pPosHelper))
264 continue;
266 aPreviousSeriesPolyMap[nAttachedAxisIndex] = pSeriesPoly;
267 }//next series in x slot (next y slot)
268 }//next x slot
269 }//next z slot
272 namespace
275 void lcl_reorderSeries( std::vector< std::vector< VDataSeriesGroup > >& rZSlots )
277 std::vector< std::vector< VDataSeriesGroup > > aRet;
278 aRet.reserve( rZSlots.size() );
280 std::vector< std::vector< VDataSeriesGroup > >::reverse_iterator aZIt( rZSlots.rbegin() );
281 std::vector< std::vector< VDataSeriesGroup > >::reverse_iterator aZEnd( rZSlots.rend() );
282 for( ; aZIt != aZEnd; ++aZIt )
284 std::vector< VDataSeriesGroup > aXSlot;
286 std::vector< VDataSeriesGroup >::reverse_iterator aXIt( aZIt->rbegin() );
287 std::vector< VDataSeriesGroup >::reverse_iterator aXEnd( aZIt->rend() );
288 for( ; aXIt != aXEnd; ++aXIt )
289 aXSlot.push_back(std::move(*aXIt));
291 aRet.push_back(std::move(aXSlot));
294 rZSlots = std::move(aRet);
297 //better performance for big data
298 struct FormerPoint
300 FormerPoint( double fX, double fY, double fZ )
301 : m_fX(fX), m_fY(fY), m_fZ(fZ)
303 FormerPoint()
304 : m_fX(std::numeric_limits<double>::quiet_NaN())
305 , m_fY(std::numeric_limits<double>::quiet_NaN())
306 , m_fZ(std::numeric_limits<double>::quiet_NaN())
311 double m_fX;
312 double m_fY;
313 double m_fZ;
316 }//anonymous namespace
318 void NetChart::createShapes()
320 if( m_aZSlots.empty() ) //no series
321 return;
323 //tdf#127813 Don't reverse the series in OOXML-heavy environments
324 if (officecfg::Office::Compatibility::View::ReverseSeriesOrderAreaAndNetChart::get() && m_bArea)
325 lcl_reorderSeries( m_aZSlots );
327 OSL_ENSURE(m_xLogicTarget.is()&&m_xFinalTarget.is(),"NetChart is not proper initialized");
328 if(!(m_xLogicTarget.is()&&m_xFinalTarget.is()))
329 return;
331 //the text labels should be always on top of the other series shapes
332 //for area chart the error bars should be always on top of the other series shapes
334 //therefore create an own group for the texts and the error bars to move them to front
335 //(because the text group is created after the series group the texts are displayed on top)
336 m_xSeriesTarget = createGroupShape( m_xLogicTarget );
337 m_xTextTarget = ShapeFactory::createGroup2D( m_xFinalTarget );
339 //check necessary here that different Y axis can not be stacked in the same group? ... hm?
341 //update/create information for current group
342 double fLogicZ = 1.0;//as defined
344 sal_Int32 const nStartIndex = 0; // inclusive ;..todo get somehow from x scale
345 sal_Int32 nEndIndex = VSeriesPlotter::getPointCount();
346 if(nEndIndex<=0)
347 nEndIndex=1;
349 //better performance for big data
350 std::map< VDataSeries*, FormerPoint > aSeriesFormerPointMap;
351 m_bPointsWereSkipped = false;
353 bool bDateCategory = (m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis());
355 //iterate through all x values per indices
356 for( sal_Int32 nIndex = nStartIndex; nIndex < nEndIndex; nIndex++ )
358 std::map< sal_Int32, double > aLogicYSumMap;//one for each different nAttachedAxisIndex
359 for( auto const& rZSlot : m_aZSlots )
361 //iterate through all x slots in this category to get 100percent sum
362 for( auto const& rXSlot : rZSlot )
364 for( std::unique_ptr<VDataSeries> const & pSeries : rXSlot.m_aSeriesVector )
366 if(!pSeries)
367 continue;
369 if (bDateCategory)
370 pSeries->doSortByXValues();
372 sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex();
373 aLogicYSumMap.insert({nAttachedAxisIndex, 0.0});
375 m_pPosHelper = &getPlottingPositionHelper(nAttachedAxisIndex);
377 double fAdd = pSeries->getYValue( nIndex );
378 if( !std::isnan(fAdd) && !std::isinf(fAdd) )
379 aLogicYSumMap[nAttachedAxisIndex] += fabs( fAdd );
384 for( auto const& rZSlot : m_aZSlots )
386 //for the area chart there should be at most one x slot (no side by side stacking available)
387 //attention different: xSlots are always interpreted as independent areas one behind the other: @todo this doesn't work why not???
388 for( auto const& rXSlot : rZSlot )
390 std::map< sal_Int32, double > aLogicYForNextSeriesMap;//one for each different nAttachedAxisIndex
391 //iterate through all series
392 for( std::unique_ptr<VDataSeries> const & pSeries : rXSlot.m_aSeriesVector )
394 if(!pSeries)
395 continue;
397 /* #i70133# ignore points outside of series length in standard area
398 charts. Stacked area charts will use missing points as zeros. In
399 standard charts, pSeriesList contains only one series. */
400 if( m_bArea && (rXSlot.m_aSeriesVector.size() == 1) && (nIndex >= pSeries->getTotalPointCount()) )
401 continue;
403 rtl::Reference<SvxShapeGroupAnyD> xSeriesGroupShape_Shapes = getSeriesGroupShapeFrontChild(pSeries.get(), m_xSeriesTarget);
405 sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex();
406 m_pPosHelper = &getPlottingPositionHelper(nAttachedAxisIndex);
408 pSeries->m_fLogicZPos = fLogicZ;
410 //collect data point information (logic coordinates, style ):
411 double fLogicX = pSeries->getXValue(nIndex);
412 if (bDateCategory)
413 fLogicX = DateHelper::RasterizeDateValue( fLogicX, m_aNullDate, m_nTimeResolution );
414 double fLogicY = pSeries->getYValue(nIndex);
416 if( m_bArea && ( std::isnan(fLogicY) || std::isinf(fLogicY) ) )
418 if( pSeries->getMissingValueTreatment() == css::chart::MissingValueTreatment::LEAVE_GAP )
420 if( rXSlot.m_aSeriesVector.size() == 1 || pSeries == rXSlot.m_aSeriesVector.front() )
422 fLogicY = m_pPosHelper->getLogicMinY();
423 if (!m_pPosHelper->isMathematicalOrientationY())
424 fLogicY = m_pPosHelper->getLogicMaxY();
426 else
427 fLogicY = 0.0;
431 if (m_pPosHelper->isPercentY() && aLogicYSumMap[nAttachedAxisIndex] != 0.0)
433 fLogicY = fabs( fLogicY )/aLogicYSumMap[nAttachedAxisIndex];
436 if( std::isnan(fLogicX) || std::isinf(fLogicX)
437 || std::isnan(fLogicY) || std::isinf(fLogicY)
438 || std::isnan(fLogicZ) || std::isinf(fLogicZ) )
440 if( pSeries->getMissingValueTreatment() == css::chart::MissingValueTreatment::LEAVE_GAP )
442 std::vector<std::vector<css::drawing::Position3D>>& rPolygon = pSeries->m_aPolyPolygonShape3D;
443 sal_Int32& rIndex = pSeries->m_nPolygonIndex;
444 if( 0<= rIndex && o3tl::make_unsigned(rIndex) < rPolygon.size() )
446 if( !rPolygon[ rIndex ].empty() )
447 rIndex++; //start a new polygon for the next point if the current poly is not empty
450 continue;
453 aLogicYForNextSeriesMap.try_emplace(nAttachedAxisIndex, 0.0);
455 double fLogicValueForLabeDisplay = fLogicY;
457 fLogicY += aLogicYForNextSeriesMap[nAttachedAxisIndex];
458 aLogicYForNextSeriesMap[nAttachedAxisIndex] = fLogicY;
460 bool bIsVisible = m_pPosHelper->isLogicVisible(fLogicX, fLogicY, fLogicZ);
462 //remind minimal and maximal x values for area 'grounding' points
463 //only for filled area
465 double& rfMinX = pSeries->m_fLogicMinX;
466 if(!nIndex||fLogicX<rfMinX)
467 rfMinX=fLogicX;
468 double& rfMaxX = pSeries->m_fLogicMaxX;
469 if(!nIndex||fLogicX>rfMaxX)
470 rfMaxX=fLogicX;
473 drawing::Position3D aUnscaledLogicPosition( fLogicX, fLogicY, fLogicZ );
474 drawing::Position3D aScaledLogicPosition(aUnscaledLogicPosition);
475 m_pPosHelper->doLogicScaling(aScaledLogicPosition);
477 //transformation 3) -> 4)
478 drawing::Position3D aScenePosition(
479 m_pPosHelper->transformLogicToScene(fLogicX, fLogicY, fLogicZ, false));
481 //better performance for big data
482 FormerPoint aFormerPoint( aSeriesFormerPointMap[pSeries.get()] );
483 m_pPosHelper->setCoordinateSystemResolution(m_aCoordinateSystemResolution);
484 if( !pSeries->isAttributedDataPoint(nIndex)
485 && m_pPosHelper->isSameForGivenResolution(
486 aFormerPoint.m_fX, aFormerPoint.m_fY, aFormerPoint.m_fZ
487 , aScaledLogicPosition.PositionX, aScaledLogicPosition.PositionY, aScaledLogicPosition.PositionZ ) )
489 m_bPointsWereSkipped = true;
490 continue;
492 aSeriesFormerPointMap[pSeries.get()] = FormerPoint(aScaledLogicPosition.PositionX, aScaledLogicPosition.PositionY, aScaledLogicPosition.PositionZ);
494 //store point information for series polygon
495 //for area and/or line (symbols only do not need this)
496 if( isValidPosition(aScaledLogicPosition) )
498 AddPointToPoly( pSeries->m_aPolyPolygonShape3D, aScaledLogicPosition, pSeries->m_nPolygonIndex );
500 //prepare clipping for filled net charts
501 if( !bIsVisible && m_bArea )
503 drawing::Position3D aClippedPos(aScaledLogicPosition);
504 m_pPosHelper->clipScaledLogicValues(nullptr, &aClippedPos.PositionY,
505 nullptr);
506 if (m_pPosHelper->isLogicVisible(aClippedPos.PositionX,
507 aClippedPos.PositionY,
508 aClippedPos.PositionZ))
510 AddPointToPoly( pSeries->m_aPolyPolygonShape3D, aClippedPos, pSeries->m_nPolygonIndex );
511 AddPointToPoly( pSeries->m_aPolyPolygonShape3D, aScaledLogicPosition, pSeries->m_nPolygonIndex );
516 //create a single datapoint if point is visible
517 //apply clipping:
518 if( !bIsVisible )
519 continue;
521 Symbol* pSymbolProperties = pSeries->getSymbolProperties( nIndex );
522 bool bCreateSymbol = pSymbolProperties && (pSymbolProperties->Style != SymbolStyle_NONE);
524 if( !bCreateSymbol && !pSeries->getDataPointLabelIfLabel(nIndex) )
525 continue;
527 //create a group shape for this point and add to the series shape:
528 OUString aPointCID = ObjectIdentifier::createPointCID(
529 pSeries->getPointCID_Stub(), nIndex );
530 rtl::Reference<SvxShapeGroupAnyD> xPointGroupShape_Shapes(
531 createGroupShape(xSeriesGroupShape_Shapes,aPointCID) );
534 //create data point
535 drawing::Direction3D aSymbolSize(0,0,0);
536 if (bCreateSymbol) // implies pSymbolProperties
538 if (pSymbolProperties->Style != SymbolStyle_NONE)
540 aSymbolSize.DirectionX = pSymbolProperties->Size.Width;
541 aSymbolSize.DirectionY = pSymbolProperties->Size.Height;
544 if (pSymbolProperties->Style == SymbolStyle_STANDARD)
546 sal_Int32 nSymbol = pSymbolProperties->StandardSymbol;
547 ShapeFactory::createSymbol2D(
548 xPointGroupShape_Shapes, aScenePosition, aSymbolSize, nSymbol,
549 pSymbolProperties->BorderColor, pSymbolProperties->FillColor);
551 else if (pSymbolProperties->Style == SymbolStyle_GRAPHIC)
553 ShapeFactory::createGraphic2D(xPointGroupShape_Shapes,
554 aScenePosition, aSymbolSize,
555 pSymbolProperties->Graphic);
557 //@todo other symbol styles
560 //create data point label
561 if( pSeries->getDataPointLabelIfLabel(nIndex) )
563 LabelAlignment eAlignment = LABEL_ALIGN_TOP;
564 drawing::Position3D aScenePosition3D( aScenePosition.PositionX
565 , aScenePosition.PositionY
566 , aScenePosition.PositionZ+getTransformedDepth() );
568 sal_Int32 nLabelPlacement = pSeries->getLabelPlacement(
569 nIndex, m_xChartTypeModel, m_pPosHelper->isSwapXAndY());
571 switch(nLabelPlacement)
573 case css::chart::DataLabelPlacement::TOP:
574 aScenePosition3D.PositionY -= (aSymbolSize.DirectionY/2+1);
575 eAlignment = LABEL_ALIGN_TOP;
576 break;
577 case css::chart::DataLabelPlacement::BOTTOM:
578 aScenePosition3D.PositionY += (aSymbolSize.DirectionY/2+1);
579 eAlignment = LABEL_ALIGN_BOTTOM;
580 break;
581 case css::chart::DataLabelPlacement::LEFT:
582 aScenePosition3D.PositionX -= (aSymbolSize.DirectionX/2+1);
583 eAlignment = LABEL_ALIGN_LEFT;
584 break;
585 case css::chart::DataLabelPlacement::RIGHT:
586 aScenePosition3D.PositionX += (aSymbolSize.DirectionX/2+1);
587 eAlignment = LABEL_ALIGN_RIGHT;
588 break;
589 case css::chart::DataLabelPlacement::CENTER:
590 eAlignment = LABEL_ALIGN_CENTER;
591 //todo implement this different for area charts
592 break;
593 default:
594 OSL_FAIL("this label alignment is not implemented yet");
595 aScenePosition3D.PositionY -= (aSymbolSize.DirectionY/2+1);
596 eAlignment = LABEL_ALIGN_TOP;
597 break;
600 awt::Point aScreenPosition2D;//get the screen position for the labels
601 sal_Int32 nOffset = 100; //todo maybe calculate this font height dependent
602 if( nLabelPlacement == css::chart::DataLabelPlacement::OUTSIDE )
604 PolarPlottingPositionHelper* pPolarPosHelper
605 = dynamic_cast<PolarPlottingPositionHelper*>(m_pPosHelper);
606 if( pPolarPosHelper )
608 PolarLabelPositionHelper aPolarLabelPositionHelper(pPolarPosHelper,m_nDimension,m_xLogicTarget);
609 aScreenPosition2D = aPolarLabelPositionHelper.getLabelScreenPositionAndAlignmentForLogicValues(
610 eAlignment, fLogicX, fLogicY, fLogicZ, nOffset );
613 else
615 if(eAlignment==LABEL_ALIGN_CENTER )
616 nOffset = 0;
617 aScreenPosition2D = LabelPositionHelper(m_nDimension,m_xLogicTarget)
618 .transformSceneToScreenPosition( aScenePosition3D );
621 createDataLabel( m_xTextTarget, *pSeries, nIndex
622 , fLogicValueForLabeDisplay
623 , aLogicYSumMap[nAttachedAxisIndex], aScreenPosition2D, eAlignment, nOffset );
627 //remove PointGroupShape if empty
628 if(!xPointGroupShape_Shapes->getCount())
629 xSeriesGroupShape_Shapes->remove(xPointGroupShape_Shapes);
631 }//next series in x slot (next y slot)
632 }//next x slot
633 }//next z slot
634 }//next category
636 impl_createSeriesShapes();
640 } //namespace chart
642 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */