1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <tools/diagnose_ex.h>
22 #include <slidebitmap.hxx>
24 #include <com/sun/star/rendering/XCanvas.hpp>
25 #include <com/sun/star/rendering/XBitmap.hpp>
26 #include <comphelper/anytostring.hxx>
27 #include <cppuhelper/exc_hlp.hxx>
29 #include <basegfx/matrix/b2dhommatrix.hxx>
30 #include <basegfx/matrix/b2dhommatrixtools.hxx>
32 #include <canvas/canvastools.hxx>
33 #include <basegfx/utils/canvastools.hxx>
36 using namespace ::com::sun::star
;
43 SlideBitmap::SlideBitmap( const ::cppcanvas::BitmapSharedPtr
& rBitmap
) :
49 mxBitmap
= rBitmap
->getUNOBitmap();
51 ENSURE_OR_THROW( mxBitmap
.is(), "SlideBitmap::SlideBitmap(): Invalid bitmap" );
54 bool SlideBitmap::draw( const ::cppcanvas::CanvasSharedPtr
& rCanvas
) const
56 ENSURE_OR_RETURN_FALSE( rCanvas
&& rCanvas
->getUNOCanvas().is(),
57 "SlideBitmap::draw(): Invalid canvas" );
59 // selectively only copy the transformation from current viewstate,
60 // don't want no clipping here.
61 rendering::ViewState aViewState
;
62 aViewState
.AffineTransform
= rCanvas
->getViewState().AffineTransform
;
64 rendering::RenderState aRenderState
;
65 ::canvas::tools::initRenderState( aRenderState
);
67 const basegfx::B2DHomMatrix
aTranslation(basegfx::utils::createTranslateB2DHomMatrix(maOutputPos
));
68 ::canvas::tools::setRenderStateTransform( aRenderState
, aTranslation
);
72 if( maClipPoly
.count() )
74 // TODO(P1): Buffer the clip polygon
76 ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
77 rCanvas
->getUNOCanvas()->getDevice(),
81 rCanvas
->getUNOCanvas()->drawBitmap( mxBitmap
,
85 catch( uno::Exception
& )
87 SAL_WARN( "slideshow", comphelper::anyToString( cppu::getCaughtException() ) );
94 ::basegfx::B2ISize
SlideBitmap::getSize() const
96 return ::basegfx::unotools::b2ISizeFromIntegerSize2D( mxBitmap
->getSize() );
99 void SlideBitmap::move( const ::basegfx::B2DPoint
& rNewPos
)
101 maOutputPos
= rNewPos
;
104 void SlideBitmap::clip( const ::basegfx::B2DPolyPolygon
& rClipPoly
)
106 maClipPoly
= rClipPoly
;
109 const css::uno::Reference
< css::rendering::XBitmap
>& SlideBitmap::getXBitmap()
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */