1*b3f79822SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b3f79822SAndrew Rist * distributed with this work for additional information 6*b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b3f79822SAndrew Rist * "License"); you may not use this file except in compliance 9*b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at 10*b3f79822SAndrew Rist * 11*b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*b3f79822SAndrew Rist * 13*b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b3f79822SAndrew Rist * software distributed under the License is distributed on an 15*b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b3f79822SAndrew Rist * KIND, either express or implied. See the License for the 17*b3f79822SAndrew Rist * specific language governing permissions and limitations 18*b3f79822SAndrew Rist * under the License. 19*b3f79822SAndrew Rist * 20*b3f79822SAndrew Rist *************************************************************/ 21*b3f79822SAndrew Rist 22*b3f79822SAndrew 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 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 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 47cdf0e10cSrcweir ScVbaCharts::getActiveChart() throw (script::BasicErrorException, uno::RuntimeException) 48cdf0e10cSrcweir { 49cdf0e10cSrcweir return xActiveChart; 50cdf0e10cSrcweir } 51cdf0e10cSrcweir 52cdf0e10cSrcweir uno::Reference< container::XEnumeration > SAL_CALL 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 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(); 78cdf0e10cSrcweir 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 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& 99cdf0e10cSrcweir ScVbaCharts::getServiceImplName() 100cdf0e10cSrcweir { 101cdf0e10cSrcweir static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCharts") ); 102cdf0e10cSrcweir return sImplName; 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir css::uno::Sequence<rtl::OUString> 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