Update ooo320-m1
[ooovba.git] / sd / source / ui / slidesorter / inc / model / SlideSorterModel.hxx
blob97731f905262c80aff51110efb16a41cfd7c4836
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SlideSorterModel.hxx,v $
10 * $Revision: 1.7 $
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
34 class SdDrawDocument;
36 #include "model/SlsPageEnumeration.hxx"
37 #include "model/SlsSharedPageDescriptor.hxx"
39 #include "pres.hxx"
40 #include <com/sun/star/drawing/XDrawPage.hpp>
41 #include <osl/mutex.hxx>
43 #include <memory>
44 #include <vector>
45 #include <functional>
47 namespace css = ::com::sun::star;
49 namespace sd { namespace slidesorter {
50 class SlideSorter;
51 } }
53 namespace sd { namespace slidesorter { namespace controller {
54 class PageObjectFactory;
55 } } }
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
68 public:
69 SlideSorterModel (SlideSorter& rSlideSorter);
71 virtual ~SlideSorterModel (void);
73 /** This method is present to let the view create a ShowView for
74 displaying slides.
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
81 has to be repainted.
82 @return
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.
105 @param nPageIndex
106 The index of the requested slide. The valid values
107 are 0 to GetPageCount()-1.
108 @param bCreate
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.
112 @return
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
127 created.
128 @return
129 Returns the index to the requested page descriptor or -1 when
130 there is no such page descriptor.
132 sal_Int32 GetIndex (
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
139 time to create.
141 void Resync (void);
143 /** Delete all descriptors that currently are in the container. The size
144 of the container, however, is not altered. Use the AdaptSize
145 method for that.
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
169 access the model.
171 ::osl::Mutex& GetMutex (void);
173 /** Set the XIndexAccess from which the called SlideSorterModel takes
174 its pages.
175 @param rxSlides
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);
192 private:
193 mutable ::osl::Mutex maMutex;
194 SlideSorter& mrSlideSorter;
195 ::com::sun::star::uno::Reference<com::sun::star::container::XIndexAccess> mxSlides;
196 PageKind mePageKind;
197 EditMode meEditMode;
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
211 #endif