diff options
Diffstat (limited to 'sd/source/ui/slidesorter/inc')
29 files changed, 4798 insertions, 0 deletions
diff --git a/sd/source/ui/slidesorter/inc/cache/SlsCacheContext.hxx b/sd/source/ui/slidesorter/inc/cache/SlsCacheContext.hxx new file mode 100644 index 000000000000..c828e95d1d02 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/cache/SlsCacheContext.hxx @@ -0,0 +1,106 @@ +/************************************************************************* + * + * 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_CACHE_CONTEXT_HXX +#define SD_SLIDESORTER_CACHE_CONTEXT_HXX + +#include <sal/types.h> +#include <com/sun/star/uno/XInterface.hpp> +#include <boost/shared_ptr.hpp> +#include <vector> + +class BitmapEx; +class SdrPage; + +namespace sd { namespace slidesorter { namespace cache { + +typedef const SdrPage* CacheKey; + +/** This interface allows the individualisation of different instances of + the PreviewCache. +*/ +class CacheContext +{ +public: + /** This method is called when the asynchronous creation of a preview + has been finished. + @param aKey + The key of the page for which the preview has been created. + @param aPreview + The newly created preview. + */ + virtual void NotifyPreviewCreation ( + CacheKey aKey, + const ::boost::shared_ptr<BitmapEx>& rPreview) = 0; + + /** Called to determine whether the system is idle and a preview can be + created without annoying the user. + */ + virtual bool IsIdle (void) = 0; + + /** This method is used to determine whether a page is currently visible + or not. It is called when the cache becomes to large and some + previews have to be released or scaled down. + */ + virtual bool IsVisible (CacheKey aKey) = 0; + + /** Return the page associdated with the given key. Note that different + keys may map to a single page (this may be the case with custom + slide shows.) + */ + virtual const SdrPage* GetPage (CacheKey aKey) = 0; + + /** This method is used when the request queue is filled. It asks for + the list of visible entries and maybe for the list of not visible + entries and creates preview creation requests for them. + @param bVisible + When this is <FALSE/> then the implementation can decide whether + to allow rendering of previews that are not visible (ahead of + time). When not then return an empty pointer or an empty vector. + */ + virtual ::boost::shared_ptr<std::vector<CacheKey> > GetEntryList (bool bVisible) = 0; + + /** Return the priority that defines the order in which previews are + created for different keys/pages. Typically the visible pages come + first, then top-down, left-to-right. + */ + virtual sal_Int32 GetPriority (CacheKey aKey) = 0; + + /** Return the model to which the pages belong for which the called + cache manages the previews. Different caches that belong to the + same model but have different preview sizes may acces previews of + each other in order to create fast previews of the previews. + */ + virtual ::com::sun::star::uno::Reference<com::sun::star::uno::XInterface> GetModel (void) = 0; +}; + +typedef ::boost::shared_ptr<CacheContext> SharedCacheContext; + +} } } // end of namespace ::sd::slidesorter::cache + +#endif + diff --git a/sd/source/ui/slidesorter/inc/cache/SlsPageCache.hxx b/sd/source/ui/slidesorter/inc/cache/SlsPageCache.hxx new file mode 100755 index 000000000000..4a5c2b51ac28 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/cache/SlsPageCache.hxx @@ -0,0 +1,148 @@ +/************************************************************************* + * + * 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_CACHE_HXX +#define SD_SLIDESORTER_PAGE_CACHE_HXX + +#include "cache/SlsCacheContext.hxx" +#include <sal/types.h> +#include <vcl/bitmapex.hxx> +#include <boost/function.hpp> +#include <boost/scoped_ptr.hpp> +#include <boost/shared_ptr.hpp> + +namespace sd { namespace slidesorter { namespace view { +class PageObjectViewObjectContact; +} } } + +namespace sd { namespace slidesorter { namespace cache { + +class GenericPageCache; +class RequestData; + +/** The page cache is responsible for the creation and storage of preview + bitmaps of pages that are shown by the slide sorter. + + <p>Bitmaps for previews and a cache are used to speed up the display + (painting) of the slide sorter. But, of course, we have to limit this + time-space-tradeoff by limiting the amount of space that can be use to + store bitmaps.</p> + + <p>There are several strategies employed by this class to shorten the + perceived time that is used to paint the slide sorter: + <ul> + <li>Rendering pages ahead of time. Additionally to rendering the + visible slides we try to render part or all of the slides that are not + (yet) visible. This, of course, makes sense only when the computer is + ohterwise idle while doing that.</li> + <li>When the size of the slides on the screen changes we mark the + bitmaps as needing an update but use them while the new bitmap in the + correct size is not available.</li> + <li>Give the UI the chance to handle user events between the rendering + of differe slides.</li> + <li>Limit the amount of space that may be used for storing preview + bitmaps and throw.</li> + </p> + + <p>There is another somewhat similar methods for requesting new previews: + GetPreviewBitmap() schedules a re-rendering (when necessary) and + returns the preview what is currently available, either as a preview of + the preview or, when nothing has changed since the last call, as the + final thing. + </p> +*/ +class PageCache +{ +public: + /** The page chache is created with a reference to the slide sorter so + that it has access to both the view and the model and so can fill + itself with requests for all or just the visible pages. + + It is the task of the PageCacheManager to create new objects of this + class. + */ + PageCache ( + const Size& rPreviewSize, + const SharedCacheContext& rpCacheContext); + + ~PageCache (void); + + void ChangeSize(const Size& rPreviewSize); + + /** Request a preview bitmap for the specified page object in the + specified size. The returned bitmap may be a preview of the + preview, i.e. either a scaled (up or down) version of a previous + preview (of the wrong size) or an empty bitmap. In this case a + request for the generation of a new preview is created and inserted + into the request queue. When the preview is available the page + shape will be told to paint itself again. When it then calls this + method again if receives the correctly sized preview bitmap. + @param rRequestData + This data is used to determine the preview. + @param rSize + The size of the requested preview bitmap. + @return + Returns a bitmap that is either empty, contains a scaled (up or + down) version or is the requested bitmap. + */ + BitmapEx GetPreviewBitmap ( + CacheKey aKey, + const Size& rSize); + + /** Call this method when a view-object-contact object is being deleted + and does not need (a) its current bitmap in the cache and (b) a + requested new bitmap. + */ + void ReleasePreviewBitmap (CacheKey aKey); + + /** Call this method when all preview bitmaps have to be generated anew. + This is the case when the size of the page objects on the screen has + changed or when the model has changed. + @param bUpdateCache + When this flags is <TRUE/> then requests for updated previews + are created. When it is <FALSE/> the existing previews are only + marked as not being up-to-date anymore. + */ + void InvalidateCache (bool bUpdateCache = true); + + /** With the precious flag you can control whether a bitmap can be + removed or reduced in size to make room for other bitmaps or is so + precious that it will not touched. A typical use is to set the + precious flag for exactly the visible pages. + */ + void SetPreciousFlag (CacheKey aKey, bool bIsPrecious); + + void Pause (void); + void Resume (void); + +private: + ::boost::scoped_ptr<GenericPageCache> mpImplementation; +}; + +} } } // end of namespace ::sd::slidesorter::cache + +#endif diff --git a/sd/source/ui/slidesorter/inc/cache/SlsPageCacheManager.hxx b/sd/source/ui/slidesorter/inc/cache/SlsPageCacheManager.hxx new file mode 100644 index 000000000000..50202a7eed3d --- /dev/null +++ b/sd/source/ui/slidesorter/inc/cache/SlsPageCacheManager.hxx @@ -0,0 +1,177 @@ +/************************************************************************* + * + * 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_PAGE_CACHE_MANAGER_HXX +#define SD_PAGE_CACHE_MANAGER_HXX + +#include <sal/types.h> +#include <com/sun/star/uno/XInterface.hpp> +#include <boost/shared_ptr.hpp> +#include <memory> +#include <vector> + +class Size; +class SdDrawDocument; +class SdrPage; + +namespace sd { namespace slidesorter { namespace view { +class SlideSorterView; +class PageObjectViewObjectContact; +} } } + +namespace sd { namespace slidesorter { namespace model { +class SlideSorterModel; +} } } + +namespace sd { namespace slidesorter { namespace cache { + +namespace css = ::com::sun::star; + +class BitmapCache; + + +/** Provide and manage the preview bitmap caches for all slide sorter + instances. There is one cache per active slide sorter plus a small + number of caches that are no longer in use. The later are kept to speed + up the switching between views. +*/ +class PageCacheManager +{ +public: + typedef BitmapCache Cache; + typedef ::std::vector< ::std::pair<Size, ::boost::shared_ptr<BitmapCache> > > BestFittingPageCaches; + typedef css::uno::Reference<css::uno::XInterface> DocumentKey; + + /** Return the one instance of the PageCacheManager class. + */ + static ::boost::shared_ptr<PageCacheManager> Instance (void); + + /** Look up the cache for the given model in which the previews have the + specified size. If no such cache exists, then one is created. When + a new BitmapCache is created its Recycle() method is called with a + sorted list of existing caches from which the new one initialize its + previews. + @return + The returned cache lives as long as somebody keeps a shared + pointer and the ReleaseCache() method has not been called. + */ + ::boost::shared_ptr<Cache> GetCache ( + DocumentKey pDocument, + const Size& rPreviewSize); + + /** Tell the cache manager to release its own reference to the specified + cache. After that the cache will live as long as the caller (and + maybe others) holds its reference. + */ + void ReleaseCache (const ::boost::shared_ptr<Cache>& rpCache); + + /** This is an information to the cache manager that the size of preview + bitmaps in the specified cache has changed. + + */ + ::boost::shared_ptr<Cache> ChangeSize ( + const ::boost::shared_ptr<Cache>& rpCache, + const Size& rOldPreviewSize, + const Size& rNewPreviewSize); + + /** Invalidate the preview bitmap for one slide that belongs to the + specified document. The bitmaps for this slide in all caches are + marked as out-of-date and will be re-created when they are requested + the next time. + */ + void InvalidatePreviewBitmap ( + DocumentKey pDocument, + const SdrPage* pPage); + + /** Invalidate all the caches that are currently in use and destroy + those that are not. This is used for example when the high contrast + mode is turned on or off. + */ + void InvalidateAllCaches (void); + +private: + /** Singleton instance of the cache manager. Note that this is a weak + pointer. The (implementation class of) ViewShellBase holds a + shared_ptr so that the cache manager has the same life time as the + ViewShellBase. + */ + static ::boost::weak_ptr<PageCacheManager> mpInstance; + + /// List of active caches. + class PageCacheContainer; + ::std::auto_ptr<PageCacheContainer> mpPageCaches; + + /// List of inactive, recently used caches. + class RecentlyUsedPageCaches; + ::std::auto_ptr<RecentlyUsedPageCaches> mpRecentlyUsedPageCaches; + + /** The maximal number of recently used caches that are kept alive after + they have become inactive, i.e. after they are not used anymore by a + slide sorter. + */ + const sal_uInt32 mnMaximalRecentlyCacheCount; + + PageCacheManager (void); + ~PageCacheManager (void); + + class Deleter; + friend class Deleter; + + ::boost::shared_ptr<Cache> GetRecentlyUsedCache( + DocumentKey pDocument, + const Size& rSize); + + /** Add the given cache to the list of recently used caches for the + document. There is one such list per document. Each least has at + most mnMaximalRecentlyCacheCount members. + */ + void PutRecentlyUsedCache( + DocumentKey pDocument, + const Size& rPreviewSize, + const ::boost::shared_ptr<Cache>& rpCache); + + /** Return a sorted list of the available caches, both active caches and + those recently used, for the given document. The sort order is so + that an exact match of the preview size is at the front. Other + caches follow with the largest size first. + */ + BestFittingPageCaches GetBestFittingCaches ( + DocumentKey pDocument, + const Size& rPreviewSize); + + /** This method is used internally to initialize a newly created + BitmapCache with already exisiting previews. + */ + void Recycle ( + const ::boost::shared_ptr<Cache>& rpCache, + DocumentKey pDocument, + const Size& rPreviewSize); +}; + +} } } // end of namespace ::sd::slidesorter::cache + +#endif diff --git a/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx b/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx new file mode 100755 index 000000000000..667aa768ee8f --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx @@ -0,0 +1,337 @@ +/************************************************************************* + * + * 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 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..50c23e3dff4e --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsAnimator.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * 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 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..0bdbd7cb569f --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx @@ -0,0 +1,216 @@ +/************************************************************************* + * + * 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 + 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..b0f3a75b540c --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsCurrentSlideManager.hxx @@ -0,0 +1,105 @@ +/************************************************************************* + * + * 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 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..ecc02e8590c1 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsFocusManager.hxx @@ -0,0 +1,236 @@ +/************************************************************************* + * + * 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 + 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..59e8f05a3883 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsPageObjectFactory.hxx @@ -0,0 +1,97 @@ +/************************************************************************* + * + * 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 + diff --git a/sd/source/ui/slidesorter/inc/controller/SlsPageSelector.hxx b/sd/source/ui/slidesorter/inc/controller/SlsPageSelector.hxx new file mode 100755 index 000000000000..57aaf9293301 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsPageSelector.hxx @@ -0,0 +1,181 @@ +/************************************************************************* + * + * 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 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..51e353d696b9 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsProperties.hxx @@ -0,0 +1,128 @@ +/************************************************************************* + * + * 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 + diff --git a/sd/source/ui/slidesorter/inc/controller/SlsScrollBarManager.hxx b/sd/source/ui/slidesorter/inc/controller/SlsScrollBarManager.hxx new file mode 100755 index 000000000000..c93ed7708650 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsScrollBarManager.hxx @@ -0,0 +1,249 @@ +/************************************************************************* + * + * 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 diff --git a/sd/source/ui/slidesorter/inc/controller/SlsSelectionFunction.hxx b/sd/source/ui/slidesorter/inc/controller/SlsSelectionFunction.hxx new file mode 100755 index 000000000000..79b8a1ff5d44 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsSelectionFunction.hxx @@ -0,0 +1,204 @@ +/************************************************************************* + * + * 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 + 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..c0fab6da84c6 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsSelectionManager.hxx @@ -0,0 +1,211 @@ +/************************************************************************* + * + * 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 diff --git a/sd/source/ui/slidesorter/inc/controller/SlsSlideFunction.hxx b/sd/source/ui/slidesorter/inc/controller/SlsSlideFunction.hxx new file mode 100755 index 000000000000..5b8c7d9a08b6 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsSlideFunction.hxx @@ -0,0 +1,73 @@ +/************************************************************************* + * + * 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 diff --git a/sd/source/ui/slidesorter/inc/controller/SlsSlotManager.hxx b/sd/source/ui/slidesorter/inc/controller/SlsSlotManager.hxx new file mode 100755 index 000000000000..0e58d5d3b411 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsSlotManager.hxx @@ -0,0 +1,102 @@ +/************************************************************************* + * + * 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 + diff --git a/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx b/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx new file mode 100755 index 000000000000..4ade19087304 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx @@ -0,0 +1,201 @@ +/************************************************************************* + * + * 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_MODEL_HXX +#define SD_SLIDESORTER_SLIDE_SORTER_MODEL_HXX + +class SdDrawDocument; + +#include "model/SlsPageEnumeration.hxx" +#include "model/SlsSharedPageDescriptor.hxx" + +#include "pres.hxx" +#include <com/sun/star/drawing/XDrawPage.hpp> +#include <osl/mutex.hxx> + +#include <memory> +#include <vector> +#include <functional> + +namespace css = ::com::sun::star; + +namespace sd { namespace slidesorter { +class SlideSorter; +} } + +namespace sd { namespace slidesorter { namespace controller { +class PageObjectFactory; +} } } + +namespace sd { namespace slidesorter { namespace model { + +class DocumentPageContainer; + +/** The model of the slide sorter gives access to the slides that are to be + displayed in the slide sorter view. Via the SetDocumentSlides() method + this set of slides can be modified (but do not call it directly, use + SlideSorterController::SetDocumentSlides() instead.) +*/ +class SlideSorterModel +{ +public: + SlideSorterModel (SlideSorter& rSlideSorter); + + virtual ~SlideSorterModel (void); + + /** This method is present to let the view create a ShowView for + displaying slides. + */ + SdDrawDocument* GetDocument (void); + + /** Set a new edit mode and return whether the edit mode really + has been changed. When the edit mode is changed then the + previous page descriptor list is replaced by a new one which + has to be repainted. + @return + A return value of <TRUE/> indicates that the edit mode has + changed and thus the page descriptor list has been set up + to reflect that change. A repaint is necessary. + */ + bool SetEditMode (EditMode eEditMode); + + EditMode GetEditMode (void) const; + PageKind GetPageType (void) const; + + /** Return the number of slides in the document regardless of whether + they are visible or not or whether they are hidden or not. + The number of slides depends on the set of slides available through + the XIndexAccess given to SetDocumentSlides(). + */ + sal_Int32 GetPageCount (void) const; + + /** Return a page descriptor for the page with the specified index. + Page descriptors are created on demand. The page descriptor is + found (or not found) in constant time. + @param nPageIndex + The index of the requested slide. The valid values + are 0 to GetPageCount()-1. + @param bCreate + When <TRUE/> and the requested page descriptor is missing then + it is created. When <FALSE/> then an empty reference is + returned for missing descriptors. + @return + When the given index is not valid, i.e. lower then zero or + larger than or equal to the number of pages then an empty + reference is returned. Note that the page count may change + between calls to GetPageCount() and GetPageDescriptor(). + */ + SharedPageDescriptor GetPageDescriptor ( + const sal_Int32 nPageIndex, + const bool bCreate = true) const; + + /** Return a page descriptor for the given XDrawPage. Page descriptors + are created on demand. The page descriptor is found (or not found) + in (at most) linear time. Note that all page descriptors in front of + the one associated with the given XDrawPage are created when not yet + present. When the XDrawPage is not found then all descriptors are + created. + @return + Returns the index to the requested page descriptor or -1 when + there is no such page descriptor. + */ + sal_Int32 GetIndex ( + const ::com::sun::star::uno::Reference<com::sun::star::drawing::XDrawPage>& rxSlide) const; + + /** Call this method after the document has changed its structure. This + will get the model in sync with the SdDrawDocument. This method + tries not to throw away to much information already gathered. This + is especially important for previews of complex pages that take some + time to create. + */ + void Resync (void); + + /** Delete all descriptors that currently are in the container. The size + of the container, however, is not altered. Use the AdaptSize + method for that. + */ + void ClearDescriptorList (void); + + /** Set the selection of the document to exactly that of the called model. + */ + void SynchronizeDocumentSelection (void); + + /** Replace the factory for the creation of the page objects and + contacts with the given object. The old factory is destroyed. + */ + void SetPageObjectFactory( + ::std::auto_ptr<controller::PageObjectFactory> pPageObjectFactory); + + /** Return the page object factory. It none has been set so far or it + has been reset, then a new one is created. + */ + const controller::PageObjectFactory& GetPageObjectFactory (void) const; + + /** Return the mutex so that the caller can lock it and then safely + access the model. + */ + ::osl::Mutex& GetMutex (void); + + /** Set the XIndexAccess from which the called SlideSorterModel takes + its pages. + @param rxSlides + The set of slides accessible through this XIndexAccess are not + necessarily the same as the ones of the XModel of the + XController (although it typically is a subset). + */ + void SetDocumentSlides (const css::uno::Reference<css::container::XIndexAccess>& rxSlides); + + /** Return the set of pages that is currently displayed by the slide sorter. + */ + css::uno::Reference<css::container::XIndexAccess> GetDocumentSlides (void) const; + + /** This method is called when the edit mode has changed. It calls + SetDocumentSlides() with the set of slides or master pages obtained + from the model of the XController. + */ + void UpdatePageList (void); + +private: + mutable ::osl::Mutex maMutex; + SlideSorter& mrSlideSorter; + ::com::sun::star::uno::Reference<com::sun::star::container::XIndexAccess> mxSlides; + PageKind mePageKind; + EditMode meEditMode; + typedef ::std::vector<SharedPageDescriptor> DescriptorContainer; + mutable DescriptorContainer maPageDescriptors; + mutable ::std::auto_ptr<controller::PageObjectFactory> mpPageObjectFactory; + + /** Resize the descriptor container according to current values of + page kind and edit mode. + */ + void AdaptSize (void); + +}; + +} } } // end of namespace ::sd::slidesorter::model + +#endif diff --git a/sd/source/ui/slidesorter/inc/model/SlsEnumeration.hxx b/sd/source/ui/slidesorter/inc/model/SlsEnumeration.hxx new file mode 100644 index 000000000000..c93641a51204 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/model/SlsEnumeration.hxx @@ -0,0 +1,53 @@ +/************************************************************************* + * + * 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_ENUMERATION_HXX +#define SD_SLIDESORTER_ENUMERATION_HXX + +#include <memory> + +namespace sd { namespace slidesorter { namespace model { + + +/** Interface to generic enumerations. Designed to operate on shared + pointers. Therefore GetNextElement() returns T and not T&. +*/ +template <class T> +class Enumeration +{ +public: + virtual bool HasMoreElements (void) const = 0; + /** Returns T instead of T& so that it can handle shared pointers. + */ + virtual T GetNextElement (void) = 0; + virtual void Rewind (void) = 0; + virtual ::std::auto_ptr<Enumeration<T> > Clone (void) = 0; +}; + +} } } // end of namespace ::sd::slidesorter::model + +#endif diff --git a/sd/source/ui/slidesorter/inc/model/SlsPageDescriptor.hxx b/sd/source/ui/slidesorter/inc/model/SlsPageDescriptor.hxx new file mode 100755 index 000000000000..81877ce7465c --- /dev/null +++ b/sd/source/ui/slidesorter/inc/model/SlsPageDescriptor.hxx @@ -0,0 +1,215 @@ +/************************************************************************* + * + * 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_DESCRIPTOR_HXX +#define SD_SLIDESORTER_PAGE_DESCRIPTOR_HXX + +#include <com/sun/star/drawing/XDrawPage.hpp> +#include <tools/gen.hxx> +#include <tools/link.hxx> +#include <vcl/bitmap.hxx> +#include <sfx2/viewfrm.hxx> + +#include <memory> +#include <boost/enable_shared_from_this.hpp> + +class SdPage; + +namespace sdr { namespace contact { +class ObjectContact; +} } + +namespace sd { namespace slidesorter { namespace view { +class PageObject; +class PageObjectViewObjectContact; +} } } + +namespace sd { namespace slidesorter { namespace controller { +class PageObjectFactory; +} } } + +namespace sd { namespace slidesorter { namespace model { + +class SlideRenderer; + +namespace css = ::com::sun::star; + +/** Each PageDescriptor object represents the preview of one draw page, + slide, or master page of a Draw or Impress document as they are displayed + in the slide sorter. This class gives access to some associated + information like prerendered preview or position on the screen. + + <p>Bounding boxes of page objects come in four varieties: + Model and screen/pixel coordinates and the bounding boxes of the actual + page objects and the larger bounding boxes that include page names and + fade symbol.</p> +*/ +class PageDescriptor + : public ::boost::enable_shared_from_this<PageDescriptor> +{ +public: + /** Create a PageDescriptor for the given SdPage object. + @param rxPage + The page that is represented by the new PageDescriptor object. + @param pPage + The page pointer can in some situations not be detected from + rxPage, e.g. after undo of page deletion. Therefore supply it + seperately. + @param nIndex + This index is displayed in the view as page number. It is not + necessaryily the page index (not even when you add or subtract 1 + or use (x-1)/2 magic). + */ + PageDescriptor ( + const css::uno::Reference<css::drawing::XDrawPage>& rxPage, + SdPage* pPage, + const sal_Int32 nIndex, + const controller::PageObjectFactory& rPageObjectFactory); + + ~PageDescriptor (void); + + /** Return the page that is represented by the descriptor as SdPage pointer . + */ + SdPage* GetPage (void) const; + + /** Return the page that is represented by the descriptor as XDrawPage reference. + */ + css::uno::Reference<css::drawing::XDrawPage> GetXDrawPage (void) const; + + /** Return the page shape that is used for visualizing the page. + */ + view::PageObject* GetPageObject (void); + void ReleasePageObject (void); + + /** Return <TRUE/> when the page object is fully or parially visible. */ + bool IsVisible (void) const; + + /** Set the visible state that is returned by the IsVisible() method. + This method is typically called by the view who renders the object + onto the screen. + */ + void SetVisible (bool bVisible); + + /** Make sure that the page is selected and return whether the + selection state changed. + */ + bool Select (void); + /** Make sure that the page is not selected and return whether the + selection state changed. + */ + bool Deselect (void); + + /** Return whether the page is selected (and thus bypasses the internal + mbIsSelected flag. + */ + bool IsSelected (void) const; + + /** Set the internal mbIsSelected flag to the selection state of the + page. Use this method to synchronize a page descriptor with the + page it describes and determine whether a redraw to update the + selection indicator is necessary. + @return + When the two selection states were different <TRUE/> is + returned. When they were the same this method returns + <FALSE/>. + */ + bool UpdateSelection (void); + + bool IsFocused (void) const; + void SetFocus (void); + void RemoveFocus (void); + + view::PageObjectViewObjectContact* GetViewObjectContact (void) const; + + void SetViewObjectContact ( + view::PageObjectViewObjectContact* pViewObjectContact); + + /** Return the currently used page object factory. + */ + const controller::PageObjectFactory& GetPageObjectFactory (void) const; + + /** Replace the current page object factory by the given one. + */ + void SetPageObjectFactory (const controller::PageObjectFactory& rFactory); + + void SetModelBorder (const SvBorder& rBorder); + SvBorder GetModelBorder (void) const; + + /** The size of the area in which the page number is displayed is + calculated by the SlideSorterView and then stored in the page + descriptors so that the contact objects can access them. The + contact objects can not calculate them on demand because the total + number of slides is needed to do that and this number is not known + to the contact objects. + */ + void SetPageNumberAreaModelSize (const Size& rSize); + Size GetPageNumberAreaModelSize (void) const; + + /** Set or revoke the state of this slide being the current slide. + */ + void SetIsCurrentPage (const bool bIsCurrent); + +private: + SdPage* mpPage; + css::uno::Reference<css::drawing::XDrawPage> mxPage; + /** This index is displayed as page number in the view. It may or may + not be actual page index. + */ + const sal_Int32 mnIndex; + + /// The factory that is used to create PageObject objects. + const controller::PageObjectFactory* mpPageObjectFactory; + + /** The page object will be destroyed by the page into which it has + been inserted. + */ + view::PageObject* mpPageObject; + + bool mbIsSelected; + bool mbIsVisible; + bool mbIsFocused; + bool mbIsCurrent; + + view::PageObjectViewObjectContact* mpViewObjectContact; + + /// The borders in model coordinates arround the page object. + SvBorder maModelBorder; + + /// The size of the page number area in model coordinates. + Size maPageNumberAreaModelSize; + + // Do not use the copy constructor operator. It is not implemented. + PageDescriptor (const PageDescriptor& rDescriptor); + + // Do not use the assignment operator. It is not implemented + // (mrPage can not be assigned). + PageDescriptor& operator= (const PageDescriptor& rDescriptor); +}; + +} } } // end of namespace ::sd::slidesorter::model + +#endif diff --git a/sd/source/ui/slidesorter/inc/model/SlsPageEnumeration.hxx b/sd/source/ui/slidesorter/inc/model/SlsPageEnumeration.hxx new file mode 100644 index 000000000000..3586eead3532 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/model/SlsPageEnumeration.hxx @@ -0,0 +1,127 @@ +/************************************************************************* + * + * 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_ENUMERATION_HXX +#define SD_SLIDESORTER_PAGE_ENUMERATION_HXX + +#include "pres.hxx" + + +#include "model/SlsEnumeration.hxx" +#include "model/SlsSharedPageDescriptor.hxx" + +#include <boost/function.hpp> +#include <memory> + +namespace sd { namespace slidesorter { namespace model { + +class SlideSorterModel; + + +/** Public class of page enumerations that delegates its calls to an + implementation object that can filter pages by using a given predicate. + + @see PageEnumerationProvider + The PageEnumerationProvider has methods for creating different types + of page enumerations. +*/ +class PageEnumeration + : public Enumeration<SharedPageDescriptor> +{ +public: + /** Create a new page enumeration that enumerates a subset of the pages + of the given model. + @param rModel + The new page enumeration enumerates the pages of this model. + @param rPredicate + This predicate determines which pages to include in the + enumeration. Pages for which rPredicate returns <FALSE/> are + exclude. + */ + typedef ::boost::function<bool(const SharedPageDescriptor&)> PagePredicate; + static PageEnumeration Create ( + const SlideSorterModel& rModel, + const PagePredicate& rPredicate); + + /** This copy constructor creates a copy of the given enumeration. + */ + PageEnumeration (const PageEnumeration& rEnumeration); + + virtual ~PageEnumeration(); + + /** Create a new enumeration object. The ownership of the + implementation object goes to the new object. Use this copy + constructor only when you know what you are doing. When in doubt, + use the one argument version. + @param bCloneImpl + When <TRUE/> is given this constructor behaves exactly like its + one argument version. When <FALSE/> is given then the + implementation object is not copied but moved from the given + enumeration to the newly created one. The given enumeration + thus becomes empty. + */ + PageEnumeration (PageEnumeration& rEnumeration, bool bCloneImpl); + + /** Create and return an exact copy of the called object. + */ + virtual ::std::auto_ptr<Enumeration<SharedPageDescriptor> > Clone (void); + + PageEnumeration& operator= (const PageEnumeration& rEnumeration); + + /** Return <TRUE/> when the enumeration has more elements, i.e. it is + save to call GetNextElement() at least one more time. + */ + virtual bool HasMoreElements (void) const; + + /** Return the next element of the enumeration. Call the + HasMoreElements() before to make sure that there exists at least one + more element. Calling this method with HasMoreElements() returning + <FALSE/> is an error. + */ + virtual SharedPageDescriptor GetNextElement (void); + + /** Rewind the enumeration so that the next call to GetNextElement() + will return its first element. + */ + virtual void Rewind (void); + +private: + /// Implementation object. + ::std::auto_ptr<Enumeration<SharedPageDescriptor> > mpImpl; + + /** This constructor expects an implementation object that holds + the predicate that filters the pages. + */ + PageEnumeration (::std::auto_ptr<Enumeration<SharedPageDescriptor> > pImpl); + + // Default constructor not implemented. + PageEnumeration (void); +}; + +} } } // end of namespace ::sd::slidesorter::model + +#endif diff --git a/sd/source/ui/slidesorter/inc/model/SlsPageEnumerationProvider.hxx b/sd/source/ui/slidesorter/inc/model/SlsPageEnumerationProvider.hxx new file mode 100644 index 000000000000..8aa51174b166 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/model/SlsPageEnumerationProvider.hxx @@ -0,0 +1,60 @@ +/************************************************************************* + * + * 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_ENUMERATION_PROVIDER_HXX +#define SD_SLIDESORTER_PAGE_ENUMERATION_PROVIDER_HXX + +#include "model/SlsPageEnumeration.hxx" + +namespace sd { namespace slidesorter { namespace model { + +class SlideSorterModel; + +/** Collection of methods that create enumeration of slides. +*/ +class PageEnumerationProvider +{ +public: + /** The returned enumeration of slides iterates over all slides of the + given model. + */ + static PageEnumeration CreateAllPagesEnumeration (const SlideSorterModel& rModel); + + /** The returned enumeration of slides iterates over the currently + selected slides of the given model. + */ + static PageEnumeration CreateSelectedPagesEnumeration (const SlideSorterModel& rModel); + + /** The returned enumeration of slides iterates over the slides + (partially) inside the visible area. + */ + static PageEnumeration CreateVisiblePagesEnumeration (const SlideSorterModel& rModel); +}; + +} } } // end of namespace ::sd::slidesorter::model + +#endif diff --git a/sd/source/ui/slidesorter/inc/model/SlsSharedPageDescriptor.hxx b/sd/source/ui/slidesorter/inc/model/SlsSharedPageDescriptor.hxx new file mode 100644 index 000000000000..6dba8a848ae1 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/model/SlsSharedPageDescriptor.hxx @@ -0,0 +1,41 @@ +/************************************************************************* + * + * 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_SHARED_PAGE_DESCRIPTOR_HXX +#define SD_SLIDESORTER_SHARED_PAGE_DESCRIPTOR_HXX + +#include <boost/shared_ptr.hpp> + +namespace sd { namespace slidesorter { namespace model { + +class PageDescriptor; + +typedef ::boost::shared_ptr<PageDescriptor> SharedPageDescriptor; + +} } } // end of namespace ::sd::slidesorter::model + +#endif diff --git a/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx b/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx new file mode 100755 index 000000000000..2ef520b1df89 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx @@ -0,0 +1,307 @@ +/************************************************************************* + * + * 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_VIEW_HXX +#define SD_SLIDESORTER_SLIDE_SORTER_VIEW_HXX + +#include "View.hxx" + +#include "model/SlsSharedPageDescriptor.hxx" + +#include <sfx2/viewfrm.hxx> +#include "pres.hxx" +#include <tools/gen.hxx> +#include <memory> +#include <boost/shared_ptr.hpp> + +class Point; + +namespace sdr { namespace contact { +class ObjectContact; +} } + +namespace sd { namespace slidesorter { +class SlideSorter; +} } + +namespace sd { namespace slidesorter { namespace controller { +class SlideSorterController; +} } } + +namespace sd { namespace slidesorter { namespace cache { +class PageCache; +} } } + +namespace sd { namespace slidesorter { namespace model { +class SlideSorterModel; +} } } + +namespace sd { namespace slidesorter { namespace view { + +class Layouter; +class ViewOverlay; + + +class SlideSorterView + : public View +{ +public: + TYPEINFO(); + + /** Create a new view for the slide sorter. + @param rViewShell + This reference is simply passed to the base class and not used + by this class. + + */ + SlideSorterView (SlideSorter& rSlideSorter); + + virtual ~SlideSorterView (void); + + enum Orientation { HORIZONTAL, VERTICAL }; + void SetOrientation (const Orientation eOrientation); + Orientation GetOrientation (void) const; + + void RequestRepaint (void); + void RequestRepaint (const model::SharedPageDescriptor& rDescriptor); + + Rectangle GetModelArea (void); + + enum CoordinateSystem { CS_SCREEN, CS_MODEL }; + enum BoundingBoxType { BBT_SHAPE, BBT_INFO }; + + /** Return the rectangle that bounds the page object represented by the + given page descriptor. + @param rDescriptor + The descriptor of the page for which to return the bounding box. + @param eCoordinateSystem + Specifies whether to return the screen or model coordinates. + @param eBoundingBoxType + Specifies whether to return the bounding box of only the page + object or the one that additionally includes other displayed + information like page name and fader symbol. + */ + Rectangle GetPageBoundingBox ( + const model::SharedPageDescriptor& rpDescriptor, + CoordinateSystem eCoordinateSystem, + BoundingBoxType eBoundingBoxType) const; + + /** Return the rectangle that bounds the page object represented by the + given page index . + @param nIndex + The index of the page for which to return the bounding box. + @param eCoordinateSystem + Specifies whether to return the screen or model coordinates. + @param eBoundingBoxType + Specifies whether to return the bounding box of only the page + object or the one that additionally includes other displayed + information like page name and fader symbol. + */ + Rectangle GetPageBoundingBox ( + sal_Int32 nIndex, + CoordinateSystem eCoordinateSystem, + BoundingBoxType eBoundingBoxType) const; + + /** Return the index of the page that is rendered at the given position. + @param rPosition + The position is expected to be in pixel coordinates. + @return + The returned index is -1 when there is no page object at the + given position. + */ + sal_Int32 GetPageIndexAtPoint (const Point& rPosition) const; + + view::Layouter& GetLayouter (void); + + virtual void ModelHasChanged (void); + + void LocalModelHasChanged(void); + + /** This method is typically called before a model change takes place. + All references to model data are released. PostModelChange() has to + be called to complete the handling of the model change. When the + calls to Pre- and PostModelChange() are very close to each other you + may call HandleModelChange() instead. + */ + void PreModelChange (void); + + /** This method is typically called after a model change took place. + References to model data are re-allocated. Call this method only + after PreModelChange() has been called. + */ + void PostModelChange (void); + + /** This method is a convenience function that simply calls + PreModelChange() and then PostModelChange(). + */ + void HandleModelChange (void); + + void HandleDrawModeChange (void); + + virtual void Resize (void); + virtual void CompleteRedraw (OutputDevice* pDevice, const Region& rPaintArea, sdr::contact::ViewObjectContactRedirector* pRedirector = 0L); + virtual void InvalidateOneWin ( + ::Window& rWindow); + virtual void InvalidateOneWin ( + ::Window& rWindow, + const Rectangle& rPaintArea ); + + void Layout (void); + /** This tells the view that it has to re-determine the visibility of + the page objects before painting them the next time. + */ + void InvalidatePageObjectVisibilities (void); + + /** Return the window to which this view renders its output. + */ + ::sd::Window* GetWindow (void) const; + + + ::boost::shared_ptr<cache::PageCache> GetPreviewCache (void); + + view::ViewOverlay& GetOverlay (void); + + /** Set the bounding box of the insertion marker in model coordinates. + + It will be painted as a dark rectangle that fills the given box. + */ + void SetInsertionMarker (const Rectangle& rBBox); + + /** Specify whether the insertion marker will be painted or not. + */ + void SetInsertionMarkerVisibility (bool bVisible); + + /** Set the size and position of the selection rectangle. + + It will be painted as a dashed rectangle. + */ + void SetSelectionRectangle (const Rectangle& rBox); + + /** Specify whether the selection rectangle will be painted or not. + */ + void SetSelectionRectangleVisibility (bool bVisible); + + typedef ::std::pair<sal_Int32,sal_Int32> PageRange; + /** Return the range of currently visible page objects including the + first and last one in that range. + @return + The returned pair of page object indices is empty when the + second index is lower than the first. + */ + PageRange GetVisiblePageRange (void); + + /** Add a shape to the page. Typically used from inside + PostModelChange(). + */ + void AddSdrObject (SdrObject& rObject); + + /** Add a listener that is called when the set of visible slides. + @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 AddVisibilityChangeListener (const Link& rListener); + + /** Remove a listener that is called when the set of visible slides changes. + @param rListener + It is save to pass a listener that was not added or has been + removed previously. Such calls are ignored. + */ + void RemoveVisibilityChangeListener (const Link& rListener); + +protected: + virtual void Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint); + +private: + SlideSorter& mrSlideSorter; + model::SlideSorterModel& mrModel; + /// This model is used for the maPage object and for the page visualizers + /// (SdrPageObj) + SdrModel maPageModel; + /** This page acts as container for the page objects that represent the + pages of the document that is represented by the SlideSorterModel. + */ + SdrPage* mpPage; + ::std::auto_ptr<Layouter> mpLayouter; + bool mbPageObjectVisibilitiesValid; + ::boost::shared_ptr<cache::PageCache> mpPreviewCache; + ::std::auto_ptr<ViewOverlay> mpViewOverlay; + + int mnFirstVisiblePageIndex; + int mnLastVisiblePageIndex; + + SvBorder maPagePixelBorder; + + bool mbModelChangedWhileModifyEnabled; + + Size maPreviewSize; + + bool mbPreciousFlagUpdatePending; + + Size maPageNumberAreaModelSize; + SvBorder maModelBorder; + + Orientation meOrientation; + + ::std::vector<Link> maVisibilityChangeListeners; + + /** Adapt the coordinates of the given bounding box according to the + other parameters. + @param rModelPageObjectBoundingBox + Bounding box given in model coordinates that bounds only the + page object. + @param eCoordinateSystem + When CS_SCREEN is given then the bounding box is converted into + screen coordinates. + @param eBoundingBoxType + When BBT_INFO is given then the bounding box is made larger so + that it encloses all relevant displayed information. + */ + void AdaptBoundingBox ( + Rectangle& rModelPageObjectBoundingBox, + CoordinateSystem eCoordinateSystem, + BoundingBoxType eBoundingBoxType) const; + + /** Determine the visibility of all page objects. + */ + void DeterminePageObjectVisibilities (void); + + /** Update the page borders used by the layouter by using those returned + by the first page. Call this function when the model changes, + especially when the number of pages changes, or when the window is + resized as the borders may be device dependent. + */ + void UpdatePageBorders (void); + + void UpdatePreciousFlags (void); +}; + + +} } } // end of namespace ::sd::slidesorter::view + +#endif diff --git a/sd/source/ui/slidesorter/inc/view/SlsFontProvider.hxx b/sd/source/ui/slidesorter/inc/view/SlsFontProvider.hxx new file mode 100644 index 000000000000..2b71c0e50152 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/view/SlsFontProvider.hxx @@ -0,0 +1,94 @@ +/************************************************************************* + * + * 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_VIEW_FONT_PROVIDER_HXX +#define SD_SLIDESORTER_VIEW_FONT_PROVIDER_HXX + +#include "tools/SdGlobalResourceContainer.hxx" + +#include <boost/shared_ptr.hpp> +#include <vcl/mapmod.hxx> + +class Font; +class OutputDevice; +class VclWindowEvent; + +namespace sd { namespace slidesorter { namespace view { + +/** This simple singleton class provides fonts that are scaled so that they + have a fixed height on the given device regardless of its map mode. +*/ +class FontProvider + : public SdGlobalResource +{ +public: + typedef ::boost::shared_ptr<Font> SharedFontPointer; + + /** Return the single instance of this class. Throws a RuntimeException + when no instance can be created. + */ + static FontProvider& Instance (void); + + /** Return a font that is scaled according to the current map mode of + the given device. Repeated calls with a device, not necessarily the + same device, with the same map mode will return the same font. The + first call with a different map mode will release the old font and + create a new one that is correctly scaled. + */ + SharedFontPointer GetFont (const OutputDevice& rDevice); + + /** Call this method to tell an object to release its currently used + font. The next call to GetFont() will then create a new one. + Typically called after a DataChange event when for instance a system + font has been modified. + */ + void Invalidate (void); + +private: + static FontProvider* mpInstance; + + /** The font that was created by a previous call to GetFont(). It is + replaced by another one only when GetFont() is called with a device + with a different map mode or by a call to Invalidate(). + */ + SharedFontPointer maFont; + /** The mape mode for which maFont was created. + */ + MapMode maMapMode; + + FontProvider (void); + virtual ~FontProvider (void); + + // Copy constructor is not implemented. + FontProvider (const FontProvider&); + // Assignment operator is not implemented. + FontProvider& operator= (const FontProvider&); +}; + +} } } // end of namespace ::sd::slidesorter::view + +#endif diff --git a/sd/source/ui/slidesorter/inc/view/SlsLayouter.hxx b/sd/source/ui/slidesorter/inc/view/SlsLayouter.hxx new file mode 100755 index 000000000000..9b1fd996e9c0 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/view/SlsLayouter.hxx @@ -0,0 +1,382 @@ +/************************************************************************* + * + * 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_VIEW_LAYOUTER_HXX +#define SD_SLIDESORTER_VIEW_LAYOUTER_HXX + +#include <sal/types.h> +#include <tools/fract.hxx> +#include <vcl/mapmod.hxx> +#include <vector> +#include <utility> + +class MapMode; +class OutputDevice; +class Size; + +namespace sd { namespace slidesorter { namespace view { + +/** Calculate the size and position of page objects displayed by a slide + sorter. The layouter takes into account various input values: + 1.) Size of the window in which the slide sorter is displayed. + 2.) Desired and minimal and maximal widths of page objects. + 3.) Minimal and maximal number of columns. + 4.) Vertical and horizontal gaps between objects in adjacent columns. + 5.) Borders arround every page object. + 6.) Vertical and horizontal borders between enclosing page and outer + page objects. + From these it calculates various output values: + 1.) The width of page objects. + 2.) The number of columns. + 3.) The size of the enclosing page. + + <p>Sizes and lengths are all in pixel except where explicitly stated + otherwise.</p> + + <p>The GetIndex... methods may return indices that are larger than or + equal to (zero based) the number of pages. This is so because the + number of pages is not known to the class instances. Indices are + calculated with reference to the general grid layout of page + objects.</p> +*/ +class Layouter +{ +public: + Layouter (void); + ~Layouter (void); + + /** Set the horizontal and vertical borders in pixel coordinates between + the enclosing window and page objects. The borders may be painted + larger then the given values when the space for the insertion marker + is not sufficient. + @param nLeftBorder + Use a negative value to indicate that the left border size + shall not be modified. A value of 10 is the default. + @param nRightBorder + Use a negative value to indicate that the right border size + shall not be modified. A value of 10 is the default. + @param nTopBorder + Use a negative value to indicate that the top border size + shall not be modified. A value of 10 is the default. + @param nBottomBorder + Use a negative value to indicate that the bottom border size + shall not be modified. A value of 10 is the default. + */ + void SetBorders (sal_Int32 nLeftBorder, sal_Int32 nRightBorder, + sal_Int32 nTopBorder, sal_Int32 nBottomBorder); + + /** Set the borders arround every page object. + @param nLeftBorder + A negative value indicates that the left border shall not be + modified. A value of 0 is the default. + @param nRightBorder + A negative value indicates that the left border shall not be + modified. A value of 0 is the default. + @param nTopBorder + A negative value indicates that the left border shall not be + modified. A value of 0 is the default. + @param nBottomBorder + A negative value indicates that the left border shall not be + modified. A value of 0 is the default. + */ + void SetPageBorders (sal_Int32 nLeftBorder, sal_Int32 nRightBorder, + sal_Int32 nTopBorder, sal_Int32 nBottomBorder); + + /** Set the interval of valid column counts. When nMinimalColumnCount + <= nMaximalColumnCount is not fullfilled then the call is ignored. + @param nMinimalColumnCount + The default value is 1. The question whether higher values make + any sense is left to the caller. + @param nMaximalColumnCount + The default value is 5. + */ + void SetColumnCount (sal_Int32 nMinimalColumnCount, + sal_Int32 nMaximalColumnCount); + + /** Central method of this class. It takes the input values and + calculates the output values. Both given sizes must not be 0 in any + dimension or the call is ignored. + @param rWindowSize + The size of the window in pixels that the slide sorter is + displayed in. + @param rPageObjectSize + Size of each page in model coordinates. + @param pDevice + The map mode of this output device is adapted to the new layout + of the page objects. + @return + The return value indicates whether the Get... methods can be + used to obtain valid values (<TRUE/>). + */ + bool RearrangeHorizontal ( + const Size& rWindowSize, + const Size& rPageObjectSize, + OutputDevice* pDevice, + const sal_uInt32 nPageCount); + bool RearrangeVertical ( + const Size& rWindowSize, + const Size& rPageObjectSize, + OutputDevice* pDevice); + + /** Change the zoom factor. This does not change the general layout + (number of columns). + */ + void SetZoom (Fraction nZoomFactor, OutputDevice* pDevice); + + /** Return the number of columns. + */ + sal_Int32 GetColumnCount (void) const; + + /** Return the scale factor that can be set at the map mode of the + output window. + */ + Fraction GetScaleFactor (void) const; + + Size GetPageObjectSize (void) const; + + /** Return the bounding box in model coordinates of the nIndex-th page + object. + */ + Rectangle GetPageObjectBox (sal_Int32 nIndex) const; + + /** Return the bounding box in model coordinates of the page that + contains the given amount of page objects. + */ + Rectangle GetPageBox (sal_Int32 nObjectCount) const; + + /** Return the rectangle that bounds the insertion marker that is + specified by the parameters. + @param nIndex + Index of the page object from which the position of the marker + will be calculated. + @param bVertical + When <TRUE/> then the insertion marker will be calculated with a + vertical orientation positioned to the left or right of the + specified page object. A horizontal orientation is indicated by + <FALSE/>. In this case the marker will be positioned above or + below the page object. + @param bLeftOrTop + This flag indicates whether the insertion marker will be + positioned above or to the left (<TRUE/>) the page object. When + <FALSE/> is given then the marker will be positioned below or to + the right of the page object. + */ + Rectangle GetInsertionMarkerBox ( + sal_Int32 nIndex, + bool bVertical, + bool bLeftOrTop) const; + + /** Return the index of the first fully or partially visible page + object. This takes into account only the vertical dimension. + */ + sal_Int32 GetIndexOfFirstVisiblePageObject ( + const Rectangle& rVisibleArea) const; + + /** Return the index of the last fully or partially visible page + object. This takes into account only the vertical dimension. + @return + The returned index may be larger than the number of existing + page objects. + */ + sal_Int32 GetIndexOfLastVisiblePageObject ( + const Rectangle& rVisibleArea) const; + + /** Return the index of the page object that is rendered at the given + point. + @param rPosition + The position is expected to be in model coordinates relative to + the page origin. + @param bIncludePageBorders + When <TRUE/> then include the page borders into the calculation, + i.e. when a point lies in the border of a page object but not on + the actual page area the index of that page is returned; + otherwise -1 would be returned to indicate that no page object + has been hit. + @return + The returned index may be larger than the number of existing + page objects. + */ + sal_Int32 GetIndexAtPoint ( + const Point& rModelPosition, + bool bIncludePageBorders = false) const; + + /** Return the page index of where to do an insert operation when the + user would release the the mouse button at the given position after + a drag operation. + @param rPosition + The position in the model coordinate system for which to + determine the insertion page index. The position does not have + to be over a page object to return a valid value. + @param bAllowVerticalPosition + When this flag is <TRUE/> then the vertical gaps between rows + may be taken into account for calculating the insertion index as + well as the horizontal gaps between columns. This will happen + only when there is only one column. + (better name, anyone?) + @return + Returns the page index, as accepted by the slide sorter model, + of the page after which an insertion would take place. An index + of 0 means that insertion will take place before the first page, + An index equal to or greater than the page count means to insert + after the last page. + A value of -1 indicates that no valid insertion index exists for + the given point. + */ + sal_Int32 GetInsertionIndex ( + const Point& rModelPosition, + bool bAllowVerticalPosition) const; + + typedef ::std::pair<double,double> DoublePoint; + /** Transform a point given in model coordinates in to layouter + coordinates. Layouter coordinates are floating point numbers where + the integer part denotes a row or a column and the part after the + decimal point is a relative position in that row or column. + */ + DoublePoint ConvertModelToLayouterCoordinates ( + const Point& rModelPoint) const; + + /** Transform a point given in layouter coordinates to model + coordinates. See ConvertModelToLayouterCoordinates for a + description of layouter coordinates. + */ + Point ConvertLayouterToModelCoordinates ( + const DoublePoint&rLayouterPoint) const; + + typedef ::std::vector<Rectangle> BackgroundRectangleList; + +private: + class ScreenAndModelValue {public: + sal_Int32 mnScreen,mnModel; + explicit ScreenAndModelValue (sal_Int32 nScreen, sal_Int32 nModel = 0) + : mnScreen(nScreen),mnModel(nModel) {} + }; + ScreenAndModelValue mnRequestedLeftBorder; + ScreenAndModelValue mnRequestedRightBorder; + ScreenAndModelValue mnRequestedTopBorder; + ScreenAndModelValue mnRequestedBottomBorder; + ScreenAndModelValue mnLeftBorder; + ScreenAndModelValue mnRightBorder; + ScreenAndModelValue mnTopBorder; + ScreenAndModelValue mnBottomBorder; + ScreenAndModelValue mnLeftPageBorder; + ScreenAndModelValue mnRightPageBorder; + ScreenAndModelValue mnTopPageBorder; + ScreenAndModelValue mnBottomPageBorder; + ScreenAndModelValue mnVerticalGap; + ScreenAndModelValue mnHorizontalGap; + ScreenAndModelValue mnInsertionMarkerThickness; + ScreenAndModelValue mnTotalVerticalGap; + ScreenAndModelValue mnTotalHorizontalGap; + sal_Int32 mnMinimalWidth; + sal_Int32 mnPreferredWidth; + sal_Int32 mnMaximalWidth; + sal_Int32 mnMinimalColumnCount; + sal_Int32 mnMaximalColumnCount; + sal_Int32 mnColumnCount; + Size maPageObjectModelSize; + Size maPageObjectPixelSize; + + BackgroundRectangleList maBackgroundRectangleList; + + enum GapMembership { GM_NONE, GM_PREVIOUS, GM_BOTH, GM_NEXT, + GM_PAGE_BORDER}; + + /** Calculate the row that the point with the given vertical coordinate + is over. The horizontal component is ignored. + @param nYPosition + Vertical position in model coordinates. + @param bIncludeBordersAndGaps + When this flag is <TRUE/> then the area of borders and gaps are + interpreted as belonging to one of the rows. + @param eGapMembership + Specifies to what row the gap areas belong. Here GM_NONE + corresponds to bIncludeBordersAndGaps being <FALSE/>. When + GM_BOTH is given then the upper half is associated to the row + above and the lower half to the row below. Values of + GM_PREVIOUS and GM_NEXT associate the whole gap area with the + row above or below respectively. + */ + sal_Int32 GetRowAtPosition ( + sal_Int32 nYPosition, + bool bIncludeBordersAndGaps, + GapMembership eGapMembership = GM_NONE) const; + + /** Calculate the column that the point with the given horizontal + coordinate is over. The verical component is ignored. + @param nXPosition + Horizontal position in model coordinates. + @param bIncludeBordersAndGaps + When this flag is <TRUE/> then the area of borders and gaps are + interpreted as belonging to one of the columns. + @param eGapMembership + Specifies to what column the gap areas belong. Here GM_NONE + corresponds to bIncludeBordersAndGaps being <FALSE/>. When + GM_BOTH is given then the left half is associated with the + column at the left and the right half with the column to the + right. Values of GM_PREVIOUS and GM_NEXT associate the whole + gap area with the column to the left or right respectively. + */ + sal_Int32 GetColumnAtPosition ( + sal_Int32 nXPosition, + bool bIncludeBordersAndGaps, + GapMembership eGapMembership = GM_NONE) const; + + /** This method is typically called from GetRowAtPosition() and + GetColumnAtPosition() to handle a position that lies inside the gap + between two adjacent rows or columns. + @param nDistanceIntoGap + Vertical distance from the bottom of the upper row down into the + gap or or horizontal distance from the right edge right into the + gap. + @param eGapMemberhship + This value decides what areas in the gap belong to which (or no) + row or column. + @param nIndex + The row index of the upper row or the column index of the left + column. + @param nLeftOrTopPageBorder + Width in model coordinates of the border the the right of or + below a page. + @param nGap + Width or height of the gap in model coordiantes between the + page borders. + @return + Returns either the index of the upper row (as given as nRow), the + index of the lower row (nRow+1) or -1 to indicate that the + position belongs to no row. + */ + sal_Int32 ResolvePositionInGap ( + sal_Int32 nDistanceIntoGap, + GapMembership eGapMembership, + sal_Int32 nIndex, + sal_Int32 nLeftOrTopPageBorder, + sal_Int32 nGap) const; +}; + +} } } // end of namespace ::sd::slidesorter::view + +#endif diff --git a/sd/source/ui/slidesorter/inc/view/SlsPageObject.hxx b/sd/source/ui/slidesorter/inc/view/SlsPageObject.hxx new file mode 100644 index 000000000000..0f4ede6216c1 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/view/SlsPageObject.hxx @@ -0,0 +1,65 @@ +/************************************************************************* + * + * 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_HXX +#define SD_SLIDESORTER_PAGE_OBJECT_HXX + +#include "model/SlsSharedPageDescriptor.hxx" + +#include <svx/svdopage.hxx> + +namespace sd { namespace slidesorter { namespace view { + + +/** This sub class of the SdrPageObject exists to create the view contact + and indirectly to create view-object-contact objects. +*/ +class PageObject + : public SdrPageObj +{ +public: + PageObject ( + const Rectangle& rRect, + SdrPage* pPage, + const model::SharedPageDescriptor& rpDescriptor); + + virtual ~PageObject (void); + + model::SharedPageDescriptor GetDescriptor (void) const; + +private: + model::SharedPageDescriptor mpDescriptor; + +protected: + virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact(); +}; + + + +} } } // end of namespace ::sd::slidesorter::view + +#endif diff --git a/sd/source/ui/slidesorter/inc/view/SlsPageObjectViewContact.hxx b/sd/source/ui/slidesorter/inc/view/SlsPageObjectViewContact.hxx new file mode 100755 index 000000000000..31899d3b3e44 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/view/SlsPageObjectViewContact.hxx @@ -0,0 +1,89 @@ +/************************************************************************* + * + * 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_VIEW_CONTACT_HXX +#define SD_SLIDESORTER_PAGE_OBJECT_VIEW_CONTACT_HXX + +#include "model/SlsSharedPageDescriptor.hxx" +#include <svx/sdtakitm.hxx> +#include <svx/sdr/contact/viewcontactofpageobj.hxx> + +class SdrPageObj; + +namespace sdr {namespace contact { +class ViewObjectContact; +class ObjectContact; +} } + +namespace sd { namespace slidesorter { namespace view { + +/** Details: + This class has to provide the bounding box but can not determine it + fully because it has no access to the output device. It therefore + retrieves some of the necessary data, the border, from the + PageDescriptor which acts here as persistent storage. +*/ +class PageObjectViewContact + : public ::sdr::contact::ViewContactOfPageObj +{ +public: + PageObjectViewContact ( + SdrPageObj& rPageObj, + const model::SharedPageDescriptor& rpDescriptor); + ~PageObjectViewContact (void); + + /** Create a ViewObjectContact object that buffers its output in a + bitmap. + @return + Ownership of the new object passes to the caller. + */ + virtual ::sdr::contact::ViewObjectContact& + CreateObjectSpecificViewObjectContact( + ::sdr::contact::ObjectContact& rObjectContact); + + const SdrPage* GetPage (void) const; + + SdrPageObj& GetPageObject (void) const; + + virtual void ActionChanged (void); + +protected: + // create graphical visualisation data + virtual drawinglayer::primitive2d::Primitive2DSequence createViewIndependentPrimitive2DSequence() const; + +private: + /** This flag is set to <TRUE/> when the destructor is called to + indicate that further calls made to it must not call outside. + */ + bool mbInDestructor; + + model::SharedPageDescriptor mpDescriptor; +}; + +} } } // end of namespace ::sd::slidesorter::view + +#endif diff --git a/sd/source/ui/slidesorter/inc/view/SlsPageObjectViewObjectContact.hxx b/sd/source/ui/slidesorter/inc/view/SlsPageObjectViewObjectContact.hxx new file mode 100644 index 000000000000..7e884fc54797 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/view/SlsPageObjectViewObjectContact.hxx @@ -0,0 +1,225 @@ +/************************************************************************* + * + * 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_VIEW_OBJECT_CONTACT_HXX +#define SD_SLIDESORTER_PAGE_OBJECT_VIEW_OBJECT_CONTACT_HXX + +#include <svx/sdr/contact/viewobjectcontactofpageobj.hxx> +#include "model/SlsSharedPageDescriptor.hxx" +#include <svx/sdr/contact/viewobjectcontact.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/image.hxx> +#include <sfx2/viewfrm.hxx> +#include <memory> +#include <boost/shared_ptr.hpp> + +class SdrPage; + +namespace sdr { namespace contact { +class DisplayInfo; +} } + +namespace sd { namespace slidesorter { namespace cache { +class PageCache; +} } } + +namespace sd { namespace slidesorter { namespace controller { +class Properties; +} } } + +namespace sd { namespace slidesorter { namespace view { + +class SlideSorterView; + +/** This object-view-contact of page objects maintains a preview bitmap for + the page to speed up redraws of the same. It does so by colaborating + with a cache of bitmaps (see ../cache). +*/ + +// needs to be derived from ViewObjectContactOfPageObj, else the calls to parent implementations +// would use ViewObjectContact and thus not enable e.g. the correct primitive creation +// for view-independent printer output +// changed: ViewObjectContact -> ViewObjectContactOfPageObj + +class PageObjectViewObjectContact : public ::sdr::contact::ViewObjectContactOfPageObj +{ +public: + /** Create a new view-object-contact object for the given contact + objects of both model and view. + @param pCache + The caller should provide a pointer to a preview cache, if + available. If given then the cache is used to control when to + create a preview and to store it. If NULL is given then the + preview is created every time when requested. + */ + PageObjectViewObjectContact ( + ::sdr::contact::ObjectContact& rObjectContact, + ::sdr::contact::ViewContact& rViewContact, + const ::boost::shared_ptr<cache::PageCache>& rpCache, + const ::boost::shared_ptr<controller::Properties>& rpProperties); + virtual ~PageObjectViewObjectContact (void); + + /** This method is primarily for releasing the current preview cache (by + providing a NULL pointer.) + */ + void SetCache (const ::boost::shared_ptr<cache::PageCache>& rpCache); + + /** Return the page that is painted by this object. + */ + const SdrPage* GetPage (void) const; + + /** This fallback method is called when no preview cache is available. + It creates a preview for the page. + */ + BitmapEx CreatePreview (const sdr::contact::DisplayInfo& rDisplayInfo); + + /** Return the page descriptor of the slide sorter model that is + associated with the same page object as this contact object is. + */ + model::SharedPageDescriptor GetPageDescriptor (void) const; + + /** Return the border widths in the screen coordinate system of the + border arround the page object. The border contains frames for + selection, focus, the page name and number, and the indicator for + the page transition. + @param pDevice + The output device is used to convert pixel coordinates into + model coordinates. When NULL is given then the device dependent + part is not re-calculated but taken from an earlier calculation + or from the default values. + @param nPageCount + The total number of pages is used to determine the width of the + box that contains the page number. + */ + static SvBorder CalculatePageModelBorder ( + OutputDevice* pDevice, + int nPageCount); + + /** Calculate the size of the page number area so that all page numbers + including the given number fit in. Because this is device dependent + we need the device as parameter. The result is returned and stored + in maPageNumberAreaPixelSize so that it can be used later without + access to the device or page count. + */ + static Size CalculatePageNumberAreaModelSize ( + OutputDevice* pDevice, + int nPageCount); + + /** Paint a mouse over effect. + @param bVisible + When bVisible is <FALSE/> then paint the area of the mouse over + effect in the background color, i.e. erase it. + */ + drawinglayer::primitive2d::Primitive2DSequence createMouseOverEffectPrimitive2DSequence(); + + enum BoundingBoxType { + // This is the outer bounding box that includes the preview, page + // number, title. + PageObjectBoundingBox, + // Bounding box of the actual preview. + PreviewBoundingBox, + // Bounding box of the mouse indicator indicator frame. + MouseOverIndicatorBoundingBox, + // Bounding box of the focus indicator frame. + FocusIndicatorBoundingBox, + // Bounding box of the selection indicator frame. + SelectionIndicatorBoundingBox, + // Bounding box of the page number. + PageNumberBoundingBox, + // Bounding box of the pane name. + NameBoundingBox, + FadeEffectIndicatorBoundingBox + }; + enum CoordinateSystem { ModelCoordinateSystem, PixelCoordinateSystem }; + + /** Return the bounding box of the page object or one of its graphical + parts. + @param rDevice + This device is used to translate between model and window + coordinates. + @param eType + The part of the page object for which to return the bounding + box. + @param eCoodinateSystem + The bounding box can be returned in model and in pixel + (window) coordinates. + */ + Rectangle GetBoundingBox ( + OutputDevice& rDevice, + BoundingBoxType eType, + CoordinateSystem eCoordinateSystem) const; + + // create the graphical visualisation data + virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequence(const sdr::contact::DisplayInfo& rDisplayInfo) const; + + // access to the current page content primitive vector which may be used for visualisation + const drawinglayer::primitive2d::Primitive2DSequence& getCurrentPageContents() const { return mxCurrentPageContents; } + + virtual void ActionChanged (void); + +private: + /// Gap between border of page object and inside of selection rectangle. + static const sal_Int32 mnSelectionIndicatorOffset; + /// Thickness of the selection rectangle. + static const sal_Int32 mnSelectionIndicatorThickness; + /// Gap between border of page object and inside of focus rectangle. + static const sal_Int32 mnFocusIndicatorOffset; + /// Size of width and height of the fade effect indicator in pixels. + static const sal_Int32 mnFadeEffectIndicatorSize; + static const sal_Int32 mnFadeEffectIndicatorOffset; + /// Gap between border of page object and number rectangle. + static const sal_Int32 mnPageNumberOffset; + /// Offset and thickness of the mouse over effect rectangle. + static const sal_Int32 mnMouseOverEffectOffset; + static const sal_Int32 mnMouseOverEffectThickness; + + /** This flag is set to <TRUE/> when the destructor is called to + indicate that further calls made to it must not call outside. + */ + bool mbInDestructor; + + /// The primitive sequence of the page contents, completely scaled + /// and prepared for painiting + drawinglayer::primitive2d::Primitive2DSequence mxCurrentPageContents; + + ::boost::shared_ptr<cache::PageCache> mpCache; + + ::boost::shared_ptr<controller::Properties> mpProperties; + + BitmapEx GetPreview ( + const sdr::contact::DisplayInfo& rDisplayInfo, + const Rectangle& rNewSizePixel); + + /** Return the bounding box of where the page number is painted (when it + is painted). + */ + Rectangle GetPageNumberArea (OutputDevice& rDevice) const; +}; + +} } } // end of namespace ::sd::slidesorter::view + +#endif diff --git a/sd/source/ui/slidesorter/inc/view/SlsViewOverlay.hxx b/sd/source/ui/slidesorter/inc/view/SlsViewOverlay.hxx new file mode 100644 index 000000000000..4ff076f72560 --- /dev/null +++ b/sd/source/ui/slidesorter/inc/view/SlsViewOverlay.hxx @@ -0,0 +1,273 @@ +/************************************************************************* + * + * 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_VIEW_OVERLAY_HXX +#define SD_SLIDESORTER_VIEW_OVERLAY_HXX + +#include "model/SlsSharedPageDescriptor.hxx" + +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <osl/mutex.hxx> +#include <svx/sdr/overlay/overlayobject.hxx> +#include <tools/gen.hxx> +#include <vector> +#include <boost/weak_ptr.hpp> +#include <boost/noncopyable.hpp> + +class OutputDevice; +class Region; + + +namespace sd { namespace slidesorter { +class SlideSorter; +} } + +namespace sd { namespace slidesorter { namespace model { +class PageEnumeration; +} } } + +namespace sd { namespace slidesorter { namespace controller { +class SlideSorterController; +} } } + +namespace sdr { namespace overlay { +class OverlayManager; +} } + +namespace sd { namespace slidesorter { namespace view { + + +class InsertionIndicatorOverlay; +class PageObjectViewObjectContact; +class SelectionRectangleOverlay; +class SubstitutionOverlay; +class ViewOverlay; + +/** This base class of slide sorter overlays uses the drawing layer overlay + support for the display. +*/ +class OverlayBase + : public sdr::overlay::OverlayObject +{ +public: + OverlayBase (ViewOverlay& rViewOverlay); + virtual ~OverlayBase (void); + +protected: + ::osl::Mutex maMutex; + + ViewOverlay& mrViewOverlay; + + /** Make sure that the overlay object is registered at the + OverlayManager. This registration is done on demand. + */ + void EnsureRegistration (void); + void RemoveRegistration(); +}; + + + + +/** During internal drag and drop the outlines of the selected slides are + painted at the mouse position in dashed lines. +*/ +class SubstitutionOverlay + : public OverlayBase +{ +public: + SubstitutionOverlay (ViewOverlay& rViewOverlay); + virtual ~SubstitutionOverlay (void); + + /** Setup the substitution display of the given set of selected pages. + The given mouse position is remembered so that it later can be + returned by GetPosition(). This is a convenience feature. + */ + void Create ( + model::PageEnumeration& rSelection, + const Point& rPosition); + + /** Clear the substitution display. Until the next call of Create() no + substution is painted. + */ + void Clear (void); + + /** Move the substitution display by the given amount of pixels. + */ + void Move (const Point& rOffset); + void SetPosition (const Point& rPosition); + Point GetPosition (void) const; + + // react on stripe definition change + virtual void stripeDefinitionHasChanged(); + +protected: + // geometry creation for OverlayObject + virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence(); + +private: + Point maPosition; + basegfx::B2DPolyPolygon maShapes; +}; + + + + +/** Slides can be selected by drawing a selection rectangle in the slide + sorter. When the left mouse button is released all slides that are at + least partially in the rectangle are selected. +*/ +class SelectionRectangleOverlay + : public OverlayBase +{ +public: + SelectionRectangleOverlay (ViewOverlay& rViewOverlay); + virtual ~SelectionRectangleOverlay(); + + void Start (const Point& rAnchor); + void Update (const Point& rSecondCorner); + + Rectangle GetSelectionRectangle (void); + + // react on stripe definition change + virtual void stripeDefinitionHasChanged(); + +protected: + // geometry creation for OverlayObject + virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence(); + +private: + Point maAnchor; + Point maSecondCorner; +}; + + + + +/** The insertion indicator is painted as a vertical or horizonal bar + in the space between slides. +*/ +class InsertionIndicatorOverlay + : public OverlayBase +{ +public: + InsertionIndicatorOverlay (ViewOverlay& rViewOverlay); + virtual ~InsertionIndicatorOverlay(); + + /** Given a position in model coordinates this method calculates the + insertion marker both as an index in the document and as a rectangle + used for drawing the insertion indicator. + */ + void SetPosition (const Point& rPosition); + + sal_Int32 GetInsertionPageIndex (void) const; + +protected: + // geometry creation for OverlayObject + virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence(); + +private: + sal_Int32 mnInsertionIndex; + Rectangle maBoundingBox; + + void SetPositionAndSize (const Rectangle& rBoundingBox); +}; + + + + +/** Paint a frame around the slide preview under the mouse. The actual + painting is done by the PageObjectViewObjectContact of the slidesorter. +*/ +class MouseOverIndicatorOverlay + : public OverlayBase +{ +public: + MouseOverIndicatorOverlay (ViewOverlay& rViewOverlay); + virtual ~MouseOverIndicatorOverlay (void); + + /** Set the page object for which to paint a mouse over indicator. + @param pContact + A value of <NULL/> indicates to not paint the mouse over indicator. + */ + void SetSlideUnderMouse (const model::SharedPageDescriptor& rpDescriptor); + +protected: + // geometry creation for OverlayObject + virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence(); + +private: + /** The page under the mouse is stored as weak shared pointer so that + model changes can be handled without having the SlideSorterModel + inform this class explicitly. + */ + ::boost::weak_ptr<model::PageDescriptor> mpPageUnderMouse; + + view::PageObjectViewObjectContact* GetViewObjectContact (void) const; +}; + + + + +/** The view overlay manages and paints some indicators that are painted on + top of the regular view content (the page objects). It is separated + from the view to allow the indicators to be altered in position and size + without repainting the whole view content (inside that the bounding box + of the indicator). This is achieved by using the drawing layer overlay + support. + + The view overlay itself simply gives access to the more specialized + classes that handle individual indicators. + +*/ +class ViewOverlay +{ +public: + ViewOverlay (SlideSorter& rSlideSorter); + ~ViewOverlay (void); + + SelectionRectangleOverlay& GetSelectionRectangleOverlay (void); + MouseOverIndicatorOverlay& GetMouseOverIndicatorOverlay (void); + InsertionIndicatorOverlay& GetInsertionIndicatorOverlay (void); + SubstitutionOverlay& GetSubstitutionOverlay (void); + + SlideSorter& GetSlideSorter (void) const; + + sdr::overlay::OverlayManager* GetOverlayManager (void) const; + +private: + SlideSorter& mrSlideSorter; + SelectionRectangleOverlay maSelectionRectangleOverlay; + MouseOverIndicatorOverlay maMouseOverIndicatorOverlay; + InsertionIndicatorOverlay maInsertionIndicatorOverlay; + SubstitutionOverlay maSubstitutionOverlay; +}; + + + +} } } // end of namespace ::sd::slidesorter::view + +#endif |