1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
;
35 ImplSpriteCanvas::TransformationArbiter::TransformationArbiter() :
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
,
54 mxSpriteCanvas( rCanvas
),
55 mpTransformArbiter( new TransformationArbiter() )
57 OSL_ENSURE( mxSpriteCanvas
.is(), "ImplSpriteCanvas::ImplSpriteCanvas(): Invalid canvas" );
60 ImplSpriteCanvas::ImplSpriteCanvas(const ImplSpriteCanvas
& rOrig
) :
64 mxSpriteCanvas( rOrig
.getUNOSpriteCanvas() ),
65 mpTransformArbiter( new TransformationArbiter() )
67 OSL_ENSURE( mxSpriteCanvas
.is(), "ImplSpriteCanvas::ImplSpriteCanvas( const ImplSpriteCanvas& ): Invalid canvas" );
69 mpTransformArbiter
->setTransformation( getTransformation() );
72 ImplSpriteCanvas::~ImplSpriteCanvas()
76 void ImplSpriteCanvas::setTransformation( const ::basegfx::B2DHomMatrix
& rMatrix
)
78 mpTransformArbiter
->setTransformation( rMatrix
);
80 ImplCanvas::setTransformation( rMatrix
);
83 bool ImplSpriteCanvas::updateScreen( bool bUpdateAll
) const
85 OSL_ENSURE( mxSpriteCanvas
.is(), "ImplSpriteCanvas::updateScreen(): Invalid canvas" );
87 if( !mxSpriteCanvas
.is() )
90 return mxSpriteCanvas
->updateScreen( bUpdateAll
);
93 CustomSpriteSharedPtr
ImplSpriteCanvas::createCustomSprite( const ::basegfx::B2DSize
& rSize
) const
95 OSL_ENSURE( mxSpriteCanvas
.is(), "ImplSpriteCanvas::createCustomSprite(): Invalid canvas" );
97 if( !mxSpriteCanvas
.is() )
98 return CustomSpriteSharedPtr();
100 return CustomSpriteSharedPtr(
101 new ImplCustomSprite( mxSpriteCanvas
,
102 mxSpriteCanvas
->createCustomSprite( ::basegfx::unotools::size2DFromB2DSize(rSize
) ),
103 mpTransformArbiter
) );
106 SpriteSharedPtr
ImplSpriteCanvas::createClonedSprite( const SpriteSharedPtr
& rSprite
) const
108 OSL_ENSURE( mxSpriteCanvas
.is(), "ImplSpriteCanvas::createCustomSprite(): Invalid canvas" );
109 OSL_ENSURE( rSprite
.get() != NULL
&& rSprite
->getUNOSprite().is(),
110 "ImplSpriteCanvas::createCustomSprite(): Invalid sprite" );
112 if( !mxSpriteCanvas
.is() ||
113 rSprite
.get() == NULL
||
114 !rSprite
->getUNOSprite().is() )
116 return SpriteSharedPtr();
119 return SpriteSharedPtr(
120 new ImplSprite( mxSpriteCanvas
,
121 mxSpriteCanvas
->createClonedSprite( rSprite
->getUNOSprite() ),
122 mpTransformArbiter
) );
125 CanvasSharedPtr
ImplSpriteCanvas::clone() const
127 return SpriteCanvasSharedPtr( new ImplSpriteCanvas( *this ) );
130 uno::Reference
< rendering::XSpriteCanvas
> ImplSpriteCanvas::getUNOSpriteCanvas() const
132 return mxSpriteCanvas
;
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */