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 #ifndef SD_FRAMEWORK_MODULE_CONTROLLER_HXX 25*b1cdbd2cSJim Jagielski #define SD_FRAMEWORK_MODULE_CONTROLLER_HXX 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski #include "MutexOwner.hxx" 28*b1cdbd2cSJim Jagielski 29*b1cdbd2cSJim Jagielski #include <osl/mutex.hxx> 30*b1cdbd2cSJim Jagielski #include <com/sun/star/drawing/framework/XModuleController.hpp> 31*b1cdbd2cSJim Jagielski #include <com/sun/star/uno/XComponentContext.hpp> 32*b1cdbd2cSJim Jagielski #include <com/sun/star/lang/XInitialization.hpp> 33*b1cdbd2cSJim Jagielski #include <com/sun/star/frame/XController.hpp> 34*b1cdbd2cSJim Jagielski #include <cppuhelper/compbase2.hxx> 35*b1cdbd2cSJim Jagielski 36*b1cdbd2cSJim Jagielski #include <boost/scoped_ptr.hpp> 37*b1cdbd2cSJim Jagielski #include <set> 38*b1cdbd2cSJim Jagielski 39*b1cdbd2cSJim Jagielski namespace css = ::com::sun::star; 40*b1cdbd2cSJim Jagielski 41*b1cdbd2cSJim Jagielski namespace { 42*b1cdbd2cSJim Jagielski 43*b1cdbd2cSJim Jagielski typedef ::cppu::WeakComponentImplHelper2 < 44*b1cdbd2cSJim Jagielski css::drawing::framework::XModuleController, 45*b1cdbd2cSJim Jagielski css::lang::XInitialization 46*b1cdbd2cSJim Jagielski > ModuleControllerInterfaceBase; 47*b1cdbd2cSJim Jagielski 48*b1cdbd2cSJim Jagielski } // end of anonymous namespace. 49*b1cdbd2cSJim Jagielski 50*b1cdbd2cSJim Jagielski 51*b1cdbd2cSJim Jagielski 52*b1cdbd2cSJim Jagielski namespace sd { namespace framework { 53*b1cdbd2cSJim Jagielski 54*b1cdbd2cSJim Jagielski /** The ModuleController has to tasks: 55*b1cdbd2cSJim Jagielski 56*b1cdbd2cSJim Jagielski 1. It reads the 57*b1cdbd2cSJim Jagielski org.openoffice.Office.Impress/MultiPaneGUI/Framework/ResourceFactories 58*b1cdbd2cSJim Jagielski configuration data that maps from resource URLs to service names of 59*b1cdbd2cSJim Jagielski factories that can create resources for the URLs. When the 60*b1cdbd2cSJim Jagielski configuration controller wants to create a resource for which it does 61*b1cdbd2cSJim Jagielski not have a factory, it asks the ModuleController to provide one. The 62*b1cdbd2cSJim Jagielski ModuleController looks up the service name registered for the URL of the 63*b1cdbd2cSJim Jagielski resource and instantiates this service. The service is expected to 64*b1cdbd2cSJim Jagielski register on its creation a factory for the resource in question. 65*b1cdbd2cSJim Jagielski 66*b1cdbd2cSJim Jagielski 2. The ModuleController reads on its creation 67*b1cdbd2cSJim Jagielski org.openoffice.Office.Impress/MultiPaneGUI/Framework/StartupServices 68*b1cdbd2cSJim Jagielski configuration data and instantiates all listed services. These servces 69*b1cdbd2cSJim Jagielski can then register as listeners at the ConfigurationController or do 70*b1cdbd2cSJim Jagielski whatever they like. 71*b1cdbd2cSJim Jagielski */ 72*b1cdbd2cSJim Jagielski class ModuleController 73*b1cdbd2cSJim Jagielski : private sd::MutexOwner, 74*b1cdbd2cSJim Jagielski public ModuleControllerInterfaceBase 75*b1cdbd2cSJim Jagielski { 76*b1cdbd2cSJim Jagielski public: 77*b1cdbd2cSJim Jagielski static css::uno::Reference< 78*b1cdbd2cSJim Jagielski css::drawing::framework::XModuleController> 79*b1cdbd2cSJim Jagielski CreateInstance ( 80*b1cdbd2cSJim Jagielski const css::uno::Reference<css::uno::XComponentContext>& 81*b1cdbd2cSJim Jagielski rxContext); 82*b1cdbd2cSJim Jagielski 83*b1cdbd2cSJim Jagielski virtual void SAL_CALL disposing (void); 84*b1cdbd2cSJim Jagielski 85*b1cdbd2cSJim Jagielski 86*b1cdbd2cSJim Jagielski // XModuleController 87*b1cdbd2cSJim Jagielski 88*b1cdbd2cSJim Jagielski virtual void SAL_CALL requestResource(const ::rtl::OUString& rsResourceURL) 89*b1cdbd2cSJim Jagielski throw (css::uno::RuntimeException); 90*b1cdbd2cSJim Jagielski 91*b1cdbd2cSJim Jagielski 92*b1cdbd2cSJim Jagielski // XInitialization 93*b1cdbd2cSJim Jagielski 94*b1cdbd2cSJim Jagielski virtual void SAL_CALL initialize( 95*b1cdbd2cSJim Jagielski const css::uno::Sequence<css::uno::Any>& aArguments) 96*b1cdbd2cSJim Jagielski throw (css::uno::Exception, css::uno::RuntimeException); 97*b1cdbd2cSJim Jagielski 98*b1cdbd2cSJim Jagielski private: 99*b1cdbd2cSJim Jagielski css::uno::Reference< 100*b1cdbd2cSJim Jagielski css::frame::XController> mxController; 101*b1cdbd2cSJim Jagielski 102*b1cdbd2cSJim Jagielski class ResourceToFactoryMap; 103*b1cdbd2cSJim Jagielski ::boost::scoped_ptr<ResourceToFactoryMap> mpResourceToFactoryMap; 104*b1cdbd2cSJim Jagielski class LoadedFactoryContainer; 105*b1cdbd2cSJim Jagielski ::boost::scoped_ptr<LoadedFactoryContainer> mpLoadedFactories; 106*b1cdbd2cSJim Jagielski 107*b1cdbd2cSJim Jagielski ModuleController ( 108*b1cdbd2cSJim Jagielski const css::uno::Reference<css::uno::XComponentContext>& rxContext) 109*b1cdbd2cSJim Jagielski throw(); 110*b1cdbd2cSJim Jagielski ModuleController (void); // Not implemented. 111*b1cdbd2cSJim Jagielski ModuleController (const ModuleController&); // Not implemented. 112*b1cdbd2cSJim Jagielski virtual ~ModuleController (void) throw(); 113*b1cdbd2cSJim Jagielski 114*b1cdbd2cSJim Jagielski /** Load a list of URL to service mappings from the 115*b1cdbd2cSJim Jagielski /org.openoffice.Office.Impress/MultiPaneGUI/Framework/ResourceFactories 116*b1cdbd2cSJim Jagielski configuration entry. The mappings are stored in the 117*b1cdbd2cSJim Jagielski mpResourceToFactoryMap member. 118*b1cdbd2cSJim Jagielski */ 119*b1cdbd2cSJim Jagielski void LoadFactories (const css::uno::Reference<css::uno::XComponentContext>& rxContext); 120*b1cdbd2cSJim Jagielski 121*b1cdbd2cSJim Jagielski /** Called for every entry in the ResourceFactories configuration entry. 122*b1cdbd2cSJim Jagielski */ 123*b1cdbd2cSJim Jagielski void ProcessFactory (const ::std::vector<css::uno::Any>& rValues); 124*b1cdbd2cSJim Jagielski 125*b1cdbd2cSJim Jagielski /** Instantiate all startup services that are found in the 126*b1cdbd2cSJim Jagielski /org.openoffice.Office.Impress/MultiPaneGUI/Framework/StartupServices 127*b1cdbd2cSJim Jagielski configuration entry. This method is called once when a new 128*b1cdbd2cSJim Jagielski ModuleController object is created. 129*b1cdbd2cSJim Jagielski */ 130*b1cdbd2cSJim Jagielski void InstantiateStartupServices (void); 131*b1cdbd2cSJim Jagielski 132*b1cdbd2cSJim Jagielski /** Called for one entry in the StartupServices configuration list this 133*b1cdbd2cSJim Jagielski method instantiates the service described by the entry. It does not 134*b1cdbd2cSJim Jagielski hold references to the new object so that the object will be 135*b1cdbd2cSJim Jagielski destroyed on function exit when it does not register itself 136*b1cdbd2cSJim Jagielski somewhere. It typically will register as 137*b1cdbd2cSJim Jagielski XConfigurationChangeListener at the configuration controller. 138*b1cdbd2cSJim Jagielski */ 139*b1cdbd2cSJim Jagielski void ProcessStartupService (const ::std::vector<css::uno::Any>& rValues); 140*b1cdbd2cSJim Jagielski }; 141*b1cdbd2cSJim Jagielski 142*b1cdbd2cSJim Jagielski } } // end of namespace sd::framework 143*b1cdbd2cSJim Jagielski 144*b1cdbd2cSJim Jagielski #endif 145