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 "LinePropertiesHelper.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 : struct StaticWallDefaults_Initializer
50 : {
51 28 : ::chart::tPropertyValueMap* operator()()
52 : {
53 28 : static ::chart::tPropertyValueMap aStaticDefaults;
54 28 : lcl_AddDefaultsToMap( aStaticDefaults );
55 28 : return &aStaticDefaults;
56 : }
57 : private:
58 28 : void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
59 : {
60 28 : ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
61 28 : ::chart::FillProperties::AddDefaultsToMap( rOutMap );
62 :
63 : // override other defaults
64 28 : ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
65 28 : }
66 : };
67 :
68 : struct StaticWallDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticWallDefaults_Initializer >
69 : {
70 : };
71 :
72 : struct StaticWallInfoHelper_Initializer
73 : {
74 28 : ::cppu::OPropertyArrayHelper* operator()()
75 : {
76 28 : static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
77 28 : return &aPropHelper;
78 : }
79 :
80 : private:
81 28 : uno::Sequence< Property > lcl_GetPropertySequence()
82 : {
83 28 : ::std::vector< ::com::sun::star::beans::Property > aProperties;
84 28 : ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
85 28 : ::chart::FillProperties::AddPropertiesToVector( aProperties );
86 28 : ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
87 :
88 : ::std::sort( aProperties.begin(), aProperties.end(),
89 28 : ::chart::PropertyNameLess() );
90 :
91 28 : return ::chart::ContainerHelper::ContainerToSequence( aProperties );
92 : }
93 :
94 : };
95 :
96 : struct StaticWallInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticWallInfoHelper_Initializer >
97 : {
98 : };
99 :
100 : struct StaticWallInfo_Initializer
101 : {
102 12 : uno::Reference< beans::XPropertySetInfo >* operator()()
103 : {
104 : static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
105 12 : ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticWallInfoHelper::get() ) );
106 12 : return &xPropertySetInfo;
107 : }
108 : };
109 :
110 : struct StaticWallInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticWallInfo_Initializer >
111 : {
112 : };
113 :
114 : } // anonymous namespace
115 :
116 : namespace chart
117 : {
118 :
119 1048 : Wall::Wall() :
120 : ::property::OPropertySet( m_aMutex ),
121 1048 : m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
122 1048 : {}
123 :
124 0 : Wall::Wall( const Wall & rOther ) :
125 : MutexContainer(),
126 : impl::Wall_Base(),
127 : ::property::OPropertySet( rOther, m_aMutex ),
128 0 : m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
129 0 : {}
130 :
131 2096 : Wall::~Wall()
132 2096 : {}
133 :
134 : // ____ XCloneable ____
135 0 : uno::Reference< util::XCloneable > SAL_CALL Wall::createClone()
136 : throw (uno::RuntimeException, std::exception)
137 : {
138 0 : return uno::Reference< util::XCloneable >( new Wall( *this ));
139 : }
140 :
141 : // ____ OPropertySet ____
142 21182 : uno::Any Wall::GetDefaultValue( sal_Int32 nHandle ) const
143 : throw(beans::UnknownPropertyException)
144 : {
145 21182 : const tPropertyValueMap& rStaticDefaults = *StaticWallDefaults::get();
146 21182 : tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
147 21182 : if( aFound == rStaticDefaults.end() )
148 3658 : return uno::Any();
149 17524 : return (*aFound).second;
150 : }
151 :
152 104020 : ::cppu::IPropertyArrayHelper & SAL_CALL Wall::getInfoHelper()
153 : {
154 104020 : return *StaticWallInfoHelper::get();
155 : }
156 :
157 : // ____ XPropertySet ____
158 270 : uno::Reference< beans::XPropertySetInfo > SAL_CALL Wall::getPropertySetInfo()
159 : throw (uno::RuntimeException, std::exception)
160 : {
161 270 : return *StaticWallInfo::get();
162 : }
163 :
164 : // ____ XModifyBroadcaster ____
165 1048 : void SAL_CALL Wall::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
166 : throw (uno::RuntimeException, std::exception)
167 : {
168 : try
169 : {
170 1048 : uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
171 1048 : xBroadcaster->addModifyListener( aListener );
172 : }
173 0 : catch( const uno::Exception & ex )
174 : {
175 : ASSERT_EXCEPTION( ex );
176 : }
177 1048 : }
178 :
179 1048 : void SAL_CALL Wall::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
180 : throw (uno::RuntimeException, std::exception)
181 : {
182 : try
183 : {
184 1048 : uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
185 1048 : xBroadcaster->removeModifyListener( aListener );
186 : }
187 0 : catch( const uno::Exception & ex )
188 : {
189 : ASSERT_EXCEPTION( ex );
190 : }
191 1048 : }
192 :
193 : // ____ XModifyListener ____
194 0 : void SAL_CALL Wall::modified( const lang::EventObject& aEvent )
195 : throw (uno::RuntimeException, std::exception)
196 : {
197 0 : m_xModifyEventForwarder->modified( aEvent );
198 0 : }
199 :
200 : // ____ XEventListener (base of XModifyListener) ____
201 0 : void SAL_CALL Wall::disposing( const lang::EventObject& /* Source */ )
202 : throw (uno::RuntimeException, std::exception)
203 : {
204 : // nothing
205 0 : }
206 :
207 : // ____ OPropertySet ____
208 2136 : void Wall::firePropertyChangeEvent()
209 : {
210 2136 : fireModifyEvent();
211 2136 : }
212 :
213 2136 : void Wall::fireModifyEvent()
214 : {
215 2136 : m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
216 2136 : }
217 :
218 : using impl::Wall_Base;
219 :
220 580490 : IMPLEMENT_FORWARD_XINTERFACE2( Wall, Wall_Base, ::property::OPropertySet )
221 :
222 : } // namespace chart
223 :
224 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|