/src/libreoffice/framework/inc/menuconfiguration.hxx
Line | Count | Source |
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 | | |
20 | | #pragma once |
21 | | |
22 | | #include <cppuhelper/weakref.hxx> |
23 | | #include <utility> |
24 | | |
25 | | namespace com::sun::star::container { class XIndexAccess; } |
26 | | namespace com::sun::star::frame { class XDispatchProvider; } |
27 | | namespace com::sun::star::io { class XInputStream; } |
28 | | namespace com::sun::star::io { class XOutputStream; } |
29 | | namespace com::sun::star::uno { class XComponentContext; } |
30 | | |
31 | | namespace framework |
32 | | { |
33 | | |
34 | | struct MenuAttributes |
35 | | { |
36 | | private: |
37 | | oslInterlockedCount refCount; |
38 | | |
39 | | MenuAttributes(OUString sFrame, OUString sImageIdStr) |
40 | 0 | : refCount(0) |
41 | 0 | , aTargetFrame(std::move(sFrame)) |
42 | 0 | , aImageId(std::move(sImageIdStr)) |
43 | 0 | { |
44 | 0 | } |
45 | | |
46 | | MenuAttributes(css::uno::WeakReference<css::frame::XDispatchProvider> _xDispatchProvider) |
47 | 0 | : refCount(0) |
48 | 0 | , xDispatchProvider(std::move(_xDispatchProvider)) |
49 | 0 | { |
50 | 0 | } |
51 | | |
52 | | MenuAttributes(const MenuAttributes&) = delete; |
53 | | |
54 | | public: |
55 | | OUString aTargetFrame; |
56 | | OUString aImageId; |
57 | | css::uno::WeakReference<css::frame::XDispatchProvider> xDispatchProvider; |
58 | | |
59 | | static void* CreateAttribute(const OUString& rFrame, const OUString& rImageIdStr); |
60 | | static void* CreateAttribute(const css::uno::WeakReference<css::frame::XDispatchProvider>& rDispatchProvider); |
61 | | static void ReleaseAttribute(void* nAttributePtr); |
62 | | |
63 | | void acquire() |
64 | 0 | { |
65 | 0 | osl_atomic_increment(&refCount); |
66 | 0 | } |
67 | | |
68 | | void release() |
69 | 0 | { |
70 | 0 | if (!osl_atomic_decrement(&refCount)) |
71 | 0 | delete this; |
72 | 0 | } |
73 | | }; |
74 | | |
75 | | class MenuConfiguration final |
76 | | { |
77 | | public: |
78 | | MenuConfiguration( |
79 | | // use const when giving a UNO reference by reference |
80 | | css::uno::Reference< css::uno::XComponentContext > rxContext ); |
81 | | |
82 | | ~MenuConfiguration(); |
83 | | |
84 | | /// @throws css::lang::WrappedTargetException |
85 | | /// @throws css::uno::RuntimeException |
86 | | css::uno::Reference< css::container::XIndexAccess > CreateMenuBarConfigurationFromXML( |
87 | | css::uno::Reference< css::io::XInputStream > const & rInputStream ); |
88 | | |
89 | | /// @throws css::lang::WrappedTargetException |
90 | | /// @throws css::uno::RuntimeException |
91 | | void StoreMenuBarConfigurationToXML( |
92 | | css::uno::Reference< css::container::XIndexAccess > const & rMenuBarConfiguration, |
93 | | css::uno::Reference< css::io::XOutputStream > const & rOutputStream, |
94 | | bool bIsMenuBar ); |
95 | | |
96 | | private: |
97 | | css::uno::Reference< css::uno::XComponentContext> m_xContext; |
98 | | }; |
99 | | |
100 | | } |
101 | | |
102 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |