summaryrefslogtreecommitdiff
path: root/chart2/source/model/main
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2018-01-04 22:15:32 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2018-01-29 23:49:42 +0100
commit790f9abeb1a1167ad5ab84c5fb855b36669c125b (patch)
treedea7c957b67be7518d2092614b82f18148817265 /chart2/source/model/main
parenta1f933ee2b9e23a505d937035821e9571cf4119c (diff)
tdf#114821 import complex data labels in bar chart
* import static text & fields: VALUE, SERIESNAME, COLUMNNAME * text is formatted * DataPointCustomLabelField with field type (DataPointCustomLabelFieldType) was introduced. * text can have many portions & multiple lines * unit tests for import data labels with formatting Not implemented: CELLREF field support which needs importing some additional data from extLst Shows custom text as a label for data points. Change-Id: Iba8fd508eb16356b05586b93d7b8da32240d2b91 Reviewed-on: https://gerrit.libreoffice.org/48243 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'chart2/source/model/main')
-rw-r--r--chart2/source/model/main/DataPointProperties.cxx11
-rw-r--r--chart2/source/model/main/DataPointProperties.hxx3
-rw-r--r--chart2/source/model/main/FormattedString.cxx40
-rw-r--r--chart2/source/model/main/FormattedString.hxx16
4 files changed, 67 insertions, 3 deletions
diff --git a/chart2/source/model/main/DataPointProperties.cxx b/chart2/source/model/main/DataPointProperties.cxx
index 217b30cbda20..54cc26b325b3 100644
--- a/chart2/source/model/main/DataPointProperties.cxx
+++ b/chart2/source/model/main/DataPointProperties.cxx
@@ -30,7 +30,7 @@
#include <com/sun/star/style/XStyle.hpp>
#include <com/sun/star/drawing/BitmapMode.hpp>
#include <com/sun/star/drawing/RectanglePoint.hpp>
-
+#include <com/sun/star/chart2/XDataPointCustomLabelField.hpp>
#include <com/sun/star/chart2/DataPointGeometry3D.hpp>
#include <com/sun/star/chart2/DataPointLabel.hpp>
#include <com/sun/star/chart2/Symbol.hpp>
@@ -406,6 +406,12 @@ void DataPointProperties::AddPropertiesToVector(
cppu::UnoType<sal_Int16>::get(),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( CHART_UNONAME_CUSTOM_LABEL_FIELDS,
+ PROP_DATAPOINT_CUSTOM_LABEL_FIELDS,
+ cppu::UnoType<uno::Sequence<uno::Reference<chart2::XDataPointCustomLabelField>>>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT);
}
void DataPointProperties::AddDefaultsToMap(
@@ -486,6 +492,9 @@ void DataPointProperties::AddDefaultsToMap(
PropertyHelper::setPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_BORDER_DASH, drawing::LineDash());
PropertyHelper::setEmptyPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_BORDER_DASH_NAME);
PropertyHelper::setPropertyValueDefault<sal_Int16>(rOutMap, PROP_DATAPOINT_LABEL_BORDER_TRANS, 0);
+
+ uno::Sequence<uno::Reference<chart2::XDataPointCustomLabelField>> aFields(0);
+ PropertyHelper::setPropertyValueDefault(rOutMap, PROP_DATAPOINT_CUSTOM_LABEL_FIELDS, aFields);
}
} // namespace chart
diff --git a/chart2/source/model/main/DataPointProperties.hxx b/chart2/source/model/main/DataPointProperties.hxx
index 3daf838e5da5..6490b5c8cfe5 100644
--- a/chart2/source/model/main/DataPointProperties.hxx
+++ b/chart2/source/model/main/DataPointProperties.hxx
@@ -80,7 +80,8 @@ namespace DataPointProperties
PROP_DATAPOINT_LABEL_BORDER_WIDTH,
PROP_DATAPOINT_LABEL_BORDER_DASH,
PROP_DATAPOINT_LABEL_BORDER_DASH_NAME,
- PROP_DATAPOINT_LABEL_BORDER_TRANS
+ PROP_DATAPOINT_LABEL_BORDER_TRANS,
+ PROP_DATAPOINT_CUSTOM_LABEL_FIELDS
// additionally some properites from ::chart::LineProperties
};
diff --git a/chart2/source/model/main/FormattedString.cxx b/chart2/source/model/main/FormattedString.cxx
index 0a89c555a0e1..8d1eff75349b 100644
--- a/chart2/source/model/main/FormattedString.cxx
+++ b/chart2/source/model/main/FormattedString.cxx
@@ -95,6 +95,8 @@ namespace chart
FormattedString::FormattedString() :
::property::OPropertySet( m_aMutex ),
m_aString(),
+ m_aType(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT),
+ m_aGuid(),
m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
{}
@@ -103,6 +105,8 @@ FormattedString::FormattedString( const FormattedString & rOther ) :
impl::FormattedString_Base(),
::property::OPropertySet( rOther, m_aMutex ),
m_aString( rOther.m_aString ),
+ m_aType(rOther.m_aType),
+ m_aGuid(rOther.m_aGuid),
m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
{}
@@ -133,6 +137,41 @@ void SAL_CALL FormattedString::setString( const OUString& String )
}
+// ____ XDataPointCustomLabelField ____
+css::chart2::DataPointCustomLabelFieldType SAL_CALL FormattedString::getFieldType()
+{
+ MutexGuard aGuard(GetMutex());
+ return m_aType;
+}
+
+void SAL_CALL
+FormattedString::setFieldType(const css::chart2::DataPointCustomLabelFieldType Type)
+{
+ {
+ MutexGuard aGuard(GetMutex());
+ m_aType = Type;
+ }
+ //don't keep the mutex locked while calling out
+ fireModifyEvent();
+}
+
+OUString SAL_CALL FormattedString::getGuid()
+{
+ MutexGuard aGuard( GetMutex());
+ return m_aGuid;
+}
+
+void SAL_CALL FormattedString::setGuid( const OUString& guid )
+{
+ {
+ MutexGuard aGuard( GetMutex());
+ m_aGuid= guid;
+ }
+ //don't keep the mutex locked while calling out
+ fireModifyEvent();
+
+}
+
// ____ XModifyBroadcaster ____
void SAL_CALL FormattedString::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
@@ -226,6 +265,7 @@ sal_Bool SAL_CALL FormattedString::supportsService( const OUString& rServiceName
css::uno::Sequence< OUString > SAL_CALL FormattedString::getSupportedServiceNames()
{
return {
+ "com.sun.star.chart2.DataPointCustomLabelField",
"com.sun.star.chart2.FormattedString",
"com.sun.star.beans.PropertySet" };
}
diff --git a/chart2/source/model/main/FormattedString.hxx b/chart2/source/model/main/FormattedString.hxx
index 16c73372ebcc..aee7674081be 100644
--- a/chart2/source/model/main/FormattedString.hxx
+++ b/chart2/source/model/main/FormattedString.hxx
@@ -26,6 +26,8 @@
#include <ModifyListenerHelper.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/chart2/XFormattedString2.hpp>
+#include <com/sun/star/chart2/DataPointCustomLabelFieldType.hpp>
+#include <com/sun/star/chart2/XDataPointCustomLabelField.hpp>
#include <com/sun/star/util/XCloneable.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
@@ -35,7 +37,7 @@ namespace chart
namespace impl
{
typedef ::cppu::WeakImplHelper<
- css::chart2::XFormattedString2,
+ css::chart2::XDataPointCustomLabelField, // inherits from XFormattedString2
css::lang::XServiceInfo,
css::util::XCloneable,
css::util::XModifyBroadcaster,
@@ -82,6 +84,13 @@ private:
virtual OUString SAL_CALL getString() override;
virtual void SAL_CALL setString( const OUString& String ) override;
+ // ____ XDataPointCustomLabelField ____
+ virtual css::chart2::DataPointCustomLabelFieldType SAL_CALL getFieldType() override;
+ virtual void SAL_CALL
+ setFieldType( const css::chart2::DataPointCustomLabelFieldType FieldType ) override;
+ virtual OUString SAL_CALL getGuid() override;
+ void SAL_CALL setGuid( const OUString& guid ) override;
+
// ____ OPropertySet ____
virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
@@ -115,8 +124,13 @@ private:
void fireModifyEvent();
+ // ____ XFormattedString ____
OUString m_aString;
+ // ____ XDataPointCustomLabelField ____
+ css::chart2::DataPointCustomLabelFieldType m_aType;
+ OUString m_aGuid;
+
css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
};