LibreOffice Module chart2 (master) 1
WrappedCharacterHeightProperty.cxx
Go to the documentation of this file.
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
23#include <com/sun/star/beans/XPropertySet.hpp>
24#include <com/sun/star/beans/XPropertyState.hpp>
25#include <osl/diagnose.h>
26
27using namespace ::com::sun::star;
28using ::com::sun::star::uno::Reference;
29using ::com::sun::star::uno::Any;
30
31namespace chart::wrapper
32{
34 const OUString& rOuterEqualsInnerName
35 , ReferenceSizePropertyProvider* pRefSizePropProvider )
36 : WrappedProperty( rOuterEqualsInnerName, rOuterEqualsInnerName )
37 , m_pRefSizePropProvider( pRefSizePropProvider )
38{
39}
41{
42}
43
44void 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
52void WrappedCharacterHeightProperty_Base::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
53{
54 if(xInnerPropertySet.is())
55 {
58 xInnerPropertySet->setPropertyValue( m_aInnerName, rOuterValue );
59 }
60}
61
63{
64 Any aRet;
65 if( xInnerPropertySet.is() )
66 {
67 aRet = xInnerPropertySet->getPropertyValue( m_aInnerName );
68 float fHeight = 0;
69 if( aRet >>= fHeight )
70 {
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
87{
88 Any aRet;
89 if( xInnerPropertyState.is() )
90 {
91 aRet = xInnerPropertyState->getPropertyDefault( m_aInnerName );
92 }
93 return aRet;
94}
95
96beans::PropertyState WrappedCharacterHeightProperty_Base::getPropertyState( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
97{
98 return beans::PropertyState_DIRECT_VALUE;
99}
100
102{
103 OSL_FAIL("should not be used: WrappedCharacterHeightProperty_Base::convertInnerToOuterValue - check if you miss data");
104 return rInnerValue;
105}
107{
108 OSL_FAIL("should not be used: WrappedCharacterHeightProperty_Base::convertOuterToInnerValue - check if you miss data");
109 return rOuterValue;
110}
111
113 : WrappedCharacterHeightProperty_Base( "CharHeight", pRefSizePropProvider )
114{
115}
117{
118}
119
121 : WrappedCharacterHeightProperty_Base( "CharHeightAsian", pRefSizePropProvider )
122{
123}
125{
126}
127
129 : WrappedCharacterHeightProperty_Base( "CharHeightComplex", pRefSizePropProvider )
130{
131}
133{
134}
135
136} //namespace chart::wrapper
137
138/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static double calculate(double fValue, const css::awt::Size &rOldReferenceSize, const css::awt::Size &rNewReferenceSize)
virtual css::awt::Size getCurrentSizeForReference()=0
virtual css::uno::Any getReferenceSize()=0
WrappedAsianCharacterHeightProperty(ReferenceSizePropertyProvider *pRefSizePropProvider)
WrappedCharacterHeightProperty_Base(const OUString &rOuterEqualsInnerName, ReferenceSizePropertyProvider *pRefSizePropProvider)
virtual css::uno::Any convertOuterToInnerValue(const css::uno::Any &rOuterValue) const override
virtual css::uno::Any getPropertyDefault(const css::uno::Reference< css::beans::XPropertyState > &xInnerPropertyState) const override
virtual css::uno::Any convertInnerToOuterValue(const css::uno::Any &rInnerValue) const override
virtual void setPropertyValue(const css::uno::Any &rOuterValue, const css::uno::Reference< css::beans::XPropertySet > &xInnerPropertySet) const override
virtual css::beans::PropertyState getPropertyState(const css::uno::Reference< css::beans::XPropertyState > &xInnerPropertyState) const override
virtual css::uno::Any getPropertyValue(const css::uno::Reference< css::beans::XPropertySet > &xInnerPropertySet) const override
WrappedCharacterHeightProperty(ReferenceSizePropertyProvider *pRefSizePropProvider)
static void addWrappedProperties(std::vector< std::unique_ptr< WrappedProperty > > &rList, ReferenceSizePropertyProvider *pRefSizePropProvider)
WrappedComplexCharacterHeightProperty(ReferenceSizePropertyProvider *pRefSizePropProvider)