Update ooo320-m1
[ooovba.git] / sd / source / ui / slidesorter / inc / view / SlsPageObjectViewObjectContact.hxx
blobe4267949aa58cb306929c3834604fbea99b183e4
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: SlsPageObjectViewObjectContact.hxx,v $
10 * $Revision: 1.14 $
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_OBJECT_VIEW_OBJECT_CONTACT_HXX
32 #define SD_SLIDESORTER_PAGE_OBJECT_VIEW_OBJECT_CONTACT_HXX
34 #include <svx/sdr/contact/viewobjectcontactofpageobj.hxx>
35 #include "model/SlsSharedPageDescriptor.hxx"
36 #include <svx/sdr/contact/viewobjectcontact.hxx>
37 #include <vcl/bitmapex.hxx>
38 #include <vcl/image.hxx>
39 #include <sfx2/viewfrm.hxx>
40 #include <memory>
41 #include <boost/shared_ptr.hpp>
43 class SdrPage;
45 namespace sdr { namespace contact {
46 class DisplayInfo;
47 } }
49 namespace sd { namespace slidesorter { namespace cache {
50 class PageCache;
51 } } }
53 namespace sd { namespace slidesorter { namespace controller {
54 class Properties;
55 } } }
57 namespace sd { namespace slidesorter { namespace view {
59 class SlideSorterView;
61 /** This object-view-contact of page objects maintains a preview bitmap for
62 the page to speed up redraws of the same. It does so by colaborating
63 with a cache of bitmaps (see ../cache).
66 // needs to be derived from ViewObjectContactOfPageObj, else the calls to parent implementations
67 // would use ViewObjectContact and thus not enable e.g. the correct primitive creation
68 // for view-independent printer output
69 // changed: ViewObjectContact -> ViewObjectContactOfPageObj
71 class PageObjectViewObjectContact : public ::sdr::contact::ViewObjectContactOfPageObj
73 public:
74 /** Create a new view-object-contact object for the given contact
75 objects of both model and view.
76 @param pCache
77 The caller should provide a pointer to a preview cache, if
78 available. If given then the cache is used to control when to
79 create a preview and to store it. If NULL is given then the
80 preview is created every time when requested.
82 PageObjectViewObjectContact (
83 ::sdr::contact::ObjectContact& rObjectContact,
84 ::sdr::contact::ViewContact& rViewContact,
85 const ::boost::shared_ptr<cache::PageCache>& rpCache,
86 const ::boost::shared_ptr<controller::Properties>& rpProperties);
87 virtual ~PageObjectViewObjectContact (void);
89 /** This method is primarily for releasing the current preview cache (by
90 providing a NULL pointer.)
92 void SetCache (const ::boost::shared_ptr<cache::PageCache>& rpCache);
94 /** Return the page that is painted by this object.
96 const SdrPage* GetPage (void) const;
98 /** This fallback method is called when no preview cache is available.
99 It creates a preview for the page.
101 BitmapEx CreatePreview (const sdr::contact::DisplayInfo& rDisplayInfo);
103 /** Return the page descriptor of the slide sorter model that is
104 associated with the same page object as this contact object is.
106 model::SharedPageDescriptor GetPageDescriptor (void) const;
108 /** Return the border widths in the screen coordinate system of the
109 border arround the page object. The border contains frames for
110 selection, focus, the page name and number, and the indicator for
111 the page transition.
112 @param pDevice
113 The output device is used to convert pixel coordinates into
114 model coordinates. When NULL is given then the device dependent
115 part is not re-calculated but taken from an earlier calculation
116 or from the default values.
117 @param nPageCount
118 The total number of pages is used to determine the width of the
119 box that contains the page number.
121 static SvBorder CalculatePageModelBorder (
122 OutputDevice* pDevice,
123 int nPageCount);
125 /** Calculate the size of the page number area so that all page numbers
126 including the given number fit in. Because this is device dependent
127 we need the device as parameter. The result is returned and stored
128 in maPageNumberAreaPixelSize so that it can be used later without
129 access to the device or page count.
131 static Size CalculatePageNumberAreaModelSize (
132 OutputDevice* pDevice,
133 int nPageCount);
135 /** Paint a mouse over effect.
136 @param bVisible
137 When bVisible is <FALSE/> then paint the area of the mouse over
138 effect in the background color, i.e. erase it.
140 drawinglayer::primitive2d::Primitive2DSequence createMouseOverEffectPrimitive2DSequence();
142 enum BoundingBoxType {
143 // This is the outer bounding box that includes the preview, page
144 // number, title.
145 PageObjectBoundingBox,
146 // Bounding box of the actual preview.
147 PreviewBoundingBox,
148 // Bounding box of the mouse indicator indicator frame.
149 MouseOverIndicatorBoundingBox,
150 // Bounding box of the focus indicator frame.
151 FocusIndicatorBoundingBox,
152 // Bounding box of the selection indicator frame.
153 SelectionIndicatorBoundingBox,
154 // Bounding box of the page number.
155 PageNumberBoundingBox,
156 // Bounding box of the pane name.
157 NameBoundingBox,
158 FadeEffectIndicatorBoundingBox
160 enum CoordinateSystem { ModelCoordinateSystem, PixelCoordinateSystem };
162 /** Return the bounding box of the page object or one of its graphical
163 parts.
164 @param rDevice
165 This device is used to translate between model and window
166 coordinates.
167 @param eType
168 The part of the page object for which to return the bounding
169 box.
170 @param eCoodinateSystem
171 The bounding box can be returned in model and in pixel
172 (window) coordinates.
174 Rectangle GetBoundingBox (
175 OutputDevice& rDevice,
176 BoundingBoxType eType,
177 CoordinateSystem eCoordinateSystem) const;
179 // create the graphical visualisation data
180 virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequence(const sdr::contact::DisplayInfo& rDisplayInfo) const;
182 // access to the current page content primitive vector which may be used for visualisation
183 const drawinglayer::primitive2d::Primitive2DSequence& getCurrentPageContents() const { return mxCurrentPageContents; }
185 virtual void ActionChanged (void);
187 private:
188 /// Gap between border of page object and inside of selection rectangle.
189 static const sal_Int32 mnSelectionIndicatorOffset;
190 /// Thickness of the selection rectangle.
191 static const sal_Int32 mnSelectionIndicatorThickness;
192 /// Gap between border of page object and inside of focus rectangle.
193 static const sal_Int32 mnFocusIndicatorOffset;
194 /// Size of width and height of the fade effect indicator in pixels.
195 static const sal_Int32 mnFadeEffectIndicatorSize;
196 static const sal_Int32 mnFadeEffectIndicatorOffset;
197 /// Gap between border of page object and number rectangle.
198 static const sal_Int32 mnPageNumberOffset;
199 /// Offset and thickness of the mouse over effect rectangle.
200 static const sal_Int32 mnMouseOverEffectOffset;
201 static const sal_Int32 mnMouseOverEffectThickness;
203 /** This flag is set to <TRUE/> when the destructor is called to
204 indicate that further calls made to it must not call outside.
206 bool mbInDestructor;
208 /// The primitive sequence of the page contents, completely scaled
209 /// and prepared for painiting
210 drawinglayer::primitive2d::Primitive2DSequence mxCurrentPageContents;
212 ::boost::shared_ptr<cache::PageCache> mpCache;
214 ::boost::shared_ptr<controller::Properties> mpProperties;
216 BitmapEx GetPreview (
217 const sdr::contact::DisplayInfo& rDisplayInfo,
218 const Rectangle& rNewSizePixel);
220 /** Return the bounding box of where the page number is painted (when it
221 is painted).
223 Rectangle GetPageNumberArea (OutputDevice& rDevice) const;
226 } } } // end of namespace ::sd::slidesorter::view
228 #endif