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 "ColumnChartType.hxx"
21 : #include "macros.hxx"
22 : #include "servicenames_charttypes.hxx"
23 : #include "PropertyHelper.hxx"
24 : #include "ContainerHelper.hxx"
25 : #include <com/sun/star/beans/PropertyAttribute.hpp>
26 :
27 : using namespace ::com::sun::star;
28 : using ::com::sun::star::uno::Sequence;
29 : using ::com::sun::star::beans::Property;
30 :
31 : namespace
32 : {
33 :
34 : enum
35 : {
36 : PROP_BARCHARTTYPE_OVERLAP_SEQUENCE,
37 : PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE
38 : };
39 :
40 12 : void lcl_AddPropertiesToVector(
41 : ::std::vector< Property > & rOutProperties )
42 : {
43 : rOutProperties.push_back(
44 : Property( "OverlapSequence",
45 : PROP_BARCHARTTYPE_OVERLAP_SEQUENCE,
46 12 : ::getCppuType( reinterpret_cast< const Sequence< sal_Int32 > * >(0)),
47 : beans::PropertyAttribute::BOUND
48 24 : | beans::PropertyAttribute::MAYBEDEFAULT ));
49 :
50 : rOutProperties.push_back(
51 : Property( "GapwidthSequence",
52 : PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE,
53 12 : ::getCppuType( reinterpret_cast< const Sequence< sal_Int32 > * >(0)),
54 : beans::PropertyAttribute::BOUND
55 24 : | beans::PropertyAttribute::MAYBEDEFAULT ));
56 12 : }
57 :
58 : struct StaticColumnChartTypeDefaults_Initializer
59 : {
60 12 : ::chart::tPropertyValueMap* operator()()
61 : {
62 12 : static ::chart::tPropertyValueMap aStaticDefaults;
63 12 : lcl_AddDefaultsToMap( aStaticDefaults );
64 12 : return &aStaticDefaults;
65 : }
66 : private:
67 12 : void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
68 : {
69 12 : Sequence< sal_Int32 > aSeq(2);
70 :
71 12 : aSeq[0] = aSeq[1] = 0;
72 12 : ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_OVERLAP_SEQUENCE, aSeq );
73 :
74 12 : aSeq[0] = aSeq[1] = 100;
75 12 : ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE, aSeq );
76 12 : }
77 : };
78 :
79 : struct StaticColumnChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticColumnChartTypeDefaults_Initializer >
80 : {
81 : };
82 :
83 : struct StaticColumnChartTypeInfoHelper_Initializer
84 : {
85 12 : ::cppu::OPropertyArrayHelper* operator()()
86 : {
87 12 : static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
88 12 : return &aPropHelper;
89 : }
90 :
91 : private:
92 12 : Sequence< Property > lcl_GetPropertySequence()
93 : {
94 12 : ::std::vector< ::com::sun::star::beans::Property > aProperties;
95 12 : lcl_AddPropertiesToVector( aProperties );
96 :
97 : ::std::sort( aProperties.begin(), aProperties.end(),
98 12 : ::chart::PropertyNameLess() );
99 :
100 12 : return ::chart::ContainerHelper::ContainerToSequence( aProperties );
101 : }
102 :
103 : };
104 :
105 : struct StaticColumnChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticColumnChartTypeInfoHelper_Initializer >
106 : {
107 : };
108 :
109 : struct StaticColumnChartTypeInfo_Initializer
110 : {
111 4 : uno::Reference< beans::XPropertySetInfo >* operator()()
112 : {
113 : static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
114 4 : ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticColumnChartTypeInfoHelper::get() ) );
115 4 : return &xPropertySetInfo;
116 : }
117 : };
118 :
119 : struct StaticColumnChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticColumnChartTypeInfo_Initializer >
120 : {
121 : };
122 :
123 : } // anonymous namespace
124 :
125 : namespace chart
126 : {
127 :
128 14431 : ColumnChartType::ColumnChartType(
129 : const uno::Reference< uno::XComponentContext > & xContext ) :
130 14431 : ChartType( xContext )
131 14431 : {}
132 :
133 0 : ColumnChartType::ColumnChartType( const ColumnChartType & rOther ) :
134 0 : ChartType( rOther )
135 : {
136 0 : }
137 :
138 28690 : ColumnChartType::~ColumnChartType()
139 28690 : {}
140 :
141 : // ____ XCloneable ____
142 0 : uno::Reference< util::XCloneable > SAL_CALL ColumnChartType::createClone()
143 : throw (uno::RuntimeException, std::exception)
144 : {
145 0 : return uno::Reference< util::XCloneable >( new ColumnChartType( *this ));
146 : }
147 :
148 : // ____ XChartType ____
149 86236 : OUString SAL_CALL ColumnChartType::getChartType()
150 : throw (uno::RuntimeException, std::exception)
151 : {
152 86236 : return CHART2_SERVICE_NAME_CHARTTYPE_COLUMN;
153 : }
154 :
155 337 : uno::Sequence< OUString > ColumnChartType::getSupportedPropertyRoles()
156 : throw (uno::RuntimeException, std::exception)
157 : {
158 337 : uno::Sequence< OUString > aPropRoles(2);
159 337 : aPropRoles[0] = "FillColor";
160 337 : aPropRoles[1] = "BorderColor";
161 :
162 337 : return aPropRoles;
163 : }
164 :
165 : // ____ OPropertySet ____
166 1363 : uno::Any ColumnChartType::GetDefaultValue( sal_Int32 nHandle ) const
167 : throw(beans::UnknownPropertyException)
168 : {
169 1363 : const tPropertyValueMap& rStaticDefaults = *StaticColumnChartTypeDefaults::get();
170 1363 : tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
171 1363 : if( aFound == rStaticDefaults.end() )
172 0 : return uno::Any();
173 1363 : return (*aFound).second;
174 : }
175 :
176 5626 : ::cppu::IPropertyArrayHelper & SAL_CALL ColumnChartType::getInfoHelper()
177 : {
178 5626 : return *StaticColumnChartTypeInfoHelper::get();
179 : }
180 :
181 : // ____ XPropertySet ____
182 42 : uno::Reference< beans::XPropertySetInfo > SAL_CALL ColumnChartType::getPropertySetInfo()
183 : throw (uno::RuntimeException, std::exception)
184 : {
185 42 : return *StaticColumnChartTypeInfo::get();
186 : }
187 :
188 14 : uno::Sequence< OUString > ColumnChartType::getSupportedServiceNames_Static()
189 : {
190 14 : uno::Sequence< OUString > aServices( 2 );
191 14 : aServices[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_COLUMN;
192 14 : aServices[ 1 ] = "com.sun.star.chart2.ChartType";
193 14 : return aServices;
194 : }
195 :
196 : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
197 107 : APPHELPER_XSERVICEINFO_IMPL( ColumnChartType,
198 : OUString("com.sun.star.comp.chart.ColumnChartType") );
199 :
200 : } // namespace chart
201 :
202 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|