32#include <unonames.hxx>
44#include <rtl/math.hxx>
46#include <com/sun/star/chart/DataLabelPlacement.hpp>
47#include <com/sun/star/chart2/AxisType.hpp>
48#include <com/sun/star/chart2/DataPointLabel.hpp>
49#include <com/sun/star/chart2/Symbol.hpp>
50#include <com/sun/star/chart2/RelativePosition.hpp>
51#include <com/sun/star/chart2/XDataSeries.hpp>
73sal_Int32 getSymbolStyleForSymbol(
const chart2::Symbol& rSymbol )
76 switch (rSymbol.Style)
78 case chart2::SymbolStyle_NONE:
81 case chart2::SymbolStyle_AUTO:
84 case chart2::SymbolStyle_GRAPHIC:
87 case chart2::SymbolStyle_STANDARD:
88 nStyle = rSymbol.StandardSymbol;
90 case chart2::SymbolStyle_POLYGON:
97bool numberFormatFromItemToPropertySet(
98 sal_uInt16 nWhichId,
const SfxItemSet& rItemSet,
const uno::Reference<beans::XPropertySet>& xPropertySet,
99 bool bOverwriteDataPoints )
101 bool bChanged =
false;
102 if (!xPropertySet.is())
105 OUString aPropertyName = (nWhichId == SID_ATTR_NUMBERFORMAT_VALUE) ? OUString(
CHART_UNONAME_NUMFMT) : OUString(
"PercentageNumberFormat");
108 if (rItemSet.
GetItemState(nSourceWhich) != SfxItemState::SET)
113 if (!bUseSourceFormat)
116 if (aState == SfxItemState::SET)
118 sal_Int32 nFmt =
static_cast<sal_Int32
>(
127 uno::Any aOldValue = xPropertySet->getPropertyValue(aPropertyName);
128 if (bOverwriteDataPoints)
131 if (aValue != aOldValue ||
138 else if (aOldValue != aValue)
140 xPropertySet->setPropertyValue(aPropertyName, aValue);
146bool useSourceFormatFromItemToPropertySet(
147 sal_uInt16 nWhichId,
const SfxItemSet& rItemSet,
const uno::Reference<beans::XPropertySet>& xPropertySet,
148 bool bOverwriteDataPoints )
150 bool bChanged =
false;
151 if (!xPropertySet.is())
153 OUString aPropertyName = (nWhichId == SID_ATTR_NUMBERFORMAT_SOURCE) ? OUString(
CHART_UNONAME_NUMFMT) : OUString(
"PercentageNumberFormat");
156 if (rItemSet.
GetItemState(nWhichId) != SfxItemState::SET)
160 bool bUseSourceFormat =
static_cast<const SfxBoolItem&
>(
163 if (!bUseSourceFormat)
166 if (aState == SfxItemState::SET)
168 sal_Int32 nFormatKey =
static_cast<sal_Int32
>(
171 aNewValue <<= nFormatKey;
177 uno::Any aOldValue(xPropertySet->getPropertyValue(aPropertyName));
178 if (bOverwriteDataPoints)
181 if (aNewValue != aOldValue ||
188 else if (aOldValue != aNewValue)
190 xPropertySet->setPropertyValue(aPropertyName, aNewValue);
204 bool bDataSeries, sal_Int32 nNumberFormat, sal_Int32 nPercentNumberFormat ) :
206 mnNumberFormat(nNumberFormat),
207 mnPercentNumberFormat(nPercentNumberFormat),
208 mbDataSeries(bDataSeries),
209 mbForbidPercentValue(true),
217 bool bAmbiguous =
false;
218 bool bSwapXAndY = xDiagram->getVertical(bFound, bAmbiguous);
231 pConv->FillItemSet( rOutItemSet );
239 bool bResult =
false;
242 bResult = pConv->ApplyItemSet( rItemSet ) || bResult;
257 ItemPropertyMapType::const_iterator it = rMap.find(nWhichId);
259 if (it == rMap.end())
262 rOutProperty = it->second;
268 bool bChanged =
false;
281 chart2::DataPointLabel
aLabel;
288 bool bOldValue = rValue;
293 if (bOldValue !=
bool(rValue) ||
301 else if (bOldValue !=
bool(rValue))
309 case SID_ATTR_NUMBERFORMAT_VALUE:
315 case SID_ATTR_NUMBERFORMAT_SOURCE:
327 GetPropertySet()->getPropertyValue(
"LabelSeparator") >>= aOldValue;
331 if (aOldValue != aNewValue ||
338 else if (aOldValue != aNewValue)
344 catch (
const uno::Exception&)
368 else if( bOld!=bNew )
374 catch(
const uno::Exception& )
386 RelativePosition aCustomLabelPosition;
405 catch (
const uno::Exception&)
416 chart2::Symbol aSymbol;
419 sal_Int32 nOldStyle = getSymbolStyleForSymbol(aSymbol);
421 if (nStyle != nOldStyle)
423 bool bDeleteSymbol =
false;
427 aSymbol.Style = chart2::SymbolStyle_NONE;
430 aSymbol.Style = chart2::SymbolStyle_AUTO;
433 aSymbol.Style = chart2::SymbolStyle_GRAPHIC;
436 bDeleteSymbol =
true;
440 aSymbol.Style = chart2::SymbolStyle_STANDARD;
441 aSymbol.StandardSymbol = nStyle;
455 rItemSet.
Get(nWhichId)).GetSize();
456 chart2::Symbol aSymbol;
459 if (aSize.
getWidth() != aSymbol.Size.Width ||
460 aSize.
getHeight() != aSymbol.Size.Height)
462 aSymbol.Size.Width = aSize.
getWidth();
473 rItemSet.
Get(nWhichId)));
481 aXGraphicAny <<= xGraphic;
482 chart2::Symbol aSymbol;
484 if (aSymbol.Graphic != xGraphic)
486 aSymbol.Graphic = xGraphic;
496 double fValue =
static_cast<double>(
499 double fOldValue = 0.0;
501 (
GetPropertySet()->getPropertyValue(
"TextRotation") >>= fOldValue);
503 if (!bPropExisted || fOldValue != fValue)
516 if( (
m_xSeries->getPropertyValue(
"ShowCustomLeaderLines") >>= bOld) && bOld != bNew )
522 catch (
const uno::Exception&)
543 chart2::DataPointLabel
aLabel;
564 case SID_ATTR_NUMBERFORMAT_VALUE:
575 if (!(
GetPropertySet()->getPropertyValue(
"PercentageNumberFormat") >>= nKey))
580 case SID_ATTR_NUMBERFORMAT_SOURCE:
582 bool bUseSourceFormat =
false;
587 catch (
const uno::Exception&)
597 bool bUseSourceFormat =
false;
602 catch (
const uno::Exception&)
606 bool bNumberFormatIsSet =
GetPropertySet()->getPropertyValue(
"PercentageNumberFormat").hasValue() && !bUseSourceFormat;
618 catch (
const uno::Exception&)
632 catch(
const uno::Exception& )
642 sal_Int32 nPlacement = 0;
643 RelativePosition aCustomLabelPosition;
645 rOutItemSet.
Put(
SfxInt32Item(nWhichId, css::chart::DataLabelPlacement::CUSTOM));
651 catch (
const uno::Exception&)
672 if(
m_xSeries->getPropertyValue(
"ShowCustomLeaderLines" ) >>= bValue )
675 catch (
const uno::Exception&)
683 chart2::Symbol aSymbol;
685 rOutItemSet.
Put(
SfxInt32Item(nWhichId, getSymbolStyleForSymbol(aSymbol)));
690 chart2::Symbol aSymbol;
698 chart2::Symbol aSymbol;
700 && aSymbol.Graphic.is())
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_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< SfxBoolItem > SCHATTR_DATADESCR_SHOW_CATEGORY(SCHATTR_DATADESCR_START+2)
rtl::Reference< ::chart::DataSeries > m_xSeries
const WhichRangesContainer nTextLabelWhichPairs(svl::Items< SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, SCHATTR_TEXT_DEGREES, SCHATTR_TEXT_DEGREES, SCHATTR_STYLE_SYMBOL, SCHATTR_STYLE_SYMBOL, SCHATTR_SYMBOL_BRUSH, SCHATTR_SYMBOL_BRUSH, SCHATTR_SYMBOL_SIZE, SCHATTR_SYMBOL_SIZE, XATTR_LINESTYLE, XATTR_LINECOLOR, XATTR_LINETRANSPARENCE, XATTR_LINETRANSPARENCE, 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)
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...
css::uno::Sequence< sal_Int32 > maAvailableLabelPlacements
virtual void FillItemSet(SfxItemSet &rOutItemSet) const override
applies all properties that can be mapped to items into the given item set.
TextLabelItemConverter(const rtl::Reference<::chart::ChartModel > &xChartModel, const css::uno::Reference< css::beans::XPropertySet > &rPropertySet, const rtl::Reference<::chart::DataSeries > &xSeries, SfxItemPool &rItemPool, const css::awt::Size *pRefSize, bool bDataSeries, sal_Int32 nNumberFormat, sal_Int32 nPercentNumberFormat)
virtual void FillSpecialItem(sal_uInt16 nWhichId, SfxItemSet &rOutItemSet) const override
for items that can not be mapped directly to a property.
rtl::Reference<::chart::DataSeries > m_xSeries
bool mbForbidPercentValue
virtual ~TextLabelItemConverter() override
virtual bool GetItemProperty(tWhichIdType nWhichId, tPropertyNameWithMemberId &rOutProperty) const override
implement this method to return a Property object for a given which id.
virtual const WhichRangesContainer & GetWhichPairs() const override
implement this method to provide an array of which-ranges
std::vector< std::unique_ptr< ItemConverter > > maConverters
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...
sal_Int32 mnPercentNumberFormat
virtual bool ApplySpecialItem(sal_uInt16 nWhichId, const SfxItemSet &rItemSet) override
for items that can not be mapped directly to a property.
#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)
std::map< ItemConverter::tWhichIdType, std::pair< ItemConverter::tPropertyNameType, ItemConverter::tMemberIdType > > ItemPropertyMapType
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)
HashMap_OWString_Interface aMap
#define SVX_SYMBOLTYPE_BRUSHITEM
#define SVX_SYMBOLTYPE_NONE
#define SVX_SYMBOLTYPE_UNKNOWN
#define SVX_SYMBOLTYPE_AUTO
constexpr OUStringLiteral CHART_UNONAME_LABEL_BORDER_WIDTH
constexpr OUStringLiteral CHART_UNONAME_LABEL_BORDER_TRANS
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_BORDER_COLOR
constexpr OUStringLiteral CHART_UNONAME_LABEL_BORDER_STYLE
constexpr OUStringLiteral CHART_UNONAME_LABEL
constexpr OUStringLiteral CHART_UNONAME_LABEL_BORDER_DASH
constexpr TypedWhichId< XLineColorItem > XATTR_LINECOLOR(XATTR_LINE_FIRST+3)
constexpr TypedWhichId< XLineDashItem > XATTR_LINEDASH(XATTR_LINE_FIRST+1)
constexpr TypedWhichId< XLineWidthItem > XATTR_LINEWIDTH(XATTR_LINE_FIRST+2)
constexpr TypedWhichId< XLineStyleItem > XATTR_LINESTYLE(XATTR_LINE_FIRST)
constexpr TypedWhichId< XLineTransparenceItem > XATTR_LINETRANSPARENCE(XATTR_LINE_FIRST+10)