2004-03-18 09:38:44 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-07 22:23:21 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-03-18 09:38:44 +00:00
|
|
|
*
|
2005-09-07 22:23:21 +00:00
|
|
|
* $RCSfile: spritecanvas.cxx,v $
|
2004-03-18 09:38:44 +00:00
|
|
|
*
|
2006-06-20 01:20:57 +00:00
|
|
|
* $Revision: 1.11 $
|
2004-03-18 09:38:44 +00:00
|
|
|
*
|
2006-06-20 01:20:57 +00:00
|
|
|
* last change: $Author: hr $ $Date: 2006-06-20 02:20:57 $
|
2004-03-18 09:38:44 +00:00
|
|
|
*
|
2005-09-07 22:23:21 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2004-03-18 09:38:44 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-07 22:23:21 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2004-03-18 09:38:44 +00:00
|
|
|
*
|
2005-09-07 22:23:21 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2004-03-18 09:38:44 +00:00
|
|
|
*
|
2005-09-07 22:23:21 +00:00
|
|
|
* This library 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 for more details.
|
2004-03-18 09:38:44 +00:00
|
|
|
*
|
2005-09-07 22:23:21 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2004-03-18 09:38:44 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2004-11-26 16:15:27 +00:00
|
|
|
#include <canvas/debug.hxx>
|
2005-11-02 12:04:13 +00:00
|
|
|
#include <canvas/verbosetrace.hxx>
|
|
|
|
#include <canvas/canvastools.hxx>
|
2004-03-18 09:38:44 +00:00
|
|
|
|
|
|
|
#include <com/sun/star/registry/XRegistryKey.hpp>
|
|
|
|
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
|
|
|
|
#include <com/sun/star/uno/XComponentContext.hpp>
|
|
|
|
|
|
|
|
#include <cppuhelper/factory.hxx>
|
|
|
|
#include <cppuhelper/implementationentry.hxx>
|
|
|
|
|
2004-11-26 16:15:27 +00:00
|
|
|
#include <vcl/canvastools.hxx>
|
|
|
|
#include <vcl/outdev.hxx>
|
|
|
|
#include <vcl/window.hxx>
|
|
|
|
#include <vcl/bitmapex.hxx>
|
2004-03-18 09:38:44 +00:00
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
#include <basegfx/tools/canvastools.hxx>
|
2004-03-18 09:38:44 +00:00
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
#include <algorithm>
|
2004-03-18 09:38:44 +00:00
|
|
|
|
|
|
|
#include "spritecanvas.hxx"
|
|
|
|
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
using namespace ::com::sun::star;
|
2004-11-26 16:15:27 +00:00
|
|
|
|
2004-03-18 09:38:44 +00:00
|
|
|
#define IMPLEMENTATION_NAME "VCLCanvas::SpriteCanvas"
|
2005-03-10 11:00:56 +00:00
|
|
|
#define SERVICE_NAME "com.sun.star.rendering.VCLCanvas"
|
2004-03-18 09:38:44 +00:00
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
static ::rtl::OUString SAL_CALL getImplementationName_SpriteCanvas()
|
|
|
|
{
|
|
|
|
return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
static uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_SpriteCanvas()
|
|
|
|
{
|
|
|
|
uno::Sequence< ::rtl::OUString > aRet(1);
|
|
|
|
aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
|
|
|
|
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace vclcanvas
|
|
|
|
{
|
|
|
|
SpriteCanvas::SpriteCanvas( const uno::Reference< uno::XComponentContext >& rxContext ) :
|
2005-11-02 12:04:13 +00:00
|
|
|
mxComponentContext( rxContext )
|
|
|
|
{
|
|
|
|
OSL_TRACE( "SpriteCanvas created" );
|
|
|
|
|
|
|
|
// add our own property to GraphicDevice
|
|
|
|
maPropHelper.addProperties(
|
|
|
|
::canvas::PropertySetHelper::MakeMap
|
|
|
|
("UnsafeScrolling",
|
|
|
|
boost::bind(&SpriteCanvasHelper::isUnsafeScrolling,
|
|
|
|
boost::ref(maCanvasHelper)),
|
|
|
|
boost::bind(&SpriteCanvasHelper::enableUnsafeScrolling,
|
|
|
|
boost::ref(maCanvasHelper),
|
|
|
|
_1))
|
|
|
|
("SpriteBounds",
|
|
|
|
boost::bind(&SpriteCanvasHelper::isSpriteBounds,
|
|
|
|
boost::ref(maCanvasHelper)),
|
|
|
|
boost::bind(&SpriteCanvasHelper::enableSpriteBounds,
|
|
|
|
boost::ref(maCanvasHelper),
|
|
|
|
_1)));
|
2004-03-18 09:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SpriteCanvas::~SpriteCanvas()
|
|
|
|
{
|
2005-11-02 12:04:13 +00:00
|
|
|
OSL_TRACE( "SpriteCanvas destroyed" );
|
2004-03-18 09:38:44 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
|
2004-11-26 16:15:27 +00:00
|
|
|
void SAL_CALL SpriteCanvas::disposing()
|
2004-03-18 09:38:44 +00:00
|
|
|
{
|
|
|
|
tools::LocalGuard aGuard;
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
mxComponentContext.clear();
|
2004-11-26 16:15:27 +00:00
|
|
|
|
|
|
|
// forward to parent
|
2005-11-02 12:04:13 +00:00
|
|
|
SpriteCanvasBaseT::disposing();
|
2004-03-18 09:38:44 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
::sal_Bool SAL_CALL SpriteCanvas::showBuffer( ::sal_Bool bUpdateAll ) throw (uno::RuntimeException)
|
2004-03-18 09:38:44 +00:00
|
|
|
{
|
|
|
|
tools::LocalGuard aGuard;
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
// avoid repaints on hidden window (hidden: not mapped to
|
|
|
|
// screen). Return failure, since the screen really has _not_
|
|
|
|
// been updated (caller should try again later)
|
|
|
|
return !mbIsVisible ? false : SpriteCanvasBaseT::showBuffer( bUpdateAll );
|
2004-03-18 09:38:44 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
::sal_Bool SAL_CALL SpriteCanvas::switchBuffer( ::sal_Bool bUpdateAll ) throw (uno::RuntimeException)
|
2004-03-18 09:38:44 +00:00
|
|
|
{
|
|
|
|
tools::LocalGuard aGuard;
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
// avoid repaints on hidden window (hidden: not mapped to
|
|
|
|
// screen). Return failure, since the screen really has _not_
|
|
|
|
// been updated (caller should try again later)
|
|
|
|
return !mbIsVisible ? false : SpriteCanvasBaseT::switchBuffer( bUpdateAll );
|
2004-03-18 09:38:44 +00:00
|
|
|
}
|
|
|
|
|
2004-11-26 16:15:27 +00:00
|
|
|
sal_Bool SAL_CALL SpriteCanvas::updateScreen( sal_Bool bUpdateAll ) throw (uno::RuntimeException)
|
2004-03-18 09:38:44 +00:00
|
|
|
{
|
|
|
|
tools::LocalGuard aGuard;
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
// avoid repaints on hidden window (hidden: not mapped to
|
|
|
|
// screen). Return failure, since the screen really has _not_
|
|
|
|
// been updated (caller should try again later)
|
|
|
|
return !mbIsVisible ? false : maCanvasHelper.updateScreen(bUpdateAll,
|
|
|
|
mbSurfaceDirty);
|
2004-03-18 09:38:44 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
|
2004-03-18 09:38:44 +00:00
|
|
|
void SAL_CALL SpriteCanvas::initialize( const uno::Sequence< uno::Any >& aArguments ) throw( uno::Exception,
|
|
|
|
uno::RuntimeException)
|
|
|
|
{
|
2005-11-02 12:04:13 +00:00
|
|
|
tools::LocalGuard aGuard;
|
|
|
|
|
|
|
|
VERBOSE_TRACE( "VCLSpriteCanvas::initialize called" );
|
2004-03-18 09:38:44 +00:00
|
|
|
|
2004-11-26 16:15:27 +00:00
|
|
|
CHECK_AND_THROW( aArguments.getLength() >= 1,
|
|
|
|
"SpriteCanvas::initialize: wrong number of arguments" );
|
2004-03-18 09:38:44 +00:00
|
|
|
|
|
|
|
// We expect a single Any here, containing a pointer to a valid
|
|
|
|
// VCL window, on which to output
|
|
|
|
if( aArguments.getLength() >= 1 &&
|
|
|
|
aArguments[0].getValueTypeClass() == uno::TypeClass_HYPER )
|
|
|
|
{
|
2006-06-20 01:20:57 +00:00
|
|
|
sal_Int64 nWindowPtr = 0;
|
|
|
|
aArguments[0] >>= nWindowPtr;
|
|
|
|
Window* pOutputWindow = reinterpret_cast<Window*>(nWindowPtr);
|
2004-11-26 16:15:27 +00:00
|
|
|
|
|
|
|
CHECK_AND_THROW( pOutputWindow != NULL,
|
|
|
|
"SpriteCanvas::initialize: invalid Window pointer" );
|
|
|
|
|
|
|
|
// setup helper
|
2005-11-02 12:04:13 +00:00
|
|
|
maDeviceHelper.init( *pOutputWindow,
|
|
|
|
*this );
|
|
|
|
maCanvasHelper.init( *this,
|
|
|
|
maDeviceHelper.getBackBuffer(),
|
|
|
|
false, // no OutDev state preservation
|
|
|
|
false ); // no alpha on surface
|
|
|
|
maCanvasHelper.setRedrawManager( maRedrawManager );
|
2004-03-18 09:38:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
::rtl::OUString SAL_CALL SpriteCanvas::getImplementationName() throw( uno::RuntimeException )
|
2004-12-02 11:41:49 +00:00
|
|
|
{
|
2005-11-02 12:04:13 +00:00
|
|
|
return getImplementationName_SpriteCanvas();
|
2004-12-02 11:41:49 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
sal_Bool SAL_CALL SpriteCanvas::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException )
|
2004-12-02 11:41:49 +00:00
|
|
|
{
|
2005-11-02 12:04:13 +00:00
|
|
|
return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
|
2004-12-02 11:41:49 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
uno::Sequence< ::rtl::OUString > SAL_CALL SpriteCanvas::getSupportedServiceNames() throw( uno::RuntimeException )
|
2004-12-02 11:41:49 +00:00
|
|
|
{
|
2005-11-02 12:04:13 +00:00
|
|
|
return getSupportedServiceNames_SpriteCanvas();
|
2004-12-02 11:41:49 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
::rtl::OUString SAL_CALL SpriteCanvas::getServiceName( ) throw (::com::sun::star::uno::RuntimeException)
|
2004-12-02 11:41:49 +00:00
|
|
|
{
|
2005-11-02 12:04:13 +00:00
|
|
|
return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) );
|
2004-12-02 11:41:49 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
uno::Reference< uno::XInterface > SAL_CALL SpriteCanvas::createInstance( const uno::Reference< uno::XComponentContext >& xContext ) throw ( uno::Exception )
|
2004-12-02 11:41:49 +00:00
|
|
|
{
|
2005-11-02 12:04:13 +00:00
|
|
|
return uno::Reference< uno::XInterface >( static_cast<cppu::OWeakObject*>(new SpriteCanvas( xContext )) );
|
2004-12-02 11:41:49 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
bool SpriteCanvas::repaint( const GraphicObjectSharedPtr& rGrf,
|
|
|
|
const ::Point& rPt,
|
|
|
|
const ::Size& rSz,
|
|
|
|
const GraphicAttr& rAttr ) const
|
2004-12-02 11:41:49 +00:00
|
|
|
{
|
|
|
|
tools::LocalGuard aGuard;
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
return maCanvasHelper.repaint( rGrf, rPt, rSz, rAttr );
|
2004-12-02 11:41:49 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
OutputDevice* SpriteCanvas::getOutDev() const
|
2004-12-02 11:41:49 +00:00
|
|
|
{
|
2005-11-02 12:04:13 +00:00
|
|
|
tools::LocalGuard aGuard;
|
2004-12-02 11:41:49 +00:00
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
return maDeviceHelper.getOutDev();
|
2004-03-18 09:38:44 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
BackBufferSharedPtr SpriteCanvas::getBackBuffer() const
|
2004-03-18 09:38:44 +00:00
|
|
|
{
|
2005-11-02 12:04:13 +00:00
|
|
|
tools::LocalGuard aGuard;
|
2004-03-18 09:38:44 +00:00
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
return maDeviceHelper.getBackBuffer();
|
2004-03-18 09:38:44 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
uno::Reference< beans::XPropertySetInfo > SAL_CALL SpriteCanvas::getPropertySetInfo() throw (uno::RuntimeException)
|
2004-03-18 09:38:44 +00:00
|
|
|
{
|
2005-11-02 12:04:13 +00:00
|
|
|
tools::LocalGuard aGuard;
|
|
|
|
return maPropHelper.getPropertySetInfo();
|
2004-03-18 09:38:44 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
void SAL_CALL SpriteCanvas::setPropertyValue( const ::rtl::OUString& aPropertyName,
|
|
|
|
const uno::Any& aValue ) throw (beans::UnknownPropertyException,
|
|
|
|
beans::PropertyVetoException,
|
|
|
|
lang::IllegalArgumentException,
|
|
|
|
lang::WrappedTargetException,
|
|
|
|
uno::RuntimeException)
|
2004-03-18 09:38:44 +00:00
|
|
|
{
|
2005-11-02 12:04:13 +00:00
|
|
|
tools::LocalGuard aGuard;
|
|
|
|
maPropHelper.setPropertyValue( aPropertyName, aValue );
|
2004-03-18 09:38:44 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
uno::Any SAL_CALL SpriteCanvas::getPropertyValue( const ::rtl::OUString& aPropertyName ) throw (beans::UnknownPropertyException,
|
|
|
|
lang::WrappedTargetException,
|
|
|
|
uno::RuntimeException)
|
2004-03-18 09:38:44 +00:00
|
|
|
{
|
|
|
|
tools::LocalGuard aGuard;
|
2005-11-02 12:04:13 +00:00
|
|
|
return maPropHelper.getPropertyValue( aPropertyName );
|
2004-03-18 09:38:44 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
void SAL_CALL SpriteCanvas::addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
|
|
|
|
const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException,
|
|
|
|
lang::WrappedTargetException,
|
|
|
|
uno::RuntimeException)
|
2004-03-18 09:38:44 +00:00
|
|
|
{
|
|
|
|
tools::LocalGuard aGuard;
|
2005-11-02 12:04:13 +00:00
|
|
|
maPropHelper.addPropertyChangeListener( aPropertyName,
|
|
|
|
xListener );
|
2004-03-18 09:38:44 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
void SAL_CALL SpriteCanvas::removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
|
|
|
|
const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException,
|
|
|
|
lang::WrappedTargetException,
|
|
|
|
uno::RuntimeException)
|
2004-03-18 09:38:44 +00:00
|
|
|
{
|
|
|
|
tools::LocalGuard aGuard;
|
2005-11-02 12:04:13 +00:00
|
|
|
maPropHelper.removePropertyChangeListener( aPropertyName,
|
|
|
|
xListener );
|
2004-03-18 09:38:44 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
void SAL_CALL SpriteCanvas::addVetoableChangeListener( const ::rtl::OUString& aPropertyName,
|
|
|
|
const uno::Reference< beans::XVetoableChangeListener >& xListener ) throw (beans::UnknownPropertyException,
|
|
|
|
lang::WrappedTargetException,
|
|
|
|
uno::RuntimeException)
|
2004-03-18 09:38:44 +00:00
|
|
|
{
|
|
|
|
tools::LocalGuard aGuard;
|
2005-11-02 12:04:13 +00:00
|
|
|
maPropHelper.addVetoableChangeListener( aPropertyName,
|
|
|
|
xListener );
|
2004-03-18 09:38:44 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 12:04:13 +00:00
|
|
|
void SAL_CALL SpriteCanvas::removeVetoableChangeListener( const ::rtl::OUString& aPropertyName,
|
|
|
|
const uno::Reference< beans::XVetoableChangeListener >& xListener ) throw (beans::UnknownPropertyException,
|
|
|
|
lang::WrappedTargetException,
|
|
|
|
uno::RuntimeException)
|
2005-03-30 06:38:54 +00:00
|
|
|
{
|
|
|
|
tools::LocalGuard aGuard;
|
2005-11-02 12:04:13 +00:00
|
|
|
maPropHelper.removeVetoableChangeListener( aPropertyName,
|
|
|
|
xListener );
|
2005-03-30 06:38:54 +00:00
|
|
|
}
|
2004-03-18 09:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
/* shared lib exports implemented with helpers */
|
|
|
|
static struct ::cppu::ImplementationEntry s_component_entries [] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
vclcanvas::SpriteCanvas::createInstance, getImplementationName_SpriteCanvas,
|
|
|
|
getSupportedServiceNames_SpriteCanvas, ::cppu::createSingleComponentFactory,
|
|
|
|
0, 0
|
|
|
|
},
|
|
|
|
{ 0, 0, 0, 0, 0, 0 }
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Exported UNO methods for registration and object creation.
|
|
|
|
==========================================================
|
|
|
|
*/
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
void SAL_CALL component_getImplementationEnvironment( const sal_Char** ppEnvTypeName,
|
2006-06-20 01:20:57 +00:00
|
|
|
uno_Environment** )
|
2004-03-18 09:38:44 +00:00
|
|
|
{
|
|
|
|
*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL component_writeInfo( lang::XMultiServiceFactory* xMgr,
|
|
|
|
registry::XRegistryKey* xRegistry )
|
|
|
|
{
|
|
|
|
return ::cppu::component_writeInfoHelper(
|
|
|
|
xMgr, xRegistry, s_component_entries );
|
|
|
|
}
|
|
|
|
|
|
|
|
void * SAL_CALL component_getFactory( sal_Char const* implName,
|
|
|
|
lang::XMultiServiceFactory* xMgr,
|
|
|
|
registry::XRegistryKey* xRegistry )
|
|
|
|
{
|
|
|
|
return ::cppu::component_getFactoryHelper(
|
|
|
|
implName, xMgr, xRegistry, s_component_entries );
|
|
|
|
}
|
|
|
|
}
|