Line data Source code
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/tools/canvastools.hxx>
22 : #include <basegfx/polygon/b2dpolypolygon.hxx>
23 : #include <com/sun/star/rendering/InterpolationMode.hpp>
24 :
25 : #include <implspritecanvas.hxx>
26 : #include <implcustomsprite.hxx>
27 :
28 :
29 : using namespace ::com::sun::star;
30 :
31 : namespace cppcanvas
32 : {
33 : namespace internal
34 : {
35 0 : ImplSpriteCanvas::TransformationArbiter::TransformationArbiter() :
36 0 : maTransformation()
37 : {
38 0 : }
39 :
40 0 : void ImplSpriteCanvas::TransformationArbiter::setTransformation( const ::basegfx::B2DHomMatrix& rViewTransform )
41 : {
42 0 : maTransformation = rViewTransform;
43 0 : }
44 :
45 0 : ::basegfx::B2DHomMatrix ImplSpriteCanvas::TransformationArbiter::getTransformation() const
46 : {
47 0 : return maTransformation;
48 : }
49 :
50 :
51 0 : 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 0 : mpTransformArbiter( new TransformationArbiter() )
58 : {
59 : OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::ImplSpriteCanvas(): Invalid canvas" );
60 0 : }
61 :
62 0 : ImplSpriteCanvas::ImplSpriteCanvas(const ImplSpriteCanvas& rOrig) :
63 : Canvas(),
64 : BitmapCanvas(),
65 : SpriteCanvas(),
66 : ImplCanvas( rOrig ),
67 : ImplBitmapCanvas( rOrig ),
68 0 : mxSpriteCanvas( rOrig.getUNOSpriteCanvas() ),
69 0 : mpTransformArbiter( new TransformationArbiter() )
70 : {
71 : OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::ImplSpriteCanvas( const ImplSpriteCanvas& ): Invalid canvas" );
72 :
73 0 : mpTransformArbiter->setTransformation( getTransformation() );
74 0 : }
75 :
76 0 : ImplSpriteCanvas::~ImplSpriteCanvas()
77 : {
78 0 : }
79 :
80 0 : void ImplSpriteCanvas::setTransformation( const ::basegfx::B2DHomMatrix& rMatrix )
81 : {
82 0 : mpTransformArbiter->setTransformation( rMatrix );
83 :
84 0 : ImplCanvas::setTransformation( rMatrix );
85 0 : }
86 :
87 0 : bool ImplSpriteCanvas::updateScreen( bool bUpdateAll ) const
88 : {
89 : OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::updateScreen(): Invalid canvas" );
90 :
91 0 : if( !mxSpriteCanvas.is() )
92 0 : return false;
93 :
94 0 : return mxSpriteCanvas->updateScreen( bUpdateAll );
95 : }
96 :
97 0 : CustomSpriteSharedPtr ImplSpriteCanvas::createCustomSprite( const ::basegfx::B2DSize& rSize ) const
98 : {
99 : OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::createCustomSprite(): Invalid canvas" );
100 :
101 0 : if( !mxSpriteCanvas.is() )
102 0 : return CustomSpriteSharedPtr();
103 :
104 : return CustomSpriteSharedPtr(
105 : new ImplCustomSprite( mxSpriteCanvas,
106 0 : mxSpriteCanvas->createCustomSprite( ::basegfx::unotools::size2DFromB2DSize(rSize) ),
107 0 : mpTransformArbiter ) );
108 : }
109 :
110 0 : SpriteSharedPtr ImplSpriteCanvas::createClonedSprite( const SpriteSharedPtr& rSprite ) const
111 : {
112 : OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::createCustomSprite(): Invalid canvas" );
113 : OSL_ENSURE( rSprite.get() != NULL && rSprite->getUNOSprite().is(),
114 : "ImplSpriteCanvas::createCustomSprite(): Invalid sprite" );
115 :
116 0 : if( !mxSpriteCanvas.is() ||
117 0 : rSprite.get() == NULL ||
118 0 : !rSprite->getUNOSprite().is() )
119 : {
120 0 : return SpriteSharedPtr();
121 : }
122 :
123 : return SpriteSharedPtr(
124 : new ImplSprite( mxSpriteCanvas,
125 0 : mxSpriteCanvas->createClonedSprite( rSprite->getUNOSprite() ),
126 0 : mpTransformArbiter ) );
127 : }
128 :
129 0 : CanvasSharedPtr ImplSpriteCanvas::clone() const
130 : {
131 0 : return SpriteCanvasSharedPtr( new ImplSpriteCanvas( *this ) );
132 : }
133 :
134 0 : uno::Reference< rendering::XSpriteCanvas > ImplSpriteCanvas::getUNOSpriteCanvas() const
135 : {
136 0 : return mxSpriteCanvas;
137 : }
138 :
139 : }
140 : }
141 :
142 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|