/src/libreoffice/chart2/source/model/main/StockBar.cxx
Line | Count | Source |
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> |
21 | | #include <LinePropertiesHelper.hxx> |
22 | | #include <FillProperties.hxx> |
23 | | #include <UserDefinedProperties.hxx> |
24 | | #include <PropertyHelper.hxx> |
25 | | #include <ModifyListenerHelper.hxx> |
26 | | |
27 | | #include <algorithm> |
28 | | |
29 | | using namespace ::com::sun::star; |
30 | | |
31 | | using ::com::sun::star::uno::Reference; |
32 | | using ::com::sun::star::beans::Property; |
33 | | |
34 | | namespace |
35 | | { |
36 | | |
37 | | ::cppu::OPropertyArrayHelper& StaticStockBarInfoHelper() |
38 | 0 | { |
39 | 0 | static ::cppu::OPropertyArrayHelper aPropHelper = []() |
40 | 0 | { |
41 | 0 | std::vector< css::beans::Property > aProperties; |
42 | 0 | ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); |
43 | 0 | ::chart::FillProperties::AddPropertiesToVector( aProperties ); |
44 | 0 | ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); |
45 | |
|
46 | 0 | std::sort( aProperties.begin(), aProperties.end(), |
47 | 0 | ::chart::PropertyNameLess() ); |
48 | |
|
49 | 0 | return comphelper::containerToSequence( aProperties ); |
50 | 0 | }(); |
51 | 0 | return aPropHelper; |
52 | 0 | }; |
53 | | |
54 | | const ::chart::tPropertyValueMap & StaticStockBarDefaults() |
55 | 0 | { |
56 | 0 | static ::chart::tPropertyValueMap aStaticDefaults = []() |
57 | 0 | { |
58 | 0 | ::chart::tPropertyValueMap aTmp; |
59 | 0 | ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp ); |
60 | 0 | ::chart::FillProperties::AddDefaultsToMap( aTmp ); |
61 | | |
62 | | // override other defaults |
63 | 0 | ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( aTmp, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff ); // white |
64 | 0 | return aTmp; |
65 | 0 | }(); |
66 | 0 | return aStaticDefaults; |
67 | 0 | }; |
68 | | |
69 | | } // anonymous namespace |
70 | | |
71 | | namespace chart |
72 | | { |
73 | | |
74 | | StockBar::StockBar( bool bRisingCourse ) : |
75 | 0 | m_xModifyEventForwarder( new ModifyEventForwarder() ) |
76 | 0 | { |
77 | 0 | if( ! bRisingCourse ) |
78 | 0 | { |
79 | 0 | setFastPropertyValue_NoBroadcast( |
80 | 0 | ::chart::FillProperties::PROP_FILL_COLOR, |
81 | 0 | uno::Any( sal_Int32( 0x000000 ))); // black |
82 | 0 | setFastPropertyValue_NoBroadcast( |
83 | 0 | ::chart::LinePropertiesHelper::PROP_LINE_COLOR, |
84 | 0 | uno::Any( sal_Int32( 0xb3b3b3 ))); // gray30 |
85 | 0 | } |
86 | 0 | } |
87 | | |
88 | | StockBar::StockBar( const StockBar & rOther ) : |
89 | 0 | impl::StockBar_Base(rOther), |
90 | 0 | ::property::OPropertySet( rOther ), |
91 | 0 | m_xModifyEventForwarder( new ModifyEventForwarder() ) |
92 | 0 | {} |
93 | | |
94 | | StockBar::~StockBar() |
95 | 0 | {} |
96 | | |
97 | | // ____ XTypeProvider ____ |
98 | | uno::Sequence< css::uno::Type > SAL_CALL StockBar::getTypes() |
99 | 0 | { |
100 | 0 | return ::comphelper::concatSequences( |
101 | 0 | impl::StockBar_Base::getTypes(), |
102 | 0 | ::property::OPropertySet::getTypes()); |
103 | 0 | } |
104 | | |
105 | | // ____ XCloneable ____ |
106 | | uno::Reference< util::XCloneable > SAL_CALL StockBar::createClone() |
107 | 0 | { |
108 | 0 | return uno::Reference< util::XCloneable >( new StockBar( *this )); |
109 | 0 | } |
110 | | |
111 | | // ____ OPropertySet ____ |
112 | | void StockBar::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const |
113 | 0 | { |
114 | 0 | const tPropertyValueMap& rStaticDefaults = StaticStockBarDefaults(); |
115 | 0 | tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); |
116 | 0 | if( aFound == rStaticDefaults.end() ) |
117 | 0 | rAny.clear(); |
118 | 0 | else |
119 | 0 | rAny = (*aFound).second; |
120 | 0 | } |
121 | | |
122 | | ::cppu::IPropertyArrayHelper & SAL_CALL StockBar::getInfoHelper() |
123 | 0 | { |
124 | 0 | return StaticStockBarInfoHelper(); |
125 | 0 | } |
126 | | |
127 | | // ____ XPropertySet ____ |
128 | | Reference< beans::XPropertySetInfo > SAL_CALL StockBar::getPropertySetInfo() |
129 | 0 | { |
130 | 0 | static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( |
131 | 0 | ::cppu::OPropertySetHelper::createPropertySetInfo(StaticStockBarInfoHelper() ) ); |
132 | 0 | return xPropertySetInfo; |
133 | 0 | } |
134 | | |
135 | | // ____ XModifyBroadcaster ____ |
136 | | void SAL_CALL StockBar::addModifyListener( const uno::Reference< util::XModifyListener >& aListener ) |
137 | 0 | { |
138 | 0 | m_xModifyEventForwarder->addModifyListener( aListener ); |
139 | 0 | } |
140 | | |
141 | | void SAL_CALL StockBar::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener ) |
142 | 0 | { |
143 | 0 | m_xModifyEventForwarder->removeModifyListener( aListener ); |
144 | 0 | } |
145 | | |
146 | | // ____ XModifyListener ____ |
147 | | void SAL_CALL StockBar::modified( const lang::EventObject& aEvent ) |
148 | 0 | { |
149 | 0 | m_xModifyEventForwarder->modified( aEvent ); |
150 | 0 | } |
151 | | |
152 | | // ____ XEventListener (base of XModifyListener) ____ |
153 | | void SAL_CALL StockBar::disposing( const lang::EventObject& /* Source */ ) |
154 | 0 | { |
155 | | // nothing |
156 | 0 | } |
157 | | |
158 | | // ____ OPropertySet ____ |
159 | | void StockBar::firePropertyChangeEvent() |
160 | 0 | { |
161 | 0 | m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this ))); |
162 | 0 | } |
163 | | |
164 | | using impl::StockBar_Base; |
165 | | |
166 | | IMPLEMENT_FORWARD_XINTERFACE2( StockBar, StockBar_Base, ::property::OPropertySet ) |
167 | | |
168 | | } // namespace chart |
169 | | |
170 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |