Update ooo320-m1
[ooovba.git] / sd / source / ui / slidesorter / inc / model / SlsPageDescriptor.hxx
blob38b4d88c70260e4377f39541afbfb62d6fbfcced
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: SlsPageDescriptor.hxx,v $
10 * $Revision: 1.8 $
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_PAGE_DESCRIPTOR_HXX
32 #define SD_SLIDESORTER_PAGE_DESCRIPTOR_HXX
34 #include <com/sun/star/drawing/XDrawPage.hpp>
35 #include <tools/gen.hxx>
36 #include <tools/link.hxx>
37 #include <vcl/bitmap.hxx>
38 #include <sfx2/viewfrm.hxx>
40 #include <memory>
41 #include <boost/enable_shared_from_this.hpp>
43 class SdPage;
45 namespace sdr { namespace contact {
46 class ObjectContact;
47 } }
49 namespace sd { namespace slidesorter { namespace view {
50 class PageObject;
51 class PageObjectViewObjectContact;
52 } } }
54 namespace sd { namespace slidesorter { namespace controller {
55 class PageObjectFactory;
56 } } }
58 namespace sd { namespace slidesorter { namespace model {
60 class SlideRenderer;
62 namespace css = ::com::sun::star;
64 /** Each PageDescriptor object represents the preview of one draw page,
65 slide, or master page of a Draw or Impress document as they are displayed
66 in the slide sorter. This class gives access to some associated
67 information like prerendered preview or position on the screen.
69 <p>Bounding boxes of page objects come in four varieties:
70 Model and screen/pixel coordinates and the bounding boxes of the actual
71 page objects and the larger bounding boxes that include page names and
72 fade symbol.</p>
74 class PageDescriptor
75 : public ::boost::enable_shared_from_this<PageDescriptor>
77 public:
78 /** Create a PageDescriptor for the given SdPage object.
79 @param rxPage
80 The page that is represented by the new PageDescriptor object.
81 @param pPage
82 The page pointer can in some situations not be detected from
83 rxPage, e.g. after undo of page deletion. Therefore supply it
84 seperately.
85 @param nIndex
86 This index is displayed in the view as page number. It is not
87 necessaryily the page index (not even when you add or subtract 1
88 or use (x-1)/2 magic).
90 PageDescriptor (
91 const css::uno::Reference<css::drawing::XDrawPage>& rxPage,
92 SdPage* pPage,
93 const sal_Int32 nIndex,
94 const controller::PageObjectFactory& rPageObjectFactory);
96 ~PageDescriptor (void);
98 /** Return the page that is represented by the descriptor as SdPage pointer .
100 SdPage* GetPage (void) const;
102 /** Return the page that is represented by the descriptor as XDrawPage reference.
104 css::uno::Reference<css::drawing::XDrawPage> GetXDrawPage (void) const;
106 /** Returns the index of the page as it is displayed in the view as page
107 number. The value may differ from the index returned by the
108 XDrawPage when there are hidden slides and the XIndexAccess used to
109 access the model filters them out.
111 sal_Int32 GetPageIndex (void) const;
113 /** Return the page shape that is used for visualizing the page.
115 view::PageObject* GetPageObject (void);
116 void ReleasePageObject (void);
118 /** Return <TRUE/> when the page object is fully or parially visible. */
119 bool IsVisible (void) const;
121 /** Set the visible state that is returned by the IsVisible() method.
122 This method is typically called by the view who renders the object
123 onto the screen.
125 void SetVisible (bool bVisible);
127 /** Make sure that the page is selected and return whether the
128 selection state changed.
130 bool Select (void);
131 /** Make sure that the page is not selected and return whether the
132 selection state changed.
134 bool Deselect (void);
136 /** Return whether the page is selected (and thus bypasses the internal
137 mbIsSelected flag.
139 bool IsSelected (void) const;
141 /** Set the internal mbIsSelected flag to the selection state of the
142 page. Use this method to synchronize a page descriptor with the
143 page it describes and determine whether a redraw to update the
144 selection indicator is necessary.
145 @return
146 When the two selection states were different <TRUE/> is
147 returned. When they were the same this method returns
148 <FALSE/>.
150 bool UpdateSelection (void);
152 bool IsFocused (void) const;
153 void SetFocus (void);
154 void RemoveFocus (void);
156 view::PageObjectViewObjectContact* GetViewObjectContact (void) const;
158 void SetViewObjectContact (
159 view::PageObjectViewObjectContact* pViewObjectContact);
161 /** Return the currently used page object factory.
163 const controller::PageObjectFactory& GetPageObjectFactory (void) const;
165 /** Replace the current page object factory by the given one.
167 void SetPageObjectFactory (const controller::PageObjectFactory& rFactory);
169 void SetModelBorder (const SvBorder& rBorder);
170 SvBorder GetModelBorder (void) const;
172 /** The size of the area in which the page number is displayed is
173 calculated by the SlideSorterView and then stored in the page
174 descriptors so that the contact objects can access them. The
175 contact objects can not calculate them on demand because the total
176 number of slides is needed to do that and this number is not known
177 to the contact objects.
179 void SetPageNumberAreaModelSize (const Size& rSize);
180 Size GetPageNumberAreaModelSize (void) const;
182 /** Returns <TRUE/> when the slide is the current slide.
184 bool IsCurrentPage (void) const;
186 /** Set or revoke the state of this slide being the current slide.
188 void SetIsCurrentPage (const bool bIsCurrent);
190 private:
191 SdPage* mpPage;
192 css::uno::Reference<css::drawing::XDrawPage> mxPage;
193 /** This index is displayed as page number in the view. It may or may
194 not be actual page index.
196 const sal_Int32 mnIndex;
198 /// The factory that is used to create PageObject objects.
199 const controller::PageObjectFactory* mpPageObjectFactory;
201 /** The page object will be destroyed by the page into which it has
202 been inserted.
204 view::PageObject* mpPageObject;
206 bool mbIsSelected;
207 bool mbIsVisible;
208 bool mbIsFocused;
209 bool mbIsCurrent;
211 view::PageObjectViewObjectContact* mpViewObjectContact;
213 /// The borders in model coordinates arround the page object.
214 SvBorder maModelBorder;
216 /// The size of the page number area in model coordinates.
217 Size maPageNumberAreaModelSize;
219 // Do not use the copy constructor operator. It is not implemented.
220 PageDescriptor (const PageDescriptor& rDescriptor);
222 // Do not use the assignment operator. It is not implemented
223 // (mrPage can not be assigned).
224 PageDescriptor& operator= (const PageDescriptor& rDescriptor);
227 } } } // end of namespace ::sd::slidesorter::model
229 #endif