merge the formfield patch from ooo-build
[ooovba.git] / canvas / source / tools / cachedprimitivebase.cxx
blob89b89253ca91d5f6bc863d3540831c36586e3344
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: cachedprimitivebase.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 <canvas/debug.hxx>
35 #include <canvas/base/cachedprimitivebase.hxx>
37 #include <com/sun/star/rendering/RepaintResult.hpp>
39 #include <basegfx/matrix/b2dhommatrix.hxx>
40 #include <basegfx/tools/canvastools.hxx>
43 using namespace ::com::sun::star;
45 #define IMPLEMENTATION_NAME "canvas::CachedPrimitiveBase"
46 #define SERVICE_NAME "com.sun.star.rendering.CachedBitmap"
48 namespace canvas
50 CachedPrimitiveBase::CachedPrimitiveBase( const rendering::ViewState& rUsedViewState,
51 const uno::Reference< rendering::XCanvas >& rTarget,
52 bool bFailForChangedViewTransform ) :
53 CachedPrimitiveBase_Base( m_aMutex ),
54 maUsedViewState( rUsedViewState ),
55 mxTarget( rTarget ),
56 mbFailForChangedViewTransform( bFailForChangedViewTransform )
60 CachedPrimitiveBase::~CachedPrimitiveBase()
64 void SAL_CALL CachedPrimitiveBase::disposing()
66 ::osl::MutexGuard aGuard( m_aMutex );
68 maUsedViewState.Clip.clear();
69 mxTarget.clear();
72 sal_Int8 SAL_CALL CachedPrimitiveBase::redraw( const rendering::ViewState& aState ) throw (lang::IllegalArgumentException, uno::RuntimeException)
74 ::basegfx::B2DHomMatrix aUsedTransformation;
75 ::basegfx::B2DHomMatrix aNewTransformation;
77 ::basegfx::unotools::homMatrixFromAffineMatrix( aUsedTransformation,
78 maUsedViewState.AffineTransform );
79 ::basegfx::unotools::homMatrixFromAffineMatrix( aNewTransformation,
80 aState.AffineTransform );
82 const bool bSameViewTransforms( aUsedTransformation == aNewTransformation );
84 if( mbFailForChangedViewTransform &&
85 !bSameViewTransforms )
87 // differing transformations, don't try to draft the
88 // output, just plain fail here.
89 return rendering::RepaintResult::FAILED;
92 return doRedraw( aState,
93 maUsedViewState,
94 mxTarget,
95 bSameViewTransforms );
98 ::rtl::OUString SAL_CALL CachedPrimitiveBase::getImplementationName( ) throw (uno::RuntimeException)
100 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) );
103 sal_Bool SAL_CALL CachedPrimitiveBase::supportsService( const ::rtl::OUString& ServiceName ) throw (uno::RuntimeException)
105 return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
108 uno::Sequence< ::rtl::OUString > SAL_CALL CachedPrimitiveBase::getSupportedServiceNames( ) throw (uno::RuntimeException)
110 uno::Sequence< ::rtl::OUString > aRet(1);
111 aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
113 return aRet;