xref: /trunk/main/sd/source/ui/framework/factories/BasicViewFactory.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 
23 
24 #ifndef SD_FRAMEWORK_BASIC_VIEW_FACTORY_HXX
25 #define SD_FRAMEWORK_BASIC_VIEW_FACTORY_HXX
26 
27 #include "MutexOwner.hxx"
28 
29 #include <com/sun/star/drawing/framework/XResourceFactory.hpp>
30 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
31 #include <com/sun/star/drawing/framework/XPane.hpp>
32 #include <com/sun/star/frame/XController.hpp>
33 #include <com/sun/star/lang/XInitialization.hpp>
34 #include <com/sun/star/uno/XComponentContext.hpp>
35 
36 #include <cppuhelper/compbase2.hxx>
37 #include <osl/mutex.hxx>
38 
39 #include <boost/shared_ptr.hpp>
40 #include <boost/scoped_ptr.hpp>
41 
42 namespace css = ::com::sun::star;
43 
44 namespace sd {
45 class ViewShell;
46 class ViewShellBase;
47 class FrameView;
48 }
49 class SfxViewFrame;
50 class Window;
51 
52 namespace {
53 
54 typedef ::cppu::WeakComponentImplHelper2 <
55     css::drawing::framework::XResourceFactory,
56     css::lang::XInitialization
57     > BasicViewFactoryInterfaceBase;
58 
59 } // end of anonymous namespace.
60 
61 
62 
63 
64 namespace sd { namespace framework {
65 
66 /** Factory for the frequently used standard views of the drawing framework:
67         private:resource/view/
68         private:resource/view/ImpressView
69         private:resource/view/GraphicView
70         private:resource/view/OutlineView
71         private:resource/view/NotesView
72         private:resource/view/HandoutView
73         private:resource/view/SlideSorter
74         private:resource/view/PresentationView
75         private:resource/view/TaskPane
76     For some views in some panes this class also acts as a cache.
77 */
78 class BasicViewFactory
79     : private sd::MutexOwner,
80       public BasicViewFactoryInterfaceBase
81 {
82 public:
83     BasicViewFactory (
84         const css::uno::Reference<css::uno::XComponentContext>& rxContext);
85     virtual ~BasicViewFactory (void);
86 
87     virtual void SAL_CALL disposing (void);
88 
89 
90     // XViewFactory
91 
92     virtual css::uno::Reference<css::drawing::framework::XResource>
93         SAL_CALL createResource (
94             const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId);
95 
96     virtual void SAL_CALL releaseResource (
97         const css::uno::Reference<css::drawing::framework::XResource>& xView);
98 
99 
100     // XInitialization
101 
102     virtual void SAL_CALL initialize(
103         const css::uno::Sequence<css::uno::Any>& aArguments);
104 
105 private:
106     css::uno::Reference<css::drawing::framework::XConfigurationController>
107         mxConfigurationController;
108     class ViewDescriptor;
109     class ViewShellContainer;
110     ::boost::scoped_ptr<ViewShellContainer> mpViewShellContainer;
111     ViewShellBase* mpBase;
112     FrameView* mpFrameView;
113 
114     class ViewCache;
115     ::boost::shared_ptr<Window> mpWindow;
116     ::boost::shared_ptr<ViewCache> mpViewCache;
117 
118     css::uno::Reference<css::drawing::framework::XPane> mxLocalPane;
119 
120     ::boost::shared_ptr<ViewDescriptor> CreateView (
121         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
122         SfxViewFrame& rFrame,
123         ::Window& rWindow,
124         const css::uno::Reference<css::drawing::framework::XPane>& rxPane,
125         FrameView* pFrameView,
126         const bool bIsCenterView);
127 
128     ::boost::shared_ptr<ViewShell> CreateViewShell (
129         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
130         SfxViewFrame& rFrame,
131         ::Window& rWindow,
132         FrameView* pFrameView,
133         const bool bIsCenterView);
134 
135     void ActivateCenterView (
136         const ::boost::shared_ptr<ViewDescriptor>& rpDescriptor);
137 
138     void ReleaseView (
139         const ::boost::shared_ptr<ViewDescriptor>& rpDescriptor,
140         bool bDoNotCache = false);
141 
142     bool IsCacheable (
143         const ::boost::shared_ptr<ViewDescriptor>& rpDescriptor);
144 
145     ::boost::shared_ptr<ViewDescriptor> GetViewFromCache (
146         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
147         const css::uno::Reference<css::drawing::framework::XPane>& rxPane);
148 };
149 
150 } } // end of namespace sd::framework
151 
152 #endif
153