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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "WrappedAutomaticPositionProperties.hxx"
21 #include <FastPropertyIdRanges.hxx>
22 #include <WrappedProperty.hxx>
23 #include <com/sun/star/beans/PropertyAttribute.hpp>
24 #include <com/sun/star/beans/XPropertyState.hpp>
25 #include <com/sun/star/beans/XPropertySet.hpp>
26 #include <tools/diagnose_ex.h>
28 using namespace ::com::sun::star
;
29 using ::com::sun::star::uno::Any
;
30 using ::com::sun::star::uno::Reference
;
31 using ::com::sun::star::beans::Property
;
38 class WrappedAutomaticPositionProperty
: public WrappedProperty
41 WrappedAutomaticPositionProperty();
43 virtual void setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const override
;
44 virtual Any
getPropertyValue( const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const override
;
45 virtual Any
getPropertyDefault( const Reference
< beans::XPropertyState
>& xInnerPropertyState
) const override
;
48 WrappedAutomaticPositionProperty::WrappedAutomaticPositionProperty()
49 : ::chart::WrappedProperty( "AutomaticPosition" , OUString() )
53 void WrappedAutomaticPositionProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
55 if( xInnerPropertySet
.is() )
57 bool bNewValue
= true;
58 if( ! (rOuterValue
>>= bNewValue
) )
59 throw lang::IllegalArgumentException( "Property AutomaticPosition requires value of type boolean", nullptr, 0 );
65 Any
aRelativePosition( xInnerPropertySet
->getPropertyValue( "RelativePosition" ) );
66 if( aRelativePosition
.hasValue() )
67 xInnerPropertySet
->setPropertyValue( "RelativePosition", Any() );
70 catch( const uno::Exception
& )
72 DBG_UNHANDLED_EXCEPTION("chart2");
77 Any
WrappedAutomaticPositionProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
79 Any
aRet( getPropertyDefault( Reference
< beans::XPropertyState
>( xInnerPropertySet
, uno::UNO_QUERY
) ) );
80 if( xInnerPropertySet
.is() )
82 Any
aRelativePosition( xInnerPropertySet
->getPropertyValue( "RelativePosition" ) );
83 if( !aRelativePosition
.hasValue() )
89 Any
WrappedAutomaticPositionProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
100 PROP_CHART_AUTOMATIC_POSITION
= FAST_PROPERTY_ID_START_CHART_AUTOPOSITION_PROP
103 }//anonymous namespace
105 void WrappedAutomaticPositionProperties::addProperties( std::vector
< Property
> & rOutProperties
)
107 rOutProperties
.emplace_back( "AutomaticPosition",
108 PROP_CHART_AUTOMATIC_POSITION
,
109 cppu::UnoType
<bool>::get(),
110 beans::PropertyAttribute::BOUND
111 | beans::PropertyAttribute::MAYBEDEFAULT
);
114 void WrappedAutomaticPositionProperties::addWrappedProperties( std::vector
< std::unique_ptr
<WrappedProperty
> >& rList
)
116 rList
.emplace_back( new WrappedAutomaticPositionProperty() );
119 } //namespace wrapper
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */