diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2020-09-29 15:11:41 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2020-10-05 21:55:29 +0200 |
commit | 80ba3eda8cd3c8ebbf2e49b215e2f2eb6d4b1837 (patch) | |
tree | 746957595926a2530a922ffe1c05923df7fff1f8 /chart2 | |
parent | 2eb685b59b63e83d6130fdd2a97ce9bbb8b26823 (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>
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 270f5743e0c7..50568da2e998 100644 --- a/chart2/source/controller/inc/ChartController.hxx +++ b/chart2/source/controller/inc/ChartController.hxx @@ -502,6 +502,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 5ee520362c0b..3d88f3aadd1a 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -1122,6 +1122,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 ff1c83ae7e7f..94bafa620bce 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -73,6 +73,9 @@ #include <svx/unoapi.hxx> #include <svx/unopage.hxx> #include <o3tl/make_unique.hxx> +#include <svx/xgrad.hxx> +#include <svx/xflgrit.hxx> +#include <PropertyHelper.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <tools/diagnose_ex.h> @@ -957,6 +960,41 @@ void ChartController::executeDispatch_FillColor(sal_uInt32 nColor) } } +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 ); + } +} + void ChartController::executeDispatch_LOKSetTextSelection(int nType, int nX, int nY) { if (m_pDrawViewWrapper) |