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 | |
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>
-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 | ||||
-rw-r--r-- | include/svx/xgrad.hxx | 2 | ||||
-rw-r--r-- | svx/source/xoutdev/xattr.cxx | 18 |
5 files changed, 63 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 ); diff --git a/include/svx/xgrad.hxx b/include/svx/xgrad.hxx index 5e1f33ace5a0..c392b9d0a2ae 100644 --- a/include/svx/xgrad.hxx +++ b/include/svx/xgrad.hxx @@ -24,6 +24,7 @@ #include <svx/svxdllapi.h> #include <com/sun/star/awt/GradientStyle.hpp> #include <boost/property_tree/json_parser.hpp> +#include <com/sun/star/awt/Gradient.hpp> class Gradient; @@ -76,6 +77,7 @@ public: boost::property_tree::ptree dumpAsJSON() const; static XGradient fromJSON(const OUString& rJSON); + css::awt::Gradient toGradientUNO(); }; #endif diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx index 682396b0de5e..b3b7a1c8d44a 100644 --- a/svx/source/xoutdev/xattr.cxx +++ b/svx/source/xoutdev/xattr.cxx @@ -2044,6 +2044,24 @@ XGradient XGradient::fromJSON(const OUString& rJSON) return lcl_buildGradientFromStringMap(aMap); } +css::awt::Gradient XGradient::toGradientUNO() +{ + css::awt::Gradient aGradient; + + aGradient.Style = this->GetGradientStyle(); + aGradient.StartColor = static_cast<sal_Int32>(this->GetStartColor()); + aGradient.EndColor = static_cast<sal_Int32>(this->GetEndColor()); + aGradient.Angle = static_cast<short>(this->GetAngle()); + aGradient.Border = this->GetBorder(); + aGradient.XOffset = this->GetXOffset(); + aGradient.YOffset = this->GetYOffset(); + aGradient.StartIntensity = this->GetStartIntens(); + aGradient.EndIntensity = this->GetEndIntens(); + aGradient.StepCount = this->GetSteps(); + + return aGradient; +} + XGradient::XGradient() : eStyle( css::awt::GradientStyle_LINEAR ), aStartColor( COL_BLACK ), |