Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "WrappedScaleTextProperties.hxx"
21 : #include "FastPropertyIdRanges.hxx"
22 : #include "macros.hxx"
23 :
24 : #include <com/sun/star/beans/PropertyAttribute.hpp>
25 :
26 : using namespace ::com::sun::star;
27 : using ::com::sun::star::uno::Any;
28 : using ::com::sun::star::uno::Reference;
29 : using ::com::sun::star::uno::Sequence;
30 : using ::com::sun::star::beans::Property;
31 :
32 : namespace chart
33 : {
34 : namespace wrapper
35 : {
36 :
37 : class WrappedScaleTextProperty : public WrappedProperty
38 : {
39 : public:
40 : WrappedScaleTextProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact );
41 : virtual ~WrappedScaleTextProperty();
42 :
43 : virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
44 : throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) SAL_OVERRIDE;
45 : virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
46 : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) SAL_OVERRIDE;
47 : virtual Any getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
48 : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) SAL_OVERRIDE;
49 :
50 : private:
51 : ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
52 : };
53 :
54 0 : WrappedScaleTextProperty::WrappedScaleTextProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
55 : : ::chart::WrappedProperty( "ScaleText" , OUString() )
56 0 : , m_spChart2ModelContact( spChart2ModelContact )
57 : {
58 0 : }
59 :
60 0 : WrappedScaleTextProperty::~WrappedScaleTextProperty()
61 : {
62 0 : }
63 :
64 0 : void WrappedScaleTextProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
65 : throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
66 : {
67 0 : static const OUString aRefSizeName( "ReferencePageSize" );
68 :
69 0 : if( xInnerPropertySet.is() )
70 : {
71 0 : bool bNewValue = false;
72 0 : if( ! (rOuterValue >>= bNewValue) )
73 : {
74 0 : if( rOuterValue.hasValue() )
75 0 : throw lang::IllegalArgumentException( "Property ScaleText requires value of type boolean", 0, 0 );
76 : }
77 :
78 : try
79 : {
80 0 : if( bNewValue )
81 : {
82 0 : awt::Size aRefSize( m_spChart2ModelContact->GetPageSize() );
83 0 : xInnerPropertySet->setPropertyValue( aRefSizeName, uno::makeAny( aRefSize ) );
84 : }
85 : else
86 0 : xInnerPropertySet->setPropertyValue( aRefSizeName, Any() );
87 : }
88 0 : catch( const uno::Exception & ex )
89 : {
90 : ASSERT_EXCEPTION( ex );
91 : }
92 : }
93 0 : }
94 :
95 0 : Any WrappedScaleTextProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
96 : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
97 : {
98 0 : static const OUString aRefSizeName( "ReferencePageSize" );
99 :
100 0 : Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) );
101 0 : if( xInnerPropertySet.is() )
102 : {
103 0 : if( xInnerPropertySet->getPropertyValue( aRefSizeName ).hasValue() )
104 0 : aRet <<= true;
105 : else
106 0 : aRet <<= false;
107 : }
108 :
109 0 : return aRet;
110 : }
111 :
112 0 : Any WrappedScaleTextProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
113 : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
114 : {
115 0 : Any aRet;
116 0 : aRet <<= false;
117 0 : return aRet;
118 : }
119 :
120 : namespace
121 : {
122 : enum
123 : {
124 : PROP_CHART_SCALE_TEXT = FAST_PROPERTY_ID_START_SCALE_TEXT_PROP
125 : };
126 :
127 : }//anonymous namespace
128 :
129 0 : void WrappedScaleTextProperties::addProperties( ::std::vector< Property > & rOutProperties )
130 : {
131 : rOutProperties.push_back(
132 : Property( "ScaleText",
133 : PROP_CHART_SCALE_TEXT,
134 0 : ::getBooleanCppuType(),
135 : beans::PropertyAttribute::MAYBEVOID
136 0 : | beans::PropertyAttribute::MAYBEDEFAULT ));
137 0 : }
138 :
139 0 : void WrappedScaleTextProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList
140 : , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
141 : {
142 0 : rList.push_back( new WrappedScaleTextProperty( spChart2ModelContact ) );
143 0 : }
144 :
145 : } //namespace wrapper
146 : } //namespace chart
147 :
148 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|