1*d4a7ee09SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*d4a7ee09SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*d4a7ee09SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*d4a7ee09SAndrew Rist * distributed with this work for additional information 6*d4a7ee09SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*d4a7ee09SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*d4a7ee09SAndrew Rist * "License"); you may not use this file except in compliance 9*d4a7ee09SAndrew Rist * with the License. You may obtain a copy of the License at 10*d4a7ee09SAndrew Rist * 11*d4a7ee09SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*d4a7ee09SAndrew Rist * 13*d4a7ee09SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*d4a7ee09SAndrew Rist * software distributed under the License is distributed on an 15*d4a7ee09SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*d4a7ee09SAndrew Rist * KIND, either express or implied. See the License for the 17*d4a7ee09SAndrew Rist * specific language governing permissions and limitations 18*d4a7ee09SAndrew Rist * under the License. 19*d4a7ee09SAndrew Rist * 20*d4a7ee09SAndrew Rist *************************************************************/ 21*d4a7ee09SAndrew Rist 22*d4a7ee09SAndrew Rist 23cdf0e10cSrcweir #ifndef VBA_COMMANDBARHELPER_HXX 24cdf0e10cSrcweir #define VBA_COMMANDBARHELPER_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <vbahelper/vbahelperinterface.hxx> 27cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp> 28cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 29cdf0e10cSrcweir #include <com/sun/star/ui/XUIConfigurationManager.hpp> 30cdf0e10cSrcweir #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp> 31cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp> 32cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp> 33cdf0e10cSrcweir #include <com/sun/star/frame/XLayoutManager.hpp> 34cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 35cdf0e10cSrcweir 36cdf0e10cSrcweir 37cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_COMMANDURL[] = "CommandURL"; 38cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_HELPURL[] = "HelpURL"; 39cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_CONTAINER[] = "ItemDescriptorContainer"; 40cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_LABEL[] = "Label"; 41cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_TYPE[] = "Type"; 42cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_STYLE[] = "Style"; 43cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_ISVISIBLE[] = "IsVisible"; 44cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_RESOURCEURL[] = "ResourceURL"; 45cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_UINAME[] = "UIName"; 46cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_ENABLED[] = "Enabled"; 47cdf0e10cSrcweir 48cdf0e10cSrcweir static const char ITEM_MENUBAR_URL[] = "private:resource/menubar/menubar"; 49cdf0e10cSrcweir static const char ITEM_TOOLBAR_URL[] = "private:resource/toolbar/"; 50cdf0e10cSrcweir 51cdf0e10cSrcweir static const char CUSTOM_TOOLBAR_STR[] = "custom_toolbar_"; 52cdf0e10cSrcweir static const char CUSTOM_MENU_STR[] = "vnd.openoffice.org:CustomMenu"; 53cdf0e10cSrcweir 54cdf0e10cSrcweir class VbaCommandBarHelper; 55cdf0e10cSrcweir typedef ::boost::shared_ptr< VbaCommandBarHelper > VbaCommandBarHelperRef; 56cdf0e10cSrcweir 57cdf0e10cSrcweir class VbaCommandBarHelper 58cdf0e10cSrcweir { 59cdf0e10cSrcweir private: 60cdf0e10cSrcweir css::uno::Reference< css::uno::XComponentContext > mxContext; 61cdf0e10cSrcweir css::uno::Reference< css::frame::XModel > mxModel; 62cdf0e10cSrcweir css::uno::Reference< css::ui::XUIConfigurationManager > m_xDocCfgMgr; // current document 63cdf0e10cSrcweir css::uno::Reference< css::ui::XUIConfigurationManager > m_xAppCfgMgr; 64cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > m_xWindowState; 65cdf0e10cSrcweir rtl::OUString maModuleId; 66cdf0e10cSrcweir 67cdf0e10cSrcweir void Init() throw (css::uno::RuntimeException); 68cdf0e10cSrcweir sal_Bool hasToolbar( const rtl::OUString& sResourceUrl, const rtl::OUString& sName ) throw (css::uno::RuntimeException); 69cdf0e10cSrcweir public: 70cdf0e10cSrcweir VbaCommandBarHelper( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::frame::XModel >& xModel ) throw( css::uno::RuntimeException ); 71cdf0e10cSrcweir getModel()72cdf0e10cSrcweir css::uno::Reference< css::frame::XModel > getModel() { return mxModel; } 73cdf0e10cSrcweir getDocCfgManager()74cdf0e10cSrcweir css::uno::Reference< css::ui::XUIConfigurationManager > getDocCfgManager() throw (css::uno::RuntimeException) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir return m_xDocCfgMgr; 77cdf0e10cSrcweir } getAppCfgManager()78cdf0e10cSrcweir css::uno::Reference< css::ui::XUIConfigurationManager > getAppCfgManager() throw (css::uno::RuntimeException) 79cdf0e10cSrcweir { 80cdf0e10cSrcweir return m_xAppCfgMgr; 81cdf0e10cSrcweir } getPersistentWindowState()82cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > getPersistentWindowState() throw (css::uno::RuntimeException) 83cdf0e10cSrcweir { 84cdf0e10cSrcweir return m_xWindowState; 85cdf0e10cSrcweir } 86cdf0e10cSrcweir sal_Bool persistChanges() throw (css::uno::RuntimeException); 87cdf0e10cSrcweir css::uno::Reference< css::container::XIndexAccess > getSettings( const rtl::OUString& sResourceUrl ) throw (css::uno::RuntimeException); 88cdf0e10cSrcweir void removeSettings( const rtl::OUString& sResourceUrl ) throw (css::uno::RuntimeException); 89cdf0e10cSrcweir void ApplyChange( const rtl::OUString& sResourceUrl, const css::uno::Reference< css::container::XIndexAccess >& xSettings, sal_Bool bTemporary = sal_True ) throw (css::uno::RuntimeException); 90cdf0e10cSrcweir 91cdf0e10cSrcweir css::uno::Reference< css::frame::XLayoutManager > getLayoutManager() throw (css::uno::RuntimeException); 92cdf0e10cSrcweir getModuleId()93cdf0e10cSrcweir const rtl::OUString getModuleId(){ return maModuleId; } 94cdf0e10cSrcweir rtl::OUString findToolbarByName( const css::uno::Reference< css::container::XNameAccess >& xNameAccess, const rtl::OUString& sName ) throw (css::uno::RuntimeException); 95cdf0e10cSrcweir static sal_Int32 findControlByName( const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, const rtl::OUString& sName, bool bMenu = false ) throw (css::uno::RuntimeException); 96cdf0e10cSrcweir static rtl::OUString generateCustomURL(); 97cdf0e10cSrcweir }; 98cdf0e10cSrcweir 99cdf0e10cSrcweir #endif //VBA_COMMANDBARHELPER_HXX 100