1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef SC_VBA_COMMANDBARCONTROL_HXX 24 #define SC_VBA_COMMANDBARCONTROL_HXX 25 26 #include <ooo/vba/XCommandBarControl.hpp> 27 #include <ooo/vba/XCommandBarPopup.hpp> 28 #include <ooo/vba/XCommandBarButton.hpp> 29 #include <ooo/vba/office/MsoControlType.hpp> 30 #include <com/sun/star/awt/XMenu.hpp> 31 #include <vbahelper/vbahelperinterface.hxx> 32 #include "vbacommandbarhelper.hxx" 33 #include <cppuhelper/implbase1.hxx> 34 35 typedef InheritedHelperInterfaceImpl1< ov::XCommandBarControl > CommandBarControl_BASE; 36 37 class ScVbaCommandBarControl : public CommandBarControl_BASE 38 { 39 protected: 40 VbaCommandBarHelperRef pCBarHelper; 41 rtl::OUString m_sResourceUrl; 42 css::uno::Reference< css::container::XIndexAccess > m_xCurrentSettings; 43 css::uno::Reference< css::container::XIndexAccess > m_xBarSettings; 44 css::uno::Sequence< css::beans::PropertyValue > m_aPropertyValues; 45 46 sal_Int32 m_nPosition; 47 sal_Bool m_bTemporary; 48 49 private: 50 void ApplyChange() throw (css::uno::RuntimeException); 51 52 public: 53 ScVbaCommandBarControl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl ) throw (css::uno::RuntimeException); 54 ScVbaCommandBarControl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException); 55 56 // Attributes 57 virtual ::rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException); 58 virtual void SAL_CALL setCaption( const ::rtl::OUString& _caption ) throw (css::uno::RuntimeException); 59 virtual ::rtl::OUString SAL_CALL getOnAction() throw (css::uno::RuntimeException); 60 virtual void SAL_CALL setOnAction( const ::rtl::OUString& _onaction ) throw (css::uno::RuntimeException); 61 virtual ::sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException); 62 virtual void SAL_CALL setVisible( ::sal_Bool _visible ) throw (css::uno::RuntimeException); 63 virtual ::sal_Bool SAL_CALL getEnabled() throw (css::uno::RuntimeException); 64 virtual void SAL_CALL setEnabled( ::sal_Bool _enabled ) throw (css::uno::RuntimeException); 65 virtual ::sal_Bool SAL_CALL getBeginGroup() throw (css::uno::RuntimeException); 66 virtual void SAL_CALL setBeginGroup( ::sal_Bool _begin ) throw (css::uno::RuntimeException); getType()67 virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException) 68 { 69 return ov::office::MsoControlType::msoControlButton; 70 } 71 72 // Methods 73 virtual void SAL_CALL Delete( ) throw (css::script::BasicErrorException, css::uno::RuntimeException); 74 virtual css::uno::Any SAL_CALL Controls( const css::uno::Any& aIndex ) throw (css::script::BasicErrorException, css::uno::RuntimeException); 75 76 // XHelperInterface 77 virtual rtl::OUString& getServiceImplName(); 78 virtual css::uno::Sequence<rtl::OUString> getServiceNames(); 79 }; 80 81 typedef cppu::ImplInheritanceHelper1< ScVbaCommandBarControl, ov::XCommandBarPopup > CommandBarPopup_BASE; 82 class ScVbaCommandBarPopup : public CommandBarPopup_BASE 83 { 84 public: 85 ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException); 86 getType()87 virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException) 88 { 89 return ov::office::MsoControlType::msoControlPopup; 90 } 91 // XHelperInterface 92 virtual rtl::OUString& getServiceImplName(); 93 virtual css::uno::Sequence<rtl::OUString> getServiceNames(); 94 }; 95 96 typedef cppu::ImplInheritanceHelper1< ScVbaCommandBarControl, ov::XCommandBarButton > CommandBarButton_BASE; 97 class ScVbaCommandBarButton : public CommandBarButton_BASE 98 { 99 public: 100 ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException); 101 getType()102 virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException) 103 { 104 return ov::office::MsoControlType::msoControlButton; 105 } 106 // XHelperInterface 107 virtual rtl::OUString& getServiceImplName(); 108 virtual css::uno::Sequence<rtl::OUString> getServiceNames(); 109 }; 110 111 #endif//SC_VBA_COMMANDBARCONTROL_HXX 112