fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / vba / vbamenubars.cxx
blob265f9a1d7e84c001ac6e6b2f37b839179de811cd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9 #include "vbamenubars.hxx"
10 #include "vbamenubar.hxx"
11 #include <ooo/vba/excel/XlSheetType.hpp>
13 using namespace com::sun::star;
14 using namespace ooo::vba;
16 typedef ::cppu::WeakImplHelper1< container::XEnumeration > MenuBarEnumeration_BASE;
18 class MenuBarEnumeration : public MenuBarEnumeration_BASE
20 uno::Reference< XHelperInterface > m_xParent;
21 uno::Reference< uno::XComponentContext > m_xContext;
22 uno::Reference< container::XEnumeration > m_xEnumeration;
23 public:
24 MenuBarEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration) throw ( uno::RuntimeException ) : m_xParent( xParent ), m_xContext( xContext ), m_xEnumeration( xEnumeration )
27 virtual sal_Bool SAL_CALL hasMoreElements() throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE
29 return m_xEnumeration->hasMoreElements();
31 virtual uno::Any SAL_CALL nextElement() throw ( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) SAL_OVERRIDE
33 // FIXME: should be add menubar
34 if( hasMoreElements() )
36 uno::Reference< XCommandBar > xCommandBar( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
37 uno::Reference< excel::XMenuBar > xMenuBar( new ScVbaMenuBar( m_xParent, m_xContext, xCommandBar ) );
38 return uno::makeAny( xMenuBar );
40 else
41 throw container::NoSuchElementException();
45 ScVbaMenuBars::ScVbaMenuBars( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< XCommandBars >& xCommandBars ) throw ( uno::RuntimeException ) : MenuBars_BASE( xParent, xContext, uno::Reference< container::XIndexAccess>() ), m_xCommandBars( xCommandBars )
49 ScVbaMenuBars::~ScVbaMenuBars()
53 // XEnumerationAccess
54 uno::Type SAL_CALL
55 ScVbaMenuBars::getElementType() throw ( uno::RuntimeException )
57 return cppu::UnoType<excel::XMenuBar>::get();
60 uno::Reference< container::XEnumeration >
61 ScVbaMenuBars::createEnumeration() throw ( uno::RuntimeException )
63 uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xCommandBars, uno::UNO_QUERY_THROW );
64 return uno::Reference< container::XEnumeration >( new MenuBarEnumeration( this, mxContext, xEnumAccess->createEnumeration() ) );
67 uno::Any
68 ScVbaMenuBars::createCollectionObject( const uno::Any& aSource )
70 // make no sense
71 return aSource;
74 sal_Int32 SAL_CALL
75 ScVbaMenuBars::getCount() throw(css::uno::RuntimeException)
77 return m_xCommandBars->getCount();
80 // ScVbaCollectionBaseImpl
81 uno::Any SAL_CALL
82 ScVbaMenuBars::Item( const uno::Any& aIndex, const uno::Any& /*aIndex2*/ ) throw( uno::RuntimeException )
84 sal_Int16 nIndex = 0;
85 aIndex >>= nIndex;
86 if( nIndex == excel::XlSheetType::xlWorksheet )
88 uno::Any aSource;
89 aSource <<= OUString( "Worksheet Menu Bar" );
90 uno::Reference< XCommandBar > xCommandBar( m_xCommandBars->Item( aSource, uno::Any() ), uno::UNO_QUERY_THROW );
91 uno::Reference< excel::XMenuBar > xMenuBar( new ScVbaMenuBar( this, mxContext, xCommandBar ) );
92 return uno::makeAny( xMenuBar );
95 throw uno::RuntimeException("Not implemented" );
98 // XHelperInterface
99 OUString
100 ScVbaMenuBars::getServiceImplName()
102 return OUString("ScVbaMenuBars");
105 uno::Sequence<OUString>
106 ScVbaMenuBars::getServiceNames()
108 static uno::Sequence< OUString > aServiceNames;
109 if ( aServiceNames.getLength() == 0 )
111 aServiceNames.realloc( 1 );
112 aServiceNames[ 0 ] = "ooo.vba.excel.MenuBars";
114 return aServiceNames;
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */