diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-03-27 22:04:28 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-03-29 00:47:20 -0400 |
commit | ef15c946998af91a88896d29903cb997a5e78ede (patch) | |
tree | bb9c418097901050c8ee16441a376f7bdaab748d /chart2 | |
parent | 91e1497abc4fd2817b56eb1e77ddd8fd2691a199 (diff) |
Trying to move this RoundedEdge property from Diagram to GL3DBarChartType.
Then things stop working. Go figure.
Change-Id: I38893b20104537a64d279063c7b7dd708efb0d2f
Diffstat (limited to 'chart2')
7 files changed, 166 insertions, 32 deletions
diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index 3160e3edb330..984a2efae336 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 031c46806a5d..c31ffc88ee79 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 5e111b89be8d..0e313b6916f8 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 6c75a3f8170c..f6beaa4150cf 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 7f07028dc704..163423a1e562 100644 --- a/chart2/source/model/template/GL3DBarChartTypeTemplate.cxx +++ b/chart2/source/model/template/GL3DBarChartTypeTemplate.cxx @@ -11,14 +11,90 @@ #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 { +namespace { + +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() {} @@ -33,6 +109,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) { @@ -43,24 +126,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) { @@ -76,6 +164,27 @@ 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(); +} + +IMPLEMENT_FORWARD_XINTERFACE2(GL3DBarChartTypeTemplate, ChartTypeTemplate, OPropertySet) + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/GL3DBarChartTypeTemplate.hxx b/chart2/source/model/template/GL3DBarChartTypeTemplate.hxx index 78e7a7480dca..ba4943a64bf9 100644 --- a/chart2/source/model/template/GL3DBarChartTypeTemplate.hxx +++ b/chart2/source/model/template/GL3DBarChartTypeTemplate.hxx @@ -13,13 +13,20 @@ #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: + + DECLARE_XINTERFACE() + GL3DBarChartTypeTemplate( const css::uno::Reference< css::uno::XComponentContext>& xContext, @@ -37,6 +44,17 @@ public: virtual sal_Bool SAL_CALL supportsCategories() throw (::css::uno::RuntimeException, ::std::exception) SAL_OVERRIDE; + + // 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 7b02bcc4db63..62f189a55c41 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 } } |