1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_chart2.hxx" 26 27 #include "WrappedCharacterHeightProperty.hxx" 28 #include "macros.hxx" 29 #include "RelativeSizeHelper.hxx" 30 #include "ReferenceSizePropertyProvider.hxx" 31 32 // header for define DBG_ASSERT 33 #include <tools/debug.hxx> 34 35 using namespace ::com::sun::star; 36 using ::com::sun::star::uno::Reference; 37 using ::com::sun::star::uno::Any; 38 using ::rtl::OUString; 39 40 //............................................................................. 41 //............................................................................. 42 43 //............................................................................. 44 //............................................................................. 45 46 namespace chart 47 { 48 namespace wrapper 49 { 50 WrappedCharacterHeightProperty_Base::WrappedCharacterHeightProperty_Base( 51 const OUString& rOuterEqualsInnerName 52 , ReferenceSizePropertyProvider* pRefSizePropProvider ) 53 : WrappedProperty( rOuterEqualsInnerName, rOuterEqualsInnerName ) 54 , m_pRefSizePropProvider( pRefSizePropProvider ) 55 { 56 } 57 WrappedCharacterHeightProperty_Base::~WrappedCharacterHeightProperty_Base() 58 { 59 } 60 61 void WrappedCharacterHeightProperty::addWrappedProperties( std::vector< WrappedProperty* >& rList 62 , ReferenceSizePropertyProvider* pRefSizePropProvider ) 63 { 64 rList.push_back( new WrappedCharacterHeightProperty( pRefSizePropProvider ) ); 65 rList.push_back( new WrappedAsianCharacterHeightProperty( pRefSizePropProvider ) ); 66 rList.push_back( new WrappedComplexCharacterHeightProperty( pRefSizePropProvider ) ); 67 } 68 69 void WrappedCharacterHeightProperty_Base::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const 70 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 71 { 72 if(xInnerPropertySet.is()) 73 { 74 if( m_pRefSizePropProvider ) 75 m_pRefSizePropProvider->updateReferenceSize(); 76 xInnerPropertySet->setPropertyValue( m_aInnerName, rOuterValue ); 77 } 78 } 79 80 Any WrappedCharacterHeightProperty_Base::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const 81 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 82 { 83 Any aRet; 84 if( xInnerPropertySet.is() ) 85 { 86 aRet = xInnerPropertySet->getPropertyValue( m_aInnerName ); 87 float fHeight = 0; 88 if( aRet >>= fHeight ) 89 { 90 if( m_pRefSizePropProvider ) 91 { 92 awt::Size aReferenceSize; 93 if( m_pRefSizePropProvider->getReferenceSize() >>= aReferenceSize ) 94 { 95 awt::Size aCurrentSize = m_pRefSizePropProvider->getCurrentSizeForReference(); 96 aRet <<= static_cast< float >( 97 RelativeSizeHelper::calculate( fHeight, aReferenceSize, aCurrentSize )); 98 } 99 } 100 } 101 } 102 return aRet; 103 } 104 105 Any WrappedCharacterHeightProperty_Base::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const 106 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 107 { 108 Any aRet; 109 if( xInnerPropertyState.is() ) 110 { 111 aRet = xInnerPropertyState->getPropertyDefault( m_aInnerName ); 112 } 113 return aRet; 114 } 115 116 beans::PropertyState WrappedCharacterHeightProperty_Base::getPropertyState( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const 117 throw (beans::UnknownPropertyException, uno::RuntimeException) 118 { 119 return beans::PropertyState_DIRECT_VALUE; 120 } 121 122 Any WrappedCharacterHeightProperty_Base::convertInnerToOuterValue( const Any& rInnerValue ) const 123 { 124 OSL_ASSERT("should not be used: WrappedCharacterHeightProperty_Base::convertInnerToOuterValue - check if you miss data"); 125 return rInnerValue; 126 } 127 Any WrappedCharacterHeightProperty_Base::convertOuterToInnerValue( const Any& rOuterValue ) const 128 { 129 OSL_ASSERT("should not be used: WrappedCharacterHeightProperty_Base::convertOuterToInnerValue - check if you miss data"); 130 return rOuterValue; 131 } 132 133 //----------------------------------------------------------------------------- 134 //----------------------------------------------------------------------------- 135 //----------------------------------------------------------------------------- 136 137 WrappedCharacterHeightProperty::WrappedCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider ) 138 : WrappedCharacterHeightProperty_Base( C2U( "CharHeight" ), pRefSizePropProvider ) 139 { 140 } 141 WrappedCharacterHeightProperty::~WrappedCharacterHeightProperty() 142 { 143 } 144 145 //----------------------------------------------------------------------------- 146 147 WrappedAsianCharacterHeightProperty::WrappedAsianCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider ) 148 : WrappedCharacterHeightProperty_Base( C2U( "CharHeightAsian" ), pRefSizePropProvider ) 149 { 150 } 151 WrappedAsianCharacterHeightProperty::~WrappedAsianCharacterHeightProperty() 152 { 153 } 154 155 //----------------------------------------------------------------------------- 156 157 WrappedComplexCharacterHeightProperty::WrappedComplexCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider ) 158 : WrappedCharacterHeightProperty_Base( C2U( "CharHeightComplex" ), pRefSizePropProvider ) 159 { 160 } 161 WrappedComplexCharacterHeightProperty::~WrappedComplexCharacterHeightProperty() 162 { 163 } 164 165 } //namespace wrapper 166 } //namespace chart 167 //............................................................................. 168