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