xref: /trunk/main/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1*cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*cde9e8dcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*cde9e8dcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*cde9e8dcSAndrew Rist  * distributed with this work for additional information
6*cde9e8dcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*cde9e8dcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*cde9e8dcSAndrew Rist  * "License"); you may not use this file except in compliance
9*cde9e8dcSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*cde9e8dcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*cde9e8dcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*cde9e8dcSAndrew Rist  * software distributed under the License is distributed on an
15*cde9e8dcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*cde9e8dcSAndrew Rist  * KIND, either express or implied.  See the License for the
17*cde9e8dcSAndrew Rist  * specific language governing permissions and limitations
18*cde9e8dcSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*cde9e8dcSAndrew Rist  *************************************************************/
21*cde9e8dcSAndrew Rist 
22*cde9e8dcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "AreaWrapper.hxx"
28cdf0e10cSrcweir #include "macros.hxx"
29cdf0e10cSrcweir #include "ContainerHelper.hxx"
30cdf0e10cSrcweir #include "Chart2ModelContact.hxx"
31cdf0e10cSrcweir #include "WrappedDirectStateProperty.hxx"
32cdf0e10cSrcweir #include <comphelper/InlineContainer.hxx>
33cdf0e10cSrcweir #include <com/sun/star/drawing/FillStyle.hpp>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include "LineProperties.hxx"
36cdf0e10cSrcweir #include "FillProperties.hxx"
37cdf0e10cSrcweir #include "UserDefinedProperties.hxx"
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <algorithm>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir using namespace ::com::sun::star;
42cdf0e10cSrcweir using ::com::sun::star::beans::Property;
43cdf0e10cSrcweir using ::osl::MutexGuard;
44cdf0e10cSrcweir using ::com::sun::star::uno::Any;
45cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
46cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir //-----------------------------------------------------------------------------
49cdf0e10cSrcweir //-----------------------------------------------------------------------------
50cdf0e10cSrcweir 
51cdf0e10cSrcweir namespace
52cdf0e10cSrcweir {
53cdf0e10cSrcweir static const ::rtl::OUString lcl_aServiceName(
54cdf0e10cSrcweir     RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Area" ));
55cdf0e10cSrcweir 
56cdf0e10cSrcweir struct StaticAreaWrapperPropertyArray_Initializer
57cdf0e10cSrcweir {
operator ()__anondd6d84530111::StaticAreaWrapperPropertyArray_Initializer58cdf0e10cSrcweir     Sequence< Property >* operator()()
59cdf0e10cSrcweir     {
60cdf0e10cSrcweir         static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
61cdf0e10cSrcweir         return &aPropSeq;
62cdf0e10cSrcweir     }
63cdf0e10cSrcweir 
64cdf0e10cSrcweir private:
lcl_GetPropertySequence__anondd6d84530111::StaticAreaWrapperPropertyArray_Initializer65cdf0e10cSrcweir     Sequence< Property > lcl_GetPropertySequence()
66cdf0e10cSrcweir     {
67cdf0e10cSrcweir         ::std::vector< ::com::sun::star::beans::Property > aProperties;
68cdf0e10cSrcweir         ::chart::LineProperties::AddPropertiesToVector( aProperties );
69cdf0e10cSrcweir         ::chart::FillProperties::AddPropertiesToVector( aProperties );
70cdf0e10cSrcweir         //::chart::NamedProperties::AddPropertiesToVector( aProperties );
71cdf0e10cSrcweir         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
72cdf0e10cSrcweir 
73cdf0e10cSrcweir         ::std::sort( aProperties.begin(), aProperties.end(),
74cdf0e10cSrcweir                      ::chart::PropertyNameLess() );
75cdf0e10cSrcweir 
76cdf0e10cSrcweir         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
77cdf0e10cSrcweir     }
78cdf0e10cSrcweir };
79cdf0e10cSrcweir 
80cdf0e10cSrcweir struct StaticAreaWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticAreaWrapperPropertyArray_Initializer >
81cdf0e10cSrcweir {
82cdf0e10cSrcweir };
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 
85cdf0e10cSrcweir } // anonymous namespace
86cdf0e10cSrcweir 
87cdf0e10cSrcweir // --------------------------------------------------------------------------------
88cdf0e10cSrcweir // --------------------------------------------------------------------------------
89cdf0e10cSrcweir 
90cdf0e10cSrcweir namespace chart
91cdf0e10cSrcweir {
92cdf0e10cSrcweir namespace wrapper
93cdf0e10cSrcweir {
94cdf0e10cSrcweir 
AreaWrapper(::boost::shared_ptr<Chart2ModelContact> spChart2ModelContact)95cdf0e10cSrcweir AreaWrapper::AreaWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
96cdf0e10cSrcweir         m_spChart2ModelContact( spChart2ModelContact ),
97cdf0e10cSrcweir         m_aEventListenerContainer( m_aMutex )
98cdf0e10cSrcweir {
99cdf0e10cSrcweir }
100cdf0e10cSrcweir 
~AreaWrapper()101cdf0e10cSrcweir AreaWrapper::~AreaWrapper()
102cdf0e10cSrcweir {}
103cdf0e10cSrcweir 
104cdf0e10cSrcweir // ____ XShape ____
getPosition()105cdf0e10cSrcweir awt::Point SAL_CALL AreaWrapper::getPosition()
106cdf0e10cSrcweir     throw (uno::RuntimeException)
107cdf0e10cSrcweir {
108cdf0e10cSrcweir     return awt::Point(0,0);
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
setPosition(const awt::Point &)111cdf0e10cSrcweir void SAL_CALL AreaWrapper::setPosition( const awt::Point& /*aPosition*/ )
112cdf0e10cSrcweir     throw (uno::RuntimeException)
113cdf0e10cSrcweir {
114cdf0e10cSrcweir     OSL_ENSURE( false, "trying to set position of chart area" );
115cdf0e10cSrcweir }
116cdf0e10cSrcweir 
getSize()117cdf0e10cSrcweir awt::Size SAL_CALL AreaWrapper::getSize()
118cdf0e10cSrcweir     throw (uno::RuntimeException)
119cdf0e10cSrcweir {
120cdf0e10cSrcweir     return m_spChart2ModelContact->GetPageSize();
121cdf0e10cSrcweir }
122cdf0e10cSrcweir 
setSize(const awt::Size &)123cdf0e10cSrcweir void SAL_CALL AreaWrapper::setSize( const awt::Size& /*aSize*/ )
124cdf0e10cSrcweir     throw (beans::PropertyVetoException,
125cdf0e10cSrcweir            uno::RuntimeException)
126cdf0e10cSrcweir {
127cdf0e10cSrcweir     OSL_ENSURE( false, "trying to set size of chart area" );
128cdf0e10cSrcweir }
129cdf0e10cSrcweir 
130cdf0e10cSrcweir // ____ XShapeDescriptor (base of XShape) ____
getShapeType()131cdf0e10cSrcweir ::rtl::OUString SAL_CALL AreaWrapper::getShapeType()
132cdf0e10cSrcweir     throw (uno::RuntimeException)
133cdf0e10cSrcweir {
134cdf0e10cSrcweir     return C2U( "com.sun.star.chart.ChartArea" );
135cdf0e10cSrcweir }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir // ____ XComponent ____
dispose()138cdf0e10cSrcweir void SAL_CALL AreaWrapper::dispose()
139cdf0e10cSrcweir     throw (uno::RuntimeException)
140cdf0e10cSrcweir {
141cdf0e10cSrcweir     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
142cdf0e10cSrcweir     m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     // /--
145cdf0e10cSrcweir     MutexGuard aGuard( GetMutex());
146cdf0e10cSrcweir     clearWrappedPropertySet();
147cdf0e10cSrcweir     // \--
148cdf0e10cSrcweir }
149cdf0e10cSrcweir 
addEventListener(const Reference<lang::XEventListener> & xListener)150cdf0e10cSrcweir void SAL_CALL AreaWrapper::addEventListener(
151cdf0e10cSrcweir     const Reference< lang::XEventListener >& xListener )
152cdf0e10cSrcweir     throw (uno::RuntimeException)
153cdf0e10cSrcweir {
154cdf0e10cSrcweir     m_aEventListenerContainer.addInterface( xListener );
155cdf0e10cSrcweir }
156cdf0e10cSrcweir 
removeEventListener(const Reference<lang::XEventListener> & aListener)157cdf0e10cSrcweir void SAL_CALL AreaWrapper::removeEventListener(
158cdf0e10cSrcweir     const Reference< lang::XEventListener >& aListener )
159cdf0e10cSrcweir     throw (uno::RuntimeException)
160cdf0e10cSrcweir {
161cdf0e10cSrcweir     m_aEventListenerContainer.removeInterface( aListener );
162cdf0e10cSrcweir }
163cdf0e10cSrcweir 
164cdf0e10cSrcweir // ================================================================================
165cdf0e10cSrcweir 
166cdf0e10cSrcweir // WrappedPropertySet
getInnerPropertySet()167cdf0e10cSrcweir Reference< beans::XPropertySet > AreaWrapper::getInnerPropertySet()
168cdf0e10cSrcweir {
169cdf0e10cSrcweir     Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
170cdf0e10cSrcweir     if( xChartDoc.is() )
171cdf0e10cSrcweir         return xChartDoc->getPageBackground();
172cdf0e10cSrcweir     OSL_ENSURE(false,"AreaWrapper::getInnerPropertySet() is NULL");
173cdf0e10cSrcweir     return 0;
174cdf0e10cSrcweir }
175cdf0e10cSrcweir 
getPropertySequence()176cdf0e10cSrcweir const Sequence< beans::Property >& AreaWrapper::getPropertySequence()
177cdf0e10cSrcweir {
178cdf0e10cSrcweir     return *StaticAreaWrapperPropertyArray::get();
179cdf0e10cSrcweir }
180cdf0e10cSrcweir 
createWrappedProperties()181cdf0e10cSrcweir const std::vector< WrappedProperty* > AreaWrapper::createWrappedProperties()
182cdf0e10cSrcweir {
183cdf0e10cSrcweir     ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
184cdf0e10cSrcweir 
185cdf0e10cSrcweir     aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U("LineStyle"), C2U("LineStyle") ) );
186cdf0e10cSrcweir 
187cdf0e10cSrcweir     return aWrappedProperties;
188cdf0e10cSrcweir }
189cdf0e10cSrcweir 
190cdf0e10cSrcweir // ================================================================================
191cdf0e10cSrcweir 
getSupportedServiceNames_Static()192cdf0e10cSrcweir Sequence< ::rtl::OUString > AreaWrapper::getSupportedServiceNames_Static()
193cdf0e10cSrcweir {
194cdf0e10cSrcweir     Sequence< ::rtl::OUString > aServices( 4 );
195cdf0e10cSrcweir     aServices[ 0 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" );
196cdf0e10cSrcweir     aServices[ 1 ] = C2U( "com.sun.star.beans.PropertySet" );
197cdf0e10cSrcweir     aServices[ 2 ] = C2U( "com.sun.star.drawing.FillProperties" );
198cdf0e10cSrcweir     aServices[ 3 ] = C2U( "com.sun.star.drawing.LineProperties" );
199cdf0e10cSrcweir 
200cdf0e10cSrcweir     return aServices;
201cdf0e10cSrcweir }
202cdf0e10cSrcweir 
203cdf0e10cSrcweir // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
204cdf0e10cSrcweir APPHELPER_XSERVICEINFO_IMPL( AreaWrapper, lcl_aServiceName );
205cdf0e10cSrcweir 
206cdf0e10cSrcweir } //  namespace wrapper
207cdf0e10cSrcweir } //  namespace chart
208