1*25b11142SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*25b11142SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*25b11142SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*25b11142SAndrew Rist  * distributed with this work for additional information
6*25b11142SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*25b11142SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*25b11142SAndrew Rist  * "License"); you may not use this file except in compliance
9*25b11142SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*25b11142SAndrew Rist  *
11*25b11142SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*25b11142SAndrew Rist  *
13*25b11142SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*25b11142SAndrew Rist  * software distributed under the License is distributed on an
15*25b11142SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*25b11142SAndrew Rist  * KIND, either express or implied.  See the License for the
17*25b11142SAndrew Rist  * specific language governing permissions and limitations
18*25b11142SAndrew Rist  * under the License.
19*25b11142SAndrew Rist  *
20*25b11142SAndrew Rist  *************************************************************/
21*25b11142SAndrew Rist 
22*25b11142SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_cppcanvas.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygon.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "implcustomsprite.hxx"
30cdf0e10cSrcweir #include "implcanvas.hxx"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir using namespace ::com::sun::star;
33cdf0e10cSrcweir 
34cdf0e10cSrcweir namespace cppcanvas
35cdf0e10cSrcweir {
36cdf0e10cSrcweir     namespace internal
37cdf0e10cSrcweir     {
ImplCustomSprite(const uno::Reference<rendering::XSpriteCanvas> & rParentCanvas,const uno::Reference<rendering::XCustomSprite> & rSprite,const ImplSpriteCanvas::TransformationArbiterSharedPtr & rTransformArbiter)38cdf0e10cSrcweir         ImplCustomSprite::ImplCustomSprite( const uno::Reference< rendering::XSpriteCanvas >& 		rParentCanvas,
39cdf0e10cSrcweir                                             const uno::Reference< rendering::XCustomSprite >& 		rSprite,
40cdf0e10cSrcweir                                             const ImplSpriteCanvas::TransformationArbiterSharedPtr&	rTransformArbiter ) :
41cdf0e10cSrcweir             ImplSprite( rParentCanvas,
42cdf0e10cSrcweir                         uno::Reference< rendering::XSprite >(rSprite,
43cdf0e10cSrcweir                                                              uno::UNO_QUERY),
44cdf0e10cSrcweir                         rTransformArbiter ),
45cdf0e10cSrcweir             mpLastCanvas(),
46cdf0e10cSrcweir             mxCustomSprite( rSprite )
47cdf0e10cSrcweir         {
48cdf0e10cSrcweir             OSL_ENSURE( rParentCanvas.is(), "ImplCustomSprite::ImplCustomSprite(): Invalid canvas" );
49cdf0e10cSrcweir             OSL_ENSURE( mxCustomSprite.is(), "ImplCustomSprite::ImplCustomSprite(): Invalid sprite" );
50cdf0e10cSrcweir         }
51cdf0e10cSrcweir 
~ImplCustomSprite()52cdf0e10cSrcweir         ImplCustomSprite::~ImplCustomSprite()
53cdf0e10cSrcweir         {
54cdf0e10cSrcweir         }
55cdf0e10cSrcweir 
getContentCanvas() const56cdf0e10cSrcweir         CanvasSharedPtr ImplCustomSprite::getContentCanvas() const
57cdf0e10cSrcweir         {
58cdf0e10cSrcweir             OSL_ENSURE( mxCustomSprite.is(), "ImplCustomSprite::getContentCanvas(): Invalid sprite" );
59cdf0e10cSrcweir 
60cdf0e10cSrcweir             if( !mxCustomSprite.is() )
61cdf0e10cSrcweir                 return CanvasSharedPtr();
62cdf0e10cSrcweir 
63cdf0e10cSrcweir             uno::Reference< rendering::XCanvas > xCanvas( mxCustomSprite->getContentCanvas() );
64cdf0e10cSrcweir 
65cdf0e10cSrcweir             if( !xCanvas.is() )
66cdf0e10cSrcweir                 return CanvasSharedPtr();
67cdf0e10cSrcweir 
68cdf0e10cSrcweir             // cache content canvas C++ wrapper
69cdf0e10cSrcweir             if( mpLastCanvas.get() == NULL ||
70cdf0e10cSrcweir                 mpLastCanvas->getUNOCanvas() != xCanvas )
71cdf0e10cSrcweir             {
72cdf0e10cSrcweir                 mpLastCanvas = CanvasSharedPtr( new ImplCanvas( xCanvas ) );
73cdf0e10cSrcweir             }
74cdf0e10cSrcweir 
75cdf0e10cSrcweir             return mpLastCanvas;
76cdf0e10cSrcweir         }
77cdf0e10cSrcweir     }
78cdf0e10cSrcweir }
79