Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include <canvas/debug.hxx>
22 : #include <tools/diagnose_ex.h>
23 : #include <canvas/verbosetrace.hxx>
24 :
25 : #include <rtl/logfile.hxx>
26 : #include <rtl/math.hxx>
27 :
28 : #include <canvas/canvastools.hxx>
29 :
30 : #include <basegfx/matrix/b2dhommatrix.hxx>
31 : #include <basegfx/point/b2dpoint.hxx>
32 :
33 : #include "null_canvascustomsprite.hxx"
34 : #include "null_spritecanvas.hxx"
35 :
36 :
37 : using namespace ::com::sun::star;
38 :
39 : namespace nullcanvas
40 : {
41 0 : CanvasCustomSprite::CanvasCustomSprite( const ::com::sun::star::geometry::RealSize2D& rSpriteSize,
42 : const SpriteCanvasRef& rRefDevice ) :
43 0 : mpSpriteCanvas( rRefDevice )
44 : {
45 0 : ENSURE_OR_THROW( rRefDevice.get(),
46 : "CanvasCustomSprite::CanvasCustomSprite(): Invalid sprite canvas" );
47 :
48 : maCanvasHelper.init( ::basegfx::B2ISize(
49 : ::canvas::tools::roundUp( rSpriteSize.Width ),
50 : ::canvas::tools::roundUp( rSpriteSize.Height ) ),
51 0 : *rRefDevice.get(),
52 0 : true );
53 :
54 : maSpriteHelper.init( rSpriteSize,
55 0 : rRefDevice );
56 0 : }
57 :
58 0 : void CanvasCustomSprite::disposeThis()
59 : {
60 0 : ::osl::MutexGuard aGuard( m_aMutex );
61 :
62 0 : mpSpriteCanvas.clear();
63 :
64 : // forward to parent
65 0 : CanvasCustomSpriteBaseT::disposeThis();
66 0 : }
67 :
68 0 : void CanvasCustomSprite::redraw() const
69 : {
70 0 : ::osl::MutexGuard aGuard( m_aMutex );
71 :
72 0 : maSpriteHelper.redraw( mbSurfaceDirty );
73 0 : }
74 :
75 : #define IMPLEMENTATION_NAME "NullCanvas.CanvasCustomSprite"
76 : #define SERVICE_NAME "com.sun.star.rendering.CanvasCustomSprite"
77 :
78 0 : ::rtl::OUString SAL_CALL CanvasCustomSprite::getImplementationName() throw( uno::RuntimeException )
79 : {
80 0 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) );
81 : }
82 :
83 0 : sal_Bool SAL_CALL CanvasCustomSprite::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException )
84 : {
85 0 : return ServiceName == SERVICE_NAME;
86 : }
87 :
88 0 : uno::Sequence< ::rtl::OUString > SAL_CALL CanvasCustomSprite::getSupportedServiceNames() throw( uno::RuntimeException )
89 : {
90 0 : uno::Sequence< ::rtl::OUString > aRet(1);
91 0 : aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
92 :
93 0 : return aRet;
94 : }
95 0 : }
96 :
97 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|