xref: /AOO41X/main/cppcanvas/source/wrapper/implspritecanvas.hxx (revision 2d7884914f8f9b4a298efe36f7357992ec4c096c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _CPPCANVAS_IMPLSPRITECANVAS_HXX
25 #define _CPPCANVAS_IMPLSPRITECANVAS_HXX
26 
27 #ifndef _COM_SUN_STAR_RENDERING_XSPRITECANVAS_HPP__
28 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
29 #endif
30 #include <basegfx/vector/b2dsize.hxx>
31 #include <basegfx/matrix/b2dhommatrix.hxx>
32 
33 #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
34 #include <boost/shared_ptr.hpp>
35 #endif
36 
37 
38 #include <cppcanvas/spritecanvas.hxx>
39 
40 #include <implbitmapcanvas.hxx>
41 
42 
43 namespace cppcanvas
44 {
45     namespace internal
46     {
47         class ImplSpriteCanvas : public virtual SpriteCanvas, protected virtual ImplBitmapCanvas
48         {
49         public:
50             ImplSpriteCanvas( const ::com::sun::star::uno::Reference<
51                                 ::com::sun::star::rendering::XSpriteCanvas >& rCanvas );
52             ImplSpriteCanvas(const ImplSpriteCanvas&);
53 
54             virtual ~ImplSpriteCanvas();
55 
56             virtual void                    setTransformation( const ::basegfx::B2DHomMatrix& rMatrix );
57 
58             virtual bool                    updateScreen( bool bUpdateAll ) const;
59 
60             virtual CustomSpriteSharedPtr   createCustomSprite( const ::basegfx::B2DSize& ) const;
61             virtual SpriteSharedPtr         createClonedSprite( const SpriteSharedPtr& ) const;
62 
63             SpriteSharedPtr                 createSpriteFromBitmaps(
64                 const ::com::sun::star::uno::Sequence<
65                     ::com::sun::star::uno::Reference<
66                         ::com::sun::star::rendering::XBitmap > >&   animationBitmaps,
67                 sal_Int8                                                    interpolationMode );
68 
69             virtual CanvasSharedPtr         clone() const;
70 
71             virtual ::com::sun::star::uno::Reference<
72                 ::com::sun::star::rendering::XSpriteCanvas >    getUNOSpriteCanvas() const;
73 
74             /** This class passes the view transformation
75                 to child sprites
76 
77                 This helper class is necessary, because the
78                 ImplSpriteCanvas object cannot hand out shared ptrs of
79                 itself, but has somehow pass an object to child
80                 sprites those can query for the canvas' view transform.
81              */
82             class TransformationArbiter
83             {
84             public:
85                 TransformationArbiter();
86 
87                 void                        setTransformation( const ::basegfx::B2DHomMatrix& rViewTransform );
88                 ::basegfx::B2DHomMatrix     getTransformation() const;
89 
90             private:
91                 ::basegfx::B2DHomMatrix     maTransformation;
92             };
93 
94             typedef ::boost::shared_ptr< TransformationArbiter > TransformationArbiterSharedPtr;
95 
96         private:
97             // default: disabled assignment
98             ImplSpriteCanvas& operator=( const ImplSpriteCanvas& );
99 
100             const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XSpriteCanvas >    mxSpriteCanvas;
101             TransformationArbiterSharedPtr                                                          mpTransformArbiter;
102         };
103     }
104 }
105 
106 #endif /* _CPPCANVAS_IMPLSPRITECANVAS_HXX */
107