1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 #ifndef INCLUDED_VBAHELPER_SOURCE_VBAHELPER_VBACOMMANDBARCONTROLS_HXX
20 #define INCLUDED_VBAHELPER_SOURCE_VBAHELPER_VBACOMMANDBARCONTROLS_HXX
21 
22 #include <ooo/vba/XCommandBarControls.hpp>
23 #include <vbahelper/vbacollectionimpl.hxx>
24 #include "vbacommandbarhelper.hxx"
25 
26 typedef CollTestImplHelper< ov::XCommandBarControls > CommandBarControls_BASE;
27 
28 class ScVbaCommandBarControls : public CommandBarControls_BASE
29 {
30 private:
31     VbaCommandBarHelperRef                              pCBarHelper;
32     css::uno::Reference< css::container::XIndexAccess > m_xBarSettings;
33     OUString                                            m_sResourceUrl;
34     bool                                                m_bIsMenu;
35 
36     static css::uno::Sequence< css::beans::PropertyValue > CreateMenuItemData( const OUString& sCommandURL,
37                                                                         const OUString& sHelpURL,
38                                                                         const OUString& sLabel,
39                                                                         sal_uInt16 nType,
40                                                                         const css::uno::Any& aSubMenu,
41                                                                         bool isVisible,
42                                                                         bool isEnabled );
43     static css::uno::Sequence< css::beans::PropertyValue > CreateToolbarItemData( const OUString& sCommandURL, const OUString& sHelpURL, const OUString& sLabel, sal_uInt16 nType, const css::uno::Any& aSubMenu, bool isVisible, sal_Int32 nStyle );
44 
45 public:
46     /// @throws css::uno::RuntimeException
47     ScVbaCommandBarControls( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, VbaCommandBarHelperRef const & pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const OUString& sResourceUrl );
48 
49     // XEnumerationAccess
50     virtual css::uno::Type SAL_CALL getElementType() override;
51     virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override;
52     virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ) override;
53 
54     // Methods
55     virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index, const css::uno::Any& /*Index2*/ ) override;
56     virtual css::uno::Reference< ov::XCommandBarControl > SAL_CALL Add( const css::uno::Any& Type, const css::uno::Any& Id, const css::uno::Any& Parameter, const css::uno::Any& Before, const css::uno::Any& Temporary ) override;
57     // XHelperInterface
58     virtual OUString getServiceImplName() override;
59     virtual css::uno::Sequence<OUString> getServiceNames() override;
60 };
61 
62 class VbaDummyCommandBarControls : public CommandBarControls_BASE
63 {
64 public:
65     /// @throws css::uno::RuntimeException
66     VbaDummyCommandBarControls(
67         const css::uno::Reference< ov::XHelperInterface >& xParent,
68         const css::uno::Reference< css::uno::XComponentContext >& xContext );
69 
70     // XEnumerationAccess
71     virtual css::uno::Type SAL_CALL getElementType() override;
72     virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override;
73     virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ) override;
74 
75     // Methods
76     virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index, const css::uno::Any& /*Index2*/ ) override;
77     virtual css::uno::Reference< ov::XCommandBarControl > SAL_CALL Add( const css::uno::Any& Type, const css::uno::Any& Id, const css::uno::Any& Parameter, const css::uno::Any& Before, const css::uno::Any& Temporary ) override;
78     // XHelperInterface
79     virtual OUString getServiceImplName() override;
80     virtual css::uno::Sequence<OUString> getServiceNames() override;
81 };
82 
83 #endif // INCLUDED_VBAHELPER_SOURCE_VBAHELPER_VBACOMMANDBARCONTROLS_HXX
84 
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
86