1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef INCLUDED_SLIDESHOW_SHAPE_HXX
30 #define INCLUDED_SLIDESHOW_SHAPE_HXX
32 #include <com/sun/star/uno/Reference.hxx>
33 #include <com/sun/star/drawing/XShape.hpp>
34 #include <com/sun/star/drawing/XDrawPage.hpp>
36 #include <basegfx/range/b2drectangle.hxx>
38 #include "viewlayer.hxx"
40 #include <boost/shared_ptr.hpp>
41 #include <boost/noncopyable.hpp>
53 // forward declaration necessary, because methods use ShapeSharedPtr
56 typedef ::boost::shared_ptr
< Shape
> ShapeSharedPtr
;
58 /** Represents a slide's shape object.
60 This interface represents the view-independent aspects of a
61 slide's shape, providing bound rect, underlying XShape and
64 class Shape
: private boost::noncopyable
69 /** Get the associated XShape of this shape.
71 @return the associated XShape. If this method returns
72 an empty reference, this object might be one of the
73 special-purpose shapes of a slide, which have no
74 direct corresponding XShape (the background comes to
77 virtual ::com::sun::star::uno::Reference
<
78 ::com::sun::star::drawing::XShape
> getXShape() const = 0;
82 //------------------------------------------------------------------
84 /** Add a new view layer.
86 This method adds a new view layer, this shape shall
93 Redraw shape on given layer
95 virtual void addViewLayer( const ViewLayerSharedPtr
& rNewLayer
,
96 bool bRedrawLayer
) = 0;
98 /** Withdraw the shape from a view layer
100 This method removes the shape from the given view
103 @return true, if the shape was successfully removed
105 virtual bool removeViewLayer( const ViewLayerSharedPtr
& rNewLayer
) = 0;
107 /** Withdraw all view layers at once
109 This method will be faster than repeated
110 removeViewLayer() calls.
112 virtual bool clearAllViewLayers() = 0;
115 //------------------------------------------------------------------
119 This method updates the Shape on all registered view
120 layers, but only if shape content has actually
123 @return whether the update finished successfully.
125 virtual bool update() const = 0;
127 /** Render the shape.
129 This method renders the shape on all registered view
130 layers, regardless of whether shape content has
133 @return whether the rendering finished successfully.
135 virtual bool render() const = 0;
137 /** Query whether shape content changed
139 This method returns true, if shape content changed
140 since the last rendering (i.e. the shape needs an
141 update to reflect that changed content on the views).
143 virtual bool isContentChanged() const = 0;
147 //------------------------------------------------------------------
149 /** Get the current shape position and size.
151 This method yields the currently effective shape
152 bounds (which might change over time, for animated
153 shapes). Please note that possibly shape rotations
154 from its original document state must not be taken
155 into account here: if you need the screen bounding
156 box, use getUpdateArea() instead. Note further that
157 shape rotations, which are already contained in the
158 shape as displayed in the original document
159 <em>are</em> included herein (we currently take the
160 shape as-is from the document, assuming a rotation
163 virtual ::basegfx::B2DRange
getBounds() const = 0;
165 /** Get the DOM position and size of the shape.
167 This method yields the underlying DOM shape bounds,
168 i.e. the original shape bounds from the document
169 model. This value is <em>always</em> unaffected by any
170 animation activity. Note that shape rotations, which
171 are already contained in the shape as displayed in the
172 original document are already included herein (we
173 currently take the shape as-is from the document,
174 assuming a rotation angle of 0).
176 virtual ::basegfx::B2DRange
getDomBounds() const = 0;
178 /** Get the current shape update area.
180 This method yields the currently effective update area
181 for the shape, i.e. the area that needs to be updated,
182 should the shape be painted. Normally, this will be
183 the (possibly rotated and sheared) area returned by
186 virtual ::basegfx::B2DRange
getUpdateArea() const = 0;
188 /** Query whether the shape is visible at all.
190 @return true, if this shape is visible, false
193 virtual bool isVisible() const = 0;
195 /** Get the shape priority.
197 The shape priority defines the relative order of the
200 @return the priority. Will be in the [0,+infty) range.
202 virtual double getPriority() const = 0;
204 /** Query whether the Shape is currently detached from the
207 This method checks whether the Shape is currently
208 detached from the slide background, i.e. whether shape
209 updates affect the underlying slide background or
210 not. A shape that returnes true here must not alter
211 slide content in any way when called render() or
212 update() (this is normally achieved by making this
215 virtual bool isBackgroundDetached() const = 0;
218 //------------------------------------------------------------------
220 /** Functor struct, for shape ordering
222 This defines a strict weak ordering of shapes, primary
223 sort key is the shape priority, and secondy sort key
224 the object ptr value. Most typical use is for
225 associative containers holding shapes (and which also
226 have to maintain something like a paint order).
230 // make functor adaptable (to boost::bind)
231 typedef bool result_type
;
233 // since the ZOrder property on the XShape has somewhat
234 // peculiar attributes (it's basically the index of the shapes
235 // in the drawing layer's SdrObjList - which means, it starts
236 // from 0 for children of group objects), we cannot use it to determine
237 // drawing order. Thus, we rely on importer-provided order values here,
238 // which is basically a running counter during shape import (i.e. denotes
239 // the order of shape import). This is the correct order, at least for the
240 // current drawing core.
242 // If, someday, the above proposition is no longer true, one directly use
243 // the shape's ZOrder property
245 static bool compare(const Shape
* pLHS
, const Shape
* pRHS
)
247 const double nPrioL( pLHS
->getPriority() );
248 const double nPrioR( pRHS
->getPriority() );
250 // if prios are equal, tie-break on ptr value
251 return nPrioL
== nPrioR
? pLHS
< pRHS
: nPrioL
< nPrioR
;
254 bool operator()(const ShapeSharedPtr
& rLHS
, const ShapeSharedPtr
& rRHS
) const
256 return compare(rLHS
.get(),rRHS
.get());
259 bool operator()(const Shape
* pLHS
, const Shape
* pRHS
) const
261 return compare(pLHS
, pRHS
);
266 typedef ::boost::shared_ptr
< Shape
> ShapeSharedPtr
;
268 /** A set which contains all shapes in an ordered fashion.
270 typedef ::std::set
< ShapeSharedPtr
, Shape::lessThanShape
> ShapeSet
;
274 #endif /* INCLUDED_SLIDESHOW_SHAPE_HXX */
276 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */