Update ooo320-m1
[ooovba.git] / chart2 / source / controller / chartapiwrapper / AreaWrapper.cxx
blobd0be6564a3e10c1afbb56bfb142c5f53971f6452
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: AreaWrapper.cxx,v $
10 * $Revision: 1.5.16.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 "AreaWrapper.hxx"
35 #include "macros.hxx"
36 #include "ContainerHelper.hxx"
37 #include "Chart2ModelContact.hxx"
38 #include "WrappedDirectStateProperty.hxx"
39 #include <comphelper/InlineContainer.hxx>
40 #include <com/sun/star/drawing/FillStyle.hpp>
42 #include "LineProperties.hxx"
43 #include "FillProperties.hxx"
44 #include "UserDefinedProperties.hxx"
46 #include <algorithm>
48 using namespace ::com::sun::star;
49 using ::com::sun::star::beans::Property;
50 using ::osl::MutexGuard;
51 using ::com::sun::star::uno::Any;
52 using ::com::sun::star::uno::Reference;
53 using ::com::sun::star::uno::Sequence;
55 //-----------------------------------------------------------------------------
56 //-----------------------------------------------------------------------------
58 namespace
60 static const ::rtl::OUString lcl_aServiceName(
61 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Area" ));
63 const Sequence< Property > & lcl_GetPropertySequence()
65 static Sequence< Property > aPropSeq;
67 // /--
68 MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
69 if( 0 == aPropSeq.getLength() )
71 // get properties
72 ::std::vector< ::com::sun::star::beans::Property > aProperties;
73 ::chart::LineProperties::AddPropertiesToVector( aProperties );
74 ::chart::FillProperties::AddPropertiesToVector( aProperties );
75 // ::chart::NamedProperties::AddPropertiesToVector( aProperties );
76 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
78 // and sort them for access via bsearch
79 ::std::sort( aProperties.begin(), aProperties.end(),
80 ::chart::PropertyNameLess() );
82 // transfer result to static Sequence
83 aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties );
86 return aPropSeq;
88 } // anonymous namespace
90 // --------------------------------------------------------------------------------
91 // --------------------------------------------------------------------------------
93 namespace chart
95 namespace wrapper
98 AreaWrapper::AreaWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
99 m_spChart2ModelContact( spChart2ModelContact ),
100 m_aEventListenerContainer( m_aMutex )
104 AreaWrapper::~AreaWrapper()
107 // ____ XShape ____
108 awt::Point SAL_CALL AreaWrapper::getPosition()
109 throw (uno::RuntimeException)
111 return awt::Point(0,0);
114 void SAL_CALL AreaWrapper::setPosition( const awt::Point& /*aPosition*/ )
115 throw (uno::RuntimeException)
117 OSL_ENSURE( false, "trying to set position of chart area" );
120 awt::Size SAL_CALL AreaWrapper::getSize()
121 throw (uno::RuntimeException)
123 return m_spChart2ModelContact->GetPageSize();
126 void SAL_CALL AreaWrapper::setSize( const awt::Size& /*aSize*/ )
127 throw (beans::PropertyVetoException,
128 uno::RuntimeException)
130 OSL_ENSURE( false, "trying to set size of chart area" );
133 // ____ XShapeDescriptor (base of XShape) ____
134 ::rtl::OUString SAL_CALL AreaWrapper::getShapeType()
135 throw (uno::RuntimeException)
137 return C2U( "com.sun.star.chart.ChartArea" );
140 // ____ XComponent ____
141 void SAL_CALL AreaWrapper::dispose()
142 throw (uno::RuntimeException)
144 Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
145 m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
147 // /--
148 MutexGuard aGuard( GetMutex());
149 clearWrappedPropertySet();
150 // \--
153 void SAL_CALL AreaWrapper::addEventListener(
154 const Reference< lang::XEventListener >& xListener )
155 throw (uno::RuntimeException)
157 m_aEventListenerContainer.addInterface( xListener );
160 void SAL_CALL AreaWrapper::removeEventListener(
161 const Reference< lang::XEventListener >& aListener )
162 throw (uno::RuntimeException)
164 m_aEventListenerContainer.removeInterface( aListener );
167 // ================================================================================
169 // WrappedPropertySet
170 Reference< beans::XPropertySet > AreaWrapper::getInnerPropertySet()
172 Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
173 if( xChartDoc.is() )
174 return xChartDoc->getPageBackground();
175 OSL_ENSURE(false,"AreaWrapper::getInnerPropertySet() is NULL");
176 return 0;
179 const Sequence< beans::Property >& AreaWrapper::getPropertySequence()
181 return lcl_GetPropertySequence();
184 const std::vector< WrappedProperty* > AreaWrapper::createWrappedProperties()
186 ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
188 aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U("LineStyle"), C2U("LineStyle") ) );
190 return aWrappedProperties;
193 // ================================================================================
195 Sequence< ::rtl::OUString > AreaWrapper::getSupportedServiceNames_Static()
197 Sequence< ::rtl::OUString > aServices( 4 );
198 aServices[ 0 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" );
199 aServices[ 1 ] = C2U( "com.sun.star.beans.PropertySet" );
200 aServices[ 2 ] = C2U( "com.sun.star.drawing.FillProperties" );
201 aServices[ 3 ] = C2U( "com.sun.star.drawing.LineProperties" );
203 return aServices;
206 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
207 APPHELPER_XSERVICEINFO_IMPL( AreaWrapper, lcl_aServiceName );
209 } // namespace wrapper
210 } // namespace chart