1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SDEXT_PRESENTER_PRESENTER_SPRITE_HXX
29 #define SDEXT_PRESENTER_PRESENTER_SPRITE_HXX
30 
31 #include <com/sun/star/rendering/XCustomSprite.hpp>
32 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
33 #include <boost/noncopyable.hpp>
34 
35 namespace css = ::com::sun::star;
36 
37 namespace sdext { namespace presenter {
38 
39 /** A wrapper around a com::sun::star::rendering::XCustomSprite that allows
40     not only setting values like size, location, and transformation but also
41     provides read access to them.
42     It also handles the showing and hiding of a sprite.  This includes not
43     to show the sprite when its size is not yet defined (results in a crash)
44     and hiding a sprite before disposing it (results in zombie sprites.)
45 */
46 class PresenterSprite
47     : private ::boost::noncopyable
48 {
49 public:
50     PresenterSprite (void);
51     virtual ~PresenterSprite (void);
52 
53     /** The given sprite canvas is used as factory to create the sprite that
54         is wrapped by objects of this class.
55         It is also used to call updateScreen() at (wrapped by the Update() method).
56     */
57     void SetFactory (
58         const ::css::uno::Reference<css::rendering::XSpriteCanvas>& rxSpriteFactory);
59 
60     ::css::uno::Reference<css::rendering::XCanvas> GetCanvas (void);
61 
62     void Show (void);
63     void Hide (void);
64     bool IsVisible (void) const;
65 
66     void SetPriority (const double nPriority);
67     double GetPriority (void) const;
68 
69     void Resize (const css::geometry::RealSize2D& rSize);
70     css::geometry::RealSize2D GetSize (void) const;
71 
72     void MoveTo (const css::geometry::RealPoint2D& rLocation);
73     css::geometry::RealPoint2D GetLocation (void) const;
74 
75     void Transform (const css::geometry::AffineMatrix2D& rTransform);
76     css::geometry::AffineMatrix2D GetTransform (void) const;
77 
78     void SetAlpha (const double nAlpha);
79     double GetAlpha (void) const;
80 
81     void Update (void);
82 
83 private:
84     ::css::uno::Reference<css::rendering::XSpriteCanvas> mxSpriteFactory;
85     ::css::uno::Reference<css::rendering::XCustomSprite> mxSprite;
86     css::geometry::RealSize2D maSize;
87     css::geometry::RealPoint2D maLocation;
88     css::geometry::AffineMatrix2D maTransform;
89     bool mbIsVisible;
90     double mnPriority;
91     double mnAlpha;
92 
93     void ProvideSprite (void);
94     void DisposeSprite (void);
95 };
96 
97 } }
98 
99 #endif
100