1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SLIDESHOW_SOURCE_INC_SHAPE_HXX
21 #define INCLUDED_SLIDESHOW_SOURCE_INC_SHAPE_HXX
23 #include <com/sun/star/uno/Reference.hxx>
24 #include <com/sun/star/drawing/XShape.hpp>
25 #include <com/sun/star/drawing/XDrawPage.hpp>
27 #include <basegfx/range/b2drectangle.hxx>
29 #include "viewlayer.hxx"
31 #include <boost/shared_ptr.hpp>
32 #include <boost/noncopyable.hpp>
44 // forward declaration necessary, because methods use ShapeSharedPtr
47 typedef ::boost::shared_ptr
< Shape
> ShapeSharedPtr
;
49 /** Represents a slide's shape object.
51 This interface represents the view-independent aspects of a
52 slide's shape, providing bound rect, underlying XShape and
55 class Shape
: private boost::noncopyable
60 /** Get the associated XShape of this shape.
62 @return the associated XShape. If this method returns
63 an empty reference, this object might be one of the
64 special-purpose shapes of a slide, which have no
65 direct corresponding XShape (the background comes to
68 virtual ::com::sun::star::uno::Reference
<
69 ::com::sun::star::drawing::XShape
> getXShape() const = 0;
75 /** Add a new view layer.
77 This method adds a new view layer, this shape shall
84 Redraw shape on given layer
86 virtual void addViewLayer( const ViewLayerSharedPtr
& rNewLayer
,
87 bool bRedrawLayer
) = 0;
89 /** Withdraw the shape from a view layer
91 This method removes the shape from the given view
94 @return true, if the shape was successfully removed
96 virtual bool removeViewLayer( const ViewLayerSharedPtr
& rNewLayer
) = 0;
98 /** Withdraw all view layers at once
100 This method will be faster than repeated
101 removeViewLayer() calls.
103 virtual bool clearAllViewLayers() = 0;
110 This method updates the Shape on all registered view
111 layers, but only if shape content has actually
114 @return whether the update finished successfully.
116 virtual bool update() const = 0;
118 /** Render the shape.
120 This method renders the shape on all registered view
121 layers, regardless of whether shape content has
124 @return whether the rendering finished successfully.
126 virtual bool render() const = 0;
128 /** Query whether shape content changed
130 This method returns true, if shape content changed
131 since the last rendering (i.e. the shape needs an
132 update to reflect that changed content on the views).
134 virtual bool isContentChanged() const = 0;
140 /** Get the current shape position and size.
142 This method yields the currently effective shape
143 bounds (which might change over time, for animated
144 shapes). Please note that possibly shape rotations
145 from its original document state must not be taken
146 into account here: if you need the screen bounding
147 box, use getUpdateArea() instead. Note further that
148 shape rotations, which are already contained in the
149 shape as displayed in the original document
150 <em>are</em> included herein (we currently take the
151 shape as-is from the document, assuming a rotation
154 virtual ::basegfx::B2DRange
getBounds() const = 0;
156 /** Get the DOM position and size of the shape.
158 This method yields the underlying DOM shape bounds,
159 i.e. the original shape bounds from the document
160 model. This value is <em>always</em> unaffected by any
161 animation activity. Note that shape rotations, which
162 are already contained in the shape as displayed in the
163 original document are already included herein (we
164 currently take the shape as-is from the document,
165 assuming a rotation angle of 0).
167 virtual ::basegfx::B2DRange
getDomBounds() const = 0;
169 /** Get the current shape update area.
171 This method yields the currently effective update area
172 for the shape, i.e. the area that needs to be updated,
173 should the shape be painted. Normally, this will be
174 the (possibly rotated and sheared) area returned by
177 virtual ::basegfx::B2DRange
getUpdateArea() const = 0;
179 /** Query whether the shape is visible at all.
181 @return true, if this shape is visible, false
184 virtual bool isVisible() const = 0;
186 /** Get the shape priority.
188 The shape priority defines the relative order of the
191 @return the priority. Will be in the [0,+infty) range.
193 virtual double getPriority() const = 0;
195 /** Query whether the Shape is currently detached from the
198 This method checks whether the Shape is currently
199 detached from the slide background, i.e. whether shape
200 updates affect the underlying slide background or
201 not. A shape that returnes true here must not alter
202 slide content in any way when called render() or
203 update() (this is normally achieved by making this
206 virtual bool isBackgroundDetached() const = 0;
211 /** Functor struct, for shape ordering
213 This defines a strict weak ordering of shapes, primary
214 sort key is the shape priority, and secondy sort key
215 the object ptr value. Most typical use is for
216 associative containers holding shapes (and which also
217 have to maintain something like a paint order).
221 // make functor adaptable (to boost::bind)
222 typedef bool result_type
;
224 // since the ZOrder property on the XShape has somewhat
225 // peculiar attributes (it's basically the index of the shapes
226 // in the drawing layer's SdrObjList - which means, it starts
227 // from 0 for children of group objects), we cannot use it to determine
228 // drawing order. Thus, we rely on importer-provided order values here,
229 // which is basically a running counter during shape import (i.e. denotes
230 // the order of shape import). This is the correct order, at least for the
231 // current drawing core.
233 // If, someday, the above proposition is no longer true, one directly use
234 // the shape's ZOrder property
236 static bool compare(const Shape
* pLHS
, const Shape
* pRHS
)
238 const double nPrioL( pLHS
->getPriority() );
239 const double nPrioR( pRHS
->getPriority() );
241 // if prios are equal, tie-break on ptr value
242 return nPrioL
== nPrioR
? pLHS
< pRHS
: nPrioL
< nPrioR
;
245 bool operator()(const ShapeSharedPtr
& rLHS
, const ShapeSharedPtr
& rRHS
) const
247 return compare(rLHS
.get(),rRHS
.get());
250 bool operator()(const Shape
* pLHS
, const Shape
* pRHS
) const
252 return compare(pLHS
, pRHS
);
257 typedef ::boost::shared_ptr
< Shape
> ShapeSharedPtr
;
259 /** A set which contains all shapes in an ordered fashion.
261 typedef ::std::set
< ShapeSharedPtr
, Shape::lessThanShape
> ShapeSet
;
265 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_SHAPE_HXX
267 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */