cid#1640468 Dereference after null check
[LibreOffice.git] / chart2 / source / controller / chartapiwrapper / WrappedCharacterHeightProperty.cxx
blob6e09285dfd623274d6950e64cb62943c53a0f890
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
27 using namespace ::com::sun::star;
28 using ::com::sun::star::uno::Reference;
29 using ::com::sun::star::uno::Any;
31 namespace chart::wrapper
33 WrappedCharacterHeightProperty_Base::WrappedCharacterHeightProperty_Base(
34 const OUString& rOuterEqualsInnerName
35 , ReferenceSizePropertyProvider* pRefSizePropProvider )
36 : WrappedProperty( rOuterEqualsInnerName, rOuterEqualsInnerName )
37 , m_pRefSizePropProvider( pRefSizePropProvider )
40 WrappedCharacterHeightProperty_Base::~WrappedCharacterHeightProperty_Base()
44 void WrappedCharacterHeightProperty::addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
45 , ReferenceSizePropertyProvider* pRefSizePropProvider )
47 rList.emplace_back( new WrappedCharacterHeightProperty( pRefSizePropProvider ) );
48 rList.emplace_back( new WrappedAsianCharacterHeightProperty( pRefSizePropProvider ) );
49 rList.emplace_back( new WrappedComplexCharacterHeightProperty( pRefSizePropProvider ) );
52 void WrappedCharacterHeightProperty_Base::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
54 if(xInnerPropertySet.is())
56 if( m_pRefSizePropProvider )
57 m_pRefSizePropProvider->updateReferenceSize();
58 xInnerPropertySet->setPropertyValue( m_aInnerName, rOuterValue );
62 Any WrappedCharacterHeightProperty_Base::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
64 Any aRet;
65 if( xInnerPropertySet.is() )
67 aRet = xInnerPropertySet->getPropertyValue( m_aInnerName );
68 float fHeight = 0;
69 if( aRet >>= fHeight )
71 if( m_pRefSizePropProvider )
73 awt::Size aReferenceSize;
74 if( m_pRefSizePropProvider->getReferenceSize() >>= aReferenceSize )
76 awt::Size aCurrentSize = m_pRefSizePropProvider->getCurrentSizeForReference();
77 aRet <<= static_cast< float >(
78 RelativeSizeHelper::calculate( fHeight, aReferenceSize, aCurrentSize ));
83 return aRet;
86 Any WrappedCharacterHeightProperty_Base::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
88 Any aRet;
89 if( xInnerPropertyState.is() )
91 aRet = xInnerPropertyState->getPropertyDefault( m_aInnerName );
93 return aRet;
96 beans::PropertyState WrappedCharacterHeightProperty_Base::getPropertyState( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
98 return beans::PropertyState_DIRECT_VALUE;
101 Any WrappedCharacterHeightProperty_Base::convertInnerToOuterValue( const Any& rInnerValue ) const
103 OSL_FAIL("should not be used: WrappedCharacterHeightProperty_Base::convertInnerToOuterValue - check if you miss data");
104 return rInnerValue;
106 Any WrappedCharacterHeightProperty_Base::convertOuterToInnerValue( const Any& rOuterValue ) const
108 OSL_FAIL("should not be used: WrappedCharacterHeightProperty_Base::convertOuterToInnerValue - check if you miss data");
109 return rOuterValue;
112 WrappedCharacterHeightProperty::WrappedCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider )
113 : WrappedCharacterHeightProperty_Base( u"CharHeight"_ustr, pRefSizePropProvider )
116 WrappedCharacterHeightProperty::~WrappedCharacterHeightProperty()
120 WrappedAsianCharacterHeightProperty::WrappedAsianCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider )
121 : WrappedCharacterHeightProperty_Base( u"CharHeightAsian"_ustr, pRefSizePropProvider )
124 WrappedAsianCharacterHeightProperty::~WrappedAsianCharacterHeightProperty()
128 WrappedComplexCharacterHeightProperty::WrappedComplexCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider )
129 : WrappedCharacterHeightProperty_Base( u"CharHeightComplex"_ustr, pRefSizePropProvider )
132 WrappedComplexCharacterHeightProperty::~WrappedComplexCharacterHeightProperty()
136 } //namespace chart::wrapper
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */