Branch data Line data Source code
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 : :
21 : : #include "GridProperties.hxx"
22 : : #include "LineProperties.hxx"
23 : : #include "UserDefinedProperties.hxx"
24 : : #include "PropertyHelper.hxx"
25 : : #include "macros.hxx"
26 : : #include "ContainerHelper.hxx"
27 : : #include <com/sun/star/style/XStyle.hpp>
28 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
29 : : #include <com/sun/star/beans/XPropertySet.hpp>
30 : : #include <com/sun/star/uno/Sequence.hxx>
31 : :
32 : : using namespace ::com::sun::star;
33 : :
34 : : using ::com::sun::star::uno::Reference;
35 : : using ::com::sun::star::uno::Sequence;
36 : : using ::com::sun::star::beans::Property;
37 : : using ::osl::MutexGuard;
38 : : using ::rtl::OUString;
39 : :
40 : : // ____________________________________________________________
41 : :
42 : : namespace
43 : : {
44 : :
45 : 16 : static const ::rtl::OUString lcl_aServiceName(
46 : : RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.GridProperties" ));
47 : :
48 : : enum
49 : : {
50 : : PROP_GRID_SHOW
51 : : };
52 : :
53 : 14 : void lcl_AddPropertiesToVector(
54 : : ::std::vector< Property > & rOutProperties )
55 : : {
56 : : rOutProperties.push_back(
57 : : Property( C2U( "Show" ),
58 : : PROP_GRID_SHOW,
59 [ + - ]: 14 : ::getBooleanCppuType(),
60 : : beans::PropertyAttribute::BOUND
61 [ + - ][ + - ]: 14 : | beans::PropertyAttribute::MAYBEDEFAULT ));
62 : 14 : }
63 : :
64 : : struct StaticGridDefaults_Initializer
65 : : {
66 : 14 : ::chart::tPropertyValueMap* operator()()
67 : : {
68 [ + - ][ + - ]: 14 : static ::chart::tPropertyValueMap aStaticDefaults;
[ + - ][ # # ]
69 : 14 : lcl_AddDefaultsToMap( aStaticDefaults );
70 : 14 : return &aStaticDefaults;
71 : : }
72 : : private:
73 : 14 : void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
74 : : {
75 : 14 : ::chart::LineProperties::AddDefaultsToMap( rOutMap );
76 : :
77 [ + - ]: 14 : ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_GRID_SHOW, false );
78 : :
79 : : // override other defaults
80 : : ::chart::PropertyHelper::setPropertyValue< sal_Int32 >(
81 [ + - ]: 14 : rOutMap, ::chart::LineProperties::PROP_LINE_COLOR, 0xb3b3b3 ); // gray30
82 : 14 : }
83 : : };
84 : :
85 : : struct StaticGridDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticGridDefaults_Initializer >
86 : : {
87 : : };
88 : :
89 : : struct StaticGridInfoHelper_Initializer
90 : : {
91 : 14 : ::cppu::OPropertyArrayHelper* operator()()
92 : : {
93 [ + - ][ + - ]: 14 : static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
[ + - ][ + - ]
[ + - ][ # # ]
94 : 14 : return &aPropHelper;
95 : : }
96 : :
97 : : private:
98 : 14 : Sequence< Property > lcl_GetPropertySequence()
99 : : {
100 [ + - ]: 14 : ::std::vector< Property > aProperties;
101 [ + - ]: 14 : lcl_AddPropertiesToVector( aProperties );
102 [ + - ]: 14 : ::chart::LineProperties::AddPropertiesToVector( aProperties );
103 [ + - ]: 14 : ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
104 : :
105 : : ::std::sort( aProperties.begin(), aProperties.end(),
106 [ + - ]: 14 : ::chart::PropertyNameLess() );
107 : :
108 [ + - ]: 14 : return ::chart::ContainerHelper::ContainerToSequence( aProperties );
109 : : }
110 : :
111 : :
112 : : };
113 : :
114 : : struct StaticGridInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticGridInfoHelper_Initializer >
115 : : {
116 : : };
117 : :
118 : : struct StaticGridInfo_Initializer
119 : : {
120 : 0 : uno::Reference< beans::XPropertySetInfo >* operator()()
121 : : {
122 : : static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
123 [ # # ][ # # ]: 0 : ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticGridInfoHelper::get() ) );
[ # # ][ # # ]
[ # # ]
124 : 0 : return &xPropertySetInfo;
125 : : }
126 : : };
127 : :
128 : : struct StaticGridInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticGridInfo_Initializer >
129 : : {
130 : : };
131 : :
132 : : } // anonymous namespace
133 : :
134 : : // ____________________________________________________________
135 : :
136 : : namespace chart
137 : : {
138 : :
139 : 0 : GridProperties::GridProperties( Reference< uno::XComponentContext > const & /* xContext */ ) :
140 : : ::property::OPropertySet( m_aMutex ),
141 [ # # ][ # # ]: 0 : m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
[ # # ]
142 : : {
143 : 0 : }
144 : :
145 : 444 : GridProperties::GridProperties() :
146 : : ::property::OPropertySet( m_aMutex ),
147 [ + - ][ + - ]: 444 : m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
[ + - ]
148 : 444 : {}
149 : :
150 : 0 : GridProperties::GridProperties( const GridProperties & rOther ) :
151 : : MutexContainer(),
152 : : impl::GridProperties_Base(),
153 : : ::property::OPropertySet( rOther, m_aMutex ),
154 [ # # ][ # # ]: 0 : m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
[ # # ]
155 : : {
156 : 0 : }
157 : :
158 [ + - ][ + - ]: 444 : GridProperties::~GridProperties()
159 [ - + ]: 888 : {}
160 : :
161 : : // ____ OPropertySet ____
162 : 27607 : uno::Any GridProperties::GetDefaultValue( sal_Int32 nHandle ) const
163 : : throw(beans::UnknownPropertyException)
164 : : {
165 [ + - ]: 27607 : const tPropertyValueMap& rStaticDefaults = *StaticGridDefaults::get();
166 [ + - ]: 27607 : tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
167 [ + + ]: 27607 : if( aFound == rStaticDefaults.end() )
168 : 771 : return uno::Any();
169 : 27607 : return (*aFound).second;
170 : : }
171 : :
172 : 63054 : ::cppu::IPropertyArrayHelper & SAL_CALL GridProperties::getInfoHelper()
173 : : {
174 : 63054 : return *StaticGridInfoHelper::get();
175 : : }
176 : :
177 : : // ____ XPropertySet ____
178 : 0 : Reference< beans::XPropertySetInfo > SAL_CALL GridProperties::getPropertySetInfo()
179 : : throw (uno::RuntimeException)
180 : : {
181 : 0 : return *StaticGridInfo::get();
182 : : }
183 : :
184 : : // ____ XCloneable ____
185 : 0 : uno::Reference< util::XCloneable > SAL_CALL GridProperties::createClone()
186 : : throw (uno::RuntimeException)
187 : : {
188 [ # # ][ # # ]: 0 : return uno::Reference< util::XCloneable >( new GridProperties( *this ));
189 : : }
190 : :
191 : : // ____ XModifyBroadcaster ____
192 : 444 : void SAL_CALL GridProperties::addModifyListener( const Reference< util::XModifyListener >& aListener )
193 : : throw (uno::RuntimeException)
194 : : {
195 : : try
196 : : {
197 [ + - ]: 444 : Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
198 [ + - ][ + - ]: 444 : xBroadcaster->addModifyListener( aListener );
[ # # ]
199 : : }
200 : 0 : catch( const uno::Exception & ex )
201 : : {
202 : : ASSERT_EXCEPTION( ex );
203 : : }
204 : 444 : }
205 : :
206 : 444 : void SAL_CALL GridProperties::removeModifyListener( const Reference< util::XModifyListener >& aListener )
207 : : throw (uno::RuntimeException)
208 : : {
209 : : try
210 : : {
211 [ + - ]: 444 : Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
212 [ + - ][ + - ]: 444 : xBroadcaster->removeModifyListener( aListener );
[ # # ]
213 : : }
214 : 0 : catch( const uno::Exception & ex )
215 : : {
216 : : ASSERT_EXCEPTION( ex );
217 : : }
218 : 444 : }
219 : :
220 : : // ____ XModifyListener ____
221 : 0 : void SAL_CALL GridProperties::modified( const lang::EventObject& aEvent )
222 : : throw (uno::RuntimeException)
223 : : {
224 : 0 : m_xModifyEventForwarder->modified( aEvent );
225 : 0 : }
226 : :
227 : : // ____ XEventListener (base of XModifyListener) ____
228 : 0 : void SAL_CALL GridProperties::disposing( const lang::EventObject& /* Source */ )
229 : : throw (uno::RuntimeException)
230 : : {
231 : : // nothing
232 : 0 : }
233 : :
234 : : // ____ OPropertySet ____
235 : 410 : void GridProperties::firePropertyChangeEvent()
236 : : {
237 : 410 : fireModifyEvent();
238 : 410 : }
239 : :
240 : 410 : void GridProperties::fireModifyEvent()
241 : : {
242 [ + - ][ + - ]: 410 : m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
[ + - ]
243 : 410 : }
244 : :
245 : : // ================================================================================
246 : :
247 : 0 : Sequence< OUString > GridProperties::getSupportedServiceNames_Static()
248 : : {
249 : 0 : Sequence< OUString > aServices( 2 );
250 [ # # ][ # # ]: 0 : aServices[ 0 ] = C2U( "com.sun.star.chart2.GridProperties" );
251 [ # # ][ # # ]: 0 : aServices[ 1 ] = C2U( "com.sun.star.beans.PropertySet" );
252 : 0 : return aServices;
253 : : }
254 : :
255 : : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
256 [ # # ][ # # ]: 173 : APPHELPER_XSERVICEINFO_IMPL( GridProperties, lcl_aServiceName );
[ # # ][ # # ]
[ # # ]
257 : :
258 : : // needed by MSC compiler
259 : : using impl::GridProperties_Base;
260 : :
261 [ + + ][ + - ]: 77416 : IMPLEMENT_FORWARD_XINTERFACE2( GridProperties, GridProperties_Base, ::property::OPropertySet )
262 [ # # ][ # # ]: 0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( GridProperties, GridProperties_Base, ::property::OPropertySet )
[ # # ]
263 : :
264 [ + - ][ + - ]: 48 : } // namespace chart
265 : :
266 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|