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