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