fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / controller / chartapiwrapper / AreaWrapper.cxx
blobceddbafaeca2e7f6c37abb059280ad1c9bef1081
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 "AreaWrapper.hxx"
21 #include "macros.hxx"
22 #include "ContainerHelper.hxx"
23 #include "Chart2ModelContact.hxx"
24 #include "WrappedDirectStateProperty.hxx"
25 #include <comphelper/InlineContainer.hxx>
26 #include <com/sun/star/drawing/FillStyle.hpp>
27 #include <cppuhelper/supportsservice.hxx>
29 #include "LinePropertiesHelper.hxx"
30 #include "FillProperties.hxx"
31 #include "UserDefinedProperties.hxx"
33 #include <algorithm>
35 using namespace ::com::sun::star;
36 using ::com::sun::star::beans::Property;
37 using ::osl::MutexGuard;
38 using ::com::sun::star::uno::Any;
39 using ::com::sun::star::uno::Reference;
40 using ::com::sun::star::uno::Sequence;
42 namespace
44 static const char lcl_aServiceName[] = "com.sun.star.comp.chart.Area";
46 struct StaticAreaWrapperPropertyArray_Initializer
48 Sequence< Property >* operator()()
50 static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
51 return &aPropSeq;
54 private:
55 static Sequence< Property > lcl_GetPropertySequence()
57 ::std::vector< ::com::sun::star::beans::Property > aProperties;
58 ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
59 ::chart::FillProperties::AddPropertiesToVector( aProperties );
60 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
62 ::std::sort( aProperties.begin(), aProperties.end(),
63 ::chart::PropertyNameLess() );
65 return ::chart::ContainerHelper::ContainerToSequence( aProperties );
69 struct StaticAreaWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticAreaWrapperPropertyArray_Initializer >
73 } // anonymous namespace
75 namespace chart
77 namespace wrapper
80 AreaWrapper::AreaWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
81 m_spChart2ModelContact( spChart2ModelContact ),
82 m_aEventListenerContainer( m_aMutex )
86 AreaWrapper::~AreaWrapper()
89 // ____ XShape ____
90 awt::Point SAL_CALL AreaWrapper::getPosition()
91 throw (uno::RuntimeException, std::exception)
93 return awt::Point(0,0);
96 void SAL_CALL AreaWrapper::setPosition( const awt::Point& /*aPosition*/ )
97 throw (uno::RuntimeException, std::exception)
99 OSL_FAIL( "trying to set position of chart area" );
102 awt::Size SAL_CALL AreaWrapper::getSize()
103 throw (uno::RuntimeException, std::exception)
105 return m_spChart2ModelContact->GetPageSize();
108 void SAL_CALL AreaWrapper::setSize( const awt::Size& /*aSize*/ )
109 throw (beans::PropertyVetoException,
110 uno::RuntimeException, std::exception)
112 OSL_FAIL( "trying to set size of chart area" );
115 // ____ XShapeDescriptor (base of XShape) ____
116 OUString SAL_CALL AreaWrapper::getShapeType()
117 throw (uno::RuntimeException, std::exception)
119 return OUString( "com.sun.star.chart.ChartArea" );
122 // ____ XComponent ____
123 void SAL_CALL AreaWrapper::dispose()
124 throw (uno::RuntimeException, std::exception)
126 Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
127 m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
129 MutexGuard aGuard( GetMutex());
130 clearWrappedPropertySet();
133 void SAL_CALL AreaWrapper::addEventListener(
134 const Reference< lang::XEventListener >& xListener )
135 throw (uno::RuntimeException, std::exception)
137 m_aEventListenerContainer.addInterface( xListener );
140 void SAL_CALL AreaWrapper::removeEventListener(
141 const Reference< lang::XEventListener >& aListener )
142 throw (uno::RuntimeException, std::exception)
144 m_aEventListenerContainer.removeInterface( aListener );
147 // WrappedPropertySet
148 Reference< beans::XPropertySet > AreaWrapper::getInnerPropertySet()
150 Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
151 if( xChartDoc.is() )
152 return xChartDoc->getPageBackground();
153 OSL_FAIL("AreaWrapper::getInnerPropertySet() is NULL");
154 return 0;
157 const Sequence< beans::Property >& AreaWrapper::getPropertySequence()
159 return *StaticAreaWrapperPropertyArray::get();
162 const std::vector< WrappedProperty* > AreaWrapper::createWrappedProperties()
164 ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
166 aWrappedProperties.push_back( new WrappedDirectStateProperty("LineStyle","LineStyle") );
168 return aWrappedProperties;
171 Sequence< OUString > AreaWrapper::getSupportedServiceNames_Static()
173 Sequence< OUString > aServices( 4 );
174 aServices[ 0 ] = "com.sun.star.xml.UserDefinedAttributesSupplier";
175 aServices[ 1 ] = "com.sun.star.beans.PropertySet";
176 aServices[ 2 ] = "com.sun.star.drawing.FillProperties";
177 aServices[ 3 ] = "com.sun.star.drawing.LineProperties";
179 return aServices;
182 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
183 OUString SAL_CALL AreaWrapper::getImplementationName()
184 throw( css::uno::RuntimeException, std::exception )
186 return getImplementationName_Static();
189 OUString AreaWrapper::getImplementationName_Static()
191 return OUString(lcl_aServiceName);
194 sal_Bool SAL_CALL AreaWrapper::supportsService( const OUString& rServiceName )
195 throw( css::uno::RuntimeException, std::exception )
197 return cppu::supportsService(this, rServiceName);
200 css::uno::Sequence< OUString > SAL_CALL AreaWrapper::getSupportedServiceNames()
201 throw( css::uno::RuntimeException, std::exception )
203 return getSupportedServiceNames_Static();
206 } // namespace wrapper
207 } // namespace chart
209 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */