summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2020-09-29 15:11:41 +0200
committerAndras Timar <andras.timar@collabora.com>2020-11-11 09:58:11 +0100
commitcd3990d1d8f212474dee1c1d989f005e4d9913a4 (patch)
treea1e4eaec70274fabdb5f978e70f0400f4f445600 /chart2
parent287dff6de897ef2dfb6743cd9273cf595c1fec13 (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/+/104808 Tested-by: Jenkins
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/controller/inc/ChartController.hxx1
-rw-r--r--chart2/source/controller/main/ChartController.cxx4
-rw-r--r--chart2/source/controller/main/ChartController_Tools.cxx39
3 files changed, 44 insertions, 0 deletions
diff --git a/chart2/source/controller/inc/ChartController.hxx b/chart2/source/controller/inc/ChartController.hxx
index 293e1b732774..aa399f2164b3 100644
--- a/chart2/source/controller/inc/ChartController.hxx
+++ b/chart2/source/controller/inc/ChartController.hxx
@@ -498,6 +498,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 552316bdd5eb..1953bf9e6f59 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -1112,6 +1112,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 0b6401456c9a..ed0776d94c79 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -67,6 +67,10 @@
#include <svx/svdpage.hxx>
#include <svx/svdundo.hxx>
#include <svx/unoapi.hxx>
+#include <svx/unopage.hxx>
+#include <svx/xgrad.hxx>
+#include <svx/xflgrit.hxx>
+#include <PropertyHelper.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <tools/debug.hxx>
@@ -940,6 +944,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().get()));
+
+ 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 & )
+ {
+ TOOLS_WARN_EXCEPTION("chart2", "" );
+ }
+}
+
void ChartController::executeDispatch_LOKSetTextSelection(int nType, int nX, int nY)
{
if (!m_pDrawViewWrapper)