LibreOffice Module slideshow (master) 1
slidebitmap.cxx
Go to the documentation of this file.
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
22#include <slidebitmap.hxx>
23
24#include <com/sun/star/rendering/XCanvas.hpp>
25#include <com/sun/star/rendering/XBitmap.hpp>
26
29
32
33
34using namespace ::com::sun::star;
35
36namespace slideshow::internal
37{
38
39 SlideBitmap::SlideBitmap( const ::cppcanvas::BitmapSharedPtr& rBitmap ) :
40 maOutputPos(),
41 maClipPoly(),
42 mxBitmap()
43 {
44 if( rBitmap )
45 mxBitmap = rBitmap->getUNOBitmap();
46
47 ENSURE_OR_THROW( mxBitmap.is(), "SlideBitmap::SlideBitmap(): Invalid bitmap" );
48 }
49
50 bool SlideBitmap::draw( const ::cppcanvas::CanvasSharedPtr& rCanvas ) const
51 {
52 ENSURE_OR_RETURN_FALSE( rCanvas && rCanvas->getUNOCanvas().is(),
53 "SlideBitmap::draw(): Invalid canvas" );
54
55 // selectively only copy the transformation from current viewstate,
56 // don't want no clipping here.
57 rendering::ViewState aViewState;
58 aViewState.AffineTransform = rCanvas->getViewState().AffineTransform;
59
60 rendering::RenderState aRenderState;
61 ::canvas::tools::initRenderState( aRenderState );
62
64 ::canvas::tools::setRenderStateTransform( aRenderState, aTranslation );
65
66 try
67 {
68 if( maClipPoly.count() )
69 {
70 // TODO(P1): Buffer the clip polygon
71 aRenderState.Clip =
72 ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
73 rCanvas->getUNOCanvas()->getDevice(),
74 maClipPoly );
75 }
76
77 rCanvas->getUNOCanvas()->drawBitmap( mxBitmap,
78 aViewState,
79 aRenderState );
80 }
81 catch( uno::Exception& )
82 {
83 TOOLS_WARN_EXCEPTION( "slideshow", "" );
84 return false;
85 }
86
87 return true;
88 }
89
91 {
92 return ::basegfx::unotools::b2ISizeFromIntegerSize2D( mxBitmap->getSize() );
93 }
94
95 void SlideBitmap::move( const ::basegfx::B2DPoint& rNewPos )
96 {
97 maOutputPos = rNewPos;
98 }
99
100 void SlideBitmap::clip( const ::basegfx::B2DPolyPolygon& rClipPoly )
101 {
102 maClipPoly = rClipPoly;
103 }
104
105 const css::uno::Reference< css::rendering::XBitmap >& SlideBitmap::getXBitmap() const
106 {
107 return mxBitmap;
108 }
109
110}
111
112/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt32 count() const
::basegfx::B2ISize getSize() const
Definition: slidebitmap.cxx:90
const css::uno::Reference< css::rendering::XBitmap > & getXBitmap() const
::basegfx::B2DPolyPolygon maClipPoly
Definition: slidebitmap.hxx:70
css::uno::Reference< css::rendering::XBitmap > mxBitmap
Definition: slidebitmap.hxx:73
SlideBitmap(const ::cppcanvas::BitmapSharedPtr &rBitmap)
Definition: slidebitmap.cxx:39
::basegfx::B2DPoint maOutputPos
Definition: slidebitmap.hxx:69
bool draw(const ::cppcanvas::CanvasSharedPtr &rCanvas) const
Definition: slidebitmap.cxx:50
void clip(const ::basegfx::B2DPolyPolygon &rClipPoly)
void move(const ::basegfx::B2DPoint &rNewPos)
Definition: slidebitmap.cxx:95
VclPtr< VirtualDevice > mxBitmap
#define TOOLS_WARN_EXCEPTION(area, stream)
#define ENSURE_OR_RETURN_FALSE(c, m)
#define ENSURE_OR_THROW(c, m)
B2DHomMatrix createTranslateB2DHomMatrix(double fTranslateX, double fTranslateY)