[Libreoffice-commits] core.git: Branch 'private/kohei/new-chart-type-skeleton' - chart2/source

Kohei Yoshida kohei.yoshida at collabora.com
Fri Mar 28 11:57:51 PDT 2014


 chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx          |    1 
 chart2/source/controller/chartapiwrapper/WrappedGL3DProperties.cxx   |  146 ++++++++++
 chart2/source/controller/chartapiwrapper/WrappedGL3DProperties.hxx   |   38 ++
 chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx |    2 
 4 files changed, 186 insertions(+), 1 deletion(-)

New commits:
commit 90b586223341b1c365235710cd04a32206b2a145
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Mar 28 14:57:34 2014 -0400

    Add API wrapper to handle properties of new GL3D chart type.
    
    Now the new proprety gets properly imported and exported to and from ODF.
    
    Change-Id: I4b773d68610a8aeaeb239901dac166e4dc2dd80d

diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
index 1f93f13..822d32c 100644
--- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
@@ -2047,6 +2047,7 @@ const std::vector< WrappedProperty* > DiagramWrapper::createWrappedProperties()
     WrappedSplineProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
     WrappedStockProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
     WrappedAutomaticPositionProperties::addWrappedProperties( aWrappedProperties );
+    WrappedGL3DProperties::addWrappedProperties(aWrappedProperties, m_spChart2ModelContact);
 
     aWrappedProperties.push_back( new WrappedDataRowSourceProperty( m_spChart2ModelContact ) );
     aWrappedProperties.push_back( new WrappedStackingProperty( StackMode_Y_STACKED,m_spChart2ModelContact ) );
diff --git a/chart2/source/controller/chartapiwrapper/WrappedGL3DProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedGL3DProperties.cxx
new file mode 100644
index 0000000..a4beaf5
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedGL3DProperties.cxx
@@ -0,0 +1,146 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "WrappedGL3DProperties.hxx"
+#include "Chart2ModelContact.hxx"
+#include <unonames.hxx>
+#include <WrappedProperty.hxx>
+#include <DiagramHelper.hxx>
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/chart2/XDiagram.hpp>
+
+using namespace com::sun::star;
+
+namespace chart { namespace wrapper {
+
+namespace {
+
+enum
+{
+    PROP_GL3DCHARTTYPE_ROUNDED_EDGE
+};
+
+class WrappedGL3DProperty : public WrappedProperty
+{
+    uno::Any maDefault;
+    boost::shared_ptr<Chart2ModelContact> mpModelContact;
+
+private:
+    uno::Reference<chart2::XChartType> getChartType() const
+    {
+        uno::Reference<chart2::XDiagram> xDiagram = mpModelContact->getChart2Diagram();
+        uno::Sequence<uno::Reference<chart2::XChartType> > aCTs =
+            DiagramHelper::getChartTypesFromDiagram(xDiagram);
+
+        for (sal_Int32 i = 0; i < aCTs.getLength(); ++i)
+        {
+            uno::Reference<chart2::XChartType> xThisCT = aCTs[i];
+            if (xThisCT->getChartType() == "com.sun.star.chart2.GL3DBarChartType")
+                // Found the right chart type.
+                return xThisCT;
+        }
+
+        return uno::Reference<chart2::XChartType>();
+    }
+
+public:
+    WrappedGL3DProperty( const OUString& rInName, const OUString& rOutName, const uno::Any& rDefault, const boost::shared_ptr<Chart2ModelContact>& pContact ) :
+        WrappedProperty(rInName, rOutName), maDefault(rDefault), mpModelContact(pContact) {}
+
+    virtual ~WrappedGL3DProperty() {}
+
+    virtual uno::Any getPropertyValue( const uno::Reference<beans::XPropertySet>& /*xInnerPS*/ ) const
+        throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+    {
+        uno::Reference<chart2::XChartType> xCT = getChartType();
+        if (!xCT.is())
+            return uno::Any();
+
+        try
+        {
+            uno::Reference<beans::XPropertySet> xPS(xCT, uno::UNO_QUERY_THROW);
+            return xPS->getPropertyValue(CHART_UNONAME_ROUNDED_EDGE);
+        }
+        catch ( const uno::Exception& )  {}
+
+        return uno::Any();
+    };
+
+    virtual void setPropertyValue(
+        const uno::Any& rOutValue, const uno::Reference<beans::XPropertySet>& /*xInnerPS*/ ) const
+            throw (beans::UnknownPropertyException, beans::PropertyVetoException,
+                   lang::IllegalArgumentException, lang::WrappedTargetException,
+                   uno::RuntimeException)
+    {
+        uno::Reference<chart2::XChartType> xCT = getChartType();
+        if (!xCT.is())
+            return;
+
+        try
+        {
+            uno::Reference<beans::XPropertySet> xPS(xCT, uno::UNO_QUERY_THROW);
+            return xPS->setPropertyValue(CHART_UNONAME_ROUNDED_EDGE, rOutValue);
+        }
+        catch ( const uno::Exception& )  {}
+    }
+
+    virtual void setPropertyToDefault( const uno::Reference<beans::XPropertyState>& /*xInnerPropState*/ ) const
+        throw (beans::UnknownPropertyException, uno::RuntimeException)
+    {
+        uno::Reference<chart2::XChartType> xCT = getChartType();
+        if (!xCT.is())
+            return;
+
+        try
+        {
+            uno::Reference<beans::XPropertySet> xPS(xCT, uno::UNO_QUERY_THROW);
+            return xPS->setPropertyValue(CHART_UNONAME_ROUNDED_EDGE, maDefault);
+        }
+        catch ( const uno::Exception& )  {}
+    }
+
+    virtual uno::Any getPropertyDefault( const uno::Reference<beans::XPropertyState>& /*xInnerPS*/ ) const
+        throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+    {
+        return maDefault;
+    }
+
+    virtual beans::PropertyState getPropertyState( const uno::Reference<beans::XPropertyState>& /*xInnerPS*/ ) const
+                        throw (beans::UnknownPropertyException, uno::RuntimeException)
+    {
+        return beans::PropertyState_DIRECT_VALUE;
+    }
+};
+
+}
+
+void WrappedGL3DProperties::addProperties( std::vector<css::beans::Property> & rOutProps )
+{
+    rOutProps.push_back(
+        beans::Property(
+            CHART_UNONAME_ROUNDED_EDGE,
+            PROP_GL3DCHARTTYPE_ROUNDED_EDGE,
+            ::getCppuBooleanType(),
+            beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT
+        )
+    );
+}
+
+void WrappedGL3DProperties::addWrappedProperties(
+    std::vector<WrappedProperty*>& rList, const boost::shared_ptr<Chart2ModelContact>& pChart2ModelContact )
+{
+    rList.push_back(
+        new WrappedGL3DProperty(
+            CHART_UNONAME_ROUNDED_EDGE, CHART_UNONAME_ROUNDED_EDGE, uno::makeAny(false), pChart2ModelContact));
+}
+
+}}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedGL3DProperties.hxx b/chart2/source/controller/chartapiwrapper/WrappedGL3DProperties.hxx
new file mode 100644
index 0000000..90034a0
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedGL3DProperties.hxx
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef CHART2_WRAPPEDGL3DPROPERTIES_HXX
+#define CHART2_WRAPPEDGL3DPROPERTIES_HXX
+
+#include <vector>
+#include <boost/shared_ptr.hpp>
+
+#include <com/sun/star/beans/Property.hpp>
+
+namespace chart {
+
+class WrappedProperty;
+
+namespace wrapper {
+
+class Chart2ModelContact;
+
+class WrappedGL3DProperties
+{
+public:
+    static void addProperties( std::vector<css::beans::Property> & rOutProps );
+    static void addWrappedProperties(
+        std::vector<WrappedProperty*>& rList, const boost::shared_ptr<Chart2ModelContact>& pChart2ModelContact );
+};
+
+}}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx
index a72e9e7..8ae43c4 100644
--- a/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx
+++ b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx
@@ -212,7 +212,7 @@ void WrappedSplineProperties::addWrappedProperties( std::vector< WrappedProperty
     rList.push_back( new WrappedSplineTypeProperty( spChart2ModelContact ) );
     rList.push_back(
         new WrappedSplineProperty<sal_Int32>(
-            CHART_UNONAME_SPLINE_ORDER, CHART_UNONAME_SPLINE_ORDER, // same name ?
+            CHART_UNONAME_SPLINE_ORDER, CHART_UNONAME_SPLINE_ORDER,
             uno::makeAny(sal_Int32(3)), spChart2ModelContact));
     rList.push_back(
         new WrappedSplineProperty<sal_Int32>(


More information about the Libreoffice-commits mailing list