diff options
Diffstat (limited to 'sd/source/ui/slidesorter/inc/controller')
13 files changed, 2268 insertions, 0 deletions
diff --git a/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx b/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx new file mode 100644 index 000000000000..4c7c8ac8edf5 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx @@ -0,0 +1,340 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SD_SLIDESORTER_SLIDE_SORTER_CONTROLLER_HXX +#define SD_SLIDESORTER_SLIDE_SORTER_CONTROLLER_HXX + +#include "model/SlsSharedPageDescriptor.hxx" +#include "ViewShell.hxx" + +#include <com/sun/star/drawing/XDrawPages.hpp> + +#include <sfx2/shell.hxx> +#include <sfx2/viewfac.hxx> +#include <tools/link.hxx> +#include <tools/gen.hxx> +#include <memory> +#include <comphelper/implementationreference.hxx> + +namespace sd { namespace slidesorter { +class SlideSorter; +} } + +namespace sd { namespace slidesorter { namespace view { +class SlideSorterView; +class HighlightObject; +} } } + +namespace sd { namespace slidesorter { namespace model { +class SlideSorterModel; +} } } + +namespace css = ::com::sun::star; + +namespace sd { namespace slidesorter { namespace controller { + +class Animator; +class Clipboard; +class CurrentSlideManager; +class FocusManager; +class Listener; +class PageSelector; +class Properties; +class ScrollBarManager; +class SelectionManager; +class SlotManager; + +class SlideSorterController +{ +public: + /** Create a new controller for the slide sorter. + @param pParentWindow + The window that contains the controls of the new + controller. + */ + SlideSorterController (SlideSorter& rSlideSorter); + + /** Late initialization. Call this method once a new new object has been + created. + */ + virtual void Init (void); + + virtual ~SlideSorterController (void); + + /** Place and size the scroll bars and the browser window so that the + given rectangle is filled. + @return + The space occupied by the browser window is returned. + */ + Rectangle Resize (const Rectangle& rAvailableSpace); + + /** Determine which of the UI elements--the scroll bars, the scroll bar + filler, the actual slide sorter view--are visible and place them in + the area last passed to Resize(). + @param bForce + When <TRUE/> is given (<FALSE/> is the default) then the content + window and with it the SlideSorterView is resized event when its + size does not change (the size does change when the visibility + of scroll bars changes.) + @return + Returns the space occupied by the browser window. + */ + Rectangle Rearrange (bool bForce = false); + + /** Return the descriptor of the page that is rendered under the + given position. + @return + Returns a pointer to a page descriptor instead of a + reference because when no page is found at the position + then NULL is returned to indicate this. + */ + model::SharedPageDescriptor GetPageAt (const Point& rPixelPosition); + + PageSelector& GetPageSelector (void); + FocusManager& GetFocusManager (void); + controller::Clipboard& GetClipboard (void); + + /** Return the object that manages the scroll bars. + */ + ScrollBarManager& GetScrollBarManager (void); + + ::boost::shared_ptr<CurrentSlideManager> GetCurrentSlideManager (void) const; + ::boost::shared_ptr<SlotManager> GetSlotManager (void) const; + ::boost::shared_ptr<SelectionManager> GetSelectionManager (void) const; + + // forward VCLs PrePaint window event to DrawingLayer + void PrePaint(); + + /** This method forwards the call to the SlideSorterView and executes + pending operations like moving selected pages into the visible area. + */ + void Paint (const Rectangle& rRect, ::Window* pWin); + + void FuTemporary (SfxRequest& rRequest); + void FuPermanent (SfxRequest& rRequest); + void FuSupport (SfxRequest& rRequest); + bool Command ( + const CommandEvent& rEvent, + ::sd::Window* pWindow); + + void GetCtrlState (SfxItemSet &rSet); + void GetStatusBarState (SfxItemSet& rSet); + + void ExecCtrl (SfxRequest& rRequest); + void GetAttrState (SfxItemSet& rSet); + void ExecStatusBar (SfxRequest& rRequest); + + bool IsLocked (void) const; + + /** Create an object of this inner class to prevent updates due to model + changes. + */ + class ModelChangeLock + {public: + ModelChangeLock (SlideSorterController& rController); + ~ModelChangeLock (void); + void Release (void); + private: + SlideSorterController* mpController; + }; + friend class ModelChangeLock; + + + /** Handle a change of the model, that is, handle the removal and + insertion of whole pages or a change of the edit mode. + + This method is a convenience function that simply calls + PreModelChange() and then PostModelChange(). + */ + void HandleModelChange (void); + + DECL_LINK(WindowEventHandler, VclWindowEvent*); + + /** Update the display of all pages. This involves a redraw and + releasing previews and caches. + */ + void UpdateAllPages (void); + + /** This factory method creates a selection function. + */ + virtual FunctionReference CreateSelectionFunction (SfxRequest& rRequest); + + /** Prepare for a change of the edit mode. Depending on the current + edit mode we may save the selection so that it can be restored when + later changing back to the current edit mode. + */ + void PrepareEditModeChange (void); + + /** Set a new edit mode and return whether the edit mode really + has been changed. For proper saving and restoring of the selection + this method should be called between calls to + PrepareEditModeChange() and FinishEditModeChange(). + @return + A return value of <TRUE/> indicates that the edit mode has + changed. + */ + bool ChangeEditMode (EditMode eEditMode); + + /** Finish the change of the edit mode. Here we may select a page or + restore a previously saved selection. + */ + void FinishEditModeChange (void); + + /** Call this method when the name of one of the pages has changed. + This is then notified to the accessibility object, when that exists. + @param nPageIndex + The index of the page whose name has been changed. + @param rsOldName + The old name of the page. The new name can be taken from the + page object. + */ + void PageNameHasChanged (int nPageIndex, const String& rsOldName); + + /** Return whether a context menu has been opened by the called + SlideSorterController object and is still open. + */ + bool IsContextMenuOpen (void) const; + + /** Return a collection of properties that are used througout the slide + sorter. + */ + ::boost::shared_ptr<Properties> GetProperties (void) const; + + /** Provide the set of pages to be displayed in the slide sorter. The + GetDocumentSlides() method can be found only in the SlideSorterModel. + */ + void SetDocumentSlides (const css::uno::Reference<css::container::XIndexAccess>& rxSlides); + + /** Return an Animator object. + */ + ::boost::shared_ptr<Animator> GetAnimator (void) const; + +private: + SlideSorter& mrSlideSorter; + model::SlideSorterModel& mrModel; + view::SlideSorterView& mrView; + ::std::auto_ptr<PageSelector> mpPageSelector; + ::std::auto_ptr<FocusManager> mpFocusManager; + ::boost::shared_ptr<SlotManager> mpSlotManager; + ::std::auto_ptr<controller::Clipboard> mpClipboard; + ::std::auto_ptr<ScrollBarManager> mpScrollBarManager; + mutable ::boost::shared_ptr<CurrentSlideManager> mpCurrentSlideManager; + ::boost::shared_ptr<SelectionManager> mpSelectionManager; + ::boost::shared_ptr<Animator> mpAnimator; + + // The listener listens to UNO events and thus is a UNO object. + // For proper life time management and at the same time free access to + // the implementation object we use the ImplementationReference class. + ::rtl::Reference<controller::Listener> mpListener; + + int mnModelChangeLockCount; + + bool mbPreModelChangeDone; + bool mbPostModelChangePending; + + ::std::vector<Link> maSelectionChangeListeners; + + /** This array stores the indices of the selected page descriptors at + the time when the edit mode is switched to EM_MASTERPAGE. With this + we can restore the selection when switching back to EM_PAGE mode. + */ + ::std::vector<SdPage*> maSelectionBeforeSwitch; + /// The current page before the edit mode is switched to EM_MASTERPAGE. + int mnCurrentPageBeforeSwitch; + + /** The master page to select after the edit mode is changed. This + member is used to pass the pointer from PrepareEditModeChange() to + FinishEditModeChange(). + */ + SdPage* mpEditModeChangeMasterPage; + + /** This rectangle in the parent window encloses scroll bars and slide + sorter window. It is set when Resize() is called. + */ + Rectangle maTotalWindowArea; + + /** This counter is used to avoid processing of reentrant calls to + Paint(). + */ + sal_Int32 mnPaintEntranceCount; + + /** Remember whether the context menu is open. + */ + bool mbIsContextMenuOpen; + + /** Some slide sorter wide properties that are used in different + classes. + */ + ::boost::shared_ptr<Properties> mpProperties; + + /** Delete the given list of normal pages. This method is a helper + function for DeleteSelectedPages(). + @param rSelectedNormalPages + A list of normal pages. Supplying master pages is an error. + */ + void DeleteSelectedNormalPages (const ::std::vector<SdPage*>& rSelectedNormalPages); + + /** Delete the given list of master pages. This method is a helper + function for DeleteSelectedPages(). + @param rSelectedMasterPages + A list of master pages. Supplying normal pages is an error. + */ + void DeleteSelectedMasterPages (const ::std::vector<SdPage*>& rSelectedMasterPages); + + /** Prepare for several model changes, i.e. prevent time-consuming and + non-critical operations like repaints until UnlockModelChange() is + called. Ciritcal operations like releasing references to pages that + do not exist anymore are executed. + */ + void LockModelChange (void); + + /** Further calls to HandleModelChange() will result in a full featured + update of model, view, and controller. When HandleModelChange() has + been called since the last LockModelChange() then this is done right + away to bring the view up-to-date. + */ + void UnlockModelChange (void); + + /** Prepare for a model change. This method does all the things that + need to be done _before_ the model changes, e.g. because they need + access to the model data before the change. + */ + void PreModelChange (void); + + /** Complete a model change. This includes the recreation of data + structures that depend on the model and the request for a repaint to + show the changes. + */ + void PostModelChange (void); +}; + +} } } // end of namespace ::sd::slidesorter::controller + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/inc/controller/SlsAnimator.hxx b/sd/source/ui/slidesorter/inc/controller/SlsAnimator.hxx new file mode 100644 index 000000000000..75660b90f174 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsAnimator.hxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SD_SLIDESORTER_CONTROLLER_ANIMATOR_HXX +#define SD_SLIDESORTER_CONTROLLER_ANIMATOR_HXX + +#include "SlideSorter.hxx" +#include <vcl/timer.hxx> +#include <sal/types.h> +#include <vector> +#include <boost/function.hpp> +#include <boost/noncopyable.hpp> +#include <boost/scoped_ptr.hpp> +#include <boost/shared_ptr.hpp> + + +namespace sd { namespace slidesorter { namespace controller { + +/** Experimental class for simple eye candy animations. +*/ +class Animator + : private ::boost::noncopyable +{ +public: + Animator (SlideSorter& rSlideSorter); + ~Animator (void); + + /** An animation object is called with values between 0 and 1 as single + argument to its operator() method. + */ + typedef ::boost::function1<void, double> AnimationFunction; + + /** Schedule a new animation for execution. The () operator of that + animation will be called with increasing values between 0 and 1 for + the specified duration. + @param rAnimation + The animation operation. + @param nDuration + The duration in milli seconds. + */ + void AddAnimation ( + const AnimationFunction& rAnimation, + const sal_Int32 nDuration); + +private: + SlideSorter& mrSlideSorter; + Timer maTimer; + + class Animation; + typedef ::std::vector<boost::shared_ptr<Animation> > AnimationList; + AnimationList maAnimations; + + class DrawLock; + ::boost::scoped_ptr<DrawLock> mpDrawLock; + + DECL_LINK(TimeoutHandler, Timer*); + + /** Execute one step of every active animation. + @return + When one or more animation has finished then <TRUE/> is + returned. Call CleanUpAnimationList() in this case. + */ + bool ServeAnimations (void); + + /** Remove animations that have expired. + */ + void CleanUpAnimationList (void); +}; + +} } } // end of namespace ::sd::slidesorter::controller + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx b/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx new file mode 100644 index 000000000000..20d0e788f31e --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx @@ -0,0 +1,218 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SD_SLIDESORTER_CLIPBOARD +#define SD_SLIDESORTER_CLIPBOARD + +#include "ViewClipboard.hxx" + +#include <sal/types.h> +#include <tools/solar.h> +#include <svx/svdpage.hxx> + +#include <set> + +class SfxRequest; +class Window; + +struct AcceptDropEvent; +class DropTargetHelper; +struct ExecuteDropEvent; +class Point; +class SdPage; +class Window; + +namespace sd { +class Window; +} + +namespace sd { namespace slidesorter { +class SlideSorter; +} } + +namespace sd { namespace slidesorter { namespace model { +class PageDescriptor; +} } } + +namespace sd { namespace slidesorter { namespace controller { + +class SlideSorterController; + +class Clipboard + : public ViewClipboard +{ +public: + Clipboard (SlideSorter& rSlideSorter); + ~Clipboard (void); + + void HandleSlotCall (SfxRequest& rRequest); + + void DoCut (::Window* pWindow = 0); + void DoCopy (::Window* pWindow = 0); + void DoPaste (::Window* pWindow = 0); + void DoDelete (::Window* pWindow = 0); + + void StartDrag ( + const Point& rDragPt, + ::Window* pWindow ); + + void DragFinished ( + sal_Int8 nDropAction); + + sal_Int8 AcceptDrop ( + const AcceptDropEvent& rEvt, + DropTargetHelper& rTargetHelper, + ::sd::Window* pTargetWindow = NULL, + USHORT nPage = SDRPAGE_NOTFOUND, + USHORT nLayer = SDRPAGE_NOTFOUND ); + + sal_Int8 ExecuteDrop ( + const ExecuteDropEvent& rEvt, + DropTargetHelper& rTargetHelper, + ::sd::Window* pTargetWindow = NULL, + USHORT nPage = SDRPAGE_NOTFOUND, + USHORT nLayer = SDRPAGE_NOTFOUND); + +protected: + virtual USHORT DetermineInsertPosition ( + const SdTransferable& rTransferable); + + virtual USHORT InsertSlides ( + const SdTransferable& rTransferable, + USHORT nInsertPosition); + +private: + SlideSorter& mrSlideSorter; + SlideSorterController& mrController; + + typedef ::std::vector<SdPage*> PageList; + /** Remember the pages that are dragged to another document or to + another place in the same document so that they can be removed after + a move operation. + */ + PageList maPagesToRemove; + + /** Remember the pages inserted from another document or another place + in the same document so that they can be selected after the + drag-and-drop operation is completed. + */ + PageList maPagesToSelect; + + /** When pages are moved or copied then the selection of the slide + sorter has to be updated. This flag is used to remember whether the + selection has to be updated or can stay as it is (FALSE). + */ + bool mbUpdateSelectionPending; + + void CreateSlideTransferable ( + ::Window* pWindow, + bool bDrag); + + /** Select the pages stored in the maPagesToSelect member. The list in + the member is cleared afterwards. + */ + void SelectPages (void); + + /** Determine the position of where to insert the pages in the current + transferable of the sd module. + @param pWindow + This window is used as parent for dialogs that have to be shown + to the user. + @return + The index in the range [0,n] (both inclusive) with n the number + of pages is returned. + */ + sal_Int32 GetInsertionPosition (::Window* pWindow); + + /** Paste the pages of the transferable of the sd module at the given + position. + @param nInsertPosition + The position at which to insert the pages. The valid range is + [0,n] (both inclusive) with n the number of pages in the + document. + @return + The number of inserted pages is returned. + */ + sal_Int32 PasteTransferable (sal_Int32 nInsertPosition); + + /** Select a range of pages of the model. Typicall usage is the + selection of newly inserted pages. + @param nFirstIndex + The index of the first page to select. + @param nPageCount + The number of pages to select. + */ + void SelectPageRange (sal_Int32 nFirstIndex, sal_Int32 nPageCount); + + /** Return <TRUE/> when the current transferable in the current state of + the slidesorter is acceptable to be pasted. For this the + transferable has to + a) exist, + b) contain one or more regular draw pages, no master pages. + When master pages are involved, either in the transferable or in the + slide sorter (by it displaying master pages) the drop of the + transferable is not accepted. The reason is the missing + implementation of proper handling master pages copy-and-paste. + */ + enum DropType { DT_PAGE, DT_SHAPE, DT_NONE }; + DropType IsDropAccepted (void) const; + + /** This method contains the code for AcceptDrop() and ExecuteDrop() shapes. + There are only minor differences for the two cases at this level. + @param eCommand + This parameter specifies whether to do a AcceptDrop() or + ExecuteDrop(). + @param rPosition + Since the event is given as void pointer we can not take the + mouse position from it. The caller has to supply it in this + parameter. + @param pDropEvent + Event though the AcceptDropEvent and ExecuteDropEvent are very + similar they do not have a common base class. Because of that + we have to use a void* to pase these structs. + @param nPage + When the page number is given as 0xffff then it is replaced by + the number of the page at the mouse position. If the mouse is + not over a page then neither AcceptDrop() nor ExecuteDrop() are + executed. + */ + enum DropCommand { DC_ACCEPT, DC_EXECUTE }; + sal_Int8 ExecuteOrAcceptShapeDrop ( + DropCommand eCommand, + const Point& rPosition, + const void* pDropEvent , + DropTargetHelper& rTargetHelper, + ::sd::Window* pTargetWindow, + USHORT nPage, + USHORT nLayer); +}; + +} } } // end of namespace ::sd::slidesorter::controller + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/inc/controller/SlsCurrentSlideManager.hxx b/sd/source/ui/slidesorter/inc/controller/SlsCurrentSlideManager.hxx new file mode 100644 index 000000000000..769cb2372cca --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsCurrentSlideManager.hxx @@ -0,0 +1,108 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SD_SLIDESORTER_CURRENT_SLIDE_MANAGER_HXX +#define SD_SLIDESORTER_CURRENT_SLIDE_MANAGER_HXX + +#include "model/SlsSharedPageDescriptor.hxx" +#include <com/sun/star/drawing/XDrawPage.hpp> + +class SdPage; + +namespace sd { namespace slidesorter { +class SlideSorter; +} } + + +namespace sd { namespace slidesorter { namespace controller { + +/** Manage the current slide. This includes setting the according flags at + the PageDescriptor objects and setting the current slide at the main + view shell. +*/ +class CurrentSlideManager +{ +public: + /** Create a new CurrentSlideManager object that manages the current + slide for the given SlideSorter. + */ + CurrentSlideManager (SlideSorter& rSlideSorter); + + ~CurrentSlideManager (void); + + /** Call this when the current page of the main view shell has been + switched. Use SwitchCurrentSlide() to initiate such a switch. + */ + void CurrentSlideHasChanged (const sal_Int32 nSlideIndex); + + /** Call this method to switch the current page of the main view shell + to the given slide. Use CurrentSlideHasChanged() when the current + slide change has been initiated by someone else. + */ + void SwitchCurrentSlide (const sal_Int32 nSlideIndex); + void SwitchCurrentSlide (const model::SharedPageDescriptor& rpSlide); + + /** Return the page descriptor for the current slide. Note, that when + there is no current slide then the returned pointer is empty. + */ + model::SharedPageDescriptor GetCurrentSlide (void); + + /** Release all references to model data. + */ + void PrepareModelChange (void); + + /** Modify inner state in reaction to a change of the SlideSorterModel. + */ + void HandleModelChange (void); + +private: + SlideSorter& mrSlideSorter; + sal_Int32 mnCurrentSlideIndex; + model::SharedPageDescriptor mpCurrentSlide; + + bool IsCurrentSlideIsValid (void); + void SetCurrentSlideAtViewShellBase (const model::SharedPageDescriptor& rpSlide); + void SetCurrentSlideAtXController (const model::SharedPageDescriptor& rpSlide); + + /** When switching from one slide to a new current slide then this + method releases all ties to the old slide. + */ + void ReleaseCurrentSlide (void); + + /** When switching from one slide to a new current slide then this + method connects to the new current slide. + */ + void AcquireCurrentSlide (const sal_Int32 nSlideIndex); +}; + + +} } } // end of namespace ::sd::slidesorter::controller + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/inc/controller/SlsFocusManager.hxx b/sd/source/ui/slidesorter/inc/controller/SlsFocusManager.hxx new file mode 100644 index 000000000000..f647f914e318 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsFocusManager.hxx @@ -0,0 +1,238 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SD_SLIDESORTER_FOCUS_MANAGER_HXX +#define SD_SLIDESORTER_FOCUS_MANAGER_HXX + +#include <model/SlsSharedPageDescriptor.hxx> + +#include <sal/types.h> +#include <tools/link.hxx> +#include <vector> + +namespace sd { namespace slidesorter { +class SlideSorter; +} } + + +namespace sd { namespace slidesorter { namespace controller { + +/** This class manages the focus of the slide sorter. There is the focus + page which is or is not focused. Initialized to point to the first page + it can be set to other pages by using the MoveFocus() method. The + focused state of the focus page can be toggled with the ToggleFocus() + method. +*/ +class FocusManager +{ +public: + /** Create a new focus manager that operates on the pages of the model + associated with the given controller. The focus page is set to the + first page. Focused state is off. + */ + FocusManager (SlideSorter& rSlideSorter); + + ~FocusManager (void); + + enum FocusMoveDirection + { + FMD_NONE, + FMD_LEFT, + FMD_RIGHT, + FMD_UP, + FMD_DOWN + }; + + /** Move the focus from the currently focused page to one that is + displayed adjacent to it, either vertically or horizontally. + @param eDirection + Direction in which to move the focus. Wrap arround is done + differently when moving vertically or horizontally. Vertical + wrap arround takes place in the same column, i.e. when you are + in the top row and move up you come out in the bottom row in the + same column. Horizontal wrap arround moves to the next + (FMD_RIGHT) or previous (FMD_LEFT) page. Moving to the right + from the last page goes to the first page and vice versa. + When FMD_NONE is given, the current page index is checked for + being valid. If it is not, then it is set to the nearest valid + page index. + */ + void MoveFocus (FocusMoveDirection eDirection); + + /** Show the focus indicator of the current slide. + @param bScrollToFocus + When <TRUE/> (the default) then the view is scrolled so that the + focus rectangle lies inside its visible area. + */ + void ShowFocus (const bool bScrollToFocus = true); + + /** Hide the focus indicator. + */ + void HideFocus (void); + + /** Toggle the focused state of the current slide. + @return + Returns the focused state of the focus page after the call. + */ + bool ToggleFocus (void); + + /** Return whether the window managed by the called focus manager has + the input focus of the application. + */ + bool HasFocus (void) const; + + /** Return the descriptor of the page that currently has the focus. + @return + When there is no page that currently has the focus then NULL is + returned. + */ + model::SharedPageDescriptor GetFocusedPageDescriptor (void) const; + + /** Return the index of the page that currently has the focus as it is + accepted by the slide sorter model. + @return + When there is no page that currently has the focus then -1 is + returned. + */ + sal_Int32 GetFocusedPageIndex (void) const; + + /** DEPRECATED. (Use equivalent SetFocusedPage(sal_Int32) instead. + + Set the focus to the page with the given index. This does not make + the focus visible. + @param nPageIndex + Index of a page as it is accepted by the slide sorter model. + The index is not checked for validity. + */ + void FocusPage (sal_Int32 nPageIndex); + + /** Set the focused page to the one described by the given page + descriptor. The visibility of the focus indicator is not modified. + @param rDescriptor + One of the page descriptors that are currently managed by the + SlideSorterModel. + */ + void SetFocusedPage (const model::SharedPageDescriptor& rDescriptor); + + /** Set the focused page to the one described by the given page + index. The visibility of the focus indicator is not modified. + @param nPageIndex + A valid page index that is understood by the SlideSorterModel. + */ + void SetFocusedPage (sal_Int32 nPageIndex); + + /** Return <TRUE/> when the focus inidcator is currently shown. A + prerequisite is that the window managed by this focus manager has + the input focus as indicated by a <TRUE/> return value of + HasFocus(). It is not necessary that the focus indicator is + visible. It may have been scrolled outside the visible area. + */ + bool IsFocusShowing (void) const; + + /** Add a listener that is called when the focus is shown or hidden or + set to another page object. + @param rListener + When this method is called multiple times for the same listener + the second and all following calls are ignored. Each listener + is added only once. + */ + void AddFocusChangeListener (const Link& rListener); + + /** Remove a focus change listener. + @param rListener + It is save to pass a listener that was not added are has been + removed previously. Such calls are ignored. + */ + void RemoveFocusChangeListener (const Link& rListener); + + /** Move focus to sibling outside the actual slide sorter. This is + typically the tool bar with the close button. + */ + void SetFocusToToolBox (void); + + /** Create an instance of this class to temporarily hide the focus + indicator. It is restored to its former visibility state when the + FocusHider is destroyed. + */ + class FocusHider + { + public: + FocusHider (FocusManager&); + ~FocusHider (void); + private: + bool mbFocusVisible; + FocusManager& mrManager; + }; + +private: + SlideSorter& mrSlideSorter; + + /** Index of the page that may be focused. It is -1 when the model + contains no page. + */ + sal_Int32 mnPageIndex; + + /** This flag indicates whether the page pointed to by mpFocusDescriptor + has the focus. + */ + bool mbPageIsFocused; + + ::std::vector<Link> maFocusChangeListeners; + + /** Reset the focus state of the given descriptor and request a repaint + so that the focus indicator is hidden. + @param pDescriptor + When NULL is given then the call is ignored. + */ + void HideFocusIndicator (const model::SharedPageDescriptor& rpDescriptor); + + /** Set the focus state of the given descriptor, scroll it into the + visible area and request a repaint so that the focus indicator is + made visible. + @param pDescriptor + When NULL is given then the call is ignored. + @param bScrollToFocus + When <TRUE/> (the default) then the view is scrolled so that the + focus rectangle lies inside its visible area. + */ + void ShowFocusIndicator ( + const model::SharedPageDescriptor& rpDescriptor, + const bool bScrollToFocus); + + /** Call all currently registered listeners that a focus change has + happended. The focus may be hidden or shown or moved from one page + object to another. + */ + void NotifyFocusChangeListeners (void) const; +}; + +} } } // end of namespace ::sd::slidesorter::controller + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/inc/controller/SlsPageObjectFactory.hxx b/sd/source/ui/slidesorter/inc/controller/SlsPageObjectFactory.hxx new file mode 100644 index 000000000000..fef75520ca22 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsPageObjectFactory.hxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SD_SLIDESORTER_PAGE_OBJECT_FACTORY_HEADER +#define SD_SLIDESORTER_PAGE_OBJECT_FACTORY_HEADER + +#include <boost/shared_ptr.hpp> +#include "model/SlsSharedPageDescriptor.hxx" + +class SdPage; + +namespace sdr { namespace contact { +class ObjectContact; +class ViewContact; +class ViewObjectContact; +} } + +namespace sd { namespace slidesorter { namespace view { +class PageObject; +} } } + +namespace sd { namespace slidesorter { namespace cache { +class PageCache; +} } } + + +namespace sd { namespace slidesorter { namespace controller { + +class Properties; + +/** This class is a factory for the creation of objects that represent page + objects (shapes). This includes the contact objects of the drawing + layer. + + <p>The factory methods are called by the model::PageDescriptor and the + standard implementations of the contact objects.</p> + + <p>The factory forwars the preview cache and Properties object to page + objects and contact objects.</p> +*/ +class PageObjectFactory +{ +public: + /** Create a new PageObjectFactory object that has references to the + given cache and properties. + */ + PageObjectFactory ( + const ::boost::shared_ptr<cache::PageCache>& rpCache, + const ::boost::shared_ptr<controller::Properties>& rpProperties); + PageObjectFactory (const ::boost::shared_ptr<cache::PageCache>& rpCache); + virtual ~PageObjectFactory (void); + + virtual view::PageObject* CreatePageObject ( + SdPage* pPage, + const model::SharedPageDescriptor& rpDescriptor) const; + + virtual ::sdr::contact::ViewContact* CreateViewContact ( + view::PageObject* pPageObject, + const model::SharedPageDescriptor& rpDescriptor) const; + + virtual ::sdr::contact::ViewObjectContact* CreateViewObjectContact ( + ::sdr::contact::ObjectContact& rObjectContact, + ::sdr::contact::ViewContact& rViewContact) const; + +private: + ::boost::shared_ptr<cache::PageCache> mpPageCache; + ::boost::shared_ptr<controller::Properties> mpProperties; +}; + +} } } // end of namespace ::sd::slidesorter::controller + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/inc/controller/SlsPageSelector.hxx b/sd/source/ui/slidesorter/inc/controller/SlsPageSelector.hxx new file mode 100644 index 000000000000..11594a03a493 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsPageSelector.hxx @@ -0,0 +1,184 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SD_SLIDESORTER_PAGE_SELECTOR_HXX +#define SD_SLIDESORTER_PAGE_SELECTOR_HXX + +#include "model/SlsSharedPageDescriptor.hxx" + +#include <com/sun/star/drawing/XDrawPage.hpp> +#include <vector> +#include <memory> + +class SdPage; + +namespace sd { namespace slidesorter { +class SlideSorter; +} } + +namespace sd { namespace slidesorter { namespace model { +class SlideSorterModel; +} } } + +namespace sd { namespace slidesorter { namespace view { +class SlideSorterView; +} } } + +namespace sd { namespace slidesorter { namespace controller { + +class SlideSorterController; + + +/** A sub-controller that handles page selection of the slide browser. + Selecting a page does not make it the current page (of the main view) + automatically as this would not be desired in a multi selection. This + has to be done explicitly by calling the + CurrentSlideManager::SetCurrentSlide() method. + + Indices of pages relate allways to the number of all pages in the model + (as returned by GetPageCount()) not just the selected pages. +*/ +class PageSelector +{ +public: + PageSelector (SlideSorter& rSlideSorter); + + void SelectAllPages (void); + void DeselectAllPages (void); + /** Update the selection state of all page descriptors to be the same as + that of the pages of the SdDrawDocument they describe and issue + redraw requests where necessary. + */ + void UpdateAllPages (void); + + void SelectPage (int nPageIndex); + /** Select the descriptor that is associated with the given page. + */ + void SelectPage (const SdPage* pPage); + void SelectPage (const model::SharedPageDescriptor& rpDescriptor); + + /** Return whether the specified page is selected. This convenience + method is a subsitute for + SlideSorterModel::GetPageDescriptor(i)->IsSelected() is included + here to make this class more self contained. + */ + bool IsPageSelected (int nPageIndex); + + /** Deselect the descriptor that is associated with the given page. + */ + void DeselectPage (int nPageIndex); + void DeselectPage (const model::SharedPageDescriptor& rpDescriptor); + + /** This convenience method returns the same number of pages that + SlideSorterModel.GetPageCount() returns. It is included here so + that it is self contained for iterating over all pages to select or + deselect them. + */ + int GetPageCount (void) const; + int GetSelectedPageCount (void) const; + + void PrepareModelChange (void); + void HandleModelChange (void); + + /** Enable the broadcasting of selection change events. This calls the + SlideSorterController::SelectionHasChanged() method to do the actual + work. When EnableBroadcasting has been called as many times as + DisableBroadcasting() was called before and the selection has been + changed in the mean time, this change will be broadcasted. + */ + void EnableBroadcasting (bool bMakeSelectionVisible = true); + + /** Disable the broadcasting o selectio change events. Subsequent + changes of the selection will set a flag that triggers the sending + of events when EnableBroadcasting() is called. + */ + void DisableBroadcasting (void); + + /** Return the descriptor of the most recently selected page. This + works only when the page has not been de-selected in the mean time. + This method helps the view when it scrolls the selection into the + visible area. + @return + When the selection is empty or when the most recently selected + page has been deselected already (but other pages are still + selected) then NULL is returned, even when a selection did exist + but has been cleared. + */ + model::SharedPageDescriptor GetMostRecentlySelectedPage (void) const; + + /** Return the anchor for a range selection. This usually is the first + selected page after all pages have been deselected. + @return + The returned anchor may be NULL. + */ + model::SharedPageDescriptor GetSelectionAnchor (void) const; + + + typedef ::std::vector<SdPage*> PageSelection; + + /** Return an object that describes the current selection. The caller + can use that object to later restore the selection. + @return + The object returned describes the selection via indices. So + even if pages are exchanged a later call to SetPageSelection() + is valid. + */ + ::boost::shared_ptr<PageSelection> GetPageSelection (void) const; + + /** Restore a page selection according to the given selection object. + @param rSelection + Typically obtained by calling GetPageSelection() this object + is used to restore the selection. If pages were exchanged since + the last call to GetPageSelection() it is still valid to call + this method with the selection. When pages have been inserted + or removed the result may be unexpected. + */ + void SetPageSelection (const ::boost::shared_ptr<PageSelection>& rSelection); + + void UpdateCurrentPage (const model::SharedPageDescriptor& rCurrentPageDescriptor); + +private: + model::SlideSorterModel& mrModel; + SlideSorter& mrSlideSorter; + SlideSorterController& mrController; + int mnSelectedPageCount; + int mnBroadcastDisableLevel; + bool mbSelectionChangeBroadcastPending; + model::SharedPageDescriptor mpMostRecentlySelectedPage; + /// Anchor for a range selection. + model::SharedPageDescriptor mpSelectionAnchor; + model::SharedPageDescriptor mpCurrentPage; + + void CountSelectedPages (void); +}; + +} } } // end of namespace ::sd::slidesorter::controller + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/inc/controller/SlsProperties.hxx b/sd/source/ui/slidesorter/inc/controller/SlsProperties.hxx new file mode 100644 index 000000000000..905f5aeccc72 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsProperties.hxx @@ -0,0 +1,130 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SD_SLIDESORTER_PROPERTIES_HEADER +#define SD_SLIDESORTER_PROPERTIES_HEADER + +#include <tools/color.hxx> + +namespace sd { namespace slidesorter { namespace controller { + +/** An extensible set of properties used throughout the slide sorter. +*/ +class Properties +{ +public: + Properties (void); + ~Properties (void); + + /** When this method returns <TRUE/> then the current slide is + highlighted in the view. The default value is <FALSE/>. + */ + bool IsHighlightCurrentSlide (void) const; + void SetHighlightCurrentSlide (const bool bIsHighlightCurrentSlide); + + /** When this method returns <TRUE/> then the selection is indicated in + the view (typically by drawing rectangles around the selected + slides.) The default value is <TRUE/>. + */ + bool IsShowSelection (void) const; + void SetShowSelection (const bool bIsShowSelection); + + /** When this method returns <TRUE/> then the focusdselection is indicated in + the view (typically by drawing dotted rectangles around the selected + slides.) The default value is <TRUE/>. + */ + bool IsShowFocus (void) const; + void SetShowFocus (const bool bIsShowFocus); + + /** When this method returns <TRUE/> then on a selection change the + visible area is adapted so that the selected slides are shown + centered in the view. This can be used to center the current slide + by selecting only the current slide. The default value is <FALSE/>. + */ + bool IsCenterSelection (void) const; + void SetCenterSelection (const bool bIsCenterSelection); + + /** When this mehod returns <TRUE/> then the view may try to change the + visible area by scrolling it smoothly on the screen. Experimental. + Default value is <FALSE/>. + */ + bool IsSmoothSelectionScrolling (void) const; + void SetSmoothSelectionScrolling (const bool bIsSmoothSelectionScrolling); + + /** When this method returns <TRUE/> then during a full screen + presentation the previews in a slide sorter are not updated. + Default value is <TRUE/>. + */ + bool IsSuspendPreviewUpdatesDuringFullScreenPresentation (void) const; + void SetSuspendPreviewUpdatesDuringFullScreenPresentation (const bool bFlag); + + /** Return the background color. + */ + Color GetBackgroundColor (void) const; + void SetBackgroundColor (const Color& rColor); + + /** Return the text color. + */ + Color GetTextColor (void) const; + void SetTextColor (const Color& rColor); + + /** Return the color in which selections are to be painted. + */ + Color GetSelectionColor (void) const; + void SetSelectionColor (const Color& rColor); + + /** Return the color used for highlighting e.g. the current slide. + */ + Color GetHighlightColor (void) const; + void SetHighlightColor (const Color& rColor); + + /** The UI can be set to be read only indepently from the model status. + Used for instance in the presenter view. + */ + bool IsUIReadOnly (void) const; + void SetUIReadOnly (const bool bIsUIReadOnly); + +private: + bool mbIsHighlightCurrentSlide; + bool mbIsShowSelection; + bool mbIsShowFocus; + bool mbIsCenterSelection; + bool mbIsSmoothSelectionScrolling; + bool mbIsSuspendPreviewUpdatesDuringFullScreenPresentation; + Color maBackgroundColor; + Color maTextColor; + Color maSelectionColor; + Color maHighlightColor; + bool mbIsUIReadOnly; +}; + +} } } // end of namespace ::sd::slidesorter::controller + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/inc/controller/SlsScrollBarManager.hxx b/sd/source/ui/slidesorter/inc/controller/SlsScrollBarManager.hxx new file mode 100644 index 000000000000..d3c25c81025e --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsScrollBarManager.hxx @@ -0,0 +1,252 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SD_SLIDESORTER_SLIDE_SORTER_SCROLL_BAR_MANAGER_HXX +#define SD_SLIDESORTER_SLIDE_SORTER_SCROLL_BAR_MANAGER_HXX + +#include <tools/link.hxx> +#include <tools/gen.hxx> +#include <vcl/timer.hxx> +#include <boost/shared_ptr.hpp> + +class Point; +class Rectangle; +class ScrollBar; +class ScrollBarBox; +class Window; + +namespace sd { +class Window; +} + +namespace sd { namespace slidesorter { + class SlideSorter; +} } + + +namespace sd { namespace slidesorter { namespace controller { + +/** Manage the horizontal and vertical scroll bars. Listen for events, set + their sizes, place them in the window, determine their visibilities. + + <p>Handle auto scrolling, i.e. the scrolling of the window when the + mouse comes near the window border while dragging a selection.</p> + + <p>In order to make the slide sorter be used in the task pane with its + own vertical scrollbars the vertical scrollbar of the use of the slide + sorter is optional. When using it the available area in a window is + used and the vertical scrollbar is displayed when that area is not large + enough. When the vertical scrollbar is not used then the available area + is assumed to be modifiable. In that case the PlaceScrollBars() method + may return an area larger than the one given.<p> +*/ +class ScrollBarManager +{ +public: + /** Create a new scroll bar manager that manages three controls: the + horizontal scroll bar, the vertical scroll bar, and the little + window that fills the gap at the bottom right corner that is left + between the two scroll bars. Call LateInitialization() after + constructing a new object. + */ + ScrollBarManager (SlideSorter& rSlideSorter); + + ~ScrollBarManager (void); + + /** Call this method after constructing a new object of this class. + */ + void LateInitialization (void); + + /** Register listeners at the scroll bars. This method is called after + startup of a new slide sorter object or after a reactivation of a + slide sorter that for example is taken from a cache. + */ + void Connect (void); + + /** Remove listeners from the scroll bars. This method is called whent + the slide sorter is destroyed or when it is suspended, e.g. put + into a cache for later reuse. + */ + void Disconnect (void); + + /** Set up the scroll bar, i.e. thumb size and position. Call this + method when the content of the browser window changed, i.e. pages + were inserted or deleted, the layout or the zoom factor has + changed. + @param bResetThumbPosition + When <TRUE/> then set the thumb position to position 0. This is + done when e.g. switching between master page mode and draw mode. + @param bScrollToCurrentPosition + When <TRUE/> then scroll the window to the new offset that is + defined by the scroll bars. Otherwise the new offset is simply + set and the whole window is repainted. + */ + void UpdateScrollBars ( + bool bResetThumbPosition = false, + bool bScrollToCurrentPosition = true); + + /** Place the scroll bars inside the given area. When the available + area is not large enough for the content to display the resulting + behaviour depends on the mbUseVerticalScrollBar flag. When it is + set to true then a vertical scroll bar is shown. Otherwise the + height of the returned area is enlarged so that the content fits + into it. + @param rAvailableArea + The scroll bars will be placed inside this rectangle. It is + expected to be given in pixel relative to its parent. + @return + Returns the space that remains after the scroll bars are + placed. When the mbUseVerticalScrollBar flag is false then the + returned rectangle may be larger than the given one. + */ + Rectangle PlaceScrollBars (const Rectangle& rAvailableArea); + + /** Update the vertical scroll bar so that the visible area has the + given top value. + */ + void SetTop (const sal_Int32 nTop); + + /** Update the horizontal scroll bar so that the visible area has the + given left value. + */ + void SetLeft (const sal_Int32 nLeft); + + /** Return the width of the vertical scroll bar, which--when + shown--should be fixed in contrast to its height. + @return + Returns 0 when the vertical scroll bar is not shown or does not + exist, otherwise its width in pixel is returned. + */ + int GetVerticalScrollBarWidth (void) const; + + /** Return the height of the horizontal scroll bar, which--when + shown--should be fixed in contrast to its width. + @return + Returns 0 when the vertical scroll bar is not shown or does not + exist, otherwise its height in pixel is returned. + */ + int GetHorizontalScrollBarHeight (void) const; + + /** Call this method to scroll a window while the mouse is in dragging a + selection. If the mouse is near the window border or is outside the + window then scroll the window accordingly. + @return + When the window is scrolled then this method returns <TRUE/>. + When the window is not changed then <FALSE/> is returned. + */ + bool AutoScroll (const Point& rMouseWindowPosition); + + void StopAutoScroll (void); + +private: + SlideSorter& mrSlideSorter; + + /** The horizontal scroll bar. Note that is used but not owned by + objects of this class. It is given to the constructor. + */ + ::boost::shared_ptr<ScrollBar> mpHorizontalScrollBar; + + /** The vertical scroll bar. Note that is used but not owned by + objects of this class. It is given to the constructor. + */ + ::boost::shared_ptr<ScrollBar> mpVerticalScrollBar; + + /// Relative horizontal position of the visible area in the view. + double mnHorizontalPosition; + /// Relative vertical position of the visible area in the view. + double mnVerticalPosition; + /** The width and height of the border at the inside of the window which + when entered while in drag mode leads to a scrolling of the window. + */ + Size maScrollBorder; + double mnHorizontalScrollFactor; + double mnVerticalScrollFactor; + /** The only task of this little window is to paint the little square at + the bottom right corner left by the two scroll bars (when both are + visible). + */ + ::boost::shared_ptr<ScrollBarBox> mpScrollBarFiller; + + /** The auto scroll timer is used for keep scrolling the window when the + mouse reaches its border while dragging a selection. When the mouse + is not moved the timer issues events to keep scrolling. + */ + Timer maAutoScrollTimer; + Size maAutoScrollOffset; + + /** The content window is the one whose view port is controlled by the + scroll bars. + */ + ::boost::shared_ptr<sd::Window> mpContentWindow; + + void SetWindowOrigin ( + double nHorizontalPosition, + double nVerticalPosition); + + /** Determine the visibility of the scroll bars so that the window + content is not clipped in any dimension without showing a scroll + bar. + @param rAvailableArea + The area in which the scroll bars, the scroll bar filler, and + the SlideSorterView will be placed. + @return + The area that is enclosed by the scroll bars is returned. It + will be filled with the SlideSorterView. + */ + Rectangle DetermineScrollBarVisibilities (const Rectangle& rAvailableArea); + + /** Typically called by DetermineScrollBarVisibilities() this method + tests a specific configuration of the two scroll bars being visible + or hidden. + @return + When the window content can be shown with only being clipped in + an orientation where the scroll bar would be shown then <TRUE/> + is returned. + */ + bool TestScrollBarVisibilities ( + bool bHorizontalScrollBarVisible, + bool bVerticalScrollBarVisible, + const Rectangle& rAvailableArea); + + void CalcAutoScrollOffset (const Point& rMouseWindowPosition); + bool RepeatAutoScroll (void); + + DECL_LINK(HorizontalScrollBarHandler, ScrollBar*); + DECL_LINK(VerticalScrollBarHandler, ScrollBar*); + DECL_LINK(AutoScrollTimeoutHandler, Timer*); + + void PlaceHorizontalScrollBar (const Rectangle& aArea); + void PlaceVerticalScrollBar (const Rectangle& aArea); + void PlaceFiller (const Rectangle& aArea); +}; + +} } } // end of namespace ::sd::slidesorter::controller + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/inc/controller/SlsSelectionFunction.hxx b/sd/source/ui/slidesorter/inc/controller/SlsSelectionFunction.hxx new file mode 100644 index 000000000000..f69f6e1fefa2 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsSelectionFunction.hxx @@ -0,0 +1,206 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SD_SLIDESORTER_SELECTION_FUNCTION_HXX +#define SD_SLIDESORTER_SELECTION_FUNCTION_HXX + +#include "controller/SlsSlideFunction.hxx" +#include "model/SlsSharedPageDescriptor.hxx" +#include <tools/list.hxx> +#include <memory> + +class SdSlideViewShell; +class SdWindow; +class SdSlideView; +class SdDrawDocument; +class Sound; + +namespace sd { namespace slidesorter { +class SlideSorter; +} } + +namespace sd { namespace slidesorter { namespace controller { + +class SlideSorterController; + +class SelectionFunction + : public SlideFunction +{ +public: + TYPEINFO(); + + static FunctionReference Create( SlideSorter& rSlideSorter, SfxRequest& rRequest ); + + // Mouse- & Key-Events + virtual BOOL KeyInput(const KeyEvent& rKEvt); + virtual BOOL MouseMove(const MouseEvent& rMEvt); + virtual BOOL MouseButtonUp(const MouseEvent& rMEvt); + virtual BOOL MouseButtonDown(const MouseEvent& rMEvt); + virtual void Paint(const Rectangle&, ::sd::Window* ); + + virtual void Activate(); // Function aktivieren + virtual void Deactivate(); // Function deaktivieren + + virtual void ScrollStart(); + virtual void ScrollEnd(); + + /// Forward to the clipboard manager. + virtual void DoCut (void); + + /// Forward to the clipboard manager. + virtual void DoCopy (void); + + /// Forward to the clipboard manager. + virtual void DoPaste (void); + + /** is called when the current function should be aborted. <p> + This is used when a function gets a KEY_ESCAPE but can also + be called directly. + + @returns + true if a active function was aborted + */ + virtual bool cancel(); + +protected: + SlideSorter& mrSlideSorter; + SlideSorterController& mrController; + + SelectionFunction ( + SlideSorter& rSlideSorter, + SfxRequest& rRequest); + + virtual ~SelectionFunction(); + +private: + class SubstitutionHandler; + class EventDescriptor; + + /// Set in MouseButtonDown this flag indicates that a page has been hit. + bool mbPageHit; + + /// The rectangle of the mouse drag selection. + Rectangle maDragSelectionRectangle; + bool mbDragSelection; + + /// Box of the insert marker in model coordinates. + Rectangle maInsertionMarkerBox; + + /** We use this flag to filter out the cases where MouseMotion() is called + with a pressed mouse button but without a prior MouseButtonDown() + call. This is an indication that the mouse button was pressed over + another control, e.g. the view tab bar, and that a re-layout of the + controls moved the slide sorter under the mouse. + */ + bool mbProcessingMouseButtonDown; + + ::std::auto_ptr<SubstitutionHandler> mpSubstitutionHandler; + + DECL_LINK( DragSlideHdl, Timer* ); + void StartDrag (void); + + /** Set the selection to exactly the specified page and also set it as + the current page. + */ + void SetCurrentPage (const model::SharedPageDescriptor& rpDescriptor); + + /** When the view on which this selection function is working is the + main view then the view is switched to the regular editing view. + */ + void SwitchView (const model::SharedPageDescriptor& rpDescriptor); + + /** Make the slide nOffset slides away of the current one the new + current slide. When the new index is outside the range of valid + page numbers it is clipped to that range. + @param nOffset + When nOffset is negative then go back. When nOffset if positive go + forward. When it is zero then ignore the call. + */ + void GotoNextPage (int nOffset); + + void ProcessMouseEvent (sal_uInt32 nEventType, const MouseEvent& rEvent); + void ProcessKeyEvent (const KeyEvent& rEvent); + + // What follows are a couple of helper methods that are used by + // ProcessMouseEvent(). + + /// Select the specified page and set the selection anchor. + void SelectHitPage (const model::SharedPageDescriptor& rpDescriptor); + /// Deselect the specified page. + void DeselectHitPage (const model::SharedPageDescriptor& rpDescriptor); + /// Deselect all pages. + void DeselectAllPages (void); + + /** for a possibly following mouse motion by starting the drag timer + that after a short time of pressed but un-moved mouse starts a drag + operation. + */ + void PrepareMouseMotion (const Point& aMouseModelPosition); + + /** Select all pages between and including the selection anchor and the + specified page. + */ + void RangeSelect (const model::SharedPageDescriptor& rpDescriptor); + + /** Start a rectangle selection at the given position. + */ + void StartRectangleSelection (const Point& aMouseModelPosition); + + /** Update the rectangle selection so that the given position becomes + the new second point of the selection rectangle. + */ + void UpdateRectangleSelection (const Point& aMouseModelPosition); + + /** Select all pages that lie completly in the selection rectangle. + */ + void ProcessRectangleSelection (bool bToggleSelection); + + /** Compute a numerical code that describes a mouse event and that can + be used for fast look up of the appropriate reaction. + */ + sal_uInt32 EncodeMouseEvent ( + const EventDescriptor& rDescriptor, + const MouseEvent& rEvent) const; + + /** Compute a numerical code that describes a key event and that can + be used for fast look up of the appropriate reaction. + */ + sal_uInt32 EncodeKeyEvent ( + const EventDescriptor& rDescriptor, + const KeyEvent& rEvent) const; + + void EventPreprocessing (const EventDescriptor& rEvent); + bool EventProcessing (const EventDescriptor& rEvent); + void EventPostprocessing (const EventDescriptor& rEvent); +}; + +} } } // end of namespace ::sd::slidesorter::controller + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/inc/controller/SlsSelectionManager.hxx b/sd/source/ui/slidesorter/inc/controller/SlsSelectionManager.hxx new file mode 100644 index 000000000000..70cfc409214b --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsSelectionManager.hxx @@ -0,0 +1,214 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SD_SLIDESORTER_CONTROLLER_SELECTION_MANAGER_HXX +#define SD_SLIDESORTER_CONTROLLER_SELECTION_MANAGER_HXX + +#include "model/SlsSharedPageDescriptor.hxx" +#include <sal/types.h> +#include <tools/gen.hxx> +#include <vector> + +class Link; +class SdPage; + +namespace sd { namespace slidesorter { +class SlideSorter; +} } + +namespace sd { namespace slidesorter { namespace controller { + +class SlideSorterController; + +/** This class is a part of the controller and handles the selection of + slides. + <p>It has methods to modify the selected slides (delete them or + move them to other places in the document), change the visible area so + to make the selected slides visble, tell listeners when the selection + changes.</p> +*/ +class SelectionManager +{ +public: + /** Create a new SelectionManger for the given slide sorter. + */ + SelectionManager (SlideSorter& rSlideSorter); + + ~SelectionManager (void); + + /** Delete the currently selected slides. When this method returns the + selection is empty. + */ + void DeleteSelectedPages (void); + + /** Move the maked pages to a position directly after the specified page. + */ + bool MoveSelectedPages (const sal_Int32 nTargetPage); + + /** Call this method after the selection has changed (possible several + calls to the PageSelector) to invalidate the relevant slots and send + appropriate events. + */ + void SelectionHasChanged (const bool bMakeSelectionVisible = true); + + /** Return <TRUE/> when the selection has changed but has not yet been + moved to the visible area of the slide sorter view. + */ + bool IsMakeSelectionVisiblePending (void) const; + + enum SelectionHint { SH_FIRST, SH_LAST, SH_RECENT }; + + /** Try to make all currently selected page objects visible, i.e. set + the origin so that the page objects lie inside the visible area. + When the selection is empty then the visible area is not modified. + + <p>This method, and the ones is calls, look into the Properties + object of the SlideSorter in order to determine whether the current + selection is to be displayed centered.</p> + @param eSelectionHint + This is an advice on which selected page object to handle with + the highest priority when the whole selection does not fit into + the visible area. + @return + Returns the vertical translation of the visible area. It is 0 + when no update of the visible area was done. + */ + Size MakeSelectionVisible ( + const SelectionHint eSelectionHint = SH_RECENT); + + /** Modify the origin of the visible area so that the given rectangle + comes into view. This is done with the smallest change: no + scrolling takes place when the given rectangle already lies in the + visible area. Otherwise either the top or the bottom of the given + rectangle is aligned with the top or the bottom of the visible area. + @return + Returns the vertical translation of the visible area. It is 0 + when no update of the visible area was done. + */ + Size MakeRectangleVisible (const Rectangle& rBox); + + /** Add a listener that is called when the selection of the slide sorter + changes. + @param rListener + When this method is called multiple times for the same listener + the second and all following calls are ignored. Each listener + is added only once. + */ + void AddSelectionChangeListener (const Link& rListener); + + /** Remove a listener that was called when the selection of the slide + sorter changes. + @param rListener + It is save to pass a listener that was not added are has been + removed previously. Such calls are ignored. + */ + void RemoveSelectionChangeListener (const Link& rListener); + + /** Return the position where to insert pasted slides based on the + current selection. When there is a selection then the insert + position is behind the last slide. When the selection is empty then + most of the time the insert position is at the end of the document. + There is an exception right after the display of a popup-menu. The + position of the associated insertion marker is stored here and reset + the next time the selection changes. + */ + sal_Int32 GetInsertionPosition (void) const; + + /** Store an insertion position temporarily. It is reset when the + selection changes the next time. + */ + void SetInsertionPosition (const sal_Int32 nInsertionPosition); + +private: + SlideSorter& mrSlideSorter; + SlideSorterController& mrController; + + ::std::vector<Link> maSelectionChangeListeners; + + /** This array stores the indices of the selected page descriptors at + the time when the edit mode is switched to EM_MASTERPAGE. With this + we can restore the selection when switching back to EM_PAGE mode. + */ + ::std::vector<SdPage*> maSelectionBeforeSwitch; + + /** When this flag is set then on the next call to Paint() the selection + is moved into the visible area. + */ + bool mbIsMakeSelectionVisiblePending; + + /** The insertion position is only temporarily valid. Negative values + indicate that the explicit insertion position is not valid. In this + case GetInsertionPosition() calculates it from the current selection. + */ + sal_Int32 mnInsertionPosition; + + /** Delete the given list of normal pages. This method is a helper + function for DeleteSelectedPages(). + @param rSelectedNormalPages + A list of normal pages. Supplying master pages is an error. + */ + void DeleteSelectedNormalPages (const ::std::vector<SdPage*>& rSelectedNormalPages); + + /** Delete the given list of master pages. This method is a helper + function for DeleteSelectedPages(). + @param rSelectedMasterPages + A list of master pages. Supplying normal pages is an error. + */ + void DeleteSelectedMasterPages (const ::std::vector<SdPage*>& rSelectedMasterPages); + + /** Return <TRUE/> when the given rectangle, that typically is the + bounding box of all currently selected slides, does not fit entirely + into the visible area of the slide sorter view. + */ + bool DoesSelectionExceedVisibleArea (const Rectangle& rSelectionBox) const; + + /** When not all currently selected slides fit into the visible area of + the slide sorter view, and thus DoesSelectionExceedVisibleArea() + would return <TRUE/>, then it is the task of this method to + determine which part of the selection to move into the visible area. + @param rpFirst + The first selected slide. Must not be an empty pointer. + @param rpLast + The last selected slide. Must not be an empty pointer. + @param eSelectionHint + This hint tells the method on which slide to concentrate, + i.e. which slide has to be inside the returned visible area. + @return + Returns the new visible area. + */ + Rectangle ResolveLargeSelection ( + const model::SharedPageDescriptor& rpFirst, + const model::SharedPageDescriptor& rpLast, + const SelectionHint eSelectionHint); +}; + +} } } // end of namespace ::sd::slidesorter::controller + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/inc/controller/SlsSlideFunction.hxx b/sd/source/ui/slidesorter/inc/controller/SlsSlideFunction.hxx new file mode 100644 index 000000000000..3a1b46675673 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsSlideFunction.hxx @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SD_SLIDESORTER_SLIDE_FUNCTION_HXX +#define SD_SLIDESORTER_SLIDE_FUNCTION_HXX + +#include "fupoor.hxx" + +class SdDrawDocument; + +namespace sd { namespace slidesorter { +class SlideSorter; +} } + + +namespace sd { namespace slidesorter { namespace controller { + +class SlideSorterController; + + +/** Base class for functions of the slide sorter. +*/ +class SlideFunction + : public FuPoor +{ +public: + TYPEINFO(); + + virtual BOOL MouseMove (const MouseEvent& rMEvt); + virtual BOOL MouseButtonUp (const MouseEvent& rMEvt); + virtual BOOL MouseButtonDown (const MouseEvent& rMEvt); + + /** Called from ForceScroll() before the actual scrolling. + */ + virtual void ScrollStart (void); + + /** Called from ForceScroll() after the actual scrolling. + */ + virtual void ScrollEnd (void); + +protected: + SlideFunction ( + SlideSorter& rSlideSorter, + SfxRequest& rRequest); +}; + +} } } // end of namespace ::sd::slidesorter::controller + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/inc/controller/SlsSlotManager.hxx b/sd/source/ui/slidesorter/inc/controller/SlsSlotManager.hxx new file mode 100644 index 000000000000..d56fc1b44388 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsSlotManager.hxx @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SD_SLIDESORTER_SLOT_MANAGER_HXX +#define SD_SLIDESORTER_SLOT_MANAGER_HXX + +#include <tools/link.hxx> +#include <memory> +#include <queue> + +class AbstractSvxNameDialog; +class SfxItemSet; +class SfxRequest; +class String; + +namespace sd { namespace slidesorter { +class SlideSorter; +} } + + +namespace sd { namespace slidesorter { namespace controller { + +class Command; + +/** This manager takes over the work of handling slot calls from the + controller of the slide sorter. +*/ +class SlotManager +{ +public: + /** Create a new slot manager that handles slot calls for the controller + of a slide sorter. + @param rController + The controller for which to handle the slot calls. + */ + SlotManager (SlideSorter& rSlideSorter); + + ~SlotManager (void); + + void FuTemporary (SfxRequest& rRequest); + void FuPermanent (SfxRequest& rRequest); + void FuSupport (SfxRequest& rRequest); + void GetMenuState (SfxItemSet &rSet); + void GetClipboardState (SfxItemSet &rSet); + void GetStatusBarState (SfxItemSet& rSet); + void ExecCtrl (SfxRequest& rRequest); + void GetAttrState (SfxItemSet& rSet); + + void ExecuteCommandAsynchronously (::std::auto_ptr<Command> pCommand); + +private: + /// The controller for which we manage the slot calls. + SlideSorter& mrSlideSorter; + + typedef ::std::queue<Command*> CommandQueue; + CommandQueue maCommandQueue; + + /** Called by FuTemporary to show the slide show. + */ + void ShowSlideShow (SfxRequest& rRequest); + + /** The implementation is a copy of the code for SID_RENAMEPAGE in + drviews2.cxx. + */ + void RenameSlide (void); + DECL_LINK(RenameSlideHdl, AbstractSvxNameDialog*); + bool RenameSlideFromDrawViewShell( USHORT nPageId, const String& rName); + + /** Handle SID_INSERTPAGE slot calls. + */ + void InsertSlide (SfxRequest& rRequest); + + DECL_LINK(UserEventCallback, void*); +}; + +} } } // end of namespace ::sd::slidesorter::controller + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |