LibreOffice Module slideshow (master) 1
shape.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_SLIDESHOW_SOURCE_INC_SHAPE_HXX
21#define INCLUDED_SLIDESHOW_SOURCE_INC_SHAPE_HXX
22
23#include <com/sun/star/uno/Reference.hxx>
24#include <com/sun/star/drawing/XShape.hpp>
25
27
28#include "viewlayer.hxx"
29
30#include <memory>
31#include <set>
32
33namespace basegfx {
34 class B2DRange;
35}
36
37namespace slideshow::internal
38 {
39 // forward declaration necessary, because methods use ShapeSharedPtr
40 class Shape;
41
42 typedef ::std::shared_ptr< Shape > ShapeSharedPtr;
43
50 class Shape
51 {
52 public:
53 Shape() : mbIsForeground(true) {}
54 virtual ~Shape() {}
55 Shape(const Shape&) = delete;
56 Shape& operator=(const Shape&) = delete;
57
66 virtual css::uno::Reference< css::drawing::XShape > getXShape() const = 0;
67
68
69 // View layer methods
70
71
83 virtual void addViewLayer( const ViewLayerSharedPtr& rNewLayer,
84 bool bRedrawLayer ) = 0;
85
93 virtual bool removeViewLayer( const ViewLayerSharedPtr& rNewLayer ) = 0;
94
100 virtual void clearAllViewLayers() = 0;
101
102 // render methods
103
104
113 virtual bool update() const = 0;
114
123 virtual bool render() const = 0;
124
131 virtual bool isContentChanged() const = 0;
132
133
134 // Shape attributes
135
136
151 virtual ::basegfx::B2DRectangle getBounds() const = 0;
152
164 virtual ::basegfx::B2DRectangle getDomBounds() const = 0;
165
174 virtual ::basegfx::B2DRectangle getUpdateArea() const = 0;
175
181 virtual bool isVisible() const = 0;
182
190 virtual double getPriority() const = 0;
191
203 virtual bool isBackgroundDetached() const = 0;
204
212 virtual bool isForeground() const { return mbIsForeground; };
213
221 virtual void setIsForeground( const bool bIsForeground ) { mbIsForeground = bIsForeground; };
222
223 // Misc
224
225
235 {
236 // make functor adaptable (to boost::bind)
237 typedef bool result_type;
238
239 // since the ZOrder property on the XShape has somewhat
240 // peculiar attributes (it's basically the index of the shapes
241 // in the drawing layer's SdrObjList - which means, it starts
242 // from 0 for children of group objects), we cannot use it to determine
243 // drawing order. Thus, we rely on importer-provided order values here,
244 // which is basically a running counter during shape import (i.e. denotes
245 // the order of shape import). This is the correct order, at least for the
246 // current drawing core.
247
248 // If, someday, the above proposition is no longer true, one directly use
249 // the shape's ZOrder property
250
251 static bool compare(const Shape* pLHS, const Shape* pRHS)
252 {
253 const double nPrioL( pLHS->getPriority() );
254 const double nPrioR( pRHS->getPriority() );
255
256 // if prios are equal, tie-break on ptr value
257 return nPrioL == nPrioR ? pLHS < pRHS : nPrioL < nPrioR;
258 }
259
260 bool operator()(const ShapeSharedPtr& rLHS, const ShapeSharedPtr& rRHS) const
261 {
262 return compare(rLHS.get(),rRHS.get());
263 }
264
265 };
266
267 private:
273 };
274
277 typedef ::std::set< ShapeSharedPtr, Shape::lessThanShape > ShapeSet;
278
279}
280
281#endif // INCLUDED_SLIDESHOW_SOURCE_INC_SHAPE_HXX
282
283/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Represents a slide's shape object.
Definition: shape.hxx:51
virtual bool isVisible() const =0
Query whether the shape is visible at all.
virtual ::basegfx::B2DRectangle getBounds() const =0
Get the current shape position and size.
virtual void addViewLayer(const ViewLayerSharedPtr &rNewLayer, bool bRedrawLayer)=0
Add a new view layer.
bool mbIsForeground
Flag to check whether the shape belongs to the foreground.
Definition: shape.hxx:272
virtual void setIsForeground(const bool bIsForeground)
Set the flag that holds whether the shape is in the foreground or not.
Definition: shape.hxx:221
virtual ::basegfx::B2DRectangle getDomBounds() const =0
Get the DOM position and size of the shape.
virtual bool isContentChanged() const =0
Query whether shape content changed.
virtual bool isForeground() const
Check whether the shape belongs to the foreground.
Definition: shape.hxx:212
virtual ::basegfx::B2DRectangle getUpdateArea() const =0
Get the current shape update area.
Shape(const Shape &)=delete
virtual css::uno::Reference< css::drawing::XShape > getXShape() const =0
Get the associated XShape of this shape.
virtual bool removeViewLayer(const ViewLayerSharedPtr &rNewLayer)=0
Withdraw the shape from a view layer.
virtual bool update() const =0
Update the shape.
virtual void clearAllViewLayers()=0
Withdraw all view layers at once.
virtual bool isBackgroundDetached() const =0
Query whether the Shape is currently detached from the background.
virtual bool render() const =0
Render the shape.
Shape & operator=(const Shape &)=delete
virtual double getPriority() const =0
Get the shape priority.
::std::set< ShapeSharedPtr, Shape::lessThanShape > ShapeSet
A set which contains all shapes in an ordered fashion.
Definition: shape.hxx:277
std::shared_ptr< ViewLayer > ViewLayerSharedPtr
Definition: viewlayer.hxx:168
::std::shared_ptr< Shape > ShapeSharedPtr
Functor struct, for shape ordering.
Definition: shape.hxx:235
static bool compare(const Shape *pLHS, const Shape *pRHS)
Definition: shape.hxx:251
bool operator()(const ShapeSharedPtr &rLHS, const ShapeSharedPtr &rRHS) const
Definition: shape.hxx:260
Shape