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