Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <canvas/debug.hxx>
31 : : #include <canvas/base/cachedprimitivebase.hxx>
32 : :
33 : : #include <com/sun/star/rendering/RepaintResult.hpp>
34 : :
35 : : #include <basegfx/matrix/b2dhommatrix.hxx>
36 : : #include <basegfx/tools/canvastools.hxx>
37 : :
38 : :
39 : : using namespace ::com::sun::star;
40 : :
41 : : #define IMPLEMENTATION_NAME "canvas::CachedPrimitiveBase"
42 : : #define SERVICE_NAME "com.sun.star.rendering.CachedBitmap"
43 : :
44 : : namespace canvas
45 : : {
46 : 0 : CachedPrimitiveBase::CachedPrimitiveBase( const rendering::ViewState& rUsedViewState,
47 : : const uno::Reference< rendering::XCanvas >& rTarget,
48 : : bool bFailForChangedViewTransform ) :
49 : : CachedPrimitiveBase_Base( m_aMutex ),
50 : : maUsedViewState( rUsedViewState ),
51 : : mxTarget( rTarget ),
52 [ # # ][ # # ]: 0 : mbFailForChangedViewTransform( bFailForChangedViewTransform )
53 : : {
54 : 0 : }
55 : :
56 [ # # ][ # # ]: 0 : CachedPrimitiveBase::~CachedPrimitiveBase()
57 : : {
58 [ # # ]: 0 : }
59 : :
60 : 0 : void SAL_CALL CachedPrimitiveBase::disposing()
61 : : {
62 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
63 : :
64 : 0 : maUsedViewState.Clip.clear();
65 [ # # ]: 0 : mxTarget.clear();
66 : 0 : }
67 : :
68 : 0 : sal_Int8 SAL_CALL CachedPrimitiveBase::redraw( const rendering::ViewState& aState ) throw (lang::IllegalArgumentException, uno::RuntimeException)
69 : : {
70 [ # # ]: 0 : ::basegfx::B2DHomMatrix aUsedTransformation;
71 [ # # ]: 0 : ::basegfx::B2DHomMatrix aNewTransformation;
72 : :
73 : : ::basegfx::unotools::homMatrixFromAffineMatrix( aUsedTransformation,
74 [ # # ]: 0 : maUsedViewState.AffineTransform );
75 : : ::basegfx::unotools::homMatrixFromAffineMatrix( aNewTransformation,
76 [ # # ]: 0 : aState.AffineTransform );
77 : :
78 [ # # ]: 0 : const bool bSameViewTransforms( aUsedTransformation == aNewTransformation );
79 : :
80 [ # # ][ # # ]: 0 : if( mbFailForChangedViewTransform &&
81 : 0 : !bSameViewTransforms )
82 : : {
83 : : // differing transformations, don't try to draft the
84 : : // output, just plain fail here.
85 : 0 : return rendering::RepaintResult::FAILED;
86 : : }
87 : :
88 : : return doRedraw( aState,
89 : : maUsedViewState,
90 : : mxTarget,
91 [ # # ][ # # ]: 0 : bSameViewTransforms );
[ # # ]
92 : : }
93 : :
94 : 0 : ::rtl::OUString SAL_CALL CachedPrimitiveBase::getImplementationName( ) throw (uno::RuntimeException)
95 : : {
96 : 0 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) );
97 : : }
98 : :
99 : 0 : sal_Bool SAL_CALL CachedPrimitiveBase::supportsService( const ::rtl::OUString& ServiceName ) throw (uno::RuntimeException)
100 : : {
101 : 0 : return ServiceName == SERVICE_NAME;
102 : : }
103 : :
104 : 0 : uno::Sequence< ::rtl::OUString > SAL_CALL CachedPrimitiveBase::getSupportedServiceNames( ) throw (uno::RuntimeException)
105 : : {
106 : 0 : uno::Sequence< ::rtl::OUString > aRet(1);
107 [ # # ][ # # ]: 0 : aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
108 : :
109 : 0 : return aRet;
110 : : }
111 : : }
112 : :
113 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|