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 : #include "BubbleChartTypeTemplate.hxx"
21 : #include "macros.hxx"
22 : #include "BubbleDataInterpreter.hxx"
23 : #include "CartesianCoordinateSystem.hxx"
24 : #include "Scaling.hxx"
25 : #include "DiagramHelper.hxx"
26 : #include "servicenames_charttypes.hxx"
27 : #include "ContainerHelper.hxx"
28 : #include "DataSeriesHelper.hxx"
29 : #include <com/sun/star/drawing/LineStyle.hpp>
30 : #include "PropertyHelper.hxx"
31 : #include <com/sun/star/beans/PropertyAttribute.hpp>
32 :
33 : #include <algorithm>
34 :
35 : using namespace ::com::sun::star;
36 :
37 : using ::com::sun::star::uno::Reference;
38 : using ::com::sun::star::uno::Sequence;
39 : using ::com::sun::star::beans::Property;
40 : using ::com::sun::star::uno::Any;
41 : using ::osl::MutexGuard;
42 :
43 : namespace
44 : {
45 :
46 0 : void lcl_AddPropertiesToVector(
47 : ::std::vector< Property > & /*rOutProperties*/ )
48 : {
49 0 : }
50 :
51 : struct StaticBubbleChartTypeTemplateDefaults_Initializer
52 : {
53 0 : ::chart::tPropertyValueMap* operator()()
54 : {
55 0 : static ::chart::tPropertyValueMap aStaticDefaults;
56 0 : return &aStaticDefaults;
57 : }
58 : };
59 :
60 : struct StaticBubbleChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticBubbleChartTypeTemplateDefaults_Initializer >
61 : {
62 : };
63 :
64 : struct StaticBubbleChartTypeTemplateInfoHelper_Initializer
65 : {
66 0 : ::cppu::OPropertyArrayHelper* operator()()
67 : {
68 0 : static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
69 0 : return &aPropHelper;
70 : }
71 :
72 : private:
73 0 : Sequence< Property > lcl_GetPropertySequence()
74 : {
75 0 : ::std::vector< ::com::sun::star::beans::Property > aProperties;
76 0 : lcl_AddPropertiesToVector( aProperties );
77 :
78 : ::std::sort( aProperties.begin(), aProperties.end(),
79 0 : ::chart::PropertyNameLess() );
80 :
81 0 : return ::chart::ContainerHelper::ContainerToSequence( aProperties );
82 : }
83 :
84 : };
85 :
86 : struct StaticBubbleChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticBubbleChartTypeTemplateInfoHelper_Initializer >
87 : {
88 : };
89 :
90 : struct StaticBubbleChartTypeTemplateInfo_Initializer
91 : {
92 0 : uno::Reference< beans::XPropertySetInfo >* operator()()
93 : {
94 : static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
95 0 : ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticBubbleChartTypeTemplateInfoHelper::get() ) );
96 0 : return &xPropertySetInfo;
97 : }
98 : };
99 :
100 : struct StaticBubbleChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticBubbleChartTypeTemplateInfo_Initializer >
101 : {
102 : };
103 :
104 : } // anonymous namespace
105 :
106 : namespace chart
107 : {
108 :
109 1750 : BubbleChartTypeTemplate::BubbleChartTypeTemplate(
110 : Reference<
111 : uno::XComponentContext > const & xContext,
112 : const OUString & rServiceName ) :
113 : ChartTypeTemplate( xContext, rServiceName ),
114 1750 : ::property::OPropertySet( m_aMutex )
115 : {
116 1750 : }
117 :
118 3500 : BubbleChartTypeTemplate::~BubbleChartTypeTemplate()
119 3500 : {}
120 :
121 : // ____ OPropertySet ____
122 0 : uno::Any BubbleChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
123 : throw(beans::UnknownPropertyException)
124 : {
125 0 : const tPropertyValueMap& rStaticDefaults = *StaticBubbleChartTypeTemplateDefaults::get();
126 0 : tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
127 0 : if( aFound == rStaticDefaults.end() )
128 0 : return uno::Any();
129 0 : return (*aFound).second;
130 : }
131 :
132 0 : ::cppu::IPropertyArrayHelper & SAL_CALL BubbleChartTypeTemplate::getInfoHelper()
133 : {
134 0 : return *StaticBubbleChartTypeTemplateInfoHelper::get();
135 : }
136 :
137 : // ____ XPropertySet ____
138 0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL BubbleChartTypeTemplate::getPropertySetInfo()
139 : throw (uno::RuntimeException, std::exception)
140 : {
141 0 : return *StaticBubbleChartTypeTemplateInfo::get();
142 : }
143 :
144 1750 : sal_Int32 BubbleChartTypeTemplate::getDimension() const
145 : {
146 1750 : return 2;
147 : }
148 :
149 0 : StackMode BubbleChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ ) const
150 : {
151 0 : return StackMode_NONE;
152 : }
153 :
154 0 : void SAL_CALL BubbleChartTypeTemplate::applyStyle(
155 : const Reference< chart2::XDataSeries >& xSeries,
156 : ::sal_Int32 nChartTypeIndex,
157 : ::sal_Int32 nSeriesIndex,
158 : ::sal_Int32 nSeriesCount )
159 : throw (uno::RuntimeException, std::exception)
160 : {
161 0 : ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
162 0 : DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::makeAny( drawing::LineStyle_NONE ) );
163 0 : }
164 :
165 : // ____ XChartTypeTemplate ____
166 0 : sal_Bool SAL_CALL BubbleChartTypeTemplate::supportsCategories()
167 : throw (uno::RuntimeException, std::exception)
168 : {
169 0 : return false;
170 : }
171 :
172 0 : Reference< chart2::XChartType > BubbleChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
173 : {
174 0 : Reference< chart2::XChartType > xResult;
175 :
176 : try
177 : {
178 : Reference< lang::XMultiServiceFactory > xFact(
179 0 : GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
180 0 : xResult.set( xFact->createInstance(
181 0 : CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE ), uno::UNO_QUERY_THROW );
182 : }
183 0 : catch( const uno::Exception & ex )
184 : {
185 : ASSERT_EXCEPTION( ex );
186 : }
187 :
188 0 : return xResult;
189 : }
190 :
191 1750 : Reference< chart2::XChartType > SAL_CALL BubbleChartTypeTemplate::getChartTypeForNewSeries(
192 : const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
193 : throw (uno::RuntimeException, std::exception)
194 : {
195 1750 : Reference< chart2::XChartType > xResult;
196 :
197 : try
198 : {
199 : Reference< lang::XMultiServiceFactory > xFact(
200 1750 : GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
201 1750 : xResult.set( xFact->createInstance(
202 1750 : CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE ), uno::UNO_QUERY_THROW );
203 :
204 1750 : ChartTypeTemplate::copyPropertiesFromOldToNewCoordianteSystem( aFormerlyUsedChartTypes, xResult );
205 : }
206 0 : catch( const uno::Exception & ex )
207 : {
208 : ASSERT_EXCEPTION( ex );
209 : }
210 :
211 1750 : return xResult;
212 : }
213 :
214 0 : Reference< chart2::XDataInterpreter > SAL_CALL BubbleChartTypeTemplate::getDataInterpreter()
215 : throw (uno::RuntimeException, std::exception)
216 : {
217 0 : if( ! m_xDataInterpreter.is())
218 0 : m_xDataInterpreter.set( new BubbleDataInterpreter( GetComponentContext()) );
219 :
220 0 : return m_xDataInterpreter;
221 : }
222 :
223 14000 : IMPLEMENT_FORWARD_XINTERFACE2( BubbleChartTypeTemplate, ChartTypeTemplate, OPropertySet )
224 0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( BubbleChartTypeTemplate, ChartTypeTemplate, OPropertySet )
225 :
226 : } // namespace chart
227 :
228 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|