1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef __FRAMEWORK_UIELEMENT_UICOMMANDDESCRPTION_HXX_
25 #define __FRAMEWORK_UIELEMENT_UICOMMANDDESCRPTION_HXX_
26 
27 /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
28                with solaris headers ...
29 */
30 #include <vector>
31 #include <list>
32 #include <hash_map>
33 
34 //_________________________________________________________________________________________________________________
35 //	my own includes
36 //_________________________________________________________________________________________________________________
37 #include <threadhelp/threadhelpbase.hxx>
38 #include <macros/generic.hxx>
39 #include <macros/xinterface.hxx>
40 #include <macros/xtypeprovider.hxx>
41 #include <macros/xserviceinfo.hxx>
42 #include <stdtypes.h>
43 
44 //_________________________________________________________________________________________________________________
45 //	interface includes
46 //_________________________________________________________________________________________________________________
47 #include <com/sun/star/lang/XServiceInfo.hpp>
48 #include <com/sun/star/lang/XTypeProvider.hpp>
49 #include <com/sun/star/container/XNameAccess.hpp>
50 #include <com/sun/star/frame/XModuleManager.hpp>
51 
52 //_________________________________________________________________________________________________________________
53 //	other includes
54 //_________________________________________________________________________________________________________________
55 #include <cppuhelper/implbase2.hxx>
56 #include <rtl/ustring.hxx>
57 
58 namespace framework
59 {
60 class UICommandDescription :  private ThreadHelpBase						,	// Struct for right initalization of mutex member! Must be first of baseclasses.
61 							  public ::cppu::WeakImplHelper2< com::sun::star::lang::XServiceInfo		,
62 							                                  com::sun::star::container::XNameAccess >
63 {
64 	public:
65 		UICommandDescription( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
66 		virtual ~UICommandDescription();
67 
68         //  XInterface, XTypeProvider, XServiceInfo
69 		DECLARE_XSERVICEINFO
70 private:
71         // XNameAccess
72         virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
73             throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
74 
75         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
76             throw (::com::sun::star::uno::RuntimeException);
77 
78         virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
79             throw (::com::sun::star::uno::RuntimeException);
80 
81         // XElementAccess
82         virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
83             throw (::com::sun::star::uno::RuntimeException);
84         virtual sal_Bool SAL_CALL hasElements()
85             throw (::com::sun::star::uno::RuntimeException);
86 
87 public:
88         typedef ::std::hash_map< ::rtl::OUString,
89                                  ::rtl::OUString,
90                                  OUStringHashCode,
91                                  ::std::equal_to< ::rtl::OUString > > ModuleToCommandFileMap;
92 
93         typedef ::std::hash_map< ::rtl::OUString,
94                                  ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >,
95                                  OUStringHashCode,
96 								 ::std::equal_to< ::rtl::OUString > > UICommandsHashMap;
97 
98     protected:
99         UICommandDescription( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager,bool  );
100         virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > impl_createConfigAccess(const ::rtl::OUString& _sName);
101         void impl_fillElements(const sal_Char* _pName);
102         sal_Bool                                                                            m_bConfigRead;
103         rtl::OUString                                                                       m_aPrivateResourceURL;
104         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >    m_xServiceManager;
105         ModuleToCommandFileMap                                                              m_aModuleToCommandFileMap;
106         UICommandsHashMap                                                                   m_aUICommandsHashMap;
107         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >        m_xGenericUICommands;
108         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager >         m_xModuleManager;
109 };
110 
111 } // namespace framework
112 
113 #endif // __FRAMEWORK_SERVICES_UICOMMANDDESCRPTION_HXX_
114