xref: /aoo42x/main/sd/source/ui/inc/SlideSorter.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SD_SLIDESORTER_SLIDE_SORTER_HXX
29 #define SD_SLIDESORTER_SLIDE_SORTER_HXX
30 
31 #include "fupoor.hxx"
32 #include "Window.hxx"
33 #include <com/sun/star/frame/XController.hpp>
34 #include <cppuhelper/weakref.hxx>
35 #include <sfx2/viewfrm.hxx>
36 #include <boost/noncopyable.hpp>
37 #include <boost/shared_ptr.hpp>
38 #include <boost/scoped_ptr.hpp>
39 #include <boost/current_function.hpp>
40 
41 
42 class ScrollBar;
43 class ScrollBarBox;
44 class Window;
45 
46 
47 namespace sd {
48 class ViewShell;
49 class ViewShellBase;
50 class Window;
51 }
52 
53 namespace sd { namespace slidesorter { namespace model {
54 class SlideSorterModel;
55 } } }
56 
57 namespace sd { namespace slidesorter { namespace view {
58 class SlideSorterView;
59 class Theme;
60 } } }
61 
62 namespace sd { namespace slidesorter { namespace controller {
63 class Listener;
64 class SlideSorterController;
65 class SlotManager;
66 class Properties;
67 } } }
68 
69 
70 typedef ::boost::shared_ptr<sd::Window> SharedSdWindow;
71 
72 
73 namespace sd { namespace slidesorter {
74 
75 /** Show previews for all the slides in a document and allow the user to
76     insert or delete slides and modify the order of the slides.
77 
78     This class is a facade for the model, view, and controller classes.
79     It is a hub that allows access to the various parts of a slide sorter.
80 
81     Note that this class is not in its final state.
82 */
83 class SlideSorter
84     : private ::boost::noncopyable
85 {
86     friend class controller::SlotManager;
87 public:
88     virtual ~SlideSorter (void);
89 
90     /** Return whether the called SlideSorter object is valid and calling
91         its Get(Model,View,Controller) methods is safe.  When <FALSE/> is
92         called then no other methods should be called.
93         Calling this method should be necessary only during startup and
94         shutdown (when that can be detected).
95     */
96     bool IsValid (void) const;
97 
98     /** Create a new slide sorter that is strongly coupled to the given view
99         shell.  Use this function for a slide sorter in the left pane.
100         @param rViewShell
101             Typically a SlideSorterViewShell object.
102         @param rpContentWindow
103             Typically the content window of the ViewShell.
104         @param rpHorizontalScrollBar
105             Typically the horizontal scroll bar of the ViewShell.
106         @param rpVerticalScrollBar
107             Typically the vertical scroll bar of the ViewShell.
108         @param rpScrollBarBox
109             The little square enclosed by the two scroll bars.  Typically
110             the one from the ViewShell.
111     */
112     static ::boost::shared_ptr<SlideSorter> CreateSlideSorter (
113         ViewShell& rViewShell,
114         const ::boost::shared_ptr<sd::Window>& rpContentWindow,
115         const ::boost::shared_ptr<ScrollBar>& rpHorizontalScrollBar,
116         const ::boost::shared_ptr<ScrollBar>& rpVerticalScrollBar,
117         const ::boost::shared_ptr<ScrollBarBox>& rpScrollBarBox);
118 
119     /** Create a new slide sorter that is losely coupled to the given view
120         shell.  The view shell may even be missing.
121         @param rBase
122             ViewShellBase object of the enclosing application.
123         @param pViewShell
124             Supply when at hand.
125         @param rParentWindow
126             The parent window of the internally created content window and
127             scroll bars.
128     */
129     static ::boost::shared_ptr<SlideSorter> CreateSlideSorter (
130         ViewShellBase& rBase,
131         ViewShell* pViewShell,
132         ::Window& rParentWindow);
133 
134     /** Return the control of the vertical scroll bar.
135     */
136     ::boost::shared_ptr<ScrollBar> GetVerticalScrollBar (void) const;
137 
138     /** Return the control of the horizontal scroll bar.
139     */
140     ::boost::shared_ptr<ScrollBar> GetHorizontalScrollBar (void) const;
141 
142     /** Return the scroll bar filler that paints the little square that is
143         enclosed by the two scroll bars.
144     */
145     ::boost::shared_ptr<ScrollBarBox> GetScrollBarFiller (void) const;
146 
147     /** Return the content window.  This is a sibling and is geometrically
148         enclosed by the scroll bars.
149     */
150     SharedSdWindow GetContentWindow (void) const;
151 
152     model::SlideSorterModel& GetModel (void) const;
153 
154     view::SlideSorterView& GetView (void) const;
155 
156     controller::SlideSorterController& GetController (void) const;
157 
158     /** Return the view shell that was given at construction.
159         @return
160             May be empty.
161     */
162     ViewShell* GetViewShell (void) const;
163 
164     /** Return the XController object of the main view.
165     */
166     ::com::sun::star::uno::Reference<com::sun::star::frame::XController>
167         GetXController (void) const;
168 
169     /** Return the ViewShellBase object.
170         @return
171             May be empty.
172     */
173     ViewShellBase* GetViewShellBase (void) const;
174 
175     void Paint (const Rectangle& rRepaintArea);
176 
177     /** Place and size the controls and windows.  You may want to call this
178         method when something has changed that for instance affects the
179         visibility state of the scroll bars.
180     */
181     void ArrangeGUIElements (
182         const Point& rOffset,
183         const Size& rSize);
184     SvBorder GetBorder (void);
185 
186     bool RelocateToWindow (::Window* pWindow);
187 
188     /** Set the current function at the view shell or, when it is not
189         present, set it at the content window.  This method supports the use
190         of functions even when there is no SlideSorterViewShell.
191     */
192     void SetCurrentFunction (const FunctionReference& rpFunction);
193 
194     /** Return a collection of properties that are used througout the slide
195         sorter.
196     */
197     ::boost::shared_ptr<controller::Properties> GetProperties (void) const;
198 
199     /** Return the active theme wich gives access to colors and fonts.
200     */
201     ::boost::shared_ptr<view::Theme> GetTheme (void) const;
202 
203 protected:
204     /** This virtual method makes it possible to create a specialization of
205         the slide sorter view shell that works with its own implementation
206         of model, view, and controller.  The default implementation simply
207         calls the CreateModel(), CreateView(), and CreateController()
208         methods in this order.
209     */
210     virtual void CreateModelViewController (void);
211 
212     /** Create the model for the view shell.  When called from the default
213         implementation of CreateModelViewController() then neither view nor
214         controller do exist.  Test their pointers when in doubt.
215     */
216     virtual model::SlideSorterModel* CreateModel (void);
217 
218     /** Create the view for the view shell.  When called from the default
219         implementation of CreateModelViewController() then the model but not
220         the controller does exist.  Test their pointers when in doubt.
221     */
222     virtual view::SlideSorterView* CreateView (void);
223 
224     /** Create the controller for the view shell.  When called from the default
225         implementation of CreateModelViewController() then both the view and
226         the controller do exist.  Test their pointers when in doubt.
227     */
228     virtual controller::SlideSorterController* CreateController (void);
229 
230 private:
231     bool mbIsValid;
232 
233     ::boost::scoped_ptr<controller::SlideSorterController> mpSlideSorterController;
234     ::boost::scoped_ptr<model::SlideSorterModel> mpSlideSorterModel;
235     ::boost::scoped_ptr<view::SlideSorterView> mpSlideSorterView;
236     ::com::sun::star::uno::WeakReference<com::sun::star::frame::XController> mxControllerWeak;
237     ViewShell* mpViewShell;
238     ViewShellBase* mpViewShellBase;
239     SharedSdWindow mpContentWindow;
240     bool mbOwnesContentWindow;
241     ::boost::shared_ptr<ScrollBar> mpHorizontalScrollBar;
242     ::boost::shared_ptr<ScrollBar> mpVerticalScrollBar;
243     ::boost::shared_ptr<ScrollBarBox> mpScrollBarBox;
244 
245     /** Set this flag to <TRUE/> to force a layout before the next paint.
246     */
247     bool mbLayoutPending;
248 
249     /** Some slide sorter wide properties that are used in different
250         classes.
251     */
252     ::boost::shared_ptr<controller::Properties> mpProperties;
253     ::boost::shared_ptr<view::Theme> mpTheme;
254 
255     SlideSorter (
256         ViewShell& rViewShell,
257         const ::boost::shared_ptr<sd::Window>& rpContentWindow,
258         const ::boost::shared_ptr<ScrollBar>& rpHorizontalScrollBar,
259         const ::boost::shared_ptr<ScrollBar>& rpVerticalScrollBar,
260         const ::boost::shared_ptr<ScrollBarBox>& rpScrollBarBox);
261     SlideSorter (
262         ViewShellBase& rBase,
263         ViewShell* pViewShell,
264         ::Window& rParentWindow);
265 
266     void Init (void);
267     /** Create the controls for the slide sorter.  This are the tab bar
268        for switching the edit mode, the scroll bar, and the actual
269        slide sorter view window.
270        This method is usually called exactly one time from the
271        constructor.
272     */
273     void SetupControls (::Window* pParentWindow);
274 
275     /** This method is usually called exactly one time from the
276         constructor.
277     */
278     void SetupListeners (void);
279 
280     /** Release the listeners that have been installed in SetupListeners().
281     */
282     void ReleaseListeners (void);
283 };
284 
285 } } // end of namespace ::sd::slidesorter
286 
287 #endif
288