Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / chart2 / source / controller / chartapiwrapper / WrappedScaleTextProperties.cxx
blob003c3b8775148270da52face064466599a75af5f
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 "WrappedScaleTextProperties.hxx"
21 #include "Chart2ModelContact.hxx"
22 #include <FastPropertyIdRanges.hxx>
23 #include <WrappedProperty.hxx>
25 #include <com/sun/star/beans/PropertyAttribute.hpp>
26 #include <com/sun/star/beans/XPropertyState.hpp>
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <tools/diagnose_ex.h>
30 using namespace ::com::sun::star;
31 using ::com::sun::star::uno::Any;
32 using ::com::sun::star::uno::Reference;
33 using ::com::sun::star::beans::Property;
35 namespace chart
37 namespace wrapper
40 class WrappedScaleTextProperty : public WrappedProperty
42 public:
43 explicit WrappedScaleTextProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
45 virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const override;
46 virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const override;
47 virtual Any getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const override;
49 private:
50 std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
53 WrappedScaleTextProperty::WrappedScaleTextProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
54 : ::chart::WrappedProperty( "ScaleText" , OUString() )
55 , m_spChart2ModelContact( spChart2ModelContact )
59 void WrappedScaleTextProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
61 static const char aRefSizeName[] = "ReferencePageSize";
63 if( xInnerPropertySet.is() )
65 bool bNewValue = false;
66 if( ! (rOuterValue >>= bNewValue) )
68 if( rOuterValue.hasValue() )
69 throw lang::IllegalArgumentException( "Property ScaleText requires value of type boolean", nullptr, 0 );
72 try
74 if( bNewValue )
76 awt::Size aRefSize( m_spChart2ModelContact->GetPageSize() );
77 xInnerPropertySet->setPropertyValue( aRefSizeName, uno::Any( aRefSize ) );
79 else
80 xInnerPropertySet->setPropertyValue( aRefSizeName, Any() );
82 catch( const uno::Exception & )
84 DBG_UNHANDLED_EXCEPTION("chart2");
89 Any WrappedScaleTextProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
91 Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) );
92 if( xInnerPropertySet.is() )
94 if( xInnerPropertySet->getPropertyValue( "ReferencePageSize" ).hasValue() )
95 aRet <<= true;
96 else
97 aRet <<= false;
100 return aRet;
103 Any WrappedScaleTextProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
105 Any aRet;
106 aRet <<= false;
107 return aRet;
110 namespace
112 enum
114 PROP_CHART_SCALE_TEXT = FAST_PROPERTY_ID_START_SCALE_TEXT_PROP
117 }//anonymous namespace
119 void WrappedScaleTextProperties::addProperties( std::vector< Property > & rOutProperties )
121 rOutProperties.emplace_back( "ScaleText",
122 PROP_CHART_SCALE_TEXT,
123 cppu::UnoType<bool>::get(),
124 beans::PropertyAttribute::MAYBEVOID
125 | beans::PropertyAttribute::MAYBEDEFAULT );
128 void WrappedScaleTextProperties::addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
129 , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
131 rList.emplace_back( new WrappedScaleTextProperty( spChart2ModelContact ) );
134 } //namespace wrapper
135 } //namespace chart
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */