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