LibreOffice Module vbahelper (master) 1
vbacommandbarhelper.hxx
Go to the documentation of this file.
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 <com/sun/star/frame/XModel.hpp>
23#include <com/sun/star/uno/XComponentContext.hpp>
24#include <com/sun/star/ui/XUIConfigurationManager.hpp>
25#include <com/sun/star/container/XIndexAccess.hpp>
26#include <com/sun/star/container/XNameAccess.hpp>
27#include <com/sun/star/frame/XLayoutManager.hpp>
28#include <memory>
29
30inline constexpr OUStringLiteral ITEM_DESCRIPTOR_COMMANDURL = u"CommandURL";
31inline constexpr OUStringLiteral ITEM_DESCRIPTOR_HELPURL = u"HelpURL";
32inline constexpr OUStringLiteral ITEM_DESCRIPTOR_CONTAINER = u"ItemDescriptorContainer";
33inline constexpr OUStringLiteral ITEM_DESCRIPTOR_LABEL = u"Label";
34inline constexpr OUStringLiteral ITEM_DESCRIPTOR_TYPE = u"Type";
35inline constexpr OUStringLiteral ITEM_DESCRIPTOR_STYLE = u"Style";
36inline constexpr OUStringLiteral ITEM_DESCRIPTOR_ISVISIBLE = u"IsVisible";
37inline constexpr OUStringLiteral ITEM_DESCRIPTOR_UINAME = u"UIName";
38inline constexpr OUStringLiteral ITEM_DESCRIPTOR_ENABLED = u"Enabled";
39
40inline constexpr OUStringLiteral ITEM_MENUBAR_URL = u"private:resource/menubar/menubar";
41constexpr char16_t ITEM_TOOLBAR_URL[] = u"private:resource/toolbar/";
42
43inline constexpr OUStringLiteral CUSTOM_TOOLBAR_STR = u"custom_toolbar_";
44inline constexpr OUStringLiteral CUSTOM_MENU_STR = u"vnd.openoffice.org:CustomMenu";
45
47typedef std::shared_ptr< VbaCommandBarHelper > VbaCommandBarHelperRef;
48
50{
51private:
52 css::uno::Reference< css::uno::XComponentContext > mxContext;
53 css::uno::Reference< css::frame::XModel > mxModel;
54 css::uno::Reference< css::ui::XUIConfigurationManager > m_xDocCfgMgr; // current document
55 css::uno::Reference< css::ui::XUIConfigurationManager > m_xAppCfgMgr;
56 css::uno::Reference< css::container::XNameAccess > m_xWindowState;
57 OUString maModuleId;
58
60 void Init();
62 bool hasToolbar( const OUString& sResourceUrl, std::u16string_view sName );
63public:
65 VbaCommandBarHelper( css::uno::Reference< css::uno::XComponentContext > xContext, css::uno::Reference< css::frame::XModel > xModel );
66
67 const css::uno::Reference< css::frame::XModel >& getModel() const { return mxModel; }
68
70 const css::uno::Reference< css::container::XNameAccess >& getPersistentWindowState() const
71 {
72 return m_xWindowState;
73 }
75 css::uno::Reference< css::container::XIndexAccess > getSettings( const OUString& sResourceUrl );
77 void removeSettings( const OUString& sResourceUrl );
79 void ApplyTempChange( const OUString& sResourceUrl, const css::uno::Reference< css::container::XIndexAccess >& xSettings);
80
82 css::uno::Reference< css::frame::XLayoutManager > getLayoutManager() const;
83
84 const OUString& getModuleId() const { return maModuleId; }
86 OUString findToolbarByName( const css::uno::Reference< css::container::XNameAccess >& xNameAccess, const OUString& sName );
88 static sal_Int32 findControlByName( const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, std::u16string_view sName, bool bMenu );
89 static OUString generateCustomURL();
90};
91
92#endif // INCLUDED_VBAHELPER_SOURCE_VBAHELPER_VBACOMMANDBARHELPER_HXX
93
94/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static sal_Int32 findControlByName(const css::uno::Reference< css::container::XIndexAccess > &xIndexAccess, std::u16string_view sName, bool bMenu)
css::uno::Reference< css::frame::XModel > mxModel
css::uno::Reference< css::ui::XUIConfigurationManager > m_xAppCfgMgr
void removeSettings(const OUString &sResourceUrl)
css::uno::Reference< css::container::XIndexAccess > getSettings(const OUString &sResourceUrl)
bool hasToolbar(const OUString &sResourceUrl, std::u16string_view sName)
VbaCommandBarHelper(css::uno::Reference< css::uno::XComponentContext > xContext, css::uno::Reference< css::frame::XModel > xModel)
void ApplyTempChange(const OUString &sResourceUrl, const css::uno::Reference< css::container::XIndexAccess > &xSettings)
css::uno::Reference< css::container::XNameAccess > m_xWindowState
css::uno::Reference< css::frame::XLayoutManager > getLayoutManager() const
css::uno::Reference< css::uno::XComponentContext > mxContext
static OUString generateCustomURL()
const css::uno::Reference< css::frame::XModel > & getModel() const
css::uno::Reference< css::ui::XUIConfigurationManager > m_xDocCfgMgr
OUString findToolbarByName(const css::uno::Reference< css::container::XNameAccess > &xNameAccess, const OUString &sName)
const OUString & getModuleId() const
const css::uno::Reference< css::container::XNameAccess > & getPersistentWindowState() const
float u
constexpr OUStringLiteral ITEM_DESCRIPTOR_ISVISIBLE
constexpr char16_t ITEM_TOOLBAR_URL[]
constexpr OUStringLiteral CUSTOM_TOOLBAR_STR
constexpr OUStringLiteral ITEM_DESCRIPTOR_STYLE
std::shared_ptr< VbaCommandBarHelper > VbaCommandBarHelperRef
constexpr OUStringLiteral ITEM_DESCRIPTOR_COMMANDURL
constexpr OUStringLiteral ITEM_DESCRIPTOR_TYPE
constexpr OUStringLiteral ITEM_DESCRIPTOR_UINAME
constexpr OUStringLiteral CUSTOM_MENU_STR
constexpr OUStringLiteral ITEM_DESCRIPTOR_HELPURL
constexpr OUStringLiteral ITEM_DESCRIPTOR_ENABLED
constexpr OUStringLiteral ITEM_DESCRIPTOR_LABEL
constexpr OUStringLiteral ITEM_MENUBAR_URL
constexpr OUStringLiteral ITEM_DESCRIPTOR_CONTAINER