diff options
Diffstat (limited to 'sd/source/ui/slidesorter/inc/model')
6 files changed, 697 insertions, 0 deletions
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 |