Debian Codegraph @

chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.cxx

raw
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 <RelativeSizeHelper.hxx>
22 #include "ReferenceSizePropertyProvider.hxx"
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/beans/XPropertyState.hpp>
25 #include <osl/diagnose.h>
26
27 using namespace ::com::sun::star;
28 using ::com::sun::star::uno::Reference;
29 using ::com::sun::star::uno::Any;
30
31 namespace chart::wrapper
32 {
33 WrappedCharacterHeightProperty_Base::WrappedCharacterHeightProperty_Base(
34 const OUString& rOuterEqualsInnerName
35 , ReferenceSizePropertyProvider* pRefSizePropProvider )
36 : WrappedProperty( rOuterEqualsInnerName, rOuterEqualsInnerName )
37 , m_pRefSizePropProvider( pRefSizePropProvider )
38 {
39 }
40 WrappedCharacterHeightProperty_Base::~WrappedCharacterHeightProperty_Base()
41 {
42 }
43
44 void WrappedCharacterHeightProperty::addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
45 , ReferenceSizePropertyProvider* pRefSizePropProvider )
46 {
47 rList.emplace_back( new WrappedCharacterHeightProperty( pRefSizePropProvider ) );
48 rList.emplace_back( new WrappedAsianCharacterHeightProperty( pRefSizePropProvider ) );
49 rList.emplace_back( new WrappedComplexCharacterHeightProperty( pRefSizePropProvider ) );
50 }
51
52 void WrappedCharacterHeightProperty_Base::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
53 {
54 if(xInnerPropertySet.is())
55 {
56 if( m_pRefSizePropProvider )
57 m_pRefSizePropProvider->updateReferenceSize();
58 xInnerPropertySet->setPropertyValue( m_aInnerName, rOuterValue );
59 }
60 }
61
62 Any WrappedCharacterHeightProperty_Base::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
63 {
64 Any aRet;
65 if( xInnerPropertySet.is() )
66 {
67 aRet = xInnerPropertySet->getPropertyValue( m_aInnerName );
68 float fHeight = 0;
69 if( aRet >>= fHeight )
70 {
71 if( m_pRefSizePropProvider )
72 {
73 awt::Size aReferenceSize;
74 if( m_pRefSizePropProvider->getReferenceSize() >>= aReferenceSize )
75 {
76 awt::Size aCurrentSize = m_pRefSizePropProvider->getCurrentSizeForReference();
77 aRet <<= static_cast< float >(
78 RelativeSizeHelper::calculate( fHeight, aReferenceSize, aCurrentSize ));
79 }
80 }
81 }
82 }
83 return aRet;
84 }
85
86 Any WrappedCharacterHeightProperty_Base::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
87 {
88 Any aRet;
89 if( xInnerPropertyState.is() )
90 {
91 aRet = xInnerPropertyState->getPropertyDefault( m_aInnerName );
92 }
93 return aRet;
94 }
95
96 beans::PropertyState WrappedCharacterHeightProperty_Base::getPropertyState( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
97 {
98 return beans::PropertyState_DIRECT_VALUE;
99 }
100
101 Any WrappedCharacterHeightProperty_Base::convertInnerToOuterValue( const Any& rInnerValue ) const
102 {
103 OSL_FAIL("should not be used: WrappedCharacterHeightProperty_Base::convertInnerToOuterValue - check if you miss data");
104 return rInnerValue;
105 }
106 Any WrappedCharacterHeightProperty_Base::convertOuterToInnerValue( const Any& rOuterValue ) const
107 {
108 OSL_FAIL("should not be used: WrappedCharacterHeightProperty_Base::convertOuterToInnerValue - check if you miss data");
109 return rOuterValue;
110 }
111
112 WrappedCharacterHeightProperty::WrappedCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider )
113 : WrappedCharacterHeightProperty_Base( u"CharHeight"_ustr, pRefSizePropProvider )
114 {
115 }
116 WrappedCharacterHeightProperty::~WrappedCharacterHeightProperty()
117 {
118 }
119
120 WrappedAsianCharacterHeightProperty::WrappedAsianCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider )
121 : WrappedCharacterHeightProperty_Base( u"CharHeightAsian"_ustr, pRefSizePropProvider )
122 {
123 }
124 WrappedAsianCharacterHeightProperty::~WrappedAsianCharacterHeightProperty()
125 {
126 }
127
128 WrappedComplexCharacterHeightProperty::WrappedComplexCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider )
129 : WrappedCharacterHeightProperty_Base( u"CharHeightComplex"_ustr, pRefSizePropProvider )
130 {
131 }
132 WrappedComplexCharacterHeightProperty::~WrappedComplexCharacterHeightProperty()
133 {
134 }
135
136 } //namespace chart::wrapper
137
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */