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_VBACOMMANDBARCONTROL_HXX 20 #define INCLUDED_VBAHELPER_SOURCE_VBAHELPER_VBACOMMANDBARCONTROL_HXX 21 22 #include <ooo/vba/XCommandBarControl.hpp> 23 #include <ooo/vba/XCommandBarPopup.hpp> 24 #include <ooo/vba/XCommandBarButton.hpp> 25 #include <ooo/vba/office/MsoControlType.hpp> 26 #include <com/sun/star/awt/XMenu.hpp> 27 #include <vbahelper/vbahelperinterface.hxx> 28 #include "vbacommandbarhelper.hxx" 29 #include <cppuhelper/implbase.hxx> 30 31 typedef InheritedHelperInterfaceWeakImpl< ov::XCommandBarControl > CommandBarControl_BASE; 32 33 class ScVbaCommandBarControl : public CommandBarControl_BASE 34 { 35 protected: 36 VbaCommandBarHelperRef pCBarHelper; 37 OUString m_sResourceUrl; 38 css::uno::Reference< css::container::XIndexAccess > m_xCurrentSettings; 39 css::uno::Reference< css::container::XIndexAccess > m_xBarSettings; 40 css::uno::Sequence< css::beans::PropertyValue > m_aPropertyValues; 41 42 sal_Int32 m_nPosition; 43 44 private: 45 /// @throws css::uno::RuntimeException 46 void ApplyChange(); 47 48 public: 49 /// @throws css::uno::RuntimeException 50 ScVbaCommandBarControl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, const VbaCommandBarHelperRef& pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const OUString& sResourceUrl ); 51 52 // Attributes 53 virtual OUString SAL_CALL getCaption() override; 54 virtual void SAL_CALL setCaption( const OUString& _caption ) override; 55 virtual OUString SAL_CALL getOnAction() override; 56 virtual void SAL_CALL setOnAction( const OUString& _onaction ) override; 57 virtual sal_Bool SAL_CALL getVisible() override; 58 virtual void SAL_CALL setVisible( sal_Bool _visible ) override; 59 virtual sal_Bool SAL_CALL getEnabled() override; 60 virtual void SAL_CALL setEnabled( sal_Bool _enabled ) override; 61 virtual sal_Bool SAL_CALL getBeginGroup() override; 62 virtual void SAL_CALL setBeginGroup( sal_Bool _begin ) override; getType()63 virtual sal_Int32 SAL_CALL getType() override 64 { 65 return ov::office::MsoControlType::msoControlButton; 66 } 67 68 // Methods 69 virtual void SAL_CALL Delete( ) override; 70 virtual css::uno::Any SAL_CALL Controls( const css::uno::Any& aIndex ) override; 71 72 // XHelperInterface 73 virtual OUString getServiceImplName() override; 74 virtual css::uno::Sequence<OUString> getServiceNames() override; 75 }; 76 77 typedef cppu::ImplInheritanceHelper< ScVbaCommandBarControl, ov::XCommandBarPopup > CommandBarPopup_BASE; 78 class ScVbaCommandBarPopup : public CommandBarPopup_BASE 79 { 80 public: 81 /// @throws css::uno::RuntimeException 82 ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, const VbaCommandBarHelperRef& pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const OUString& sResourceUrl, sal_Int32 nPosition ); 83 getType()84 virtual sal_Int32 SAL_CALL getType() override 85 { 86 return ov::office::MsoControlType::msoControlPopup; 87 } 88 // XHelperInterface 89 virtual OUString getServiceImplName() override; 90 virtual css::uno::Sequence<OUString> getServiceNames() override; 91 }; 92 93 typedef cppu::ImplInheritanceHelper< ScVbaCommandBarControl, ov::XCommandBarButton > CommandBarButton_BASE; 94 class ScVbaCommandBarButton : public CommandBarButton_BASE 95 { 96 public: 97 /// @throws css::uno::RuntimeException 98 ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, const VbaCommandBarHelperRef& pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const OUString& sResourceUrl, sal_Int32 nPosition ); 99 getType()100 virtual sal_Int32 SAL_CALL getType() override 101 { 102 return ov::office::MsoControlType::msoControlButton; 103 } 104 // XHelperInterface 105 virtual OUString getServiceImplName() override; 106 virtual css::uno::Sequence<OUString> getServiceNames() override; 107 }; 108 109 #endif // INCLUDED_VBAHELPER_SOURCE_VBAHELPER_VBACOMMANDBARCONTROL_HXX 110 111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 112