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

Kohei Yoshida kohei.yoshida at collabora.com
Thu Mar 27 19:06:25 PDT 2014


 chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx    |    7 
 chart2/source/controller/dialogs/ChartTypeDialogController.cxx |   18 +
 chart2/source/controller/dialogs/tp_ChartType.cxx              |    3 
 chart2/source/model/main/Diagram.cxx                           |   10 
 chart2/source/model/template/GL3DBarChartTypeTemplate.cxx      |  114 +++++++++-
 chart2/source/model/template/GL3DBarChartTypeTemplate.hxx      |   19 +
 chart2/source/view/charttypes/GL3DBarChart.cxx                 |   52 ++++
 7 files changed, 196 insertions(+), 27 deletions(-)

New commits:
commit d22fbd97e2f93cdde78339a283a807037da5a6fa
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Thu Mar 27 22:04:28 2014 -0400

    Trying to move this RoundedEdge property from Diagram to GL3DBarChartType.
    
    Then things stop working. Go figure.
    
    Change-Id: I38893b20104537a64d279063c7b7dd708efb0d2f

diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
index 01075fc..0e05e6d 100644
--- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
@@ -446,13 +446,6 @@ void lcl_AddPropertiesToVector(
                   ::getCppuType( reinterpret_cast< const OUString * >(0)),
                   beans::PropertyAttribute::BOUND
                   | beans::PropertyAttribute::MAYBEVOID ));
-
-    rOutProperties.push_back(
-         Property( CHART_UNONAME_ROUNDED_EDGE,
-                   PROP_DIAGRAM_ROUNDED_EDGE,
-                   ::getCppuBooleanType(),
-                   beans::PropertyAttribute::BOUND
-                   | beans::PropertyAttribute::MAYBEVOID));
 }
 
 struct StaticDiagramWrapperPropertyArray_Initializer
diff --git a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx
index 031c468..c31ffc8 100644
--- a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx
+++ b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx
@@ -162,9 +162,15 @@ ChartTypeParameter ChartTypeDialogController::getChartTypeParameterForService(
         }
         catch( uno::Exception& ex )
         {
-            //not all templates need to support CGeometry3D
+            //not all templates need to support Geometry3D
             ex.Context.is();//to have debug information without compilation warnings
         }
+
+        try
+        {
+            xTemplateProps->getPropertyValue(CHART_UNONAME_ROUNDED_EDGE) >>= aRet.mbRoundedEdge;
+        }
+        catch ( const uno::Exception& ) {}
     }
     return aRet;
 }
@@ -303,6 +309,15 @@ uno::Reference< XChartTypeTemplate > ChartTypeDialogController::getCurrentTempla
                     //not all templates need to support Geometry3D
                     ex.Context.is();//to have debug information without compilation warnings
                 }
+
+                try
+                {
+                    xTemplateProps->setPropertyValue(CHART_UNONAME_ROUNDED_EDGE, uno::makeAny(rParameter.mbRoundedEdge));
+                }
+                catch ( const uno::Exception& )
+                {
+                }
+
                 try
                 {
                     this->setTemplateProperties( xTemplateProps );
@@ -343,7 +358,6 @@ bool ChartTypeDialogController::commitToModel( const ChartTypeParameter& rParame
         if (xDiaProp.is())
         {
             xDiaProp->setPropertyValue(CHART_UNONAME_SORT_BY_XVALUES, uno::makeAny(rParameter.bSortByXValues));
-            xDiaProp->setPropertyValue(CHART_UNONAME_ROUNDED_EDGE, uno::makeAny(rParameter.mbRoundedEdge));
         }
     }
     return false;
diff --git a/chart2/source/controller/dialogs/tp_ChartType.cxx b/chart2/source/controller/dialogs/tp_ChartType.cxx
index c7bed9a..18f6cf0 100644
--- a/chart2/source/controller/dialogs/tp_ChartType.cxx
+++ b/chart2/source/controller/dialogs/tp_ChartType.cxx
@@ -834,7 +834,6 @@ void ChartTypeTabPage::stateChanged( ChangingResource* /*pResource*/ )
     {
         uno::Reference<beans::XPropertySet> xPropSet(xDiagram, uno::UNO_QUERY_THROW);
         xPropSet->getPropertyValue(CHART_UNONAME_SORT_BY_XVALUES) >>= aParameter.bSortByXValues;
-        xPropSet->getPropertyValue(CHART_UNONAME_ROUNDED_EDGE) >>= aParameter.mbRoundedEdge;
     }
     catch ( const uno::Exception& ex )
     {
@@ -901,7 +900,6 @@ void ChartTypeTabPage::selectMainType()
         {
             uno::Reference<beans::XPropertySet> xPropSet(xDiagram, uno::UNO_QUERY_THROW);
             xPropSet->getPropertyValue(CHART_UNONAME_SORT_BY_XVALUES) >>= aParameter.bSortByXValues;
-            xPropSet->getPropertyValue(CHART_UNONAME_ROUNDED_EDGE) >>= aParameter.mbRoundedEdge;
         }
         catch ( const uno::Exception& ex )
         {
@@ -986,7 +984,6 @@ void ChartTypeTabPage::initializePage()
             {
                 uno::Reference<beans::XPropertySet> xPropSet(xDiagram, uno::UNO_QUERY_THROW);
                 xPropSet->getPropertyValue(CHART_UNONAME_SORT_BY_XVALUES) >>= aParameter.bSortByXValues;
-                xPropSet->getPropertyValue(CHART_UNONAME_ROUNDED_EDGE) >>= aParameter.mbRoundedEdge;
             }
             catch (const uno::Exception& ex)
             {
diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx
index 6c75a3f..f6beaa4 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -77,8 +77,7 @@ enum
     PROP_DIAGRAM_DATATABLEHBORDER,
     PROP_DIAGRAM_DATATABLEVBORDER,
     PROP_DIAGRAM_DATATABLEOUTLINE,
-    PROP_DIAGRAM_EXTERNALDATA,
-    PROP_DIAGRAM_ROUNDED_EDGE
+    PROP_DIAGRAM_EXTERNALDATA
 };
 
 void lcl_AddPropertiesToVector(
@@ -199,12 +198,6 @@ void lcl_AddPropertiesToVector(
                   PROP_DIAGRAM_EXTERNALDATA,
                   ::getCppuType( reinterpret_cast< const OUString   * >(0)),
                   beans::PropertyAttribute::MAYBEVOID ));
-
-   rOutProperties.push_back(
-        Property( CHART_UNONAME_ROUNDED_EDGE,
-                  PROP_DIAGRAM_ROUNDED_EDGE,
-                  ::getCppuBooleanType(),
-                  beans::PropertyAttribute::MAYBEVOID));
 }
 
 struct StaticDiagramDefaults_Initializer
@@ -227,7 +220,6 @@ private:
         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_DATATABLEHBORDER, false );
         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_DATATABLEVBORDER, false );
         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_DATATABLEOUTLINE, false );
-        ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_ROUNDED_EDGE, false );
         ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DIAGRAM_STARTING_ANGLE, 90 );
         ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DIAGRAM_3DRELATIVEHEIGHT, 100 );
          ::chart::SceneProperties::AddDefaultsToMap( rOutMap );
diff --git a/chart2/source/model/template/GL3DBarChartTypeTemplate.cxx b/chart2/source/model/template/GL3DBarChartTypeTemplate.cxx
index da5b8c1..13a3077 100644
--- a/chart2/source/model/template/GL3DBarChartTypeTemplate.cxx
+++ b/chart2/source/model/template/GL3DBarChartTypeTemplate.cxx
@@ -11,8 +11,14 @@
 #include "GL3DBarChartType.hxx"
 
 #include <servicenames_charttypes.hxx>
+#include <PropertyHelper.hxx>
+#include <DiagramHelper.hxx>
+#include <unonames.hxx>
 #include <macros.hxx>
 
+#include <com/sun/star/beans/Property.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+
 using namespace com::sun::star;
 
 namespace chart {
@@ -21,10 +27,76 @@ namespace {
 
 const OUString aServiceName("com.sun.star.chart2.GL3DBarChartTypeTemplate");
 
+enum
+{
+    PROP_GL3DCHARTTYPE_ROUNDED_EDGE
+};
+
+struct DefaultsInitializer
+{
+    tPropertyValueMap* operator()()
+    {
+        static tPropertyValueMap aStaticDefaults;
+
+        if (aStaticDefaults.empty())
+            addDefaults(aStaticDefaults);
+
+        return &aStaticDefaults;
+    }
+private:
+
+    void addDefaults( tPropertyValueMap & rOutMap )
+    {
+        PropertyHelper::setPropertyValueDefault(rOutMap, PROP_GL3DCHARTTYPE_ROUNDED_EDGE, false);
+    }
+};
+
+struct Defaults : public rtl::StaticAggregate<tPropertyValueMap, DefaultsInitializer> {};
+
+struct InfoHelperInitializer
+{
+    cppu::OPropertyArrayHelper* operator()()
+    {
+        static cppu::OPropertyArrayHelper aHelper(getProperties());
+        return &aHelper;
+    }
+
+    uno::Sequence<beans::Property> getProperties()
+    {
+        uno::Sequence<beans::Property> aRet(1);
+
+        aRet[0] = beans::Property(
+            CHART_UNONAME_ROUNDED_EDGE,
+            PROP_GL3DCHARTTYPE_ROUNDED_EDGE,
+            ::getCppuBooleanType(),
+            beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT);
+
+        return aRet;
+    }
+};
+
+struct InfoHelper : public rtl::StaticAggregate<cppu::OPropertyArrayHelper, InfoHelperInitializer> {};
+
+struct ChartTypeInfoInitializer
+{
+    uno::Reference<beans::XPropertySetInfo>* operator()()
+    {
+        static uno::Reference<beans::XPropertySetInfo> xPropertySetInfo;
+
+        if (!xPropertySetInfo.is())
+            xPropertySetInfo = cppu::OPropertySetHelper::createPropertySetInfo(*InfoHelper::get());
+
+        return &xPropertySetInfo;
+    }
+};
+
+struct ChartTypeInfo : public rtl::StaticAggregate<uno::Reference<beans::XPropertySetInfo>, ChartTypeInfoInitializer> {};
+
 }
 
 GL3DBarChartTypeTemplate::GL3DBarChartTypeTemplate(
     const uno::Reference<uno::XComponentContext>& xContext, const OUString& rServiceName ) :
+    property::OPropertySet(m_aMutex),
     ChartTypeTemplate(xContext, rServiceName) {}
 
 GL3DBarChartTypeTemplate::~GL3DBarChartTypeTemplate() {}
@@ -39,6 +111,13 @@ uno::Reference<chart2::XChartType> GL3DBarChartTypeTemplate::getChartTypeForInde
             GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW);
 
         xResult.set(xFact->createInstance(CHART2_SERVICE_NAME_CHARTTYPE_GL3DBAR), uno::UNO_QUERY_THROW);
+
+        uno::Reference<beans::XPropertySet> xCTProp(xResult, uno::UNO_QUERY);
+        if (xCTProp.is())
+        {
+            xCTProp->setPropertyValue(
+                CHART_UNONAME_ROUNDED_EDGE, getFastPropertyValue(PROP_GL3DCHARTTYPE_ROUNDED_EDGE));
+        }
     }
     catch (const uno::Exception & ex)
     {
@@ -49,24 +128,29 @@ uno::Reference<chart2::XChartType> GL3DBarChartTypeTemplate::getChartTypeForInde
 }
 
 uno::Reference<chart2::XChartType>
-GL3DBarChartTypeTemplate::getChartTypeForNewSeries( const uno::Sequence<uno::Reference<chart2::XChartType> >& xOldChartTypes )
+GL3DBarChartTypeTemplate::getChartTypeForNewSeries( const uno::Sequence<uno::Reference<chart2::XChartType> >& /*xOldChartTypes*/ )
     throw (::css::uno::RuntimeException, ::std::exception)
 {
     uno::Reference<chart2::XChartType> xResult;
 
     try
     {
-        uno::Reference<lang::XMultiServiceFactory> xFact(
-            GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW);
-
 #if 1
         // I gave up trying to use UNO just to instantiate this little thing...
         xResult.set(new GL3DBarChartType(GetComponentContext()));
+        uno::Reference<beans::XPropertySet> xCTProp(xResult, uno::UNO_QUERY);
+        if (xCTProp.is())
+        {
+            bool bVal = false;
+            getFastPropertyValue(PROP_GL3DCHARTTYPE_ROUNDED_EDGE) >>= bVal;
+            xCTProp->setPropertyValue(CHART_UNONAME_ROUNDED_EDGE, uno::makeAny(bVal));
+        }
 #else
         // This never works for me.
+        uno::Reference<lang::XMultiServiceFactory> xFact(
+            GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW);
         xResult.set(xFact->createInstance(CHART2_SERVICE_NAME_CHARTTYPE_GL3DBAR), uno::UNO_QUERY_THROW);
 #endif
-        ChartTypeTemplate::copyPropertiesFromOldToNewCoordianteSystem(xOldChartTypes, xResult);
     }
     catch (const uno::Exception & ex)
     {
@@ -82,6 +166,25 @@ sal_Bool GL3DBarChartTypeTemplate::supportsCategories()
     return false;
 }
 
+css::uno::Any GL3DBarChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+    throw (css::beans::UnknownPropertyException)
+{
+    const tPropertyValueMap& rDefaults = *Defaults::get();
+    tPropertyValueMap::const_iterator it = rDefaults.find(nHandle);
+    return it == rDefaults.end() ? uno::Any() : it->second;
+}
+
+cppu::IPropertyArrayHelper& GL3DBarChartTypeTemplate::getInfoHelper()
+{
+    return *InfoHelper::get();
+}
+
+css::uno::Reference<css::beans::XPropertySetInfo> GL3DBarChartTypeTemplate::getPropertySetInfo()
+    throw (css::uno::RuntimeException, std::exception)
+{
+    return *ChartTypeInfo::get();
+}
+
 uno::Sequence<OUString> GL3DBarChartTypeTemplate::getSupportedServiceNames_Static()
 {
     uno::Sequence<OUString> aServices(2);
@@ -91,6 +194,7 @@ uno::Sequence<OUString> GL3DBarChartTypeTemplate::getSupportedServiceNames_Stati
 }
 
 APPHELPER_XSERVICEINFO_IMPL(GL3DBarChartTypeTemplate, aServiceName);
+IMPLEMENT_FORWARD_XINTERFACE2(GL3DBarChartTypeTemplate, ChartTypeTemplate, OPropertySet)
 
 }
 
diff --git a/chart2/source/model/template/GL3DBarChartTypeTemplate.hxx b/chart2/source/model/template/GL3DBarChartTypeTemplate.hxx
index 4f4a0ce..da9f191 100644
--- a/chart2/source/model/template/GL3DBarChartTypeTemplate.hxx
+++ b/chart2/source/model/template/GL3DBarChartTypeTemplate.hxx
@@ -13,15 +13,21 @@
 #include <MutexContainer.hxx>
 #include <ChartTypeTemplate.hxx>
 #include <OPropertySet.hxx>
+#include <MutexContainer.hxx>
 #include <ServiceMacros.hxx>
 
+#include <comphelper/uno3.hxx>
+
 namespace chart {
 
-class GL3DBarChartTypeTemplate : public ChartTypeTemplate
+class GL3DBarChartTypeTemplate :
+    public MutexContainer, public property::OPropertySet, public ChartTypeTemplate
 {
 public:
     APPHELPER_XSERVICEINFO_DECL()
 
+    DECLARE_XINTERFACE()
+
     GL3DBarChartTypeTemplate(
         const css::uno::Reference<
             css::uno::XComponentContext>& xContext,
@@ -39,6 +45,17 @@ public:
 
     virtual sal_Bool SAL_CALL supportsCategories()
         throw (::css::uno::RuntimeException, ::std::exception);
+
+    // OPropertySet
+    virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const
+        throw (css::beans::UnknownPropertyException);
+
+    virtual cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+    // XPropertySet
+    virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL
+        getPropertySetInfo()
+            throw (css::uno::RuntimeException, std::exception);
 };
 
 }
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 7b02bcc..62f189a 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -8,6 +8,7 @@
  */
 
 #include "GL3DBarChart.hxx"
+#include <unonames.hxx>
 
 #include <com/sun/star/chart2/data/XDataSequence.hpp>
 #include <com/sun/star/chart2/data/LabelOrigin.hpp>
@@ -27,6 +28,18 @@ GL3DBarChart::~GL3DBarChart()
 
 void GL3DBarChart::createShapes()
 {
+    fprintf(stdout, "GL3DBarChart::createShapes:   type = '%s'\n",
+            rtl::OUStringToOString(m_xChartTypeModel->getChartType(), RTL_TEXTENCODING_UTF8).getStr());
+
+    uno::Reference<beans::XPropertySet> xPropSet(m_xChartTypeModel, uno::UNO_QUERY);
+    if (xPropSet.is())
+    {
+        bool bRoundedEdge = false;
+        if (xPropSet->getPropertyValue(CHART_UNONAME_ROUNDED_EDGE) >>= bRoundedEdge)
+            fprintf(stdout, "GL3DBarChart::createShapes:   rounded edge = %d (%p)\n", bRoundedEdge, m_xChartTypeModel.get());
+    }
+
+#if 0
     if (m_pExplicitCategoriesProvider)
     {
         uno::Reference<chart2::data::XDataSequence> xCats = m_pExplicitCategoriesProvider->getOriginalCategories();
@@ -56,13 +69,11 @@ void GL3DBarChart::createShapes()
                 rtl::OUStringToOString(pSeries->getSeriesParticle(), RTL_TEXTENCODING_UTF8).getStr());
 
         uno::Sequence<double> aXValues = pSeries->getAllX();
-        for (size_t j = 0; j < aXValues.getLength(); ++j)
-            fprintf(stdout, "GL3DBarChart::createShapes:     x = %g\n", aXValues[j]);
-
         uno::Sequence<double> aYValues = pSeries->getAllY();
-        for (size_t j = 0; j < aYValues.getLength(); ++j)
-            fprintf(stdout, "GL3DBarChart::createShapes:     y = %g\n", aYValues[j]);
+        for (size_t j = 0; j < aXValues.getLength(); ++j)
+            fprintf(stdout, "GL3DBarChart::createShapes:     (x=%g,y=%g)\n", aXValues[j], aYValues[j]);
     }
+#endif
 }
 
 }
commit c8a0dd05f0ffee40745f60550812d2aac3fd21b2
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Thu Mar 27 15:34:27 2014 -0400

    Some debugging output of GL chart.
    
    Change-Id: Ia216358085378b449626f9c9f36e63a65b7a2669

diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index bd0250b..7b02bcc 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -9,6 +9,11 @@
 
 #include "GL3DBarChart.hxx"
 
+#include <com/sun/star/chart2/data/XDataSequence.hpp>
+#include <com/sun/star/chart2/data/LabelOrigin.hpp>
+
+using namespace com::sun::star;
+
 namespace chart {
 
 GL3DBarChart::GL3DBarChart( const css::uno::Reference<css::chart2::XChartType>& xChartTypeModel ) :
@@ -22,6 +27,42 @@ GL3DBarChart::~GL3DBarChart()
 
 void GL3DBarChart::createShapes()
 {
+    if (m_pExplicitCategoriesProvider)
+    {
+        uno::Reference<chart2::data::XDataSequence> xCats = m_pExplicitCategoriesProvider->getOriginalCategories();
+
+        OUString aSrcRange = xCats->getSourceRangeRepresentation();
+
+        fprintf(stdout, "GL3DBarChart::createShapes:   source range = '%s'\n", rtl::OUStringToOString(aSrcRange, RTL_TEXTENCODING_UTF8).getStr());
+
+        uno::Sequence<OUString> aCats = m_pExplicitCategoriesProvider->getSimpleCategories();
+        for (sal_Int32 i = 0; i < aCats.getLength(); ++i)
+            fprintf(stdout, "GL3DBarChart::createShapes:   category = '%s'\n", rtl::OUStringToOString(aCats[i], RTL_TEXTENCODING_UTF8).getStr());
+    }
+
+    uno::Sequence<OUString> aSeriesNames = getSeriesNames();
+    fprintf(stdout, "GL3DBarChart::createShapes:   series name count = %d\n", aSeriesNames.getLength());
+    for (sal_Int32 i = 0; i < aSeriesNames.getLength(); ++i)
+        fprintf(stdout, "GL3DBarChart::createShapes:   name = '%s'\n", rtl::OUStringToOString(aSeriesNames[i], RTL_TEXTENCODING_UTF8).getStr());
+
+    std::vector<VDataSeries*> aAllSeries = getAllSeries();
+    fprintf(stdout, "GL3DBarChart::createShapes:   series count = %d\n", aAllSeries.size());
+    for (size_t i = 0, n = aAllSeries.size(); i < n; ++i)
+    {
+        const VDataSeries* pSeries = aAllSeries[i];
+        fprintf(stdout, "GL3DBarChart::createShapes:   series %d: cid = '%s'  particle = '%s'\n",
+                i,
+                rtl::OUStringToOString(pSeries->getCID(), RTL_TEXTENCODING_UTF8).getStr(),
+                rtl::OUStringToOString(pSeries->getSeriesParticle(), RTL_TEXTENCODING_UTF8).getStr());
+
+        uno::Sequence<double> aXValues = pSeries->getAllX();
+        for (size_t j = 0; j < aXValues.getLength(); ++j)
+            fprintf(stdout, "GL3DBarChart::createShapes:     x = %g\n", aXValues[j]);
+
+        uno::Sequence<double> aYValues = pSeries->getAllY();
+        for (size_t j = 0; j < aYValues.getLength(); ++j)
+            fprintf(stdout, "GL3DBarChart::createShapes:     y = %g\n", aYValues[j]);
+    }
 }
 
 }


More information about the Libreoffice-commits mailing list