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         throw(css::uno::RuntimeException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException);
96 
97     virtual void SAL_CALL releaseResource (
98         const css::uno::Reference<css::drawing::framework::XResource>& xView)
99         throw(css::uno::RuntimeException);
100 
101 
102     // XInitialization
103 
104     virtual void SAL_CALL initialize(
105         const css::uno::Sequence<css::uno::Any>& aArguments)
106         throw (css::uno::Exception, css::uno::RuntimeException);
107 
108 private:
109     css::uno::Reference<css::drawing::framework::XConfigurationController>
110         mxConfigurationController;
111     class ViewDescriptor;
112     class ViewShellContainer;
113     ::boost::scoped_ptr<ViewShellContainer> mpViewShellContainer;
114     ViewShellBase* mpBase;
115     FrameView* mpFrameView;
116 
117     class ViewCache;
118     ::boost::shared_ptr<Window> mpWindow;
119     ::boost::shared_ptr<ViewCache> mpViewCache;
120 
121     css::uno::Reference<css::drawing::framework::XPane> mxLocalPane;
122 
123     ::boost::shared_ptr<ViewDescriptor> CreateView (
124         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
125         SfxViewFrame& rFrame,
126         ::Window& rWindow,
127         const css::uno::Reference<css::drawing::framework::XPane>& rxPane,
128         FrameView* pFrameView,
129         const bool bIsCenterView);
130 
131     ::boost::shared_ptr<ViewShell> CreateViewShell (
132         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
133         SfxViewFrame& rFrame,
134         ::Window& rWindow,
135         FrameView* pFrameView,
136         const bool bIsCenterView);
137 
138     void ActivateCenterView (
139         const ::boost::shared_ptr<ViewDescriptor>& rpDescriptor);
140 
141     void ReleaseView (
142         const ::boost::shared_ptr<ViewDescriptor>& rpDescriptor,
143         bool bDoNotCache = false);
144 
145     bool IsCacheable (
146         const ::boost::shared_ptr<ViewDescriptor>& rpDescriptor);
147 
148     ::boost::shared_ptr<ViewDescriptor> GetViewFromCache (
149         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
150         const css::uno::Reference<css::drawing::framework::XPane>& rxPane);
151 };
152 
153 } } // end of namespace sd::framework
154 
155 #endif
156