merge the formfield patch from ooo-build
[ooovba.git] / chart2 / source / controller / chartapiwrapper / WallFloorWrapper.cxx
blobc8d980cd2e441e4d13c2462a2b144f68cb6443e1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: WallFloorWrapper.cxx,v $
10 * $Revision: 1.3.44.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
34 #include "WallFloorWrapper.hxx"
35 #include "macros.hxx"
36 #include "Chart2ModelContact.hxx"
37 #include "ContainerHelper.hxx"
38 #include <com/sun/star/beans/PropertyAttribute.hpp>
39 #include <com/sun/star/drawing/FillStyle.hpp>
41 #include "FillProperties.hxx"
42 #include "LineProperties.hxx"
43 #include "UserDefinedProperties.hxx"
44 #include "WrappedDirectStateProperty.hxx"
46 #include <algorithm>
47 #include <rtl/ustrbuf.hxx>
48 #include <rtl/math.hxx>
50 using namespace ::com::sun::star;
51 using namespace ::com::sun::star::chart2;
53 using ::com::sun::star::beans::Property;
54 using ::osl::MutexGuard;
55 using ::com::sun::star::uno::Any;
56 using ::com::sun::star::uno::Reference;
57 using ::com::sun::star::uno::Sequence;
58 using ::rtl::OUString;
60 namespace
62 static const OUString lcl_aServiceName(
63 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.WallOrFloor" ));
65 const Sequence< Property > & lcl_GetPropertySequence()
67 static Sequence< Property > aPropSeq;
69 // /--
70 MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
71 if( 0 == aPropSeq.getLength() )
73 // get properties
74 ::std::vector< ::com::sun::star::beans::Property > aProperties;
75 ::chart::FillProperties::AddPropertiesToVector( aProperties );
76 ::chart::LineProperties::AddPropertiesToVector( aProperties );
77 // ::chart::NamedProperties::AddPropertiesToVector( aProperties );
78 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
80 // and sort them for access via bsearch
81 ::std::sort( aProperties.begin(), aProperties.end(),
82 ::chart::PropertyNameLess() );
84 // transfer result to static Sequence
85 aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties );
88 return aPropSeq;
91 } // anonymous namespace
93 // --------------------------------------------------------------------------------
95 namespace chart
97 namespace wrapper
100 WallFloorWrapper::WallFloorWrapper( bool bWall,
101 ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
102 m_spChart2ModelContact( spChart2ModelContact ),
103 m_aEventListenerContainer( m_aMutex ),
104 m_bWall( bWall )
109 WallFloorWrapper::~WallFloorWrapper()
113 // ____ XComponent ____
114 void SAL_CALL WallFloorWrapper::dispose()
115 throw (uno::RuntimeException)
117 Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
118 m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
120 // /--
121 MutexGuard aGuard( GetMutex());
122 clearWrappedPropertySet();
123 // \--
126 void SAL_CALL WallFloorWrapper::addEventListener(
127 const Reference< lang::XEventListener >& xListener )
128 throw (uno::RuntimeException)
130 m_aEventListenerContainer.addInterface( xListener );
133 void SAL_CALL WallFloorWrapper::removeEventListener(
134 const Reference< lang::XEventListener >& aListener )
135 throw (uno::RuntimeException)
137 m_aEventListenerContainer.removeInterface( aListener );
140 // ================================================================================
142 // WrappedPropertySet
143 Reference< beans::XPropertySet > WallFloorWrapper::getInnerPropertySet()
145 Reference< beans::XPropertySet > xRet;
147 Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
148 if( xDiagram.is() )
150 if( m_bWall )
151 xRet.set( xDiagram->getWall() );
152 else
153 xRet.set( xDiagram->getFloor() );
156 return xRet;
159 const Sequence< beans::Property >& WallFloorWrapper::getPropertySequence()
161 return lcl_GetPropertySequence();
164 const std::vector< WrappedProperty* > WallFloorWrapper::createWrappedProperties()
166 ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
168 // use direct state always, so that in XML the value is always
169 // exported. Because in the old chart the defaults is as follows:
170 // Floor: SOLID (new and old model default), Wall: NONE, except for some chart types (line, scatter)
171 if( m_bWall )
172 aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U("FillStyle"), C2U("FillStyle") ));
173 aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U("FillColor"), C2U("FillColor") ));
175 return aWrappedProperties;
178 // ================================================================================
180 Sequence< OUString > WallFloorWrapper::getSupportedServiceNames_Static()
182 Sequence< OUString > aServices( 4 );
183 aServices[ 0 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" );
184 aServices[ 1 ] = C2U( "com.sun.star.drawing.FillProperties" );
185 aServices[ 2 ] = C2U( "com.sun.star.drawing.LineProperties" );
186 aServices[ 3 ] = C2U( "com.sun.star.beans.PropertySet" );
188 return aServices;
191 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
192 APPHELPER_XSERVICEINFO_IMPL( WallFloorWrapper, lcl_aServiceName );
194 } // namespace wrapper
195 } // namespace chart