1*cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*cde9e8dcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*cde9e8dcSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*cde9e8dcSAndrew Rist * distributed with this work for additional information
6*cde9e8dcSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*cde9e8dcSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*cde9e8dcSAndrew Rist * "License"); you may not use this file except in compliance
9*cde9e8dcSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*cde9e8dcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*cde9e8dcSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*cde9e8dcSAndrew Rist * software distributed under the License is distributed on an
15*cde9e8dcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*cde9e8dcSAndrew Rist * KIND, either express or implied. See the License for the
17*cde9e8dcSAndrew Rist * specific language governing permissions and limitations
18*cde9e8dcSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*cde9e8dcSAndrew Rist *************************************************************/
21*cde9e8dcSAndrew Rist
22*cde9e8dcSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #include "precompiled_chart2.hxx"
25cdf0e10cSrcweir
26cdf0e10cSrcweir #include "WrappedAutomaticPositionProperties.hxx"
27cdf0e10cSrcweir #include "FastPropertyIdRanges.hxx"
28cdf0e10cSrcweir #include "macros.hxx"
29cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
30cdf0e10cSrcweir #include <com/sun/star/chart2/RelativePosition.hpp>
31cdf0e10cSrcweir
32cdf0e10cSrcweir using namespace ::com::sun::star;
33cdf0e10cSrcweir using ::com::sun::star::uno::Any;
34cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
35cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
36cdf0e10cSrcweir using ::com::sun::star::beans::Property;
37cdf0e10cSrcweir using ::rtl::OUString;
38cdf0e10cSrcweir
39cdf0e10cSrcweir //.............................................................................
40cdf0e10cSrcweir namespace chart
41cdf0e10cSrcweir {
42cdf0e10cSrcweir namespace wrapper
43cdf0e10cSrcweir {
44cdf0e10cSrcweir
45cdf0e10cSrcweir class WrappedAutomaticPositionProperty : public WrappedProperty
46cdf0e10cSrcweir {
47cdf0e10cSrcweir public:
48cdf0e10cSrcweir WrappedAutomaticPositionProperty();
49cdf0e10cSrcweir virtual ~WrappedAutomaticPositionProperty();
50cdf0e10cSrcweir
51cdf0e10cSrcweir virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
52cdf0e10cSrcweir throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException);
53cdf0e10cSrcweir virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
54cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
55cdf0e10cSrcweir virtual Any getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
56cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
57cdf0e10cSrcweir };
58cdf0e10cSrcweir
WrappedAutomaticPositionProperty()59cdf0e10cSrcweir WrappedAutomaticPositionProperty::WrappedAutomaticPositionProperty()
60cdf0e10cSrcweir : ::chart::WrappedProperty( C2U( "AutomaticPosition" ), rtl::OUString() )
61cdf0e10cSrcweir {
62cdf0e10cSrcweir }
~WrappedAutomaticPositionProperty()63cdf0e10cSrcweir WrappedAutomaticPositionProperty::~WrappedAutomaticPositionProperty()
64cdf0e10cSrcweir {
65cdf0e10cSrcweir }
66cdf0e10cSrcweir
setPropertyValue(const Any & rOuterValue,const Reference<beans::XPropertySet> & xInnerPropertySet) const67cdf0e10cSrcweir void WrappedAutomaticPositionProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
68cdf0e10cSrcweir throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
69cdf0e10cSrcweir {
70cdf0e10cSrcweir if( xInnerPropertySet.is() )
71cdf0e10cSrcweir {
72cdf0e10cSrcweir bool bNewValue = true;
73cdf0e10cSrcweir if( ! (rOuterValue >>= bNewValue) )
74cdf0e10cSrcweir throw lang::IllegalArgumentException( C2U("Property AutomaticPosition requires value of type boolean"), 0, 0 );
75cdf0e10cSrcweir
76cdf0e10cSrcweir try
77cdf0e10cSrcweir {
78cdf0e10cSrcweir if( bNewValue )
79cdf0e10cSrcweir {
80cdf0e10cSrcweir Any aRelativePosition( xInnerPropertySet->getPropertyValue( C2U( "RelativePosition" ) ) );
81cdf0e10cSrcweir if( aRelativePosition.hasValue() )
82cdf0e10cSrcweir xInnerPropertySet->setPropertyValue( C2U( "RelativePosition" ), Any() );
83cdf0e10cSrcweir }
84cdf0e10cSrcweir }
85cdf0e10cSrcweir catch( uno::Exception & ex )
86cdf0e10cSrcweir {
87cdf0e10cSrcweir ASSERT_EXCEPTION( ex );
88cdf0e10cSrcweir }
89cdf0e10cSrcweir }
90cdf0e10cSrcweir }
91cdf0e10cSrcweir
getPropertyValue(const Reference<beans::XPropertySet> & xInnerPropertySet) const92cdf0e10cSrcweir Any WrappedAutomaticPositionProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
93cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
94cdf0e10cSrcweir {
95cdf0e10cSrcweir Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) );
96cdf0e10cSrcweir if( xInnerPropertySet.is() )
97cdf0e10cSrcweir {
98cdf0e10cSrcweir Any aRelativePosition( xInnerPropertySet->getPropertyValue( C2U( "RelativePosition" ) ) );
99cdf0e10cSrcweir if( !aRelativePosition.hasValue() )
100cdf0e10cSrcweir aRet <<= true;
101cdf0e10cSrcweir }
102cdf0e10cSrcweir return aRet;
103cdf0e10cSrcweir }
104cdf0e10cSrcweir
getPropertyDefault(const Reference<beans::XPropertyState> &) const105cdf0e10cSrcweir Any WrappedAutomaticPositionProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
106cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
107cdf0e10cSrcweir {
108cdf0e10cSrcweir Any aRet;
109cdf0e10cSrcweir aRet <<= false;
110cdf0e10cSrcweir return aRet;
111cdf0e10cSrcweir }
112cdf0e10cSrcweir
113cdf0e10cSrcweir namespace
114cdf0e10cSrcweir {
115cdf0e10cSrcweir enum
116cdf0e10cSrcweir {
117cdf0e10cSrcweir PROP_CHART_AUTOMATIC_POSITION = FAST_PROPERTY_ID_START_CHART_AUTOPOSITION_PROP
118cdf0e10cSrcweir };
119cdf0e10cSrcweir
lcl_addWrappedProperties(std::vector<WrappedProperty * > & rList)120cdf0e10cSrcweir void lcl_addWrappedProperties( std::vector< WrappedProperty* >& rList )
121cdf0e10cSrcweir {
122cdf0e10cSrcweir rList.push_back( new WrappedAutomaticPositionProperty() );
123cdf0e10cSrcweir }
124cdf0e10cSrcweir
125cdf0e10cSrcweir }//anonymous namespace
126cdf0e10cSrcweir
127cdf0e10cSrcweir //-----------------------------------------------------------------------------
128cdf0e10cSrcweir //-----------------------------------------------------------------------------
129cdf0e10cSrcweir //-----------------------------------------------------------------------------
addProperties(::std::vector<Property> & rOutProperties)130cdf0e10cSrcweir void WrappedAutomaticPositionProperties::addProperties( ::std::vector< Property > & rOutProperties )
131cdf0e10cSrcweir {
132cdf0e10cSrcweir rOutProperties.push_back(
133cdf0e10cSrcweir Property( C2U( "AutomaticPosition" ),
134cdf0e10cSrcweir PROP_CHART_AUTOMATIC_POSITION,
135cdf0e10cSrcweir ::getBooleanCppuType(),
136cdf0e10cSrcweir beans::PropertyAttribute::BOUND
137cdf0e10cSrcweir | beans::PropertyAttribute::MAYBEDEFAULT ));
138cdf0e10cSrcweir }
139cdf0e10cSrcweir
140cdf0e10cSrcweir //-----------------------------------------------------------------------------
141cdf0e10cSrcweir //-----------------------------------------------------------------------------
142cdf0e10cSrcweir
addWrappedProperties(std::vector<WrappedProperty * > & rList)143cdf0e10cSrcweir void WrappedAutomaticPositionProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList )
144cdf0e10cSrcweir {
145cdf0e10cSrcweir lcl_addWrappedProperties( rList );
146cdf0e10cSrcweir }
147cdf0e10cSrcweir
148cdf0e10cSrcweir } //namespace wrapper
149cdf0e10cSrcweir } //namespace chart
150cdf0e10cSrcweir //.............................................................................
151