nss: upgrade to release 3.73
[LibreOffice.git] / chart2 / source / model / main / Wall.cxx
blob5ba8aaf184016729c64158c274065ef68ec55e8a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "Wall.hxx"
21 #include <LinePropertiesHelper.hxx>
22 #include <FillProperties.hxx>
23 #include <UserDefinedProperties.hxx>
24 #include <PropertyHelper.hxx>
25 #include <ModifyListenerHelper.hxx>
26 #include <com/sun/star/drawing/LineStyle.hpp>
27 #include <tools/diagnose_ex.h>
29 #include <vector>
30 #include <algorithm>
32 using namespace ::com::sun::star;
34 using ::com::sun::star::beans::Property;
36 namespace
39 struct StaticWallDefaults_Initializer
41 ::chart::tPropertyValueMap* operator()()
43 static ::chart::tPropertyValueMap aStaticDefaults;
44 lcl_AddDefaultsToMap( aStaticDefaults );
45 return &aStaticDefaults;
47 private:
48 static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
50 ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
51 ::chart::FillProperties::AddDefaultsToMap( rOutMap );
53 // override other defaults
54 ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
58 struct StaticWallDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticWallDefaults_Initializer >
62 struct StaticWallInfoHelper_Initializer
64 ::cppu::OPropertyArrayHelper* operator()()
66 static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
67 return &aPropHelper;
70 private:
71 static uno::Sequence< Property > lcl_GetPropertySequence()
73 std::vector< css::beans::Property > aProperties;
74 ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
75 ::chart::FillProperties::AddPropertiesToVector( aProperties );
76 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
78 std::sort( aProperties.begin(), aProperties.end(),
79 ::chart::PropertyNameLess() );
81 return comphelper::containerToSequence( aProperties );
86 struct StaticWallInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticWallInfoHelper_Initializer >
90 struct StaticWallInfo_Initializer
92 uno::Reference< beans::XPropertySetInfo >* operator()()
94 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
95 ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticWallInfoHelper::get() ) );
96 return &xPropertySetInfo;
100 struct StaticWallInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticWallInfo_Initializer >
104 } // anonymous namespace
106 namespace chart
109 Wall::Wall() :
110 ::property::OPropertySet( m_aMutex ),
111 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
114 Wall::Wall( const Wall & rOther ) :
115 impl::Wall_Base(rOther),
116 ::property::OPropertySet( rOther, m_aMutex ),
117 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
120 Wall::~Wall()
123 // ____ XCloneable ____
124 uno::Reference< util::XCloneable > SAL_CALL Wall::createClone()
126 return uno::Reference< util::XCloneable >( new Wall( *this ));
129 // ____ OPropertySet ____
130 uno::Any Wall::GetDefaultValue( sal_Int32 nHandle ) const
132 const tPropertyValueMap& rStaticDefaults = *StaticWallDefaults::get();
133 tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
134 if( aFound == rStaticDefaults.end() )
135 return uno::Any();
136 return (*aFound).second;
139 ::cppu::IPropertyArrayHelper & SAL_CALL Wall::getInfoHelper()
141 return *StaticWallInfoHelper::get();
144 // ____ XPropertySet ____
145 uno::Reference< beans::XPropertySetInfo > SAL_CALL Wall::getPropertySetInfo()
147 return *StaticWallInfo::get();
150 // ____ XModifyBroadcaster ____
151 void SAL_CALL Wall::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
155 uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
156 xBroadcaster->addModifyListener( aListener );
158 catch( const uno::Exception & )
160 DBG_UNHANDLED_EXCEPTION("chart2");
164 void SAL_CALL Wall::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
168 uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
169 xBroadcaster->removeModifyListener( aListener );
171 catch( const uno::Exception & )
173 DBG_UNHANDLED_EXCEPTION("chart2");
177 // ____ XModifyListener ____
178 void SAL_CALL Wall::modified( const lang::EventObject& aEvent )
180 m_xModifyEventForwarder->modified( aEvent );
183 // ____ XEventListener (base of XModifyListener) ____
184 void SAL_CALL Wall::disposing( const lang::EventObject& /* Source */ )
186 // nothing
189 // ____ OPropertySet ____
190 void Wall::firePropertyChangeEvent()
192 m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
195 using impl::Wall_Base;
197 IMPLEMENT_FORWARD_XINTERFACE2( Wall, Wall_Base, ::property::OPropertySet )
199 } // namespace chart
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */