summaryrefslogtreecommitdiffstats
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
parentUpdate git submodules (diff)
downloadcore-cd3990d1d8f212474dee1c1d989f005e4d9913a4.tar.gz
core-cd3990d1d8f212474dee1c1d989f005e4d9913a4.zip
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
-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
-rw-r--r--include/svx/xgrad.hxx2
-rw-r--r--svx/source/xoutdev/xattr.cxx18
5 files changed, 64 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)
diff --git a/include/svx/xgrad.hxx b/include/svx/xgrad.hxx
index 6e372ec2dbfb..e6331d7274c5 100644
--- a/include/svx/xgrad.hxx
+++ b/include/svx/xgrad.hxx
@@ -25,6 +25,7 @@
#include <svx/svxdllapi.h>
#include <com/sun/star/awt/GradientStyle.hpp>
#include <boost/property_tree/ptree_fwd.hpp>
+#include <com/sun/star/awt/Gradient.hpp>
class Gradient;
@@ -77,6 +78,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 9d70537d188c..f8b532ab554e 100644
--- a/svx/source/xoutdev/xattr.cxx
+++ b/svx/source/xoutdev/xattr.cxx
@@ -2036,6 +2036,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 ),