[Libreoffice-commits] core.git: Branch 'feature/chart-style-experiment-markus' - 2 commits - chart2/source offapi/com
Markus Mohrhard (via logerrit)
logerrit at kemper.freedesktop.org
Fri Aug 9 17:21:50 UTC 2019
chart2/source/inc/ChartStyle.hxx | 3 ++
chart2/source/model/main/ChartModel.cxx | 2 +
chart2/source/model/main/ChartModel_Persistence.cxx | 11 ++++----
chart2/source/tools/ChartStyle.cxx | 25 ++++++++++++++++++++
offapi/com/sun/star/chart2/XChartStyle.idl | 3 ++
5 files changed, 39 insertions(+), 5 deletions(-)
New commits:
commit b91405200821542b714c19eb65c5ec0532499913
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
AuthorDate: Sat Aug 10 01:17:50 2019 +0800
Commit: Markus Mohrhard <markus.mohrhard at googlemail.com>
CommitDate: Sat Aug 10 01:19:49 2019 +0800
move default chart legend formatting to the style
Change-Id: If996e2d86ce07e91da77789732a1abf1ae1b3f99
diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx
index 87a0a742b7d9..db3b05ea195c 100644
--- a/chart2/source/model/main/ChartModel_Persistence.cxx
+++ b/chart2/source/model/main/ChartModel_Persistence.cxx
@@ -416,11 +416,6 @@ void ChartModel::insertDefaultChart()
Reference< beans::XPropertySet > xLegendProperties( xLegend, uno::UNO_QUERY );
if( xLegendProperties.is() )
{
- xLegendProperties->setPropertyValue( "FillStyle", uno::Any( drawing::FillStyle_NONE ));
- xLegendProperties->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_NONE ));
- xLegendProperties->setPropertyValue( "LineColor", uno::Any( static_cast< sal_Int32 >( 0xb3b3b3 ) )); // gray30
- xLegendProperties->setPropertyValue( "FillColor", uno::Any( static_cast< sal_Int32 >( 0xe6e6e6 ) ) ); // gray10
-
if( bIsRTL )
xLegendProperties->setPropertyValue( "AnchorPosition", uno::Any( chart2::LegendPosition_LINE_START ));
}
diff --git a/chart2/source/tools/ChartStyle.cxx b/chart2/source/tools/ChartStyle.cxx
index 8aac449dcf90..6c7c0bafe093 100644
--- a/chart2/source/tools/ChartStyle.cxx
+++ b/chart2/source/tools/ChartStyle.cxx
@@ -19,6 +19,8 @@
#include <ChartStyle.hxx>
#include <com/sun/star/chart2/ChartObjectType.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
#include <cppuhelper/supportsservice.hxx>
#include <vector>
@@ -104,6 +106,15 @@ void ChartStyle::register_styles()
m_xChartStyle[css::chart2::ChartObjectType::LEGEND] = new ChartObjectStyle(
*chart::legend::StaticLegendInfo::get(), *chart::legend::StaticLegendInfoHelper::get(),
*chart::legend::StaticLegendDefaults::get());
+
+ css::uno::Reference<css::beans::XPropertySet> xLegendStyle
+ = m_xChartStyle[css::chart2::ChartObjectType::LEGEND];
+ xLegendStyle->setPropertyValue("FillStyle", css::uno::Any(css::drawing::FillStyle_NONE));
+ xLegendStyle->setPropertyValue("LineStyle", css::uno::Any(css::drawing::LineStyle_NONE));
+ xLegendStyle->setPropertyValue("LineColor",
+ css::uno::Any(static_cast<sal_Int32>(0xb3b3b3))); // gray30
+ xLegendStyle->setPropertyValue("FillColor",
+ css::uno::Any(static_cast<sal_Int32>(0xe6e6e6))); // gray10
}
// _____ XServiceInfo _____
commit 3ff4ac00a7bdee0e7cecaf5c35bc8056bc3f1d41
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
AuthorDate: Sat Aug 10 01:19:23 2019 +0800
Commit: Markus Mohrhard <markus.mohrhard at googlemail.com>
CommitDate: Sat Aug 10 01:19:48 2019 +0800
add initial code to apply style to chart
Change-Id: I33207f95236f4102f8ae5620465494b3384fbbbb
diff --git a/chart2/source/inc/ChartStyle.hxx b/chart2/source/inc/ChartStyle.hxx
index 2c1fb3d9e7f8..c12441e1cd76 100644
--- a/chart2/source/inc/ChartStyle.hxx
+++ b/chart2/source/inc/ChartStyle.hxx
@@ -91,6 +91,9 @@ public:
virtual css::uno::Reference<css::beans::XPropertySet>
SAL_CALL getStyleForObject(const sal_Int16 nChartObjectType) override;
+ virtual void SAL_CALL
+ applyStyleToDiagram(const css::uno::Reference<css::chart2::XDiagram>& xDiagram);
+
private:
sal_Int16 m_nNumObjects;
diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx
index 262070310591..ba5a5d399445 100644
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -687,6 +687,8 @@ void SAL_CALL ChartModel::setFirstDiagram( const uno::Reference< chart2::XDiagra
ModifyListenerHelper::removeListener( xOldDiagram, xListener );
ModifyListenerHelper::addListener( xDiagram, xListener );
setModified( true );
+
+ m_xChartStyle->applyStyleToDiagram(xDiagram);
}
Reference< chart2::data::XDataSource > ChartModel::impl_createDefaultData()
diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx
index 642aceb626ae..87a0a742b7d9 100644
--- a/chart2/source/model/main/ChartModel_Persistence.cxx
+++ b/chart2/source/model/main/ChartModel_Persistence.cxx
@@ -732,6 +732,12 @@ void SAL_CALL ChartModel::modified( const lang::EventObject& rEvenObject)
}
unlockControllers();
}
+ uno::Reference<chart2::XDiagram> xDiagram(rEvenObject.Source, uno::UNO_QUERY);
+ if (xDiagram.is())
+ {
+ if (m_xChartStyle.is())
+ m_xChartStyle->applyStyleToDiagram(xDiagram);
+ }
if (m_nInLoad == 0)
setModified(true);
diff --git a/chart2/source/tools/ChartStyle.cxx b/chart2/source/tools/ChartStyle.cxx
index 7ec585b330f3..8aac449dcf90 100644
--- a/chart2/source/tools/ChartStyle.cxx
+++ b/chart2/source/tools/ChartStyle.cxx
@@ -121,6 +121,20 @@ css::uno::Sequence<OUString> SAL_CALL ChartStyle::getSupportedServiceNames()
{
return { "com.sun.star.chart2.ChartStyle" };
}
+
+void SAL_CALL
+ChartStyle::applyStyleToDiagram(const css::uno::Reference<css::chart2::XDiagram>& xDiagram)
+{
+ css::uno::Reference<css::style::XStyleSupplier> xLegendStyle(xDiagram->getLegend(),
+ css::uno::UNO_QUERY);
+ if (xLegendStyle.is())
+ {
+ xLegendStyle->setStyle(css::uno::Reference<css::style::XStyle>(
+ m_xChartStyle.find(css::chart2::ChartObjectType::LEGEND)->second,
+ css::uno::UNO_QUERY_THROW));
+ }
+}
+
//
// needed by MSC compiler
using impl::ChartObjectStyle_Base;
diff --git a/offapi/com/sun/star/chart2/XChartStyle.idl b/offapi/com/sun/star/chart2/XChartStyle.idl
index a072d6f2c833..3293f94f130a 100644
--- a/offapi/com/sun/star/chart2/XChartStyle.idl
+++ b/offapi/com/sun/star/chart2/XChartStyle.idl
@@ -13,12 +13,15 @@
#include <com/sun/star/uno/XInterface.idl>
#include <com/sun/star/beans/XPropertySet.idl>
#include <com/sun/star/chart2/ChartObjectType.idl>
+#include <com/sun/star/chart2/XDiagram.idl>
module com { module sun { module star { module chart2 {
interface XChartStyle : ::com::sun::star::uno::XInterface
{
com::sun::star::beans::XPropertySet getStyleForObject([in] short chartObjectType);
+
+ void applyStyleToDiagram([in] XDiagram chartDiagram);
};
}; }; }; };
More information about the Libreoffice-commits
mailing list