1*cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*cde9e8dcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*cde9e8dcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*cde9e8dcSAndrew Rist  * distributed with this work for additional information
6*cde9e8dcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*cde9e8dcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*cde9e8dcSAndrew Rist  * "License"); you may not use this file except in compliance
9*cde9e8dcSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*cde9e8dcSAndrew Rist  *
11*cde9e8dcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*cde9e8dcSAndrew Rist  *
13*cde9e8dcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*cde9e8dcSAndrew Rist  * software distributed under the License is distributed on an
15*cde9e8dcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*cde9e8dcSAndrew Rist  * KIND, either express or implied.  See the License for the
17*cde9e8dcSAndrew Rist  * specific language governing permissions and limitations
18*cde9e8dcSAndrew Rist  * under the License.
19*cde9e8dcSAndrew Rist  *
20*cde9e8dcSAndrew Rist  *************************************************************/
21*cde9e8dcSAndrew Rist 
22*cde9e8dcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir #include "ColumnLineChartTypeTemplate.hxx"
27cdf0e10cSrcweir #include "macros.hxx"
28cdf0e10cSrcweir #include "CommonConverters.hxx"
29cdf0e10cSrcweir #include "DiagramHelper.hxx"
30cdf0e10cSrcweir #include "DataSeriesHelper.hxx"
31cdf0e10cSrcweir #include "servicenames_charttypes.hxx"
32cdf0e10cSrcweir #include "ColumnLineDataInterpreter.hxx"
33cdf0e10cSrcweir #include "ContainerHelper.hxx"
34cdf0e10cSrcweir #include "PropertyHelper.hxx"
35cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
36cdf0e10cSrcweir #include <com/sun/star/chart2/XChartTypeContainer.hpp>
37cdf0e10cSrcweir #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
38cdf0e10cSrcweir #include <com/sun/star/drawing/LineStyle.hpp>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include <algorithm>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir using namespace ::com::sun::star::chart2;
43cdf0e10cSrcweir using namespace ::com::sun::star;
44cdf0e10cSrcweir 
45cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
46cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
47cdf0e10cSrcweir using ::rtl::OUString;
48cdf0e10cSrcweir using ::com::sun::star::beans::Property;
49cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
50cdf0e10cSrcweir using ::com::sun::star::uno::Any;
51cdf0e10cSrcweir using ::osl::MutexGuard;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir namespace
54cdf0e10cSrcweir {
55cdf0e10cSrcweir 
56cdf0e10cSrcweir static const ::rtl::OUString lcl_aServiceName(
57cdf0e10cSrcweir     RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.ColumnLineChartTypeTemplate" ));
58cdf0e10cSrcweir 
59cdf0e10cSrcweir enum
60cdf0e10cSrcweir {
61cdf0e10cSrcweir     PROP_COL_LINE_NUMBER_OF_LINES
62cdf0e10cSrcweir };
63cdf0e10cSrcweir 
lcl_AddPropertiesToVector(::std::vector<Property> & rOutProperties)64cdf0e10cSrcweir void lcl_AddPropertiesToVector(
65cdf0e10cSrcweir     ::std::vector< Property > & rOutProperties )
66cdf0e10cSrcweir {
67cdf0e10cSrcweir     rOutProperties.push_back(
68cdf0e10cSrcweir         Property( C2U( "NumberOfLines" ),
69cdf0e10cSrcweir                   PROP_COL_LINE_NUMBER_OF_LINES,
70cdf0e10cSrcweir                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
71cdf0e10cSrcweir                   beans::PropertyAttribute::BOUND
72cdf0e10cSrcweir                   | beans::PropertyAttribute::MAYBEDEFAULT ));
73cdf0e10cSrcweir }
74cdf0e10cSrcweir 
75cdf0e10cSrcweir struct StaticColumnLineChartTypeTemplateDefaults_Initializer
76cdf0e10cSrcweir {
operator ()__anona02556730111::StaticColumnLineChartTypeTemplateDefaults_Initializer77cdf0e10cSrcweir     ::chart::tPropertyValueMap* operator()()
78cdf0e10cSrcweir     {
79cdf0e10cSrcweir         static ::chart::tPropertyValueMap aStaticDefaults;
80cdf0e10cSrcweir         lcl_AddDefaultsToMap( aStaticDefaults );
81cdf0e10cSrcweir         return &aStaticDefaults;
82cdf0e10cSrcweir     }
83cdf0e10cSrcweir private:
lcl_AddDefaultsToMap__anona02556730111::StaticColumnLineChartTypeTemplateDefaults_Initializer84cdf0e10cSrcweir     void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
85cdf0e10cSrcweir     {
86cdf0e10cSrcweir         ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_COL_LINE_NUMBER_OF_LINES, 1 );
87cdf0e10cSrcweir     }
88cdf0e10cSrcweir };
89cdf0e10cSrcweir 
90cdf0e10cSrcweir struct StaticColumnLineChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticColumnLineChartTypeTemplateDefaults_Initializer >
91cdf0e10cSrcweir {
92cdf0e10cSrcweir };
93cdf0e10cSrcweir 
94cdf0e10cSrcweir struct StaticColumnLineChartTypeTemplateInfoHelper_Initializer
95cdf0e10cSrcweir {
operator ()__anona02556730111::StaticColumnLineChartTypeTemplateInfoHelper_Initializer96cdf0e10cSrcweir     ::cppu::OPropertyArrayHelper* operator()()
97cdf0e10cSrcweir     {
98cdf0e10cSrcweir         static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
99cdf0e10cSrcweir         return &aPropHelper;
100cdf0e10cSrcweir     }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir private:
lcl_GetPropertySequence__anona02556730111::StaticColumnLineChartTypeTemplateInfoHelper_Initializer103cdf0e10cSrcweir     uno::Sequence< Property > lcl_GetPropertySequence()
104cdf0e10cSrcweir     {
105cdf0e10cSrcweir         ::std::vector< ::com::sun::star::beans::Property > aProperties;
106cdf0e10cSrcweir         lcl_AddPropertiesToVector( aProperties );
107cdf0e10cSrcweir 
108cdf0e10cSrcweir         ::std::sort( aProperties.begin(), aProperties.end(),
109cdf0e10cSrcweir                      ::chart::PropertyNameLess() );
110cdf0e10cSrcweir 
111cdf0e10cSrcweir         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
112cdf0e10cSrcweir     }
113cdf0e10cSrcweir 
114cdf0e10cSrcweir };
115cdf0e10cSrcweir 
116cdf0e10cSrcweir struct StaticColumnLineChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticColumnLineChartTypeTemplateInfoHelper_Initializer >
117cdf0e10cSrcweir {
118cdf0e10cSrcweir };
119cdf0e10cSrcweir 
120cdf0e10cSrcweir struct StaticColumnLineChartTypeTemplateInfo_Initializer
121cdf0e10cSrcweir {
operator ()__anona02556730111::StaticColumnLineChartTypeTemplateInfo_Initializer122cdf0e10cSrcweir     uno::Reference< beans::XPropertySetInfo >* operator()()
123cdf0e10cSrcweir     {
124cdf0e10cSrcweir         static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
125cdf0e10cSrcweir             ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticColumnLineChartTypeTemplateInfoHelper::get() ) );
126cdf0e10cSrcweir         return &xPropertySetInfo;
127cdf0e10cSrcweir     }
128cdf0e10cSrcweir };
129cdf0e10cSrcweir 
130cdf0e10cSrcweir struct StaticColumnLineChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticColumnLineChartTypeTemplateInfo_Initializer >
131cdf0e10cSrcweir {
132cdf0e10cSrcweir };
133cdf0e10cSrcweir 
134cdf0e10cSrcweir } // anonymous namespace
135cdf0e10cSrcweir 
136cdf0e10cSrcweir namespace chart
137cdf0e10cSrcweir {
138cdf0e10cSrcweir 
ColumnLineChartTypeTemplate(Reference<uno::XComponentContext> const & xContext,const::rtl::OUString & rServiceName,StackMode eStackMode,sal_Int32 nNumberOfLines)139cdf0e10cSrcweir ColumnLineChartTypeTemplate::ColumnLineChartTypeTemplate(
140cdf0e10cSrcweir     Reference<
141cdf0e10cSrcweir         uno::XComponentContext > const & xContext,
142cdf0e10cSrcweir     const ::rtl::OUString & rServiceName,
143cdf0e10cSrcweir     StackMode eStackMode,
144cdf0e10cSrcweir     sal_Int32 nNumberOfLines ) :
145cdf0e10cSrcweir         ChartTypeTemplate( xContext, rServiceName ),
146cdf0e10cSrcweir         ::property::OPropertySet( m_aMutex ),
147cdf0e10cSrcweir         m_eStackMode( eStackMode )
148cdf0e10cSrcweir {
149cdf0e10cSrcweir     setFastPropertyValue_NoBroadcast( PROP_COL_LINE_NUMBER_OF_LINES, uno::makeAny( nNumberOfLines ));
150cdf0e10cSrcweir }
151cdf0e10cSrcweir 
~ColumnLineChartTypeTemplate()152cdf0e10cSrcweir ColumnLineChartTypeTemplate::~ColumnLineChartTypeTemplate()
153cdf0e10cSrcweir {}
154cdf0e10cSrcweir 
155cdf0e10cSrcweir // ____ OPropertySet ____
GetDefaultValue(sal_Int32 nHandle) const156cdf0e10cSrcweir uno::Any ColumnLineChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
157cdf0e10cSrcweir     throw(beans::UnknownPropertyException)
158cdf0e10cSrcweir {
159cdf0e10cSrcweir     const tPropertyValueMap& rStaticDefaults = *StaticColumnLineChartTypeTemplateDefaults::get();
160cdf0e10cSrcweir     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
161cdf0e10cSrcweir     if( aFound == rStaticDefaults.end() )
162cdf0e10cSrcweir         return uno::Any();
163cdf0e10cSrcweir     return (*aFound).second;
164cdf0e10cSrcweir }
165cdf0e10cSrcweir 
getInfoHelper()166cdf0e10cSrcweir ::cppu::IPropertyArrayHelper & SAL_CALL ColumnLineChartTypeTemplate::getInfoHelper()
167cdf0e10cSrcweir {
168cdf0e10cSrcweir     return *StaticColumnLineChartTypeTemplateInfoHelper::get();
169cdf0e10cSrcweir }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir // ____ XPropertySet ____
getPropertySetInfo()172cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > SAL_CALL ColumnLineChartTypeTemplate::getPropertySetInfo()
173cdf0e10cSrcweir     throw (uno::RuntimeException)
174cdf0e10cSrcweir {
175cdf0e10cSrcweir     return *StaticColumnLineChartTypeTemplateInfo::get();
176cdf0e10cSrcweir }
177cdf0e10cSrcweir 
createChartTypes(const Sequence<Sequence<Reference<XDataSeries>>> & aSeriesSeq,const Sequence<Reference<XCoordinateSystem>> & rCoordSys,const Sequence<Reference<XChartType>> & aOldChartTypesSeq)178cdf0e10cSrcweir void ColumnLineChartTypeTemplate::createChartTypes(
179cdf0e10cSrcweir     const Sequence< Sequence< Reference< XDataSeries > > > & aSeriesSeq,
180cdf0e10cSrcweir     const Sequence< Reference< XCoordinateSystem > > & rCoordSys,
181cdf0e10cSrcweir     const Sequence< Reference< XChartType > >& aOldChartTypesSeq )
182cdf0e10cSrcweir {
183cdf0e10cSrcweir     if( rCoordSys.getLength() == 0 ||
184cdf0e10cSrcweir         ! rCoordSys[0].is() )
185cdf0e10cSrcweir         return;
186cdf0e10cSrcweir 
187cdf0e10cSrcweir     try
188cdf0e10cSrcweir     {
189cdf0e10cSrcweir         Reference< lang::XMultiServiceFactory > xFact(
190cdf0e10cSrcweir             GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
191cdf0e10cSrcweir         Sequence< Reference< XDataSeries > > aFlatSeriesSeq( FlattenSequence( aSeriesSeq ));
192cdf0e10cSrcweir         sal_Int32 nNumberOfSeries = aFlatSeriesSeq.getLength();
193cdf0e10cSrcweir         sal_Int32 nNumberOfLines = 0;
194cdf0e10cSrcweir         sal_Int32 nNumberOfColumns = 0;
195cdf0e10cSrcweir 
196cdf0e10cSrcweir         getFastPropertyValue( PROP_COL_LINE_NUMBER_OF_LINES ) >>= nNumberOfLines;
197cdf0e10cSrcweir         OSL_ENSURE( nNumberOfLines>=0, "number of lines should be not negative" );
198cdf0e10cSrcweir         if( nNumberOfLines < 0 )
199cdf0e10cSrcweir             nNumberOfLines = 0;
200cdf0e10cSrcweir 
201cdf0e10cSrcweir         if( nNumberOfLines >= nNumberOfSeries )
202cdf0e10cSrcweir         {
203cdf0e10cSrcweir             if( nNumberOfSeries > 0 )
204cdf0e10cSrcweir             {
205cdf0e10cSrcweir                 nNumberOfLines = nNumberOfSeries - 1;
206cdf0e10cSrcweir                 nNumberOfColumns = 1;
207cdf0e10cSrcweir             }
208cdf0e10cSrcweir             else
209cdf0e10cSrcweir                 nNumberOfLines = 0;
210cdf0e10cSrcweir         }
211cdf0e10cSrcweir         else
212cdf0e10cSrcweir             nNumberOfColumns = nNumberOfSeries - nNumberOfLines;
213cdf0e10cSrcweir 
214cdf0e10cSrcweir         // Columns
215cdf0e10cSrcweir         // -------
216cdf0e10cSrcweir         Reference< XChartType > xCT(
217cdf0e10cSrcweir             xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_COLUMN ), uno::UNO_QUERY_THROW );
218cdf0e10cSrcweir 
219cdf0e10cSrcweir         ChartTypeTemplate::copyPropertiesFromOldToNewCoordianteSystem( aOldChartTypesSeq, xCT );
220cdf0e10cSrcweir 
221cdf0e10cSrcweir         Reference< XChartTypeContainer > xCTCnt( rCoordSys[ 0 ], uno::UNO_QUERY_THROW );
222cdf0e10cSrcweir         xCTCnt->setChartTypes( Sequence< Reference< chart2::XChartType > >( &xCT, 1 ));
223cdf0e10cSrcweir 
224cdf0e10cSrcweir         if( nNumberOfColumns > 0 )
225cdf0e10cSrcweir         {
226cdf0e10cSrcweir             Reference< XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
227cdf0e10cSrcweir             Sequence< Reference< XDataSeries > > aColumnSeq( nNumberOfColumns );
228cdf0e10cSrcweir             ::std::copy( aFlatSeriesSeq.getConstArray(),
229cdf0e10cSrcweir                          aFlatSeriesSeq.getConstArray() + nNumberOfColumns,
230cdf0e10cSrcweir                          aColumnSeq.getArray());
231cdf0e10cSrcweir             xDSCnt->setDataSeries( aColumnSeq );
232cdf0e10cSrcweir         }
233cdf0e10cSrcweir 
234cdf0e10cSrcweir         // Lines
235cdf0e10cSrcweir         // -----
236cdf0e10cSrcweir         xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY_THROW );
237cdf0e10cSrcweir         xCTCnt.set( rCoordSys[ 0 ], uno::UNO_QUERY_THROW );
238cdf0e10cSrcweir         xCTCnt->addChartType( xCT );
239cdf0e10cSrcweir 
240cdf0e10cSrcweir         if( nNumberOfLines > 0 )
241cdf0e10cSrcweir         {
242cdf0e10cSrcweir             Reference< XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
243cdf0e10cSrcweir             Sequence< Reference< XDataSeries > > aLineSeq( nNumberOfLines );
244cdf0e10cSrcweir             ::std::copy( aFlatSeriesSeq.getConstArray() + nNumberOfColumns,
245cdf0e10cSrcweir                          aFlatSeriesSeq.getConstArray() + aFlatSeriesSeq.getLength(),
246cdf0e10cSrcweir                          aLineSeq.getArray());
247cdf0e10cSrcweir             xDSCnt->setDataSeries( aLineSeq );
248cdf0e10cSrcweir         }
249cdf0e10cSrcweir     }
250cdf0e10cSrcweir     catch( uno::Exception & ex )
251cdf0e10cSrcweir     {
252cdf0e10cSrcweir         ASSERT_EXCEPTION( ex );
253cdf0e10cSrcweir     }
254cdf0e10cSrcweir }
255cdf0e10cSrcweir 
applyStyle(const Reference<chart2::XDataSeries> & xSeries,::sal_Int32 nChartTypeIndex,::sal_Int32 nSeriesIndex,::sal_Int32 nSeriesCount)256cdf0e10cSrcweir void SAL_CALL ColumnLineChartTypeTemplate::applyStyle(
257cdf0e10cSrcweir     const Reference< chart2::XDataSeries >& xSeries,
258cdf0e10cSrcweir     ::sal_Int32 nChartTypeIndex,
259cdf0e10cSrcweir     ::sal_Int32 nSeriesIndex,
260cdf0e10cSrcweir     ::sal_Int32 nSeriesCount )
261cdf0e10cSrcweir     throw (uno::RuntimeException)
262cdf0e10cSrcweir {
263cdf0e10cSrcweir     ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
264cdf0e10cSrcweir 
265cdf0e10cSrcweir     if( nChartTypeIndex==0 ) // columns
266cdf0e10cSrcweir     {
267cdf0e10cSrcweir         DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "BorderStyle" ), uno::makeAny( drawing::LineStyle_NONE ) );
268cdf0e10cSrcweir     }
269cdf0e10cSrcweir     else if( nChartTypeIndex==1 ) // lines
270cdf0e10cSrcweir     {
271cdf0e10cSrcweir         Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY );
272cdf0e10cSrcweir         if( xProp.is() )
273cdf0e10cSrcweir         {
274cdf0e10cSrcweir             DataSeriesHelper::switchLinesOnOrOff( xProp, true );
275cdf0e10cSrcweir             DataSeriesHelper::switchSymbolsOnOrOff( xProp, false, nSeriesIndex );
276cdf0e10cSrcweir             DataSeriesHelper::makeLinesThickOrThin( xProp, true );
277cdf0e10cSrcweir         }
278cdf0e10cSrcweir     }
279cdf0e10cSrcweir }
280cdf0e10cSrcweir 
getStackMode(sal_Int32 nChartTypeIndex) const281cdf0e10cSrcweir StackMode ColumnLineChartTypeTemplate::getStackMode( sal_Int32 nChartTypeIndex ) const
282cdf0e10cSrcweir {
283cdf0e10cSrcweir     if( nChartTypeIndex == 0 )
284cdf0e10cSrcweir         return m_eStackMode;
285cdf0e10cSrcweir     return StackMode_NONE;
286cdf0e10cSrcweir }
287cdf0e10cSrcweir 
288cdf0e10cSrcweir // ____ XChartTypeTemplate ____
matchesTemplate(const uno::Reference<XDiagram> & xDiagram,sal_Bool bAdaptProperties)289cdf0e10cSrcweir sal_Bool SAL_CALL ColumnLineChartTypeTemplate::matchesTemplate(
290cdf0e10cSrcweir     const uno::Reference< XDiagram >& xDiagram,
291cdf0e10cSrcweir     sal_Bool bAdaptProperties )
292cdf0e10cSrcweir     throw (uno::RuntimeException)
293cdf0e10cSrcweir {
294cdf0e10cSrcweir     sal_Bool bResult = sal_False;
295cdf0e10cSrcweir 
296cdf0e10cSrcweir     if( ! xDiagram.is())
297cdf0e10cSrcweir         return bResult;
298cdf0e10cSrcweir 
299cdf0e10cSrcweir     try
300cdf0e10cSrcweir     {
301cdf0e10cSrcweir         Reference< chart2::XChartType > xColumnChartType;
302cdf0e10cSrcweir         Reference< XCoordinateSystem > xColumnChartCooSys;
303cdf0e10cSrcweir         Reference< chart2::XChartType > xLineChartType;
304cdf0e10cSrcweir         sal_Int32 nNumberOfChartTypes = 0;
305cdf0e10cSrcweir 
306cdf0e10cSrcweir         Reference< XCoordinateSystemContainer > xCooSysCnt(
307cdf0e10cSrcweir             xDiagram, uno::UNO_QUERY_THROW );
308cdf0e10cSrcweir         Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
309cdf0e10cSrcweir             xCooSysCnt->getCoordinateSystems());
310cdf0e10cSrcweir         for( sal_Int32 i=0; i<aCooSysSeq.getLength(); ++i )
311cdf0e10cSrcweir         {
312cdf0e10cSrcweir             Reference< XChartTypeContainer > xCTCnt( aCooSysSeq[i], uno::UNO_QUERY_THROW );
313cdf0e10cSrcweir             Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes());
314cdf0e10cSrcweir             for( sal_Int32 j=0; j<aChartTypeSeq.getLength(); ++j )
315cdf0e10cSrcweir             {
316cdf0e10cSrcweir                 if( aChartTypeSeq[j].is())
317cdf0e10cSrcweir                 {
318cdf0e10cSrcweir                     ++nNumberOfChartTypes;
319cdf0e10cSrcweir                     if( nNumberOfChartTypes > 2 )
320cdf0e10cSrcweir                         break;
321cdf0e10cSrcweir                     OUString aCTService = aChartTypeSeq[j]->getChartType();
322cdf0e10cSrcweir                     if( aCTService.equals( CHART2_SERVICE_NAME_CHARTTYPE_COLUMN ))
323cdf0e10cSrcweir                     {
324cdf0e10cSrcweir                         xColumnChartType.set( aChartTypeSeq[j] );
325cdf0e10cSrcweir                         xColumnChartCooSys.set( aCooSysSeq[i] );
326cdf0e10cSrcweir                     }
327cdf0e10cSrcweir                     else if( aCTService.equals( CHART2_SERVICE_NAME_CHARTTYPE_LINE ))
328cdf0e10cSrcweir                         xLineChartType.set( aChartTypeSeq[j] );
329cdf0e10cSrcweir                 }
330cdf0e10cSrcweir             }
331cdf0e10cSrcweir             if( nNumberOfChartTypes > 2 )
332cdf0e10cSrcweir                 break;
333cdf0e10cSrcweir         }
334cdf0e10cSrcweir 
335cdf0e10cSrcweir         if( nNumberOfChartTypes == 2 &&
336cdf0e10cSrcweir             xColumnChartType.is() &&
337cdf0e10cSrcweir             xLineChartType.is())
338cdf0e10cSrcweir         {
339cdf0e10cSrcweir             OSL_ASSERT( xColumnChartCooSys.is());
340cdf0e10cSrcweir 
341cdf0e10cSrcweir             // check stackmode of bars
342cdf0e10cSrcweir             bResult = (xColumnChartCooSys->getDimension() == getDimension());
343cdf0e10cSrcweir             if( bResult )
344cdf0e10cSrcweir             {
345cdf0e10cSrcweir                 bool bFound=false;
346cdf0e10cSrcweir                 bool bAmbiguous=false;
347cdf0e10cSrcweir                 bResult = ( DiagramHelper::getStackModeFromChartType(
348cdf0e10cSrcweir                                 xColumnChartType, bFound, bAmbiguous,
349cdf0e10cSrcweir                                 xColumnChartCooSys )
350cdf0e10cSrcweir                             == getStackMode( 0 ) );
351cdf0e10cSrcweir 
352cdf0e10cSrcweir                 if( bResult && bAdaptProperties )
353cdf0e10cSrcweir                 {
354cdf0e10cSrcweir                     Reference< XDataSeriesContainer > xSeriesContainer( xLineChartType, uno::UNO_QUERY );
355cdf0e10cSrcweir                     if( xSeriesContainer.is() )
356cdf0e10cSrcweir                     {
357cdf0e10cSrcweir                         sal_Int32 nNumberOfLines = xSeriesContainer->getDataSeries().getLength();
358cdf0e10cSrcweir                         setFastPropertyValue_NoBroadcast( PROP_COL_LINE_NUMBER_OF_LINES, uno::makeAny( nNumberOfLines ));
359cdf0e10cSrcweir                     }
360cdf0e10cSrcweir                 }
361cdf0e10cSrcweir             }
362cdf0e10cSrcweir         }
363cdf0e10cSrcweir     }
364cdf0e10cSrcweir     catch( uno::Exception & ex )
365cdf0e10cSrcweir     {
366cdf0e10cSrcweir         ASSERT_EXCEPTION( ex );
367cdf0e10cSrcweir     }
368cdf0e10cSrcweir 
369cdf0e10cSrcweir     return bResult;
370cdf0e10cSrcweir }
371cdf0e10cSrcweir 
getChartTypeForIndex(sal_Int32 nChartTypeIndex)372cdf0e10cSrcweir Reference< chart2::XChartType > ColumnLineChartTypeTemplate::getChartTypeForIndex( sal_Int32 nChartTypeIndex )
373cdf0e10cSrcweir {
374cdf0e10cSrcweir     Reference< chart2::XChartType > xCT;
375cdf0e10cSrcweir     Reference< lang::XMultiServiceFactory > xFact(
376cdf0e10cSrcweir             GetComponentContext()->getServiceManager(), uno::UNO_QUERY );
377cdf0e10cSrcweir     if(xFact.is())
378cdf0e10cSrcweir     {
379cdf0e10cSrcweir         if( nChartTypeIndex == 0 )
380cdf0e10cSrcweir             xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_COLUMN ), uno::UNO_QUERY );
381cdf0e10cSrcweir         else
382cdf0e10cSrcweir             xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY );
383cdf0e10cSrcweir     }
384cdf0e10cSrcweir     return xCT;
385cdf0e10cSrcweir }
386cdf0e10cSrcweir 
getChartTypeForNewSeries(const uno::Sequence<Reference<chart2::XChartType>> & aFormerlyUsedChartTypes)387cdf0e10cSrcweir Reference< XChartType > SAL_CALL ColumnLineChartTypeTemplate::getChartTypeForNewSeries(
388cdf0e10cSrcweir         const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
389cdf0e10cSrcweir     throw (uno::RuntimeException)
390cdf0e10cSrcweir {
391cdf0e10cSrcweir     Reference< chart2::XChartType > xResult;
392cdf0e10cSrcweir 
393cdf0e10cSrcweir     try
394cdf0e10cSrcweir     {
395cdf0e10cSrcweir         Reference< lang::XMultiServiceFactory > xFact(
396cdf0e10cSrcweir             GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
397cdf0e10cSrcweir         xResult.set( xFact->createInstance(
398cdf0e10cSrcweir                          CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY_THROW );
399cdf0e10cSrcweir         ChartTypeTemplate::copyPropertiesFromOldToNewCoordianteSystem( aFormerlyUsedChartTypes, xResult );
400cdf0e10cSrcweir     }
401cdf0e10cSrcweir     catch( uno::Exception & ex )
402cdf0e10cSrcweir     {
403cdf0e10cSrcweir         ASSERT_EXCEPTION( ex );
404cdf0e10cSrcweir     }
405cdf0e10cSrcweir 
406cdf0e10cSrcweir     return xResult;
407cdf0e10cSrcweir }
408cdf0e10cSrcweir 
getDataInterpreter()409cdf0e10cSrcweir Reference< XDataInterpreter > SAL_CALL ColumnLineChartTypeTemplate::getDataInterpreter()
410cdf0e10cSrcweir     throw (uno::RuntimeException)
411cdf0e10cSrcweir {
412cdf0e10cSrcweir     if( ! m_xDataInterpreter.is())
413cdf0e10cSrcweir     {
414cdf0e10cSrcweir         sal_Int32 nNumberOfLines = 1;
415cdf0e10cSrcweir         getFastPropertyValue( PROP_COL_LINE_NUMBER_OF_LINES ) >>= nNumberOfLines;
416cdf0e10cSrcweir         m_xDataInterpreter.set( new ColumnLineDataInterpreter( nNumberOfLines, GetComponentContext() ) );
417cdf0e10cSrcweir     }
418cdf0e10cSrcweir     else
419cdf0e10cSrcweir     {
420cdf0e10cSrcweir         //todo...
421cdf0e10cSrcweir         OSL_ENSURE( false, "number of lines may not be valid anymore in the datainterpreter" );
422cdf0e10cSrcweir 
423cdf0e10cSrcweir     }
424cdf0e10cSrcweir 
425cdf0e10cSrcweir     return m_xDataInterpreter;
426cdf0e10cSrcweir }
427cdf0e10cSrcweir 
428cdf0e10cSrcweir // ----------------------------------------
429cdf0e10cSrcweir 
getSupportedServiceNames_Static()430cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > ColumnLineChartTypeTemplate::getSupportedServiceNames_Static()
431cdf0e10cSrcweir {
432cdf0e10cSrcweir     uno::Sequence< ::rtl::OUString > aServices( 2 );
433cdf0e10cSrcweir     aServices[ 0 ] = lcl_aServiceName;
434cdf0e10cSrcweir     aServices[ 1 ] = C2U( "com.sun.star.chart2.ChartTypeTemplate" );
435cdf0e10cSrcweir     return aServices;
436cdf0e10cSrcweir }
437cdf0e10cSrcweir 
438cdf0e10cSrcweir // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
439cdf0e10cSrcweir APPHELPER_XSERVICEINFO_IMPL( ColumnLineChartTypeTemplate, lcl_aServiceName );
440cdf0e10cSrcweir 
441cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( ColumnLineChartTypeTemplate, ChartTypeTemplate, OPropertySet )
442cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( ColumnLineChartTypeTemplate, ChartTypeTemplate, OPropertySet )
443cdf0e10cSrcweir 
444cdf0e10cSrcweir } //  namespace chart
445