update dev300-m58
[ooovba.git] / sc / source / ui / vba / vbachart.cxx
blobf5085776180d37e88ad66e138a38de1506b9d925
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: vbachart.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "vbachart.hxx"
31 #include <com/sun/star/beans/XPropertySet.hpp>
32 #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
33 #include <com/sun/star/chart/XAxisXSupplier.hpp>
34 #include <com/sun/star/chart/XAxisYSupplier.hpp>
35 #include <com/sun/star/chart/XAxisZSupplier.hpp>
36 #include <com/sun/star/chart/XTwoAxisXSupplier.hpp>
37 #include <com/sun/star/chart/XTwoAxisYSupplier.hpp>
38 #include <com/sun/star/chart/XChartDataArray.hpp>
39 #include <com/sun/star/chart/ChartSymbolType.hpp>
40 #include <com/sun/star/chart/ChartSolidType.hpp>
41 #include <com/sun/star/chart/ChartDataRowSource.hpp>
42 #include <com/sun/star/chart/ChartDataCaption.hpp>
43 #include <ooo/vba/excel/XlChartType.hpp>
44 #include <ooo/vba/excel/XlRowCol.hpp>
45 #include <ooo/vba/excel/XlAxisType.hpp>
46 #include <ooo/vba/excel/XlAxisGroup.hpp>
48 #include <basic/sberrors.hxx>
49 #include "vbachartobject.hxx"
50 #include "vbarange.hxx"
51 #include "vbacharttitle.hxx"
52 #include "vbaaxes.hxx"
54 using namespace ::com::sun::star;
55 using namespace ::ooo::vba;
56 using namespace ::ooo::vba::excel::XlChartType;
57 using namespace ::ooo::vba::excel::XlRowCol;
58 using namespace ::ooo::vba::excel::XlAxisType;
59 using namespace ::ooo::vba::excel::XlAxisGroup;
61 const rtl::OUString CHART_NAME( RTL_CONSTASCII_USTRINGPARAM("Name") );
62 // #TODO move this constant to vbaseries.[ch]xx ( when it exists )
63 const rtl::OUString DEFAULTSERIESPREFIX( RTL_CONSTASCII_USTRINGPARAM("Series") );
64 const rtl::OUString DATAROWSOURCE( RTL_CONSTASCII_USTRINGPARAM("DataRowSource") );
65 const rtl::OUString UPDOWN( RTL_CONSTASCII_USTRINGPARAM("UpDown") );
66 const rtl::OUString VOLUME( RTL_CONSTASCII_USTRINGPARAM("Volume") );
67 const rtl::OUString LINES( RTL_CONSTASCII_USTRINGPARAM("Lines") );
68 const rtl::OUString SPLINETYPE( RTL_CONSTASCII_USTRINGPARAM("SplineType") );
69 const rtl::OUString SYMBOLTYPE( RTL_CONSTASCII_USTRINGPARAM("SymbolType") );
70 const rtl::OUString DEEP( RTL_CONSTASCII_USTRINGPARAM("Deep") );
71 const rtl::OUString SOLIDTYPE( RTL_CONSTASCII_USTRINGPARAM("SolidType") );
72 const rtl::OUString VERTICAL( RTL_CONSTASCII_USTRINGPARAM("Vertical") );
73 const rtl::OUString PERCENT( RTL_CONSTASCII_USTRINGPARAM("Percent") );
74 const rtl::OUString STACKED( RTL_CONSTASCII_USTRINGPARAM("Stacked") );
75 const rtl::OUString DIM3D( RTL_CONSTASCII_USTRINGPARAM("Dim3D") );
76 const rtl::OUString HASMAINTITLE( RTL_CONSTASCII_USTRINGPARAM("HasMainTitle") );
77 const rtl::OUString HASLEGEND( RTL_CONSTASCII_USTRINGPARAM("HasLegend") );
78 const rtl::OUString DATACAPTION( RTL_CONSTASCII_USTRINGPARAM("DataCaption") );
80 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 )
82 mxChartDocument.set( _xChartComponent, uno::UNO_QUERY_THROW ) ;
83 // #TODO is is possible that the XPropertySet interface is not set
84 // code in setPlotBy seems to indicate that this is possible? but
85 // additionally there is no check in most of the places where it is used
86 // ( and therefore could possibly be NULL )
87 // I'm going to let it throw for the moment ( npower )
88 mxDiagramPropertySet.set( mxChartDocument->getDiagram(), uno::UNO_QUERY_THROW );
89 mxChartPropertySet.set( _xChartComponent, uno::UNO_QUERY_THROW ) ;
92 ::rtl::OUString SAL_CALL
93 ScVbaChart::getName() throw (css::uno::RuntimeException)
95 rtl::OUString sName;
96 uno::Reference< beans::XPropertySet > xProps( mxChartDocument, uno::UNO_QUERY_THROW );
97 try
99 xProps->getPropertyValue( CHART_NAME ) >>= sName;
101 catch( uno::Exception e ) // swallow exceptions
104 return sName;
107 uno::Any SAL_CALL
108 ScVbaChart::SeriesCollection(const uno::Any&) throw (uno::RuntimeException)
110 return uno::Any();
113 ::sal_Int32 SAL_CALL
114 ScVbaChart::getChartType() throw ( uno::RuntimeException, script::BasicErrorException)
116 sal_Int32 nChartType = -1;
119 rtl::OUString sDiagramType = mxChartDocument->getDiagram()->getDiagramType();
120 if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart.AreaDiagram" ))))
122 if (is3D())
124 nChartType = getStackedType(xl3DAreaStacked, xl3DAreaStacked100, xl3DArea);
126 else
128 nChartType = getStackedType(xlAreaStacked, xlAreaStacked100, xlArea);
131 else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.PieDiagram"))))
133 if (is3D())
134 nChartType = xl3DPie;
135 else
136 nChartType = xlPie; /*TODO XlChartType xlPieExploded, XlChartType xlPieOfPie */
138 else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.BarDiagram"))))
140 sal_Int32 nSolidType = chart::ChartSolidType::RECTANGULAR_SOLID;
141 if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(SOLIDTYPE))
142 { //in 2D diagrams 'SolidType' may not be set
143 if (is3D())
144 mxDiagramPropertySet->getPropertyValue(SOLIDTYPE) >>= nSolidType;
146 switch (nSolidType)
148 case chart::ChartSolidType::CONE:
149 nChartType = getSolidType(xlConeCol, xlConeColStacked, xlConeColStacked100, xlConeColClustered, xlConeBarStacked, xlConeBarStacked100, xlConeBarClustered);
150 break;
151 case chart::ChartSolidType::CYLINDER:
152 nChartType = getSolidType(xlCylinderCol, xlCylinderColStacked, xlCylinderColStacked100, xlCylinderColClustered, xlCylinderBarStacked, xlCylinderBarStacked100, xlCylinderBarClustered);
153 break;
154 case chart::ChartSolidType::PYRAMID:
155 nChartType = getSolidType(xlPyramidCol, xlPyramidColStacked, xlPyramidColStacked100, xlPyramidColClustered, xlPyramidBarStacked, xlPyramidBarStacked100, xlPyramidBarClustered);
156 break;
157 default: // RECTANGULAR_SOLID
158 if (is3D())
160 nChartType = getSolidType(xl3DColumn, xl3DColumnStacked, xl3DColumnStacked100, xl3DColumnClustered, xl3DBarStacked, xl3DBarStacked100, xl3DBarClustered);
162 else
164 nChartType = getSolidType(xlColumnClustered, xlColumnStacked, xlColumnStacked100, xlColumnClustered, xlBarStacked, xlBarStacked100, xlBarClustered);
166 break;
169 else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.StockDiagram"))))
171 sal_Bool bVolume = sal_False;
172 mxDiagramPropertySet->getPropertyValue(VOLUME) >>= bVolume;
173 if (bVolume)
175 nChartType = getStockUpDownValue(xlStockVOHLC, xlStockVHLC);
177 else
179 nChartType = getStockUpDownValue(xlStockOHLC, xlStockHLC);
182 else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.XYDiagram"))))
184 sal_Bool bHasLines = sal_False;
185 mxDiagramPropertySet->getPropertyValue(LINES) >>= bHasLines;
186 sal_Int32 nSplineType = 0;
187 mxDiagramPropertySet->getPropertyValue(SPLINETYPE) >>= nSplineType;
188 if (nSplineType == 1)
190 nChartType = getMarkerType(xlXYScatterSmooth, xlXYScatterSmoothNoMarkers);
192 else if (bHasLines)
194 nChartType = getMarkerType(xlXYScatterLines, xlXYScatterLinesNoMarkers);
196 else
198 nChartType = xlXYScatter;
201 else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.LineDiagram"))))
203 if (is3D())
205 nChartType = xl3DLine;
207 else if (hasMarkers())
209 nChartType = getStackedType(xlLineMarkersStacked, xlLineMarkersStacked100, xlLineMarkers);
211 else
213 nChartType = getStackedType(xlLineStacked, xlLineStacked100, xlLine);
216 else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.DonutDiagram"))))
218 nChartType = xlDoughnut; // TODO DoughnutExploded ??
220 else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.NetDiagram"))))
222 nChartType = getMarkerType(xlRadarMarkers, xlRadar);
225 catch (uno::Exception& )
227 throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
229 return nChartType;
232 void SAL_CALL
233 ScVbaChart::setChartType( ::sal_Int32 _nChartType ) throw ( uno::RuntimeException, script::BasicErrorException)
237 switch (_nChartType)
239 case xlColumnClustered:
240 case xlColumnStacked:
241 case xlColumnStacked100:
242 case xl3DColumnClustered:
243 case xl3DColumnStacked:
244 case xl3DColumnStacked100:
245 case xl3DColumn:
246 case xlBarClustered:
247 case xlBarStacked:
248 case xlBarStacked100:
249 case xl3DBarClustered:
250 case xl3DBarStacked:
251 case xl3DBarStacked100:
252 case xlConeColClustered:
253 case xlConeColStacked:
254 case xlConeColStacked100:
255 case xlConeBarClustered:
256 case xlConeBarStacked:
257 case xlConeBarStacked100:
258 case xlConeCol:
259 case xlPyramidColClustered:
260 case xlPyramidColStacked:
261 case xlPyramidColStacked100:
262 case xlPyramidBarClustered:
263 case xlPyramidBarStacked:
264 case xlPyramidBarStacked100:
265 case xlPyramidCol:
266 case xlCylinderColClustered:
267 case xlCylinderColStacked:
268 case xlCylinderColStacked100:
269 case xlCylinderBarClustered:
270 case xlCylinderBarStacked:
271 case xlCylinderBarStacked100:
272 case xlCylinderCol:
273 case xlSurface: // not possible
274 case xlSurfaceWireframe:
275 case xlSurfaceTopView:
276 case xlSurfaceTopViewWireframe:
277 setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.BarDiagram")));
278 break;
279 case xlLine:
280 case xl3DLine:
281 case xlLineStacked:
282 case xlLineStacked100:
283 case xlLineMarkers:
284 case xlLineMarkersStacked:
285 case xlLineMarkersStacked100:
286 setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.LineDiagram")));
287 break;
288 case xl3DArea:
289 case xlArea:
290 case xlAreaStacked:
291 case xlAreaStacked100:
292 case xl3DAreaStacked:
293 case xl3DAreaStacked100:
294 setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.AreaDiagram")) );
295 break;
296 case xlDoughnut:
297 case xlDoughnutExploded:
298 setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.DonutDiagram") ) );
299 break;
300 case xlStockHLC:
301 case xlStockOHLC:
302 case xlStockVHLC:
303 case xlStockVOHLC:
304 setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.StockDiagram")));
305 mxDiagramPropertySet->setPropertyValue( UPDOWN, uno::makeAny(sal_Bool((_nChartType == xlStockOHLC) || (_nChartType == xlStockVOHLC))));
306 mxDiagramPropertySet->setPropertyValue(VOLUME, uno::makeAny(sal_Bool((_nChartType == xlStockVHLC) || (_nChartType == xlStockVOHLC))));
307 break;
309 case xlPieOfPie: // not possible
310 case xlPieExploded: // SegmentOffset an ChartDataPointProperties ->am XDiagram abholen //wie macht Excel das?
311 case xl3DPieExploded:
312 case xl3DPie:
313 case xlPie:
314 case xlBarOfPie: // not possible (Zoom pie)
315 setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.PieDiagram")));
316 break;
318 case xlRadar:
319 case xlRadarMarkers:
320 case xlRadarFilled:
321 setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.NetDiagram")));
322 break;
323 case xlXYScatter:
324 case xlBubble: // not possible
325 case xlBubble3DEffect: // not possible
326 case xlXYScatterLines:
327 case xlXYScatterLinesNoMarkers:
328 case xlXYScatterSmooth:
329 case xlXYScatterSmoothNoMarkers:
330 setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.XYDiagram")));
331 switch(_nChartType)
333 case xlXYScatter:
334 case xlBubble: // not possible
335 case xlBubble3DEffect: // not possible
336 mxDiagramPropertySet->setPropertyValue(LINES, uno::makeAny( sal_False ));
337 break;
338 case xlXYScatterLines:
339 case xlXYScatterLinesNoMarkers:
340 mxDiagramPropertySet->setPropertyValue(LINES, uno::makeAny( sal_True ));
341 break;
342 case xlXYScatterSmooth:
343 case xlXYScatterSmoothNoMarkers:
344 mxDiagramPropertySet->setPropertyValue(SPLINETYPE, uno::makeAny( sal_Int32(1)));
345 break;
346 default:
347 break;
349 break;
350 default:
351 throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_CONVERSION, rtl::OUString() );
354 switch (_nChartType)
356 case xlLineMarkers:
357 case xlLineMarkersStacked:
358 case xlLineMarkersStacked100:
359 case xlRadarMarkers:
360 case xlXYScatterLines:
361 case xlXYScatterSmooth:
362 case xlXYScatter:
363 case xlBubble: // not possible
364 case xlBubble3DEffect: // not possible
365 mxDiagramPropertySet->setPropertyValue(SYMBOLTYPE, uno::makeAny( chart::ChartSymbolType::AUTO));
366 break;
367 default:
368 if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(SYMBOLTYPE))
370 mxDiagramPropertySet->setPropertyValue(SYMBOLTYPE, uno::makeAny(chart::ChartSymbolType::NONE));
372 break;
375 switch (_nChartType)
377 case xlConeCol:
378 case xlPyramidCol:
379 case xlCylinderCol:
380 case xl3DColumn:
381 case xlSurface: // not possible
382 case xlSurfaceWireframe:
383 case xlSurfaceTopView:
384 case xlSurfaceTopViewWireframe:
385 mxDiagramPropertySet->setPropertyValue(DEEP,uno::makeAny( sal_True ));
386 break;
387 default:
388 if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(DEEP))
390 mxDiagramPropertySet->setPropertyValue(DEEP, uno::makeAny( sal_False));
392 break;
396 switch (_nChartType)
398 case xlConeColClustered:
399 case xlConeColStacked:
400 case xlConeColStacked100:
401 case xlConeBarClustered:
402 case xlConeBarStacked:
403 case xlConeBarStacked100:
404 case xlConeCol:
405 mxDiagramPropertySet->setPropertyValue(SOLIDTYPE, uno::makeAny(chart::ChartSolidType::CONE));
406 break;
407 case xlPyramidColClustered:
408 case xlPyramidColStacked:
409 case xlPyramidColStacked100:
410 case xlPyramidBarClustered:
411 case xlPyramidBarStacked:
412 case xlPyramidBarStacked100:
413 case xlPyramidCol:
414 mxDiagramPropertySet->setPropertyValue(SOLIDTYPE, uno::makeAny(chart::ChartSolidType::PYRAMID));
415 break;
416 case xlCylinderColClustered:
417 case xlCylinderColStacked:
418 case xlCylinderColStacked100:
419 case xlCylinderBarClustered:
420 case xlCylinderBarStacked:
421 case xlCylinderBarStacked100:
422 case xlCylinderCol:
423 mxDiagramPropertySet->setPropertyValue(SOLIDTYPE, uno::makeAny(chart::ChartSolidType::CYLINDER));
424 break;
425 default:
426 if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(SOLIDTYPE))
428 mxDiagramPropertySet->setPropertyValue(SOLIDTYPE, uno::makeAny(chart::ChartSolidType::RECTANGULAR_SOLID));
430 break;
433 switch ( _nChartType)
435 case xlConeCol:
436 case xlConeColClustered:
437 case xlConeColStacked:
438 case xlConeColStacked100:
439 case xlPyramidColClustered:
440 case xlPyramidColStacked:
441 case xlPyramidColStacked100:
442 case xlCylinderColClustered:
443 case xlCylinderColStacked:
444 case xlCylinderColStacked100:
445 case xlColumnClustered:
446 case xlColumnStacked:
447 case xlColumnStacked100:
448 case xl3DColumnClustered:
449 case xl3DColumnStacked:
450 case xl3DColumnStacked100:
451 case xlSurface: // not possible
452 case xlSurfaceWireframe:
453 case xlSurfaceTopView:
454 case xlSurfaceTopViewWireframe:
455 mxDiagramPropertySet->setPropertyValue(VERTICAL, uno::makeAny( sal_True));
456 break;
457 default:
458 if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(VERTICAL))
460 mxDiagramPropertySet->setPropertyValue(VERTICAL, uno::makeAny(sal_False));
462 break;
465 switch (_nChartType)
467 case xlColumnStacked:
468 case xl3DColumnStacked:
469 case xlBarStacked:
470 case xl3DBarStacked:
471 case xlLineStacked:
472 case xlLineMarkersStacked:
473 case xlAreaStacked:
474 case xl3DAreaStacked:
475 case xlCylinderColStacked:
476 case xlCylinderBarStacked:
477 case xlConeColStacked:
478 case xlConeBarStacked:
479 case xlPyramidColStacked:
480 case xlPyramidBarStacked:
481 mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( sal_False ));
482 mxDiagramPropertySet->setPropertyValue(STACKED, uno::makeAny( sal_True ));
483 break;
484 case xlPyramidColStacked100:
485 case xlPyramidBarStacked100:
486 case xlConeColStacked100:
487 case xlConeBarStacked100:
488 case xlCylinderBarStacked100:
489 case xlCylinderColStacked100:
490 case xl3DAreaStacked100:
491 case xlLineMarkersStacked100:
492 case xlAreaStacked100:
493 case xlLineStacked100:
494 case xl3DBarStacked100:
495 case xlBarStacked100:
496 case xl3DColumnStacked100:
497 case xlColumnStacked100:
498 mxDiagramPropertySet->setPropertyValue(STACKED, uno::makeAny( sal_True));
499 mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( sal_True ));
500 break;
501 default:
502 mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( sal_False));
503 mxDiagramPropertySet->setPropertyValue(STACKED, uno::makeAny( sal_False));
504 break;
506 switch (_nChartType)
508 case xl3DArea:
509 case xl3DAreaStacked:
510 case xl3DAreaStacked100:
511 case xl3DBarClustered:
512 case xl3DBarStacked:
513 case xl3DBarStacked100:
514 case xl3DColumn:
515 case xl3DColumnClustered:
516 case xl3DColumnStacked:
517 case xl3DColumnStacked100:
518 case xl3DLine:
519 case xl3DPie:
520 case xl3DPieExploded:
521 case xlConeColClustered:
522 case xlConeColStacked:
523 case xlConeColStacked100:
524 case xlConeBarClustered:
525 case xlConeBarStacked:
526 case xlConeBarStacked100:
527 case xlConeCol:
528 case xlPyramidColClustered:
529 case xlPyramidColStacked:
530 case xlPyramidColStacked100:
531 case xlPyramidBarClustered:
532 case xlPyramidBarStacked:
533 case xlPyramidBarStacked100:
534 case xlPyramidCol:
535 case xlCylinderColClustered:
536 case xlCylinderColStacked:
537 case xlCylinderColStacked100:
538 case xlCylinderBarClustered:
539 case xlCylinderBarStacked:
540 case xlCylinderBarStacked100:
541 case xlCylinderCol:
542 mxDiagramPropertySet->setPropertyValue(DIM3D, uno::makeAny( sal_True));
543 break;
544 default:
545 if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(DIM3D))
547 mxDiagramPropertySet->setPropertyValue(DIM3D, uno::makeAny( sal_False));
549 break;
552 catch ( uno::Exception& )
554 throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
558 void SAL_CALL
559 ScVbaChart::Activate() throw (script::BasicErrorException, uno::RuntimeException)
561 // #TODO how are Chart sheets handled ( I know we don't even consider
562 // them in the worksheets/sheets collections ), but.....???
563 // note: in vba for excel the parent of a Chart sheet is a workbook,
564 // e.g. 'ThisWorkbook'
565 uno::Reference< XHelperInterface > xParent( getParent() );
566 ScVbaChartObject* pChartObj = static_cast< ScVbaChartObject* >( xParent.get() );
567 if ( pChartObj )
568 pChartObj->Activate();
569 else
570 throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "no ChartObject as parent" ) ) );
573 void SAL_CALL
574 ScVbaChart::setSourceData( const css::uno::Reference< ::ooo::vba::excel::XRange >& _xCalcRange, const css::uno::Any& _aPlotBy ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
578 uno::Sequence< table::CellRangeAddress > mRangeAddresses(1);
579 table::CellRangeAddress mSingleRangeAddress;
581 uno::Reference< sheet::XCellRangeAddressable > xAddressable( _xCalcRange->getCellRange(), uno::UNO_QUERY_THROW );
582 mSingleRangeAddress = xAddressable->getRangeAddress();
584 mRangeAddresses[0] = mSingleRangeAddress;
586 mxTableChart->setRanges(mRangeAddresses);
588 sal_Bool bsetRowHeaders = sal_False;
589 sal_Bool bsetColumnHeaders = sal_False;
591 ScVbaRange* pRange = static_cast< ScVbaRange* >( _xCalcRange.get() );
592 if ( pRange )
594 ScDocument* pDoc = pRange->getScDocument();
595 if ( pDoc )
597 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 ) );;
598 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 ));
602 mxTableChart->setHasRowHeaders(bsetRowHeaders);
603 mxTableChart->setHasColumnHeaders(bsetColumnHeaders);
605 if ((!bsetColumnHeaders) || (!bsetRowHeaders))
607 uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
608 if (!bsetColumnHeaders)
610 xChartDataArray->setColumnDescriptions( getDefaultSeriesDescriptions(xChartDataArray->getColumnDescriptions().getLength() ));
612 if (!bsetRowHeaders)
614 xChartDataArray->setRowDescriptions(getDefaultSeriesDescriptions(xChartDataArray->getRowDescriptions().getLength() ));
618 if ( _aPlotBy.hasValue() )
620 sal_Int32 nVal = 0;
621 _aPlotBy >>= nVal;
622 setPlotBy( nVal );
624 else
626 sal_Int32 nRows = mSingleRangeAddress.EndRow - mSingleRangeAddress.StartRow;
627 sal_Int32 nCols = mSingleRangeAddress.EndColumn - mSingleRangeAddress.StartColumn;
628 // AutoDetect emulation
629 if ( nRows > nCols )
630 setPlotBy( xlColumns );
631 else if ( nRows <= nCols )
632 setPlotBy( xlRows );
635 catch (uno::Exception& )
637 throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
641 uno::Sequence< rtl::OUString >
642 ScVbaChart::getDefaultSeriesDescriptions( sal_Int32 _nCount )
644 uno::Sequence< rtl::OUString > sDescriptions ( _nCount );
645 sal_Int32 nLen = sDescriptions.getLength();
646 for (sal_Int32 i = 0; i < nLen; i++)
648 sDescriptions[i] = DEFAULTSERIESPREFIX + rtl::OUString::valueOf(i+1);
650 return sDescriptions;
653 void
654 ScVbaChart::setDefaultChartType() throw ( script::BasicErrorException )
656 setChartType( xlColumnClustered );
659 void
660 ScVbaChart::setPlotBy( ::sal_Int32 _nPlotBy ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
664 if ( !mxDiagramPropertySet.is() )
665 setDefaultChartType();
666 switch (_nPlotBy)
668 case xlRows:
669 mxDiagramPropertySet->setPropertyValue( DATAROWSOURCE, uno::makeAny( chart::ChartDataRowSource_ROWS ) );
670 break;
671 case xlColumns:
672 mxDiagramPropertySet->setPropertyValue( DATAROWSOURCE, uno::makeAny( chart::ChartDataRowSource_COLUMNS) );
673 break;
674 default:
675 throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
678 catch (uno::Exception& )
680 throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
684 ::sal_Int32 SAL_CALL
685 ScVbaChart::getPlotBy( ) throw (script::BasicErrorException, uno::RuntimeException)
689 chart::ChartDataRowSource aChartDataRowSource;
690 mxDiagramPropertySet->getPropertyValue(DATAROWSOURCE) >>= aChartDataRowSource;
691 if (aChartDataRowSource == chart::ChartDataRowSource_COLUMNS)
693 return xlColumns;
695 else
697 return xlRows;
700 catch (uno::Exception& )
702 throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
706 void
707 ScVbaChart::setDiagram( const rtl::OUString& _sDiagramType ) throw( script::BasicErrorException )
711 uno::Reference< lang::XMultiServiceFactory > xMSF( mxChartDocument, uno::UNO_QUERY_THROW );
712 uno::Reference< chart::XDiagram > xDiagram( xMSF->createInstance( _sDiagramType ), uno::UNO_QUERY_THROW );
713 mxChartDocument->setDiagram( xDiagram );
714 mxDiagramPropertySet.set( xDiagram, uno::UNO_QUERY_THROW );
716 catch ( uno::Exception& )
718 throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
722 // #TODO find out why we have Location/getLocation ? there is afaiks no
723 // Location property, just a Location function for the Chart object
724 sal_Int32 SAL_CALL
725 ScVbaChart::Location() throw (css::script::BasicErrorException, css::uno::RuntimeException)
727 return getLocation();
730 sal_Int32 SAL_CALL
731 ScVbaChart::getLocation() throw (css::script::BasicErrorException, css::uno::RuntimeException)
733 return -1;
736 void SAL_CALL
737 ScVbaChart::setLocation( ::sal_Int32 /*where*/, const css::uno::Any& /*Name*/ ) throw (script::BasicErrorException, uno::RuntimeException)
739 // Helper api just stubs out the code <shrug>
740 // #TODO come back and make sense out of this
741 // String sheetName = null;
743 // if ((name != null) && name instanceof String) {
744 // sheetName = (String) name;
745 // }
746 // XSpreadsheetDocument xShDoc = (XSpreadsheetDocument) UnoRuntime.queryInterface( XSpreadsheetDocument.class,getXModel() );
747 // com.sun.star.sheet.XSpreadsheets xSheets = xShDoc.Sheets();
749 // switch (where) {
750 // case ClLocationType.clLocationAsObject_value: //{
752 // if (sheetName == null) {
753 // DebugHelper.writeInfo("Can't embed in Chart without knowing SheetName");
754 // return;
755 // }
757 // try {
758 // Any any = (Any) xSheets.getByName(sheetName);
759 // chartSheet = (XSpreadsheet) any.getObject();
761 // // chartSheet = (XSpreadsheet) xSheets.getByName( sheetName );
762 // } catch (NoSuchElementException e) {
763 // // TODO Auto-generated catch block
764 // e.printStackTrace();
766 // return;
767 // } catch (WrappedTargetException e) {
768 // // TODO Auto-generated catch block
769 // e.printStackTrace();
771 // return;
772 // } catch (java.lang.Exception e) {
773 // e.printStackTrace();
774 // }
776 // XTableChartsSupplier xTCS = (XTableChartsSupplier) UnoRuntime.queryInterface( XTableChartsSupplier.class, chartSheet);
777 // XTableCharts xTableCharts = xTCS.getCharts();
778 // XIndexAccess xIA = (XIndexAccess) UnoRuntime.queryInterface( XIndexAccess.class, xTableCharts);
779 // int numCharts = xIA.getCount();
780 // chartName = "Chart " + (numCharts + 1);
782 // //}
783 // break;
785 // case ClLocationType.clLocationAsNewSheet_value:
786 // case ClLocationType.clLocationAutomatic_value:default: //{
787 // chartName = "Chart 1"; // Since it's a new sheet, it's the first on it...
789 // XIndexAccess xSheetIA = (XIndexAccess) UnoRuntime.queryInterface( XIndexAccess.class, xSheets);
791 // short newSheetNum = (short) (xSheetIA.getCount() + 1);
793 // if (sheetName == null){
794 // sheetName = "ChartSheet " + newSheetNum; // Why not?
795 // }
796 // // DPK TODO : Probably should use Sheets to create this!
797 // xSheets.insertNewByName(sheetName, newSheetNum);
799 // try {
800 // chartSheet =
801 // (XSpreadsheet) xSheets.getByName(sheetName);
802 // } catch (NoSuchElementException e) {
803 // // TODO Auto-generated catch block
804 // e.printStackTrace();
806 // return;
807 // } catch (WrappedTargetException e) {
808 // // TODO Auto-generated catch block
809 // e.printStackTrace();
811 // return;
812 // }
814 // //}
815 // break;
816 // }
818 // // Last thing should be a call to createChartForReal(), one of them
819 // // should succeed.
820 // createChartForReal();
824 sal_Bool SAL_CALL
825 ScVbaChart::getHasTitle( ) throw (script::BasicErrorException, uno::RuntimeException)
827 sal_Bool bHasTitle = sal_False;
830 mxChartPropertySet->getPropertyValue(HASMAINTITLE) >>= bHasTitle;
832 catch (uno::Exception& )
834 throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
836 return bHasTitle;
839 void SAL_CALL
840 ScVbaChart::setHasTitle( ::sal_Bool bTitle ) throw (script::BasicErrorException, uno::RuntimeException)
844 mxChartPropertySet->setPropertyValue(HASMAINTITLE, uno::makeAny( bTitle ));
846 catch (uno::Exception& )
848 throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
853 ::sal_Bool SAL_CALL
854 ScVbaChart::getHasLegend( ) throw (script::BasicErrorException, uno::RuntimeException)
856 sal_Bool bHasLegend = sal_False;
859 mxChartPropertySet->getPropertyValue(HASLEGEND) >>= bHasLegend;
861 catch (uno::Exception& )
863 throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
865 return bHasLegend;
868 void SAL_CALL
869 ScVbaChart::setHasLegend( ::sal_Bool bLegend ) throw (script::BasicErrorException, uno::RuntimeException)
873 mxChartPropertySet->setPropertyValue(HASLEGEND, uno::makeAny(bLegend));
875 catch (uno::Exception& )
877 throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
881 uno::Reference< excel::XChartTitle > SAL_CALL
882 ScVbaChart::getChartTitle( ) throw (script::BasicErrorException, uno::RuntimeException)
884 uno::Reference< drawing::XShape > xTitleShape = mxChartDocument->getTitle();
885 // #TODO check parent
886 return new ScVbaChartTitle(this, mxContext, xTitleShape);
889 uno::Any SAL_CALL
890 ScVbaChart::Axes( const uno::Any& Type, const uno::Any& AxisGroup ) throw (script::BasicErrorException, uno::RuntimeException)
892 // mmm chart probably is the parent, #TODO check parent
893 uno::Reference< excel::XAxes > xAxes = new ScVbaAxes( this, mxContext, this );
894 if ( !Type.hasValue() )
895 return uno::makeAny( xAxes );
896 return xAxes->Item( Type, AxisGroup );
898 bool
899 ScVbaChart::is3D() throw ( uno::RuntimeException )
901 // #TODO perhaps provide limited Debughelper functionality
902 sal_Bool is3d = sal_False;
903 mxDiagramPropertySet->getPropertyValue(DIM3D) >>= is3d;
904 return is3d;
907 sal_Int32
908 ScVbaChart::getStackedType( sal_Int32 _nStacked, sal_Int32 _n100PercentStacked, sal_Int32 _nUnStacked ) throw ( uno::RuntimeException )
910 // #TODO perhaps provide limited Debughelper functionality
911 if (isStacked())
913 if (is100PercentStacked())
914 return _n100PercentStacked;
915 else
916 return _nStacked;
918 else
919 return _nUnStacked;
922 bool
923 ScVbaChart::isStacked() throw ( uno::RuntimeException )
925 // #TODO perhaps provide limited Debughelper functionality
926 sal_Bool bStacked = sal_False;
927 mxDiagramPropertySet->getPropertyValue(STACKED) >>= bStacked;
928 return bStacked;
931 bool
932 ScVbaChart::is100PercentStacked() throw ( uno::RuntimeException )
934 // #TODO perhaps provide limited Debughelper functionality
935 sal_Bool b100Percent = sal_False;
936 mxDiagramPropertySet->getPropertyValue(PERCENT) >>= b100Percent;
937 return b100Percent;
940 sal_Int32
941 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 )
943 sal_Bool bIsVertical = true;
946 mxDiagramPropertySet->getPropertyValue(VERTICAL) >>= bIsVertical;
947 sal_Bool bIsDeep = false;
948 mxDiagramPropertySet->getPropertyValue(DEEP) >>= bIsDeep;
950 if (bIsDeep)
952 return _nDeep;
954 else
956 if (bIsVertical)
958 return getStackedType(_nVertiStacked, _nVerti100PercentStacked, _nVertiUnStacked);
960 else
962 return getStackedType(_nHoriStacked, _nHori100PercentStacked, _nHoriUnStacked);
966 catch (uno::Exception& )
968 throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
973 sal_Int32
974 ScVbaChart::getStockUpDownValue(sal_Int32 _nUpDown, sal_Int32 _nNotUpDown) throw (script::BasicErrorException)
976 sal_Bool bUpDown = sal_False;
979 mxDiagramPropertySet->getPropertyValue(UPDOWN) >>= bUpDown;
980 if (bUpDown)
982 return _nUpDown;
984 else
986 return _nNotUpDown;
989 catch (uno::Exception& )
991 rtl::OUString aTemp; // temporary needed for g++ 3.3.5
992 script::BasicErrorException( aTemp, uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
994 return _nNotUpDown;
997 bool
998 ScVbaChart::hasMarkers() throw ( script::BasicErrorException )
1000 bool bHasMarkers = false;
1003 sal_Int32 nSymbol=0;
1004 mxDiagramPropertySet->getPropertyValue(SYMBOLTYPE) >>= nSymbol;
1005 bHasMarkers = nSymbol != chart::ChartSymbolType::NONE;
1007 catch ( uno::Exception& )
1009 rtl::OUString aTemp; // temporary needed for g++ 3.3.5
1010 script::BasicErrorException( aTemp, uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
1012 return bHasMarkers;
1015 sal_Int32
1016 ScVbaChart::getMarkerType(sal_Int32 _nWithMarkers, sal_Int32 _nWithoutMarkers) throw ( script::BasicErrorException )
1018 if (hasMarkers())
1019 return _nWithMarkers;
1020 return _nWithoutMarkers;
1023 void
1024 ScVbaChart::assignDiagramAttributes()
1026 xAxisXSupplier.set( mxDiagramPropertySet, uno::UNO_QUERY_THROW );
1027 xAxisYSupplier.set( mxDiagramPropertySet, uno::UNO_QUERY_THROW );
1028 xAxisZSupplier.set( mxDiagramPropertySet, uno::UNO_QUERY_THROW );
1029 xTwoAxisXSupplier.set( mxDiagramPropertySet, uno::UNO_QUERY_THROW );
1030 xTwoAxisYSupplier.set( mxDiagramPropertySet, uno::UNO_QUERY_THROW );
1033 bool
1034 ScVbaChart::isSeriesIndexValid(sal_Int32 _seriesindex) throw( script::BasicErrorException )
1036 bool bret = false;
1039 uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
1040 // dblValues = xChartDataArray.getData();
1041 //TODO I guess we have to differentiate between XlRowCol
1042 if ( !xChartDataArray.is() )
1044 if (getPlotBy() == xlRows)
1046 if ((_seriesindex < xChartDataArray->getRowDescriptions().getLength() ) && (_seriesindex >= 0))
1047 bret = true;
1049 else
1051 if ((_seriesindex < xChartDataArray->getColumnDescriptions().getLength() ) && (_seriesindex >= 0))
1052 bret = true;
1056 catch (uno::Exception& )
1058 throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
1060 if (!bret)
1062 throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_OUT_OF_RANGE, rtl::OUString() );
1064 return bret;
1067 bool
1068 ScVbaChart::areIndicesValid( sal_Int32 _seriesindex, sal_Int32 _valindex) throw ( css::script::BasicErrorException )
1070 if (isSeriesIndexValid(_seriesindex))
1072 uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
1073 dblValues = xChartDataArray->getData();
1074 return (_valindex < dblValues[_seriesindex].getLength() );
1076 return false;
1079 sal_Int32
1080 ScVbaChart::getSeriesIndex(rtl::OUString _sseriesname) throw ( script::BasicErrorException )
1082 uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
1083 if (getPlotBy() == xlRows)
1084 return ContainerUtilities::FieldInList(xChartDataArray->getRowDescriptions(), _sseriesname);
1085 return ContainerUtilities::FieldInList(xChartDataArray->getColumnDescriptions(), _sseriesname);
1087 void
1088 ScVbaChart::setSeriesName(sal_Int32 _index, rtl::OUString _sname) throw ( script::BasicErrorException )
1090 uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
1091 if (isSeriesIndexValid(_index))
1093 uno::Sequence< rtl::OUString > sDescriptions = xChartDataArray->getColumnDescriptions();
1094 sDescriptions[_index] = _sname;
1095 xChartDataArray->setColumnDescriptions(sDescriptions);
1099 sal_Int32
1100 ScVbaChart::getSeriesCount() throw ( script::BasicErrorException )
1102 uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
1104 if (getPlotBy() == xlRows)
1105 return xChartDataArray->getRowDescriptions().getLength();
1106 return xChartDataArray->getColumnDescriptions().getLength();
1110 rtl::OUString
1111 ScVbaChart::getSeriesName(sal_Int32 _index) throw ( script::BasicErrorException )
1113 uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
1114 uno::Sequence< rtl::OUString > sDescriptions;
1115 rtl::OUString sName;
1116 if (isSeriesIndexValid(_index))
1118 if (getPlotBy() == xlRows)
1119 sDescriptions = xChartDataArray->getRowDescriptions();
1120 else
1121 sDescriptions = xChartDataArray->getColumnDescriptions();
1122 sName = sDescriptions[_index];
1124 return sName;
1127 double
1128 ScVbaChart::getValue(sal_Int32 _seriesindex, sal_Int32 _valindex) throw ( script::BasicErrorException )
1130 double result = -1.0;
1131 if (areIndicesValid(_seriesindex, _valindex))
1133 if (getPlotBy() == xlRows)
1134 result = dblValues[_seriesindex][_valindex];
1135 else
1136 result = dblValues[_valindex][_seriesindex];
1138 return result;
1141 sal_Int32
1142 ScVbaChart::getValuesCount(sal_Int32 _seriesIndex) throw ( script::BasicErrorException )
1144 sal_Int32 nCount = 0;
1145 uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
1146 if (isSeriesIndexValid(_seriesIndex))
1148 dblValues = xChartDataArray->getData();
1149 if (getPlotBy() == xlRows)
1150 nCount = dblValues[_seriesIndex].getLength();
1151 else
1152 nCount = dblValues.getLength();
1154 return nCount;
1158 uno::Reference< excel::XDataLabels >
1159 ScVbaChart::DataLabels( const uno::Reference< ov::excel::XSeries > /*_oSeries*/ ) throw ( css::script::BasicErrorException )
1161 if ( true )
1162 throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
1163 // #TODO #FIXE provide implementation
1164 return uno::Reference< excel::XDataLabels > ();
1167 bool
1168 ScVbaChart::getHasDataCaption( const uno::Reference< css::beans::XPropertySet >& _xPropertySet )throw ( script::BasicErrorException )
1170 bool bResult = false;
1173 sal_Int32 nChartDataCaption = 0;
1174 _xPropertySet->getPropertyValue(DATACAPTION) >>= nChartDataCaption;
1175 bResult = (nChartDataCaption != chart::ChartDataCaption::NONE);
1177 catch (uno::Exception& )
1179 throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
1181 return bResult;
1184 void
1185 ScVbaChart::setHasDataCaption( const uno::Reference< beans::XPropertySet >& _xPropertySet, bool _bHasDataLabels )throw ( script::BasicErrorException )
1189 if ( _bHasDataLabels )
1190 _xPropertySet->setPropertyValue(DATACAPTION, uno::makeAny ( chart::ChartDataCaption::VALUE) );
1191 else
1192 _xPropertySet->setPropertyValue(DATACAPTION, uno::makeAny ( chart::ChartDataCaption::NONE) );
1194 catch (uno::Exception& )
1196 throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
1200 uno::Reference< beans::XPropertySet >
1201 ScVbaChart::getAxisPropertySet(sal_Int32 _nAxisType, sal_Int32 _nAxisGroup) throw ( script::BasicErrorException )
1203 assignDiagramAttributes();
1204 uno::Reference< beans::XPropertySet > xAxisProps;
1205 switch(_nAxisType)
1207 case xlCategory:
1208 if (_nAxisGroup == xlPrimary)
1210 xAxisProps = xAxisXSupplier->getXAxis();
1212 else if (_nAxisGroup == xlSecondary)
1214 xAxisProps = xTwoAxisXSupplier->getSecondaryXAxis();
1216 break;
1217 case xlSeriesAxis:
1218 // if (_nAxisGroup == xlPrimary){
1219 xAxisProps = xAxisZSupplier->getZAxis();
1220 break;
1221 // }
1222 // else if (_nAxisGroup == xlSecondary){
1223 // return xTwoAxisXSupplier.getSecondaryZAxis();
1224 // }
1225 case xlValue:
1226 if (_nAxisGroup == xlPrimary)
1227 xAxisProps = xAxisYSupplier->getYAxis();
1228 else if (_nAxisGroup == xlSecondary)
1229 xAxisProps = xTwoAxisYSupplier->getSecondaryYAxis();
1230 break;
1231 default:
1232 return xAxisProps;
1234 return xAxisProps;
1238 rtl::OUString&
1239 ScVbaChart::getServiceImplName()
1241 static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaChart") );
1242 return sImplName;
1245 uno::Sequence< rtl::OUString >
1246 ScVbaChart::getServiceNames()
1248 static uno::Sequence< rtl::OUString > aServiceNames;
1249 if ( aServiceNames.getLength() == 0 )
1251 aServiceNames.realloc( 1 );
1252 aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Chart" ) );
1254 return aServiceNames;