Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "WrappedCharacterHeightProperty.hxx"
21 : #include "macros.hxx"
22 : #include "RelativeSizeHelper.hxx"
23 : #include "ReferenceSizePropertyProvider.hxx"
24 :
25 : using namespace ::com::sun::star;
26 : using ::com::sun::star::uno::Reference;
27 : using ::com::sun::star::uno::Any;
28 :
29 : namespace chart
30 : {
31 : namespace wrapper
32 : {
33 20574 : WrappedCharacterHeightProperty_Base::WrappedCharacterHeightProperty_Base(
34 : const OUString& rOuterEqualsInnerName
35 : , ReferenceSizePropertyProvider* pRefSizePropProvider )
36 : : WrappedProperty( rOuterEqualsInnerName, rOuterEqualsInnerName )
37 20574 : , m_pRefSizePropProvider( pRefSizePropProvider )
38 : {
39 20574 : }
40 20574 : WrappedCharacterHeightProperty_Base::~WrappedCharacterHeightProperty_Base()
41 : {
42 20574 : }
43 :
44 6858 : void WrappedCharacterHeightProperty::addWrappedProperties( std::vector< WrappedProperty* >& rList
45 : , ReferenceSizePropertyProvider* pRefSizePropProvider )
46 : {
47 6858 : rList.push_back( new WrappedCharacterHeightProperty( pRefSizePropProvider ) );
48 6858 : rList.push_back( new WrappedAsianCharacterHeightProperty( pRefSizePropProvider ) );
49 6858 : rList.push_back( new WrappedComplexCharacterHeightProperty( pRefSizePropProvider ) );
50 6858 : }
51 :
52 4334 : void WrappedCharacterHeightProperty_Base::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
53 : throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
54 : {
55 4334 : if(xInnerPropertySet.is())
56 : {
57 4334 : if( m_pRefSizePropProvider )
58 4334 : m_pRefSizePropProvider->updateReferenceSize();
59 4334 : xInnerPropertySet->setPropertyValue( m_aInnerName, rOuterValue );
60 : }
61 4334 : }
62 :
63 31366 : Any WrappedCharacterHeightProperty_Base::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
64 : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
65 : {
66 31366 : Any aRet;
67 31366 : if( xInnerPropertySet.is() )
68 : {
69 31366 : aRet = xInnerPropertySet->getPropertyValue( m_aInnerName );
70 31366 : float fHeight = 0;
71 31366 : if( aRet >>= fHeight )
72 : {
73 31366 : if( m_pRefSizePropProvider )
74 : {
75 31366 : awt::Size aReferenceSize;
76 31366 : if( m_pRefSizePropProvider->getReferenceSize() >>= aReferenceSize )
77 : {
78 0 : awt::Size aCurrentSize = m_pRefSizePropProvider->getCurrentSizeForReference();
79 0 : aRet <<= static_cast< float >(
80 0 : RelativeSizeHelper::calculate( fHeight, aReferenceSize, aCurrentSize ));
81 : }
82 : }
83 : }
84 : }
85 31366 : return aRet;
86 : }
87 :
88 0 : Any WrappedCharacterHeightProperty_Base::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
89 : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
90 : {
91 0 : Any aRet;
92 0 : if( xInnerPropertyState.is() )
93 : {
94 0 : aRet = xInnerPropertyState->getPropertyDefault( m_aInnerName );
95 : }
96 0 : return aRet;
97 : }
98 :
99 19584 : beans::PropertyState WrappedCharacterHeightProperty_Base::getPropertyState( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
100 : throw (beans::UnknownPropertyException, uno::RuntimeException)
101 : {
102 19584 : return beans::PropertyState_DIRECT_VALUE;
103 : }
104 :
105 0 : Any WrappedCharacterHeightProperty_Base::convertInnerToOuterValue( const Any& rInnerValue ) const
106 : {
107 : OSL_FAIL("should not be used: WrappedCharacterHeightProperty_Base::convertInnerToOuterValue - check if you miss data");
108 0 : return rInnerValue;
109 : }
110 0 : Any WrappedCharacterHeightProperty_Base::convertOuterToInnerValue( const Any& rOuterValue ) const
111 : {
112 : OSL_FAIL("should not be used: WrappedCharacterHeightProperty_Base::convertOuterToInnerValue - check if you miss data");
113 0 : return rOuterValue;
114 : }
115 :
116 6858 : WrappedCharacterHeightProperty::WrappedCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider )
117 6858 : : WrappedCharacterHeightProperty_Base( "CharHeight", pRefSizePropProvider )
118 : {
119 6858 : }
120 13716 : WrappedCharacterHeightProperty::~WrappedCharacterHeightProperty()
121 : {
122 13716 : }
123 :
124 6858 : WrappedAsianCharacterHeightProperty::WrappedAsianCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider )
125 6858 : : WrappedCharacterHeightProperty_Base( "CharHeightAsian", pRefSizePropProvider )
126 : {
127 6858 : }
128 13716 : WrappedAsianCharacterHeightProperty::~WrappedAsianCharacterHeightProperty()
129 : {
130 13716 : }
131 :
132 6858 : WrappedComplexCharacterHeightProperty::WrappedComplexCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider )
133 6858 : : WrappedCharacterHeightProperty_Base( "CharHeightComplex", pRefSizePropProvider )
134 : {
135 6858 : }
136 13716 : WrappedComplexCharacterHeightProperty::~WrappedComplexCharacterHeightProperty()
137 : {
138 13716 : }
139 :
140 : } //namespace wrapper
141 : } //namespace chart
142 :
143 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|