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_VIEW_SHELL_HXX
29 #define SD_SLIDESORTER_SLIDE_SORTER_VIEW_SHELL_HXX
30 
31 #include "ViewShell.hxx"
32 #include "glob.hxx"
33 #include <sfx2/shell.hxx>
34 #include <sfx2/viewfac.hxx>
35 #include <boost/shared_ptr.hpp>
36 #include <vector>
37 
38 namespace sd { namespace slidesorter { namespace controller {
39 class SlotManager;
40 } } }
41 
42 
43 namespace sd { namespace slidesorter {
44 
45 class SlideSorter;
46 
47 class SlideSorterViewShell
48     : public ViewShell
49 {
50     friend class controller::SlotManager;
51 
52 public:
53     TYPEINFO();
54     SFX_DECL_INTERFACE(SD_IF_SDSLIDESORTERVIEWSHELL)
55 
56     static ::boost::shared_ptr<SlideSorterViewShell> Create(
57         SfxViewFrame* pFrame,
58         ViewShellBase& rViewShellBase,
59         ::Window* pParentWindow,
60         FrameView* pFrameView,
61         const bool bIsCenterPane);
62 
63     virtual ~SlideSorterViewShell (void);
64 
65     /** Late initialization that has to be called after a new instance has
66         completed its construction.
67     */
68     virtual void Init (bool bIsMainViewShell);
69 
70     /** Return a slide sorter that is currently displayed in one of the
71         panes that belong to the given ViewShellBase object.
72         When there is only one slide sorter visible then that one is
73         returned.  When two (or more) are visible then the one in the center
74         pane is returned.  When no slidesorter is visible then NULL is
75         returned.
76     */
77     static SlideSorterViewShell* GetSlideSorter (ViewShellBase& rBase);
78 
79     virtual void GetFocus (void);
80     virtual void LoseFocus (void);
81     virtual SdPage*	GetActualPage (void);
82 
83 	/// inherited from sd::ViewShell
84 	virtual SdPage* getCurrentPage() const;
85 
86 	void ExecCtrl (SfxRequest& rRequest);
87 	virtual void GetCtrlState (SfxItemSet &rSet);
88 	virtual void FuSupport (SfxRequest& rRequest);
89 	virtual void FuTemporary (SfxRequest& rRequest);
90 	virtual void GetStatusBarState (SfxItemSet& rSet);
91 	virtual void FuPermanent (SfxRequest& rRequest);
92 	void GetAttrState (SfxItemSet& rSet);
93 	void ExecStatusBar (SfxRequest& rRequest);
94     virtual void Command (const CommandEvent& rEvent, ::sd::Window* pWindow);
95 	virtual void GetMenuState (SfxItemSet &rSet);
96 	virtual void GetClipboardState (SfxItemSet &rSet);
97 
98 	virtual void ReadFrameViewData (FrameView* pView);
99 	virtual void WriteFrameViewData (void);
100 
101     /** Set the zoom factor.  The given value is clipped against an upper
102         bound.
103         @param nZoom
104             An integer percent value, i.e. nZoom/100 is the actual zoom
105             factor.
106         */
107 	virtual void SetZoom (long int nZoom);
108 	virtual void SetZoomRect (const Rectangle& rZoomRect);
109 
110     /** This is a callback method used by the active window to delegate its
111         Paint() call to.  This view shell itself delegates it to the view.
112     */
113 	virtual void Paint(const Rectangle& rRect, ::sd::Window* pWin);
114 
115     /** Place and size the controls and windows.  You may want to call this
116         method when something has changed that for instance affects the
117         visibility state of the scroll bars.
118     */
119     virtual void ArrangeGUIElements (void);
120 
121 	virtual void Activate (sal_Bool IsMDIActivate);
122 
123     //===== Drag and Drop =====================================================
124 
125     virtual void StartDrag (
126         const Point& rDragPt,
127         ::Window* pWindow );
128 	virtual void DragFinished (
129         sal_Int8 nDropAction);
130     virtual sal_Int8 AcceptDrop (
131         const AcceptDropEvent& rEvt,
132         DropTargetHelper& rTargetHelper,
133         ::sd::Window* pTargetWindow = NULL,
134         sal_uInt16 nPage = SDRPAGE_NOTFOUND,
135         sal_uInt16 nLayer = SDRPAGE_NOTFOUND );
136 	virtual sal_Int8 ExecuteDrop (
137         const ExecuteDropEvent& rEvt,
138         DropTargetHelper& rTargetHelper,
139         ::sd::Window* pTargetWindow = NULL,
140         sal_uInt16 nPage = SDRPAGE_NOTFOUND,
141         sal_uInt16 nLayer = SDRPAGE_NOTFOUND);
142 
143     typedef ::std::vector<SdPage*> PageSelection;
144 
145     /** Return the set of selected pages.
146     */
147     ::boost::shared_ptr<PageSelection> GetPageSelection (void) const;
148 
149     void SetPageSelection (const ::boost::shared_ptr<PageSelection>& rSelection);
150 
151     /** Add a listener that is called when the selection of the slide sorter
152         changes.
153         @param rListener
154             When this method is called multiple times for the same listener
155             the second and all following calls are ignored.  Each listener
156             is added only once.
157     */
158     void AddSelectionChangeListener (const Link& rListener);
159 
160     /** Remove a listener that was called when the selection of the slide
161         sorter changes.
162         @param rListener
163             It is save to pass a listener that was not added are has been
164             removed previously.  Such calls are ignored.
165     */
166     void RemoveSelectionChangeListener (const Link& rListener);
167 
168     virtual css::uno::Reference<css::drawing::XDrawSubController> CreateSubController (void);
169 
170     /** Create an accessible object representing the specified window.
171 	    @param pWindow
172 	        The returned object makes the document displayed in this window
173 	        accessible.
174         @return
175 	        Returns an <type>AccessibleSlideSorterView</type> object.
176    */
177     virtual ::com::sun::star::uno::Reference<
178         ::com::sun::star::accessibility::XAccessible>
179         CreateAccessibleDocumentView (::sd::Window* pWindow);
180 
181     SlideSorter& GetSlideSorter (void) const;
182 
183     /** Try to relocate all toplevel window elements to the given parent
184         window.
185     */
186     virtual bool RelocateToParentWindow (::Window* pParentWindow);
187 
188 protected:
189 
190     virtual SvBorder GetBorder (bool bOuterResize);
191 
192     /** This method is overloaded to handle a missing tool bar correctly.
193         This is the case when the slide sorter is not the main view shell.
194     */
195     virtual ::svl::IUndoManager* ImpGetUndoManager (void) const;
196 
197 private:
198     ::boost::shared_ptr<SlideSorter> mpSlideSorter;
199     bool mbIsArrangeGUIElementsPending;
200 
201     SlideSorterViewShell (
202         SfxViewFrame* pFrame,
203         ViewShellBase& rViewShellBase,
204         ::Window* pParentWindow,
205         FrameView* pFrameView);
206     void Initialize (void);
207 
208     /** This method overwrites the one from our base class:  We do our own
209         scroll bar and the base class call is thus unnecessary.  It simply
210         calls UpdateScrollBars(false).
211     */
212     virtual void UpdateScrollBars (void);
213 };
214 
215 typedef ::boost::shared_ptr<SlideSorterViewShell::PageSelection> SharedPageSelection;
216 
217 } } // end of namespace ::sd::slidesorter
218 
219 #endif
220