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