update dev300-m58
[ooovba.git] / cppcanvas / source / wrapper / implspritecanvas.cxx
blob1f6654411bc015e0b60f5379d7e65929640d6cb1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: implspritecanvas.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_cppcanvas.hxx"
33 #include <basegfx/matrix/b2dhommatrix.hxx>
34 #include <basegfx/tools/canvastools.hxx>
35 #include <basegfx/polygon/b2dpolypolygon.hxx>
36 #include <com/sun/star/rendering/InterpolationMode.hpp>
38 #include <implspritecanvas.hxx>
39 #include <implcustomsprite.hxx>
42 using namespace ::com::sun::star;
44 namespace cppcanvas
46 namespace internal
48 ImplSpriteCanvas::TransformationArbiter::TransformationArbiter() :
49 maTransformation()
53 void ImplSpriteCanvas::TransformationArbiter::setTransformation( const ::basegfx::B2DHomMatrix& rViewTransform )
55 maTransformation = rViewTransform;
58 ::basegfx::B2DHomMatrix ImplSpriteCanvas::TransformationArbiter::getTransformation() const
60 return maTransformation;
64 ImplSpriteCanvas::ImplSpriteCanvas( const uno::Reference< rendering::XSpriteCanvas >& rCanvas ) :
65 ImplCanvas( uno::Reference< rendering::XCanvas >(rCanvas,
66 uno::UNO_QUERY) ),
67 ImplBitmapCanvas( uno::Reference< rendering::XBitmapCanvas >(rCanvas,
68 uno::UNO_QUERY) ),
69 mxSpriteCanvas( rCanvas ),
70 mpTransformArbiter( new TransformationArbiter() )
72 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::ImplSpriteCanvas(): Invalid canvas" );
75 ImplSpriteCanvas::ImplSpriteCanvas(const ImplSpriteCanvas& rOrig) :
76 Canvas(),
77 BitmapCanvas(),
78 SpriteCanvas(),
79 ImplCanvas( rOrig ),
80 ImplBitmapCanvas( rOrig ),
81 mxSpriteCanvas( rOrig.getUNOSpriteCanvas() ),
82 mpTransformArbiter( new TransformationArbiter() )
84 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::ImplSpriteCanvas( const ImplSpriteCanvas& ): Invalid canvas" );
86 mpTransformArbiter->setTransformation( getTransformation() );
89 ImplSpriteCanvas::~ImplSpriteCanvas()
93 void ImplSpriteCanvas::setTransformation( const ::basegfx::B2DHomMatrix& rMatrix )
95 mpTransformArbiter->setTransformation( rMatrix );
97 ImplCanvas::setTransformation( rMatrix );
100 bool ImplSpriteCanvas::updateScreen( bool bUpdateAll ) const
102 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::updateScreen(): Invalid canvas" );
104 if( !mxSpriteCanvas.is() )
105 return false;
107 return mxSpriteCanvas->updateScreen( bUpdateAll );
110 CustomSpriteSharedPtr ImplSpriteCanvas::createCustomSprite( const ::basegfx::B2DSize& rSize ) const
112 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::createCustomSprite(): Invalid canvas" );
114 if( !mxSpriteCanvas.is() )
115 return CustomSpriteSharedPtr();
117 return CustomSpriteSharedPtr(
118 new ImplCustomSprite( mxSpriteCanvas,
119 mxSpriteCanvas->createCustomSprite( ::basegfx::unotools::size2DFromB2DSize(rSize) ),
120 mpTransformArbiter ) );
123 SpriteSharedPtr ImplSpriteCanvas::createClonedSprite( const SpriteSharedPtr& rSprite ) const
125 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::createCustomSprite(): Invalid canvas" );
126 OSL_ENSURE( rSprite.get() != NULL && rSprite->getUNOSprite().is(),
127 "ImplSpriteCanvas::createCustomSprite(): Invalid sprite" );
129 if( !mxSpriteCanvas.is() ||
130 rSprite.get() == NULL ||
131 !rSprite->getUNOSprite().is() )
133 return SpriteSharedPtr();
136 return SpriteSharedPtr(
137 new ImplSprite( mxSpriteCanvas,
138 mxSpriteCanvas->createClonedSprite( rSprite->getUNOSprite() ),
139 mpTransformArbiter ) );
142 SpriteSharedPtr ImplSpriteCanvas::createSpriteFromBitmaps( const uno::Sequence< uno::Reference< rendering::XBitmap > >& rAnimationBitmaps,
143 sal_Int8 nInterpolationMode )
145 return SpriteSharedPtr( new internal::ImplSprite( mxSpriteCanvas,
146 mxSpriteCanvas->createSpriteFromBitmaps( rAnimationBitmaps,
147 nInterpolationMode ),
148 mpTransformArbiter ) );
151 CanvasSharedPtr ImplSpriteCanvas::clone() const
153 return SpriteCanvasSharedPtr( new ImplSpriteCanvas( *this ) );
156 uno::Reference< rendering::XSpriteCanvas > ImplSpriteCanvas::getUNOSpriteCanvas() const
158 return mxSpriteCanvas;