Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / cppcanvas / source / wrapper / implspritecanvas.cxx
blob21a9ae4e0a18f0bbce2239e9ab8be8642da2fc8f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <basegfx/matrix/b2dhommatrix.hxx>
21 #include <basegfx/tools/canvastools.hxx>
22 #include <basegfx/polygon/b2dpolypolygon.hxx>
23 #include <com/sun/star/rendering/InterpolationMode.hpp>
25 #include <implspritecanvas.hxx>
26 #include <implcustomsprite.hxx>
29 using namespace ::com::sun::star;
31 namespace cppcanvas
33 namespace internal
35 ImplSpriteCanvas::TransformationArbiter::TransformationArbiter() :
36 maTransformation()
40 void ImplSpriteCanvas::TransformationArbiter::setTransformation( const ::basegfx::B2DHomMatrix& rViewTransform )
42 maTransformation = rViewTransform;
46 ImplSpriteCanvas::ImplSpriteCanvas( const uno::Reference< rendering::XSpriteCanvas >& rCanvas ) :
47 ImplCanvas( uno::Reference< rendering::XCanvas >(rCanvas,
48 uno::UNO_QUERY) ),
49 mxSpriteCanvas( rCanvas ),
50 mpTransformArbiter( new TransformationArbiter() )
52 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::ImplSpriteCanvas(): Invalid canvas" );
55 ImplSpriteCanvas::ImplSpriteCanvas(const ImplSpriteCanvas& rOrig) :
56 Canvas(),
57 SpriteCanvas(),
58 ImplCanvas( rOrig ),
59 mxSpriteCanvas( rOrig.getUNOSpriteCanvas() ),
60 mpTransformArbiter( new TransformationArbiter() )
62 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::ImplSpriteCanvas( const ImplSpriteCanvas& ): Invalid canvas" );
64 mpTransformArbiter->setTransformation( getTransformation() );
67 ImplSpriteCanvas::~ImplSpriteCanvas()
71 void ImplSpriteCanvas::setTransformation( const ::basegfx::B2DHomMatrix& rMatrix )
73 mpTransformArbiter->setTransformation( rMatrix );
75 ImplCanvas::setTransformation( rMatrix );
78 bool ImplSpriteCanvas::updateScreen( bool bUpdateAll ) const
80 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::updateScreen(): Invalid canvas" );
82 if( !mxSpriteCanvas.is() )
83 return false;
85 return mxSpriteCanvas->updateScreen( bUpdateAll );
88 CustomSpriteSharedPtr ImplSpriteCanvas::createCustomSprite( const ::basegfx::B2DSize& rSize ) const
90 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::createCustomSprite(): Invalid canvas" );
92 if( !mxSpriteCanvas.is() )
93 return CustomSpriteSharedPtr();
95 return CustomSpriteSharedPtr(
96 new ImplCustomSprite( mxSpriteCanvas,
97 mxSpriteCanvas->createCustomSprite( ::basegfx::unotools::size2DFromB2DSize(rSize) ),
98 mpTransformArbiter ) );
101 CanvasSharedPtr ImplSpriteCanvas::clone() const
103 return SpriteCanvasSharedPtr( new ImplSpriteCanvas( *this ) );
106 uno::Reference< rendering::XSpriteCanvas > ImplSpriteCanvas::getUNOSpriteCanvas() const
108 return mxSpriteCanvas;
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */