2010-10-12 15:51:52 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-11 09:51:50 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2004-03-18 09:44:39 +00:00
|
|
|
|
2006-09-17 07:28:53 +00:00
|
|
|
|
2008-06-24 11:02:54 +00:00
|
|
|
#include <tools/diagnose_ex.h>
|
2004-11-26 17:59:01 +00:00
|
|
|
#include <slidebitmap.hxx>
|
2004-03-18 09:44:39 +00:00
|
|
|
|
2005-03-10 12:45:00 +00:00
|
|
|
#include <com/sun/star/rendering/XCanvas.hpp>
|
|
|
|
#include <com/sun/star/rendering/XBitmap.hpp>
|
2007-07-17 13:40:28 +00:00
|
|
|
#include <comphelper/anytostring.hxx>
|
|
|
|
#include <cppuhelper/exc_hlp.hxx>
|
2004-03-18 09:44:39 +00:00
|
|
|
|
2004-11-26 17:59:01 +00:00
|
|
|
#include <basegfx/matrix/b2dhommatrix.hxx>
|
2009-09-22 18:14:05 +02:00
|
|
|
#include <basegfx/matrix/b2dhommatrixtools.hxx>
|
2004-11-26 17:59:01 +00:00
|
|
|
|
2004-03-18 09:44:39 +00:00
|
|
|
#include <canvas/canvastools.hxx>
|
2017-09-22 14:12:07 +03:00
|
|
|
#include <basegfx/utils/canvastools.hxx>
|
2004-03-18 09:44:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
2006-12-13 14:20:24 +00:00
|
|
|
namespace slideshow
|
2004-03-18 09:44:39 +00:00
|
|
|
{
|
|
|
|
namespace internal
|
|
|
|
{
|
|
|
|
|
|
|
|
SlideBitmap::SlideBitmap( const ::cppcanvas::BitmapSharedPtr& rBitmap ) :
|
2004-11-26 17:59:01 +00:00
|
|
|
maOutputPos(),
|
|
|
|
maClipPoly(),
|
|
|
|
mxBitmap()
|
2004-03-18 09:44:39 +00:00
|
|
|
{
|
2006-12-13 14:20:24 +00:00
|
|
|
if( rBitmap )
|
2004-11-26 17:59:01 +00:00
|
|
|
mxBitmap = rBitmap->getUNOBitmap();
|
|
|
|
|
2008-06-24 11:02:54 +00:00
|
|
|
ENSURE_OR_THROW( mxBitmap.is(), "SlideBitmap::SlideBitmap(): Invalid bitmap" );
|
2004-03-18 09:44:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SlideBitmap::draw( const ::cppcanvas::CanvasSharedPtr& rCanvas ) const
|
|
|
|
{
|
2010-01-29 08:49:42 +01:00
|
|
|
ENSURE_OR_RETURN_FALSE( rCanvas && rCanvas->getUNOCanvas().is(),
|
2004-11-26 17:59:01 +00:00
|
|
|
"SlideBitmap::draw(): Invalid canvas" );
|
2004-03-18 09:44:39 +00:00
|
|
|
|
2004-11-26 17:59:01 +00:00
|
|
|
// selectively only copy the transformation from current viewstate,
|
|
|
|
// don't want no clipping here.
|
|
|
|
rendering::ViewState aViewState;
|
|
|
|
aViewState.AffineTransform = rCanvas->getViewState().AffineTransform;
|
2004-03-18 09:44:39 +00:00
|
|
|
|
|
|
|
rendering::RenderState aRenderState;
|
|
|
|
::canvas::tools::initRenderState( aRenderState );
|
|
|
|
|
2017-09-22 14:12:07 +03:00
|
|
|
const basegfx::B2DHomMatrix aTranslation(basegfx::utils::createTranslateB2DHomMatrix(maOutputPos));
|
2004-11-26 17:59:01 +00:00
|
|
|
::canvas::tools::setRenderStateTransform( aRenderState, aTranslation );
|
|
|
|
|
2007-07-17 13:40:28 +00:00
|
|
|
try
|
2004-11-26 17:59:01 +00:00
|
|
|
{
|
2007-07-17 13:40:28 +00:00
|
|
|
if( maClipPoly.count() )
|
|
|
|
{
|
|
|
|
// TODO(P1): Buffer the clip polygon
|
|
|
|
aRenderState.Clip =
|
|
|
|
::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
|
|
|
|
rCanvas->getUNOCanvas()->getDevice(),
|
|
|
|
maClipPoly );
|
|
|
|
}
|
|
|
|
|
|
|
|
rCanvas->getUNOCanvas()->drawBitmap( mxBitmap,
|
|
|
|
aViewState,
|
|
|
|
aRenderState );
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
2017-05-26 10:58:42 +02:00
|
|
|
SAL_WARN( "slideshow", comphelper::anyToString( cppu::getCaughtException() ) );
|
2007-07-17 13:40:28 +00:00
|
|
|
return false;
|
2004-11-26 17:59:01 +00:00
|
|
|
}
|
|
|
|
|
2004-03-18 09:44:39 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
::basegfx::B2ISize SlideBitmap::getSize() const
|
|
|
|
{
|
|
|
|
return ::basegfx::unotools::b2ISizeFromIntegerSize2D( mxBitmap->getSize() );
|
|
|
|
}
|
|
|
|
|
2004-11-26 17:59:01 +00:00
|
|
|
void SlideBitmap::move( const ::basegfx::B2DPoint& rNewPos )
|
|
|
|
{
|
|
|
|
maOutputPos = rNewPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SlideBitmap::clip( const ::basegfx::B2DPolyPolygon& rClipPoly )
|
|
|
|
{
|
|
|
|
maClipPoly = rClipPoly;
|
|
|
|
}
|
|
|
|
|
2016-04-13 15:38:30 +02:00
|
|
|
const css::uno::Reference< css::rendering::XBitmap >& SlideBitmap::getXBitmap()
|
2007-11-09 09:16:18 +00:00
|
|
|
{
|
|
|
|
return mxBitmap;
|
|
|
|
}
|
|
|
|
|
2004-03-18 09:44:39 +00:00
|
|
|
}
|
|
|
|
}
|
2010-10-12 15:51:52 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|