Branch libreoffice-5-0-4
[LibreOffice.git] / canvas / source / tools / cachedprimitivebase.cxx
blob29f204121ac0e76d56d6589ce845255b621d49f9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <canvas/debug.hxx>
22 #include <canvas/base/cachedprimitivebase.hxx>
24 #include <com/sun/star/rendering/RepaintResult.hpp>
25 #include <cppuhelper/supportsservice.hxx>
27 #include <basegfx/matrix/b2dhommatrix.hxx>
28 #include <basegfx/tools/canvastools.hxx>
30 using namespace ::com::sun::star;
32 namespace canvas
34 CachedPrimitiveBase::CachedPrimitiveBase( const rendering::ViewState& rUsedViewState,
35 const uno::Reference< rendering::XCanvas >& rTarget,
36 bool bFailForChangedViewTransform ) :
37 CachedPrimitiveBase_Base( m_aMutex ),
38 maUsedViewState( rUsedViewState ),
39 mxTarget( rTarget ),
40 mbFailForChangedViewTransform( bFailForChangedViewTransform )
44 CachedPrimitiveBase::~CachedPrimitiveBase()
48 void SAL_CALL CachedPrimitiveBase::disposing()
50 ::osl::MutexGuard aGuard( m_aMutex );
52 maUsedViewState.Clip.clear();
53 mxTarget.clear();
56 sal_Int8 SAL_CALL CachedPrimitiveBase::redraw( const rendering::ViewState& aState ) throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
58 ::basegfx::B2DHomMatrix aUsedTransformation;
59 ::basegfx::B2DHomMatrix aNewTransformation;
61 ::basegfx::unotools::homMatrixFromAffineMatrix( aUsedTransformation,
62 maUsedViewState.AffineTransform );
63 ::basegfx::unotools::homMatrixFromAffineMatrix( aNewTransformation,
64 aState.AffineTransform );
66 const bool bSameViewTransforms( aUsedTransformation == aNewTransformation );
68 if( mbFailForChangedViewTransform &&
69 !bSameViewTransforms )
71 // differing transformations, don't try to draft the
72 // output, just plain fail here.
73 return rendering::RepaintResult::FAILED;
76 return doRedraw( aState,
77 maUsedViewState,
78 mxTarget,
79 bSameViewTransforms );
82 OUString SAL_CALL CachedPrimitiveBase::getImplementationName( ) throw (uno::RuntimeException, std::exception)
84 return OUString("canvas::CachedPrimitiveBase");
87 sal_Bool SAL_CALL CachedPrimitiveBase::supportsService( const OUString& ServiceName ) throw (uno::RuntimeException, std::exception)
89 return cppu::supportsService(this, ServiceName);
92 uno::Sequence< OUString > SAL_CALL CachedPrimitiveBase::getSupportedServiceNames( ) throw (uno::RuntimeException, std::exception)
94 uno::Sequence< OUString > aRet(1);
95 aRet[0] = "com.sun.star.rendering.CachedBitmap";
97 return aRet;
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */