1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_chart2.hxx"
26 #include "ColumnChartType.hxx"
27 #include "macros.hxx"
28 #include "servicenames_charttypes.hxx"
29 #include "PropertyHelper.hxx"
30 #include "ContainerHelper.hxx"
31 #include <com/sun/star/beans/PropertyAttribute.hpp>
32 
33 using namespace ::com::sun::star;
34 using ::com::sun::star::uno::Sequence;
35 using ::com::sun::star::beans::Property;
36 
37 //-----------------------------------------------------------------------------
38 
39 namespace
40 {
41 
42 enum
43 {
44     PROP_BARCHARTTYPE_OVERLAP_SEQUENCE,
45     PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE
46 };
47 
lcl_AddPropertiesToVector(::std::vector<Property> & rOutProperties)48 void lcl_AddPropertiesToVector(
49     ::std::vector< Property > & rOutProperties )
50 {
51     rOutProperties.push_back(
52         Property( C2U( "OverlapSequence" ),
53                   PROP_BARCHARTTYPE_OVERLAP_SEQUENCE,
54                   ::getCppuType( reinterpret_cast< const Sequence< sal_Int32 > * >(0)),
55                   beans::PropertyAttribute::BOUND
56                   | beans::PropertyAttribute::MAYBEDEFAULT ));
57 
58     rOutProperties.push_back(
59         Property( C2U( "GapwidthSequence" ),
60                   PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE,
61                   ::getCppuType( reinterpret_cast< const Sequence< sal_Int32 > * >(0)),
62                   beans::PropertyAttribute::BOUND
63                   | beans::PropertyAttribute::MAYBEDEFAULT ));
64 }
65 
66 struct StaticColumnChartTypeDefaults_Initializer
67 {
operator ()__anonfb4aa4770111::StaticColumnChartTypeDefaults_Initializer68     ::chart::tPropertyValueMap* operator()()
69     {
70         static ::chart::tPropertyValueMap aStaticDefaults;
71         lcl_AddDefaultsToMap( aStaticDefaults );
72         return &aStaticDefaults;
73     }
74 private:
lcl_AddDefaultsToMap__anonfb4aa4770111::StaticColumnChartTypeDefaults_Initializer75     void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
76     {
77         Sequence< sal_Int32 > aSeq(2);
78 
79         aSeq[0] = aSeq[1] = 0;
80         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_OVERLAP_SEQUENCE, aSeq );
81 
82         aSeq[0] = aSeq[1] = 100;
83         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE, aSeq );
84     }
85 };
86 
87 struct StaticColumnChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticColumnChartTypeDefaults_Initializer >
88 {
89 };
90 
91 struct StaticColumnChartTypeInfoHelper_Initializer
92 {
operator ()__anonfb4aa4770111::StaticColumnChartTypeInfoHelper_Initializer93     ::cppu::OPropertyArrayHelper* operator()()
94     {
95         static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
96         return &aPropHelper;
97     }
98 
99 private:
lcl_GetPropertySequence__anonfb4aa4770111::StaticColumnChartTypeInfoHelper_Initializer100     Sequence< Property > lcl_GetPropertySequence()
101     {
102         ::std::vector< ::com::sun::star::beans::Property > aProperties;
103         lcl_AddPropertiesToVector( aProperties );
104 
105         ::std::sort( aProperties.begin(), aProperties.end(),
106                      ::chart::PropertyNameLess() );
107 
108         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
109     }
110 
111 };
112 
113 struct StaticColumnChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticColumnChartTypeInfoHelper_Initializer >
114 {
115 };
116 
117 struct StaticColumnChartTypeInfo_Initializer
118 {
operator ()__anonfb4aa4770111::StaticColumnChartTypeInfo_Initializer119     uno::Reference< beans::XPropertySetInfo >* operator()()
120     {
121         static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
122             ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticColumnChartTypeInfoHelper::get() ) );
123         return &xPropertySetInfo;
124     }
125 };
126 
127 struct StaticColumnChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticColumnChartTypeInfo_Initializer >
128 {
129 };
130 
131 } // anonymous namespace
132 
133 namespace chart
134 {
135 
ColumnChartType(const uno::Reference<uno::XComponentContext> & xContext)136 ColumnChartType::ColumnChartType(
137     const uno::Reference< uno::XComponentContext > & xContext ) :
138         ChartType( xContext )
139 {}
140 
ColumnChartType(const ColumnChartType & rOther)141 ColumnChartType::ColumnChartType( const ColumnChartType & rOther ) :
142         ChartType( rOther )
143 {
144 }
145 
~ColumnChartType()146 ColumnChartType::~ColumnChartType()
147 {}
148 
149 // ____ XCloneable ____
createClone()150 uno::Reference< util::XCloneable > SAL_CALL ColumnChartType::createClone()
151     throw (uno::RuntimeException)
152 {
153     return uno::Reference< util::XCloneable >( new ColumnChartType( *this ));
154 }
155 
156 // ____ XChartType ____
getChartType()157 ::rtl::OUString SAL_CALL ColumnChartType::getChartType()
158     throw (uno::RuntimeException)
159 {
160     return CHART2_SERVICE_NAME_CHARTTYPE_COLUMN;
161 }
162 
163 // ____ OPropertySet ____
GetDefaultValue(sal_Int32 nHandle) const164 uno::Any ColumnChartType::GetDefaultValue( sal_Int32 nHandle ) const
165     throw(beans::UnknownPropertyException)
166 {
167     const tPropertyValueMap& rStaticDefaults = *StaticColumnChartTypeDefaults::get();
168     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
169     if( aFound == rStaticDefaults.end() )
170         return uno::Any();
171     return (*aFound).second;
172 }
173 
getInfoHelper()174 ::cppu::IPropertyArrayHelper & SAL_CALL ColumnChartType::getInfoHelper()
175 {
176     return *StaticColumnChartTypeInfoHelper::get();
177 }
178 
179 // ____ XPropertySet ____
getPropertySetInfo()180 uno::Reference< beans::XPropertySetInfo > SAL_CALL ColumnChartType::getPropertySetInfo()
181     throw (uno::RuntimeException)
182 {
183     return *StaticColumnChartTypeInfo::get();
184 }
185 
186 //
187 
getSupportedServiceNames_Static()188 uno::Sequence< ::rtl::OUString > ColumnChartType::getSupportedServiceNames_Static()
189 {
190     uno::Sequence< ::rtl::OUString > aServices( 2 );
191     aServices[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_COLUMN;
192     aServices[ 1 ] = C2U( "com.sun.star.chart2.ChartType" );
193     return aServices;
194 }
195 
196 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
197 APPHELPER_XSERVICEINFO_IMPL( ColumnChartType,
198                              C2U( "com.sun.star.comp.chart.ColumnChartType" ));
199 
200 } //  namespace chart
201