tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / vba / vbamenubars.cxx
bloba6df4695497f9ab8dad614a6fc75800c777ad643
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 <cppuhelper/implbase.hxx>
12 #include <ooo/vba/excel/XlSheetType.hpp>
13 #include <ooo/vba/XCommandBars.hpp>
14 #include <utility>
16 using namespace com::sun::star;
17 using namespace ooo::vba;
19 namespace {
21 class MenuBarEnumeration : public ::cppu::WeakImplHelper< container::XEnumeration >
23 uno::Reference< XHelperInterface > m_xParent;
24 uno::Reference< uno::XComponentContext > m_xContext;
25 uno::Reference< container::XEnumeration > m_xEnumeration;
26 public:
27 /// @throws uno::RuntimeException
28 MenuBarEnumeration( uno::Reference< XHelperInterface > xParent, uno::Reference< uno::XComponentContext > xContext, uno::Reference< container::XEnumeration > xEnumeration) : m_xParent(std::move( xParent )), m_xContext(std::move( xContext )), m_xEnumeration(std::move( xEnumeration ))
31 virtual sal_Bool SAL_CALL hasMoreElements() override
33 return m_xEnumeration->hasMoreElements();
35 virtual uno::Any SAL_CALL nextElement() override
37 // FIXME: should be add menubar
38 if( !hasMoreElements() )
39 throw container::NoSuchElementException();
41 uno::Reference< XCommandBar > xCommandBar( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
42 uno::Reference< excel::XMenuBar > xMenuBar( new ScVbaMenuBar( m_xParent, m_xContext, xCommandBar ) );
43 return uno::Any( xMenuBar );
49 ScVbaMenuBars::ScVbaMenuBars( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, uno::Reference< XCommandBars > xCommandBars ) : MenuBars_BASE( xParent, xContext, uno::Reference< container::XIndexAccess>() ), m_xCommandBars(std::move( xCommandBars ))
53 ScVbaMenuBars::~ScVbaMenuBars()
57 // XEnumerationAccess
58 uno::Type SAL_CALL
59 ScVbaMenuBars::getElementType()
61 return cppu::UnoType<excel::XMenuBar>::get();
64 uno::Reference< container::XEnumeration >
65 ScVbaMenuBars::createEnumeration()
67 uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xCommandBars, uno::UNO_QUERY_THROW );
68 return uno::Reference< container::XEnumeration >( new MenuBarEnumeration( this, mxContext, xEnumAccess->createEnumeration() ) );
71 uno::Any
72 ScVbaMenuBars::createCollectionObject( const uno::Any& aSource )
74 // make no sense
75 return aSource;
78 sal_Int32 SAL_CALL
79 ScVbaMenuBars::getCount()
81 return m_xCommandBars->getCount();
84 // ScVbaCollectionBaseImpl
85 uno::Any SAL_CALL
86 ScVbaMenuBars::Item( const uno::Any& aIndex, const uno::Any& /*aIndex2*/ )
88 sal_Int16 nIndex = 0;
89 aIndex >>= nIndex;
90 if( nIndex == excel::XlSheetType::xlWorksheet )
92 uno::Any aSource;
93 aSource <<= u"Worksheet Menu Bar"_ustr;
94 uno::Reference< XCommandBar > xCommandBar( m_xCommandBars->Item( aSource, uno::Any() ), uno::UNO_QUERY_THROW );
95 uno::Reference< excel::XMenuBar > xMenuBar( new ScVbaMenuBar( this, mxContext, xCommandBar ) );
96 return uno::Any( xMenuBar );
99 throw uno::RuntimeException(u"Not implemented"_ustr );
102 // XHelperInterface
103 OUString
104 ScVbaMenuBars::getServiceImplName()
106 return u"ScVbaMenuBars"_ustr;
109 uno::Sequence<OUString>
110 ScVbaMenuBars::getServiceNames()
112 static uno::Sequence< OUString > const aServiceNames
114 u"ooo.vba.excel.MenuBars"_ustr
116 return aServiceNames;
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */