16d739b60SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
36d739b60SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
46d739b60SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
56d739b60SAndrew Rist  * distributed with this work for additional information
66d739b60SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
76d739b60SAndrew Rist  * to you under the Apache License, Version 2.0 (the
86d739b60SAndrew Rist  * "License"); you may not use this file except in compliance
96d739b60SAndrew Rist  * with the License.  You may obtain a copy of the License at
106d739b60SAndrew Rist  *
116d739b60SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
126d739b60SAndrew Rist  *
136d739b60SAndrew Rist  * Unless required by applicable law or agreed to in writing,
146d739b60SAndrew Rist  * software distributed under the License is distributed on an
156d739b60SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
166d739b60SAndrew Rist  * KIND, either express or implied.  See the License for the
176d739b60SAndrew Rist  * specific language governing permissions and limitations
186d739b60SAndrew Rist  * under the License.
196d739b60SAndrew Rist  *
206d739b60SAndrew Rist  *************************************************************/
216d739b60SAndrew Rist 
226d739b60SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_framework.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //_________________________________________________________________________________________________________________
28cdf0e10cSrcweir //	my own includes
29cdf0e10cSrcweir //_________________________________________________________________________________________________________________
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #ifndef __FRAMEWORK_UICONFIGURATION_UICATEGORYDESCRPTION_HXX_
32cdf0e10cSrcweir #include "uiconfiguration/uicategorydescription.hxx"
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir #include <threadhelp/resetableguard.hxx>
35cdf0e10cSrcweir #include "services.h"
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include "properties.h"
38cdf0e10cSrcweir 
39cdf0e10cSrcweir //_________________________________________________________________________________________________________________
40cdf0e10cSrcweir //	interface includes
41cdf0e10cSrcweir //_________________________________________________________________________________________________________________
42cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
43cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
44cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
45cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
46cdf0e10cSrcweir #include <com/sun/star/container/XContainer.hpp>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir //_________________________________________________________________________________________________________________
49cdf0e10cSrcweir //	includes of other projects
50cdf0e10cSrcweir //_________________________________________________________________________________________________________________
51cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
52cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
53cdf0e10cSrcweir #include <unotools/configmgr.hxx>
54cdf0e10cSrcweir #include <tools/string.hxx>
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #ifndef _VCL_MNEMONIC_HXX_
57cdf0e10cSrcweir #include <vcl/mnemonic.hxx>
58cdf0e10cSrcweir #endif
59cdf0e10cSrcweir #include <comphelper/sequence.hxx>
60cdf0e10cSrcweir #include <rtl/logfile.hxx>
61cdf0e10cSrcweir 
62cdf0e10cSrcweir //_________________________________________________________________________________________________________________
63cdf0e10cSrcweir //	Defines
64cdf0e10cSrcweir //_________________________________________________________________________________________________________________
65cdf0e10cSrcweir //
66cdf0e10cSrcweir 
67cdf0e10cSrcweir using namespace com::sun::star::uno;
68cdf0e10cSrcweir using namespace com::sun::star::lang;
69cdf0e10cSrcweir using namespace com::sun::star::beans;
70cdf0e10cSrcweir using namespace com::sun::star::container;
71cdf0e10cSrcweir using namespace ::com::sun::star::frame;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir //_________________________________________________________________________________________________________________
74cdf0e10cSrcweir //	Namespace
75cdf0e10cSrcweir //_________________________________________________________________________________________________________________
76cdf0e10cSrcweir //
77cdf0e10cSrcweir 
78cdf0e10cSrcweir struct ModuleToCategory
79cdf0e10cSrcweir {
80cdf0e10cSrcweir     const char* pModuleId;
81cdf0e10cSrcweir     const char* pCommands;
82cdf0e10cSrcweir };
83cdf0e10cSrcweir 
84cdf0e10cSrcweir static const char CATEGORY[]                                = "Category";
85cdf0e10cSrcweir static const char GENERIC_MODULE_NAME[]                     = "generic";
86cdf0e10cSrcweir static const char CONFIGURATION_ROOT_ACCESS[]               = "/org.openoffice.Office.UI.";
87cdf0e10cSrcweir static const char CONFIGURATION_CATEGORY_ELEMENT_ACCESS[]   = "/Commands/Categories";
88cdf0e10cSrcweir static const char CONFIGURATION_PROPERTY_NAME[]             = "Name";
89cdf0e10cSrcweir 
90cdf0e10cSrcweir namespace framework
91cdf0e10cSrcweir {
92cdf0e10cSrcweir 
93cdf0e10cSrcweir //*****************************************************************************************************************
94cdf0e10cSrcweir //	Configuration access class for PopupMenuControllerFactory implementation
95cdf0e10cSrcweir //*****************************************************************************************************************
96cdf0e10cSrcweir 
97*07a3d7f1SPedro Giffuni class ConfigurationAccess_UICategory : // Order is necessary for right initialization!
98cdf0e10cSrcweir                                         private ThreadHelpBase                           ,
99cdf0e10cSrcweir                                         public  ::cppu::WeakImplHelper2<XNameAccess,XContainerListener>
100cdf0e10cSrcweir {
101cdf0e10cSrcweir     public:
102cdf0e10cSrcweir                                   ConfigurationAccess_UICategory( const ::rtl::OUString& aModuleName, const Reference< XNameAccess >& xGenericUICommands, const Reference< XMultiServiceFactory >& rServiceManager );
103cdf0e10cSrcweir         virtual                   ~ConfigurationAccess_UICategory();
104cdf0e10cSrcweir 
105cdf0e10cSrcweir         // XNameAccess
106cdf0e10cSrcweir         virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
107cdf0e10cSrcweir             throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
108cdf0e10cSrcweir 
109cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
110cdf0e10cSrcweir             throw (::com::sun::star::uno::RuntimeException);
111cdf0e10cSrcweir 
112cdf0e10cSrcweir         virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
113cdf0e10cSrcweir             throw (::com::sun::star::uno::RuntimeException);
114cdf0e10cSrcweir 
115cdf0e10cSrcweir         // XElementAccess
116cdf0e10cSrcweir         virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
117cdf0e10cSrcweir             throw (::com::sun::star::uno::RuntimeException);
118cdf0e10cSrcweir 
119cdf0e10cSrcweir         virtual sal_Bool SAL_CALL hasElements()
120cdf0e10cSrcweir             throw (::com::sun::star::uno::RuntimeException);
121cdf0e10cSrcweir 
122cdf0e10cSrcweir         // container.XContainerListener
123cdf0e10cSrcweir         virtual void SAL_CALL     elementInserted( const ContainerEvent& aEvent ) throw(RuntimeException);
124cdf0e10cSrcweir         virtual void SAL_CALL     elementRemoved ( const ContainerEvent& aEvent ) throw(RuntimeException);
125cdf0e10cSrcweir         virtual void SAL_CALL     elementReplaced( const ContainerEvent& aEvent ) throw(RuntimeException);
126cdf0e10cSrcweir 
127cdf0e10cSrcweir         // lang.XEventListener
128cdf0e10cSrcweir         virtual void SAL_CALL disposing( const EventObject& aEvent ) throw(RuntimeException);
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     protected:
131cdf0e10cSrcweir         Any                       getUINameFromID( const rtl::OUString& rId );
132cdf0e10cSrcweir         Any                       getUINameFromCache( const rtl::OUString& rId );
133cdf0e10cSrcweir         Sequence< rtl::OUString > getAllIds();
134cdf0e10cSrcweir         sal_Bool                  fillCache();
135cdf0e10cSrcweir 
136cdf0e10cSrcweir     private:
137cdf0e10cSrcweir         typedef ::std::hash_map< ::rtl::OUString,
138cdf0e10cSrcweir                                  ::rtl::OUString,
1395758ad8cSAriel Constenla-Haile                                  rtl::OUStringHash,
140cdf0e10cSrcweir                                  ::std::equal_to< ::rtl::OUString > > IdToInfoCache;
141cdf0e10cSrcweir 
142cdf0e10cSrcweir         sal_Bool initializeConfigAccess();
143cdf0e10cSrcweir 
144cdf0e10cSrcweir         rtl::OUString                     m_aConfigCategoryAccess;
145cdf0e10cSrcweir         rtl::OUString                     m_aPropUIName;
146cdf0e10cSrcweir         Reference< XNameAccess >          m_xGenericUICategories;
147cdf0e10cSrcweir         Reference< XMultiServiceFactory > m_xServiceManager;
148cdf0e10cSrcweir         Reference< XMultiServiceFactory > m_xConfigProvider;
149cdf0e10cSrcweir         Reference< XNameAccess >          m_xConfigAccess;
150cdf0e10cSrcweir         sal_Bool                          m_bConfigAccessInitialized;
151cdf0e10cSrcweir         sal_Bool                          m_bCacheFilled;
152cdf0e10cSrcweir         IdToInfoCache                     m_aIdCache;
153cdf0e10cSrcweir };
154cdf0e10cSrcweir 
155cdf0e10cSrcweir //*****************************************************************************************************************
156cdf0e10cSrcweir //	XInterface, XTypeProvider
157cdf0e10cSrcweir //*****************************************************************************************************************
158cdf0e10cSrcweir 
ConfigurationAccess_UICategory(const rtl::OUString & aModuleName,const Reference<XNameAccess> & rGenericUICategories,const Reference<XMultiServiceFactory> & rServiceManager)159cdf0e10cSrcweir ConfigurationAccess_UICategory::ConfigurationAccess_UICategory( const rtl::OUString& aModuleName, const Reference< XNameAccess >& rGenericUICategories, const Reference< XMultiServiceFactory >& rServiceManager ) :
160cdf0e10cSrcweir     ThreadHelpBase(),
161cdf0e10cSrcweir     m_aConfigCategoryAccess( RTL_CONSTASCII_USTRINGPARAM( CONFIGURATION_ROOT_ACCESS )),
162cdf0e10cSrcweir     m_aPropUIName( RTL_CONSTASCII_USTRINGPARAM( CONFIGURATION_PROPERTY_NAME )),
163cdf0e10cSrcweir     m_xGenericUICategories( rGenericUICategories ),
164cdf0e10cSrcweir     m_xServiceManager( rServiceManager ),
165cdf0e10cSrcweir     m_bConfigAccessInitialized( sal_False ),
166cdf0e10cSrcweir     m_bCacheFilled( sal_False )
167cdf0e10cSrcweir {
168cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ConfigurationAccess_UICategory::ConfigurationAccess_UICategory" );
169*07a3d7f1SPedro Giffuni     // Create configuration hierarchical access name
170cdf0e10cSrcweir     m_aConfigCategoryAccess += aModuleName;
171cdf0e10cSrcweir     m_aConfigCategoryAccess += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( CONFIGURATION_CATEGORY_ELEMENT_ACCESS ));
172cdf0e10cSrcweir 
173cdf0e10cSrcweir     m_xConfigProvider = Reference< XMultiServiceFactory >( rServiceManager->createInstance(SERVICENAME_CFGPROVIDER),UNO_QUERY );
174cdf0e10cSrcweir }
175cdf0e10cSrcweir 
~ConfigurationAccess_UICategory()176cdf0e10cSrcweir ConfigurationAccess_UICategory::~ConfigurationAccess_UICategory()
177cdf0e10cSrcweir {
178cdf0e10cSrcweir     // SAFE
179cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
180cdf0e10cSrcweir     Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
181cdf0e10cSrcweir     if ( xContainer.is() )
182cdf0e10cSrcweir         xContainer->removeContainerListener( this );
183cdf0e10cSrcweir }
184cdf0e10cSrcweir 
185cdf0e10cSrcweir // XNameAccess
getByName(const::rtl::OUString & rId)186cdf0e10cSrcweir Any SAL_CALL ConfigurationAccess_UICategory::getByName( const ::rtl::OUString& rId )
187cdf0e10cSrcweir throw ( NoSuchElementException, WrappedTargetException, RuntimeException)
188cdf0e10cSrcweir {
189cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ConfigurationAccess_UICategory::getByName" );
190cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
191cdf0e10cSrcweir     if ( !m_bConfigAccessInitialized )
192cdf0e10cSrcweir     {
193cdf0e10cSrcweir         initializeConfigAccess();
194cdf0e10cSrcweir         m_bConfigAccessInitialized = sal_True;
195cdf0e10cSrcweir         fillCache();
196cdf0e10cSrcweir     }
197cdf0e10cSrcweir 
198cdf0e10cSrcweir     // SAFE
199cdf0e10cSrcweir     Any a = getUINameFromID( rId );
200cdf0e10cSrcweir 
201cdf0e10cSrcweir     if ( !a.hasValue() )
202cdf0e10cSrcweir         throw NoSuchElementException();
203cdf0e10cSrcweir 
204cdf0e10cSrcweir     return a;
205cdf0e10cSrcweir }
206cdf0e10cSrcweir 
getElementNames()207cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL ConfigurationAccess_UICategory::getElementNames()
208cdf0e10cSrcweir throw ( RuntimeException )
209cdf0e10cSrcweir {
210cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ConfigurationAccess_UICategory::getElementNames" );
211cdf0e10cSrcweir     return getAllIds();
212cdf0e10cSrcweir }
213cdf0e10cSrcweir 
hasByName(const::rtl::OUString & rId)214cdf0e10cSrcweir sal_Bool SAL_CALL ConfigurationAccess_UICategory::hasByName( const ::rtl::OUString& rId )
215cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
216cdf0e10cSrcweir {
217cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ConfigurationAccess_UICategory::hasByName" );
218cdf0e10cSrcweir     return getByName( rId ).hasValue();
219cdf0e10cSrcweir }
220cdf0e10cSrcweir 
221cdf0e10cSrcweir // XElementAccess
getElementType()222cdf0e10cSrcweir Type SAL_CALL ConfigurationAccess_UICategory::getElementType()
223cdf0e10cSrcweir throw ( RuntimeException )
224cdf0e10cSrcweir {
225cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ConfigurationAccess_UICategory::getElementType" );
226cdf0e10cSrcweir     return( ::getCppuType( (const rtl::OUString*)NULL ) );
227cdf0e10cSrcweir }
228cdf0e10cSrcweir 
hasElements()229cdf0e10cSrcweir sal_Bool SAL_CALL ConfigurationAccess_UICategory::hasElements()
230cdf0e10cSrcweir throw ( RuntimeException )
231cdf0e10cSrcweir {
232cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ConfigurationAccess_UICategory::hasElements" );
233cdf0e10cSrcweir     // There must be global categories!
234cdf0e10cSrcweir     return sal_True;
235cdf0e10cSrcweir }
236cdf0e10cSrcweir 
fillCache()237cdf0e10cSrcweir sal_Bool ConfigurationAccess_UICategory::fillCache()
238cdf0e10cSrcweir {
239cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ConfigurationAccess_UICategory::fillCache" );
240cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::ConfigurationAccess_UICategory::fillCache" );
241cdf0e10cSrcweir 
242cdf0e10cSrcweir     if ( m_bCacheFilled )
243cdf0e10cSrcweir         return sal_True;
244cdf0e10cSrcweir 
245cdf0e10cSrcweir     sal_Int32            i( 0 );
246cdf0e10cSrcweir     rtl::OUString        aUIName;
247cdf0e10cSrcweir     Sequence< ::rtl::OUString > aNameSeq = m_xConfigAccess->getElementNames();
248cdf0e10cSrcweir 
249cdf0e10cSrcweir     for ( i = 0; i < aNameSeq.getLength(); i++ )
250cdf0e10cSrcweir     {
251cdf0e10cSrcweir         try
252cdf0e10cSrcweir         {
253cdf0e10cSrcweir             Reference< XNameAccess > xNameAccess(m_xConfigAccess->getByName( aNameSeq[i] ),UNO_QUERY);
254cdf0e10cSrcweir             if ( xNameAccess.is() )
255cdf0e10cSrcweir             {
256cdf0e10cSrcweir                 xNameAccess->getByName( m_aPropUIName ) >>= aUIName;
257cdf0e10cSrcweir 
258cdf0e10cSrcweir                 m_aIdCache.insert( IdToInfoCache::value_type( aNameSeq[i], aUIName ));
259cdf0e10cSrcweir             }
260cdf0e10cSrcweir         }
261cdf0e10cSrcweir         catch ( com::sun::star::lang::WrappedTargetException& )
262cdf0e10cSrcweir         {
263cdf0e10cSrcweir         }
264cdf0e10cSrcweir         catch ( com::sun::star::container::NoSuchElementException& )
265cdf0e10cSrcweir         {
266cdf0e10cSrcweir         }
267cdf0e10cSrcweir     }
268cdf0e10cSrcweir 
269cdf0e10cSrcweir     m_bCacheFilled = sal_True;
270cdf0e10cSrcweir 
271cdf0e10cSrcweir     return sal_True;
272cdf0e10cSrcweir }
273cdf0e10cSrcweir 
getUINameFromID(const rtl::OUString & rId)274cdf0e10cSrcweir Any ConfigurationAccess_UICategory::getUINameFromID( const rtl::OUString& rId )
275cdf0e10cSrcweir {
276cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ConfigurationAccess_UICategory::getUINameFromID" );
277cdf0e10cSrcweir     Any a;
278cdf0e10cSrcweir 
279cdf0e10cSrcweir     try
280cdf0e10cSrcweir     {
281cdf0e10cSrcweir         a = getUINameFromCache( rId );
282cdf0e10cSrcweir         if ( !a.hasValue() )
283cdf0e10cSrcweir         {
284cdf0e10cSrcweir             // Try to ask our global commands configuration access
285cdf0e10cSrcweir             if ( m_xGenericUICategories.is() )
286cdf0e10cSrcweir             {
287cdf0e10cSrcweir                 try
288cdf0e10cSrcweir                 {
289cdf0e10cSrcweir                     return m_xGenericUICategories->getByName( rId );
290cdf0e10cSrcweir                 }
291cdf0e10cSrcweir                 catch ( com::sun::star::lang::WrappedTargetException& )
292cdf0e10cSrcweir                 {
293cdf0e10cSrcweir                 }
294cdf0e10cSrcweir                 catch ( com::sun::star::container::NoSuchElementException& )
295cdf0e10cSrcweir                 {
296cdf0e10cSrcweir                 }
297cdf0e10cSrcweir             }
298cdf0e10cSrcweir         }
299cdf0e10cSrcweir     }
300cdf0e10cSrcweir     catch( com::sun::star::container::NoSuchElementException& )
301cdf0e10cSrcweir     {
302cdf0e10cSrcweir     }
303cdf0e10cSrcweir     catch ( com::sun::star::lang::WrappedTargetException& )
304cdf0e10cSrcweir     {
305cdf0e10cSrcweir     }
306cdf0e10cSrcweir 
307cdf0e10cSrcweir     return a;
308cdf0e10cSrcweir }
309cdf0e10cSrcweir 
getUINameFromCache(const rtl::OUString & rId)310cdf0e10cSrcweir Any ConfigurationAccess_UICategory::getUINameFromCache( const rtl::OUString& rId )
311cdf0e10cSrcweir {
312cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ConfigurationAccess_UICategory::getUINameFromCache" );
313cdf0e10cSrcweir     Any a;
314cdf0e10cSrcweir 
315cdf0e10cSrcweir     IdToInfoCache::const_iterator pIter = m_aIdCache.find( rId );
316cdf0e10cSrcweir     if ( pIter != m_aIdCache.end() )
317cdf0e10cSrcweir         a <<= pIter->second;
318cdf0e10cSrcweir 
319cdf0e10cSrcweir     return a;
320cdf0e10cSrcweir }
321cdf0e10cSrcweir 
getAllIds()322cdf0e10cSrcweir Sequence< rtl::OUString > ConfigurationAccess_UICategory::getAllIds()
323cdf0e10cSrcweir {
324cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ConfigurationAccess_UICategory::getAllIds" );
325cdf0e10cSrcweir     // SAFE
326cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
327cdf0e10cSrcweir 
328cdf0e10cSrcweir     if ( !m_bConfigAccessInitialized )
329cdf0e10cSrcweir     {
330cdf0e10cSrcweir         initializeConfigAccess();
331cdf0e10cSrcweir         m_bConfigAccessInitialized = sal_True;
332cdf0e10cSrcweir         fillCache();
333cdf0e10cSrcweir     }
334cdf0e10cSrcweir 
335cdf0e10cSrcweir     if ( m_xConfigAccess.is() )
336cdf0e10cSrcweir     {
337cdf0e10cSrcweir         Any                      a;
338cdf0e10cSrcweir         Reference< XNameAccess > xNameAccess;
339cdf0e10cSrcweir 
340cdf0e10cSrcweir         try
341cdf0e10cSrcweir         {
342cdf0e10cSrcweir             Sequence< ::rtl::OUString > aNameSeq = m_xConfigAccess->getElementNames();
343cdf0e10cSrcweir 
344cdf0e10cSrcweir             if ( m_xGenericUICategories.is() )
345cdf0e10cSrcweir             {
346cdf0e10cSrcweir                 // Create concat list of supported user interface commands of the module
347cdf0e10cSrcweir                 Sequence< ::rtl::OUString > aGenericNameSeq = m_xGenericUICategories->getElementNames();
348cdf0e10cSrcweir                 sal_uInt32 nCount1 = aNameSeq.getLength();
349cdf0e10cSrcweir                 sal_uInt32 nCount2 = aGenericNameSeq.getLength();
350cdf0e10cSrcweir 
351cdf0e10cSrcweir                 aNameSeq.realloc( nCount1 + nCount2 );
352cdf0e10cSrcweir                 ::rtl::OUString* pNameSeq = aNameSeq.getArray();
353cdf0e10cSrcweir                 const ::rtl::OUString* pGenericSeq = aGenericNameSeq.getConstArray();
354cdf0e10cSrcweir                 for ( sal_uInt32 i = 0; i < nCount2; i++ )
355cdf0e10cSrcweir                     pNameSeq[nCount1+i] = pGenericSeq[i];
356cdf0e10cSrcweir             }
357cdf0e10cSrcweir 
358cdf0e10cSrcweir             return aNameSeq;
359cdf0e10cSrcweir         }
360cdf0e10cSrcweir         catch( com::sun::star::container::NoSuchElementException& )
361cdf0e10cSrcweir         {
362cdf0e10cSrcweir         }
363cdf0e10cSrcweir         catch ( com::sun::star::lang::WrappedTargetException& )
364cdf0e10cSrcweir         {
365cdf0e10cSrcweir         }
366cdf0e10cSrcweir     }
367cdf0e10cSrcweir 
368cdf0e10cSrcweir     return Sequence< rtl::OUString >();
369cdf0e10cSrcweir }
370cdf0e10cSrcweir 
initializeConfigAccess()371cdf0e10cSrcweir sal_Bool ConfigurationAccess_UICategory::initializeConfigAccess()
372cdf0e10cSrcweir {
373cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ConfigurationAccess_UICategory::initializeConfigAccess" );
374cdf0e10cSrcweir     Sequence< Any > aArgs( 1 );
375cdf0e10cSrcweir     PropertyValue   aPropValue;
376cdf0e10cSrcweir 
377cdf0e10cSrcweir     try
378cdf0e10cSrcweir     {
379cdf0e10cSrcweir         aPropValue.Name  = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ));
380cdf0e10cSrcweir         aPropValue.Value <<= m_aConfigCategoryAccess;
381cdf0e10cSrcweir         aArgs[0] <<= aPropValue;
382cdf0e10cSrcweir 
383cdf0e10cSrcweir         m_xConfigAccess = Reference< XNameAccess >( m_xConfigProvider->createInstanceWithArguments(SERVICENAME_CFGREADACCESS,aArgs ),UNO_QUERY );
384cdf0e10cSrcweir         if ( m_xConfigAccess.is() )
385cdf0e10cSrcweir         {
386cdf0e10cSrcweir             // Add as container listener
387cdf0e10cSrcweir             Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
388cdf0e10cSrcweir             if ( xContainer.is() )
389cdf0e10cSrcweir                 xContainer->addContainerListener( this );
390cdf0e10cSrcweir         }
391cdf0e10cSrcweir 
392cdf0e10cSrcweir         return sal_True;
393cdf0e10cSrcweir     }
394cdf0e10cSrcweir     catch ( WrappedTargetException& )
395cdf0e10cSrcweir     {
396cdf0e10cSrcweir     }
397cdf0e10cSrcweir     catch ( Exception& )
398cdf0e10cSrcweir     {
399cdf0e10cSrcweir     }
400cdf0e10cSrcweir 
401cdf0e10cSrcweir     return sal_False;
402cdf0e10cSrcweir }
403cdf0e10cSrcweir 
404cdf0e10cSrcweir // container.XContainerListener
elementInserted(const ContainerEvent &)405cdf0e10cSrcweir void SAL_CALL ConfigurationAccess_UICategory::elementInserted( const ContainerEvent& ) throw(RuntimeException)
406cdf0e10cSrcweir {
407cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ConfigurationAccess_UICategory::elementInserted" );
408cdf0e10cSrcweir }
409cdf0e10cSrcweir 
elementRemoved(const ContainerEvent &)410cdf0e10cSrcweir void SAL_CALL ConfigurationAccess_UICategory::elementRemoved ( const ContainerEvent& ) throw(RuntimeException)
411cdf0e10cSrcweir {
412cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ConfigurationAccess_UICategory::elementRemoved " );
413cdf0e10cSrcweir }
414cdf0e10cSrcweir 
elementReplaced(const ContainerEvent &)415cdf0e10cSrcweir void SAL_CALL ConfigurationAccess_UICategory::elementReplaced( const ContainerEvent& ) throw(RuntimeException)
416cdf0e10cSrcweir {
417cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ConfigurationAccess_UICategory::elementReplaced" );
418cdf0e10cSrcweir }
419cdf0e10cSrcweir 
420cdf0e10cSrcweir // lang.XEventListener
disposing(const EventObject & aEvent)421cdf0e10cSrcweir void SAL_CALL ConfigurationAccess_UICategory::disposing( const EventObject& aEvent ) throw(RuntimeException)
422cdf0e10cSrcweir {
423cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ConfigurationAccess_UICategory::disposing" );
424cdf0e10cSrcweir     // SAFE
425cdf0e10cSrcweir     // remove our reference to the config access
426cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
427cdf0e10cSrcweir 
428cdf0e10cSrcweir     Reference< XInterface > xIfac1( aEvent.Source, UNO_QUERY );
429cdf0e10cSrcweir     Reference< XInterface > xIfac2( m_xConfigAccess, UNO_QUERY );
430cdf0e10cSrcweir     if ( xIfac1 == xIfac2 )
431cdf0e10cSrcweir         m_xConfigAccess.clear();
432cdf0e10cSrcweir }
433cdf0e10cSrcweir 
434cdf0e10cSrcweir //*****************************************************************************************************************
435cdf0e10cSrcweir //	XInterface, XTypeProvider, XServiceInfo
436cdf0e10cSrcweir //*****************************************************************************************************************
DEFINE_XSERVICEINFO_ONEINSTANCESERVICE(UICategoryDescription,::cppu::OWeakObject,SERVICENAME_UICATEGORYDESCRIPTION,IMPLEMENTATIONNAME_UICATEGORYDESCRIPTION)437cdf0e10cSrcweir DEFINE_XSERVICEINFO_ONEINSTANCESERVICE  (   UICategoryDescription				    ,
438cdf0e10cSrcweir                                             ::cppu::OWeakObject						,
439cdf0e10cSrcweir                                             SERVICENAME_UICATEGORYDESCRIPTION	    ,
440cdf0e10cSrcweir 											IMPLEMENTATIONNAME_UICATEGORYDESCRIPTION
441cdf0e10cSrcweir 										)
442cdf0e10cSrcweir 
443cdf0e10cSrcweir DEFINE_INIT_SERVICE                     (   UICategoryDescription, {} )
444cdf0e10cSrcweir 
445cdf0e10cSrcweir UICategoryDescription::UICategoryDescription( const Reference< XMultiServiceFactory >& xServiceManager ) :
446cdf0e10cSrcweir     UICommandDescription(xServiceManager,true)
447cdf0e10cSrcweir {
448cdf0e10cSrcweir     Reference< XNameAccess > xEmpty;
449cdf0e10cSrcweir     rtl::OUString aGenericCategories( RTL_CONSTASCII_USTRINGPARAM( "GenericCategories" ));
450cdf0e10cSrcweir     m_xGenericUICommands = new ConfigurationAccess_UICategory( aGenericCategories, xEmpty, xServiceManager );
451cdf0e10cSrcweir 
452cdf0e10cSrcweir     // insert generic categories mappings
453cdf0e10cSrcweir     m_aModuleToCommandFileMap.insert( ModuleToCommandFileMap::value_type(
454cdf0e10cSrcweir         rtl::OUString::createFromAscii( GENERIC_MODULE_NAME ), aGenericCategories ));
455cdf0e10cSrcweir 
456cdf0e10cSrcweir     UICommandsHashMap::iterator pCatIter = m_aUICommandsHashMap.find( aGenericCategories );
457cdf0e10cSrcweir     if ( pCatIter != m_aUICommandsHashMap.end() )
458cdf0e10cSrcweir         pCatIter->second = m_xGenericUICommands;
459cdf0e10cSrcweir 
460cdf0e10cSrcweir     impl_fillElements("ooSetupFactoryCmdCategoryConfigRef");
461cdf0e10cSrcweir }
462cdf0e10cSrcweir 
~UICategoryDescription()463cdf0e10cSrcweir UICategoryDescription::~UICategoryDescription()
464cdf0e10cSrcweir {
465cdf0e10cSrcweir }
impl_createConfigAccess(const::rtl::OUString & _sName)466cdf0e10cSrcweir Reference< XNameAccess > UICategoryDescription::impl_createConfigAccess(const ::rtl::OUString& _sName)
467cdf0e10cSrcweir {
468cdf0e10cSrcweir     return new ConfigurationAccess_UICategory( _sName,m_xGenericUICommands,m_xServiceManager );
469cdf0e10cSrcweir }
470cdf0e10cSrcweir 
471cdf0e10cSrcweir } // namespace framework
472cdf0e10cSrcweir 
473