diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2020-09-29 15:11:41 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2020-10-07 08:52:58 +0200 |
commit | 8fdaa15db9a9303c42184e7d3a2b32a4b5e1c340 (patch) | |
tree | ce1ba1d6a1621dcf1dff09d06621e974f55bf0e3 /chart2 | |
parent | 4941dced3db465d7e2e88db0864fd785a4574882 (diff) |
lok: Add posibility to change chart fill gradient
Change-Id: I942d478cd870036710390d2c03413b6fc0454038
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103619
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104034
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/controller/inc/ChartController.hxx | 1 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartController.cxx | 4 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartController_Tools.cxx | 38 |
3 files changed, 43 insertions, 0 deletions
diff --git a/chart2/source/controller/inc/ChartController.hxx b/chart2/source/controller/inc/ChartController.hxx index 6894ab3b3592..5e5c229cd147 100644 --- a/chart2/source/controller/inc/ChartController.hxx +++ b/chart2/source/controller/inc/ChartController.hxx @@ -503,6 +503,7 @@ private: void executeDispatch_LOKSetTextSelection(int nType, int nX, int nY); void executeDispatch_LOKPieSegmentDragging(int nOffset); void executeDispatch_FillColor(sal_uInt32 nColor); + void executeDispatch_FillGradient(OUString sJSONGradient); void sendPopupRequest(OUString const & rCID, tools::Rectangle aRectangle); diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index c2dc975d02f2..8fedb472ca04 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -1113,6 +1113,10 @@ void SAL_CALL ChartController::dispatch( this->executeDispatch_FillColor(nColor); } } + else if(aCommand.startsWith("FillGradient")) + { + this->executeDispatch_FillGradient(aCommand.copy(aCommand.indexOf('=') + 1)); + } else if(aCommand == "Paste") this->executeDispatch_Paste(); else if(aCommand == "Copy" ) diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index 646aaf535b17..396ae00807a8 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -67,6 +67,9 @@ #include <svx/svdpage.hxx> #include <svx/svdundo.hxx> #include <svx/unoapi.hxx> +#include <svx/xgrad.hxx> +#include <svx/xflgrit.hxx> +#include <PropertyHelper.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <tools/debug.hxx> @@ -946,6 +949,41 @@ void ChartController::executeDispatch_FillColor(sal_uInt32 nColor) xPointProperties->setPropertyValue( "FillColor", uno::Any( nColor ) ); } } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION( "chart2" ); + } +} + +void ChartController::executeDispatch_FillGradient(OUString sJSONGradient) +{ + XGradient aXGradient = XGradient::fromJSON(sJSONGradient); + css::awt::Gradient aGradient = aXGradient.toGradientUNO(); + + try + { + OUString aCID( m_aSelection.getSelectedCID() ); + const uno::Reference< frame::XModel >& xChartModel = getModel(); + + if( xChartModel.is() ) + { + Reference< beans::XPropertySet > xPropSet( + ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ) ); + + if( xPropSet.is() ) + { + OUString aPrefferedName = OUString::number(static_cast<sal_Int32>(aXGradient.GetStartColor())) + + OUString::number(static_cast<sal_Int32>(aXGradient.GetEndColor())) + + OUString::number(static_cast<sal_Int32>(aXGradient.GetAngle())); + + OUString aNewName = PropertyHelper::addGradientUniqueNameToTable(css::uno::Any(aGradient), + css::uno::Reference<css::lang::XMultiServiceFactory>(xChartModel, css::uno::UNO_QUERY_THROW), + aPrefferedName); + + xPropSet->setPropertyValue("FillGradientName", css::uno::Any(aNewName)); + } + } + } catch( const uno::Exception & ex ) { SAL_WARN( "chart2", "Exception caught. " << ex ); |