Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include "AreaWrapper.hxx"
22 : #include "macros.hxx"
23 : #include "ContainerHelper.hxx"
24 : #include "Chart2ModelContact.hxx"
25 : #include "WrappedDirectStateProperty.hxx"
26 : #include <comphelper/InlineContainer.hxx>
27 : #include <com/sun/star/drawing/FillStyle.hpp>
28 :
29 : #include "LineProperties.hxx"
30 : #include "FillProperties.hxx"
31 : #include "UserDefinedProperties.hxx"
32 :
33 : #include <algorithm>
34 :
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;
41 :
42 : //-----------------------------------------------------------------------------
43 : //-----------------------------------------------------------------------------
44 :
45 : namespace
46 : {
47 1 : static const ::rtl::OUString lcl_aServiceName(
48 : RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Area" ));
49 :
50 : struct StaticAreaWrapperPropertyArray_Initializer
51 : {
52 0 : Sequence< Property >* operator()()
53 : {
54 0 : static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
55 0 : return &aPropSeq;
56 : }
57 :
58 : private:
59 0 : Sequence< Property > lcl_GetPropertySequence()
60 : {
61 0 : ::std::vector< ::com::sun::star::beans::Property > aProperties;
62 0 : ::chart::LineProperties::AddPropertiesToVector( aProperties );
63 0 : ::chart::FillProperties::AddPropertiesToVector( aProperties );
64 0 : ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
65 :
66 : ::std::sort( aProperties.begin(), aProperties.end(),
67 0 : ::chart::PropertyNameLess() );
68 :
69 0 : return ::chart::ContainerHelper::ContainerToSequence( aProperties );
70 : }
71 : };
72 :
73 : struct StaticAreaWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticAreaWrapperPropertyArray_Initializer >
74 : {
75 : };
76 :
77 :
78 : } // anonymous namespace
79 :
80 : // --------------------------------------------------------------------------------
81 : // --------------------------------------------------------------------------------
82 :
83 : namespace chart
84 : {
85 : namespace wrapper
86 : {
87 :
88 0 : AreaWrapper::AreaWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
89 : m_spChart2ModelContact( spChart2ModelContact ),
90 0 : m_aEventListenerContainer( m_aMutex )
91 : {
92 0 : }
93 :
94 0 : AreaWrapper::~AreaWrapper()
95 0 : {}
96 :
97 : // ____ XShape ____
98 0 : awt::Point SAL_CALL AreaWrapper::getPosition()
99 : throw (uno::RuntimeException)
100 : {
101 0 : return awt::Point(0,0);
102 : }
103 :
104 0 : void SAL_CALL AreaWrapper::setPosition( const awt::Point& /*aPosition*/ )
105 : throw (uno::RuntimeException)
106 : {
107 : OSL_FAIL( "trying to set position of chart area" );
108 0 : }
109 :
110 0 : awt::Size SAL_CALL AreaWrapper::getSize()
111 : throw (uno::RuntimeException)
112 : {
113 0 : return m_spChart2ModelContact->GetPageSize();
114 : }
115 :
116 0 : void SAL_CALL AreaWrapper::setSize( const awt::Size& /*aSize*/ )
117 : throw (beans::PropertyVetoException,
118 : uno::RuntimeException)
119 : {
120 : OSL_FAIL( "trying to set size of chart area" );
121 0 : }
122 :
123 : // ____ XShapeDescriptor (base of XShape) ____
124 0 : ::rtl::OUString SAL_CALL AreaWrapper::getShapeType()
125 : throw (uno::RuntimeException)
126 : {
127 0 : return rtl::OUString( "com.sun.star.chart.ChartArea" );
128 : }
129 :
130 : // ____ XComponent ____
131 0 : void SAL_CALL AreaWrapper::dispose()
132 : throw (uno::RuntimeException)
133 : {
134 0 : Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
135 0 : m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
136 :
137 0 : MutexGuard aGuard( GetMutex());
138 0 : clearWrappedPropertySet();
139 0 : }
140 :
141 0 : void SAL_CALL AreaWrapper::addEventListener(
142 : const Reference< lang::XEventListener >& xListener )
143 : throw (uno::RuntimeException)
144 : {
145 0 : m_aEventListenerContainer.addInterface( xListener );
146 0 : }
147 :
148 0 : void SAL_CALL AreaWrapper::removeEventListener(
149 : const Reference< lang::XEventListener >& aListener )
150 : throw (uno::RuntimeException)
151 : {
152 0 : m_aEventListenerContainer.removeInterface( aListener );
153 0 : }
154 :
155 : // ================================================================================
156 :
157 : // WrappedPropertySet
158 0 : Reference< beans::XPropertySet > AreaWrapper::getInnerPropertySet()
159 : {
160 0 : Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
161 0 : if( xChartDoc.is() )
162 0 : return xChartDoc->getPageBackground();
163 : OSL_FAIL("AreaWrapper::getInnerPropertySet() is NULL");
164 0 : return 0;
165 : }
166 :
167 0 : const Sequence< beans::Property >& AreaWrapper::getPropertySequence()
168 : {
169 0 : return *StaticAreaWrapperPropertyArray::get();
170 : }
171 :
172 0 : const std::vector< WrappedProperty* > AreaWrapper::createWrappedProperties()
173 : {
174 0 : ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
175 :
176 0 : aWrappedProperties.push_back( new WrappedDirectStateProperty("LineStyle","LineStyle") );
177 :
178 0 : return aWrappedProperties;
179 : }
180 :
181 : // ================================================================================
182 :
183 0 : Sequence< ::rtl::OUString > AreaWrapper::getSupportedServiceNames_Static()
184 : {
185 0 : Sequence< ::rtl::OUString > aServices( 4 );
186 0 : aServices[ 0 ] = "com.sun.star.xml.UserDefinedAttributesSupplier";
187 0 : aServices[ 1 ] = "com.sun.star.beans.PropertySet";
188 0 : aServices[ 2 ] = "com.sun.star.drawing.FillProperties";
189 0 : aServices[ 3 ] = "com.sun.star.drawing.LineProperties";
190 :
191 0 : return aServices;
192 : }
193 :
194 : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
195 0 : APPHELPER_XSERVICEINFO_IMPL( AreaWrapper, lcl_aServiceName );
196 :
197 : } // namespace wrapper
198 3 : } // namespace chart
199 :
200 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|