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/utils/canvastools.hxx>
22 #include <osl/diagnose.h>
24 #include "implspritecanvas.hxx"
25 #include "implcustomsprite.hxx"
28 using namespace ::com::sun::star
;
30 namespace cppcanvas::internal
32 ImplSpriteCanvas::TransformationArbiter::TransformationArbiter() :
37 void ImplSpriteCanvas::TransformationArbiter::setTransformation( const ::basegfx::B2DHomMatrix
& rViewTransform
)
39 maTransformation
= rViewTransform
;
43 ImplSpriteCanvas::ImplSpriteCanvas( const uno::Reference
< rendering::XSpriteCanvas
>& rCanvas
) :
44 ImplCanvas( rCanvas
),
45 mxSpriteCanvas( rCanvas
),
46 mpTransformArbiter( std::make_shared
<TransformationArbiter
>() )
48 OSL_ENSURE( mxSpriteCanvas
.is(), "ImplSpriteCanvas::ImplSpriteCanvas(): Invalid canvas" );
51 ImplSpriteCanvas::ImplSpriteCanvas(const ImplSpriteCanvas
& rOrig
) :
55 mxSpriteCanvas( rOrig
.getUNOSpriteCanvas() ),
56 mpTransformArbiter( std::make_shared
<TransformationArbiter
>() )
58 OSL_ENSURE( mxSpriteCanvas
.is(), "ImplSpriteCanvas::ImplSpriteCanvas( const ImplSpriteCanvas& ): Invalid canvas" );
60 mpTransformArbiter
->setTransformation( getTransformation() );
63 ImplSpriteCanvas::~ImplSpriteCanvas()
67 void ImplSpriteCanvas::setTransformation( const ::basegfx::B2DHomMatrix
& rMatrix
)
69 mpTransformArbiter
->setTransformation( rMatrix
);
71 ImplCanvas::setTransformation( rMatrix
);
74 bool ImplSpriteCanvas::updateScreen( bool bUpdateAll
) const
76 OSL_ENSURE( mxSpriteCanvas
.is(), "ImplSpriteCanvas::updateScreen(): Invalid canvas" );
78 if( !mxSpriteCanvas
.is() )
81 return mxSpriteCanvas
->updateScreen( bUpdateAll
);
84 CustomSpriteSharedPtr
ImplSpriteCanvas::createCustomSprite( const ::basegfx::B2DSize
& rSize
) const
86 OSL_ENSURE( mxSpriteCanvas
.is(), "ImplSpriteCanvas::createCustomSprite(): Invalid canvas" );
88 if( !mxSpriteCanvas
.is() )
89 return CustomSpriteSharedPtr();
91 return std::make_shared
<ImplCustomSprite
>( mxSpriteCanvas
,
92 mxSpriteCanvas
->createCustomSprite( ::basegfx::unotools::size2DFromB2DSize(rSize
) ),
96 CanvasSharedPtr
ImplSpriteCanvas::clone() const
98 return std::make_shared
<ImplSpriteCanvas
>( *this );
101 uno::Reference
< rendering::XSpriteCanvas
> ImplSpriteCanvas::getUNOSpriteCanvas() const
103 return mxSpriteCanvas
;
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */