build fix
[LibreOffice.git] / include / framework / menuconfiguration.hxx
blob4e434d81e0685306ea1e5544e1e0e61dae1f55fa
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_FRAMEWORK_MENUCONFIGURATION_HXX
21 #define INCLUDED_FRAMEWORK_MENUCONFIGURATION_HXX
23 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
24 #include <com/sun/star/lang/WrappedTargetException.hpp>
25 #include <com/sun/star/io/XInputStream.hpp>
26 #include <com/sun/star/io/XOutputStream.hpp>
27 #include <com/sun/star/frame/XFrame.hpp>
28 #include <com/sun/star/container/XIndexContainer.hpp>
29 #include <com/sun/star/container/XIndexAccess.hpp>
30 #include <com/sun/star/frame/XDispatchProvider.hpp>
31 #include <com/sun/star/uno/XComponentContext.hpp>
33 #include <framework/fwedllapi.h>
35 #include <cppuhelper/weak.hxx>
36 #include <vcl/menu.hxx>
37 #include <vcl/toolbox.hxx>
39 // Prepare for inclusion by framework and sfx
40 // Please consider that there is a corresponding define also in sfxsids.hrc!! (SID_SFX_START)/(SID_ADDONS)
41 #define FWK_SID_SFX_START 5000
42 #define FWK_SID_ADDONS (FWK_SID_SFX_START+1678)
43 #define FWK_SID_ADDONHELP (FWK_SID_SFX_START+1684)
45 const sal_uInt16 START_ITEMID_PICKLIST = 4500;
46 const sal_uInt16 END_ITEMID_PICKLIST = 4599;
47 const sal_uInt16 MAX_ITEMCOUNT_PICKLIST = 99; // difference between START_... & END_... for picklist / must be changed too, if these values are changed!
48 const sal_uInt16 START_ITEMID_WINDOWLIST = 4600;
49 const sal_uInt16 END_ITEMID_WINDOWLIST = 4699;
50 const sal_uInt16 ITEMID_ADDONLIST = FWK_SID_ADDONS;
51 const sal_uInt16 ITEMID_ADDONHELP = FWK_SID_ADDONHELP;
53 namespace framework
56 struct FWE_DLLPUBLIC MenuAttributes
58 private:
59 oslInterlockedCount refCount;
61 MenuAttributes(const OUString& rFrame, const OUString& rImageIdStr)
62 : refCount(0)
63 , aTargetFrame(rFrame)
64 , aImageId(rImageIdStr)
68 MenuAttributes(const css::uno::WeakReference<css::frame::XDispatchProvider>& rDispatchProvider)
69 : refCount(0)
70 , xDispatchProvider(rDispatchProvider)
74 MenuAttributes(const MenuAttributes&) = delete;
76 public:
77 OUString aTargetFrame;
78 OUString aImageId;
79 css::uno::WeakReference<css::frame::XDispatchProvider> xDispatchProvider;
81 static sal_uIntPtr CreateAttribute(const OUString& rFrame, const OUString& rImageIdStr);
82 static sal_uIntPtr CreateAttribute(const css::uno::WeakReference<css::frame::XDispatchProvider>& rDispatchProvider);
83 static void ReleaseAttribute(sal_uIntPtr nAttributePtr);
85 void acquire()
87 osl_atomic_increment(&refCount);
90 void release()
92 if (!osl_atomic_decrement(&refCount))
93 delete this;
97 class FWE_DLLPUBLIC MenuConfiguration final
99 public:
100 MenuConfiguration(
101 // use const when giving a uno reference by reference
102 const css::uno::Reference< css::uno::XComponentContext >& rxContext );
104 ~MenuConfiguration();
106 css::uno::Reference< css::container::XIndexAccess > CreateMenuBarConfigurationFromXML(
107 css::uno::Reference< css::io::XInputStream >& rInputStream )
108 throw (css::lang::WrappedTargetException, css::uno::RuntimeException);
110 void StoreMenuBarConfigurationToXML(
111 css::uno::Reference< css::container::XIndexAccess >& rMenuBarConfiguration,
112 css::uno::Reference< css::io::XOutputStream >& rOutputStream,
113 bool bIsMenuBar )
114 throw (css::lang::WrappedTargetException, css::uno::RuntimeException);
116 private:
117 css::uno::Reference< css::uno::XComponentContext> m_xContext;
122 #endif // INCLUDED_FRAMEWORK_MENUCONFIGURATION_HXX
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */