Bump version to 5.0-14
[LibreOffice.git] / cppcanvas / source / wrapper / implspritecanvas.cxx
blob9138d1d724f44c9a8caf18c0b8c1383280b1691f
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;
47 ImplSpriteCanvas::ImplSpriteCanvas( const uno::Reference< rendering::XSpriteCanvas >& rCanvas ) :
48 ImplCanvas( uno::Reference< rendering::XCanvas >(rCanvas,
49 uno::UNO_QUERY) ),
50 mxSpriteCanvas( rCanvas ),
51 mpTransformArbiter( new TransformationArbiter() )
53 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::ImplSpriteCanvas(): Invalid canvas" );
56 ImplSpriteCanvas::ImplSpriteCanvas(const ImplSpriteCanvas& rOrig) :
57 Canvas(),
58 SpriteCanvas(),
59 ImplCanvas( rOrig ),
60 mxSpriteCanvas( rOrig.getUNOSpriteCanvas() ),
61 mpTransformArbiter( new TransformationArbiter() )
63 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::ImplSpriteCanvas( const ImplSpriteCanvas& ): Invalid canvas" );
65 mpTransformArbiter->setTransformation( getTransformation() );
68 ImplSpriteCanvas::~ImplSpriteCanvas()
72 void ImplSpriteCanvas::setTransformation( const ::basegfx::B2DHomMatrix& rMatrix )
74 mpTransformArbiter->setTransformation( rMatrix );
76 ImplCanvas::setTransformation( rMatrix );
79 bool ImplSpriteCanvas::updateScreen( bool bUpdateAll ) const
81 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::updateScreen(): Invalid canvas" );
83 if( !mxSpriteCanvas.is() )
84 return false;
86 return mxSpriteCanvas->updateScreen( bUpdateAll );
89 CustomSpriteSharedPtr ImplSpriteCanvas::createCustomSprite( const ::basegfx::B2DSize& rSize ) const
91 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::createCustomSprite(): Invalid canvas" );
93 if( !mxSpriteCanvas.is() )
94 return CustomSpriteSharedPtr();
96 return CustomSpriteSharedPtr(
97 new ImplCustomSprite( mxSpriteCanvas,
98 mxSpriteCanvas->createCustomSprite( ::basegfx::unotools::size2DFromB2DSize(rSize) ),
99 mpTransformArbiter ) );
102 SpriteSharedPtr ImplSpriteCanvas::createClonedSprite( const SpriteSharedPtr& rSprite ) const
104 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::createCustomSprite(): Invalid canvas" );
105 OSL_ENSURE( rSprite.get() != NULL && rSprite->getUNOSprite().is(),
106 "ImplSpriteCanvas::createCustomSprite(): Invalid sprite" );
108 if( !mxSpriteCanvas.is() ||
109 rSprite.get() == NULL ||
110 !rSprite->getUNOSprite().is() )
112 return SpriteSharedPtr();
115 return SpriteSharedPtr(
116 new ImplSprite( mxSpriteCanvas,
117 mxSpriteCanvas->createClonedSprite( rSprite->getUNOSprite() ),
118 mpTransformArbiter ) );
121 CanvasSharedPtr ImplSpriteCanvas::clone() const
123 return SpriteCanvasSharedPtr( new ImplSpriteCanvas( *this ) );
126 uno::Reference< rendering::XSpriteCanvas > ImplSpriteCanvas::getUNOSpriteCanvas() const
128 return mxSpriteCanvas;
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */