update dev300-m58
[ooovba.git] / slideshow / source / inc / shape.hxx
blob3fd72968d0d7cac186f89e34464bdb611ecd09be
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: shape.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 INCLUDED_SLIDESHOW_SHAPE_HXX
32 #define INCLUDED_SLIDESHOW_SHAPE_HXX
34 #include <com/sun/star/uno/Reference.hxx>
35 #include <com/sun/star/drawing/XShape.hpp>
36 #include <com/sun/star/drawing/XDrawPage.hpp>
38 #include <basegfx/range/b2drectangle.hxx>
40 #include "viewlayer.hxx"
42 #include <boost/shared_ptr.hpp>
43 #include <boost/noncopyable.hpp>
44 #include <set>
45 #include <vector>
47 namespace basegfx {
48 class B2DRange;
51 namespace slideshow
53 namespace internal
55 // forward declaration necessary, because methods use ShapeSharedPtr
56 class Shape;
58 typedef ::boost::shared_ptr< Shape > ShapeSharedPtr;
60 /** Represents a slide's shape object.
62 This interface represents the view-independent aspects of a
63 slide's shape, providing bound rect, underlying XShape and
64 basic paint methods.
66 class Shape : private boost::noncopyable
68 public:
69 virtual ~Shape() {}
71 /** Get the associated XShape of this shape.
73 @return the associated XShape. If this method returns
74 an empty reference, this object might be one of the
75 special-purpose shapes of a slide, which have no
76 direct corresponding XShape (the background comes to
77 mind here).
79 virtual ::com::sun::star::uno::Reference<
80 ::com::sun::star::drawing::XShape > getXShape() const = 0;
83 // View layer methods
84 //------------------------------------------------------------------
86 /** Add a new view layer.
88 This method adds a new view layer, this shape shall
89 show itself on.
91 @param rNewLayer
92 New layer to show on
94 @param bRedrawLayer
95 Redraw shape on given layer
97 virtual void addViewLayer( const ViewLayerSharedPtr& rNewLayer,
98 bool bRedrawLayer ) = 0;
100 /** Withdraw the shape from a view layer
102 This method removes the shape from the given view
103 layer.
105 @return true, if the shape was successfully removed
107 virtual bool removeViewLayer( const ViewLayerSharedPtr& rNewLayer ) = 0;
109 /** Withdraw all view layers at once
111 This method will be faster than repeated
112 removeViewLayer() calls.
114 virtual bool clearAllViewLayers() = 0;
116 // render methods
117 //------------------------------------------------------------------
119 /** Update the shape
121 This method updates the Shape on all registered view
122 layers, but only if shape content has actually
123 changed.
125 @return whether the update finished successfully.
127 virtual bool update() const = 0;
129 /** Render the shape.
131 This method renders the shape on all registered view
132 layers, regardless of whether shape content has
133 changed or not.
135 @return whether the rendering finished successfully.
137 virtual bool render() const = 0;
139 /** Query whether shape content changed
141 This method returns true, if shape content changed
142 since the last rendering (i.e. the shape needs an
143 update to reflect that changed content on the views).
145 virtual bool isContentChanged() const = 0;
148 // Shape attributes
149 //------------------------------------------------------------------
151 /** Get the current shape position and size.
153 This method yields the currently effective shape
154 bounds (which might change over time, for animated
155 shapes). Please note that possibly shape rotations
156 from its original document state must not be taken
157 into account here: if you need the screen bounding
158 box, use getUpdateArea() instead. Note further that
159 shape rotations, which are already contained in the
160 shape as displayed in the original document
161 <em>are</em> included herein (we currently take the
162 shape as-is from the document, assuming a rotation
163 angle of 0).
165 virtual ::basegfx::B2DRange getBounds() const = 0;
167 /** Get the DOM position and size of the shape.
169 This method yields the underlying DOM shape bounds,
170 i.e. the original shape bounds from the document
171 model. This value is <em>always</em> unaffected by any
172 animation activity. Note that shape rotations, which
173 are already contained in the shape as displayed in the
174 original document are already included herein (we
175 currently take the shape as-is from the document,
176 assuming a rotation angle of 0).
178 virtual ::basegfx::B2DRange getDomBounds() const = 0;
180 /** Get the current shape update area.
182 This method yields the currently effective update area
183 for the shape, i.e. the area that needs to be updated,
184 should the shape be painted. Normally, this will be
185 the (possibly rotated and sheared) area returned by
186 getBounds().
188 virtual ::basegfx::B2DRange getUpdateArea() const = 0;
190 /** Query whether the shape is visible at all.
192 @return true, if this shape is visible, false
193 otherwise.
195 virtual bool isVisible() const = 0;
197 /** Get the shape priority.
199 The shape priority defines the relative order of the
200 shapes on the slide.
202 @return the priority. Will be in the [0,+infty) range.
204 virtual double getPriority() const = 0;
206 /** Query whether the Shape is currently detached from the
207 background.
209 This method checks whether the Shape is currently
210 detached from the slide background, i.e. whether shape
211 updates affect the underlying slide background or
212 not. A shape that returnes true here must not alter
213 slide content in any way when called render() or
214 update() (this is normally achieved by making this
215 shape a sprite).
217 virtual bool isBackgroundDetached() const = 0;
219 // Misc
220 //------------------------------------------------------------------
222 /** Functor struct, for shape ordering
224 This defines a strict weak ordering of shapes, primary
225 sort key is the shape priority, and secondy sort key
226 the object ptr value. Most typical use is for
227 associative containers holding shapes (and which also
228 have to maintain something like a paint order).
230 struct lessThanShape
232 // make functor adaptable (to boost::bind)
233 typedef bool result_type;
235 // since the ZOrder property on the XShape has somewhat
236 // peculiar attributes (it's basically the index of the shapes
237 // in the drawing layer's SdrObjList - which means, it starts
238 // from 0 for children of group objects), we cannot use it to determine
239 // drawing order. Thus, we rely on importer-provided order values here,
240 // which is basically a running counter during shape import (i.e. denotes
241 // the order of shape import). This is the correct order, at least for the
242 // current drawing core.
244 // If, someday, the above proposition is no longer true, one directly use
245 // the shape's ZOrder property
247 static bool compare(const Shape* pLHS, const Shape* pRHS)
249 const double nPrioL( pLHS->getPriority() );
250 const double nPrioR( pRHS->getPriority() );
252 // if prios are equal, tie-break on ptr value
253 return nPrioL == nPrioR ? pLHS < pRHS : nPrioL < nPrioR;
256 bool operator()(const ShapeSharedPtr& rLHS, const ShapeSharedPtr& rRHS) const
258 return compare(rLHS.get(),rRHS.get());
261 bool operator()(const Shape* pLHS, const Shape* pRHS) const
263 return compare(pLHS, pRHS);
268 typedef ::boost::shared_ptr< Shape > ShapeSharedPtr;
270 /** A set which contains all shapes in an ordered fashion.
272 typedef ::std::set< ShapeSharedPtr, Shape::lessThanShape > ShapeSet;
276 #endif /* INCLUDED_SLIDESHOW_SHAPE_HXX */