1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
30 
31 #include "WrappedCharacterHeightProperty.hxx"
32 #include "macros.hxx"
33 #include "RelativeSizeHelper.hxx"
34 #include "ReferenceSizePropertyProvider.hxx"
35 
36 // header for define DBG_ASSERT
37 #include <tools/debug.hxx>
38 
39 using namespace ::com::sun::star;
40 using ::com::sun::star::uno::Reference;
41 using ::com::sun::star::uno::Any;
42 using ::rtl::OUString;
43 
44 //.............................................................................
45 //.............................................................................
46 
47 //.............................................................................
48 //.............................................................................
49 
50 namespace chart
51 {
52 namespace wrapper
53 {
54 WrappedCharacterHeightProperty_Base::WrappedCharacterHeightProperty_Base(
55                             const OUString& rOuterEqualsInnerName
56                             , ReferenceSizePropertyProvider* pRefSizePropProvider )
57                             : WrappedProperty( rOuterEqualsInnerName, rOuterEqualsInnerName )
58                            , m_pRefSizePropProvider( pRefSizePropProvider )
59 {
60 }
61 WrappedCharacterHeightProperty_Base::~WrappedCharacterHeightProperty_Base()
62 {
63 }
64 
65 void WrappedCharacterHeightProperty::addWrappedProperties( std::vector< WrappedProperty* >& rList
66             , ReferenceSizePropertyProvider* pRefSizePropProvider  )
67 {
68     rList.push_back( new WrappedCharacterHeightProperty( pRefSizePropProvider ) );
69     rList.push_back( new WrappedAsianCharacterHeightProperty( pRefSizePropProvider ) );
70     rList.push_back( new WrappedComplexCharacterHeightProperty( pRefSizePropProvider ) );
71 }
72 
73 void WrappedCharacterHeightProperty_Base::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
74                 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
75 {
76     if(xInnerPropertySet.is())
77     {
78         if( m_pRefSizePropProvider )
79             m_pRefSizePropProvider->updateReferenceSize();
80         xInnerPropertySet->setPropertyValue( m_aInnerName, rOuterValue );
81     }
82 }
83 
84 Any WrappedCharacterHeightProperty_Base::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
85                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
86 {
87     Any aRet;
88     if( xInnerPropertySet.is() )
89     {
90         aRet = xInnerPropertySet->getPropertyValue( m_aInnerName );
91         float fHeight = 0;
92         if( aRet >>= fHeight )
93         {
94             if( m_pRefSizePropProvider )
95             {
96                 awt::Size aReferenceSize;
97                 if( m_pRefSizePropProvider->getReferenceSize() >>= aReferenceSize )
98                 {
99                     awt::Size aCurrentSize = m_pRefSizePropProvider->getCurrentSizeForReference();
100                     aRet <<= static_cast< float >(
101                             RelativeSizeHelper::calculate( fHeight, aReferenceSize, aCurrentSize ));
102                 }
103             }
104         }
105     }
106     return aRet;
107 }
108 
109 Any WrappedCharacterHeightProperty_Base::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
110                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
111 {
112     Any aRet;
113     if( xInnerPropertyState.is() )
114     {
115         aRet = xInnerPropertyState->getPropertyDefault( m_aInnerName );
116     }
117     return aRet;
118 }
119 
120 beans::PropertyState WrappedCharacterHeightProperty_Base::getPropertyState( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
121                         throw (beans::UnknownPropertyException, uno::RuntimeException)
122 {
123     return beans::PropertyState_DIRECT_VALUE;
124 }
125 
126 Any WrappedCharacterHeightProperty_Base::convertInnerToOuterValue( const Any& rInnerValue ) const
127 {
128     OSL_ASSERT("should not be used: WrappedCharacterHeightProperty_Base::convertInnerToOuterValue - check if you miss data");
129     return rInnerValue;
130 }
131 Any WrappedCharacterHeightProperty_Base::convertOuterToInnerValue( const Any& rOuterValue ) const
132 {
133     OSL_ASSERT("should not be used: WrappedCharacterHeightProperty_Base::convertOuterToInnerValue - check if you miss data");
134     return rOuterValue;
135 }
136 
137 //-----------------------------------------------------------------------------
138 //-----------------------------------------------------------------------------
139 //-----------------------------------------------------------------------------
140 
141 WrappedCharacterHeightProperty::WrappedCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider )
142         : WrappedCharacterHeightProperty_Base( C2U( "CharHeight" ), pRefSizePropProvider )
143 {
144 }
145 WrappedCharacterHeightProperty::~WrappedCharacterHeightProperty()
146 {
147 }
148 
149 //-----------------------------------------------------------------------------
150 
151 WrappedAsianCharacterHeightProperty::WrappedAsianCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider )
152         : WrappedCharacterHeightProperty_Base( C2U( "CharHeightAsian" ), pRefSizePropProvider )
153 {
154 }
155 WrappedAsianCharacterHeightProperty::~WrappedAsianCharacterHeightProperty()
156 {
157 }
158 
159 //-----------------------------------------------------------------------------
160 
161 WrappedComplexCharacterHeightProperty::WrappedComplexCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider )
162         : WrappedCharacterHeightProperty_Base( C2U( "CharHeightComplex" ), pRefSizePropProvider )
163 {
164 }
165 WrappedComplexCharacterHeightProperty::~WrappedComplexCharacterHeightProperty()
166 {
167 }
168 
169 } //namespace wrapper
170 } //namespace chart
171 //.............................................................................
172