1b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file
5b3f79822SAndrew Rist * distributed with this work for additional information
6b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the
8b3f79822SAndrew Rist * "License"); you may not use this file except in compliance
9b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at
10b3f79822SAndrew Rist *
11b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12b3f79822SAndrew Rist *
13b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing,
14b3f79822SAndrew Rist * software distributed under the License is distributed on an
15b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b3f79822SAndrew Rist * KIND, either express or implied. See the License for the
17b3f79822SAndrew Rist * specific language governing permissions and limitations
18b3f79822SAndrew Rist * under the License.
19b3f79822SAndrew Rist *
20b3f79822SAndrew Rist *************************************************************/
21b3f79822SAndrew Rist
22b3f79822SAndrew Rist
23cdf0e10cSrcweir #include "vbacharts.hxx"
24cdf0e10cSrcweir #include <basic/sberrors.hxx>
25cdf0e10cSrcweir #include <com/sun/star/table/XTableChartsSupplier.hpp>
26cdf0e10cSrcweir
27cdf0e10cSrcweir using namespace ::com::sun::star;
28cdf0e10cSrcweir using namespace ::ooo::vba;
29cdf0e10cSrcweir
30cdf0e10cSrcweir
ScVbaCharts(const css::uno::Reference<ov::XHelperInterface> & _xParent,const css::uno::Reference<css::uno::XComponentContext> & _xContext,const uno::Reference<frame::XModel> & xModel)31cdf0e10cSrcweir ScVbaCharts::ScVbaCharts( const css::uno::Reference< ov::XHelperInterface >& _xParent, const css::uno::Reference< css::uno::XComponentContext >& _xContext, const uno::Reference< frame::XModel >& xModel ) : Charts_BASE(_xParent, _xContext, uno::Reference< container::XIndexAccess >())
32cdf0e10cSrcweir {
33cdf0e10cSrcweir xComponent.set( xModel, uno::UNO_QUERY_THROW );
34cdf0e10cSrcweir xSpreadsheetDocument.set( xComponent, uno::UNO_QUERY_THROW );
35cdf0e10cSrcweir }
36cdf0e10cSrcweir
37cdf0e10cSrcweir uno::Any SAL_CALL
Add()38cdf0e10cSrcweir ScVbaCharts::Add() throw (css::script::BasicErrorException, css::uno::RuntimeException)
39cdf0e10cSrcweir {
40cdf0e10cSrcweir // Not implemented in the helperapi ( see ChartsImpl.java )
41cdf0e10cSrcweir if ( true )
42cdf0e10cSrcweir throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_BAD_METHOD, rtl::OUString() );
43cdf0e10cSrcweir return aNULL();
44cdf0e10cSrcweir }
45cdf0e10cSrcweir
46cdf0e10cSrcweir uno::Reference< excel::XChart > SAL_CALL
getActiveChart()47cdf0e10cSrcweir ScVbaCharts::getActiveChart() throw (script::BasicErrorException, uno::RuntimeException)
48cdf0e10cSrcweir {
49cdf0e10cSrcweir return xActiveChart;
50cdf0e10cSrcweir }
51cdf0e10cSrcweir
52cdf0e10cSrcweir uno::Reference< container::XEnumeration > SAL_CALL
createEnumeration()53cdf0e10cSrcweir ScVbaCharts::createEnumeration() throw (uno::RuntimeException)
54cdf0e10cSrcweir {
55cdf0e10cSrcweir // #FIXME not implemented
56cdf0e10cSrcweir if ( true )
57cdf0e10cSrcweir throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_BAD_METHOD, rtl::OUString() );
58cdf0e10cSrcweir return uno::Reference< container::XEnumeration >();
59cdf0e10cSrcweir }
60cdf0e10cSrcweir
61cdf0e10cSrcweir // #FIXME #TODO this method shouldn't appear in this class directly
62cdf0e10cSrcweir // a XIndexAccess/XNameAccess wrapper should be passed to the base class instead
63cdf0e10cSrcweir ::sal_Int32 SAL_CALL
getCount()64cdf0e10cSrcweir ScVbaCharts::getCount() throw (uno::RuntimeException)
65cdf0e10cSrcweir {
66cdf0e10cSrcweir sal_Int32 ncount = 0;
67cdf0e10cSrcweir try
68cdf0e10cSrcweir {
69cdf0e10cSrcweir uno::Reference< sheet::XSpreadsheets > xSpreadsheets( xSpreadsheetDocument->getSheets() );
70cdf0e10cSrcweir uno::Sequence< rtl::OUString > SheetNames = xSpreadsheets->getElementNames();
71cdf0e10cSrcweir sal_Int32 nLen = SheetNames.getLength();
72cdf0e10cSrcweir for (sal_Int32 i = 0; i < nLen; i++)
73cdf0e10cSrcweir {
74cdf0e10cSrcweir uno::Reference< table::XTableChartsSupplier > xTableChartsSupplier( xSpreadsheets->getByName(SheetNames[i]), uno::UNO_QUERY);
75cdf0e10cSrcweir if ( xTableChartsSupplier.is() )
76cdf0e10cSrcweir {
77cdf0e10cSrcweir uno::Reference< table::XTableCharts > xTableCharts = xTableChartsSupplier->getCharts();
78*d311fc8bSHerbert Dürr ncount += xTableCharts->getElementNames().getLength();
79cdf0e10cSrcweir }
80cdf0e10cSrcweir }
81cdf0e10cSrcweir }
82cdf0e10cSrcweir catch (uno::Exception& )
83cdf0e10cSrcweir {
84cdf0e10cSrcweir throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
85cdf0e10cSrcweir }
86cdf0e10cSrcweir return ncount;
87cdf0e10cSrcweir }
88cdf0e10cSrcweir
89cdf0e10cSrcweir uno::Any
createCollectionObject(const uno::Any & aSource)90cdf0e10cSrcweir ScVbaCharts::createCollectionObject( const uno::Any& aSource )
91cdf0e10cSrcweir {
92cdf0e10cSrcweir if ( true )
93cdf0e10cSrcweir throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_BAD_METHOD, rtl::OUString() );
94cdf0e10cSrcweir // #TODO implementation please
95cdf0e10cSrcweir return aSource;
96cdf0e10cSrcweir }
97cdf0e10cSrcweir
98cdf0e10cSrcweir rtl::OUString&
getServiceImplName()99cdf0e10cSrcweir ScVbaCharts::getServiceImplName()
100cdf0e10cSrcweir {
101cdf0e10cSrcweir static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCharts") );
102cdf0e10cSrcweir return sImplName;
103cdf0e10cSrcweir }
104cdf0e10cSrcweir
105cdf0e10cSrcweir css::uno::Sequence<rtl::OUString>
getServiceNames()106cdf0e10cSrcweir ScVbaCharts::getServiceNames()
107cdf0e10cSrcweir {
108cdf0e10cSrcweir static uno::Sequence< rtl::OUString > sNames;
109cdf0e10cSrcweir if ( sNames.getLength() == 0 )
110cdf0e10cSrcweir {
111cdf0e10cSrcweir sNames.realloc( 1 );
112cdf0e10cSrcweir sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Charts") );
113cdf0e10cSrcweir }
114cdf0e10cSrcweir return sNames;
115cdf0e10cSrcweir }
116cdf0e10cSrcweir
117