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_chartcontroller.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 { 71 if(xInnerPropertySet.is()) 72 { 73 if( m_pRefSizePropProvider ) 74 m_pRefSizePropProvider->updateReferenceSize(); 75 xInnerPropertySet->setPropertyValue( m_aInnerName, rOuterValue ); 76 } 77 } 78 79 Any WrappedCharacterHeightProperty_Base::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const 80 { 81 Any aRet; 82 if( xInnerPropertySet.is() ) 83 { 84 aRet = xInnerPropertySet->getPropertyValue( m_aInnerName ); 85 float fHeight = 0; 86 if( aRet >>= fHeight ) 87 { 88 if( m_pRefSizePropProvider ) 89 { 90 awt::Size aReferenceSize; 91 if( m_pRefSizePropProvider->getReferenceSize() >>= aReferenceSize ) 92 { 93 awt::Size aCurrentSize = m_pRefSizePropProvider->getCurrentSizeForReference(); 94 aRet <<= static_cast< float >( 95 RelativeSizeHelper::calculate( fHeight, aReferenceSize, aCurrentSize )); 96 } 97 } 98 } 99 } 100 return aRet; 101 } 102 103 Any WrappedCharacterHeightProperty_Base::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const 104 { 105 Any aRet; 106 if( xInnerPropertyState.is() ) 107 { 108 aRet = xInnerPropertyState->getPropertyDefault( m_aInnerName ); 109 } 110 return aRet; 111 } 112 113 beans::PropertyState WrappedCharacterHeightProperty_Base::getPropertyState( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const 114 { 115 return beans::PropertyState_DIRECT_VALUE; 116 } 117 118 Any WrappedCharacterHeightProperty_Base::convertInnerToOuterValue( const Any& rInnerValue ) const 119 { 120 OSL_ASSERT("should not be used: WrappedCharacterHeightProperty_Base::convertInnerToOuterValue - check if you miss data"); 121 return rInnerValue; 122 } 123 Any WrappedCharacterHeightProperty_Base::convertOuterToInnerValue( const Any& rOuterValue ) const 124 { 125 OSL_ASSERT("should not be used: WrappedCharacterHeightProperty_Base::convertOuterToInnerValue - check if you miss data"); 126 return rOuterValue; 127 } 128 129 //----------------------------------------------------------------------------- 130 //----------------------------------------------------------------------------- 131 //----------------------------------------------------------------------------- 132 133 WrappedCharacterHeightProperty::WrappedCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider ) 134 : WrappedCharacterHeightProperty_Base( C2U( "CharHeight" ), pRefSizePropProvider ) 135 { 136 } 137 WrappedCharacterHeightProperty::~WrappedCharacterHeightProperty() 138 { 139 } 140 141 //----------------------------------------------------------------------------- 142 143 WrappedAsianCharacterHeightProperty::WrappedAsianCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider ) 144 : WrappedCharacterHeightProperty_Base( C2U( "CharHeightAsian" ), pRefSizePropProvider ) 145 { 146 } 147 WrappedAsianCharacterHeightProperty::~WrappedAsianCharacterHeightProperty() 148 { 149 } 150 151 //----------------------------------------------------------------------------- 152 153 WrappedComplexCharacterHeightProperty::WrappedComplexCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider ) 154 : WrappedCharacterHeightProperty_Base( C2U( "CharHeightComplex" ), pRefSizePropProvider ) 155 { 156 } 157 WrappedComplexCharacterHeightProperty::~WrappedComplexCharacterHeightProperty() 158 { 159 } 160 161 } //namespace wrapper 162 } //namespace chart 163 //............................................................................. 164