1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_framework.hxx"
30*cdf0e10cSrcweir #include <uiconfiguration/moduleuicfgsupplier.hxx>
31*cdf0e10cSrcweir #include <threadhelp/resetableguard.hxx>
32*cdf0e10cSrcweir #include <services.h>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
35*cdf0e10cSrcweir //	interface includes
36*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
37*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/io/XSeekable.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/embed/XPackageStructureCreator.hpp>
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
47*cdf0e10cSrcweir //	other includes
48*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
49*cdf0e10cSrcweir #include <rtl/logfile.hxx>
50*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
51*cdf0e10cSrcweir #include <vcl/svapp.hxx>
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir using namespace com::sun::star::uno;
54*cdf0e10cSrcweir using namespace com::sun::star::io;
55*cdf0e10cSrcweir using namespace com::sun::star::lang;
56*cdf0e10cSrcweir using namespace com::sun::star::container;
57*cdf0e10cSrcweir using namespace com::sun::star::beans;
58*cdf0e10cSrcweir using namespace com::sun::star::embed;
59*cdf0e10cSrcweir using namespace ::com::sun::star::ui;
60*cdf0e10cSrcweir using namespace ::com::sun::star::frame;
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir namespace framework
63*cdf0e10cSrcweir {
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir class RootStorageWrapper :  public ::cppu::WeakImplHelper1< com::sun::star::embed::XTransactedObject >
66*cdf0e10cSrcweir {
67*cdf0e10cSrcweir     public:
68*cdf0e10cSrcweir         //  XInterface, XTypeProvider
69*cdf0e10cSrcweir         RootStorageWrapper( const Reference< XTransactedObject >& xRootCommit ) : m_xRootCommit( xRootCommit ) {}
70*cdf0e10cSrcweir         virtual ~RootStorageWrapper() {}
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir         // XTransactedObject
73*cdf0e10cSrcweir         virtual void SAL_CALL commit() throw ( com::sun::star::io::IOException, com::sun::star::lang::WrappedTargetException )
74*cdf0e10cSrcweir         {
75*cdf0e10cSrcweir             m_xRootCommit->commit();
76*cdf0e10cSrcweir         }
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir 	    virtual void SAL_CALL revert() throw ( com::sun::star::io::IOException, com::sun::star::lang::WrappedTargetException )
79*cdf0e10cSrcweir         {
80*cdf0e10cSrcweir             m_xRootCommit->revert();
81*cdf0e10cSrcweir         }
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir     private:
84*cdf0e10cSrcweir         Reference< XTransactedObject > m_xRootCommit;
85*cdf0e10cSrcweir };
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir //*****************************************************************************************************************
88*cdf0e10cSrcweir //	XInterface, XTypeProvider, XServiceInfo
89*cdf0e10cSrcweir //*****************************************************************************************************************
90*cdf0e10cSrcweir DEFINE_XINTERFACE_4                    (    ModuleUIConfigurationManagerSupplier                    ,
91*cdf0e10cSrcweir                                             OWeakObject                                             ,
92*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::lang::XTypeProvider                                          ),
93*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::lang::XServiceInfo                                           ),
94*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::lang::XComponent                                             ),
95*cdf0e10cSrcweir 											DIRECT_INTERFACE( ::com::sun::star::ui::XModuleUIConfigurationManagerSupplier )
96*cdf0e10cSrcweir 										)
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir DEFINE_XTYPEPROVIDER_4                  (   ModuleUIConfigurationManagerSupplier                                ,
99*cdf0e10cSrcweir                                             css::lang::XTypeProvider			                                ,
100*cdf0e10cSrcweir                                             css::lang::XServiceInfo				                                ,
101*cdf0e10cSrcweir                                             css::lang::XComponent                                               ,
102*cdf0e10cSrcweir 											::com::sun::star::ui::XModuleUIConfigurationManagerSupplier
103*cdf0e10cSrcweir 										)
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir DEFINE_XSERVICEINFO_ONEINSTANCESERVICE  (   ModuleUIConfigurationManagerSupplier                    ,
106*cdf0e10cSrcweir                                             ::cppu::OWeakObject                                     ,
107*cdf0e10cSrcweir                                             SERVICENAME_MODULEUICONFIGURATIONMANAGERSUPPLIER        ,
108*cdf0e10cSrcweir 											IMPLEMENTATIONNAME_MODULEUICONFIGURATIONMANAGERSUPPLIER
109*cdf0e10cSrcweir 										)
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir DEFINE_INIT_SERVICE                     (   ModuleUIConfigurationManagerSupplier, {} )
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir /*TODO_AS
115*cdf0e10cSrcweir void ModuleUIConfigurationManagerSupplier::impl_initStorages()
116*cdf0e10cSrcweir {
117*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManagerSupplier::impl_initStorages" );
118*cdf0e10cSrcweir     if ( !m_bInit )
119*cdf0e10cSrcweir     {
120*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::ModuleUIConfigurationManagerSupplier::impl_initStorages" );
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir         rtl::OUString aFinalSlash( RTL_CONSTASCII_USTRINGPARAM( "/" ));
123*cdf0e10cSrcweir         rtl::OUString aConfigRootFolder( RTL_CONSTASCII_USTRINGPARAM( "soffice.cfg/modules" ));
124*cdf0e10cSrcweir         rtl::OUString aConfigSubFolder( RTL_CONSTASCII_USTRINGPARAM( "soffice.cfg/modules/soffice.cfg" ));
125*cdf0e10cSrcweir         rtl::OUString aConfigRootFolder( RTL_CONSTASCII_USTRINGPARAM( "soffice.cfg" ));
126*cdf0e10cSrcweir         rtl::OUString aConfigSubFolder( RTL_CONSTASCII_USTRINGPARAM( "soffice.cfg/soffice.cfg" ));
127*cdf0e10cSrcweir         rtl::OUString aConfigFileName( RTL_CONSTASCII_USTRINGPARAM( "soffice.cfg/uiconfig.zip" ));
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir         Reference< XPropertySet > xPathSettings( m_xServiceManager->createInstance(
130*cdf0e10cSrcweir                                                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.PathSettings" ))),
131*cdf0e10cSrcweir                                                   UNO_QUERY_THROW );
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir         Any a = xPathSettings->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UIConfig" )));
134*cdf0e10cSrcweir         a >>= m_aDefaultConfigURL;
135*cdf0e10cSrcweir         a = xPathSettings->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UserConfig" )));
136*cdf0e10cSrcweir         a >>= m_aUserConfigURL;
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir         // Use only the first entry from "UIConfig"
139*cdf0e10cSrcweir         sal_Int32 nIndex = m_aDefaultConfigURL.indexOf( ';' );
140*cdf0e10cSrcweir         if ( nIndex > 0 )
141*cdf0e10cSrcweir             m_aDefaultConfigURL = m_aDefaultConfigURL.copy( 0, nIndex );
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir         rtl::OUString aDefaultConfigFolderURL( m_aDefaultConfigURL );
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir         nIndex = m_aDefaultConfigURL.lastIndexOf( '/' );
146*cdf0e10cSrcweir         if (( nIndex > 0 ) &&  ( nIndex != ( m_aDefaultConfigURL.getLength()-1 )))
147*cdf0e10cSrcweir         {
148*cdf0e10cSrcweir             m_aDefaultConfigURL += aFinalSlash;
149*cdf0e10cSrcweir             aDefaultConfigFolderURL += aFinalSlash;
150*cdf0e10cSrcweir         }
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir         nIndex = m_aUserConfigURL.lastIndexOf( '/' );
153*cdf0e10cSrcweir         if (( nIndex > 0 ) &&  ( nIndex != ( m_aUserConfigURL.getLength()-1 )))
154*cdf0e10cSrcweir             m_aUserConfigURL += aFinalSlash;
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir //        aDefaultConfigFolderURL += aConfigRootFolder;
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir         // Create root storages for user interface configuration data (default and customizable)
159*cdf0e10cSrcweir         Reference< XSingleServiceFactory > xStorageFactory( m_xServiceManager->createInstance(
160*cdf0e10cSrcweir                                                                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.embed.StorageFactory" ))),
161*cdf0e10cSrcweir                                                             UNO_QUERY_THROW );
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir         Sequence< Any > aArgs( 2 );
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir         // Default root storage (READ-ACCESS)
166*cdf0e10cSrcweir         aArgs[0] <<= m_aDefaultConfigURL + aConfigFileName; //aConfigSubFolder;
167*cdf0e10cSrcweir         aArgs[1] <<= ElementModes::READ;
168*cdf0e10cSrcweir         m_xDefaultCfgRootStorage = Reference< XStorage >( xStorageFactory->createInstanceWithArguments( aArgs ), UNO_QUERY_THROW );
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 	    Reference < XOutputStream > xTempOut( m_xServiceManager->createInstance (
171*cdf0e10cSrcweir                                                 ::rtl::OUString::createFromAscii( "com.sun.star.io.TempFile" ) ),
172*cdf0e10cSrcweir 						                      UNO_QUERY );
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir         Reference< XPackageStructureCreator > xPackageStructCreator( m_xServiceManager->createInstance(
175*cdf0e10cSrcweir                                                                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.embed.PackageStructureCreator" ))),
176*cdf0e10cSrcweir                                                                      UNO_QUERY_THROW );
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ convertToPackage" );
179*cdf0e10cSrcweir         xPackageStructCreator->convertToPackage( aDefaultConfigFolderURL, xTempOut );
180*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_TRACE( aLog, "} convertToPackage" );
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir         xTempOut->closeOutput();
183*cdf0e10cSrcweir         Reference< XInputStream > xTempIn( xTempOut, UNO_QUERY );
184*cdf0e10cSrcweir         Reference< XSeekable > xTempSeek( xTempOut, UNO_QUERY );
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir         // Default root storage (READ-ACCESS)
187*cdf0e10cSrcweir         xTempSeek->seek( 0 );
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir         aArgs[0] <<= xTempIn;
190*cdf0e10cSrcweir         aArgs[1] <<= ElementModes::READ;
191*cdf0e10cSrcweir         m_xDefaultCfgRootStorage = Reference< XStorage >( xStorageFactory->createInstanceWithArguments( aArgs ), UNO_QUERY_THROW );
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir         // Customizable root storage (READWRITE-ACCESS)
194*cdf0e10cSrcweir         aArgs[0] <<= m_aUserConfigURL + aConfigSubFolder;
195*cdf0e10cSrcweir         aArgs[1] <<= ElementModes::READWRITE;
196*cdf0e10cSrcweir         m_xUserCfgRootStorage = Reference< XStorage >( xStorageFactory->createInstanceWithArguments( aArgs ), UNO_QUERY );
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir         // Create wrapper object for module user interface configuration managers, so they are able to call commit/revert on
199*cdf0e10cSrcweir         // root storage and nothing more (saftey)!
200*cdf0e10cSrcweir         RootStorageWrapper* pUserRootStorageWrapper = new RootStorageWrapper( Reference< XTransactedObject >( m_xUserCfgRootStorage, UNO_QUERY ));
201*cdf0e10cSrcweir         m_xUserRootCommit = Reference< XTransactedObject>( static_cast< OWeakObject *>( pUserRootStorageWrapper ), UNO_QUERY );
202*cdf0e10cSrcweir     }
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir     m_bInit = true;
205*cdf0e10cSrcweir }
206*cdf0e10cSrcweir */
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir ModuleUIConfigurationManagerSupplier::ModuleUIConfigurationManagerSupplier( const Reference< XMultiServiceFactory >& xServiceManager ) :
210*cdf0e10cSrcweir     ThreadHelpBase( &Application::GetSolarMutex() )
211*cdf0e10cSrcweir     , m_bDisposed( false )
212*cdf0e10cSrcweir //TODO_AS    , m_bInit( false )
213*cdf0e10cSrcweir     , m_xModuleMgr( Reference< XModuleManager >( xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY ))
214*cdf0e10cSrcweir     , m_xServiceManager( xServiceManager )
215*cdf0e10cSrcweir     , m_aListenerContainer( m_aLock.getShareableOslMutex() )
216*cdf0e10cSrcweir {
217*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManagerSupplier::ModuleUIConfigurationManagerSupplier" );
218*cdf0e10cSrcweir     // Retrieve known modules and insert them into our hash_map to speed-up access time.
219*cdf0e10cSrcweir     Reference< XNameAccess > xNameAccess( m_xModuleMgr, UNO_QUERY );
220*cdf0e10cSrcweir     const Sequence< ::rtl::OUString >     aNameSeq   = xNameAccess->getElementNames();
221*cdf0e10cSrcweir     const ::rtl::OUString*                pNameSeq   = aNameSeq.getConstArray();
222*cdf0e10cSrcweir     for ( sal_Int32 n = 0; n < aNameSeq.getLength(); n++ )
223*cdf0e10cSrcweir         m_aModuleToModuleUICfgMgrMap.insert( ModuleToModuleCfgMgr::value_type(  pNameSeq[n], Reference< XUIConfigurationManager >() ));
224*cdf0e10cSrcweir }
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir ModuleUIConfigurationManagerSupplier::~ModuleUIConfigurationManagerSupplier()
227*cdf0e10cSrcweir {
228*cdf0e10cSrcweir     m_xUserRootCommit.clear();
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir     // dispose all our module user interface configuration managers
231*cdf0e10cSrcweir     ModuleToModuleCfgMgr::iterator pIter = m_aModuleToModuleUICfgMgrMap.begin();
232*cdf0e10cSrcweir     while ( pIter != m_aModuleToModuleUICfgMgrMap.end() )
233*cdf0e10cSrcweir     {
234*cdf0e10cSrcweir         Reference< XComponent > xComponent( pIter->second, UNO_QUERY );
235*cdf0e10cSrcweir         if ( xComponent.is() )
236*cdf0e10cSrcweir             xComponent->dispose();
237*cdf0e10cSrcweir         ++pIter;
238*cdf0e10cSrcweir     }
239*cdf0e10cSrcweir /*TODO_AS
240*cdf0e10cSrcweir     // Dispose our root configuration storages
241*cdf0e10cSrcweir     if ( m_xDefaultCfgRootStorage.is() )
242*cdf0e10cSrcweir     {
243*cdf0e10cSrcweir         Reference< XComponent > xComponent( m_xDefaultCfgRootStorage, UNO_QUERY );
244*cdf0e10cSrcweir         xComponent->dispose();
245*cdf0e10cSrcweir     }
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir     if ( m_xUserCfgRootStorage.is() )
248*cdf0e10cSrcweir     {
249*cdf0e10cSrcweir         Reference< XComponent > xComponent( m_xUserCfgRootStorage, UNO_QUERY );
250*cdf0e10cSrcweir         xComponent->dispose();
251*cdf0e10cSrcweir     }
252*cdf0e10cSrcweir */
253*cdf0e10cSrcweir }
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir // XComponent
256*cdf0e10cSrcweir void SAL_CALL ModuleUIConfigurationManagerSupplier::dispose()
257*cdf0e10cSrcweir throw ( RuntimeException )
258*cdf0e10cSrcweir {
259*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManagerSupplier::dispose" );
260*cdf0e10cSrcweir     Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir     css::lang::EventObject aEvent( xThis );
263*cdf0e10cSrcweir     m_aListenerContainer.disposeAndClear( aEvent );
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir 	{
266*cdf0e10cSrcweir 	    ResetableGuard aGuard( m_aLock );
267*cdf0e10cSrcweir         m_bDisposed = true;
268*cdf0e10cSrcweir     }
269*cdf0e10cSrcweir }
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir void SAL_CALL ModuleUIConfigurationManagerSupplier::addEventListener( const Reference< XEventListener >& xListener )
272*cdf0e10cSrcweir throw ( RuntimeException )
273*cdf0e10cSrcweir {
274*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManagerSupplier::addEventListener" );
275*cdf0e10cSrcweir     {
276*cdf0e10cSrcweir         ResetableGuard aGuard( m_aLock );
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir 	    /* SAFE AREA ----------------------------------------------------------------------------------------------- */
279*cdf0e10cSrcweir         if ( m_bDisposed )
280*cdf0e10cSrcweir             throw DisposedException();
281*cdf0e10cSrcweir     }
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir     m_aListenerContainer.addInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener );
284*cdf0e10cSrcweir }
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir void SAL_CALL ModuleUIConfigurationManagerSupplier::removeEventListener( const Reference< XEventListener >& xListener )
287*cdf0e10cSrcweir throw ( RuntimeException )
288*cdf0e10cSrcweir {
289*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManagerSupplier::removeEventListener" );
290*cdf0e10cSrcweir     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
291*cdf0e10cSrcweir     m_aListenerContainer.removeInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener );
292*cdf0e10cSrcweir }
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir // XModuleUIConfigurationManagerSupplier
295*cdf0e10cSrcweir Reference< XUIConfigurationManager > SAL_CALL ModuleUIConfigurationManagerSupplier::getUIConfigurationManager( const ::rtl::OUString& ModuleIdentifier )
296*cdf0e10cSrcweir throw ( NoSuchElementException, RuntimeException)
297*cdf0e10cSrcweir {
298*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManagerSupplier::getUIConfigurationManager" );
299*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
302*cdf0e10cSrcweir     if ( m_bDisposed )
303*cdf0e10cSrcweir         throw DisposedException();
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir     ModuleToModuleCfgMgr::iterator pIter = m_aModuleToModuleUICfgMgrMap.find( ModuleIdentifier );
306*cdf0e10cSrcweir     if ( pIter == m_aModuleToModuleUICfgMgrMap.end() )
307*cdf0e10cSrcweir         throw NoSuchElementException();
308*cdf0e10cSrcweir //TODO_AS    impl_initStorages();
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir     // Create instance on demand
311*cdf0e10cSrcweir     if ( !pIter->second.is() )
312*cdf0e10cSrcweir     {
313*cdf0e10cSrcweir         /*TODO_AS
314*cdf0e10cSrcweir         Reference< XStorage > xDefaultConfigModuleStorage;
315*cdf0e10cSrcweir         Reference< XStorage > xUserConfigModuleStorage;
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir         try
318*cdf0e10cSrcweir         {
319*cdf0e10cSrcweir             xDefaultConfigModuleStorage = Reference< XStorage >( m_xDefaultCfgRootStorage->openStorageElement(
320*cdf0e10cSrcweir                                                                     sShort, ElementModes::READ ), UNO_QUERY_THROW );
321*cdf0e10cSrcweir 
322*cdf0e10cSrcweir             if ( m_xUserCfgRootStorage.is() )
323*cdf0e10cSrcweir             {
324*cdf0e10cSrcweir                 try
325*cdf0e10cSrcweir                 {
326*cdf0e10cSrcweir                     xUserConfigModuleStorage = Reference< XStorage >( m_xUserCfgRootStorage->openStorageElement(
327*cdf0e10cSrcweir                                                                         sShort, ElementModes::READWRITE ), UNO_QUERY );
328*cdf0e10cSrcweir                 }
329*cdf0e10cSrcweir                 catch( ::com::sun::star::io::IOException& )
330*cdf0e10cSrcweir                 {
331*cdf0e10cSrcweir                     try
332*cdf0e10cSrcweir                     {
333*cdf0e10cSrcweir                         xUserConfigModuleStorage = Reference< XStorage >( m_xUserCfgRootStorage->openStorageElement(
334*cdf0e10cSrcweir                                                                             sShort, ElementModes::READ ), UNO_QUERY );
335*cdf0e10cSrcweir                     }
336*cdf0e10cSrcweir                     catch( com::sun::star::uno::Exception& )
337*cdf0e10cSrcweir                     {
338*cdf0e10cSrcweir                     }
339*cdf0e10cSrcweir                 }
340*cdf0e10cSrcweir             }
341*cdf0e10cSrcweir         }
342*cdf0e10cSrcweir         catch ( com::sun::star::uno::Exception& )
343*cdf0e10cSrcweir         {
344*cdf0e10cSrcweir         }
345*cdf0e10cSrcweir         PropertyValue   aArg;
346*cdf0e10cSrcweir         Sequence< Any > aArgs( 5 );
347*cdf0e10cSrcweir         aArg.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModuleIdentifier" ));
348*cdf0e10cSrcweir         aArg.Value <<= ModuleIdentifier;
349*cdf0e10cSrcweir         aArgs[0] <<= aArg;
350*cdf0e10cSrcweir         aArg.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultConfigStorage" ));
351*cdf0e10cSrcweir         aArg.Value <<= xDefaultConfigModuleStorage;
352*cdf0e10cSrcweir         aArgs[1] <<= aArg;
353*cdf0e10cSrcweir         aArg.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UserConfigStorage" ));
354*cdf0e10cSrcweir         aArg.Value <<= xUserConfigModuleStorage;
355*cdf0e10cSrcweir         aArgs[2] <<= aArg;
356*cdf0e10cSrcweir         aArg.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UserRootCommit" ));
357*cdf0e10cSrcweir         aArg.Value <<= m_xUserRootCommit;
358*cdf0e10cSrcweir         aArgs[3] <<= aArg;
359*cdf0e10cSrcweir         */
360*cdf0e10cSrcweir         ::rtl::OUString sShort;
361*cdf0e10cSrcweir         try
362*cdf0e10cSrcweir         {
363*cdf0e10cSrcweir             Sequence< PropertyValue > lProps;
364*cdf0e10cSrcweir             Reference< XNameAccess > xCont(m_xModuleMgr, UNO_QUERY);
365*cdf0e10cSrcweir             xCont->getByName(ModuleIdentifier) >>= lProps;
366*cdf0e10cSrcweir             for (sal_Int32 i=0; i<lProps.getLength(); ++i)
367*cdf0e10cSrcweir             {
368*cdf0e10cSrcweir                 if (lProps[i].Name.equalsAscii("ooSetupFactoryShortName"))
369*cdf0e10cSrcweir                 {
370*cdf0e10cSrcweir                     lProps[i].Value >>= sShort;
371*cdf0e10cSrcweir                     break;
372*cdf0e10cSrcweir                 }
373*cdf0e10cSrcweir             }
374*cdf0e10cSrcweir         }
375*cdf0e10cSrcweir         catch( Exception& )
376*cdf0e10cSrcweir         {
377*cdf0e10cSrcweir             sShort = ::rtl::OUString();
378*cdf0e10cSrcweir         }
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir         if (!sShort.getLength())
381*cdf0e10cSrcweir             throw NoSuchElementException();
382*cdf0e10cSrcweir         PropertyValue   aArg;
383*cdf0e10cSrcweir         Sequence< Any > aArgs( 2 );
384*cdf0e10cSrcweir         aArg.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModuleShortName" ));
385*cdf0e10cSrcweir         aArg.Value <<= sShort;
386*cdf0e10cSrcweir         aArgs[0] <<= aArg;
387*cdf0e10cSrcweir         aArg.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModuleIdentifier" ));
388*cdf0e10cSrcweir         aArg.Value <<= ModuleIdentifier;
389*cdf0e10cSrcweir         aArgs[1] <<= aArg;
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir         pIter->second.set( m_xServiceManager->createInstanceWithArguments(SERVICENAME_MODULEUICONFIGURATIONMANAGER, aArgs ),UNO_QUERY );
392*cdf0e10cSrcweir     }
393*cdf0e10cSrcweir 
394*cdf0e10cSrcweir     return pIter->second;
395*cdf0e10cSrcweir }
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir } // namespace framework
398*cdf0e10cSrcweir 
399