37#include <unonames.hxx>
39#include <com/sun/star/chart/DataLabelPlacement.hpp>
40#include <com/sun/star/chart2/AxisType.hpp>
41#include <com/sun/star/chart2/DataPointLabel.hpp>
42#include <com/sun/star/chart2/Symbol.hpp>
43#include <com/sun/star/chart2/RelativePosition.hpp>
44#include <com/sun/star/chart2/XDataSeries.hpp>
45#include <com/sun/star/beans/XPropertySet.hpp>
58#include <rtl/math.hxx>
67using ::com::sun::star::uno::Reference;
77 return aDataPointPropertyMap;
80sal_Int32 lcl_getSymbolStyleForSymbol(
const chart2::Symbol & rSymbol )
83 switch( rSymbol.Style )
85 case chart2::SymbolStyle_NONE:
88 case chart2::SymbolStyle_AUTO:
91 case chart2::SymbolStyle_GRAPHIC:
94 case chart2::SymbolStyle_STANDARD:
95 nStyle = rSymbol.StandardSymbol;
98 case chart2::SymbolStyle_POLYGON:
100 case chart2::SymbolStyle::SymbolStyle_MAKE_FIXED_SIZE:
107bool lcl_NumberFormatFromItemToPropertySet( sal_uInt16 nWhichId,
const SfxItemSet & rItemSet,
const uno::Reference< beans::XPropertySet > & xPropertySet,
bool bOverwriteAttributedDataPointsAlso )
109 bool bChanged =
false;
110 if( !xPropertySet.is() )
112 OUString aPropertyName = (nWhichId==SID_ATTR_NUMBERFORMAT_VALUE) ? OUString(
CHART_UNONAME_NUMFMT) : OUString(
"PercentageNumberFormat" );
115 if( rItemSet.
GetItemState( nSourceWhich ) != SfxItemState::SET )
119 bool bUseSourceFormat =
static_cast< const SfxBoolItem &
>(
121 if( !bUseSourceFormat )
124 if( aState == SfxItemState::SET )
126 sal_Int32 nFmt =
static_cast< sal_Int32
>(
135 uno::Any aOldValue( xPropertySet->getPropertyValue(aPropertyName) );
136 if( bOverwriteAttributedDataPointsAlso )
139 if( aValue != aOldValue ||
146 else if( aOldValue != aValue )
148 xPropertySet->setPropertyValue(aPropertyName, aValue );
154bool lcl_UseSourceFormatFromItemToPropertySet( sal_uInt16 nWhichId,
const SfxItemSet & rItemSet,
const uno::Reference< beans::XPropertySet > & xPropertySet,
bool bOverwriteAttributedDataPointsAlso )
156 bool bChanged =
false;
157 if( !xPropertySet.is() )
159 OUString aPropertyName = (nWhichId==SID_ATTR_NUMBERFORMAT_SOURCE) ? OUString(
CHART_UNONAME_NUMFMT) : OUString(
"PercentageNumberFormat" );
162 if( rItemSet.
GetItemState( nWhichId ) != SfxItemState::SET )
166 bool bUseSourceFormat =
static_cast< const SfxBoolItem &
>(
169 if( !bUseSourceFormat )
172 if( aState == SfxItemState::SET )
174 sal_Int32 nFormatKey =
static_cast< sal_Int32
>(
177 aNewValue <<= nFormatKey;
183 uno::Any aOldValue( xPropertySet->getPropertyValue(aPropertyName) );
184 if( bOverwriteAttributedDataPointsAlso )
187 if( aNewValue != aOldValue ||
194 else if( aOldValue != aNewValue )
196 xPropertySet->setPropertyValue( aPropertyName, aNewValue );
214 const awt::Size* pRefSize,
216 bool bUseSpecialFillColor,
217 sal_Int32 nSpecialFillColor,
218 bool bOverwriteLabelsForAttributedDataPointsAlso,
219 sal_Int32 nNumberFormat,
220 sal_Int32 nPercentNumberFormat,
221 sal_Int32 nPointIndex ) :
223 m_bDataSeries( bDataSeries ),
224 m_bOverwriteLabelsForAttributedDataPointsAlso(m_bDataSeries && bOverwriteLabelsForAttributedDataPointsAlso),
225 m_bUseSpecialFillColor(bUseSpecialFillColor),
227 m_nNumberFormat(nNumberFormat),
228 m_nPercentNumberFormat(nPercentNumberFormat),
229 m_bForbidPercentValue(true),
230 m_bHideLegendEntry(false),
231 m_nPointIndex(nPointIndex),
235 rPropertySet, rItemPool, rDrawModel, xNamedPropertyContainerFactory, eMapTo ));
239 assert(
dynamic_cast<DataSeries*
>(rPropertySet.get()));
242 dynamic_cast<DataSeries*
>(rPropertySet.get()), rItemPool ));
248 bool bAmbiguous =
false;
249 bool bSwapXAndY = xDiagram->getVertical( bFound, bAmbiguous );
260 for (
const auto& deletedLegendEntry : std::as_const(deletedLegendEntriesSeq))
262 if (nPointIndex == deletedLegendEntry)
277 pConv->FillItemSet( rOutItemSet );
291 bool bResult =
false;
294 bResult = pConv->ApplyItemSet( rItemSet ) || bResult;
311 ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId ));
313 if( aIt == rMap.end())
316 rOutProperty =(*aIt).second;
321 sal_uInt16 nWhichId,
const SfxItemSet & rItemSet )
323 bool bChanged =
false;
336 chart2::DataPointLabel
aLabel;
337 if( aOldValue >>=
aLabel )
343 bool bOldValue = rValue;
348 if( bOldValue !=
bool(rValue) ||
356 else if( bOldValue !=
bool(rValue) )
365 case SID_ATTR_NUMBERFORMAT_VALUE:
372 case SID_ATTR_NUMBERFORMAT_SOURCE:
385 GetPropertySet()->getPropertyValue(
"LabelSeparator" ) >>= aOldValue;
389 if( aOldValue != aNewValue ||
396 else if( aOldValue != aNewValue )
402 catch(
const uno::Exception& )
427 else if( bOld!=bNew )
433 catch(
const uno::Exception& )
447 RelativePosition aCustomLabelPosition;
466 catch(
const uno::Exception& )
478 chart2::Symbol aSymbol;
481 sal_Int32 nOldStyle = lcl_getSymbolStyleForSymbol( aSymbol );
483 if( nStyle != nOldStyle )
485 bool bDeleteSymbol =
false;
489 aSymbol.Style = chart2::SymbolStyle_NONE;
492 aSymbol.Style = chart2::SymbolStyle_AUTO;
495 aSymbol.Style = chart2::SymbolStyle_GRAPHIC;
498 bDeleteSymbol =
true;
502 aSymbol.Style = chart2::SymbolStyle_STANDARD;
503 aSymbol.StandardSymbol = nStyle;
518 rItemSet.
Get( nWhichId )).GetSize();
519 chart2::Symbol aSymbol;
522 if( aSize.
getWidth() != aSymbol.Size.Width ||
523 aSize.
getHeight() != aSymbol.Size.Height )
525 aSymbol.Size.Width = aSize.
getWidth();
537 rItemSet.
Get( nWhichId )));
545 aXGraphicAny <<= xGraphic;
546 chart2::Symbol aSymbol;
548 if( aSymbol.Graphic != xGraphic )
550 aSymbol.Graphic = xGraphic;
562 double fOldValue = 0.0;
564 (
GetPropertySet()->getPropertyValue(
"TextRotation" ) >>= fOldValue );
566 if( ! bPropExisted || fOldValue != fValue )
582 std::vector<sal_Int32> deletedLegendEntries;
583 for (
const auto& deletedLegendEntry : std::as_const(deletedLegendEntriesSeq))
586 deletedLegendEntries.push_back(deletedLegendEntry);
588 if (bHideLegendEntry)
602 if( (
m_xSeries->getPropertyValue(
"ShowCustomLeaderLines") >>= bOld) && bOld != bNew )
608 catch (
const uno::Exception&)
620 sal_uInt16 nWhichId,
SfxItemSet & rOutItemSet )
const
630 chart2::DataPointLabel
aLabel;
652 case SID_ATTR_NUMBERFORMAT_VALUE:
664 if( !(
GetPropertySet()->getPropertyValue(
"PercentageNumberFormat" ) >>= nKey) )
670 case SID_ATTR_NUMBERFORMAT_SOURCE:
672 bool bUseSourceFormat =
false;
677 catch (
const uno::Exception&)
687 bool bUseSourceFormat =
false;
692 catch (
const uno::Exception&)
696 bool bNumberFormatIsSet =
GetPropertySet()->getPropertyValue(
"PercentageNumberFormat" ).hasValue() && !bUseSourceFormat;
706 GetPropertySet()->getPropertyValue(
"LabelSeparator" ) >>= aValue;
709 catch(
const uno::Exception& )
724 catch(
const uno::Exception& )
735 sal_Int32 nPlacement=0;
736 RelativePosition aCustomLabelPosition;
738 rOutItemSet.
Put(
SfxInt32Item(nWhichId, css::chart::DataLabelPlacement::CUSTOM));
744 catch(
const uno::Exception& )
768 if(
m_xSeries->getPropertyValue(
"ShowCustomLeaderLines" ) >>= bValue )
771 catch (
const uno::Exception&)
780 chart2::Symbol aSymbol;
782 rOutItemSet.
Put(
SfxInt32Item( nWhichId, lcl_getSymbolStyleForSymbol( aSymbol ) ));
788 chart2::Symbol aSymbol;
791 SvxSizeItem( nWhichId,
Size( aSymbol.Size.Width, aSymbol.Size.Height ) ));
797 chart2::Symbol aSymbol;
799 && aSymbol.Graphic.is() )
813 ::rtl::math::round( fValue * 100.0 ) ) )));
constexpr TypedWhichId< SfxBoolItem > SCHATTR_DATADESCR_SHOW_SYMBOL(SCHATTR_DATADESCR_START+3)
constexpr TypedWhichId< SvxSizeItem > SCHATTR_SYMBOL_SIZE(SCHATTR_AXIS_END+4)
constexpr TypedWhichId< SfxInt32Item > SCHATTR_DATADESCR_PLACEMENT(SCHATTR_DATADESCR_START+6)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_DATADESCR_CUSTOM_LEADER_LINES(SCHATTR_DATADESCR_START+9)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME(SCHATTR_DATADESCR_START+12)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_PERCENT_NUMBERFORMAT_SOURCE(SCHATTR_DATADESCR_START+11)
constexpr TypedWhichId< SfxInt32Item > SCHATTR_STYLE_SYMBOL(SCHATTR_STYLE_START+8)
constexpr TypedWhichId< SfxStringItem > SCHATTR_DATADESCR_SEPARATOR(SCHATTR_DATADESCR_START+5)
constexpr TypedWhichId< SfxUInt32Item > SCHATTR_PERCENT_NUMBERFORMAT_VALUE(SCHATTR_DATADESCR_START+10)
constexpr TypedWhichId< SfxIntegerListItem > SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS(SCHATTR_DATADESCR_START+7)
constexpr TypedWhichId< SdrAngleItem > SCHATTR_TEXT_DEGREES(SCHATTR_TEXT_START)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_DATADESCR_NO_PERCENTVALUE(SCHATTR_DATADESCR_START+8)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY(SCHATTR_AXIS_END+5)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_DATADESCR_SHOW_NUMBER(SCHATTR_DATADESCR_START)
constexpr TypedWhichId< SvxBrushItem > SCHATTR_SYMBOL_BRUSH(SCHATTR_AXIS_END+1)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_DATADESCR_WRAP_TEXT(SCHATTR_DATADESCR_START+4)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_DATADESCR_SHOW_PERCENTAGE(SCHATTR_DATADESCR_START+1)
constexpr TypedWhichId< SfxInt32Item > SCHATTR_STYLE_SHAPE(SCHATTR_STYLE_START+9)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_DATADESCR_SHOW_CATEGORY(SCHATTR_DATADESCR_START+2)
rtl::Reference< ::chart::DataSeries > m_xSeries
const WhichRangesContainer nRowWhichPairs(svl::Items< SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, SCHATTR_TEXT_DEGREES, SCHATTR_TEXT_DEGREES, SCHATTR_STYLE_START, SCHATTR_STYLE_END, SCHATTR_AXIS, SCHATTR_AXIS, SCHATTR_SYMBOL_BRUSH, SCHATTR_SYMBOL_BRUSH, SCHATTR_SYMBOL_SIZE, SCHATTR_SYMBOL_SIZE, SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY, SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY, SCHATTR_BAR_OVERLAP, SCHATTR_BAR_CONNECT, SCHATTR_GROUP_BARS_PER_AXIS, SCHATTR_AXIS_FOR_ALL_SERIES, XATTR_LINE_FIRST, XATTR_LINE_LAST, XATTR_FILL_FIRST, XATTR_FILL_LAST, SDRATTR_3D_FIRST, SDRATTR_3D_LAST, EE_ITEMS_START, EE_ITEMS_END, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING >)
const WhichRangesContainer nDataPointWhichPairs(svl::Items< SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, SCHATTR_TEXT_DEGREES, SCHATTR_TEXT_DEGREES, SCHATTR_STYLE_START, SCHATTR_STYLE_END, SCHATTR_SYMBOL_BRUSH, SCHATTR_SYMBOL_BRUSH, SCHATTR_SYMBOL_SIZE, SCHATTR_SYMBOL_SIZE, SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY, SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY, XATTR_LINE_FIRST, XATTR_LINE_LAST, XATTR_FILL_FIRST, XATTR_FILL_LAST, SDRATTR_3D_FIRST, SDRATTR_3D_LAST, EE_ITEMS_START, EE_ITEMS_END, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING >)
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void InvalidateItem(sal_uInt16 nWhich)
constexpr tools::Long getHeight() const
constexpr tools::Long getWidth() const
const Graphic * GetGraphic(OUString const &referer=OUString()) const
static css::uno::Sequence< sal_Int32 > getSupportedLabelPlacements(const rtl::Reference< ::chart::ChartType > &xChartType, bool bSwapXAndY, const rtl::Reference< ::chart::DataSeries > &xSeries)
static sal_Int32 getAxisType(const rtl::Reference< ::chart::ChartType > &xChartType, sal_Int32 nDimensionIndex)
virtual bool ApplySpecialItem(sal_uInt16 nWhichId, const SfxItemSet &rItemSet) override
for items that can not be mapped directly to a property.
sal_Int32 m_nNumberFormat
virtual void FillSpecialItem(sal_uInt16 nWhichId, SfxItemSet &rOutItemSet) const override
for items that can not be mapped directly to a property.
virtual ~DataPointItemConverter() override
virtual bool GetItemProperty(tWhichIdType nWhichId, tPropertyNameWithMemberId &rOutProperty) const override
implement this method to return a Property object for a given which id.
virtual bool ApplyItemSet(const SfxItemSet &rItemSet) override
applies all properties that are results of a conversion from all items in rItemSet to the internal XP...
bool m_bForbidPercentValue
sal_Int32 m_nPercentNumberFormat
virtual void FillItemSet(SfxItemSet &rOutItemSet) const override
applies all properties that can be mapped to items into the given item set.
virtual const WhichRangesContainer & GetWhichPairs() const override
implement this method to provide an array of which-ranges
rtl::Reference<::chart::DataSeries > m_xSeries
std::vector< std::unique_ptr< ItemConverter > > m_aConverters
bool m_bUseSpecialFillColor
DataPointItemConverter(const rtl::Reference<::chart::ChartModel > &xChartModel, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::beans::XPropertySet > &rPropertySet, const rtl::Reference<::chart::DataSeries > &xSeries, SfxItemPool &rItemPool, SdrModel &rDrawModel, const css::uno::Reference< css::lang::XMultiServiceFactory > &xNamedPropertyContainerFactory, GraphicObjectType eMapTo, const css::awt::Size *pRefSize=nullptr, bool bDataSeries=false, bool bUseSpecialFillColor=false, sal_Int32 nSpecialFillColor=0, bool bOverwriteLabelsForAttributedDataPointsAlso=false, sal_Int32 nNumberFormat=0, sal_Int32 nPercentNumberFormat=0, sal_Int32 nPointIndex=-1)
Color m_nSpecialFillColor
css::uno::Sequence< sal_Int32 > m_aAvailableLabelPlacements
bool m_bOverwriteLabelsForAttributedDataPointsAlso
This class serves for conversion between properties of an XPropertySet and SfxItems in SfxItemSets.
virtual void FillItemSet(SfxItemSet &rOutItemSet) const
applies all properties that can be mapped to items into the given item set.
std::pair< tPropertyNameType, tMemberIdType > tPropertyNameWithMemberId
const css::uno::Reference< css::beans::XPropertySet > & GetPropertySet() const
Returns the XPropertySet that was given in the CTOR and is used to apply items in ApplyItemSet().
virtual bool ApplyItemSet(const SfxItemSet &rItemSet)
applies all properties that are results of a conversion from all items in rItemSet to the internal XP...
#define TOOLS_WARN_EXCEPTION(area, stream)
OOO_DLLPUBLIC_CHARTTOOLS void setPropertyAlsoToAllAttributedDataPoints(const rtl::Reference< ::chart::DataSeries > &xSeries, const OUString &rPropertyName, const css::uno::Any &rPropertyValue)
OOO_DLLPUBLIC_CHARTTOOLS bool hasAttributedDataPointDifferentValue(const rtl::Reference< ::chart::DataSeries > &xSeries, const OUString &rPropertyName, const css::uno::Any &rPropertyValue)
@ PROP_DATASERIES_DELETED_LEGEND_ENTRIES
std::map< ItemConverter::tWhichIdType, std::pair< ItemConverter::tPropertyNameType, ItemConverter::tMemberIdType > > ItemPropertyMapType
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
#define SVX_SYMBOLTYPE_BRUSHITEM
#define SVX_SYMBOLTYPE_NONE
#define SVX_SYMBOLTYPE_UNKNOWN
#define SVX_SYMBOLTYPE_AUTO
constexpr OUStringLiteral CHART_UNONAME_LINK_TO_SRC_NUMFMT
constexpr OUStringLiteral CHART_UNONAME_NUMFMT
constexpr OUStringLiteral CHART_UNONAME_CUSTOM_LABEL_FIELDS
constexpr OUStringLiteral CHART_UNONAME_LABEL