1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: WrappedCharacterHeightProperty.cxx,v $
10 * $Revision: 1.5.44.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
34 #include "WrappedCharacterHeightProperty.hxx"
36 #include "RelativeSizeHelper.hxx"
37 #include "ReferenceSizePropertyProvider.hxx"
39 // header for define DBG_ASSERT
40 #include <tools/debug.hxx>
42 using namespace ::com::sun::star
;
43 using ::com::sun::star::uno::Reference
;
44 using ::com::sun::star::uno::Any
;
45 using ::rtl::OUString
;
47 //.............................................................................
48 //.............................................................................
50 //.............................................................................
51 //.............................................................................
57 WrappedCharacterHeightProperty_Base::WrappedCharacterHeightProperty_Base(
58 const OUString
& rOuterEqualsInnerName
59 , ReferenceSizePropertyProvider
* pRefSizePropProvider
)
60 : WrappedProperty( rOuterEqualsInnerName
, rOuterEqualsInnerName
)
61 , m_pRefSizePropProvider( pRefSizePropProvider
)
64 WrappedCharacterHeightProperty_Base::~WrappedCharacterHeightProperty_Base()
69 void WrappedCharacterHeightProperty::addWrappedProperties( std::vector
< WrappedProperty
* >& rList
70 , ReferenceSizePropertyProvider
* pRefSizePropProvider
)
72 rList
.push_back( new WrappedCharacterHeightProperty( pRefSizePropProvider
) );
73 rList
.push_back( new WrappedAsianCharacterHeightProperty( pRefSizePropProvider
) );
74 rList
.push_back( new WrappedComplexCharacterHeightProperty( pRefSizePropProvider
) );
77 void WrappedCharacterHeightProperty_Base::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
78 throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
80 if(xInnerPropertySet
.is())
82 if( m_pRefSizePropProvider
)
83 m_pRefSizePropProvider
->updateReferenceSize();
84 xInnerPropertySet
->setPropertyValue( m_aInnerName
, rOuterValue
);
88 Any
WrappedCharacterHeightProperty_Base::getPropertyValue( const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
89 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
92 if( xInnerPropertySet
.is() )
94 aRet
= xInnerPropertySet
->getPropertyValue( m_aInnerName
);
96 if( aRet
>>= fHeight
)
98 if( m_pRefSizePropProvider
)
100 awt::Size aReferenceSize
;
101 if( m_pRefSizePropProvider
->getReferenceSize() >>= aReferenceSize
)
103 awt::Size aCurrentSize
= m_pRefSizePropProvider
->getCurrentSizeForReference();
104 aRet
<<= static_cast< float >(
105 RelativeSizeHelper::calculate( fHeight
, aReferenceSize
, aCurrentSize
));
113 Any
WrappedCharacterHeightProperty_Base::getPropertyDefault( const Reference
< beans::XPropertyState
>& xInnerPropertyState
) const
114 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
117 if( xInnerPropertyState
.is() )
119 aRet
= xInnerPropertyState
->getPropertyDefault( m_aInnerName
);
124 beans::PropertyState
WrappedCharacterHeightProperty_Base::getPropertyState( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
125 throw (beans::UnknownPropertyException
, uno::RuntimeException
)
127 return beans::PropertyState_DIRECT_VALUE
;
130 Any
WrappedCharacterHeightProperty_Base::convertInnerToOuterValue( const Any
& rInnerValue
) const
132 OSL_ASSERT("should not be used: WrappedCharacterHeightProperty_Base::convertInnerToOuterValue - check if you miss data");
135 Any
WrappedCharacterHeightProperty_Base::convertOuterToInnerValue( const Any
& rOuterValue
) const
137 OSL_ASSERT("should not be used: WrappedCharacterHeightProperty_Base::convertOuterToInnerValue - check if you miss data");
141 //-----------------------------------------------------------------------------
142 //-----------------------------------------------------------------------------
143 //-----------------------------------------------------------------------------
145 WrappedCharacterHeightProperty::WrappedCharacterHeightProperty( ReferenceSizePropertyProvider
* pRefSizePropProvider
)
146 : WrappedCharacterHeightProperty_Base( C2U( "CharHeight" ), pRefSizePropProvider
)
149 WrappedCharacterHeightProperty::~WrappedCharacterHeightProperty()
153 //-----------------------------------------------------------------------------
155 WrappedAsianCharacterHeightProperty::WrappedAsianCharacterHeightProperty( ReferenceSizePropertyProvider
* pRefSizePropProvider
)
156 : WrappedCharacterHeightProperty_Base( C2U( "CharHeightAsian" ), pRefSizePropProvider
)
159 WrappedAsianCharacterHeightProperty::~WrappedAsianCharacterHeightProperty()
163 //-----------------------------------------------------------------------------
165 WrappedComplexCharacterHeightProperty::WrappedComplexCharacterHeightProperty( ReferenceSizePropertyProvider
* pRefSizePropProvider
)
166 : WrappedCharacterHeightProperty_Base( C2U( "CharHeightComplex" ), pRefSizePropProvider
)
169 WrappedComplexCharacterHeightProperty::~WrappedComplexCharacterHeightProperty()
173 } //namespace wrapper
175 //.............................................................................