1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SlideSorterModel.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_SLIDESORTER_SLIDE_SORTER_MODEL_HXX
32 #define SD_SLIDESORTER_SLIDE_SORTER_MODEL_HXX
36 #include "model/SlsPageEnumeration.hxx"
37 #include "model/SlsSharedPageDescriptor.hxx"
40 #include <com/sun/star/drawing/XDrawPage.hpp>
41 #include <osl/mutex.hxx>
47 namespace css
= ::com::sun::star
;
49 namespace sd
{ namespace slidesorter
{
53 namespace sd
{ namespace slidesorter
{ namespace controller
{
54 class PageObjectFactory
;
57 namespace sd
{ namespace slidesorter
{ namespace model
{
59 class DocumentPageContainer
;
61 /** The model of the slide sorter gives access to the slides that are to be
62 displayed in the slide sorter view. Via the SetDocumentSlides() method
63 this set of slides can be modified (but do not call it directly, use
64 SlideSorterController::SetDocumentSlides() instead.)
66 class SlideSorterModel
69 SlideSorterModel (SlideSorter
& rSlideSorter
);
71 virtual ~SlideSorterModel (void);
73 /** This method is present to let the view create a ShowView for
76 SdDrawDocument
* GetDocument (void);
78 /** Set a new edit mode and return whether the edit mode really
79 has been changed. When the edit mode is changed then the
80 previous page descriptor list is replaced by a new one which
83 A return value of <TRUE/> indicates that the edit mode has
84 changed and thus the page descriptor list has been set up
85 to reflect that change. A repaint is necessary.
87 bool SetEditMode (EditMode eEditMode
);
89 /** Set the edit mode to that currently used by the controller.
91 bool SetEditModeFromController (void);
92 EditMode
GetEditMode (void) const;
93 PageKind
GetPageType (void) const;
95 /** Return the number of slides in the document regardless of whether
96 they are visible or not or whether they are hidden or not.
97 The number of slides depends on the set of slides available through
98 the XIndexAccess given to SetDocumentSlides().
100 sal_Int32
GetPageCount (void) const;
102 /** Return a page descriptor for the page with the specified index.
103 Page descriptors are created on demand. The page descriptor is
104 found (or not found) in constant time.
106 The index of the requested slide. The valid values
107 are 0 to GetPageCount()-1.
109 When <TRUE/> and the requested page descriptor is missing then
110 it is created. When <FALSE/> then an empty reference is
111 returned for missing descriptors.
113 When the given index is not valid, i.e. lower then zero or
114 larger than or equal to the number of pages then an empty
115 reference is returned. Note that the page count may change
116 between calls to GetPageCount() and GetPageDescriptor().
118 SharedPageDescriptor
GetPageDescriptor (
119 const sal_Int32 nPageIndex
,
120 const bool bCreate
= true) const;
122 /** Return a page descriptor for the given XDrawPage. Page descriptors
123 are created on demand. The page descriptor is found (or not found)
124 in (at most) linear time. Note that all page descriptors in front of
125 the one associated with the given XDrawPage are created when not yet
126 present. When the XDrawPage is not found then all descriptors are
129 Returns the index to the requested page descriptor or -1 when
130 there is no such page descriptor.
133 const ::com::sun::star::uno::Reference
<com::sun::star::drawing::XDrawPage
>& rxSlide
) const;
135 /** Call this method after the document has changed its structure. This
136 will get the model in sync with the SdDrawDocument. This method
137 tries not to throw away to much information already gathered. This
138 is especially important for previews of complex pages that take some
143 /** Delete all descriptors that currently are in the container. The size
144 of the container, however, is not altered. Use the AdaptSize
147 void ClearDescriptorList (void);
149 /** Set the selection of the document to exactly that of the called model.
151 void SynchronizeDocumentSelection (void);
153 /** Set the selection of the called model to exactly that of the document.
155 void SynchronizeModelSelection (void);
157 /** Replace the factory for the creation of the page objects and
158 contacts with the given object. The old factory is destroyed.
160 void SetPageObjectFactory(
161 ::std::auto_ptr
<controller::PageObjectFactory
> pPageObjectFactory
);
163 /** Return the page object factory. It none has been set so far or it
164 has been reset, then a new one is created.
166 const controller::PageObjectFactory
& GetPageObjectFactory (void) const;
168 /** Return the mutex so that the caller can lock it and then safely
171 ::osl::Mutex
& GetMutex (void);
173 /** Set the XIndexAccess from which the called SlideSorterModel takes
176 The set of slides accessible through this XIndexAccess are not
177 necessarily the same as the ones of the XModel of the
178 XController (although it typically is a subset).
180 void SetDocumentSlides (const css::uno::Reference
<css::container::XIndexAccess
>& rxSlides
);
182 /** Return the set of pages that is currently displayed by the slide sorter.
184 css::uno::Reference
<css::container::XIndexAccess
> GetDocumentSlides (void) const;
186 /** This method is called when the edit mode has changed. It calls
187 SetDocumentSlides() with the set of slides or master pages obtained
188 from the model of the XController.
190 void UpdatePageList (void);
193 mutable ::osl::Mutex maMutex
;
194 SlideSorter
& mrSlideSorter
;
195 ::com::sun::star::uno::Reference
<com::sun::star::container::XIndexAccess
> mxSlides
;
198 typedef ::std::vector
<SharedPageDescriptor
> DescriptorContainer
;
199 mutable DescriptorContainer maPageDescriptors
;
200 mutable ::std::auto_ptr
<controller::PageObjectFactory
> mpPageObjectFactory
;
202 /** Resize the descriptor container according to current values of
203 page kind and edit mode.
205 void AdaptSize (void);
209 } } } // end of namespace ::sd::slidesorter::model