nss: upgrade to release 3.73
[LibreOffice.git] / chart2 / source / view / charttypes / NetChart.cxx
bloba8a0f776dd245377015339a78a1d91c4e2d19fbb
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>
31 #include <com/sun/star/chart2/Symbol.hpp>
32 #include <com/sun/star/chart/DataLabelPlacement.hpp>
33 #include <com/sun/star/chart/MissingValueTreatment.hpp>
35 #include <rtl/math.hxx>
36 #include <osl/diagnose.h>
38 #include <com/sun/star/drawing/XShapes.hpp>
39 #include <officecfg/Office/Compatibility.hxx>
41 namespace chart
43 using namespace ::com::sun::star;
44 using namespace ::rtl::math;
45 using namespace ::com::sun::star::chart2;
47 NetChart::NetChart( const uno::Reference<XChartType>& xChartTypeModel
48 , sal_Int32 nDimensionCount
49 , bool bNoArea
50 , std::unique_ptr<PlottingPositionHelper> pPlottingPositionHelper
52 : VSeriesPlotter( xChartTypeModel, nDimensionCount, true )
53 , m_pMainPosHelper(std::move(pPlottingPositionHelper))
54 , m_bArea(!bNoArea)
55 , m_bLine(bNoArea)
57 // we only support 2D Net charts
58 assert(nDimensionCount == 2);
60 m_pMainPosHelper->AllowShiftXAxisPos(true);
61 m_pMainPosHelper->AllowShiftZAxisPos(true);
63 PlotterBase::m_pPosHelper = m_pMainPosHelper.get();
64 VSeriesPlotter::m_pMainPosHelper = m_pMainPosHelper.get();
67 NetChart::~NetChart()
71 double NetChart::getMaximumX()
73 double fMax = VSeriesPlotter::getMaximumX() + 1.0;
74 return fMax;
77 bool NetChart::isExpandIfValuesCloseToBorder( sal_Int32 )
79 return false;
82 bool NetChart::isSeparateStackingForDifferentSigns( sal_Int32 /*nDimensionIndex*/ )
84 // no separate stacking in all types of line/area charts
85 return false;
88 LegendSymbolStyle NetChart::getLegendSymbolStyle()
90 if( m_bArea )
91 return LegendSymbolStyle::Box;
92 return LegendSymbolStyle::Line;
95 uno::Any NetChart::getExplicitSymbol( const VDataSeries& rSeries, sal_Int32 nPointIndex )
97 uno::Any aRet;
99 Symbol* pSymbolProperties = rSeries.getSymbolProperties( nPointIndex );
100 if( pSymbolProperties )
102 aRet <<= *pSymbolProperties;
105 return aRet;
108 drawing::Direction3D NetChart::getPreferredDiagramAspectRatio() const
110 return drawing::Direction3D(1,1,1);
113 bool NetChart::impl_createLine( VDataSeries* pSeries
114 , drawing::PolyPolygonShape3D* pSeriesPoly
115 , PlottingPositionHelper const * pPosHelper )
117 //return true if a line was created successfully
118 uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShapeBackChild(pSeries, m_xSeriesTarget);
120 drawing::PolyPolygonShape3D aPoly;
122 bool bIsClipped = false;
123 if( !ShapeFactory::isPolygonEmptyOrSinglePoint(*pSeriesPoly) )
125 // do NOT connect last and first point, if one is NAN, and NAN handling is NAN_AS_GAP
126 double fFirstY = pSeries->getYValue( 0 );
127 double fLastY = pSeries->getYValue( VSeriesPlotter::getPointCount() - 1 );
128 if( (pSeries->getMissingValueTreatment() != css::chart::MissingValueTreatment::LEAVE_GAP)
129 || (std::isfinite( fFirstY ) && std::isfinite( fLastY )) )
131 // connect last point in last polygon with first point in first polygon
132 ::basegfx::B2DRectangle aScaledLogicClipDoubleRect( pPosHelper->getScaledLogicClipDoubleRect() );
133 drawing::PolyPolygonShape3D aTmpPoly(*pSeriesPoly);
134 drawing::Position3D aLast(aScaledLogicClipDoubleRect.getMaxX(),aTmpPoly.SequenceY[0][0],aTmpPoly.SequenceZ[0][0]);
135 // add connector line to last polygon
136 AddPointToPoly( aTmpPoly, aLast, pSeriesPoly->SequenceX.getLength() - 1 );
137 Clipping::clipPolygonAtRectangle( aTmpPoly, aScaledLogicClipDoubleRect, aPoly );
138 bIsClipped = true;
142 if( !bIsClipped )
143 Clipping::clipPolygonAtRectangle( *pSeriesPoly, pPosHelper->getScaledLogicClipDoubleRect(), aPoly );
146 if(!ShapeFactory::hasPolygonAnyLines(aPoly))
147 return false;
149 //transformation 3) -> 4)
150 pPosHelper->transformScaledLogicToScene( aPoly );
152 //create line:
153 uno::Reference< drawing::XShape > xShape;
155 xShape = m_pShapeFactory->createLine2D( xSeriesGroupShape_Shapes
156 , PolyToPointSequence( aPoly ) );
157 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, "MarkHandles");
163 return true;
166 bool NetChart::impl_createArea( VDataSeries* pSeries
167 , drawing::PolyPolygonShape3D* pSeriesPoly
168 , drawing::PolyPolygonShape3D const * pPreviousSeriesPoly
169 , PlottingPositionHelper const * pPosHelper )
171 //return true if an area was created successfully
173 uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShapeBackChild(pSeries, m_xSeriesTarget);
174 double zValue = pSeries->m_fLogicZPos;
176 drawing::PolyPolygonShape3D 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 drawing::PolyPolygonShape3D aClippedPoly;
213 Clipping::clipPolygonAtRectangle( aPoly, pPosHelper->getScaledLogicClipDoubleRect(), aClippedPoly, false );
214 ShapeFactory::closePolygon(aClippedPoly); //again necessary after clipping
215 aPoly = aClippedPoly;
218 if(!ShapeFactory::hasPolygonAnyLines(aPoly))
219 return false;
221 //transformation 3) -> 4)
222 pPosHelper->transformScaledLogicToScene( aPoly );
224 //create area:
225 uno::Reference< drawing::XShape >
226 xShape = m_pShapeFactory->createArea2D( xSeriesGroupShape_Shapes
227 , aPoly );
228 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, "MarkHandles");
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, drawing::PolyPolygonShape3D* > aPreviousSeriesPolyMap;//a PreviousSeriesPoly for each different nAttachedAxisIndex
246 drawing::PolyPolygonShape3D* 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()
305 ::rtl::math::setNan( &m_fX );
306 ::rtl::math::setNan( &m_fY );
307 ::rtl::math::setNan( &m_fZ );
310 double m_fX;
311 double m_fY;
312 double m_fZ;
315 }//anonymous namespace
317 void NetChart::createShapes()
319 if( m_aZSlots.empty() ) //no series
320 return;
322 //tdf#127813 Don't reverse the series in OOXML-heavy environments
323 if (officecfg::Office::Compatibility::View::ReverseSeriesOrderAreaAndNetChart::get() && m_bArea)
324 lcl_reorderSeries( m_aZSlots );
326 OSL_ENSURE(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is(),"NetChart is not proper initialized");
327 if(!(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is()))
328 return;
330 //the text labels should be always on top of the other series shapes
331 //for area chart the error bars should be always on top of the other series shapes
333 //therefore create an own group for the texts and the error bars to move them to front
334 //(because the text group is created after the series group the texts are displayed on top)
335 m_xSeriesTarget = createGroupShape( m_xLogicTarget );
336 m_xTextTarget = m_pShapeFactory->createGroup2D( m_xFinalTarget );
338 //check necessary here that different Y axis can not be stacked in the same group? ... hm?
340 //update/create information for current group
341 double fLogicZ = 1.0;//as defined
343 sal_Int32 const nStartIndex = 0; // inclusive ;..todo get somehow from x scale
344 sal_Int32 nEndIndex = VSeriesPlotter::getPointCount();
345 if(nEndIndex<=0)
346 nEndIndex=1;
348 //better performance for big data
349 std::map< VDataSeries*, FormerPoint > aSeriesFormerPointMap;
350 m_bPointsWereSkipped = false;
352 bool bDateCategory = (m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis());
354 //iterate through all x values per indices
355 for( sal_Int32 nIndex = nStartIndex; nIndex < nEndIndex; nIndex++ )
357 std::map< sal_Int32, double > aLogicYSumMap;//one for each different nAttachedAxisIndex
358 for( auto const& rZSlot : m_aZSlots )
360 //iterate through all x slots in this category to get 100percent sum
361 for( auto const& rXSlot : rZSlot )
363 for( std::unique_ptr<VDataSeries> const & pSeries : rXSlot.m_aSeriesVector )
365 if(!pSeries)
366 continue;
368 if (bDateCategory)
369 pSeries->doSortByXValues();
371 sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex();
372 if( aLogicYSumMap.find(nAttachedAxisIndex)==aLogicYSumMap.end() )
373 aLogicYSumMap[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 uno::Reference< drawing::XShapes > 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 drawing::PolyPolygonShape3D& rPolygon = pSeries->m_aPolyPolygonShape3D;
443 sal_Int32& rIndex = pSeries->m_nPolygonIndex;
444 if( 0<= rIndex && rIndex < rPolygon.SequenceX.getLength() )
446 if( rPolygon.SequenceX[ rIndex ].hasElements() )
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 uno::Reference< drawing::XShapes > xPointGroupShape_Shapes(
531 createGroupShape(xSeriesGroupShape_Shapes,aPointCID) );
532 uno::Reference<drawing::XShape> xPointGroupShape_Shape( xPointGroupShape_Shapes, uno::UNO_QUERY );
535 //create data point
536 drawing::Direction3D aSymbolSize(0,0,0);
537 if (bCreateSymbol) // implies pSymbolProperties
539 if (pSymbolProperties->Style != SymbolStyle_NONE)
541 aSymbolSize.DirectionX = pSymbolProperties->Size.Width;
542 aSymbolSize.DirectionY = pSymbolProperties->Size.Height;
545 if (pSymbolProperties->Style == SymbolStyle_STANDARD)
547 sal_Int32 nSymbol = pSymbolProperties->StandardSymbol;
548 m_pShapeFactory->createSymbol2D(
549 xPointGroupShape_Shapes, aScenePosition, aSymbolSize, nSymbol,
550 pSymbolProperties->BorderColor, pSymbolProperties->FillColor);
552 else if (pSymbolProperties->Style == SymbolStyle_GRAPHIC)
554 m_pShapeFactory->createGraphic2D(xPointGroupShape_Shapes,
555 aScenePosition, aSymbolSize,
556 pSymbolProperties->Graphic);
558 //@todo other symbol styles
561 //create data point label
562 if( pSeries->getDataPointLabelIfLabel(nIndex) )
564 LabelAlignment eAlignment = LABEL_ALIGN_TOP;
565 drawing::Position3D aScenePosition3D( aScenePosition.PositionX
566 , aScenePosition.PositionY
567 , aScenePosition.PositionZ+getTransformedDepth() );
569 sal_Int32 nLabelPlacement = pSeries->getLabelPlacement(
570 nIndex, m_xChartTypeModel, m_pPosHelper->isSwapXAndY());
572 switch(nLabelPlacement)
574 case css::chart::DataLabelPlacement::TOP:
575 aScenePosition3D.PositionY -= (aSymbolSize.DirectionY/2+1);
576 eAlignment = LABEL_ALIGN_TOP;
577 break;
578 case css::chart::DataLabelPlacement::BOTTOM:
579 aScenePosition3D.PositionY += (aSymbolSize.DirectionY/2+1);
580 eAlignment = LABEL_ALIGN_BOTTOM;
581 break;
582 case css::chart::DataLabelPlacement::LEFT:
583 aScenePosition3D.PositionX -= (aSymbolSize.DirectionX/2+1);
584 eAlignment = LABEL_ALIGN_LEFT;
585 break;
586 case css::chart::DataLabelPlacement::RIGHT:
587 aScenePosition3D.PositionX += (aSymbolSize.DirectionX/2+1);
588 eAlignment = LABEL_ALIGN_RIGHT;
589 break;
590 case css::chart::DataLabelPlacement::CENTER:
591 eAlignment = LABEL_ALIGN_CENTER;
592 //todo implement this different for area charts
593 break;
594 default:
595 OSL_FAIL("this label alignment is not implemented yet");
596 aScenePosition3D.PositionY -= (aSymbolSize.DirectionY/2+1);
597 eAlignment = LABEL_ALIGN_TOP;
598 break;
601 awt::Point aScreenPosition2D;//get the screen position for the labels
602 sal_Int32 nOffset = 100; //todo maybe calculate this font height dependent
603 if( nLabelPlacement == css::chart::DataLabelPlacement::OUTSIDE )
605 PolarPlottingPositionHelper* pPolarPosHelper
606 = dynamic_cast<PolarPlottingPositionHelper*>(m_pPosHelper);
607 if( pPolarPosHelper )
609 PolarLabelPositionHelper aPolarLabelPositionHelper(pPolarPosHelper,m_nDimension,m_xLogicTarget,m_pShapeFactory);
610 aScreenPosition2D = aPolarLabelPositionHelper.getLabelScreenPositionAndAlignmentForLogicValues(
611 eAlignment, fLogicX, fLogicY, fLogicZ, nOffset );
614 else
616 if(eAlignment==LABEL_ALIGN_CENTER )
617 nOffset = 0;
618 aScreenPosition2D = LabelPositionHelper(m_nDimension,m_xLogicTarget,m_pShapeFactory)
619 .transformSceneToScreenPosition( aScenePosition3D );
622 createDataLabel( m_xTextTarget, *pSeries, nIndex
623 , fLogicValueForLabeDisplay
624 , aLogicYSumMap[nAttachedAxisIndex], aScreenPosition2D, eAlignment, nOffset );
628 //remove PointGroupShape if empty
629 if(!xPointGroupShape_Shapes->getCount())
630 xSeriesGroupShape_Shapes->remove(xPointGroupShape_Shape);
632 }//next series in x slot (next y slot)
633 }//next x slot
634 }//next z slot
635 }//next category
637 impl_createSeriesShapes();
641 } //namespace chart
643 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */