1*7a32b0c8SAndre Fischer /**************************************************************
2*7a32b0c8SAndre Fischer  *
3*7a32b0c8SAndre Fischer  * Licensed to the Apache Software Foundation (ASF) under one
4*7a32b0c8SAndre Fischer  * or more contributor license agreements.  See the NOTICE file
5*7a32b0c8SAndre Fischer  * distributed with this work for additional information
6*7a32b0c8SAndre Fischer  * regarding copyright ownership.  The ASF licenses this file
7*7a32b0c8SAndre Fischer  * to you under the Apache License, Version 2.0 (the
8*7a32b0c8SAndre Fischer  * "License"); you may not use this file except in compliance
9*7a32b0c8SAndre Fischer  * with the License.  You may obtain a copy of the License at
10*7a32b0c8SAndre Fischer  *
11*7a32b0c8SAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
12*7a32b0c8SAndre Fischer  *
13*7a32b0c8SAndre Fischer  * Unless required by applicable law or agreed to in writing,
14*7a32b0c8SAndre Fischer  * software distributed under the License is distributed on an
15*7a32b0c8SAndre Fischer  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*7a32b0c8SAndre Fischer  * KIND, either express or implied.  See the License for the
17*7a32b0c8SAndre Fischer  * specific language governing permissions and limitations
18*7a32b0c8SAndre Fischer  * under the License.
19*7a32b0c8SAndre Fischer  *
20*7a32b0c8SAndre Fischer  *************************************************************/
21*7a32b0c8SAndre Fischer 
22*7a32b0c8SAndre Fischer #ifndef SD_SIDEBAR_FACTORY_HXX
23*7a32b0c8SAndre Fischer #define SD_SIDEBAR_FACTORY_HXX
24*7a32b0c8SAndre Fischer 
25*7a32b0c8SAndre Fischer #include <cppuhelper/compbase4.hxx>
26*7a32b0c8SAndre Fischer #include <cppuhelper/basemutex.hxx>
27*7a32b0c8SAndre Fischer #include <rtl/ref.hxx>
28*7a32b0c8SAndre Fischer #include "framework/Pane.hxx"
29*7a32b0c8SAndre Fischer 
30*7a32b0c8SAndre Fischer #include <com/sun/star/ui/XUIElementFactory.hpp>
31*7a32b0c8SAndre Fischer #include <com/sun/star/drawing/framework/XResourceFactory.hpp>
32*7a32b0c8SAndre Fischer #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
33*7a32b0c8SAndre Fischer #include <com/sun/star/uno/XComponentContext.hpp>
34*7a32b0c8SAndre Fischer #include <com/sun/star/lang/XInitialization.hpp>
35*7a32b0c8SAndre Fischer 
36*7a32b0c8SAndre Fischer #include <map>
37*7a32b0c8SAndre Fischer #include <boost/noncopyable.hpp>
38*7a32b0c8SAndre Fischer #include <boost/shared_ptr.hpp>
39*7a32b0c8SAndre Fischer 
40*7a32b0c8SAndre Fischer 
41*7a32b0c8SAndre Fischer namespace css = ::com::sun::star;
42*7a32b0c8SAndre Fischer namespace cssu = ::com::sun::star::uno;
43*7a32b0c8SAndre Fischer namespace cssdf = ::com::sun::star::drawing::framework;
44*7a32b0c8SAndre Fischer 
45*7a32b0c8SAndre Fischer 
46*7a32b0c8SAndre Fischer namespace sd {
47*7a32b0c8SAndre Fischer     class ViewShellBase;
48*7a32b0c8SAndre Fischer }
49*7a32b0c8SAndre Fischer 
50*7a32b0c8SAndre Fischer namespace sd { namespace sidebar {
51*7a32b0c8SAndre Fischer 
52*7a32b0c8SAndre Fischer namespace
53*7a32b0c8SAndre Fischer {
54*7a32b0c8SAndre Fischer     typedef ::cppu::WeakComponentImplHelper4 <
55*7a32b0c8SAndre Fischer         css::lang::XInitialization,
56*7a32b0c8SAndre Fischer         css::ui::XUIElementFactory,
57*7a32b0c8SAndre Fischer         cssdf::XResourceFactory,
58*7a32b0c8SAndre Fischer         css::lang::XEventListener
59*7a32b0c8SAndre Fischer         > SidebarFactoryInterfaceBase;
60*7a32b0c8SAndre Fischer }
61*7a32b0c8SAndre Fischer 
62*7a32b0c8SAndre Fischer 
63*7a32b0c8SAndre Fischer /** This factory creates both XUIElements (for sidebar panels) and
64*7a32b0c8SAndre Fischer     a drawing framework pane.
65*7a32b0c8SAndre Fischer 
66*7a32b0c8SAndre Fischer     The drawing framework pane is a container for the SidebarViewShell
67*7a32b0c8SAndre Fischer     which is necessary to run the legacy implementations of the task
68*7a32b0c8SAndre Fischer     pane panels.
69*7a32b0c8SAndre Fischer 
70*7a32b0c8SAndre Fischer     Control and information flow is like this:
71*7a32b0c8SAndre Fischer 
72*7a32b0c8SAndre Fischer     When one of the old task panels is requested to be displayed in
73*7a32b0c8SAndre Fischer     the sidebar this factory is called for
74*7a32b0c8SAndre Fischer     XUIElementFactory::createUIElement().
75*7a32b0c8SAndre Fischer     One of the arguments, the window, is then exported into the
76*7a32b0c8SAndre Fischer     drawing framework as pane.  After this the drawing framework is
77*7a32b0c8SAndre Fischer     used to create the SidebarViewShell (once known as
78*7a32b0c8SAndre Fischer     TaskPaneViewShell or ToolPanelViewShell) and the requested panel.
79*7a32b0c8SAndre Fischer */
80*7a32b0c8SAndre Fischer class SidebarFactory
81*7a32b0c8SAndre Fischer     : private ::boost::noncopyable,
82*7a32b0c8SAndre Fischer       private ::cppu::BaseMutex,
83*7a32b0c8SAndre Fischer       public SidebarFactoryInterfaceBase
84*7a32b0c8SAndre Fischer {
85*7a32b0c8SAndre Fischer public:
86*7a32b0c8SAndre Fischer     static ::rtl::OUString SAL_CALL getImplementationName (void);
87*7a32b0c8SAndre Fischer     static cssu::Reference<cssu::XInterface> SAL_CALL createInstance (
88*7a32b0c8SAndre Fischer         const cssu::Reference<css::lang::XMultiServiceFactory>& rxFactory);
89*7a32b0c8SAndre Fischer     static cssu::Sequence<rtl::OUString> SAL_CALL getSupportedServiceNames (void);
90*7a32b0c8SAndre Fischer 
91*7a32b0c8SAndre Fischer     SidebarFactory (const cssu::Reference<cssu::XComponentContext>& rxContext);
92*7a32b0c8SAndre Fischer     virtual ~SidebarFactory (void);
93*7a32b0c8SAndre Fischer 
94*7a32b0c8SAndre Fischer     virtual void SAL_CALL disposing (void);
95*7a32b0c8SAndre Fischer 
96*7a32b0c8SAndre Fischer 
97*7a32b0c8SAndre Fischer     // XInitialization
98*7a32b0c8SAndre Fischer 
99*7a32b0c8SAndre Fischer     virtual void SAL_CALL initialize(
100*7a32b0c8SAndre Fischer         const css::uno::Sequence<css::uno::Any>& aArguments)
101*7a32b0c8SAndre Fischer         throw (css::uno::Exception, css::uno::RuntimeException);
102*7a32b0c8SAndre Fischer 
103*7a32b0c8SAndre Fischer 
104*7a32b0c8SAndre Fischer     // XUIElementFactory
105*7a32b0c8SAndre Fischer 
106*7a32b0c8SAndre Fischer     cssu::Reference<css::ui::XUIElement> SAL_CALL createUIElement (
107*7a32b0c8SAndre Fischer         const ::rtl::OUString& rsResourceURL,
108*7a32b0c8SAndre Fischer         const ::cssu::Sequence<css::beans::PropertyValue>& rArguments)
109*7a32b0c8SAndre Fischer         throw(
110*7a32b0c8SAndre Fischer             css::container::NoSuchElementException,
111*7a32b0c8SAndre Fischer             css::lang::IllegalArgumentException,
112*7a32b0c8SAndre Fischer             cssu::RuntimeException);
113*7a32b0c8SAndre Fischer 
114*7a32b0c8SAndre Fischer 
115*7a32b0c8SAndre Fischer     // XResourceFactory
116*7a32b0c8SAndre Fischer 
117*7a32b0c8SAndre Fischer     virtual css::uno::Reference<cssdf::XResource>
118*7a32b0c8SAndre Fischer         SAL_CALL createResource (
119*7a32b0c8SAndre Fischer             const css::uno::Reference<cssdf::XResourceId>& rxPaneId)
120*7a32b0c8SAndre Fischer         throw (css::uno::RuntimeException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException);
121*7a32b0c8SAndre Fischer     virtual void SAL_CALL
122*7a32b0c8SAndre Fischer         releaseResource (
123*7a32b0c8SAndre Fischer             const css::uno::Reference<cssdf::XResource>& rxPane)
124*7a32b0c8SAndre Fischer         throw (css::uno::RuntimeException);
125*7a32b0c8SAndre Fischer 
126*7a32b0c8SAndre Fischer 
127*7a32b0c8SAndre Fischer     // XEventListener
128*7a32b0c8SAndre Fischer 
129*7a32b0c8SAndre Fischer     virtual void SAL_CALL disposing (const ::css::lang::EventObject& rEvent)
130*7a32b0c8SAndre Fischer         throw(cssu::RuntimeException);
131*7a32b0c8SAndre Fischer 
132*7a32b0c8SAndre Fischer private:
133*7a32b0c8SAndre Fischer     /** Due to the fact that this class is a factory for both
134*7a32b0c8SAndre Fischer         XUIElement and XResource objects, there are different
135*7a32b0c8SAndre Fischer         instantiations for the same XController although only one
136*7a32b0c8SAndre Fischer         would be really necessary.  This map makes sure that the
137*7a32b0c8SAndre Fischer         different object have access to the same information.
138*7a32b0c8SAndre Fischer     */
139*7a32b0c8SAndre Fischer     class Implementation;
140*7a32b0c8SAndre Fischer     typedef ::boost::shared_ptr<Implementation> SharedImplementation;
141*7a32b0c8SAndre Fischer     typedef ::std::map<cssu::Reference<css::frame::XController>,SharedImplementation>
142*7a32b0c8SAndre Fischer         ControllerToImplementationMap;
143*7a32b0c8SAndre Fischer     static ControllerToImplementationMap maControllerToImplementationMap;
144*7a32b0c8SAndre Fischer     SharedImplementation mpImplementation;
145*7a32b0c8SAndre Fischer 
146*7a32b0c8SAndre Fischer     static SharedImplementation GetImplementationForController (
147*7a32b0c8SAndre Fischer         const cssu::Reference<css::frame::XController>& rxController);
148*7a32b0c8SAndre Fischer };
149*7a32b0c8SAndre Fischer 
150*7a32b0c8SAndre Fischer 
151*7a32b0c8SAndre Fischer } } // end of namespace sd::sidebar
152*7a32b0c8SAndre Fischer 
153*7a32b0c8SAndre Fischer #endif
154