1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include "WrappedGL3DProperties.hxx"
11 #include "Chart2ModelContact.hxx"
12 #include "FastPropertyIdRanges.hxx"
13 #include <unonames.hxx>
14 #include <WrappedProperty.hxx>
15 #include <DiagramHelper.hxx>
17 #include <com/sun/star/beans/PropertyAttribute.hpp>
18 #include <com/sun/star/chart2/XDiagram.hpp>
20 using namespace com::sun::star
;
22 namespace chart
{ namespace wrapper
{
28 PROP_GL3DCHARTTYPE_ROUNDED_EDGE
= FAST_PROPERTY_ID_START_GL_3D
31 class WrappedGL3DProperty
: public WrappedProperty
34 boost::shared_ptr
<Chart2ModelContact
> mpModelContact
;
37 uno::Reference
<chart2::XChartType
> getChartType() const
39 uno::Reference
<chart2::XDiagram
> xDiagram
= mpModelContact
->getChart2Diagram();
40 uno::Sequence
<uno::Reference
<chart2::XChartType
> > aCTs
=
41 DiagramHelper::getChartTypesFromDiagram(xDiagram
);
43 for (sal_Int32 i
= 0; i
< aCTs
.getLength(); ++i
)
45 uno::Reference
<chart2::XChartType
> xThisCT
= aCTs
[i
];
46 if (xThisCT
->getChartType() == "com.sun.star.chart2.GL3DBarChartType")
47 // Found the right chart type.
51 return uno::Reference
<chart2::XChartType
>();
55 WrappedGL3DProperty( const OUString
& rInName
, const OUString
& rOutName
, const uno::Any
& rDefault
, const boost::shared_ptr
<Chart2ModelContact
>& pContact
) :
56 WrappedProperty(rInName
, rOutName
), maDefault(rDefault
), mpModelContact(pContact
) {}
58 virtual ~WrappedGL3DProperty() {}
60 virtual uno::Any
getPropertyValue( const uno::Reference
<beans::XPropertySet
>& /*xInnerPS*/ ) const
61 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
,
62 uno::RuntimeException
) SAL_OVERRIDE
64 uno::Reference
<chart2::XChartType
> xCT
= getChartType();
70 uno::Reference
<beans::XPropertySet
> xPS(xCT
, uno::UNO_QUERY_THROW
);
71 return xPS
->getPropertyValue(CHART_UNONAME_ROUNDED_EDGE
);
73 catch ( const uno::Exception
& ) {}
78 virtual void setPropertyValue(
79 const uno::Any
& rOutValue
, const uno::Reference
<beans::XPropertySet
>& /*xInnerPS*/ ) const
80 throw (beans::UnknownPropertyException
, beans::PropertyVetoException
,
81 lang::IllegalArgumentException
, lang::WrappedTargetException
,
82 uno::RuntimeException
) SAL_OVERRIDE
84 uno::Reference
<chart2::XChartType
> xCT
= getChartType();
90 uno::Reference
<beans::XPropertySet
> xPS(xCT
, uno::UNO_QUERY_THROW
);
91 return xPS
->setPropertyValue(CHART_UNONAME_ROUNDED_EDGE
, rOutValue
);
93 catch ( const uno::Exception
& ) {}
96 virtual void setPropertyToDefault( const uno::Reference
<beans::XPropertyState
>& /*xInnerPropState*/ ) const
97 throw (beans::UnknownPropertyException
, uno::RuntimeException
) SAL_OVERRIDE
99 uno::Reference
<chart2::XChartType
> xCT
= getChartType();
105 uno::Reference
<beans::XPropertySet
> xPS(xCT
, uno::UNO_QUERY_THROW
);
106 return xPS
->setPropertyValue(CHART_UNONAME_ROUNDED_EDGE
, maDefault
);
108 catch ( const uno::Exception
& ) {}
111 virtual uno::Any
getPropertyDefault( const uno::Reference
<beans::XPropertyState
>& /*xInnerPS*/ ) const
112 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
,
113 uno::RuntimeException
) SAL_OVERRIDE
118 virtual beans::PropertyState
getPropertyState( const uno::Reference
<beans::XPropertyState
>& /*xInnerPS*/ ) const
119 throw (beans::UnknownPropertyException
, uno::RuntimeException
) SAL_OVERRIDE
121 return beans::PropertyState_DIRECT_VALUE
;
127 void WrappedGL3DProperties::addProperties( std::vector
<css::beans::Property
> & rOutProps
)
131 CHART_UNONAME_ROUNDED_EDGE
,
132 PROP_GL3DCHARTTYPE_ROUNDED_EDGE
,
133 cppu::UnoType
<bool>::get(),
134 beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEDEFAULT
139 void WrappedGL3DProperties::addWrappedProperties(
140 std::vector
<WrappedProperty
*>& rList
, const boost::shared_ptr
<Chart2ModelContact
>& pChart2ModelContact
)
143 new WrappedGL3DProperty(
144 CHART_UNONAME_ROUNDED_EDGE
, CHART_UNONAME_ROUNDED_EDGE
, uno::makeAny(false), pChart2ModelContact
));
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */