merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / inc / SlideSorter.hxx
blobf54942db428bd3ad4dac4cd300d5b584aab052a3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SlideSorter.hxx,v $
11 * $Revision: 1.3 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #ifndef SD_SLIDESORTER_SLIDE_SORTER_HXX
33 #define SD_SLIDESORTER_SLIDE_SORTER_HXX
35 #include "fupoor.hxx"
36 #include <com/sun/star/frame/XController.hpp>
37 #include <cppuhelper/weakref.hxx>
38 #include <sfx2/viewfrm.hxx>
39 #include <boost/noncopyable.hpp>
40 #include <boost/shared_ptr.hpp>
41 #include <boost/scoped_ptr.hpp>
43 class ScrollBar;
44 class ScrollBarBox;
45 class Window;
48 namespace sd {
49 class ViewShell;
50 class ViewShellBase;
51 class Window;
54 namespace sd { namespace slidesorter { namespace model {
55 class SlideSorterModel;
56 } } }
58 namespace sd { namespace slidesorter { namespace view {
59 class SlideSorterView;
60 } } }
62 namespace sd { namespace slidesorter { namespace controller {
63 class Listener;
64 class SlideSorterController;
65 class SlotManager;
66 } } }
69 namespace sd { namespace slidesorter {
72 /** Show previews for all the slides in a document and allow the user to
73 insert or delete slides and modify the order of the slides.
75 This class is a facade for the model, view, and controller classes.
76 It is a hub that allows access to the various parts of a slide sorter.
78 Note that this class is not in its final state.
80 class SlideSorter
81 : private ::boost::noncopyable
83 friend class controller::SlotManager;
84 public:
85 virtual ~SlideSorter (void);
87 /** Return whether the called SlideSorter object is valid and calling
88 its Get(Model,View,Controller) methods is safe. When <FALSE/> is
89 called then no other methods should be called.
90 Calling this method should be necessary only during startup and
91 shutdown (when that can be detected).
93 bool IsValid (void) const;
95 /** Create a new slide sorter that is strongly coupled to the given view
96 shell. Use this function for a slide sorter in the left pane.
97 @param rViewShell
98 Typically a SlideSorterViewShell object.
99 @param rpContentWindow
100 Typically the content window of the ViewShell.
101 @param rpHorizontalScrollBar
102 Typically the horizontal scroll bar of the ViewShell.
103 @param rpVerticalScrollBar
104 Typically the vertical scroll bar of the ViewShell.
105 @param rpScrollBarBox
106 The little square enclosed by the two scroll bars. Typically
107 the one from the ViewShell.
109 static ::boost::shared_ptr<SlideSorter> CreateSlideSorter (
110 ViewShell& rViewShell,
111 const ::boost::shared_ptr<sd::Window>& rpContentWindow,
112 const ::boost::shared_ptr<ScrollBar>& rpHorizontalScrollBar,
113 const ::boost::shared_ptr<ScrollBar>& rpVerticalScrollBar,
114 const ::boost::shared_ptr<ScrollBarBox>& rpScrollBarBox);
116 /** Create a new slide sorter that is losely coupled to the given view
117 shell. The view shell may even be missing.
118 @param rBase
119 ViewShellBase object of the enclosing application.
120 @param pViewShell
121 Supply when at hand.
122 @param rParentWindow
123 The parent window of the internally created content window and
124 scroll bars.
126 static ::boost::shared_ptr<SlideSorter> CreateSlideSorter (
127 ViewShellBase& rBase,
128 ViewShell* pViewShell,
129 ::Window& rParentWindow);
131 /** Return the control of the vertical scroll bar.
133 ::boost::shared_ptr<ScrollBar> GetVerticalScrollBar (void) const;
135 /** Return the control of the horizontal scroll bar.
137 ::boost::shared_ptr<ScrollBar> GetHorizontalScrollBar (void) const;
139 /** Return the scroll bar filler that paints the little square that is
140 enclosed by the two scroll bars.
142 ::boost::shared_ptr<ScrollBarBox> GetScrollBarFiller (void) const;
144 /** Return the content window. This is a sibling and is geometrically
145 enclosed by the scroll bars.
147 ::boost::shared_ptr<sd::Window> GetContentWindow (void) const;
149 /** Return the active window as it is returned by a view shell.
150 Typically the content window.
152 ::sd::Window* GetActiveWindow (void) const;
154 model::SlideSorterModel& GetModel (void) const;
156 view::SlideSorterView& GetView (void) const;
158 controller::SlideSorterController& GetController (void) const;
160 /** Return the view shell that was given at construction.
161 @return
162 May be empty.
164 ViewShell* GetViewShell (void) const;
166 /** Return the XController object of the main view.
168 ::com::sun::star::uno::Reference<com::sun::star::frame::XController>
169 GetXController (void) const;
171 /** Return the ViewShellBase object.
172 @return
173 May be empty.
175 ViewShellBase* GetViewShellBase (void) const;
177 void Paint (const Rectangle& rRepaintArea);
179 /** Place and size the controls and windows. You may want to call this
180 method when something has changed that for instance affects the
181 visibility state of the scroll bars.
183 void ArrangeGUIElements (
184 const Point& rOffset,
185 const Size& rSize);
186 SvBorder GetBorder (void);
188 bool RelocateToWindow (::Window* pWindow);
190 /** Set the current function at the view shell or, when it is not
191 present, set it at the content window. This method supports the use
192 of functions even when there is no SlideSorterViewShell.
194 void SetCurrentFunction (const FunctionReference& rpFunction);
196 protected:
197 /** This virtual method makes it possible to create a specialization of
198 the slide sorter view shell that works with its own implementation
199 of model, view, and controller. The default implementation simply
200 calls the CreateModel(), CreateView(), and CreateController()
201 methods in this order.
203 virtual void CreateModelViewController (void);
205 /** Create the model for the view shell. When called from the default
206 implementation of CreateModelViewController() then neither view nor
207 controller do exist. Test their pointers when in doubt.
209 virtual model::SlideSorterModel* CreateModel (void);
211 /** Create the view for the view shell. When called from the default
212 implementation of CreateModelViewController() then the model but not
213 the controller does exist. Test their pointers when in doubt.
215 virtual view::SlideSorterView* CreateView (void);
217 /** Create the controller for the view shell. When called from the default
218 implementation of CreateModelViewController() then both the view and
219 the controller do exist. Test their pointers when in doubt.
221 virtual controller::SlideSorterController* CreateController (void);
223 private:
224 bool mbIsValid;
226 ::boost::scoped_ptr<controller::SlideSorterController> mpSlideSorterController;
227 ::boost::scoped_ptr<model::SlideSorterModel> mpSlideSorterModel;
228 ::boost::scoped_ptr<view::SlideSorterView> mpSlideSorterView;
229 ::com::sun::star::uno::WeakReference<com::sun::star::frame::XController> mxControllerWeak;
230 ViewShell* mpViewShell;
231 ViewShellBase* mpViewShellBase;
232 ::boost::shared_ptr<sd::Window> mpContentWindow;
233 ::boost::shared_ptr<ScrollBar> mpHorizontalScrollBar;
234 ::boost::shared_ptr<ScrollBar> mpVerticalScrollBar;
235 ::boost::shared_ptr<ScrollBarBox> mpScrollBarBox;
237 /** Set this flag to <TRUE/> to force a layout before the next paint.
239 bool mbLayoutPending;
242 SlideSorter (
243 ViewShell& rViewShell,
244 const ::boost::shared_ptr<sd::Window>& rpContentWindow,
245 const ::boost::shared_ptr<ScrollBar>& rpHorizontalScrollBar,
246 const ::boost::shared_ptr<ScrollBar>& rpVerticalScrollBar,
247 const ::boost::shared_ptr<ScrollBarBox>& rpScrollBarBox);
248 SlideSorter (
249 ViewShellBase& rBase,
250 ViewShell* pViewShell,
251 ::Window& rParentWindow);
253 void Init (void);
254 /** Create the controls for the slide sorter. This are the tab bar
255 for switching the edit mode, the scroll bar, and the actual
256 slide sorter view window.
257 This method is usually called exactly one time from the
258 constructor.
260 void SetupControls (::Window* pParentWindow);
262 /** This method is usually called exactly one time from the
263 constructor.
265 void SetupListeners (void);
267 /** Release the listeners that have been installed in SetupListeners().
269 void ReleaseListeners (void);
272 } } // end of namespace ::sd::slidesorter
274 #endif