[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 2 commits - chart2/source include/svx sc/source svx/source

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Wed Oct 7 06:53:31 UTC 2020


 chart2/source/controller/inc/ChartController.hxx        |    1 
 chart2/source/controller/main/ChartController.cxx       |    4 +
 chart2/source/controller/main/ChartController_Tools.cxx |   38 ++++++++++++++++
 include/svx/xgrad.hxx                                   |    2 
 sc/source/ui/drawfunc/drawsh2.cxx                       |   30 ++++++++++++
 svx/source/xoutdev/xattr.cxx                            |   18 +++++++
 6 files changed, 93 insertions(+)

New commits:
commit 7a061d5c8778fee58f966eee7f95917a5a74123e
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Sep 29 13:40:41 2020 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Wed Oct 7 08:53:04 2020 +0200

    Set correct gradient color for chart background in sidebar
    
    Change-Id: I98dc177494fddc4a975479e99aba7b6318051b1a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103618
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104033
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/sc/source/ui/drawfunc/drawsh2.cxx b/sc/source/ui/drawfunc/drawsh2.cxx
index 264f81998af9..e5339cc22940 100644
--- a/sc/source/ui/drawfunc/drawsh2.cxx
+++ b/sc/source/ui/drawfunc/drawsh2.cxx
@@ -34,6 +34,7 @@
 #include <svx/sidebar/SelectionChangeHandler.hxx>
 #include <svx/sidebar/SelectionAnalyzer.hxx>
 #include <svx/sidebar/ContextChangeEventMultiplexer.hxx>
+#include <svx/unomid.hxx>
 
 #include <drawsh.hxx>
 #include <drawview.hxx>
@@ -343,6 +344,35 @@ static void setupFillColorForChart(SfxViewShell* pShell, SfxItemSet& rSet)
                                     pShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED,
                                             (".uno:FillColor=" + std::to_string(nFillColor)).c_str());
                             }
+
+                            if (comphelper::LibreOfficeKit::isActive() && xInfo->hasPropertyByName("FillGradientName"))
+                            {
+                                OUString aGradientName;
+                                xPropSet->getPropertyValue("FillGradientName") >>= aGradientName;
+
+                                ::css::uno::Reference< ::css::frame::XController > xChartController = xChart->getCurrentController();
+                                if( xChartController.is() )
+                                {
+                                    css::uno::Reference<css::lang::XMultiServiceFactory> xFact(xChartController->getModel(), css::uno::UNO_QUERY);
+
+                                    if (xFact.is())
+                                    {
+                                        css::uno::Reference<css::container::XNameAccess> xNameAccess(
+                                            xFact->createInstance("com.sun.star.drawing.GradientTable"), css::uno::UNO_QUERY);
+
+                                        if (xNameAccess.is() && xNameAccess->hasByName(aGradientName))
+                                        {
+                                            css::uno::Any aAny = xNameAccess->getByName(aGradientName);
+
+                                            XFillGradientItem aItem;
+                                            aItem.SetName(aGradientName);
+                                            aItem.PutValue(aAny, MID_FILLGRADIENT);
+
+                                            rSet.Put(aItem);
+                                        }
+                                    }
+                                }
+                            }
                         }
                     }
                 }
commit 8fdaa15db9a9303c42184e7d3a2b32a4b5e1c340
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Sep 29 15:11:41 2020 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Wed Oct 7 08:52:58 2020 +0200

    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 at gmail.com>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104034
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

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 ),


More information about the Libreoffice-commits mailing list