Update ooo320-m1
[ooovba.git] / sd / source / ui / slidesorter / inc / view / SlideSorterView.hxx
blob1caf49e08d2b5a66fa7abfa914661ae40a6574e1
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: SlideSorterView.hxx,v $
10 * $Revision: 1.15 $
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_VIEW_HXX
32 #define SD_SLIDESORTER_SLIDE_SORTER_VIEW_HXX
34 #include "View.hxx"
36 #include "model/SlsSharedPageDescriptor.hxx"
38 #include <sfx2/viewfrm.hxx>
39 #include "pres.hxx"
40 #include <tools/gen.hxx>
41 #include <memory>
42 #include <boost/shared_ptr.hpp>
44 class Point;
46 namespace sdr { namespace contact {
47 class ObjectContact;
48 } }
50 namespace sd { namespace slidesorter {
51 class SlideSorter;
52 } }
54 namespace sd { namespace slidesorter { namespace controller {
55 class SlideSorterController;
56 } } }
58 namespace sd { namespace slidesorter { namespace cache {
59 class PageCache;
60 } } }
62 namespace sd { namespace slidesorter { namespace model {
63 class SlideSorterModel;
64 } } }
66 namespace sd { namespace slidesorter { namespace view {
68 class Layouter;
69 class ViewOverlay;
72 class SlideSorterView
73 : public View
75 public:
76 TYPEINFO();
78 /** Create a new view for the slide sorter.
79 @param rViewShell
80 This reference is simply passed to the base class and not used
81 by this class.
84 SlideSorterView (SlideSorter& rSlideSorter);
86 virtual ~SlideSorterView (void);
88 enum Orientation { HORIZONTAL, VERTICAL };
89 void SetOrientation (const Orientation eOrientation);
90 Orientation GetOrientation (void) const;
92 void RequestRepaint (void);
93 void RequestRepaint (const model::SharedPageDescriptor& rDescriptor);
95 Rectangle GetModelArea (void);
97 enum CoordinateSystem { CS_SCREEN, CS_MODEL };
98 enum BoundingBoxType { BBT_SHAPE, BBT_INFO };
100 /** Return the rectangle that bounds the page object represented by the
101 given page descriptor.
102 @param rDescriptor
103 The descriptor of the page for which to return the bounding box.
104 @param eCoordinateSystem
105 Specifies whether to return the screen or model coordinates.
106 @param eBoundingBoxType
107 Specifies whether to return the bounding box of only the page
108 object or the one that additionally includes other displayed
109 information like page name and fader symbol.
111 Rectangle GetPageBoundingBox (
112 const model::SharedPageDescriptor& rpDescriptor,
113 CoordinateSystem eCoordinateSystem,
114 BoundingBoxType eBoundingBoxType) const;
116 /** Return the rectangle that bounds the page object represented by the
117 given page index .
118 @param nIndex
119 The index of the page for which to return the bounding box.
120 @param eCoordinateSystem
121 Specifies whether to return the screen or model coordinates.
122 @param eBoundingBoxType
123 Specifies whether to return the bounding box of only the page
124 object or the one that additionally includes other displayed
125 information like page name and fader symbol.
127 Rectangle GetPageBoundingBox (
128 sal_Int32 nIndex,
129 CoordinateSystem eCoordinateSystem,
130 BoundingBoxType eBoundingBoxType) const;
132 /** Return the index of the page that is rendered at the given position.
133 @param rPosition
134 The position is expected to be in pixel coordinates.
135 @return
136 The returned index is -1 when there is no page object at the
137 given position.
139 sal_Int32 GetPageIndexAtPoint (const Point& rPosition) const;
140 sal_Int32 GetFadePageIndexAtPoint (const Point& rPosition) const;
142 view::Layouter& GetLayouter (void);
144 virtual void ModelHasChanged (void);
146 void LocalModelHasChanged(void);
148 /** This method is typically called before a model change takes place.
149 All references to model data are released. PostModelChange() has to
150 be called to complete the handling of the model change. When the
151 calls to Pre- and PostModelChange() are very close to each other you
152 may call HandleModelChange() instead.
154 void PreModelChange (void);
156 /** This method is typically called after a model change took place.
157 References to model data are re-allocated. Call this method only
158 after PreModelChange() has been called.
160 void PostModelChange (void);
162 /** This method is a convenience function that simply calls
163 PreModelChange() and then PostModelChange().
165 void HandleModelChange (void);
167 void HandleDrawModeChange (void);
169 virtual void Resize (void);
170 virtual void CompleteRedraw (OutputDevice* pDevice, const Region& rPaintArea, sdr::contact::ViewObjectContactRedirector* pRedirector = 0L);
171 virtual void InvalidateOneWin (
172 ::Window& rWindow);
173 virtual void InvalidateOneWin (
174 ::Window& rWindow,
175 const Rectangle& rPaintArea );
177 void Layout (void);
178 /** This tells the view that it has to re-determine the visibility of
179 the page objects before painting them the next time.
181 void InvalidatePageObjectVisibilities (void);
183 /** Return the window to which this view renders its output.
185 ::sd::Window* GetWindow (void) const;
188 ::boost::shared_ptr<cache::PageCache> GetPreviewCache (void);
190 view::ViewOverlay& GetOverlay (void);
192 /** Set the bounding box of the insertion marker in model coordinates.
194 It will be painted as a dark rectangle that fills the given box.
196 void SetInsertionMarker (const Rectangle& rBBox);
198 /** Specify whether the insertion marker will be painted or not.
200 void SetInsertionMarkerVisibility (bool bVisible);
202 /** Set the size and position of the selection rectangle.
204 It will be painted as a dashed rectangle.
206 void SetSelectionRectangle (const Rectangle& rBox);
208 /** Specify whether the selection rectangle will be painted or not.
210 void SetSelectionRectangleVisibility (bool bVisible);
212 ::sdr::contact::ObjectContact& GetObjectContact (void) const;
214 typedef ::std::pair<sal_Int32,sal_Int32> PageRange;
215 /** Return the range of currently visible page objects including the
216 first and last one in that range.
217 @return
218 The returned pair of page object indices is empty when the
219 second index is lower than the first.
221 PageRange GetVisiblePageRange (void);
223 /** Return the size of the area where the page numbers are displayed.
224 @return
225 The returned size is given in model coordinates.
227 Size GetPageNumberAreaModelSize (void) const;
229 /** Return the size of the border around the original SdrPageObj.
231 SvBorder GetModelBorder (void) const;
233 /** Add a shape to the page. Typically used from inside
234 PostModelChange().
236 void AddSdrObject (SdrObject& rObject);
238 protected:
239 virtual void Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint);
241 private:
242 SlideSorter& mrSlideSorter;
243 model::SlideSorterModel& mrModel;
244 /// This model is used for the maPage object and for the page visualizers
245 /// (SdrPageObj)
246 SdrModel maPageModel;
247 /** This page acts as container for the page objects that represent the
248 pages of the document that is represented by the SlideSorterModel.
250 SdrPage* mpPage;
251 ::std::auto_ptr<Layouter> mpLayouter;
252 bool mbPageObjectVisibilitiesValid;
253 ::boost::shared_ptr<cache::PageCache> mpPreviewCache;
254 ::std::auto_ptr<ViewOverlay> mpViewOverlay;
256 int mnFirstVisiblePageIndex;
257 int mnLastVisiblePageIndex;
259 SvBorder maPagePixelBorder;
261 bool mbModelChangedWhileModifyEnabled;
263 Size maPreviewSize;
265 bool mbPreciousFlagUpdatePending;
267 Size maPageNumberAreaModelSize;
268 SvBorder maModelBorder;
270 Orientation meOrientation;
272 /** Adapt the coordinates of the given bounding box according to the
273 other parameters.
274 @param rModelPageObjectBoundingBox
275 Bounding box given in model coordinates that bounds only the
276 page object.
277 @param eCoordinateSystem
278 When CS_SCREEN is given then the bounding box is converted into
279 screen coordinates.
280 @param eBoundingBoxType
281 When BBT_INFO is given then the bounding box is made larger so
282 that it encloses all relevant displayed information.
284 void AdaptBoundingBox (
285 Rectangle& rModelPageObjectBoundingBox,
286 CoordinateSystem eCoordinateSystem,
287 BoundingBoxType eBoundingBoxType) const;
289 /** Determine the visibility of all page objects.
291 void DeterminePageObjectVisibilities (void);
293 /** Update the page borders used by the layouter by using those returned
294 by the first page. Call this function when the model changes,
295 especially when the number of pages changes, or when the window is
296 resized as the borders may be device dependent.
298 void UpdatePageBorders (void);
300 void UpdatePreciousFlags (void);
304 } } } // end of namespace ::sd::slidesorter::view
306 #endif