1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: vbacharts.cxx,v $
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 "vbacharts.hxx"
31 #include <basic/sberrors.hxx>
32 #include <com/sun/star/table/XTableChartsSupplier.hpp>
34 using namespace ::com::sun::star
;
35 using namespace ::ooo::vba
;
38 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
>())
40 xComponent
.set( xModel
, uno::UNO_QUERY_THROW
);
41 xSpreadsheetDocument
.set( xComponent
, uno::UNO_QUERY_THROW
);
45 ScVbaCharts::Add() throw (css::script::BasicErrorException
, css::uno::RuntimeException
)
47 // Not implemented in the helperapi ( see ChartsImpl.java )
49 throw script::BasicErrorException( rtl::OUString(), uno::Reference
< uno::XInterface
>(), SbERR_BAD_METHOD
, rtl::OUString() );
53 uno::Reference
< excel::XChart
> SAL_CALL
54 ScVbaCharts::getActiveChart() throw (script::BasicErrorException
, uno::RuntimeException
)
59 uno::Reference
< container::XEnumeration
> SAL_CALL
60 ScVbaCharts::createEnumeration() throw (uno::RuntimeException
)
62 // #FIXME not implemented
64 throw script::BasicErrorException( rtl::OUString(), uno::Reference
< uno::XInterface
>(), SbERR_BAD_METHOD
, rtl::OUString() );
65 return uno::Reference
< container::XEnumeration
>();
68 // #FIXME #TODO this method shouldn't appear in this class directly
69 // a XIndexAccess/XNameAccess wrapper should be passed to the base class instead
71 ScVbaCharts::getCount() throw (uno::RuntimeException
)
76 uno::Reference
< sheet::XSpreadsheets
> xSpreadsheets( xSpreadsheetDocument
->getSheets() );
77 uno::Sequence
< rtl::OUString
> SheetNames
= xSpreadsheets
->getElementNames();
78 sal_Int32 nLen
= SheetNames
.getLength();
79 for (sal_Int32 i
= 0; i
< nLen
; i
++)
81 uno::Reference
< table::XTableChartsSupplier
> xTableChartsSupplier( xSpreadsheets
->getByName(SheetNames
[i
]), uno::UNO_QUERY
);
82 if ( xTableChartsSupplier
.is() )
84 uno::Reference
< table::XTableCharts
> xTableCharts
= xTableChartsSupplier
->getCharts();
85 ncount
=+ xTableCharts
->getElementNames().getLength();
89 catch (uno::Exception
& )
91 throw script::BasicErrorException( rtl::OUString(), uno::Reference
< uno::XInterface
>(), SbERR_METHOD_FAILED
, rtl::OUString() );
97 ScVbaCharts::createCollectionObject( const uno::Any
& aSource
)
100 throw script::BasicErrorException( rtl::OUString(), uno::Reference
< uno::XInterface
>(), SbERR_BAD_METHOD
, rtl::OUString() );
101 // #TODO implementation please
106 ScVbaCharts::getServiceImplName()
108 static rtl::OUString
sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCharts") );
112 css::uno::Sequence
<rtl::OUString
>
113 ScVbaCharts::getServiceNames()
115 static uno::Sequence
< rtl::OUString
> sNames
;
116 if ( sNames
.getLength() == 0 )
119 sNames
[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Charts") );