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 INCLUDED_SLIDESHOW_VIEWBACKGROUNDSHAPE_HXX
25 #define INCLUDED_SLIDESHOW_VIEWBACKGROUNDSHAPE_HXX
26 
27 #include <com/sun/star/uno/Reference.hxx>
28 #include <com/sun/star/rendering/XBitmap.hpp>
29 
30 #include <basegfx/range/b2drectangle.hxx>
31 #include <basegfx/matrix/b2dhommatrix.hxx>
32 #include <cppcanvas/spritecanvas.hxx>
33 
34 #include <boost/shared_ptr.hpp>
35 #include <boost/utility.hpp>
36 
37 #include "gdimtftools.hxx"
38 #include "viewlayer.hxx"
39 
40 
41 namespace slideshow
42 {
43     namespace internal
44     {
45         /** This class is the viewable representation of a draw
46             document's background, associated to a specific View
47 
48             The class is able to render the associated background on
49             View implementations.
50          */
51         class ViewBackgroundShape : private boost::noncopyable
52         {
53         public:
54             /** Create a ViewBackgroundShape for the given View
55 
56             	@param rView
57                 The associated View object.
58 
59                 @param rShapeBounds
60                 Bounds of the background shape, in document coordinate
61                 system.
62              */
63             ViewBackgroundShape( const ViewLayerSharedPtr& 		rViewLayer,
64                                  const ::basegfx::B2DRectangle&	rShapeBounds );
65 
66 			/** Query the associated view layer of this shape
67              */
68             ViewLayerSharedPtr getViewLayer() const;
69 
70             bool render( const GDIMetaFileSharedPtr& rMtf ) const;
71 
72         private:
73             /** Prefetch bitmap for given canvas
74              */
75             bool prefetch( const ::cppcanvas::CanvasSharedPtr&	rDestinationCanvas,
76                            const GDIMetaFileSharedPtr&			rMtf ) const;
77 
78             /** The view layer this object is part of.
79              */
80             ViewLayerSharedPtr									mpViewLayer;
81 
82             /// Generated content bitmap, already with correct output size
83             mutable ::com::sun::star::uno::Reference<
84                 ::com::sun::star::rendering::XBitmap >	mxBitmap;
85 
86             /// The last metafile a render object was generated for
87             mutable GDIMetaFileSharedPtr						mpLastMtf;
88 
89             /// The canvas, mpRenderer is associated with
90             mutable ::basegfx::B2DHomMatrix						maLastTransformation;
91 
92             const ::basegfx::B2DRectangle						maBounds;
93         };
94 
95         typedef ::boost::shared_ptr< ViewBackgroundShape > ViewBackgroundShapeSharedPtr;
96 
97     }
98 }
99 
100 #endif /* INCLUDED_SLIDESHOW_VIEWBACKGROUNDSHAPE_HXX */
101