xref: /trunk/main/vbahelper/source/vbahelper/vbacommandbarhelper.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 VBA_COMMANDBARHELPER_HXX
24 #define VBA_COMMANDBARHELPER_HXX
25 
26 #include <vbahelper/vbahelperinterface.hxx>
27 #include <com/sun/star/frame/XModel.hpp>
28 #include <com/sun/star/uno/XComponentContext.hpp>
29 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
30 #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
31 #include <com/sun/star/container/XIndexAccess.hpp>
32 #include <com/sun/star/container/XNameAccess.hpp>
33 #include <com/sun/star/frame/XLayoutManager.hpp>
34 #include <boost/shared_ptr.hpp>
35 
36 
37 static const char ITEM_DESCRIPTOR_COMMANDURL[]  = "CommandURL";
38 static const char ITEM_DESCRIPTOR_HELPURL[]     = "HelpURL";
39 static const char ITEM_DESCRIPTOR_CONTAINER[]   = "ItemDescriptorContainer";
40 static const char ITEM_DESCRIPTOR_LABEL[]       = "Label";
41 static const char ITEM_DESCRIPTOR_TYPE[]        = "Type";
42 static const char ITEM_DESCRIPTOR_STYLE[]       = "Style";
43 static const char ITEM_DESCRIPTOR_ISVISIBLE[]   = "IsVisible";
44 static const char ITEM_DESCRIPTOR_RESOURCEURL[] = "ResourceURL";
45 static const char ITEM_DESCRIPTOR_UINAME[]      = "UIName";
46 static const char ITEM_DESCRIPTOR_ENABLED[]     = "Enabled";
47 
48 static const char ITEM_MENUBAR_URL[] = "private:resource/menubar/menubar";
49 static const char ITEM_TOOLBAR_URL[] = "private:resource/toolbar/";
50 
51 static const char CUSTOM_TOOLBAR_STR[] = "custom_toolbar_";
52 static const char CUSTOM_MENU_STR[] = "vnd.openoffice.org:CustomMenu";
53 
54 class VbaCommandBarHelper;
55 typedef ::boost::shared_ptr< VbaCommandBarHelper > VbaCommandBarHelperRef;
56 
57 class VbaCommandBarHelper
58 {
59 private:
60     css::uno::Reference< css::uno::XComponentContext > mxContext;
61     css::uno::Reference< css::frame::XModel > mxModel;
62     css::uno::Reference< css::ui::XUIConfigurationManager > m_xDocCfgMgr; // current document
63     css::uno::Reference< css::ui::XUIConfigurationManager > m_xAppCfgMgr;
64     css::uno::Reference< css::container::XNameAccess > m_xWindowState;
65     rtl::OUString maModuleId;
66 
67     void Init();
68     sal_Bool hasToolbar( const rtl::OUString& sResourceUrl, const rtl::OUString& sName );
69 public:
70     VbaCommandBarHelper( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::frame::XModel >& xModel );
71 
getModel()72     css::uno::Reference< css::frame::XModel > getModel() { return mxModel; }
73 
getDocCfgManager()74     css::uno::Reference< css::ui::XUIConfigurationManager > getDocCfgManager()
75     {
76         return m_xDocCfgMgr;
77     }
getAppCfgManager()78     css::uno::Reference< css::ui::XUIConfigurationManager > getAppCfgManager()
79     {
80         return m_xAppCfgMgr;
81     }
getPersistentWindowState()82     css::uno::Reference< css::container::XNameAccess > getPersistentWindowState()
83     {
84         return m_xWindowState;
85     }
86     sal_Bool persistChanges();
87     css::uno::Reference< css::container::XIndexAccess > getSettings( const rtl::OUString& sResourceUrl );
88     void removeSettings( const rtl::OUString& sResourceUrl );
89     void ApplyChange( const rtl::OUString& sResourceUrl, const css::uno::Reference< css::container::XIndexAccess >& xSettings, sal_Bool bTemporary = sal_True );
90 
91     css::uno::Reference< css::frame::XLayoutManager > getLayoutManager();
92 
getModuleId()93     const rtl::OUString getModuleId(){ return maModuleId; }
94     rtl::OUString findToolbarByName( const css::uno::Reference< css::container::XNameAccess >& xNameAccess, const rtl::OUString& sName );
95     static sal_Int32 findControlByName( const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, const rtl::OUString& sName, bool bMenu = false );
96     static rtl::OUString generateCustomURL();
97 };
98 
99 #endif //VBA_COMMANDBARHELPER_HXX
100