1f8e07b45SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3f8e07b45SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4f8e07b45SAndrew Rist * or more contributor license agreements. See the NOTICE file 5f8e07b45SAndrew Rist * distributed with this work for additional information 6f8e07b45SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7f8e07b45SAndrew Rist * to you under the Apache License, Version 2.0 (the 8f8e07b45SAndrew Rist * "License"); you may not use this file except in compliance 9f8e07b45SAndrew Rist * with the License. You may obtain a copy of the License at 10f8e07b45SAndrew Rist * 11f8e07b45SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12f8e07b45SAndrew Rist * 13f8e07b45SAndrew Rist * Unless required by applicable law or agreed to in writing, 14f8e07b45SAndrew Rist * software distributed under the License is distributed on an 15f8e07b45SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16f8e07b45SAndrew Rist * KIND, either express or implied. See the License for the 17f8e07b45SAndrew Rist * specific language governing permissions and limitations 18f8e07b45SAndrew Rist * under the License. 19f8e07b45SAndrew Rist * 20f8e07b45SAndrew Rist *************************************************************/ 21f8e07b45SAndrew Rist 22f8e07b45SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef __FRAMEWORK_SERVICES_MODULEMANAGER_HXX_ 25cdf0e10cSrcweir #define __FRAMEWORK_SERVICES_MODULEMANAGER_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir //_______________________________________________ 28cdf0e10cSrcweir // own includes 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx> 31cdf0e10cSrcweir #include <macros/xinterface.hxx> 32cdf0e10cSrcweir #include <macros/xtypeprovider.hxx> 33cdf0e10cSrcweir #include <macros/xserviceinfo.hxx> 34cdf0e10cSrcweir #include <general.h> 35cdf0e10cSrcweir #include <general.h> 36cdf0e10cSrcweir #include <stdtypes.h> 37cdf0e10cSrcweir 38cdf0e10cSrcweir //_______________________________________________ 39cdf0e10cSrcweir // interface includes 40cdf0e10cSrcweir #include <com/sun/star/uno/XInterface.hpp> 41cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp> 42cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 43cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 44cdf0e10cSrcweir #include <com/sun/star/frame/XModuleManager.hpp> 45cdf0e10cSrcweir #include <com/sun/star/container/XNameReplace.hpp> 46cdf0e10cSrcweir #include <com/sun/star/container/XContainerQuery.hpp> 47cdf0e10cSrcweir 48cdf0e10cSrcweir //_______________________________________________ 49cdf0e10cSrcweir // other includes 50cdf0e10cSrcweir #include <cppuhelper/weak.hxx> 51cdf0e10cSrcweir 52cdf0e10cSrcweir //_______________________________________________ 53cdf0e10cSrcweir // definition 54cdf0e10cSrcweir 55cdf0e10cSrcweir namespace framework 56cdf0e10cSrcweir { 57cdf0e10cSrcweir 58cdf0e10cSrcweir //_______________________________________________ 59cdf0e10cSrcweir /** 60cdf0e10cSrcweir implements the service com.sun.star.frame.ModuleManager 61cdf0e10cSrcweir */ 62cdf0e10cSrcweir class ModuleManager : public css::lang::XTypeProvider 63cdf0e10cSrcweir , public css::lang::XServiceInfo 64cdf0e10cSrcweir , public css::frame::XModuleManager 65cdf0e10cSrcweir , public css::container::XNameReplace // => XNameAccess, XElementAccess 66cdf0e10cSrcweir , public css::container::XContainerQuery 6707a3d7f1SPedro Giffuni // attention! Must be the first base class to guarantee right initialize lock ... 68cdf0e10cSrcweir , private ThreadHelpBase 69cdf0e10cSrcweir , public ::cppu::OWeakObject 70cdf0e10cSrcweir { 71cdf0e10cSrcweir //___________________________________________ 72cdf0e10cSrcweir // member 73cdf0e10cSrcweir 74cdf0e10cSrcweir private: 75cdf0e10cSrcweir 76cdf0e10cSrcweir //--------------------------------------- 77cdf0e10cSrcweir /** the global uno service manager. 78cdf0e10cSrcweir Must be used to create own needed services. 79cdf0e10cSrcweir */ 80cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; 81cdf0e10cSrcweir 82cdf0e10cSrcweir //--------------------------------------- 83cdf0e10cSrcweir /** points to the underlying configuration. 84cdf0e10cSrcweir This ModuleManager does not cache - it calls directly the 85cdf0e10cSrcweir configuration API! 86cdf0e10cSrcweir */ 87cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > m_xCFG; 88cdf0e10cSrcweir 89cdf0e10cSrcweir //___________________________________________ 90cdf0e10cSrcweir // interface 91cdf0e10cSrcweir 92cdf0e10cSrcweir public: 93cdf0e10cSrcweir 94cdf0e10cSrcweir ModuleManager(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR); 95cdf0e10cSrcweir virtual ~ModuleManager( ); 96cdf0e10cSrcweir 97cdf0e10cSrcweir // XInterface, XTypeProvider, XServiceInfo 98cdf0e10cSrcweir FWK_DECLARE_XINTERFACE 99cdf0e10cSrcweir FWK_DECLARE_XTYPEPROVIDER 100cdf0e10cSrcweir DECLARE_XSERVICEINFO 101cdf0e10cSrcweir 102cdf0e10cSrcweir // XModuleManager 103cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL identify(const css::uno::Reference< css::uno::XInterface >& xModule) 104cdf0e10cSrcweir throw(css::lang::IllegalArgumentException, 105cdf0e10cSrcweir css::frame::UnknownModuleException, 106cdf0e10cSrcweir css::uno::RuntimeException ); 107cdf0e10cSrcweir 108cdf0e10cSrcweir // XNameReplace 109cdf0e10cSrcweir virtual void SAL_CALL replaceByName(const ::rtl::OUString& sName , 110cdf0e10cSrcweir const css::uno::Any& aValue) 111cdf0e10cSrcweir throw (css::lang::IllegalArgumentException , 112cdf0e10cSrcweir css::container::NoSuchElementException, 113cdf0e10cSrcweir css::lang::WrappedTargetException , 114cdf0e10cSrcweir css::uno::RuntimeException ); 115cdf0e10cSrcweir 116cdf0e10cSrcweir // XNameAccess 117cdf0e10cSrcweir virtual css::uno::Any SAL_CALL getByName(const ::rtl::OUString& sName) 118cdf0e10cSrcweir throw(css::container::NoSuchElementException, 119cdf0e10cSrcweir css::lang::WrappedTargetException , 120cdf0e10cSrcweir css::uno::RuntimeException ); 121cdf0e10cSrcweir 122cdf0e10cSrcweir virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() 123cdf0e10cSrcweir throw(css::uno::RuntimeException); 124cdf0e10cSrcweir 125cdf0e10cSrcweir virtual sal_Bool SAL_CALL hasByName(const ::rtl::OUString& sName) 126cdf0e10cSrcweir throw(css::uno::RuntimeException); 127cdf0e10cSrcweir 128cdf0e10cSrcweir // XElementAccess 129cdf0e10cSrcweir virtual css::uno::Type SAL_CALL getElementType() 130cdf0e10cSrcweir throw(css::uno::RuntimeException); 131cdf0e10cSrcweir 132cdf0e10cSrcweir virtual sal_Bool SAL_CALL hasElements() 133cdf0e10cSrcweir throw(css::uno::RuntimeException); 134cdf0e10cSrcweir 135cdf0e10cSrcweir // XContainerQuery 136cdf0e10cSrcweir virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createSubSetEnumerationByQuery(const ::rtl::OUString& sQuery) 137cdf0e10cSrcweir throw(css::uno::RuntimeException); 138cdf0e10cSrcweir 139cdf0e10cSrcweir virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createSubSetEnumerationByProperties(const css::uno::Sequence< css::beans::NamedValue >& lProperties) 140cdf0e10cSrcweir throw(css::uno::RuntimeException); 141cdf0e10cSrcweir //___________________________________________ 142cdf0e10cSrcweir // helper 143cdf0e10cSrcweir 144cdf0e10cSrcweir private: 145cdf0e10cSrcweir 146cdf0e10cSrcweir //--------------------------------------- 147cdf0e10cSrcweir /** @short open the underlying configuration. 148cdf0e10cSrcweir 149*9f813b30Smseidel @descr This method must be called every time 150cdf0e10cSrcweir a (reaonly!) configuration is needed. Because 151cdf0e10cSrcweir method works together with the member 152cdf0e10cSrcweir m_xCFG, open it on demand and cache it 153cdf0e10cSrcweir afterwards. 154cdf0e10cSrcweir 155cdf0e10cSrcweir Note: A writable configuration access 156cdf0e10cSrcweir must be created explicitly. Otherwise 15707a3d7f1SPedro Giffuni we can't make sure that broken write requests 158*9f813b30Smseidel won't affect our read access ! 159cdf0e10cSrcweir 160cdf0e10cSrcweir @return [com.sun.star.container.XNameAccess] 161cdf0e10cSrcweir the configuration object 162cdf0e10cSrcweir 163cdf0e10cSrcweir @throw [com.sun.star.uno.RuntimeException] 164cdf0e10cSrcweir if config could not be opened successfully! 165cdf0e10cSrcweir 166cdf0e10cSrcweir @threadsafe 167cdf0e10cSrcweir */ 168cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > implts_getConfig() 169cdf0e10cSrcweir throw(css::uno::RuntimeException); 170cdf0e10cSrcweir 171cdf0e10cSrcweir //--------------------------------------- 172cdf0e10cSrcweir /** @short makes the real identification of the module. 173cdf0e10cSrcweir 174cdf0e10cSrcweir @descr It checks for the optional but preferred interface 175cdf0e10cSrcweir XModule first. If this module does not exists at the 176cdf0e10cSrcweir given component it tries to use XServiceInfo instead. 177cdf0e10cSrcweir 178*9f813b30Smseidel Note: This method tries to locate a suitable module name. 179cdf0e10cSrcweir Nothing else. Selecting the right component and throwing suitable 180cdf0e10cSrcweir exceptions must be done outside. 181cdf0e10cSrcweir 182cdf0e10cSrcweir @see identify() 183cdf0e10cSrcweir 184cdf0e10cSrcweir @param xComponent 185cdf0e10cSrcweir the module for identification. 186cdf0e10cSrcweir 187cdf0e10cSrcweir @return The identifier of the given module. 188cdf0e10cSrcweir Can be empty if given component is not a real module ! 189cdf0e10cSrcweir 190cdf0e10cSrcweir @threadsafe 191cdf0e10cSrcweir */ 192cdf0e10cSrcweir ::rtl::OUString implts_identify(const css::uno::Reference< css::uno::XInterface >& xComponent); 193cdf0e10cSrcweir }; 194cdf0e10cSrcweir 195cdf0e10cSrcweir } // namespace framework 196cdf0e10cSrcweir 197cdf0e10cSrcweir #endif // __FRAMEWORK_SERVICES_MODULEMANAGER_HXX_ 198