Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / cppcanvas / source / wrapper / implspritecanvas.cxx
blob3358dc090a50bf7f002e801bba3666b24e31568a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <basegfx/matrix/b2dhommatrix.hxx>
30 #include <basegfx/tools/canvastools.hxx>
31 #include <basegfx/polygon/b2dpolypolygon.hxx>
32 #include <com/sun/star/rendering/InterpolationMode.hpp>
34 #include <implspritecanvas.hxx>
35 #include <implcustomsprite.hxx>
38 using namespace ::com::sun::star;
40 namespace cppcanvas
42 namespace internal
44 ImplSpriteCanvas::TransformationArbiter::TransformationArbiter() :
45 maTransformation()
49 void ImplSpriteCanvas::TransformationArbiter::setTransformation( const ::basegfx::B2DHomMatrix& rViewTransform )
51 maTransformation = rViewTransform;
54 ::basegfx::B2DHomMatrix ImplSpriteCanvas::TransformationArbiter::getTransformation() const
56 return maTransformation;
60 ImplSpriteCanvas::ImplSpriteCanvas( const uno::Reference< rendering::XSpriteCanvas >& rCanvas ) :
61 ImplCanvas( uno::Reference< rendering::XCanvas >(rCanvas,
62 uno::UNO_QUERY) ),
63 ImplBitmapCanvas( uno::Reference< rendering::XBitmapCanvas >(rCanvas,
64 uno::UNO_QUERY) ),
65 mxSpriteCanvas( rCanvas ),
66 mpTransformArbiter( new TransformationArbiter() )
68 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::ImplSpriteCanvas(): Invalid canvas" );
71 ImplSpriteCanvas::ImplSpriteCanvas(const ImplSpriteCanvas& rOrig) :
72 Canvas(),
73 BitmapCanvas(),
74 SpriteCanvas(),
75 ImplCanvas( rOrig ),
76 ImplBitmapCanvas( rOrig ),
77 mxSpriteCanvas( rOrig.getUNOSpriteCanvas() ),
78 mpTransformArbiter( new TransformationArbiter() )
80 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::ImplSpriteCanvas( const ImplSpriteCanvas& ): Invalid canvas" );
82 mpTransformArbiter->setTransformation( getTransformation() );
85 ImplSpriteCanvas::~ImplSpriteCanvas()
89 void ImplSpriteCanvas::setTransformation( const ::basegfx::B2DHomMatrix& rMatrix )
91 mpTransformArbiter->setTransformation( rMatrix );
93 ImplCanvas::setTransformation( rMatrix );
96 bool ImplSpriteCanvas::updateScreen( bool bUpdateAll ) const
98 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::updateScreen(): Invalid canvas" );
100 if( !mxSpriteCanvas.is() )
101 return false;
103 return mxSpriteCanvas->updateScreen( bUpdateAll );
106 CustomSpriteSharedPtr ImplSpriteCanvas::createCustomSprite( const ::basegfx::B2DSize& rSize ) const
108 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::createCustomSprite(): Invalid canvas" );
110 if( !mxSpriteCanvas.is() )
111 return CustomSpriteSharedPtr();
113 return CustomSpriteSharedPtr(
114 new ImplCustomSprite( mxSpriteCanvas,
115 mxSpriteCanvas->createCustomSprite( ::basegfx::unotools::size2DFromB2DSize(rSize) ),
116 mpTransformArbiter ) );
119 SpriteSharedPtr ImplSpriteCanvas::createClonedSprite( const SpriteSharedPtr& rSprite ) const
121 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::createCustomSprite(): Invalid canvas" );
122 OSL_ENSURE( rSprite.get() != NULL && rSprite->getUNOSprite().is(),
123 "ImplSpriteCanvas::createCustomSprite(): Invalid sprite" );
125 if( !mxSpriteCanvas.is() ||
126 rSprite.get() == NULL ||
127 !rSprite->getUNOSprite().is() )
129 return SpriteSharedPtr();
132 return SpriteSharedPtr(
133 new ImplSprite( mxSpriteCanvas,
134 mxSpriteCanvas->createClonedSprite( rSprite->getUNOSprite() ),
135 mpTransformArbiter ) );
138 CanvasSharedPtr ImplSpriteCanvas::clone() const
140 return SpriteCanvasSharedPtr( new ImplSpriteCanvas( *this ) );
143 uno::Reference< rendering::XSpriteCanvas > ImplSpriteCanvas::getUNOSpriteCanvas() const
145 return mxSpriteCanvas;
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */