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 .
22 #include <canvas/debug.hxx>
23 #include <tools/diagnose_ex.h>
24 #include <slidebitmap.hxx>
26 #include <com/sun/star/rendering/XCanvas.hpp>
27 #include <com/sun/star/rendering/XBitmap.hpp>
28 #include <comphelper/anytostring.hxx>
29 #include <cppuhelper/exc_hlp.hxx>
31 #include <basegfx/matrix/b2dhommatrix.hxx>
32 #include <basegfx/matrix/b2dhommatrixtools.hxx>
34 #include <canvas/canvastools.hxx>
35 #include <basegfx/tools/canvastools.hxx>
38 using namespace ::com::sun::star
;
45 SlideBitmap::SlideBitmap( const ::cppcanvas::BitmapSharedPtr
& rBitmap
) :
51 mxBitmap
= rBitmap
->getUNOBitmap();
53 ENSURE_OR_THROW( mxBitmap
.is(), "SlideBitmap::SlideBitmap(): Invalid bitmap" );
56 bool SlideBitmap::draw( const ::cppcanvas::CanvasSharedPtr
& rCanvas
) const
58 ENSURE_OR_RETURN_FALSE( rCanvas
&& rCanvas
->getUNOCanvas().is(),
59 "SlideBitmap::draw(): Invalid canvas" );
61 // selectively only copy the transformation from current viewstate,
62 // don't want no clipping here.
63 rendering::ViewState aViewState
;
64 aViewState
.AffineTransform
= rCanvas
->getViewState().AffineTransform
;
66 rendering::RenderState aRenderState
;
67 ::canvas::tools::initRenderState( aRenderState
);
69 const basegfx::B2DHomMatrix
aTranslation(basegfx::tools::createTranslateB2DHomMatrix(maOutputPos
));
70 ::canvas::tools::setRenderStateTransform( aRenderState
, aTranslation
);
74 if( maClipPoly
.count() )
76 // TODO(P1): Buffer the clip polygon
78 ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
79 rCanvas
->getUNOCanvas()->getDevice(),
83 rCanvas
->getUNOCanvas()->drawBitmap( mxBitmap
,
87 catch( uno::Exception
& )
89 OSL_FAIL( OUStringToOString(
90 comphelper::anyToString( cppu::getCaughtException() ),
91 RTL_TEXTENCODING_UTF8
).getStr() );
99 ::basegfx::B2ISize
SlideBitmap::getSize() const
101 return ::basegfx::unotools::b2ISizeFromIntegerSize2D( mxBitmap
->getSize() );
104 void SlideBitmap::move( const ::basegfx::B2DPoint
& rNewPos
)
106 maOutputPos
= rNewPos
;
109 void SlideBitmap::clip( const ::basegfx::B2DPolyPolygon
& rClipPoly
)
111 maClipPoly
= rClipPoly
;
114 ::com::sun::star::uno::Reference
<
115 ::com::sun::star::rendering::XBitmap
> SlideBitmap::getXBitmap()
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */