LibreOffice Module chart2 (master) 1
StockBar.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
20#include <StockBar.hxx>
22#include <FillProperties.hxx>
24#include <PropertyHelper.hxx>
26#include <com/sun/star/uno/Sequence.hxx>
27
28#include <algorithm>
29
30namespace com::sun::star::beans { class XPropertySetInfo; }
31
32using namespace ::com::sun::star;
33
34using ::com::sun::star::uno::Reference;
35using ::com::sun::star::beans::Property;
36
37namespace
38{
39
40::cppu::OPropertyArrayHelper& StaticStockBarInfoHelper()
41{
42 static ::cppu::OPropertyArrayHelper aPropHelper = []()
43 {
44 std::vector< css::beans::Property > aProperties;
48
49 std::sort( aProperties.begin(), aProperties.end(),
51
52 return comphelper::containerToSequence( aProperties );
53 }();
54 return aPropHelper;
55};
56
57const ::chart::tPropertyValueMap & StaticStockBarDefaults()
58{
59 static ::chart::tPropertyValueMap aStaticDefaults = []()
60 {
64
65 // override other defaults
66 ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( aTmp, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff ); // white
67 return aTmp;
68 }();
69 return aStaticDefaults;
70};
71
72} // anonymous namespace
73
74namespace chart
75{
76
77StockBar::StockBar( bool bRisingCourse ) :
78 m_xModifyEventForwarder( new ModifyEventForwarder() )
79{
80 if( ! bRisingCourse )
81 {
83 ::chart::FillProperties::PROP_FILL_COLOR,
84 uno::Any( sal_Int32( 0x000000 ))); // black
87 uno::Any( sal_Int32( 0xb3b3b3 ))); // gray30
88 }
89}
90
91StockBar::StockBar( const StockBar & rOther ) :
92 impl::StockBar_Base(rOther),
93 ::property::OPropertySet( rOther ),
94 m_xModifyEventForwarder( new ModifyEventForwarder() )
95{}
96
98{}
99
100// ____ XTypeProvider ____
102{
103 return ::comphelper::concatSequences(
104 impl::StockBar_Base::getTypes(),
106}
107
108// ____ XCloneable ____
110{
111 return uno::Reference< util::XCloneable >( new StockBar( *this ));
112}
113
114// ____ OPropertySet ____
115void StockBar::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
116{
117 const tPropertyValueMap& rStaticDefaults = StaticStockBarDefaults();
118 tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
119 if( aFound == rStaticDefaults.end() )
120 rAny.clear();
121 else
122 rAny = (*aFound).second;
123}
124
126{
127 return StaticStockBarInfoHelper();
128}
129
130// ____ XPropertySet ____
132{
133 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
134 ::cppu::OPropertySetHelper::createPropertySetInfo(StaticStockBarInfoHelper() ) );
135 return xPropertySetInfo;
136}
137
138// ____ XModifyBroadcaster ____
140{
141 m_xModifyEventForwarder->addModifyListener( aListener );
142}
143
145{
146 m_xModifyEventForwarder->removeModifyListener( aListener );
147}
148
149// ____ XModifyListener ____
150void SAL_CALL StockBar::modified( const lang::EventObject& aEvent )
151{
152 m_xModifyEventForwarder->modified( aEvent );
153}
154
155// ____ XEventListener (base of XModifyListener) ____
156void SAL_CALL StockBar::disposing( const lang::EventObject& /* Source */ )
157{
158 // nothing
159}
160
161// ____ OPropertySet ____
163{
164 m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
165}
166
168
170
171} // namespace chart
172
173/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PropertiesInfo aProperties
AnyEventRef aEvent
This helper class serves as forwarder of modify events.
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override
Definition: StockBar.cxx:109
virtual void SAL_CALL removeModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
Definition: StockBar.cxx:144
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: StockBar.cxx:131
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
The InfoHelper table contains all property names and types of this object.
Definition: StockBar.cxx:125
virtual ~StockBar() override
Definition: StockBar.cxx:97
rtl::Reference< ModifyEventForwarder > m_xModifyEventForwarder
Definition: StockBar.hxx:87
virtual void SAL_CALL modified(const css::lang::EventObject &aEvent) override
Definition: StockBar.cxx:150
virtual void GetDefaultValue(sal_Int32 nHandle, css::uno::Any &rAny) const override
implement this method to provide default values for all properties supporting defaults.
Definition: StockBar.cxx:115
StockBar(bool bRisingCourse)
Definition: StockBar.cxx:77
virtual void SAL_CALL addModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
Definition: StockBar.cxx:139
virtual void firePropertyChangeEvent() override
implement this method in derived classes to get called when properties change.
Definition: StockBar.cxx:162
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: StockBar.cxx:101
static css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL createPropertySetInfo(IPropertyArrayHelper &rProperties)
void SAL_CALL disposing()
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
The same as setFastPropertyValue; nHandle is always valid.
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
OOO_DLLPUBLIC_CHARTTOOLS void AddDefaultsToMap(::chart::tPropertyValueMap &rOutMap)
OOO_DLLPUBLIC_CHARTTOOLS void AddPropertiesToVector(std::vector< css::beans::Property > &rOutProperties)
::cppu::WeakImplHelper< css::util::XCloneable, css::util::XModifyBroadcaster, css::util::XModifyListener > StockBar_Base
Definition: StockBar.hxx:37
std::unordered_map< tPropertyValueMapKey, css::uno::Any > tPropertyValueMap
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
IMPLEMENT_FORWARD_XINTERFACE2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
sal_Int32 nHandle