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 :
20 : #ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_UICOMMANDDESCRIPTION_HXX
21 : #define INCLUDED_FRAMEWORK_INC_UIELEMENT_UICOMMANDDESCRIPTION_HXX
22 :
23 : #include <boost/unordered_map.hpp>
24 :
25 : #include <stdtypes.h>
26 :
27 : #include <com/sun/star/lang/XServiceInfo.hpp>
28 : #include <com/sun/star/container/XNameAccess.hpp>
29 : #include <com/sun/star/frame/XModuleManager2.hpp>
30 : #include <com/sun/star/uno/XComponentContext.hpp>
31 :
32 : #include <cppuhelper/basemutex.hxx>
33 : #include <cppuhelper/compbase2.hxx>
34 : #include <cppuhelper/supportsservice.hxx>
35 : #include <rtl/ustring.hxx>
36 :
37 : namespace framework
38 : {
39 : typedef ::cppu::WeakComponentImplHelper2< com::sun::star::lang::XServiceInfo,
40 : com::sun::star::container::XNameAccess > UICommandDescription_BASE;
41 :
42 : class UICommandDescription : private cppu::BaseMutex,
43 : public UICommandDescription_BASE
44 : {
45 : public:
46 : UICommandDescription( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
47 : virtual ~UICommandDescription();
48 :
49 0 : virtual OUString SAL_CALL getImplementationName()
50 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
51 : {
52 0 : return OUString("com.sun.star.comp.framework.UICommandDescription");
53 : }
54 :
55 0 : virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
56 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
57 : {
58 0 : return cppu::supportsService(this, ServiceName);
59 : }
60 :
61 0 : virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
62 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
63 : {
64 0 : css::uno::Sequence< OUString > aSeq(1);
65 0 : aSeq[0] = OUString("com.sun.star.frame.UICommandDescription");
66 0 : return aSeq;
67 : }
68 :
69 : private:
70 : // XNameAccess
71 : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName )
72 : throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
73 :
74 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames()
75 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
76 :
77 : virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
78 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
79 :
80 : // XElementAccess
81 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
82 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
83 : virtual sal_Bool SAL_CALL hasElements()
84 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
85 :
86 : public:
87 : typedef ::boost::unordered_map< OUString,
88 : OUString,
89 : OUStringHash,
90 : ::std::equal_to< OUString > > ModuleToCommandFileMap;
91 :
92 : typedef ::boost::unordered_map< OUString,
93 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >,
94 : OUStringHash,
95 : ::std::equal_to< OUString > > UICommandsHashMap;
96 :
97 : protected:
98 : UICommandDescription( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& rxContext, bool );
99 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > impl_createConfigAccess(const OUString& _sName);
100 : void impl_fillElements(const sal_Char* _pName);
101 : bool m_bConfigRead;
102 : OUString m_aPrivateResourceURL;
103 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
104 : ModuleToCommandFileMap m_aModuleToCommandFileMap;
105 : UICommandsHashMap m_aUICommandsHashMap;
106 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xGenericUICommands;
107 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 > m_xModuleManager;
108 : };
109 :
110 : } // namespace framework
111 :
112 : #endif // __FRAMEWORK_SERVICES_UICOMMANDDESCRPTION_HXX_
113 :
114 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|