tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / chart2 / source / model / main / StockBar.cxx
blob5d7efdc5f0d93282ac5d712b6a5e0e5c7ebf46f0
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 <StockBar.hxx>
21 #include <LinePropertiesHelper.hxx>
22 #include <FillProperties.hxx>
23 #include <UserDefinedProperties.hxx>
24 #include <PropertyHelper.hxx>
25 #include <ModifyListenerHelper.hxx>
27 #include <algorithm>
29 namespace com::sun::star::beans { class XPropertySetInfo; }
31 using namespace ::com::sun::star;
33 using ::com::sun::star::uno::Reference;
34 using ::com::sun::star::beans::Property;
36 namespace
39 ::cppu::OPropertyArrayHelper& StaticStockBarInfoHelper()
41 static ::cppu::OPropertyArrayHelper aPropHelper = []()
43 std::vector< css::beans::Property > aProperties;
44 ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
45 ::chart::FillProperties::AddPropertiesToVector( aProperties );
46 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
48 std::sort( aProperties.begin(), aProperties.end(),
49 ::chart::PropertyNameLess() );
51 return comphelper::containerToSequence( aProperties );
52 }();
53 return aPropHelper;
56 const ::chart::tPropertyValueMap & StaticStockBarDefaults()
58 static ::chart::tPropertyValueMap aStaticDefaults = []()
60 ::chart::tPropertyValueMap aTmp;
61 ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp );
62 ::chart::FillProperties::AddDefaultsToMap( aTmp );
64 // override other defaults
65 ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( aTmp, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff ); // white
66 return aTmp;
67 }();
68 return aStaticDefaults;
71 } // anonymous namespace
73 namespace chart
76 StockBar::StockBar( bool bRisingCourse ) :
77 m_xModifyEventForwarder( new ModifyEventForwarder() )
79 if( ! bRisingCourse )
81 setFastPropertyValue_NoBroadcast(
82 ::chart::FillProperties::PROP_FILL_COLOR,
83 uno::Any( sal_Int32( 0x000000 ))); // black
84 setFastPropertyValue_NoBroadcast(
85 ::chart::LinePropertiesHelper::PROP_LINE_COLOR,
86 uno::Any( sal_Int32( 0xb3b3b3 ))); // gray30
90 StockBar::StockBar( const StockBar & rOther ) :
91 impl::StockBar_Base(rOther),
92 ::property::OPropertySet( rOther ),
93 m_xModifyEventForwarder( new ModifyEventForwarder() )
96 StockBar::~StockBar()
99 // ____ XTypeProvider ____
100 uno::Sequence< css::uno::Type > SAL_CALL StockBar::getTypes()
102 return ::comphelper::concatSequences(
103 impl::StockBar_Base::getTypes(),
104 ::property::OPropertySet::getTypes());
107 // ____ XCloneable ____
108 uno::Reference< util::XCloneable > SAL_CALL StockBar::createClone()
110 return uno::Reference< util::XCloneable >( new StockBar( *this ));
113 // ____ OPropertySet ____
114 void StockBar::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
116 const tPropertyValueMap& rStaticDefaults = StaticStockBarDefaults();
117 tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
118 if( aFound == rStaticDefaults.end() )
119 rAny.clear();
120 else
121 rAny = (*aFound).second;
124 ::cppu::IPropertyArrayHelper & SAL_CALL StockBar::getInfoHelper()
126 return StaticStockBarInfoHelper();
129 // ____ XPropertySet ____
130 Reference< beans::XPropertySetInfo > SAL_CALL StockBar::getPropertySetInfo()
132 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
133 ::cppu::OPropertySetHelper::createPropertySetInfo(StaticStockBarInfoHelper() ) );
134 return xPropertySetInfo;
137 // ____ XModifyBroadcaster ____
138 void SAL_CALL StockBar::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
140 m_xModifyEventForwarder->addModifyListener( aListener );
143 void SAL_CALL StockBar::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
145 m_xModifyEventForwarder->removeModifyListener( aListener );
148 // ____ XModifyListener ____
149 void SAL_CALL StockBar::modified( const lang::EventObject& aEvent )
151 m_xModifyEventForwarder->modified( aEvent );
154 // ____ XEventListener (base of XModifyListener) ____
155 void SAL_CALL StockBar::disposing( const lang::EventObject& /* Source */ )
157 // nothing
160 // ____ OPropertySet ____
161 void StockBar::firePropertyChangeEvent()
163 m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
166 using impl::StockBar_Base;
168 IMPLEMENT_FORWARD_XINTERFACE2( StockBar, StockBar_Base, ::property::OPropertySet )
170 } // namespace chart
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */