Updated core
[LibreOffice.git] / cppcanvas / source / wrapper / implspritecanvas.cxx
blobc6b43a6a9af1a249a4b45c4dc035e11af3eacbe1
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;
45 ::basegfx::B2DHomMatrix ImplSpriteCanvas::TransformationArbiter::getTransformation() const
47 return maTransformation;
51 ImplSpriteCanvas::ImplSpriteCanvas( const uno::Reference< rendering::XSpriteCanvas >& rCanvas ) :
52 ImplCanvas( uno::Reference< rendering::XCanvas >(rCanvas,
53 uno::UNO_QUERY) ),
54 ImplBitmapCanvas( uno::Reference< rendering::XBitmapCanvas >(rCanvas,
55 uno::UNO_QUERY) ),
56 mxSpriteCanvas( rCanvas ),
57 mpTransformArbiter( new TransformationArbiter() )
59 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::ImplSpriteCanvas(): Invalid canvas" );
62 ImplSpriteCanvas::ImplSpriteCanvas(const ImplSpriteCanvas& rOrig) :
63 Canvas(),
64 BitmapCanvas(),
65 SpriteCanvas(),
66 ImplCanvas( rOrig ),
67 ImplBitmapCanvas( rOrig ),
68 mxSpriteCanvas( rOrig.getUNOSpriteCanvas() ),
69 mpTransformArbiter( new TransformationArbiter() )
71 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::ImplSpriteCanvas( const ImplSpriteCanvas& ): Invalid canvas" );
73 mpTransformArbiter->setTransformation( getTransformation() );
76 ImplSpriteCanvas::~ImplSpriteCanvas()
80 void ImplSpriteCanvas::setTransformation( const ::basegfx::B2DHomMatrix& rMatrix )
82 mpTransformArbiter->setTransformation( rMatrix );
84 ImplCanvas::setTransformation( rMatrix );
87 bool ImplSpriteCanvas::updateScreen( bool bUpdateAll ) const
89 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::updateScreen(): Invalid canvas" );
91 if( !mxSpriteCanvas.is() )
92 return false;
94 return mxSpriteCanvas->updateScreen( bUpdateAll );
97 CustomSpriteSharedPtr ImplSpriteCanvas::createCustomSprite( const ::basegfx::B2DSize& rSize ) const
99 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::createCustomSprite(): Invalid canvas" );
101 if( !mxSpriteCanvas.is() )
102 return CustomSpriteSharedPtr();
104 return CustomSpriteSharedPtr(
105 new ImplCustomSprite( mxSpriteCanvas,
106 mxSpriteCanvas->createCustomSprite( ::basegfx::unotools::size2DFromB2DSize(rSize) ),
107 mpTransformArbiter ) );
110 SpriteSharedPtr ImplSpriteCanvas::createClonedSprite( const SpriteSharedPtr& rSprite ) const
112 OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::createCustomSprite(): Invalid canvas" );
113 OSL_ENSURE( rSprite.get() != NULL && rSprite->getUNOSprite().is(),
114 "ImplSpriteCanvas::createCustomSprite(): Invalid sprite" );
116 if( !mxSpriteCanvas.is() ||
117 rSprite.get() == NULL ||
118 !rSprite->getUNOSprite().is() )
120 return SpriteSharedPtr();
123 return SpriteSharedPtr(
124 new ImplSprite( mxSpriteCanvas,
125 mxSpriteCanvas->createClonedSprite( rSprite->getUNOSprite() ),
126 mpTransformArbiter ) );
129 CanvasSharedPtr ImplSpriteCanvas::clone() const
131 return SpriteCanvasSharedPtr( new ImplSpriteCanvas( *this ) );
134 uno::Reference< rendering::XSpriteCanvas > ImplSpriteCanvas::getUNOSpriteCanvas() const
136 return mxSpriteCanvas;
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */