xref: /aoo42x/main/sc/source/ui/vba/vbachart.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #include "vbachart.hxx"
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
30 #include <com/sun/star/chart/XAxisXSupplier.hpp>
31 #include <com/sun/star/chart/XAxisYSupplier.hpp>
32 #include <com/sun/star/chart/XAxisZSupplier.hpp>
33 #include <com/sun/star/chart/XTwoAxisXSupplier.hpp>
34 #include <com/sun/star/chart/XTwoAxisYSupplier.hpp>
35 #include <com/sun/star/chart/XChartDataArray.hpp>
36 #include <com/sun/star/chart/ChartSymbolType.hpp>
37 #include <com/sun/star/chart/ChartSolidType.hpp>
38 #include <com/sun/star/chart/ChartDataRowSource.hpp>
39 #include <com/sun/star/chart/ChartDataCaption.hpp>
40 #include <ooo/vba/excel/XlChartType.hpp>
41 #include <ooo/vba/excel/XlRowCol.hpp>
42 #include <ooo/vba/excel/XlAxisType.hpp>
43 #include <ooo/vba/excel/XlAxisGroup.hpp>
44 
45 #include <basic/sberrors.hxx>
46 #include "vbachartobject.hxx"
47 #include "vbarange.hxx"
48 #include "vbacharttitle.hxx"
49 #include "vbaaxes.hxx"
50 
51 using namespace ::com::sun::star;
52 using namespace ::ooo::vba;
53 using namespace ::ooo::vba::excel::XlChartType;
54 using namespace ::ooo::vba::excel::XlRowCol;
55 using namespace ::ooo::vba::excel::XlAxisType;
56 using namespace ::ooo::vba::excel::XlAxisGroup;
57 
58 const rtl::OUString CHART_NAME( RTL_CONSTASCII_USTRINGPARAM("Name") );
59 // #TODO move this constant to vbaseries.[ch]xx ( when it exists )
60 const rtl::OUString DEFAULTSERIESPREFIX( RTL_CONSTASCII_USTRINGPARAM("Series") );
61 const rtl::OUString DATAROWSOURCE( RTL_CONSTASCII_USTRINGPARAM("DataRowSource") );
62 const rtl::OUString UPDOWN( RTL_CONSTASCII_USTRINGPARAM("UpDown") );
63 const rtl::OUString VOLUME( RTL_CONSTASCII_USTRINGPARAM("Volume") );
64 const rtl::OUString LINES( RTL_CONSTASCII_USTRINGPARAM("Lines") );
65 const rtl::OUString SPLINETYPE( RTL_CONSTASCII_USTRINGPARAM("SplineType") );
66 const rtl::OUString SYMBOLTYPE( RTL_CONSTASCII_USTRINGPARAM("SymbolType") );
67 const rtl::OUString DEEP( RTL_CONSTASCII_USTRINGPARAM("Deep") );
68 const rtl::OUString SOLIDTYPE( RTL_CONSTASCII_USTRINGPARAM("SolidType") );
69 const rtl::OUString VERTICAL( RTL_CONSTASCII_USTRINGPARAM("Vertical") );
70 const rtl::OUString PERCENT( RTL_CONSTASCII_USTRINGPARAM("Percent") );
71 const rtl::OUString STACKED( RTL_CONSTASCII_USTRINGPARAM("Stacked") );
72 const rtl::OUString DIM3D( RTL_CONSTASCII_USTRINGPARAM("Dim3D") );
73 const rtl::OUString HASMAINTITLE( RTL_CONSTASCII_USTRINGPARAM("HasMainTitle") );
74 const rtl::OUString HASLEGEND( RTL_CONSTASCII_USTRINGPARAM("HasLegend") );
75 const rtl::OUString DATACAPTION( RTL_CONSTASCII_USTRINGPARAM("DataCaption") );
76 
77 ScVbaChart::ScVbaChart( const css::uno::Reference< ov::XHelperInterface >& _xParent, const css::uno::Reference< css::uno::XComponentContext >& _xContext, const css::uno::Reference< css::lang::XComponent >& _xChartComponent, const css::uno::Reference< css::table::XTableChart >& _xTableChart ) : ChartImpl_BASE( _xParent, _xContext ), mxTableChart( _xTableChart )
78 {
79 	mxChartDocument.set( _xChartComponent, uno::UNO_QUERY_THROW ) ;
80 	// #TODO is is possible that the XPropertySet interface is not set
81 	// code in setPlotBy seems to indicate that this is possible? but
82 	// additionally there is no check in most of the places where it is used
83 	// ( and therefore could possibly be NULL )
84 	// I'm going to let it throw for the moment ( npower )
85 	mxDiagramPropertySet.set( mxChartDocument->getDiagram(), uno::UNO_QUERY_THROW );
86 	mxChartPropertySet.set( _xChartComponent, uno::UNO_QUERY_THROW ) ;
87 }
88 
89 ::rtl::OUString SAL_CALL
90 ScVbaChart::getName() throw (css::uno::RuntimeException)
91 {
92 	rtl::OUString sName;
93 	uno::Reference< beans::XPropertySet > xProps( mxChartDocument, uno::UNO_QUERY_THROW );
94 	try
95 	{
96 		xProps->getPropertyValue( CHART_NAME ) >>= sName;
97 	}
98 	catch( uno::Exception e ) // swallow exceptions
99 	{
100 	}
101 	return sName;
102 }
103 
104 uno::Any  SAL_CALL
105 ScVbaChart::SeriesCollection(const uno::Any&) throw (uno::RuntimeException)
106 {
107 	return uno::Any();
108 }
109 
110 ::sal_Int32 SAL_CALL
111 ScVbaChart::getChartType() throw ( uno::RuntimeException, script::BasicErrorException)
112 {
113 	sal_Int32 nChartType = -1;
114 	try
115 	{
116 		rtl::OUString sDiagramType = mxChartDocument->getDiagram()->getDiagramType();
117 		if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart.AreaDiagram" ))))
118 		{
119 			if (is3D())
120 			{
121 				nChartType = getStackedType(xl3DAreaStacked, xl3DAreaStacked100, xl3DArea);
122 			}
123 			else
124 			{
125 				nChartType = getStackedType(xlAreaStacked, xlAreaStacked100, xlArea);
126 			}
127 		}
128 		else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.PieDiagram"))))
129 		{
130 			if (is3D())
131 				nChartType = xl3DPie;
132 			else
133 				nChartType = xlPie;                 /*TODO XlChartType  xlPieExploded, XlChartType xlPieOfPie */
134 		}
135 		else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.BarDiagram"))))
136 		{
137 			sal_Int32 nSolidType = chart::ChartSolidType::RECTANGULAR_SOLID;
138 			if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(SOLIDTYPE))
139 			{       //in 2D diagrams 'SolidType' may not be set
140 				if (is3D())
141 					mxDiagramPropertySet->getPropertyValue(SOLIDTYPE) >>= nSolidType;
142 			}
143 			switch (nSolidType)
144 			{
145 				case chart::ChartSolidType::CONE:
146 					nChartType = getSolidType(xlConeCol, xlConeColStacked, xlConeColStacked100, xlConeColClustered, xlConeBarStacked, xlConeBarStacked100, xlConeBarClustered);
147 					break;
148 				case chart::ChartSolidType::CYLINDER:
149 					nChartType = getSolidType(xlCylinderCol, xlCylinderColStacked, xlCylinderColStacked100, xlCylinderColClustered, xlCylinderBarStacked, xlCylinderBarStacked100, xlCylinderBarClustered);
150 					break;
151 				case chart::ChartSolidType::PYRAMID:
152 					nChartType = getSolidType(xlPyramidCol, xlPyramidColStacked, xlPyramidColStacked100, xlPyramidColClustered, xlPyramidBarStacked, xlPyramidBarStacked100, xlPyramidBarClustered);
153 					break;
154 				default: // RECTANGULAR_SOLID
155 					if (is3D())
156 					{
157 						nChartType = getSolidType(xl3DColumn, xl3DColumnStacked, xl3DColumnStacked100, xl3DColumnClustered, xl3DBarStacked, xl3DBarStacked100, xl3DBarClustered);
158 					}
159 					else
160 					{
161 						nChartType = getSolidType(xlColumnClustered,  xlColumnStacked, xlColumnStacked100, xlColumnClustered, xlBarStacked, xlBarStacked100, xlBarClustered);
162 					}
163 					break;
164 				}
165 			}
166 		else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.StockDiagram"))))
167 		{
168 			sal_Bool bVolume = sal_False;
169 			mxDiagramPropertySet->getPropertyValue(VOLUME) >>= bVolume;
170 			if (bVolume)
171 			{
172 				nChartType = getStockUpDownValue(xlStockVOHLC, xlStockVHLC);
173 			}
174 			else
175 			{
176 				nChartType = getStockUpDownValue(xlStockOHLC, xlStockHLC);
177 			}
178 		}
179 		else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.XYDiagram"))))
180 		{
181 			sal_Bool bHasLines = sal_False;
182 			mxDiagramPropertySet->getPropertyValue(LINES) >>= bHasLines;
183 			sal_Int32 nSplineType = 0;
184 			mxDiagramPropertySet->getPropertyValue(SPLINETYPE) >>= nSplineType;
185 			if (nSplineType == 1)
186 			{
187 				nChartType = getMarkerType(xlXYScatterSmooth, xlXYScatterSmoothNoMarkers);
188 			}
189 			else if (bHasLines)
190 			{
191 				nChartType = getMarkerType(xlXYScatterLines, xlXYScatterLinesNoMarkers);
192 			}
193 			else
194 			{
195 				nChartType = xlXYScatter;
196 			}
197 		}
198 		else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.LineDiagram"))))
199 		{
200 			if (is3D())
201 			{
202 				nChartType = xl3DLine;
203 			}
204 			else if (hasMarkers())
205 			{
206 				nChartType = getStackedType(xlLineMarkersStacked, xlLineMarkersStacked100, xlLineMarkers);
207 			}
208 			else
209 			{
210 				nChartType = getStackedType(xlLineStacked, xlLineStacked100, xlLine);
211 			}
212 		}
213 		else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.DonutDiagram"))))
214 		{
215 			nChartType = xlDoughnut;                    // TODO DoughnutExploded ??
216 		}
217 		else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.NetDiagram"))))
218 		{
219 			nChartType = getMarkerType(xlRadarMarkers, xlRadar);
220 		}
221 	}
222 	catch (uno::Exception& )
223 	{
224 		throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
225 	}
226 	return nChartType;
227 }
228 
229 void SAL_CALL
230 ScVbaChart::setChartType( ::sal_Int32 _nChartType ) throw ( uno::RuntimeException, script::BasicErrorException)
231 {
232 try
233 {
234 	switch (_nChartType)
235 	{
236 		case xlColumnClustered:
237 		case xlColumnStacked:
238 		case xlColumnStacked100:
239 		case xl3DColumnClustered:
240 		case xl3DColumnStacked:
241 		case xl3DColumnStacked100:
242 		case xl3DColumn:
243 		case xlBarClustered:
244 		case xlBarStacked:
245 		case xlBarStacked100:
246 		case xl3DBarClustered:
247 		case xl3DBarStacked:
248 		case xl3DBarStacked100:
249 		case xlConeColClustered:
250 		case xlConeColStacked:
251 		case xlConeColStacked100:
252 		case xlConeBarClustered:
253 		case xlConeBarStacked:
254 		case xlConeBarStacked100:
255 		case xlConeCol:
256 		case xlPyramidColClustered:
257 		case xlPyramidColStacked:
258 		case xlPyramidColStacked100:
259 		case xlPyramidBarClustered:
260 		case xlPyramidBarStacked:
261 		case xlPyramidBarStacked100:
262 		case xlPyramidCol:
263 		case xlCylinderColClustered:
264 		case xlCylinderColStacked:
265 		case xlCylinderColStacked100:
266 		case xlCylinderBarClustered:
267 		case xlCylinderBarStacked:
268 		case xlCylinderBarStacked100:
269 		case xlCylinderCol:
270 		case xlSurface: // not possible
271 		case xlSurfaceWireframe:
272 		case xlSurfaceTopView:
273 		case xlSurfaceTopViewWireframe:
274 			setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.BarDiagram")));
275 			break;
276 		case xlLine:
277 		case xl3DLine:
278 		case xlLineStacked:
279 		case xlLineStacked100:
280 		case xlLineMarkers:
281 		case xlLineMarkersStacked:
282 		case xlLineMarkersStacked100:
283 			setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.LineDiagram")));
284 			break;
285 		case xl3DArea:
286 		case xlArea:
287 		case xlAreaStacked:
288 		case xlAreaStacked100:
289 		case xl3DAreaStacked:
290 		case xl3DAreaStacked100:
291 			setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.AreaDiagram")) );
292 			break;
293 		case xlDoughnut:
294 		case xlDoughnutExploded:
295 			setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.DonutDiagram") ) );
296 			break;
297 		case xlStockHLC:
298 		case xlStockOHLC:
299 		case xlStockVHLC:
300 		case xlStockVOHLC:
301 			setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.StockDiagram")));
302 			mxDiagramPropertySet->setPropertyValue( UPDOWN, uno::makeAny(sal_Bool((_nChartType == xlStockOHLC) || (_nChartType == xlStockVOHLC))));
303 			mxDiagramPropertySet->setPropertyValue(VOLUME, uno::makeAny(sal_Bool((_nChartType == xlStockVHLC) || (_nChartType == xlStockVOHLC))));
304 			break;
305 
306 		case xlPieOfPie:                            // not possible
307 		case xlPieExploded: // SegmentOffset an ChartDataPointProperties ->am XDiagram abholen //wie macht Excel das?
308 		case xl3DPieExploded:
309 		case xl3DPie:
310 		case xlPie:
311 		case xlBarOfPie:                            // not possible (Zoom pie)
312 			setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.PieDiagram")));
313 			break;
314 
315 		case xlRadar:
316 		case xlRadarMarkers:
317 		case xlRadarFilled:
318 			setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.NetDiagram")));
319 			break;
320 		case xlXYScatter:
321 		case xlBubble:                      // not possible
322 		case xlBubble3DEffect:              // not possible
323 		case xlXYScatterLines:
324 		case xlXYScatterLinesNoMarkers:
325 		case xlXYScatterSmooth:
326 		case xlXYScatterSmoothNoMarkers:
327 			setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.XYDiagram")));
328 			switch(_nChartType)
329 			{
330 				case xlXYScatter:
331 				case xlBubble:                      // not possible
332 				case xlBubble3DEffect:              // not possible
333 					mxDiagramPropertySet->setPropertyValue(LINES, uno::makeAny( sal_False ));
334 					break;
335 				case xlXYScatterLines:
336 				case xlXYScatterLinesNoMarkers:
337 					mxDiagramPropertySet->setPropertyValue(LINES, uno::makeAny( sal_True ));
338 					break;
339 				case xlXYScatterSmooth:
340 				case xlXYScatterSmoothNoMarkers:
341 					mxDiagramPropertySet->setPropertyValue(SPLINETYPE, uno::makeAny( sal_Int32(1)));
342 					break;
343 				default:
344 					break;
345 			}
346 			break;
347 		default:
348 			throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_CONVERSION, rtl::OUString() );
349 	}
350 
351 	switch (_nChartType)
352 	{
353 		case xlLineMarkers:
354 		case xlLineMarkersStacked:
355 		case xlLineMarkersStacked100:
356 		case xlRadarMarkers:
357 		case xlXYScatterLines:
358 		case xlXYScatterSmooth:
359 		case xlXYScatter:
360 		case xlBubble:                      // not possible
361 		case xlBubble3DEffect:              // not possible
362 			mxDiagramPropertySet->setPropertyValue(SYMBOLTYPE, uno::makeAny( chart::ChartSymbolType::AUTO));
363 			break;
364 		default:
365 			if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(SYMBOLTYPE))
366 			{
367 				mxDiagramPropertySet->setPropertyValue(SYMBOLTYPE, uno::makeAny(chart::ChartSymbolType::NONE));
368 			}
369 			break;
370 	}
371 
372 	switch (_nChartType)
373 	{
374 		case xlConeCol:
375 		case xlPyramidCol:
376 		case xlCylinderCol:
377 		case xl3DColumn:
378 		case xlSurface:                         // not possible
379 		case xlSurfaceWireframe:
380 		case xlSurfaceTopView:
381 		case xlSurfaceTopViewWireframe:
382 			mxDiagramPropertySet->setPropertyValue(DEEP,uno::makeAny( sal_True ));
383 			break;
384 		default:
385 				if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(DEEP))
386 				{
387 					mxDiagramPropertySet->setPropertyValue(DEEP, uno::makeAny( sal_False));
388 				}
389 				break;
390 		}
391 
392 
393 		switch (_nChartType)
394 		{
395 				case xlConeColClustered:
396 				case xlConeColStacked:
397 				case xlConeColStacked100:
398 				case xlConeBarClustered:
399 				case xlConeBarStacked:
400 				case xlConeBarStacked100:
401 				case xlConeCol:
402 						mxDiagramPropertySet->setPropertyValue(SOLIDTYPE, uno::makeAny(chart::ChartSolidType::CONE));
403 						break;
404 				case xlPyramidColClustered:
405 				case xlPyramidColStacked:
406 				case xlPyramidColStacked100:
407 				case xlPyramidBarClustered:
408 				case xlPyramidBarStacked:
409 				case xlPyramidBarStacked100:
410 				case xlPyramidCol:
411 						mxDiagramPropertySet->setPropertyValue(SOLIDTYPE, uno::makeAny(chart::ChartSolidType::PYRAMID));
412 						break;
413 				case xlCylinderColClustered:
414 				case xlCylinderColStacked:
415 				case xlCylinderColStacked100:
416 				case xlCylinderBarClustered:
417 				case xlCylinderBarStacked:
418 				case xlCylinderBarStacked100:
419 				case xlCylinderCol:
420 						mxDiagramPropertySet->setPropertyValue(SOLIDTYPE, uno::makeAny(chart::ChartSolidType::CYLINDER));
421 						break;
422 				default:
423 					if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(SOLIDTYPE))
424 					{
425 							mxDiagramPropertySet->setPropertyValue(SOLIDTYPE, uno::makeAny(chart::ChartSolidType::RECTANGULAR_SOLID));
426 					}
427 					break;
428 		}
429 
430 		switch ( _nChartType)
431 		{
432 			case xlConeCol:
433 			case xlConeColClustered:
434 			case xlConeColStacked:
435 			case xlConeColStacked100:
436 			case xlPyramidColClustered:
437 			case xlPyramidColStacked:
438 			case xlPyramidColStacked100:
439 			case xlCylinderColClustered:
440 			case xlCylinderColStacked:
441 			case xlCylinderColStacked100:
442 			case xlColumnClustered:
443 			case xlColumnStacked:
444 			case xlColumnStacked100:
445 			case xl3DColumnClustered:
446 			case xl3DColumnStacked:
447 			case xl3DColumnStacked100:
448 			case xlSurface: // not possible
449 			case xlSurfaceWireframe:
450 			case xlSurfaceTopView:
451 			case xlSurfaceTopViewWireframe:
452 				mxDiagramPropertySet->setPropertyValue(VERTICAL, uno::makeAny( sal_True));
453 				break;
454 			default:
455 				if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(VERTICAL))
456 				{
457 					mxDiagramPropertySet->setPropertyValue(VERTICAL, uno::makeAny(sal_False));
458 				}
459 				break;
460 		}
461 
462 		switch (_nChartType)
463 		{
464 			case xlColumnStacked:
465 			case xl3DColumnStacked:
466 			case xlBarStacked:
467 			case xl3DBarStacked:
468 			case xlLineStacked:
469 			case xlLineMarkersStacked:
470 			case xlAreaStacked:
471 			case xl3DAreaStacked:
472 			case xlCylinderColStacked:
473 			case xlCylinderBarStacked:
474 			case xlConeColStacked:
475 			case xlConeBarStacked:
476 			case xlPyramidColStacked:
477 			case xlPyramidBarStacked:
478 				mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( sal_False ));
479 				mxDiagramPropertySet->setPropertyValue(STACKED, uno::makeAny( sal_True ));
480 				break;
481 			case xlPyramidColStacked100:
482 			case xlPyramidBarStacked100:
483 			case xlConeColStacked100:
484 			case xlConeBarStacked100:
485 			case xlCylinderBarStacked100:
486 			case xlCylinderColStacked100:
487 			case xl3DAreaStacked100:
488 			case xlLineMarkersStacked100:
489 			case xlAreaStacked100:
490 			case xlLineStacked100:
491 			case xl3DBarStacked100:
492 			case xlBarStacked100:
493 			case xl3DColumnStacked100:
494 			case xlColumnStacked100:
495 				mxDiagramPropertySet->setPropertyValue(STACKED, uno::makeAny( sal_True));
496 				mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( sal_True ));
497 				break;
498 			default:
499 				mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( sal_False));
500 				mxDiagramPropertySet->setPropertyValue(STACKED, uno::makeAny( sal_False));
501 				break;
502 		}
503 		switch (_nChartType)
504 		{
505 			case xl3DArea:
506 			case xl3DAreaStacked:
507 			case xl3DAreaStacked100:
508 			case xl3DBarClustered:
509 			case xl3DBarStacked:
510 			case xl3DBarStacked100:
511 			case xl3DColumn:
512 			case xl3DColumnClustered:
513 			case xl3DColumnStacked:
514 			case xl3DColumnStacked100:
515 			case xl3DLine:
516 			case xl3DPie:
517 			case xl3DPieExploded:
518 			case xlConeColClustered:
519 			case xlConeColStacked:
520 			case xlConeColStacked100:
521 			case xlConeBarClustered:
522 			case xlConeBarStacked:
523 			case xlConeBarStacked100:
524 			case xlConeCol:
525 			case xlPyramidColClustered:
526 			case xlPyramidColStacked:
527 			case xlPyramidColStacked100:
528 			case xlPyramidBarClustered:
529 			case xlPyramidBarStacked:
530 			case xlPyramidBarStacked100:
531 			case xlPyramidCol:
532 			case xlCylinderColClustered:
533 			case xlCylinderColStacked:
534 			case xlCylinderColStacked100:
535 			case xlCylinderBarClustered:
536 			case xlCylinderBarStacked:
537 			case xlCylinderBarStacked100:
538 			case xlCylinderCol:
539 				mxDiagramPropertySet->setPropertyValue(DIM3D, uno::makeAny( sal_True));
540 				break;
541 			default:
542 				if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(DIM3D))
543 				{
544 					mxDiagramPropertySet->setPropertyValue(DIM3D, uno::makeAny( sal_False));
545 				}
546 				break;
547 		}
548 	}
549 	catch ( uno::Exception& )
550 	{
551 		throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
552 	}
553 }
554 
555 void SAL_CALL
556 ScVbaChart::Activate() throw (script::BasicErrorException, uno::RuntimeException)
557 {
558 	// #TODO how are Chart sheets handled ( I know we don't even consider
559 	// them in the worksheets/sheets collections ), but.....???
560 	// note: in vba for excel the parent of a Chart sheet is a workbook,
561 	// e.g. 'ThisWorkbook'
562 	uno::Reference< XHelperInterface > xParent( getParent() );
563 	ScVbaChartObject* pChartObj = static_cast< ScVbaChartObject* >( xParent.get() );
564 	if ( pChartObj )
565 		pChartObj->Activate();
566 	else
567 		throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "no ChartObject as parent" ) ) );
568 }
569 
570 void SAL_CALL
571 ScVbaChart::setSourceData( const css::uno::Reference< ::ooo::vba::excel::XRange >& _xCalcRange, const css::uno::Any& _aPlotBy ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
572 {
573 	try
574 	{
575 		uno::Sequence< table::CellRangeAddress > mRangeAddresses(1);
576 		table::CellRangeAddress mSingleRangeAddress;
577 
578 		uno::Reference< sheet::XCellRangeAddressable > xAddressable( _xCalcRange->getCellRange(), uno::UNO_QUERY_THROW );
579 		mSingleRangeAddress = xAddressable->getRangeAddress();
580 
581 		mRangeAddresses[0] = mSingleRangeAddress;
582 
583 		mxTableChart->setRanges(mRangeAddresses);
584 
585 		sal_Bool bsetRowHeaders = sal_False;
586 		sal_Bool bsetColumnHeaders = sal_False;
587 
588 		ScVbaRange* pRange = static_cast< ScVbaRange* >( _xCalcRange.get() );
589 		if ( pRange )
590 		{
591 			ScDocument* pDoc = pRange->getScDocument();
592 			if ( pDoc )
593 			{
594 				bsetRowHeaders = pDoc->HasRowHeader(  static_cast< SCCOL >( mSingleRangeAddress.StartColumn ), static_cast< SCROW >( mSingleRangeAddress.StartRow ), static_cast< SCCOL >( mSingleRangeAddress.EndColumn ), static_cast< SCROW >( mSingleRangeAddress.EndRow ), static_cast< SCTAB >( mSingleRangeAddress.Sheet ) );;
595 				bsetColumnHeaders =  pDoc->HasColHeader(  static_cast< SCCOL >( mSingleRangeAddress.StartColumn ), static_cast< SCROW >( mSingleRangeAddress.StartRow ), static_cast< SCCOL >( mSingleRangeAddress.EndColumn ), static_cast< SCROW >( mSingleRangeAddress.EndRow ), static_cast< SCTAB >( mSingleRangeAddress.Sheet ));
596 ;
597 			}
598 		}
599 		mxTableChart->setHasRowHeaders(bsetRowHeaders);
600 		mxTableChart->setHasColumnHeaders(bsetColumnHeaders);
601 
602 		if ((!bsetColumnHeaders) || (!bsetRowHeaders))
603 		{
604 			uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
605 			if (!bsetColumnHeaders)
606 			{
607 				xChartDataArray->setColumnDescriptions( getDefaultSeriesDescriptions(xChartDataArray->getColumnDescriptions().getLength() ));
608 			}
609 			if (!bsetRowHeaders)
610 			{
611 				xChartDataArray->setRowDescriptions(getDefaultSeriesDescriptions(xChartDataArray->getRowDescriptions().getLength() ));
612 			}
613 		}
614 
615 		if ( _aPlotBy.hasValue() )
616 		{
617 			sal_Int32 nVal = 0;
618 			_aPlotBy >>= nVal;
619 			setPlotBy( nVal );
620 		}
621 		else
622 		{
623 			sal_Int32 nRows =  mSingleRangeAddress.EndRow - mSingleRangeAddress.StartRow;
624 			sal_Int32 nCols = mSingleRangeAddress.EndColumn - mSingleRangeAddress.StartColumn;
625 			// AutoDetect emulation
626 			if ( nRows > nCols )
627 				setPlotBy( xlColumns );
628 			else if ( nRows <= nCols )
629 				setPlotBy( xlRows );
630 		}
631 	}
632 	catch (uno::Exception& )
633 	{
634 		throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
635 	}
636 }
637 
638 uno::Sequence< rtl::OUString >
639 ScVbaChart::getDefaultSeriesDescriptions( sal_Int32 _nCount )
640 {
641 	uno::Sequence< rtl::OUString > sDescriptions ( _nCount );
642 	sal_Int32 nLen = sDescriptions.getLength();
643 	for (sal_Int32 i = 0; i < nLen; i++)
644 	{
645 		sDescriptions[i] = DEFAULTSERIESPREFIX + rtl::OUString::valueOf(i+1);
646 	}
647 	return sDescriptions;
648 }
649 
650 void
651 ScVbaChart::setDefaultChartType() throw ( script::BasicErrorException )
652 {
653 	setChartType( xlColumnClustered );
654 }
655 
656 void
657 ScVbaChart::setPlotBy( ::sal_Int32 _nPlotBy ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
658 {
659 	try
660 	{
661 		if ( !mxDiagramPropertySet.is() )
662 			setDefaultChartType();
663 		switch (_nPlotBy)
664 		{
665 			case xlRows:
666 				mxDiagramPropertySet->setPropertyValue( DATAROWSOURCE,  uno::makeAny( chart::ChartDataRowSource_ROWS ) );
667 				break;
668 			case xlColumns:
669 				mxDiagramPropertySet->setPropertyValue( DATAROWSOURCE, uno::makeAny( chart::ChartDataRowSource_COLUMNS) );
670 				break;
671 			default:
672 				throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
673 		}
674 	}
675 	catch (uno::Exception& )
676 	{
677 		throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
678 	}
679 }
680 
681 ::sal_Int32 SAL_CALL
682 ScVbaChart::getPlotBy(  ) throw (script::BasicErrorException, uno::RuntimeException)
683 {
684 	try
685 	{
686 		chart::ChartDataRowSource aChartDataRowSource;
687 		mxDiagramPropertySet->getPropertyValue(DATAROWSOURCE) >>= aChartDataRowSource;
688 		if (aChartDataRowSource == chart::ChartDataRowSource_COLUMNS)
689 		{
690 			return xlColumns;
691 		}
692 		else
693 		{
694 			return xlRows;
695 		}
696 	}
697 	catch (uno::Exception& )
698 	{
699 		throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
700 	}
701 }
702 
703 void
704 ScVbaChart::setDiagram( const rtl::OUString& _sDiagramType ) throw( script::BasicErrorException )
705 {
706 	try
707 	{
708 		uno::Reference< lang::XMultiServiceFactory > xMSF( mxChartDocument, uno::UNO_QUERY_THROW );
709 		uno::Reference< chart::XDiagram > xDiagram( xMSF->createInstance( _sDiagramType ), uno::UNO_QUERY_THROW  );
710 		mxChartDocument->setDiagram( xDiagram );
711 		mxDiagramPropertySet.set( xDiagram, uno::UNO_QUERY_THROW );
712 	}
713 	catch ( uno::Exception& )
714 	{
715 		throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
716 	}
717 }
718 
719 // #TODO find out why we have Location/getLocation ? there is afaiks no
720 // Location property, just a Location function for the Chart object
721 sal_Int32 SAL_CALL
722 ScVbaChart::Location() throw (css::script::BasicErrorException, css::uno::RuntimeException)
723 {
724 	return getLocation();
725 }
726 
727 sal_Int32 SAL_CALL
728 ScVbaChart::getLocation() throw (css::script::BasicErrorException, css::uno::RuntimeException)
729 {
730 	 return -1;
731 }
732 
733 void SAL_CALL
734 ScVbaChart::setLocation( ::sal_Int32 /*where*/, const css::uno::Any& /*Name*/ ) throw (script::BasicErrorException, uno::RuntimeException)
735 {
736 	// Helper api just stubs out the code <shrug>
737 	// #TODO come back and make sense out of this
738 //        String sheetName = null;
739 //
740 //        if ((name != null) && name instanceof String) {
741 //            sheetName = (String) name;
742 //        }
743 //        XSpreadsheetDocument xShDoc = (XSpreadsheetDocument) UnoRuntime.queryInterface( XSpreadsheetDocument.class,getXModel() );
744 //        com.sun.star.sheet.XSpreadsheets xSheets = xShDoc.Sheets();
745 //
746 //        switch (where) {
747 //        case ClLocationType.clLocationAsObject_value: //{
748 //
749 //            if (sheetName == null) {
750 //                DebugHelper.writeInfo("Can't embed in Chart without knowing SheetName");
751 //                return;
752 //            }
753 //
754 //            try {
755 //                Any any = (Any) xSheets.getByName(sheetName);
756 //                chartSheet = (XSpreadsheet) any.getObject();
757 //
758 //                // chartSheet = (XSpreadsheet) xSheets.getByName( sheetName );
759 //            } catch (NoSuchElementException e) {
760 //                // TODO Auto-generated catch block
761 //                e.printStackTrace();
762 //
763 //                return;
764 //            } catch (WrappedTargetException e) {
765 //                // TODO Auto-generated catch block
766 //                e.printStackTrace();
767 //
768 //                return;
769 //            } catch (java.lang.Exception e) {
770 //                e.printStackTrace();
771 //            }
772 //
773 //            XTableChartsSupplier xTCS = (XTableChartsSupplier) UnoRuntime.queryInterface( XTableChartsSupplier.class, chartSheet);
774 //            XTableCharts xTableCharts = xTCS.getCharts();
775 //            XIndexAccess xIA = (XIndexAccess) UnoRuntime.queryInterface( XIndexAccess.class, xTableCharts);
776 //            int numCharts = xIA.getCount();
777 //            chartName = "Chart " + (numCharts + 1);
778 //
779 //            //}
780 //            break;
781 //
782 //        case ClLocationType.clLocationAsNewSheet_value:
783 //        case ClLocationType.clLocationAutomatic_value:default: //{
784 //            chartName = "Chart 1"; // Since it's a new sheet, it's the first on it...
785 //
786 //            XIndexAccess xSheetIA = (XIndexAccess) UnoRuntime.queryInterface( XIndexAccess.class, xSheets);
787 //
788 //            short newSheetNum = (short) (xSheetIA.getCount() + 1);
789 //
790 //            if (sheetName == null){
791 //                sheetName = "ChartSheet " + newSheetNum; // Why not?
792 //            }
793 //            // DPK TODO : Probably should use Sheets to create this!
794 //            xSheets.insertNewByName(sheetName, newSheetNum);
795 //
796 //            try {
797 //                chartSheet =
798 //                    (XSpreadsheet) xSheets.getByName(sheetName);
799 //            } catch (NoSuchElementException e) {
800 //                // TODO Auto-generated catch block
801 //                e.printStackTrace();
802 //
803 //                return;
804 //            } catch (WrappedTargetException e) {
805 //                // TODO Auto-generated catch block
806 //                e.printStackTrace();
807 //
808 //                return;
809 //            }
810 //
811 //            //}
812 //            break;
813 //        }
814 //
815 //        // Last thing should be a call to createChartForReal(), one of them
816 //        // should succeed.
817 //        createChartForReal();
818 
819 }
820 
821 sal_Bool SAL_CALL
822 ScVbaChart::getHasTitle(  ) throw (script::BasicErrorException, uno::RuntimeException)
823 {
824 	sal_Bool bHasTitle = sal_False;
825 	try
826 	{
827 		mxChartPropertySet->getPropertyValue(HASMAINTITLE) >>= bHasTitle;
828 	}
829 	catch (uno::Exception& )
830 	{
831 		throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
832 	}
833 	return bHasTitle;
834 }
835 
836 void SAL_CALL
837 ScVbaChart::setHasTitle( ::sal_Bool bTitle ) throw (script::BasicErrorException, uno::RuntimeException)
838 {
839 	try
840 	{
841 		mxChartPropertySet->setPropertyValue(HASMAINTITLE, uno::makeAny( bTitle ));
842 	}
843 	catch (uno::Exception& )
844 	{
845 		throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
846 	}
847 
848 }
849 
850 ::sal_Bool SAL_CALL
851 ScVbaChart::getHasLegend(  ) throw (script::BasicErrorException, uno::RuntimeException)
852 {
853 	sal_Bool bHasLegend = sal_False;
854 	try
855 	{
856 		mxChartPropertySet->getPropertyValue(HASLEGEND) >>= bHasLegend;
857 	}
858 	catch (uno::Exception& )
859 	{
860 		throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
861 	}
862 	return bHasLegend;
863 }
864 
865 void SAL_CALL
866 ScVbaChart::setHasLegend( ::sal_Bool bLegend ) throw (script::BasicErrorException, uno::RuntimeException)
867 {
868 	try
869 	{
870 		mxChartPropertySet->setPropertyValue(HASLEGEND, uno::makeAny(bLegend));
871 	}
872 	catch (uno::Exception& )
873 	{
874 		throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
875 	}
876 }
877 
878 uno::Reference< excel::XChartTitle > SAL_CALL
879 ScVbaChart::getChartTitle(  ) throw (script::BasicErrorException, uno::RuntimeException)
880 {
881 	uno::Reference< drawing::XShape > xTitleShape = mxChartDocument->getTitle();
882 	// #TODO check parent
883 	return new ScVbaChartTitle(this, mxContext, xTitleShape);
884 }
885 
886 uno::Any SAL_CALL
887 ScVbaChart::Axes( const uno::Any& Type, const uno::Any& AxisGroup ) throw (script::BasicErrorException, uno::RuntimeException)
888 {
889 	// mmm chart probably is the parent, #TODO check parent
890 	uno::Reference< excel::XAxes > xAxes = new ScVbaAxes( this, mxContext, this );
891 	if ( !Type.hasValue() )
892 		return uno::makeAny( xAxes );
893 	return xAxes->Item( Type, AxisGroup );
894 }
895 bool
896 ScVbaChart::is3D() throw ( uno::RuntimeException )
897 {
898 	// #TODO perhaps provide limited Debughelper functionality
899 	sal_Bool is3d = sal_False;
900 	mxDiagramPropertySet->getPropertyValue(DIM3D) >>= is3d;
901 	return is3d;
902 }
903 
904 sal_Int32
905 ScVbaChart::getStackedType( sal_Int32 _nStacked, sal_Int32 _n100PercentStacked, sal_Int32 _nUnStacked ) throw ( uno::RuntimeException )
906 {
907 	// #TODO perhaps provide limited Debughelper functionality
908 	if (isStacked())
909 	{
910 		if (is100PercentStacked())
911 			return _n100PercentStacked;
912 		else
913 			return _nStacked;
914 	}
915 	else
916 		return _nUnStacked;
917 }
918 
919 bool
920 ScVbaChart::isStacked() throw ( uno::RuntimeException )
921 {
922 	// #TODO perhaps provide limited Debughelper functionality
923 	sal_Bool bStacked = sal_False;
924 	mxDiagramPropertySet->getPropertyValue(STACKED) >>= bStacked;
925 	return bStacked;
926 }
927 
928 bool
929 ScVbaChart::is100PercentStacked() throw ( uno::RuntimeException )
930 {
931 	// #TODO perhaps provide limited Debughelper functionality
932 	sal_Bool b100Percent = sal_False;
933 	mxDiagramPropertySet->getPropertyValue(PERCENT) >>= b100Percent;
934 	return b100Percent;
935 }
936 
937 sal_Int32
938 ScVbaChart::getSolidType(sal_Int32 _nDeep, sal_Int32 _nVertiStacked, sal_Int32 _nVerti100PercentStacked, sal_Int32 _nVertiUnStacked, sal_Int32 _nHoriStacked, sal_Int32 _nHori100PercentStacked, sal_Int32 _nHoriUnStacked) throw ( script::BasicErrorException )
939 {
940 	sal_Bool bIsVertical = true;
941 	try
942 	{
943 		mxDiagramPropertySet->getPropertyValue(VERTICAL) >>= bIsVertical;
944 		sal_Bool bIsDeep = false;
945 		mxDiagramPropertySet->getPropertyValue(DEEP) >>= bIsDeep;
946 
947 		if (bIsDeep)
948 		{
949 			return _nDeep;
950 		}
951 		else
952 		{
953 			if (bIsVertical)
954 			{
955 				return getStackedType(_nVertiStacked, _nVerti100PercentStacked, _nVertiUnStacked);
956 			}
957 			else
958 			{
959 				return getStackedType(_nHoriStacked, _nHori100PercentStacked, _nHoriUnStacked);
960 			}
961 		}
962 	}
963 	catch (uno::Exception& )
964 	{
965 		throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
966 	}
967 }
968 
969 
970 sal_Int32
971 ScVbaChart::getStockUpDownValue(sal_Int32 _nUpDown, sal_Int32 _nNotUpDown) throw (script::BasicErrorException)
972 {
973 	sal_Bool bUpDown = sal_False;
974 	try
975 	{
976 		mxDiagramPropertySet->getPropertyValue(UPDOWN) >>= bUpDown;
977 		if (bUpDown)
978 		{
979 			return _nUpDown;
980 		}
981 		else
982 		{
983 			return _nNotUpDown;
984 		}
985 	}
986 	catch (uno::Exception& )
987 	{
988         rtl::OUString aTemp;    // temporary needed for g++ 3.3.5
989 		script::BasicErrorException( aTemp, uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
990 	}
991 	return _nNotUpDown;
992 }
993 
994 bool
995 ScVbaChart::hasMarkers() throw ( script::BasicErrorException )
996 {
997 	bool bHasMarkers = false;
998 	try
999 	{
1000 		sal_Int32 nSymbol=0;
1001 		mxDiagramPropertySet->getPropertyValue(SYMBOLTYPE) >>= nSymbol;
1002 		bHasMarkers = nSymbol != chart::ChartSymbolType::NONE;
1003 	}
1004 	catch ( uno::Exception& )
1005 	{
1006         rtl::OUString aTemp;    // temporary needed for g++ 3.3.5
1007 		script::BasicErrorException( aTemp, uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
1008 	}
1009 	return bHasMarkers;
1010 }
1011 
1012 sal_Int32
1013 ScVbaChart::getMarkerType(sal_Int32 _nWithMarkers, sal_Int32 _nWithoutMarkers) throw ( script::BasicErrorException )
1014 {
1015 	if (hasMarkers())
1016 		return _nWithMarkers;
1017 	return _nWithoutMarkers;
1018 }
1019 
1020 void
1021 ScVbaChart::assignDiagramAttributes()
1022 {
1023 	xAxisXSupplier.set( mxDiagramPropertySet, uno::UNO_QUERY_THROW );
1024 	xAxisYSupplier.set( mxDiagramPropertySet, uno::UNO_QUERY_THROW );
1025 	xAxisZSupplier.set( mxDiagramPropertySet, uno::UNO_QUERY_THROW );
1026 	xTwoAxisXSupplier.set( mxDiagramPropertySet, uno::UNO_QUERY_THROW );
1027 	xTwoAxisYSupplier.set( mxDiagramPropertySet, uno::UNO_QUERY_THROW );
1028 }
1029 
1030 bool
1031 ScVbaChart::isSeriesIndexValid(sal_Int32 _seriesindex) throw( script::BasicErrorException )
1032 {
1033 	bool bret = false;
1034 	try
1035 	{
1036 		uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
1037 		//        dblValues = xChartDataArray.getData();
1038 		//TODO I guess we have to differentiate between XlRowCol
1039 		if ( !xChartDataArray.is() )
1040 		{
1041 			if (getPlotBy() == xlRows)
1042 			{
1043 				if ((_seriesindex < xChartDataArray->getRowDescriptions().getLength() ) && (_seriesindex >= 0))
1044 					bret = true;
1045 			}
1046 			else
1047 			{
1048 				if ((_seriesindex < xChartDataArray->getColumnDescriptions().getLength() ) && (_seriesindex >= 0))
1049 					bret = true;
1050 			}
1051 		}
1052 	}
1053 	catch (uno::Exception& )
1054 	{
1055 		throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
1056 	}
1057 	if (!bret)
1058 	{
1059 		throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_OUT_OF_RANGE, rtl::OUString() );
1060 	}
1061 	return bret;
1062 }
1063 
1064 bool
1065 ScVbaChart::areIndicesValid( sal_Int32 _seriesindex, sal_Int32 _valindex) throw ( css::script::BasicErrorException )
1066 {
1067 	if (isSeriesIndexValid(_seriesindex))
1068 	{
1069 		uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
1070 		dblValues = xChartDataArray->getData();
1071 		return (_valindex < dblValues[_seriesindex].getLength() );
1072         }
1073 	return false;
1074 }
1075 
1076 sal_Int32
1077 ScVbaChart::getSeriesIndex(rtl::OUString _sseriesname) throw ( script::BasicErrorException )
1078 {
1079 	uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
1080 	if (getPlotBy() == xlRows)
1081 		return ContainerUtilities::FieldInList(xChartDataArray->getRowDescriptions(), _sseriesname);
1082 	return ContainerUtilities::FieldInList(xChartDataArray->getColumnDescriptions(), _sseriesname);
1083 }
1084 void
1085 ScVbaChart::setSeriesName(sal_Int32 _index, rtl::OUString _sname) throw ( script::BasicErrorException )
1086 {
1087 	uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
1088 	if (isSeriesIndexValid(_index))
1089 	{
1090 		uno::Sequence< rtl::OUString > sDescriptions = xChartDataArray->getColumnDescriptions();
1091 		sDescriptions[_index] = _sname;
1092 		xChartDataArray->setColumnDescriptions(sDescriptions);
1093 	}
1094 }
1095 
1096 sal_Int32
1097 ScVbaChart::getSeriesCount() throw ( script::BasicErrorException )
1098 {
1099 	uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
1100 
1101 	if (getPlotBy() == xlRows)
1102 		return xChartDataArray->getRowDescriptions().getLength();
1103 	return xChartDataArray->getColumnDescriptions().getLength();
1104 
1105 }
1106 
1107 rtl::OUString
1108 ScVbaChart::getSeriesName(sal_Int32 _index) throw ( script::BasicErrorException )
1109 {
1110 	uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
1111         uno::Sequence< rtl::OUString > sDescriptions;
1112 	rtl::OUString sName;
1113 	if (isSeriesIndexValid(_index))
1114 	{
1115 		if (getPlotBy() == xlRows)
1116 			sDescriptions = xChartDataArray->getRowDescriptions();
1117 		else
1118 			sDescriptions = xChartDataArray->getColumnDescriptions();
1119 		sName =  sDescriptions[_index];
1120         }
1121         return sName;
1122 }
1123 
1124 double
1125 ScVbaChart::getValue(sal_Int32 _seriesindex, sal_Int32 _valindex) throw ( script::BasicErrorException )
1126 {
1127 	double result = -1.0;
1128 	if (areIndicesValid(_seriesindex, _valindex))
1129 	{
1130 		if (getPlotBy() == xlRows)
1131 			result =  dblValues[_seriesindex][_valindex];
1132 		else
1133 			result =  dblValues[_valindex][_seriesindex];
1134 	}
1135 	return result;
1136 }
1137 
1138 sal_Int32
1139 ScVbaChart::getValuesCount(sal_Int32 _seriesIndex) throw ( script::BasicErrorException )
1140 {
1141 	sal_Int32 nCount = 0;
1142 	uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
1143 	if (isSeriesIndexValid(_seriesIndex))
1144 	{
1145 		dblValues = xChartDataArray->getData();
1146 		if (getPlotBy() == xlRows)
1147 			nCount = dblValues[_seriesIndex].getLength();
1148 		else
1149 			nCount =  dblValues.getLength();
1150 	}
1151 	return nCount;
1152 }
1153 
1154 
1155 uno::Reference< excel::XDataLabels >
1156 ScVbaChart::DataLabels( const uno::Reference< ov::excel::XSeries > /*_oSeries*/ ) throw ( css::script::BasicErrorException )
1157 {
1158 	if ( true )
1159 		throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
1160 	// #TODO #FIXE provide implementation
1161 	return uno::Reference< excel::XDataLabels > ();
1162 }
1163 
1164 bool
1165 ScVbaChart::getHasDataCaption( const uno::Reference< css::beans::XPropertySet >& _xPropertySet )throw ( script::BasicErrorException )
1166 {
1167 	bool bResult = false;
1168 	try
1169 	{
1170 		sal_Int32 nChartDataCaption = 0;
1171 		_xPropertySet->getPropertyValue(DATACAPTION) >>= nChartDataCaption;
1172 		bResult = (nChartDataCaption != chart::ChartDataCaption::NONE);
1173 	}
1174 	catch (uno::Exception& )
1175 	{
1176 		throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
1177 	}
1178 	return bResult;
1179 }
1180 
1181 void
1182 ScVbaChart::setHasDataCaption( const uno::Reference< beans::XPropertySet >& _xPropertySet, bool _bHasDataLabels )throw ( script::BasicErrorException )
1183 {
1184 	try
1185 	{
1186 		if ( _bHasDataLabels )
1187 			_xPropertySet->setPropertyValue(DATACAPTION, uno::makeAny ( chart::ChartDataCaption::VALUE) );
1188 		else
1189 			_xPropertySet->setPropertyValue(DATACAPTION, uno::makeAny ( chart::ChartDataCaption::NONE) );
1190 	}
1191 	catch (uno::Exception& )
1192 	{
1193 		throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
1194 	}
1195 }
1196 
1197 uno::Reference< beans::XPropertySet >
1198 ScVbaChart::getAxisPropertySet(sal_Int32 _nAxisType, sal_Int32 _nAxisGroup) throw ( script::BasicErrorException )
1199 {
1200 	assignDiagramAttributes();
1201 	uno::Reference< beans::XPropertySet > xAxisProps;
1202 	switch(_nAxisType)
1203 	{
1204 		case xlCategory:
1205 			if (_nAxisGroup == xlPrimary)
1206 			{
1207 				xAxisProps = xAxisXSupplier->getXAxis();
1208 			}
1209 			else if (_nAxisGroup == xlSecondary)
1210 			{
1211 				xAxisProps = xTwoAxisXSupplier->getSecondaryXAxis();
1212 			}
1213 			break;
1214 		case xlSeriesAxis:
1215 //                if (_nAxisGroup == xlPrimary){
1216 			xAxisProps = xAxisZSupplier->getZAxis();
1217 			break;
1218 //                }
1219 //                else if (_nAxisGroup == xlSecondary){
1220  //                   return xTwoAxisXSupplier.getSecondaryZAxis();
1221  //               }
1222 		case xlValue:
1223 			if (_nAxisGroup == xlPrimary)
1224 				xAxisProps = xAxisYSupplier->getYAxis();
1225 			else if (_nAxisGroup == xlSecondary)
1226 				xAxisProps = xTwoAxisYSupplier->getSecondaryYAxis();
1227 			break;
1228 		default:
1229 			return xAxisProps;
1230 		}
1231 	return xAxisProps;
1232 }
1233 
1234 
1235 rtl::OUString&
1236 ScVbaChart::getServiceImplName()
1237 {
1238 	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaChart") );
1239 	return sImplName;
1240 }
1241 
1242 uno::Sequence< rtl::OUString >
1243 ScVbaChart::getServiceNames()
1244 {
1245 	static uno::Sequence< rtl::OUString > aServiceNames;
1246 	if ( aServiceNames.getLength() == 0 )
1247 	{
1248 		aServiceNames.realloc( 1 );
1249 		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Chart" ) );
1250 	}
1251 	return aServiceNames;
1252 }
1253 
1254