merge the formfield patch from ooo-build
[ooovba.git] / canvas / source / directx / dx_canvascustomsprite.cxx
blob0d59379517aa20941235a32c2d07827101adb427
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dx_canvascustomsprite.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_canvas.hxx"
34 #include <ctype.h> // don't ask. msdev breaks otherwise...
35 #include <canvas/debug.hxx>
36 #include <canvas/verbosetrace.hxx>
37 #include <tools/diagnose_ex.h>
39 #include <rtl/logfile.hxx>
40 #include <rtl/math.hxx>
42 #include <canvas/canvastools.hxx>
44 #include <basegfx/matrix/b2dhommatrix.hxx>
45 #include <basegfx/point/b2dpoint.hxx>
47 #include "dx_canvascustomsprite.hxx"
48 #include "dx_spritecanvas.hxx"
49 #include "dx_impltools.hxx"
51 using namespace ::com::sun::star;
53 namespace dxcanvas
55 CanvasCustomSprite::CanvasCustomSprite( const ::com::sun::star::geometry::RealSize2D& rSpriteSize,
56 const SpriteCanvasRef& rRefDevice,
57 const IDXRenderModuleSharedPtr& rRenderModule,
58 const ::canvas::ISurfaceProxyManagerSharedPtr& rSurfaceProxy,
59 bool bShowSpriteBounds ) :
60 mpSpriteCanvas( rRefDevice ),
61 mpSurface()
63 ENSURE_OR_THROW( rRefDevice.get(),
64 "CanvasCustomSprite::CanvasCustomSprite(): Invalid sprite canvas" );
66 mpSurface.reset(
67 new DXSurfaceBitmap(
68 ::basegfx::B2IVector(
69 ::canvas::tools::roundUp( rSpriteSize.Width ),
70 ::canvas::tools::roundUp( rSpriteSize.Height )),
71 rSurfaceProxy,
72 rRenderModule,
73 true));
75 maCanvasHelper.setDevice( *rRefDevice.get() );
76 maCanvasHelper.setTarget( mpSurface );
78 maSpriteHelper.init( rSpriteSize,
79 rRefDevice,
80 rRenderModule,
81 mpSurface,
82 bShowSpriteBounds );
84 // clear sprite to 100% transparent
85 maCanvasHelper.clear();
88 void SAL_CALL CanvasCustomSprite::disposing()
90 ::osl::MutexGuard aGuard( m_aMutex );
92 mpSurface.reset();
93 mpSpriteCanvas.clear();
95 // forward to parent
96 CanvasCustomSpriteBaseT::disposing();
99 #define IMPLEMENTATION_NAME "DXCanvas.CanvasCustomSprite"
100 #define SERVICE_NAME "com.sun.star.rendering.CanvasCustomSprite"
102 ::rtl::OUString SAL_CALL CanvasCustomSprite::getImplementationName() throw( uno::RuntimeException )
104 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) );
107 sal_Bool SAL_CALL CanvasCustomSprite::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException )
109 return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
112 uno::Sequence< ::rtl::OUString > SAL_CALL CanvasCustomSprite::getSupportedServiceNames() throw( uno::RuntimeException )
114 uno::Sequence< ::rtl::OUString > aRet(1);
115 aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
117 return aRet;
120 void CanvasCustomSprite::redraw() const
122 ::osl::MutexGuard aGuard( m_aMutex );
124 maSpriteHelper.redraw( mbSurfaceDirty );