2004-03-18 03:41:15 -06:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 04:17:48 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2004-03-18 03:41:15 -06:00
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2004-03-18 03:41:15 -06:00
|
|
|
*
|
2008-04-11 04:17:48 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-03-18 03:41:15 -06:00
|
|
|
*
|
2008-04-11 04:17:48 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2004-03-18 03:41:15 -06:00
|
|
|
*
|
2008-04-11 04:17:48 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2004-03-18 03:41:15 -06:00
|
|
|
*
|
2008-04-11 04:17:48 -05:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2004-03-18 03:41:15 -06:00
|
|
|
*
|
2008-04-11 04:17:48 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2004-03-18 03:41:15 -06:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 06:51:30 -05:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_cppcanvas.hxx"
|
|
|
|
|
2008-06-24 05:50:40 -05:00
|
|
|
#include "implbitmap.hxx"
|
|
|
|
#include "implbitmapcanvas.hxx"
|
2004-03-18 03:41:15 -06:00
|
|
|
|
2008-06-24 05:50:40 -05:00
|
|
|
#include <basegfx/matrix/b2dhommatrix.hxx>
|
2005-04-18 04:01:43 -05:00
|
|
|
#include <canvas/canvastools.hxx>
|
|
|
|
|
2004-03-18 03:41:15 -06:00
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
|
|
|
namespace cppcanvas
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace internal
|
|
|
|
{
|
|
|
|
|
|
|
|
ImplBitmap::ImplBitmap( const CanvasSharedPtr& rParentCanvas,
|
|
|
|
const uno::Reference< rendering::XBitmap >& rBitmap ) :
|
|
|
|
CanvasGraphicHelper( rParentCanvas ),
|
|
|
|
mxBitmap( rBitmap ),
|
2005-03-10 06:28:06 -06:00
|
|
|
mpBitmapCanvas()
|
2004-03-18 03:41:15 -06:00
|
|
|
{
|
|
|
|
OSL_ENSURE( mxBitmap.is(), "ImplBitmap::ImplBitmap: no valid bitmap" );
|
2005-03-10 06:28:06 -06:00
|
|
|
|
|
|
|
uno::Reference< rendering::XBitmapCanvas > xBitmapCanvas( rBitmap,
|
|
|
|
uno::UNO_QUERY );
|
|
|
|
if( xBitmapCanvas.is() )
|
|
|
|
mpBitmapCanvas.reset( new ImplBitmapCanvas(
|
|
|
|
uno::Reference< rendering::XBitmapCanvas >(rBitmap,
|
|
|
|
uno::UNO_QUERY) ) );
|
2004-03-18 03:41:15 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
ImplBitmap::~ImplBitmap()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ImplBitmap::draw() const
|
|
|
|
{
|
|
|
|
CanvasSharedPtr pCanvas( getCanvas() );
|
|
|
|
|
|
|
|
OSL_ENSURE( pCanvas.get() != NULL &&
|
|
|
|
pCanvas->getUNOCanvas().is(),
|
|
|
|
"ImplBitmap::draw: invalid canvas" );
|
|
|
|
|
|
|
|
if( pCanvas.get() == NULL ||
|
2004-11-26 13:58:48 -06:00
|
|
|
!pCanvas->getUNOCanvas().is() )
|
|
|
|
{
|
2004-03-18 03:41:15 -06:00
|
|
|
return false;
|
2004-11-26 13:58:48 -06:00
|
|
|
}
|
2004-03-18 03:41:15 -06:00
|
|
|
|
2004-11-26 13:58:48 -06:00
|
|
|
// TODO(P1): implement caching
|
2004-03-18 03:41:15 -06:00
|
|
|
pCanvas->getUNOCanvas()->drawBitmap( mxBitmap,
|
|
|
|
pCanvas->getViewState(),
|
2005-11-02 06:42:47 -06:00
|
|
|
getRenderState() );
|
2004-03-18 03:41:15 -06:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-11-26 13:58:48 -06:00
|
|
|
bool ImplBitmap::drawAlphaModulated( double nAlphaModulation ) const
|
|
|
|
{
|
|
|
|
CanvasSharedPtr pCanvas( getCanvas() );
|
|
|
|
|
|
|
|
OSL_ENSURE( pCanvas.get() != NULL &&
|
|
|
|
pCanvas->getUNOCanvas().is(),
|
|
|
|
"ImplBitmap::drawAlphaModulated(): invalid canvas" );
|
|
|
|
|
|
|
|
if( pCanvas.get() == NULL ||
|
|
|
|
!pCanvas->getUNOCanvas().is() )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-11-02 06:42:47 -06:00
|
|
|
rendering::RenderState aLocalState( getRenderState() );
|
2008-06-24 05:50:40 -05:00
|
|
|
uno::Sequence<rendering::ARGBColor> aCol(1);
|
|
|
|
aCol[0] = rendering::ARGBColor( nAlphaModulation, 1.0, 1.0, 1.0 );
|
|
|
|
aLocalState.DeviceColor =
|
|
|
|
pCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace()->convertFromARGB(aCol);
|
2004-11-26 13:58:48 -06:00
|
|
|
|
|
|
|
// TODO(P1): implement caching
|
|
|
|
pCanvas->getUNOCanvas()->drawBitmapModulated( mxBitmap,
|
|
|
|
pCanvas->getViewState(),
|
|
|
|
aLocalState );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-03-18 03:41:15 -06:00
|
|
|
BitmapCanvasSharedPtr ImplBitmap::getBitmapCanvas() const
|
|
|
|
{
|
|
|
|
return mpBitmapCanvas;
|
|
|
|
}
|
|
|
|
|
|
|
|
uno::Reference< rendering::XBitmap > ImplBitmap::getUNOBitmap() const
|
|
|
|
{
|
|
|
|
return mxBitmap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|