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