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