| 1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the LibreOffice project. |
| 4 |
* |
| 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/. |
| 8 |
* |
| 9 |
* This file incorporates work covered by the following license notice: |
| 10 |
* |
| 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 . |
| 18 |
*/ |
| 19 |
|
| 20 |
#include <basegfx/matrix/b2dhommatrix.hxx> |
| 21 |
#include <basegfx/utils/canvastools.hxx> |
| 22 |
#include <osl/diagnose.h> |
| 23 |
|
| 24 |
#include "implspritecanvas.hxx" |
| 25 |
#include "implcustomsprite.hxx" |
| 26 |
|
| 27 |
|
| 28 |
using namespace ::com::sun::star; |
| 29 |
|
| 30 |
namespace cppcanvas::internal |
| 31 |
{ |
| 32 |
ImplSpriteCanvas::TransformationArbiter::TransformationArbiter() : |
| 33 |
maTransformation() |
| 34 |
{ |
| 35 |
} |
| 36 |
|
| 37 |
void ImplSpriteCanvas::TransformationArbiter::setTransformation( const ::basegfx::B2DHomMatrix& rViewTransform ) |
| 38 |
{ |
| 39 |
maTransformation = rViewTransform; |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
ImplSpriteCanvas::ImplSpriteCanvas( const uno::Reference< rendering::XSpriteCanvas >& rCanvas ) : |
| 44 |
ImplCanvas( rCanvas ), |
| 45 |
mxSpriteCanvas( rCanvas ), |
| 46 |
mpTransformArbiter( std::make_shared<TransformationArbiter>() ) |
| 47 |
{ |
| 48 |
OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::ImplSpriteCanvas(): Invalid canvas" ); |
| 49 |
} |
| 50 |
|
| 51 |
ImplSpriteCanvas::ImplSpriteCanvas(const ImplSpriteCanvas& rOrig) : |
| 52 |
Canvas(), |
| 53 |
SpriteCanvas(), |
| 54 |
ImplCanvas( rOrig ), |
| 55 |
mxSpriteCanvas( rOrig.getUNOSpriteCanvas() ), |
| 56 |
mpTransformArbiter( std::make_shared<TransformationArbiter>() ) |
| 57 |
{ |
| 58 |
OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::ImplSpriteCanvas( const ImplSpriteCanvas& ): Invalid canvas" ); |
| 59 |
|
| 60 |
mpTransformArbiter->setTransformation( getTransformation() ); |
| 61 |
} |
| 62 |
|
| 63 |
ImplSpriteCanvas::~ImplSpriteCanvas() |
| 64 |
{ |
| 65 |
} |
| 66 |
|
| 67 |
void ImplSpriteCanvas::setTransformation( const ::basegfx::B2DHomMatrix& rMatrix ) |
| 68 |
{ |
| 69 |
mpTransformArbiter->setTransformation( rMatrix ); |
| 70 |
|
| 71 |
ImplCanvas::setTransformation( rMatrix ); |
| 72 |
} |
| 73 |
|
| 74 |
bool ImplSpriteCanvas::updateScreen( bool bUpdateAll ) const |
| 75 |
{ |
| 76 |
OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::updateScreen(): Invalid canvas" ); |
| 77 |
|
| 78 |
if( !mxSpriteCanvas.is() ) |
| 79 |
return false; |
| 80 |
|
| 81 |
return mxSpriteCanvas->updateScreen( bUpdateAll ); |
| 82 |
} |
| 83 |
|
| 84 |
CustomSpriteSharedPtr ImplSpriteCanvas::createCustomSprite( const ::basegfx::B2DSize& rSize ) const |
| 85 |
{ |
| 86 |
OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::createCustomSprite(): Invalid canvas" ); |
| 87 |
|
| 88 |
if( !mxSpriteCanvas.is() ) |
| 89 |
return CustomSpriteSharedPtr(); |
| 90 |
|
| 91 |
return std::make_shared<ImplCustomSprite>( mxSpriteCanvas, |
| 92 |
mxSpriteCanvas->createCustomSprite( ::basegfx::unotools::size2DFromB2DSize(rSize) ), |
| 93 |
mpTransformArbiter ); |
| 94 |
} |
| 95 |
|
| 96 |
CanvasSharedPtr ImplSpriteCanvas::clone() const |
| 97 |
{ |
| 98 |
return std::make_shared<ImplSpriteCanvas>( *this ); |
| 99 |
} |
| 100 |
|
| 101 |
uno::Reference< rendering::XSpriteCanvas > ImplSpriteCanvas::getUNOSpriteCanvas() const |
| 102 |
{ |
| 103 |
return mxSpriteCanvas; |
| 104 |
} |
| 105 |
|
| 106 |
} |
| 107 |
|
| 108 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |