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 #ifndef __FRAMEWORK_SERVICES_MODULEMANAGER_HXX_ 29*cdf0e10cSrcweir #define __FRAMEWORK_SERVICES_MODULEMANAGER_HXX_ 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir //_______________________________________________ 32*cdf0e10cSrcweir // own includes 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx> 35*cdf0e10cSrcweir #include <macros/xinterface.hxx> 36*cdf0e10cSrcweir #include <macros/xtypeprovider.hxx> 37*cdf0e10cSrcweir #include <macros/xserviceinfo.hxx> 38*cdf0e10cSrcweir #include <general.h> 39*cdf0e10cSrcweir #include <general.h> 40*cdf0e10cSrcweir #include <stdtypes.h> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir //_______________________________________________ 43*cdf0e10cSrcweir // interface includes 44*cdf0e10cSrcweir #include <com/sun/star/uno/XInterface.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/frame/XModuleManager.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/container/XNameReplace.hpp> 50*cdf0e10cSrcweir #include <com/sun/star/container/XContainerQuery.hpp> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir //_______________________________________________ 53*cdf0e10cSrcweir // other includes 54*cdf0e10cSrcweir #include <cppuhelper/weak.hxx> 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir //_______________________________________________ 57*cdf0e10cSrcweir // definition 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir namespace framework 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir //_______________________________________________ 63*cdf0e10cSrcweir /** 64*cdf0e10cSrcweir implements the service com.sun.star.frame.ModuleManager 65*cdf0e10cSrcweir */ 66*cdf0e10cSrcweir class ModuleManager : public css::lang::XTypeProvider 67*cdf0e10cSrcweir , public css::lang::XServiceInfo 68*cdf0e10cSrcweir , public css::frame::XModuleManager 69*cdf0e10cSrcweir , public css::container::XNameReplace // => XNameAccess, XElementAccess 70*cdf0e10cSrcweir , public css::container::XContainerQuery 71*cdf0e10cSrcweir // attention! Must be the first base class to guarentee right initialize lock ... 72*cdf0e10cSrcweir , private ThreadHelpBase 73*cdf0e10cSrcweir , public ::cppu::OWeakObject 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir //___________________________________________ 76*cdf0e10cSrcweir // member 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir private: 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir //--------------------------------------- 81*cdf0e10cSrcweir /** the global uno service manager. 82*cdf0e10cSrcweir Must be used to create own needed services. 83*cdf0e10cSrcweir */ 84*cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir //--------------------------------------- 87*cdf0e10cSrcweir /** points to the underlying configuration. 88*cdf0e10cSrcweir This ModuleManager does not cache - it calls directly the 89*cdf0e10cSrcweir configuration API! 90*cdf0e10cSrcweir */ 91*cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > m_xCFG; 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir //___________________________________________ 94*cdf0e10cSrcweir // interface 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir public: 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir ModuleManager(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR); 99*cdf0e10cSrcweir virtual ~ModuleManager( ); 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir // XInterface, XTypeProvider, XServiceInfo 102*cdf0e10cSrcweir FWK_DECLARE_XINTERFACE 103*cdf0e10cSrcweir FWK_DECLARE_XTYPEPROVIDER 104*cdf0e10cSrcweir DECLARE_XSERVICEINFO 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir // XModuleManager 107*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL identify(const css::uno::Reference< css::uno::XInterface >& xModule) 108*cdf0e10cSrcweir throw(css::lang::IllegalArgumentException, 109*cdf0e10cSrcweir css::frame::UnknownModuleException, 110*cdf0e10cSrcweir css::uno::RuntimeException ); 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir // XNameReplace 113*cdf0e10cSrcweir virtual void SAL_CALL replaceByName(const ::rtl::OUString& sName , 114*cdf0e10cSrcweir const css::uno::Any& aValue) 115*cdf0e10cSrcweir throw (css::lang::IllegalArgumentException , 116*cdf0e10cSrcweir css::container::NoSuchElementException, 117*cdf0e10cSrcweir css::lang::WrappedTargetException , 118*cdf0e10cSrcweir css::uno::RuntimeException ); 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir // XNameAccess 121*cdf0e10cSrcweir virtual css::uno::Any SAL_CALL getByName(const ::rtl::OUString& sName) 122*cdf0e10cSrcweir throw(css::container::NoSuchElementException, 123*cdf0e10cSrcweir css::lang::WrappedTargetException , 124*cdf0e10cSrcweir css::uno::RuntimeException ); 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() 127*cdf0e10cSrcweir throw(css::uno::RuntimeException); 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir virtual sal_Bool SAL_CALL hasByName(const ::rtl::OUString& sName) 130*cdf0e10cSrcweir throw(css::uno::RuntimeException); 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir // XElementAccess 133*cdf0e10cSrcweir virtual css::uno::Type SAL_CALL getElementType() 134*cdf0e10cSrcweir throw(css::uno::RuntimeException); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir virtual sal_Bool SAL_CALL hasElements() 137*cdf0e10cSrcweir throw(css::uno::RuntimeException); 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir // XContainerQuery 140*cdf0e10cSrcweir virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createSubSetEnumerationByQuery(const ::rtl::OUString& sQuery) 141*cdf0e10cSrcweir throw(css::uno::RuntimeException); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createSubSetEnumerationByProperties(const css::uno::Sequence< css::beans::NamedValue >& lProperties) 144*cdf0e10cSrcweir throw(css::uno::RuntimeException); 145*cdf0e10cSrcweir //___________________________________________ 146*cdf0e10cSrcweir // helper 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir private: 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir //--------------------------------------- 151*cdf0e10cSrcweir /** @short open the underlying configuration. 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir @descr This method must be called everytimes 154*cdf0e10cSrcweir a (reaonly!) configuration is needed. Because 155*cdf0e10cSrcweir method works together with the member 156*cdf0e10cSrcweir m_xCFG, open it on demand and cache it 157*cdf0e10cSrcweir afterwards. 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir Note: A writable configuration access 160*cdf0e10cSrcweir must be created explicitly. Otherwise 161*cdf0e10cSrcweir we cant make sure that broken write requests 162*cdf0e10cSrcweir wont affect our read access ! 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir @return [com.sun.star.container.XNameAccess] 165*cdf0e10cSrcweir the configuration object 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir @throw [com.sun.star.uno.RuntimeException] 168*cdf0e10cSrcweir if config could not be opened successfully! 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir @threadsafe 171*cdf0e10cSrcweir */ 172*cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > implts_getConfig() 173*cdf0e10cSrcweir throw(css::uno::RuntimeException); 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir //--------------------------------------- 176*cdf0e10cSrcweir /** @short makes the real identification of the module. 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir @descr It checks for the optional but preferred interface 179*cdf0e10cSrcweir XModule first. If this module does not exists at the 180*cdf0e10cSrcweir given component it tries to use XServiceInfo instead. 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir Note: This method try to locate a suitable module name. 183*cdf0e10cSrcweir Nothing else. Selecting the right component and throwing suitable 184*cdf0e10cSrcweir exceptions must be done outside. 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir @see identify() 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir @param xComponent 189*cdf0e10cSrcweir the module for identification. 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir @return The identifier of the given module. 192*cdf0e10cSrcweir Can be empty if given component is not a real module ! 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir @threadsafe 195*cdf0e10cSrcweir */ 196*cdf0e10cSrcweir ::rtl::OUString implts_identify(const css::uno::Reference< css::uno::XInterface >& xComponent); 197*cdf0e10cSrcweir }; 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir } // namespace framework 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir #endif // __FRAMEWORK_SERVICES_MODULEMANAGER_HXX_ 202