1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ModuleController.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_FRAMEWORK_MODULE_CONTROLLER_HXX
32 #define SD_FRAMEWORK_MODULE_CONTROLLER_HXX
34 #include "MutexOwner.hxx"
36 #include <osl/mutex.hxx>
37 #include <com/sun/star/drawing/framework/XModuleController.hpp>
38 #include <com/sun/star/uno/XComponentContext.hpp>
39 #include <com/sun/star/lang/XInitialization.hpp>
40 #include <com/sun/star/frame/XController.hpp>
41 #include <cppuhelper/compbase2.hxx>
43 #include <boost/scoped_ptr.hpp>
46 namespace css
= ::com::sun::star
;
50 typedef ::cppu::WeakComponentImplHelper2
<
51 css::drawing::framework::XModuleController
,
52 css::lang::XInitialization
53 > ModuleControllerInterfaceBase
;
55 } // end of anonymous namespace.
59 namespace sd
{ namespace framework
{
61 /** The ModuleController has to tasks:
64 org.openoffice.Office.Impress/MultiPaneGUI/Framework/ResourceFactories
65 configuration data that maps from resource URLs to service names of
66 factories that can create resources for the URLs. When the
67 configuration controller wants to create a resource for which it does
68 not have a factory, it asks the ModuleController to provide one. The
69 ModuleController looks up the service name registered for the URL of the
70 resource and instantiates this service. The service is expected to
71 register on its creation a factory for the resource in question.
73 2. The ModuleController reads on its creation
74 org.openoffice.Office.Impress/MultiPaneGUI/Framework/StartupServices
75 configuration data and instantiates all listed services. These servces
76 can then register as listeners at the ConfigurationController or do
79 class ModuleController
80 : private sd::MutexOwner
,
81 public ModuleControllerInterfaceBase
84 static css::uno::Reference
<
85 css::drawing::framework::XModuleController
>
87 const css::uno::Reference
<css::uno::XComponentContext
>&
90 virtual void SAL_CALL
disposing (void);
95 virtual void SAL_CALL
requestResource(const ::rtl::OUString
& rsResourceURL
)
96 throw (css::uno::RuntimeException
);
101 virtual void SAL_CALL
initialize(
102 const css::uno::Sequence
<css::uno::Any
>& aArguments
)
103 throw (css::uno::Exception
, css::uno::RuntimeException
);
107 css::frame::XController
> mxController
;
109 class ResourceToFactoryMap
;
110 ::boost::scoped_ptr
<ResourceToFactoryMap
> mpResourceToFactoryMap
;
111 class LoadedFactoryContainer
;
112 ::boost::scoped_ptr
<LoadedFactoryContainer
> mpLoadedFactories
;
115 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
)
117 ModuleController (void); // Not implemented.
118 ModuleController (const ModuleController
&); // Not implemented.
119 virtual ~ModuleController (void) throw();
121 /** Load a list of URL to service mappings from the
122 /org.openoffice.Office.Impress/MultiPaneGUI/Framework/ResourceFactories
123 configuration entry. The mappings are stored in the
124 mpResourceToFactoryMap member.
126 void LoadFactories (const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
);
128 /** Called for every entry in the ResourceFactories configuration entry.
130 void ProcessFactory (const ::std::vector
<css::uno::Any
>& rValues
);
132 /** Instantiate all startup services that are found in the
133 /org.openoffice.Office.Impress/MultiPaneGUI/Framework/StartupServices
134 configuration entry. This method is called once when a new
135 ModuleController object is created.
137 void InstantiateStartupServices (void);
139 /** Called for one entry in the StartupServices configuration list this
140 method instantiates the service described by the entry. It does not
141 hold references to the new object so that the object will be
142 destroyed on function exit when it does not register itself
143 somewhere. It typically will register as
144 XConfigurationChangeListener at the configuration controller.
146 void ProcessStartupService (const ::std::vector
<css::uno::Any
>& rValues
);
149 } } // end of namespace sd::framework