Branch data 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 : 16 : static const ::rtl::OUString lcl_aServiceName(
48 : : RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Area" ));
49 : :
50 : : struct StaticAreaWrapperPropertyArray_Initializer
51 : : {
52 : 7 : Sequence< Property >* operator()()
53 : : {
54 [ + - ][ + - ]: 7 : static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
[ + - ][ # # ]
55 : 7 : return &aPropSeq;
56 : : }
57 : :
58 : : private:
59 : 7 : Sequence< Property > lcl_GetPropertySequence()
60 : : {
61 [ + - ]: 7 : ::std::vector< ::com::sun::star::beans::Property > aProperties;
62 [ + - ]: 7 : ::chart::LineProperties::AddPropertiesToVector( aProperties );
63 [ + - ]: 7 : ::chart::FillProperties::AddPropertiesToVector( aProperties );
64 [ + - ]: 7 : ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
65 : :
66 : : ::std::sort( aProperties.begin(), aProperties.end(),
67 [ + - ]: 7 : ::chart::PropertyNameLess() );
68 : :
69 [ + - ]: 7 : 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 : 15 : AreaWrapper::AreaWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
89 : : m_spChart2ModelContact( spChart2ModelContact ),
90 [ + - ][ + - ]: 15 : m_aEventListenerContainer( m_aMutex )
91 : : {
92 : 15 : }
93 : :
94 [ + - ][ + - ]: 15 : AreaWrapper::~AreaWrapper()
95 [ - + ]: 30 : {}
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 : 15 : void SAL_CALL AreaWrapper::dispose()
132 : : throw (uno::RuntimeException)
133 : : {
134 [ + - ]: 15 : Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
135 [ + - ][ + - ]: 15 : m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
[ + - ]
136 : :
137 [ + - ][ + - ]: 15 : MutexGuard aGuard( GetMutex());
138 [ + - ][ + - ]: 15 : clearWrappedPropertySet();
139 : 15 : }
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 : 680 : Reference< beans::XPropertySet > AreaWrapper::getInnerPropertySet()
159 : : {
160 [ + - ]: 680 : Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
161 [ + - ]: 680 : if( xChartDoc.is() )
162 [ + - ][ + - ]: 680 : return xChartDoc->getPageBackground();
163 : : OSL_FAIL("AreaWrapper::getInnerPropertySet() is NULL");
164 [ # # ]: 680 : return 0;
165 : : }
166 : :
167 : 13 : const Sequence< beans::Property >& AreaWrapper::getPropertySequence()
168 : : {
169 : 13 : return *StaticAreaWrapperPropertyArray::get();
170 : : }
171 : :
172 : 13 : const std::vector< WrappedProperty* > AreaWrapper::createWrappedProperties()
173 : : {
174 : 13 : ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
175 : :
176 [ + - ][ + - ]: 13 : aWrappedProperties.push_back( new WrappedDirectStateProperty("LineStyle","LineStyle") );
[ + - ]
177 : :
178 : 13 : return aWrappedProperties;
179 : : }
180 : :
181 : : // ================================================================================
182 : :
183 : 4 : Sequence< ::rtl::OUString > AreaWrapper::getSupportedServiceNames_Static()
184 : : {
185 : 4 : Sequence< ::rtl::OUString > aServices( 4 );
186 [ + - ]: 4 : aServices[ 0 ] = "com.sun.star.xml.UserDefinedAttributeSupplier";
187 [ + - ]: 4 : aServices[ 1 ] = "com.sun.star.beans.PropertySet";
188 [ + - ]: 4 : aServices[ 2 ] = "com.sun.star.drawing.FillProperties";
189 [ + - ]: 4 : aServices[ 3 ] = "com.sun.star.drawing.LineProperties";
190 : :
191 : 4 : return aServices;
192 : : }
193 : :
194 : : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
195 [ + - ][ + - ]: 18 : APPHELPER_XSERVICEINFO_IMPL( AreaWrapper, lcl_aServiceName );
[ + + ][ + - ]
[ + - ]
196 : :
197 : : } // namespace wrapper
198 [ + - ][ + - ]: 48 : } // namespace chart
199 : :
200 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|