summaryrefslogtreecommitdiff
path: root/canvas/source/vcl
diff options
context:
space:
mode:
authorThorsten Behrens <thb@openoffice.org>2004-03-18 09:38:44 +0000
committerThorsten Behrens <thb@openoffice.org>2004-03-18 09:38:44 +0000
commit6e89341b5045a01e823364633ef0fbfd44ebdfd5 (patch)
treee8bfc629f55ce0e0d31befb0b5c02233ef935705 /canvas/source/vcl
parentaac18e0575873e71532ce77e4c2e4083e4c71b9a (diff)
#110496# Merge from cws_srx645_canvas01: first working version of XCanvas UNO components, for now consisting of javacanvas.uno.jar, vclcanvas.uno and directxcanvas.uno (windows only)
Diffstat (limited to 'canvas/source/vcl')
-rw-r--r--canvas/source/vcl/canvasbitmap.cxx451
-rw-r--r--canvas/source/vcl/canvasbitmap.hxx137
-rw-r--r--canvas/source/vcl/canvascustomsprite.cxx444
-rw-r--r--canvas/source/vcl/canvascustomsprite.hxx258
-rw-r--r--canvas/source/vcl/canvasfont.cxx174
-rw-r--r--canvas/source/vcl/canvasfont.hxx134
-rw-r--r--canvas/source/vcl/exports.dxp3
-rw-r--r--canvas/source/vcl/impltools.cxx414
-rw-r--r--canvas/source/vcl/impltools.hxx195
-rw-r--r--canvas/source/vcl/makefile.mk106
-rw-r--r--canvas/source/vcl/outdevprovider.hxx124
-rw-r--r--canvas/source/vcl/sprite.hxx101
-rw-r--r--canvas/source/vcl/spritecanvas.cxx532
-rw-r--r--canvas/source/vcl/spritecanvas.hxx298
14 files changed, 3371 insertions, 0 deletions
diff --git a/canvas/source/vcl/canvasbitmap.cxx b/canvas/source/vcl/canvasbitmap.cxx
new file mode 100644
index 000000000000..ed5fbab62737
--- /dev/null
+++ b/canvas/source/vcl/canvasbitmap.cxx
@@ -0,0 +1,451 @@
+/*************************************************************************
+ *
+ * $RCSfile: canvasbitmap.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: thb $ $Date: 2004-03-18 10:38:39 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _SV_BMPACC_HXX
+#include <vcl/bmpacc.hxx>
+#endif
+#ifndef _VCL_CANVASTOOLS_HXX
+#include <vcl/canvastools.hxx>
+#endif
+
+#include <canvas/canvastools.hxx>
+
+#include "canvasbitmap.hxx"
+#include "bitmapcanvas.hxx"
+#include "impltools.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::drafts::com::sun::star;
+
+namespace vclcanvas
+{
+ // Currently, the only way to generate an XBitmap is from
+ // XGraphicDevice.getCompatibleBitmap(). Therefore, we don't even
+ // take a bitmap here, but a VDev directly.
+ CanvasBitmap::CanvasBitmap( const ::Size& rSize,
+ const OutDevProvider::ImplRef& rReferenceCanvas ) :
+ mpReferenceCanvas( rReferenceCanvas ),
+ mpBitmapCanvas( new BitmapCanvas( rSize,
+ rReferenceCanvas ) )
+ {
+ }
+
+ CanvasBitmap::CanvasBitmap( const BitmapEx& rBitmap,
+ const OutDevProvider::ImplRef& rReferenceCanvas ) :
+ mpReferenceCanvas( rReferenceCanvas ),
+ mpBitmapCanvas( new BitmapCanvas( rBitmap.GetSizePixel(),
+ rReferenceCanvas ) )
+ {
+ // TODO: Support alpha canvas here
+ VirtualDevice& rVDev( getVirDev() );
+ rVDev.EnableMapMode( FALSE );
+ const Point aEmptyPoint(0,0);
+ rVDev.DrawBitmapEx(aEmptyPoint, rBitmap);
+ }
+
+ CanvasBitmap::~CanvasBitmap()
+ {
+ }
+
+ geometry::IntegerSize2D SAL_CALL CanvasBitmap::getSize( ) throw (uno::RuntimeException)
+ {
+ tools::LocalGuard aGuard;
+ return ::vcl::unotools::integerSize2DFromSize( getVirDev().GetOutputSizePixel() );
+ }
+
+ uno::Reference< rendering::XBitmapCanvas > SAL_CALL CanvasBitmap::queryBitmapCanvas( ) throw (uno::RuntimeException)
+ {
+ return mpBitmapCanvas.getRef();
+ }
+
+ uno::Reference< rendering::XBitmap > SAL_CALL CanvasBitmap::getScaledBitmap( const geometry::RealSize2D& newSize, sal_Bool beFast ) throw (uno::RuntimeException)
+ {
+ tools::LocalGuard aGuard;
+
+#if 0
+ // TODO: To be used when dealing with real bitmaps here
+ BitmapEx aRes( *maBitmap );
+
+ aRes.Scale( ::canvas::tools::sizeFromRealSize2D(newSize),
+ beFast ? BMP_SCALE_FAST : BMP_SCALE_INTERPOLATE );
+
+ return uno::Reference< rendering::XBitmap >( new CanvasBitmap( aRes ) );
+#else
+ // TODO: Support alpha canvas here
+ VirtualDevice& rVDev( getVirDev() );
+ const Point aEmptyPoint(0,0);
+ const Size aBmpSize( rVDev.GetOutputSizePixel() );
+
+ Bitmap aBitmap( rVDev.GetBitmap(aEmptyPoint, aBmpSize) );
+
+ aBitmap.Scale( ::vcl::unotools::sizeFromRealSize2D(newSize),
+ beFast ? BMP_SCALE_FAST : BMP_SCALE_INTERPOLATE );
+
+ return uno::Reference< rendering::XBitmap >( new CanvasBitmap( aBitmap,
+ mpReferenceCanvas ) );
+#endif
+ }
+
+ uno::Sequence< sal_Int8 > SAL_CALL CanvasBitmap::getData( const geometry::IntegerRectangle2D& rect ) throw (lang::IndexOutOfBoundsException, rendering::VolatileContentDestroyedException,uno::RuntimeException)
+ {
+ tools::LocalGuard aGuard;
+
+#if 0
+ // TODO: To be used when dealing with real bitmaps here
+ Bitmap aBitmap( maBitmap->GetBitmap() );
+ Bitmap aAlpha( maBitmap->GetAlpha().GetBitmap() );
+#else
+ // TODO: Support alpha canvas here
+ VirtualDevice& rVDev( getVirDev() );
+ const Point aEmptyPoint(0,0);
+ const Size aBmpSize( rVDev.GetOutputSizePixel() );
+
+ Bitmap aBitmap( rVDev.GetBitmap(aEmptyPoint, aBmpSize) );
+ Bitmap aAlpha( Bitmap( aBmpSize, 8) );
+#endif
+
+ ScopedBitmapReadAccess pReadAccess( aBitmap.AcquireReadAccess(),
+ aBitmap );
+ ScopedBitmapReadAccess pAlphaReadAccess( aAlpha.AcquireReadAccess(),
+ aAlpha );
+
+ if( pReadAccess.get() != NULL &&
+ pAlphaReadAccess.get() != NULL )
+ {
+ // TODO: Support more formats.
+ const Size aBmpSize( aBitmap.GetSizePixel() );
+
+ // for the time being, always return as BGRA
+ uno::Sequence< sal_Int8 > aRes( 4*aBmpSize.Width()*aBmpSize.Height() );
+
+ int nCurrPos(0);
+ for( int y=rect.Y1;
+ y<aBmpSize.Height() && y<rect.Y2;
+ ++y )
+ {
+ for( int x=rect.X1;
+ x<aBmpSize.Width() && x<rect.X2;
+ ++x )
+ {
+ aRes[ nCurrPos++ ] = pReadAccess->GetColor( y, x ).GetBlue();
+ aRes[ nCurrPos++ ] = pReadAccess->GetColor( y, x ).GetGreen();
+ aRes[ nCurrPos++ ] = pReadAccess->GetColor( y, x ).GetRed();
+ aRes[ nCurrPos++ ] = pAlphaReadAccess->GetPixel( y, x ).GetIndex();
+ }
+ }
+
+ return aRes;
+ }
+
+ return uno::Sequence< sal_Int8 >();
+ }
+
+ void SAL_CALL CanvasBitmap::setData( const uno::Sequence< sal_Int8 >& data, const geometry::IntegerRectangle2D& rect ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, uno::RuntimeException)
+ {
+ tools::LocalGuard aGuard;
+
+#if 0
+ // TODO: To be used when dealing with real bitmaps here
+
+ // retrieve local copies from the BitmapEx, which are later
+ // stored back. Unfortunately, the BitmapEx does not permit
+ // in-place modifications, as they are necessary here.
+ Bitmap aBitmap( maBitmap->GetBitmap() );
+ Bitmap aAlpha( maBitmap->GetAlpha().GetBitmap() );
+#else
+ // TODO: Support alpha canvas here
+ VirtualDevice& rVDev( getVirDev() );
+ const Point aEmptyPoint(0,0);
+ const Size aBmpSize( rVDev.GetOutputSizePixel() );
+
+ Bitmap aBitmap( rVDev.GetBitmap(aEmptyPoint, aBmpSize) );
+ Bitmap aAlpha( Bitmap( aBmpSize, 8) );
+#endif
+
+ bool bCopyBack( false ); // only copy something back, if we
+ // actually changed pixel
+
+ {
+ ScopedBitmapWriteAccess pWriteAccess( aBitmap.AcquireWriteAccess(),
+ aBitmap );
+ ScopedBitmapWriteAccess pAlphaWriteAccess( aAlpha.AcquireWriteAccess(),
+ aAlpha );
+
+ if( pWriteAccess.get() != NULL &&
+ pAlphaWriteAccess.get() != NULL )
+ {
+ // TODO: Support more formats.
+ const Size aBmpSize( aBitmap.GetSizePixel() );
+
+ // for the time being, always read as BGRA
+ int nCurrPos(0);
+ for( int y=rect.Y1;
+ y<aBmpSize.Height() && y<rect.Y2;
+ ++y )
+ {
+ for( int x=rect.X1;
+ x<aBmpSize.Width() && x<rect.X2;
+ ++x )
+ {
+ pWriteAccess->SetPixel( y, x, BitmapColor( data[ nCurrPos+2 ],
+ data[ nCurrPos+1 ],
+ data[ nCurrPos ] ) );
+ nCurrPos += 3;
+
+ pAlphaWriteAccess->SetPixel( y, x, BitmapColor( 255 - data[ nCurrPos++ ] ) );
+ }
+ }
+
+ bCopyBack = true;
+ }
+ }
+
+ // copy back only here, since the BitmapAccessors must be
+ // destroyed beforehand
+ if( bCopyBack )
+ {
+#if 0
+ // TODO: To be used when dealing with real bitmaps here
+ maBitmap = BitmapEx( aBitmap,
+ AlphaMask( aAlpha ) );
+#else
+ // TODO: Support alpha canvas here
+ VirtualDevice& rVDev( getVirDev() );
+ rVDev.EnableMapMode( FALSE );
+ const Point aEmptyPoint(0,0);
+ rVDev.DrawBitmap(aEmptyPoint, aBitmap);
+#endif
+ }
+ }
+
+ void SAL_CALL CanvasBitmap::setPixel( const uno::Sequence< sal_Int8 >& color, const geometry::IntegerPoint2D& pos ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, uno::RuntimeException)
+ {
+ tools::LocalGuard aGuard;
+
+#if 0
+ // TODO: To be used when dealing with real bitmaps here
+ const Size aBmpSize( maBitmap->GetSizePixel() );
+#else
+ const Size aBmpSize( getVirDev().GetOutputSizePixel() );
+#endif
+
+ OSL_ENSURE( pos.X >= 0 && pos.X < aBmpSize.Width(), "CanvasBitmap::setPixel: X coordinate out of bounds" );
+ OSL_ENSURE( pos.Y >= 0 && pos.Y < aBmpSize.Height(), "CanvasBitmap::setPixel: Y coordinate out of bounds" );
+ OSL_ENSURE( color.getLength() > 3, "CanvasBitmap::setPixel: not enough color components" );
+
+#if 0
+ // TODO: To be used when dealing with real bitmaps here
+ // retrieve local copies from the BitmapEx, which are later
+ // stored back. Unfortunately, the BitmapEx does not permit
+ // in-place modifications, as they are necessary here.
+ Bitmap aBitmap( maBitmap->GetBitmap() );
+ Bitmap aAlpha( maBitmap->GetAlpha().GetBitmap() );
+
+ bool bCopyBack( false ); // only copy something back, if we
+ // actually changed a pixel
+
+ {
+ ScopedBitmapWriteAccess pWriteAccess( aBitmap.AcquireWriteAccess(),
+ aBitmap );
+ ScopedBitmapWriteAccess pAlphaWriteAccess( aAlpha.AcquireWriteAccess(),
+ aAlpha );
+
+ if( pWriteAccess.get() != NULL &&
+ pAlphaWriteAccess.get() != NULL )
+ {
+ pWriteAccess->SetPixel( pos.Y, pos.X, BitmapColor( color[ 2 ],
+ color[ 1 ],
+ color[ 0 ] ) );
+ pAlphaWriteAccess->SetPixel( pos.Y, pos.X, BitmapColor( 255 - color[ 3 ] ) );
+ }
+ }
+
+ // copy back only here, since the BitmapAccessors must be
+ // destroyed beforehand
+ if( bCopyBack )
+ {
+ maBitmap = BitmapEx( aBitmap,
+ AlphaMask( aAlpha ) );
+ }
+#else
+ VirtualDevice& rVDev( getVirDev() );
+ rVDev.EnableMapMode( FALSE );
+
+ uno::Reference< rendering::XCanvas > xCanvas( mpBitmapCanvas.getRef(),
+ uno::UNO_QUERY );
+ OSL_ENSURE( xCanvas.is(), "CanvasBitmap::setPixel(): Invalid reference canvas" );
+
+ getVirDev().DrawPixel( ::vcl::unotools::pointFromIntegerPoint2D( pos ),
+ ::vcl::unotools::sequenceToColor(
+ xCanvas->getDevice(),
+ color ) );
+#endif
+ }
+
+ uno::Sequence< sal_Int8 > SAL_CALL CanvasBitmap::getPixel( const geometry::IntegerPoint2D& pos ) throw (lang::IndexOutOfBoundsException, rendering::VolatileContentDestroyedException, uno::RuntimeException)
+ {
+ tools::LocalGuard aGuard;
+
+#if 0
+ // TODO: To be used when dealing with real bitmaps here
+ const Size aBmpSize( maBitmap->GetSizePixel() );
+#else
+ const Size aBmpSize( getVirDev().GetOutputSizePixel() );
+#endif
+
+ OSL_ENSURE( pos.X >= 0 && pos.X < aBmpSize.Width(), "CanvasBitmap::getPixel: X coordinate out of bounds" );
+ OSL_ENSURE( pos.Y >= 0 && pos.Y < aBmpSize.Height(), "CanvasBitmap::getPixel: Y coordinate out of bounds" );
+
+#if 0
+ // TODO: To be used when dealing with real bitmaps here
+ Bitmap aBitmap( maBitmap->GetBitmap() );
+ Bitmap aAlpha( maBitmap->GetAlpha().GetBitmap() );
+ ScopedBitmapReadAccess pReadAccess( aBitmap.AcquireReadAccess(),
+ aBitmap );
+ ScopedBitmapReadAccess pAlphaReadAccess( aAlpha.AcquireReadAccess(),
+ aAlpha );
+
+ if( pReadAccess.get() != NULL &&
+ pAlphaReadAccess.get() != NULL )
+ {
+ // for the time being, always return as BGRA
+ uno::Sequence< sal_Int8 > aRes( 4 );
+
+ const BitmapColor aColor( pReadAccess->GetColor( pos.Y, pos.X ) );
+ aRes[ 3 ] = aColor.GetRed();
+ aRes[ 2 ] = aColor.GetGreen();
+ aRes[ 1 ] = aColor.GetBlue();
+
+ aRes[ 3 ] = pAlphaReadAccess->GetPixel( pos.Y, pos.X ).GetIndex();
+
+ return aRes;
+ }
+
+ return uno::Sequence< sal_Int8 >();
+#else
+ VirtualDevice& rVDev( getVirDev() );
+ rVDev.EnableMapMode( FALSE );
+
+ uno::Reference< rendering::XCanvas > xCanvas(mpBitmapCanvas.getRef(),
+ uno::UNO_QUERY);
+
+ OSL_ENSURE( xCanvas.is(), "CanvasBitmap::getPixel(): Invalid reference canvas" );
+
+ return ::vcl::unotools::colorToIntSequence(
+ xCanvas->getDevice(),
+ getVirDev().GetPixel( ::vcl::unotools::pointFromIntegerPoint2D( pos ) ) );
+#endif
+ }
+
+ uno::Reference< rendering::XBitmapPalette > SAL_CALL CanvasBitmap::getPalette( ) throw (uno::RuntimeException)
+ {
+ return uno::Reference< rendering::XBitmapPalette >();
+ }
+
+ rendering::IntegerBitmapLayout SAL_CALL CanvasBitmap::getMemoryLayout( ) throw (uno::RuntimeException)
+ {
+ // TODO: finish that one
+ rendering::IntegerBitmapLayout aLayout;
+
+#if 0
+ // TODO: To be used when dealing with real bitmaps here
+ const Size aBmpSize( maBitmap->GetSizePixel() );
+#else
+ const Size aBmpSize( getVirDev().GetOutputSizePixel() );
+#endif
+
+ aLayout.ScanLines = aBmpSize.Height();
+ aLayout.ScanLineBytes = aBmpSize.Width()*4;
+ aLayout.ScanLineStride = aLayout.ScanLineBytes;
+ aLayout.Format = 0;
+ aLayout.NumComponents = 4;
+ aLayout.ComponentMasks = uno::Sequence<sal_Int64>();
+ aLayout.Endianness = 0;
+ aLayout.IsPseudoColor = false;
+
+ return aLayout;
+ }
+
+#define SERVICE_NAME "drafts.com.sun.star.rendering.CanvasBitmap"
+
+ ::rtl::OUString SAL_CALL CanvasBitmap::getImplementationName( ) throw (uno::RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( CANVASBITMAP_IMPLEMENTATION_NAME ) );
+ }
+
+ sal_Bool SAL_CALL CanvasBitmap::supportsService( const ::rtl::OUString& ServiceName ) throw (uno::RuntimeException)
+ {
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
+ }
+
+ uno::Sequence< ::rtl::OUString > SAL_CALL CanvasBitmap::getSupportedServiceNames( ) throw (uno::RuntimeException)
+ {
+ uno::Sequence< ::rtl::OUString > aRet(1);
+ aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
+
+ return aRet;
+ }
+
+ VirtualDevice& CanvasBitmap::getVirDev()
+ {
+ return mpBitmapCanvas->getVirDev();
+ }
+}
diff --git a/canvas/source/vcl/canvasbitmap.hxx b/canvas/source/vcl/canvasbitmap.hxx
new file mode 100644
index 000000000000..7bceb6abcc77
--- /dev/null
+++ b/canvas/source/vcl/canvasbitmap.hxx
@@ -0,0 +1,137 @@
+/*************************************************************************
+ *
+ * $RCSfile: canvasbitmap.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: thb $ $Date: 2004-03-18 10:38:39 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _VCLCANVAS_CANVASBITMAP_HXX
+#define _VCLCANVAS_CANVASBITMAP_HXX
+
+#include <memory>
+
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+
+#ifndef _DRAFTS_COM_SUN_STAR_RENDERING_XINTEGERBITMAP_HPP_
+#include <drafts/com/sun/star/rendering/XIntegerBitmap.hpp>
+#endif
+
+#ifndef _SV_BITMAPEX_HXX
+#include <vcl/bitmapex.hxx>
+#endif
+
+#include "spritecanvas.hxx"
+#include "bitmapcanvas.hxx"
+#include "impltools.hxx"
+
+#define CANVASBITMAP_IMPLEMENTATION_NAME "VCLCanvas::CanvasBitmap"
+
+/* Definition of CanvasBitmap class */
+
+namespace vclcanvas
+{
+ class CanvasBitmap : public ::cppu::WeakImplHelper2< ::drafts::com::sun::star::rendering::XIntegerBitmap,
+ ::com::sun::star::lang::XServiceInfo >
+ {
+ public:
+ // Must be called with locked Solar mutex
+ CanvasBitmap( const ::Size& rSize,
+ const OutDevProvider::ImplRef& rReferenceCanvas );
+
+ // XBitmap
+ virtual ::drafts::com::sun::star::geometry::IntegerSize2D SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XBitmapCanvas > SAL_CALL queryBitmapCanvas( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XBitmap > SAL_CALL getScaledBitmap( const ::drafts::com::sun::star::geometry::RealSize2D& newSize, sal_Bool beFast ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XIntegerBitmap
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getData( const ::drafts::com::sun::star::geometry::IntegerRectangle2D& rect ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::drafts::com::sun::star::rendering::VolatileContentDestroyedException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setData( const ::com::sun::star::uno::Sequence< sal_Int8 >& data, const ::drafts::com::sun::star::geometry::IntegerRectangle2D& rect ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPixel( const ::com::sun::star::uno::Sequence< sal_Int8 >& color, const ::drafts::com::sun::star::geometry::IntegerPoint2D& pos ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getPixel( const ::drafts::com::sun::star::geometry::IntegerPoint2D& pos ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::drafts::com::sun::star::rendering::VolatileContentDestroyedException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XBitmapPalette > SAL_CALL getPalette( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::drafts::com::sun::star::rendering::IntegerBitmapLayout SAL_CALL getMemoryLayout( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+
+ VirtualDevice& getVirDev();
+
+ protected:
+ ~CanvasBitmap(); // we're a ref-counted UNO class. _We_ destroy ourselves.
+
+ private:
+ // default: disabled copy/assignment
+ CanvasBitmap(const CanvasBitmap&);
+ CanvasBitmap& operator=( const CanvasBitmap& );
+
+ // only needed internally
+ CanvasBitmap( const BitmapEx& rBitmap,
+ const OutDevProvider::ImplRef& rReferenceCanvas );
+
+ OutDevProvider::ImplRef mpReferenceCanvas;
+ BitmapCanvas::ImplRef mpBitmapCanvas;
+ };
+}
+
+#endif /* _VCLCANVAS_CANVASBITMAP_HXX */
diff --git a/canvas/source/vcl/canvascustomsprite.cxx b/canvas/source/vcl/canvascustomsprite.cxx
new file mode 100644
index 000000000000..b228e67b3506
--- /dev/null
+++ b/canvas/source/vcl/canvascustomsprite.cxx
@@ -0,0 +1,444 @@
+/*************************************************************************
+ *
+ * $RCSfile: canvascustomsprite.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: thb $ $Date: 2004-03-18 10:38:40 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_RTL_MATH_HXX
+#include <rtl/math.hxx>
+#endif
+
+#include <canvas/canvastools.hxx>
+
+#include "canvascustomsprite.hxx"
+#include "spritecanvas.hxx"
+#include "impltools.hxx"
+
+#ifndef _SV_OUTDEV_HXX
+#include <vcl/outdev.hxx>
+#endif
+#ifndef _SV_BITMAP_HXX
+#include <vcl/bitmap.hxx>
+#endif
+#ifndef _SV_GDIMTF_HXX
+#include <vcl/gdimtf.hxx>
+#endif
+#ifndef _SV_METAACT_HXX
+#include <vcl/metaact.hxx>
+#endif
+#ifndef _VCL_CANVASTOOLS_HXX
+#include <vcl/canvastools.hxx>
+#endif
+
+#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#endif
+#ifndef _BGFX_POINT_B2DPOINT_HXX
+#include <basegfx/point/b2dpoint.hxx>
+#endif
+#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX
+#include <basegfx/tools/canvastools.hxx>
+#endif
+
+using namespace ::com::sun::star;
+using namespace ::drafts::com::sun::star;
+
+namespace vclcanvas
+{
+
+ CanvasCustomSprite::CanvasCustomSprite( const geometry::RealSize2D& rSpriteSize,
+ const SpriteCanvas::ImplRef& rSpriteCanvas ) :
+ maVDev( new VirtualDevice( rSpriteCanvas->getOutDev() ) ), // create from reference device
+ maMaskVDev( new VirtualDevice( rSpriteCanvas->getOutDev(), 1) ), // create from reference device, bit depth: one
+ maCanvasHelper(),
+ mpSpriteCanvas( rSpriteCanvas ),
+ maPosition(0.0, 0.0),
+ maSize( ::vcl::unotools::sizeFromRealSize2D( rSpriteSize ) ),
+ mfAlpha(0.0),
+ mbActive( false )
+ {
+ // setup outdev sizes to total sprite size
+ maVDev->SetOutputSizePixel( maSize );
+ maMaskVDev->SetOutputSizePixel( maSize );
+
+ // set mask vdev drawmode, such that everything is painted
+ // black. That leaves us with a binary image, white for
+ // background, black for painted content
+ maMaskVDev->SetDrawMode( DRAWMODE_BLACKLINE | DRAWMODE_BLACKFILL | DRAWMODE_BLACKTEXT |
+ DRAWMODE_BLACKGRADIENT | DRAWMODE_BLACKBITMAP );
+
+ maCanvasHelper.setOutDev( *maVDev );
+ maCanvasHelper.setBackgroundOutDev( *maMaskVDev );
+ }
+
+ CanvasCustomSprite::~CanvasCustomSprite()
+ {
+ hide();
+ }
+
+ OutDevProvider::ImplRef CanvasCustomSprite::getImplRef()
+ {
+ return OutDevProvider::ImplRef::createFromQuery( this );
+ }
+
+ void SAL_CALL CanvasCustomSprite::drawPoint( const geometry::RealPoint2D& aPoint,
+ const rendering::ViewState& viewState,
+ const rendering::RenderState& renderState ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ // TODO: You might consider copying the SpriteCanvas
+ // background VDev behaviour here, notably the call to
+ // SpriteSurface::updateSprite(). But on the other hand, there
+ // are enough external cases that could mess that up (see
+ // comment on XCustomSprite), that we're maybe wise to keep it
+ // like this (i.e. invalidating the sprite content only once,
+ // for the call to getContentCanvas). This way, the inevitable
+ // errors will show up earlier, not only when multi-threading
+ // the updateScreen.
+ maCanvasHelper.drawPoint( aPoint, viewState, renderState, getImplRef() );
+ }
+
+ void SAL_CALL CanvasCustomSprite::drawLine( const geometry::RealPoint2D& aStartPoint, const geometry::RealPoint2D& aEndPoint, const rendering::ViewState& viewState, const rendering::RenderState& renderState ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ maCanvasHelper.drawLine(aStartPoint, aEndPoint, viewState, renderState, getImplRef());
+ }
+
+ void SAL_CALL CanvasCustomSprite::drawBezier( const ::drafts::com::sun::star::geometry::RealBezierSegment2D& aBezierSegment,
+ const ::drafts::com::sun::star::geometry::RealPoint2D& aEndPoint,
+ const rendering::ViewState& viewState,
+ const rendering::RenderState& renderState ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ maCanvasHelper.drawBezier(aBezierSegment, aEndPoint, viewState, renderState, getImplRef());
+ }
+
+ uno::Reference< rendering::XCachedPrimitive > SAL_CALL CanvasCustomSprite::drawPolyPolygon( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon, const rendering::ViewState& viewState, const rendering::RenderState& renderState ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ return maCanvasHelper.drawPolyPolygon(xPolyPolygon, viewState, renderState, getImplRef());
+ }
+
+ uno::Reference< rendering::XCachedPrimitive > SAL_CALL CanvasCustomSprite::strokePolyPolygon( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon, const rendering::ViewState& viewState, const rendering::RenderState& renderState, const rendering::StrokeAttributes& strokeAttributes ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ return maCanvasHelper.strokePolyPolygon(xPolyPolygon, viewState, renderState, strokeAttributes, getImplRef());
+ }
+
+ uno::Reference< rendering::XCachedPrimitive > SAL_CALL CanvasCustomSprite::strokeTexturedPolyPolygon( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon, const rendering::ViewState& viewState, const rendering::RenderState& renderState, const uno::Sequence< rendering::Texture >& textures, const rendering::StrokeAttributes& strokeAttributes ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ return maCanvasHelper.strokeTexturedPolyPolygon(xPolyPolygon, viewState, renderState, textures, strokeAttributes, getImplRef());
+ }
+
+ uno::Reference< rendering::XCachedPrimitive > SAL_CALL CanvasCustomSprite::strokeTextureMappedPolyPolygon( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon, const rendering::ViewState& viewState, const rendering::RenderState& renderState, const uno::Sequence< rendering::Texture >& textures, const uno::Reference< geometry::XMapping2D >& xMapping, const rendering::StrokeAttributes& strokeAttributes ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ return maCanvasHelper.strokeTextureMappedPolyPolygon(xPolyPolygon, viewState, renderState, textures, xMapping, strokeAttributes, getImplRef());
+ }
+
+ uno::Reference< rendering::XPolyPolygon2D > SAL_CALL CanvasCustomSprite::queryStrokeShapes( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon, const rendering::ViewState& viewState, const rendering::RenderState& renderState, const rendering::StrokeAttributes& strokeAttributes ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ return maCanvasHelper.queryStrokeShapes(xPolyPolygon, viewState, renderState, strokeAttributes, getImplRef());
+ }
+
+ uno::Reference< rendering::XCachedPrimitive > SAL_CALL CanvasCustomSprite::fillPolyPolygon( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon, const rendering::ViewState& viewState, const rendering::RenderState& renderState ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ return maCanvasHelper.fillPolyPolygon(xPolyPolygon, viewState, renderState, getImplRef() );
+ }
+
+ uno::Reference< rendering::XCachedPrimitive > SAL_CALL CanvasCustomSprite::fillTexturedPolyPolygon( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon, const rendering::ViewState& viewState, const rendering::RenderState& renderState, const uno::Sequence< rendering::Texture >& textures ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ return maCanvasHelper.fillTexturedPolyPolygon(xPolyPolygon, viewState, renderState, textures, getImplRef());
+ }
+
+ uno::Reference< rendering::XCachedPrimitive > SAL_CALL CanvasCustomSprite::fillTextureMappedPolyPolygon( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon, const rendering::ViewState& viewState, const rendering::RenderState& renderState, const uno::Sequence< rendering::Texture >& textures, const uno::Reference< geometry::XMapping2D >& xMapping ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ return maCanvasHelper.fillTextureMappedPolyPolygon(xPolyPolygon, viewState, renderState, textures, xMapping, getImplRef());
+ }
+
+ uno::Reference< rendering::XCanvasFont > SAL_CALL CanvasCustomSprite::queryFont( const rendering::FontRequest& fontRequest ) throw (uno::RuntimeException)
+ {
+ return maCanvasHelper.queryFont( fontRequest, getImplRef() );
+ }
+
+ uno::Reference< rendering::XCachedPrimitive > SAL_CALL CanvasCustomSprite::drawText( const rendering::StringContext& text,
+ const uno::Reference< rendering::XCanvasFont >& xFont,
+ const rendering::ViewState& viewState,
+ const rendering::RenderState& renderState,
+ sal_Int8 textDirection ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ return maCanvasHelper.drawText(text, xFont, viewState, renderState, textDirection, getImplRef());
+ }
+
+ uno::Reference< rendering::XCachedPrimitive > SAL_CALL CanvasCustomSprite::drawOffsettedText( const rendering::StringContext& text, const uno::Reference< rendering::XCanvasFont >& xFont, const uno::Sequence< double >& offsets, const rendering::ViewState& viewState, const rendering::RenderState& renderState, sal_Int8 textDirection ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ return maCanvasHelper.drawOffsettedText(text, xFont, offsets, viewState, renderState, textDirection, getImplRef());
+ }
+
+ uno::Reference< rendering::XCachedPrimitive > SAL_CALL CanvasCustomSprite::drawBitmap( const uno::Reference< rendering::XBitmap >& xBitmap, const rendering::ViewState& viewState, const rendering::RenderState& renderState ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ return maCanvasHelper.drawBitmap(xBitmap, viewState, renderState, getImplRef());
+ }
+
+ uno::Reference< rendering::XGraphicDevice > SAL_CALL CanvasCustomSprite::getDevice() throw (uno::RuntimeException)
+ {
+ return maCanvasHelper.getDevice( getImplRef() );
+ }
+
+ void SAL_CALL CanvasCustomSprite::copyRect( const uno::Reference< rendering::XBitmapCanvas >& sourceCanvas,
+ const geometry::RealRectangle2D& sourceRect,
+ const rendering::ViewState& sourceViewState,
+ const rendering::RenderState& sourceRenderState,
+ const geometry::RealRectangle2D& destRect,
+ const rendering::ViewState& destViewState,
+ const rendering::RenderState& destRenderState ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ tools::LocalGuard aGuard;
+ }
+
+ void SAL_CALL CanvasCustomSprite::setAlpha( double alpha ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ ::canvas::tools::checkRange(alpha, 0.0, 1.0);
+
+ if( alpha != mfAlpha )
+ {
+ if( mbActive )
+ mpSpriteCanvas->updateSprite( Sprite::ImplRef( this ),
+ ::vcl::unotools::pointFromB2DPoint( maPosition ),
+ Rectangle( ::vcl::unotools::pointFromB2DPoint( maPosition ),
+ maSize ) );
+
+ mfAlpha = alpha;
+ }
+ }
+
+ void SAL_CALL CanvasCustomSprite::move( const ::drafts::com::sun::star::geometry::RealPoint2D& aNewPos,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ ::basegfx::B2DHomMatrix aTransform;
+ ::canvas::tools::mergeViewAndRenderTransform(aTransform,
+ viewState,
+ renderState);
+
+ ::basegfx::B2DPoint aPoint( ::basegfx::unotools::b2DPointFromRealPoint2D(aNewPos) );
+ aPoint *= aTransform;
+
+ if( aPoint != maPosition )
+ {
+ if( mbActive )
+ mpSpriteCanvas->moveSprite( Sprite::ImplRef( this ),
+ ::vcl::unotools::pointFromB2DPoint( maPosition ),
+ ::vcl::unotools::pointFromB2DPoint( aPoint ) );
+
+ maPosition = aPoint;
+ }
+ }
+
+ void SAL_CALL CanvasCustomSprite::transform( const geometry::AffineMatrix2D& aTransformation ) throw (lang::IllegalArgumentException,
+ uno::RuntimeException)
+ {
+ // TODO
+ }
+
+ void SAL_CALL CanvasCustomSprite::clip( const uno::Reference< rendering::XPolyPolygon2D >& aClip,
+ const rendering::ViewState& viewState,
+ const rendering::RenderState& renderState ) throw (lang::IllegalArgumentException,
+ uno::RuntimeException)
+ {
+ // TODO
+ }
+
+ void SAL_CALL CanvasCustomSprite::show( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ if( !mbActive )
+ {
+ mpSpriteCanvas->showSprite( Sprite::ImplRef( this ) );
+ mbActive = true;
+
+ if( mfAlpha != 0.0 )
+ {
+ mpSpriteCanvas->updateSprite( Sprite::ImplRef( this ),
+ ::vcl::unotools::pointFromB2DPoint( maPosition ),
+ Rectangle( ::vcl::unotools::pointFromB2DPoint( maPosition ),
+ maSize ) );
+ }
+ }
+ }
+
+ void SAL_CALL CanvasCustomSprite::hide( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ if( mbActive )
+ {
+ mpSpriteCanvas->hideSprite( Sprite::ImplRef( this ) );
+ mbActive = false;
+
+ if( mfAlpha != 0.0 )
+ {
+ mpSpriteCanvas->updateSprite( Sprite::ImplRef( this ),
+ ::vcl::unotools::pointFromB2DPoint( maPosition ),
+ Rectangle( ::vcl::unotools::pointFromB2DPoint( maPosition ),
+ maSize ) );
+ }
+ }
+ }
+
+ uno::Reference< rendering::XCanvas > SAL_CALL CanvasCustomSprite::getContentCanvas() throw (uno::RuntimeException)
+ {
+ if( mbActive )
+ {
+ // the client is about to render into the sprite. Thus,
+ // potentially the whole sprite area has changed.
+ mpSpriteCanvas->updateSprite( Sprite::ImplRef( this ),
+ ::vcl::unotools::pointFromB2DPoint( maPosition ),
+ Rectangle( ::vcl::unotools::pointFromB2DPoint( maPosition ),
+ maSize ) );
+ }
+
+ // TODO: Locking! Everywhere!
+ tools::LocalGuard aGuard;
+
+ // clear surface
+ maVDev->EnableMapMode( FALSE );
+ maVDev->SetFillColor( Color( COL_WHITE ) );
+ maVDev->SetLineColor();
+ maVDev->DrawRect( Rectangle(Point(), maSize) );
+
+ maMaskVDev->SetDrawMode( DRAWMODE_DEFAULT );
+ maMaskVDev->EnableMapMode( FALSE );
+ maMaskVDev->SetFillColor( Color( COL_WHITE ) );
+ maMaskVDev->SetLineColor();
+ maMaskVDev->DrawRect( Rectangle(Point(), maSize) );
+ maMaskVDev->SetDrawMode( DRAWMODE_BLACKLINE | DRAWMODE_BLACKFILL | DRAWMODE_BLACKTEXT |
+ DRAWMODE_BLACKGRADIENT | DRAWMODE_BLACKBITMAP );
+
+ return this;
+ }
+
+#define SERVICE_NAME "drafts.com.sun.star.rendering.Canvas"
+
+ ::rtl::OUString SAL_CALL CanvasCustomSprite::getImplementationName() throw( uno::RuntimeException )
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( CANVASCUSTOMSPRITE_IMPLEMENTATION_NAME ) );
+ }
+
+ sal_Bool SAL_CALL CanvasCustomSprite::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException )
+ {
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
+ }
+
+ uno::Sequence< ::rtl::OUString > SAL_CALL CanvasCustomSprite::getSupportedServiceNames() throw( uno::RuntimeException )
+ {
+ uno::Sequence< ::rtl::OUString > aRet(1);
+ aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
+
+ return aRet;
+ }
+
+ // Sprite
+ void CanvasCustomSprite::redraw( OutputDevice& rTargetSurface ) const
+ {
+ redraw( rTargetSurface,
+ ::vcl::unotools::pointFromB2DPoint( maPosition ) );
+ }
+
+ void CanvasCustomSprite::redraw( OutputDevice& rTargetSurface, const Point& rOutputPos ) const
+ {
+ tools::OutDevStateKeeper aStateKeeper(rTargetSurface);
+
+ const Point aEmptyPoint;
+ const Bitmap aMaskBitmap( maMaskVDev->GetBitmap( aEmptyPoint, maSize ) );
+ const Bitmap aContentBitmap( maVDev->GetBitmap( aEmptyPoint, maSize ) );
+
+ // TODO: Support for alpha-VDev
+ rTargetSurface.EnableMapMode( FALSE );
+
+ if( ::rtl::math::approxEqual(mfAlpha, 1.0) )
+ {
+ // copy to output
+ rTargetSurface.DrawBitmapEx( rOutputPos,
+ BitmapEx( aContentBitmap, aMaskBitmap ) );
+ }
+ else if( mfAlpha != 0.0 ) // TODO: be a little bit more tolerant here
+ {
+ // Only draw something if we're not completely transparent
+ BYTE nColor( static_cast<UINT8>(255.0*(1.0 - mfAlpha) + .5) );
+ AlphaMask aAlpha( maSize, &nColor );
+
+ // mask out fully transparent areas
+ aAlpha.Replace( aMaskBitmap, 255 );
+
+ // alpha-blend to output
+ rTargetSurface.DrawBitmapEx( rOutputPos,
+ BitmapEx( aContentBitmap, aAlpha ) );
+ }
+ }
+
+ ::basegfx::B2DSize CanvasCustomSprite::getSize() const
+ {
+ // TODO: Use AW's wrappers once resynced
+ return ::basegfx::B2DSize( maSize.Width(),
+ maSize.Height() );
+ }
+
+ // OutDevProvider
+ ::OutputDevice& CanvasCustomSprite::getOutDev()
+ {
+ return *maVDev;
+ }
+
+ const ::OutputDevice& CanvasCustomSprite::getOutDev() const
+ {
+ return *maVDev;
+ }
+
+}
diff --git a/canvas/source/vcl/canvascustomsprite.hxx b/canvas/source/vcl/canvascustomsprite.hxx
new file mode 100644
index 000000000000..4414ea6150ec
--- /dev/null
+++ b/canvas/source/vcl/canvascustomsprite.hxx
@@ -0,0 +1,258 @@
+/*************************************************************************
+ *
+ * $RCSfile: canvascustomsprite.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: thb $ $Date: 2004-03-18 10:38:40 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _VCLCANVAS_CANVASCUSTOMSPRITE_HXX
+#define _VCLCANVAS_CANVASCUSTOMSPRITE_HXX
+
+#ifndef _CPPUHELPER_IMPLBASE3_HXX_
+#include <cppuhelper/implbase3.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+
+#ifndef _DRAFTS_COM_SUN_STAR_RENDERING_XCUSTOMSPRITE_HPP_
+#include <drafts/com/sun/star/rendering/XCustomSprite.hpp>
+#endif
+
+#ifndef _BGFX_POINT_B2DPOINT_HXX
+#include <basegfx/point/b2dpoint.hxx>
+#endif
+
+#ifndef _SV_VIRDEV_HXX
+#include <vcl/virdev.hxx>
+#endif
+
+#include <canvas/vclwrapper.hxx>
+
+#include "outdevprovider.hxx"
+#include "spritecanvas.hxx"
+#include "bitmapcanvas.hxx"
+#include "sprite.hxx"
+
+#define CANVASCUSTOMSPRITE_IMPLEMENTATION_NAME "VCLCanvas::CanvasCustomSprite"
+
+namespace vclcanvas
+{
+ typedef ::cppu::WeakImplHelper3< ::drafts::com::sun::star::rendering::XCustomSprite,
+ ::drafts::com::sun::star::rendering::XBitmapCanvas,
+ ::com::sun::star::lang::XServiceInfo > CanvasCustomSprite_Base;
+
+ /* Definition of CanvasCustomSprite class */
+
+ class CanvasCustomSprite : public Sprite,
+ public OutDevProvider,
+ public CanvasCustomSprite_Base
+ {
+ public:
+ CanvasCustomSprite( const ::drafts::com::sun::star::geometry::RealSize2D& rSpriteSize,
+ const SpriteCanvas::ImplRef& rSpriteCanvas );
+
+ // XInterface
+
+ // Need to implement that, because Sprite and OutDevProvider
+ // both come with an unimplemented version of XInterface.
+
+ // Forwarding the XInterface implementation to the
+ // cppu::ImplHelper templated base, which does the refcounting and
+ // queryInterface for us: Classname Base doing refcount and handling queryInterface
+ // | |
+ // V V
+ DECLARE_UNO3_AGG_DEFAULTS( CanvasCustomSprite, CanvasCustomSprite_Base );
+
+ // XCanvas
+ virtual void SAL_CALL drawPoint( const ::drafts::com::sun::star::geometry::RealPoint2D& aPoint,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL drawLine( const ::drafts::com::sun::star::geometry::RealPoint2D& aStartPoint,
+ const ::drafts::com::sun::star::geometry::RealPoint2D& aEndPoint,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL drawBezier( const ::drafts::com::sun::star::geometry::RealBezierSegment2D& aBezierSegment,
+ const ::drafts::com::sun::star::geometry::RealPoint2D& aEndPoint,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCachedPrimitive > SAL_CALL
+ drawPolyPolygon( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCachedPrimitive > SAL_CALL
+ strokePolyPolygon( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState,
+ const ::drafts::com::sun::star::rendering::StrokeAttributes& strokeAttributes ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCachedPrimitive > SAL_CALL
+ strokeTexturedPolyPolygon( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState,
+ const ::com::sun::star::uno::Sequence< ::drafts::com::sun::star::rendering::Texture >& textures,
+ const ::drafts::com::sun::star::rendering::StrokeAttributes& strokeAttributes ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCachedPrimitive > SAL_CALL
+ strokeTextureMappedPolyPolygon( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState,
+ const ::com::sun::star::uno::Sequence< ::drafts::com::sun::star::rendering::Texture >& textures,
+ const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::geometry::XMapping2D >& xMapping,
+ const ::drafts::com::sun::star::rendering::StrokeAttributes& strokeAttributes ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XPolyPolygon2D > SAL_CALL
+ queryStrokeShapes( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState,
+ const ::drafts::com::sun::star::rendering::StrokeAttributes& strokeAttributes ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCachedPrimitive > SAL_CALL
+ fillPolyPolygon( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCachedPrimitive > SAL_CALL
+ fillTexturedPolyPolygon( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState,
+ const ::com::sun::star::uno::Sequence< ::drafts::com::sun::star::rendering::Texture >& textures ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCachedPrimitive > SAL_CALL
+ fillTextureMappedPolyPolygon( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState,
+ const ::com::sun::star::uno::Sequence< ::drafts::com::sun::star::rendering::Texture >& textures,
+ const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::geometry::XMapping2D >& xMapping ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCanvasFont > SAL_CALL
+ queryFont( const ::drafts::com::sun::star::rendering::FontRequest& fontRequest ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCachedPrimitive > SAL_CALL
+ drawText( const ::drafts::com::sun::star::rendering::StringContext& text,
+ const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCanvasFont >& xFont,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState,
+ sal_Int8 textDirection ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCachedPrimitive > SAL_CALL
+ drawOffsettedText( const ::drafts::com::sun::star::rendering::StringContext& text,
+ const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCanvasFont >& xFont,
+ const ::com::sun::star::uno::Sequence< double >& offsets,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState,
+ sal_Int8 textDirection ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCachedPrimitive > SAL_CALL
+ drawBitmap( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XBitmap >& xBitmap,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XGraphicDevice > SAL_CALL
+ getDevice() throw (::com::sun::star::uno::RuntimeException);
+
+ // XBitmapCanvas (only providing, not implementing the
+ // interface. Also note subtle method parameter differences)
+ virtual void SAL_CALL copyRect( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XBitmapCanvas >& sourceCanvas,
+ const ::drafts::com::sun::star::geometry::RealRectangle2D& sourceRect,
+ const ::drafts::com::sun::star::rendering::ViewState& sourceViewState,
+ const ::drafts::com::sun::star::rendering::RenderState& sourceRenderState,
+ const ::drafts::com::sun::star::geometry::RealRectangle2D& destRect,
+ const ::drafts::com::sun::star::rendering::ViewState& destViewState,
+ const ::drafts::com::sun::star::rendering::RenderState& destRenderState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ // XSprite
+ virtual void SAL_CALL setAlpha( double alpha ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL move( const ::drafts::com::sun::star::geometry::RealPoint2D& aNewPos, const ::drafts::com::sun::star::rendering::ViewState& viewState, const ::drafts::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL transform( const ::drafts::com::sun::star::geometry::AffineMatrix2D& aTransformation ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clip( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XPolyPolygon2D >& aClip, const ::drafts::com::sun::star::rendering::ViewState& viewState, const ::drafts::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL show( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL hide( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XCustomSprite
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCanvas > SAL_CALL
+ getContentCanvas( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
+
+ // OutDevProvider
+ virtual OutputDevice& getOutDev();
+ virtual const OutputDevice& getOutDev() const;
+
+ // Sprite
+ virtual void redraw( OutputDevice& rTargetSurface ) const;
+ virtual void redraw( OutputDevice& rTargetSurface, const Point& rOutputPosition ) const;
+ virtual ::basegfx::B2DSize getSize() const;
+
+ protected:
+ ~CanvasCustomSprite(); // we're a ref-counted UNO class. _We_ destroy ourselves.
+
+ private:
+ // default: disabled copy/assignment
+ CanvasCustomSprite(const CanvasCustomSprite&);
+ CanvasCustomSprite& operator=( const CanvasCustomSprite& );
+
+ OutDevProvider::ImplRef getImplRef();
+
+ // for the integrated bitmap canvas implementation
+ ::canvas::vcltools::VCLObject<VirtualDevice> maVDev;
+ ::canvas::vcltools::VCLObject<VirtualDevice> maMaskVDev;
+ CanvasBase maCanvasHelper;
+
+ SpriteCanvas::ImplRef mpSpriteCanvas;
+
+ // sprite state
+ ::basegfx::B2DPoint maPosition;
+ Size maSize;
+ double mfAlpha;
+ bool mbActive;
+ };
+}
+
+#endif /* _VCLCANVAS_CANVASCUSTOMSPRITE_HXX */
diff --git a/canvas/source/vcl/canvasfont.cxx b/canvas/source/vcl/canvasfont.cxx
new file mode 100644
index 000000000000..3f4d88efcd2b
--- /dev/null
+++ b/canvas/source/vcl/canvasfont.cxx
@@ -0,0 +1,174 @@
+/*************************************************************************
+ *
+ * $RCSfile: canvasfont.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: thb $ $Date: 2004-03-18 10:38:40 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "canvasfont.hxx"
+#include "spritecanvas.hxx"
+
+#ifndef _DRAFTS_COM_SUN_STAR_RENDERING_XSPRITECANVAS_HPP_
+#include <drafts/com/sun/star/rendering/XSpriteCanvas.hpp>
+#endif
+
+using namespace ::com::sun::star;
+using namespace ::drafts::com::sun::star;
+
+namespace vclcanvas
+{
+ CanvasFont::CanvasFont( const rendering::FontRequest& rFontRequest,
+ const OutDevProvider::ImplRef& rCanvas ) :
+ maFont( Font( rFontRequest.FamilyName, rFontRequest.StyleName, ::Size( 0,
+ static_cast<long>(rFontRequest.CellSize + .5)) ) ),
+ maFontRequest( rFontRequest ),
+ mpCanvas( rCanvas )
+ {
+ maFont->SetAlign( ALIGN_BASELINE );
+ maFont->SetHeight( static_cast<long>(rFontRequest.CellSize + .5) );
+ }
+
+ CanvasFont::~CanvasFont()
+ {
+ }
+
+ uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > > SAL_CALL CanvasFont::queryTextShapes( const rendering::StringContext& text,
+ const rendering::ViewState& viewState,
+ const rendering::RenderState& renderState,
+ sal_Int8 direction ) throw (uno::RuntimeException)
+ {
+ // TODO
+ return uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > >();
+ }
+
+ uno::Sequence< geometry::RealRectangle2D > SAL_CALL CanvasFont::queryTightMeasures( const rendering::StringContext& text,
+ const rendering::ViewState& viewState,
+ const rendering::RenderState& renderState,
+ sal_Int8 direction ) throw (uno::RuntimeException)
+ {
+ // TODO
+ return uno::Sequence< geometry::RealRectangle2D >();
+ }
+
+ uno::Sequence< geometry::RealRectangle2D > SAL_CALL CanvasFont::queryTextMeasures( const rendering::StringContext& text,
+ const rendering::ViewState& viewState,
+ const rendering::RenderState& renderState,
+ sal_Int8 direction ) throw (uno::RuntimeException)
+ {
+ // TODO
+ return uno::Sequence< geometry::RealRectangle2D >();
+ }
+
+ uno::Sequence< double > SAL_CALL CanvasFont::queryTextOffsets( const rendering::StringContext& text,
+ const rendering::ViewState& viewState,
+ const rendering::RenderState& renderState,
+ sal_Int8 direction ) throw (uno::RuntimeException)
+ {
+ // TODO
+ return uno::Sequence< double >();
+ }
+
+ geometry::RealRectangle2D SAL_CALL CanvasFont::queryTextBounds( const rendering::StringContext& text,
+ const rendering::ViewState& viewState,
+ const rendering::RenderState& renderState,
+ sal_Int8 direction ) throw (uno::RuntimeException)
+ {
+ // TODO
+ return geometry::RealRectangle2D();
+ }
+
+ rendering::FontRequest SAL_CALL CanvasFont::getFontRequest( ) throw (uno::RuntimeException)
+ {
+ return maFontRequest;
+ }
+
+ rendering::FontMetrics SAL_CALL CanvasFont::getFontMetrics( ) throw (uno::RuntimeException)
+ {
+ return rendering::FontMetrics();
+ }
+
+ uno::Reference< rendering::XCanvas > SAL_CALL CanvasFont::getAssociatedCanvas( ) throw (uno::RuntimeException)
+ {
+ return uno::Reference< rendering::XCanvas >( mpCanvas.getRef(),
+ uno::UNO_QUERY );
+ }
+
+#define SERVICE_NAME "drafts.com.sun.star.rendering.CanvasFont"
+
+ ::rtl::OUString SAL_CALL CanvasFont::getImplementationName() throw( uno::RuntimeException )
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( CANVASFONT_IMPLEMENTATION_NAME ) );
+ }
+
+ sal_Bool SAL_CALL CanvasFont::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException )
+ {
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
+ }
+
+ uno::Sequence< ::rtl::OUString > SAL_CALL CanvasFont::getSupportedServiceNames() throw( uno::RuntimeException )
+ {
+ uno::Sequence< ::rtl::OUString > aRet(1);
+ aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
+
+ return aRet;
+ }
+
+ ::Font CanvasFont::getVCLFont() const
+ {
+ return *maFont;
+ }
+}
diff --git a/canvas/source/vcl/canvasfont.hxx b/canvas/source/vcl/canvasfont.hxx
new file mode 100644
index 000000000000..3bbbe5f21bd9
--- /dev/null
+++ b/canvas/source/vcl/canvasfont.hxx
@@ -0,0 +1,134 @@
+/*************************************************************************
+ *
+ * $RCSfile: canvasfont.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: thb $ $Date: 2004-03-18 10:38:40 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CANVASFONT_HXX
+#define _CANVASFONT_HXX
+
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+
+#ifndef _DRAFTS_COM_SUN_STAR_RENDERING_XCANVASFONT_HPP_
+#include <drafts/com/sun/star/rendering/XCanvasFont.hpp>
+#endif
+
+#ifndef _SV_FONT_HXX
+#include <vcl/font.hxx>
+#endif
+
+#include <canvas/vclwrapper.hxx>
+
+#include "canvasbase.hxx"
+#include "outdevprovider.hxx"
+#include "impltools.hxx"
+
+
+#define CANVASFONT_IMPLEMENTATION_NAME "VCLCanvas::CanvasFont"
+
+/* Definition of CanvasFont class */
+
+namespace vclcanvas
+{
+ class SpriteCanvas;
+
+ class CanvasFont : public ::cppu::WeakImplHelper2< ::drafts::com::sun::star::rendering::XCanvasFont,
+ ::com::sun::star::lang::XServiceInfo >
+ {
+ public:
+ CanvasFont( const ::drafts::com::sun::star::rendering::FontRequest& fontRequest,
+ const OutDevProvider::ImplRef& rCanvas );
+
+ // XCanvasFont
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XPolyPolygon2D > > SAL_CALL queryTextShapes( const ::drafts::com::sun::star::rendering::StringContext& text, const ::drafts::com::sun::star::rendering::ViewState& viewState, const ::drafts::com::sun::star::rendering::RenderState& renderState, sal_Int8 direction ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::drafts::com::sun::star::geometry::RealRectangle2D > SAL_CALL queryTightMeasures( const ::drafts::com::sun::star::rendering::StringContext& text, const ::drafts::com::sun::star::rendering::ViewState& viewState, const ::drafts::com::sun::star::rendering::RenderState& renderState, sal_Int8 direction ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::drafts::com::sun::star::geometry::RealRectangle2D > SAL_CALL queryTextMeasures( const ::drafts::com::sun::star::rendering::StringContext& text, const ::drafts::com::sun::star::rendering::ViewState& viewState, const ::drafts::com::sun::star::rendering::RenderState& renderState, sal_Int8 direction ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< double > SAL_CALL queryTextOffsets( const ::drafts::com::sun::star::rendering::StringContext& text, const ::drafts::com::sun::star::rendering::ViewState& viewState, const ::drafts::com::sun::star::rendering::RenderState& renderState, sal_Int8 direction ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::drafts::com::sun::star::geometry::RealRectangle2D SAL_CALL queryTextBounds( const ::drafts::com::sun::star::rendering::StringContext& text, const ::drafts::com::sun::star::rendering::ViewState& viewState, const ::drafts::com::sun::star::rendering::RenderState& renderState, sal_Int8 direction ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::drafts::com::sun::star::rendering::FontRequest SAL_CALL getFontRequest( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::drafts::com::sun::star::rendering::FontMetrics SAL_CALL getFontMetrics( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCanvas > SAL_CALL getAssociatedCanvas( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
+
+ ::Font getVCLFont() const;
+
+ protected:
+ ~CanvasFont(); // we're a ref-counted UNO class. _We_ destroy ourselves.
+
+ private:
+ // default: disabled copy/assignment
+ CanvasFont(const CanvasFont&);
+ CanvasFont& operator=( const CanvasFont& );
+
+ ::canvas::vcltools::VCLObject<Font> maFont;
+ ::drafts::com::sun::star::rendering::FontRequest maFontRequest;
+ OutDevProvider::ImplRef mpCanvas;
+ };
+
+}
+
+#endif /* _CANVASFONT_HXX */
diff --git a/canvas/source/vcl/exports.dxp b/canvas/source/vcl/exports.dxp
new file mode 100644
index 000000000000..0c2e3e7cddd7
--- /dev/null
+++ b/canvas/source/vcl/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory \ No newline at end of file
diff --git a/canvas/source/vcl/impltools.cxx b/canvas/source/vcl/impltools.cxx
new file mode 100644
index 000000000000..75a492665a74
--- /dev/null
+++ b/canvas/source/vcl/impltools.cxx
@@ -0,0 +1,414 @@
+/*************************************************************************
+ *
+ * $RCSfile: impltools.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: thb $ $Date: 2004-03-18 10:38:41 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _DRAFTS_COM_SUN_STAR_GEOMETRY_REALSIZE2D_HPP__
+#include <drafts/com/sun/star/geometry/RealSize2D.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_GEOMETRY_REALPOINT2D_HPP__
+#include <drafts/com/sun/star/geometry/RealPoint2D.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_GEOMETRY_REALRECTANGLE2D_HPP__
+#include <drafts/com/sun/star/geometry/RealRectangle2D.hpp>
+#endif
+
+#ifndef _DRAFTS_COM_SUN_STAR_RENDERING_RENDERSTATE_HPP__
+#include <drafts/com/sun/star/rendering/RenderState.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_RENDERING_XCANVAS_HPP__
+#include <drafts/com/sun/star/rendering/XCanvas.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_RENDERING_XBITMAP_HPP__
+#include <drafts/com/sun/star/rendering/XBitmap.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_RENDERING_XPOLYPOLYGON2D_HPP__
+#include <drafts/com/sun/star/rendering/XPolyPolygon2D.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_GEOMETRY_REALBEZIERSEGMENT2D_HPP__
+#include <drafts/com/sun/star/geometry/RealBezierSegment2D.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_RENDERING_XINTEGERBITMAP_HPP__
+#include <drafts/com/sun/star/rendering/XIntegerBitmap.hpp>
+#endif
+
+#ifndef _TL_POLY_HXX
+#include <tools/poly.hxx>
+#endif
+#ifndef _SV_SALBTYPE_HXX
+#include <vcl/salbtype.hxx>
+#endif
+#ifndef _SV_BMPACC_HXX
+#include <vcl/bmpacc.hxx>
+#endif
+#ifndef _SV_BITMAPEX_HXX
+#include <vcl/bitmapex.hxx>
+#endif
+#ifndef _SV_METRIC_HXX
+#include <vcl/metric.hxx>
+#endif
+#ifndef _VCL_CANVASTOOLS_HXX
+#include <vcl/canvastools.hxx>
+#endif
+
+#ifndef _BGFX_TUPLE_B2DTUPLE_HXX
+#include <basegfx/tuple/b2dtuple.hxx>
+#endif
+#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#endif
+#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX
+#include <basegfx/tools/canvastools.hxx>
+#endif
+
+#ifndef INCLUDED_RTL_MATH_HXX
+#include <rtl/math.hxx>
+#endif
+
+#include <cmath> // for fmod
+
+#include <canvas/canvastools.hxx>
+
+#include "impltools.hxx"
+#include "linepolypolygon.hxx"
+#include "canvasbitmap.hxx"
+
+
+using namespace ::com::sun::star;
+using namespace ::drafts::com::sun::star;
+
+namespace vclcanvas
+{
+ namespace tools
+ {
+ ::PolyPolygon polyPolygonFromXPolyPolygon2D( const uno::Reference< rendering::XPolyPolygon2D >& xPoly )
+ {
+ uno::Reference< lang::XServiceInfo > xRef( xPoly,
+ uno::UNO_QUERY );
+
+ if( xRef.is() &&
+ xRef->getImplementationName().equals( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(LINEPOLYPOLYGON_IMPLEMENTATION_NAME))) )
+ {
+ // TODO: Maybe use dynamic_cast here
+
+ // TODO: Provide true beziers here!
+ return static_cast<LinePolyPolygon*>(xPoly.get())->getVCLPolyPolygon();
+ }
+ else
+ {
+ // TODO: extract points from polygon interface
+ }
+
+ return ::PolyPolygon();
+ }
+
+ ::BitmapEx bitmapExFromXBitmap( const uno::Reference< rendering::XBitmap >& xBitmap )
+ {
+ uno::Reference< lang::XServiceInfo > xRef( xBitmap,
+ uno::UNO_QUERY );
+
+ if( xRef.is() &&
+ xRef->getImplementationName().equals( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CANVASBITMAP_IMPLEMENTATION_NAME))) )
+ {
+ // TODO: Maybe use dynamic_cast here
+ VirtualDevice& rVDev( static_cast<CanvasBitmap*>(xBitmap.get())->getVirDev() );
+ const Point aEmptyPoint(0,0);
+ const Size aBmpSize(rVDev.GetOutputSizePixel());
+
+ // TODO: handle alpha vDev here
+ return rVDev.GetBitmap(aEmptyPoint, aBmpSize);
+ }
+ else
+ {
+ // TODO: extract points from polygon interface
+ }
+
+ return ::BitmapEx();
+ }
+
+ ::Point setupFontTransform( ::Font& aVCLFont,
+ const rendering::ViewState& rViewState,
+ const rendering::RenderState& rRenderState,
+ OutputDevice& rOutDev )
+ {
+ ::basegfx::B2DHomMatrix aMatrix;
+
+ ::canvas::tools::mergeViewAndRenderTransform(aMatrix,
+ rViewState,
+ rRenderState);
+
+ ::basegfx::B2DTuple aScale;
+ ::basegfx::B2DTuple aTranslate;
+ double nRotate, nShearX;
+
+ aMatrix.decompose( aScale, aTranslate, nRotate, nShearX );
+
+ // query font metric _before_ tampering with width and height
+ if( !::rtl::math::approxEqual(aScale.getX(), aScale.getY()) )
+ {
+ // retrieve true font width
+ const int aFontWidth( rOutDev.GetFontMetric( aVCLFont ).GetWidth() );
+
+ aVCLFont.SetWidth( static_cast<long>(aFontWidth * aScale.getX() + .5) );
+ }
+
+ if( !::rtl::math::approxEqual(aScale.getY(), 1.0) )
+ {
+ const int nFontHeight( aVCLFont.GetHeight() );
+ aVCLFont.SetHeight( static_cast<long>(nFontHeight * aScale.getY() + .5) );
+ }
+
+ aVCLFont.SetOrientation( static_cast< short >(-fmod(nRotate, 2*F_PI)*(1800.0/F_PI) + .5) );
+
+ // TODO: Missing functionality in VCL: shearing
+ return ::Point( static_cast<long>(aTranslate.getX() + .5),
+ static_cast<long>(aTranslate.getY() + .5) );
+ }
+
+ // VCL-Canvas related
+ //---------------------------------------------------------------------
+
+ ::Point mapRealPoint2D( const geometry::RealPoint2D& rPoint,
+ const rendering::ViewState& rViewState,
+ const rendering::RenderState& rRenderState )
+ {
+ ::basegfx::B2DPoint aPoint( ::basegfx::unotools::b2DPointFromRealPoint2D(rPoint) );
+
+ ::basegfx::B2DHomMatrix aMatrix;
+ aPoint *= ::canvas::tools::mergeViewAndRenderTransform(aMatrix,
+ rViewState,
+ rRenderState);
+
+ return ::vcl::unotools::pointFromB2DPoint( aPoint );
+ }
+
+ ::PolyPolygon mapPolyPolygon( const ::PolyPolygon& rPoly,
+ const rendering::ViewState& rViewState,
+ const rendering::RenderState& rRenderState )
+ {
+ PolyPolygon aRes;
+ ::basegfx::B2DHomMatrix aMatrix;
+ ::canvas::tools::mergeViewAndRenderTransform(aMatrix,
+ rViewState,
+ rRenderState);
+
+ int nCurrPoly, nCurrPoint;
+ for( nCurrPoly=0; nCurrPoly<rPoly.Count(); ++nCurrPoly )
+ {
+ Polygon aDest(rPoly[nCurrPoly].GetSize());
+
+ for( nCurrPoint=0; nCurrPoint<aDest.GetSize(); ++nCurrPoint )
+ {
+ ::basegfx::B2DPoint aPoint( ::vcl::unotools::b2DPointFromPoint( rPoly[nCurrPoly][nCurrPoint] ) );
+
+ aPoint *= aMatrix;
+
+ aDest[nCurrPoint] = ::vcl::unotools::pointFromB2DPoint( aPoint );
+ }
+
+ aRes.Insert(aDest);
+ }
+
+ return aRes;
+ }
+
+ ::BitmapEx transformBitmap( const BitmapEx& rBitmap,
+ const rendering::ViewState& rViewState,
+ const rendering::RenderState& rRenderState )
+ {
+ // calc transformation and size of bitmap to be
+ // generated. Note, that the translational components are
+ // deleted from the transformation; this can be handled by
+ // an offset when painting the bitmap
+ ::basegfx::B2DHomMatrix aTransform;
+ ::canvas::tools::mergeViewAndRenderTransform(aTransform,
+ rViewState,
+ rRenderState);
+ aTransform.set(0,2,0.0);
+ aTransform.set(1,2,0.0);
+
+ const Size aBmpSize( rBitmap.GetSizePixel() );
+ ::basegfx::B2DRectangle aDestRect;
+
+ bool bCopyBack( false );
+
+ ::canvas::tools::calcTransformedRectBounds( aDestRect,
+ ::basegfx::B2DRectangle(0,
+ 0,
+ aBmpSize.Width(),
+ aBmpSize.Height()),
+ aTransform );
+
+ Bitmap aSrcBitmap( rBitmap.GetBitmap() );
+ Bitmap aSrcAlpha;
+
+ // differentiate mask and alpha channel (on-off
+ // vs. multi-level transparency)
+ if( rBitmap.IsTransparent() )
+ {
+ if( rBitmap.IsAlpha() )
+ aSrcAlpha = rBitmap.GetAlpha().GetBitmap();
+ else
+ aSrcAlpha = rBitmap.GetMask();
+ }
+
+ Bitmap aDstBitmap( aSrcBitmap );
+ Bitmap aDstAlpha( rBitmap.IsTransparent() ? aSrcAlpha : Bitmap( Size(1,1), 8) );
+ aDstBitmap.SetSizePixel( Size( FRound( aDestRect.getMaxX() ),
+ FRound( aDestRect.getMaxY() ) ) );
+ aDstAlpha.SetSizePixel( Size(FRound( aDestRect.getMaxX() ),
+ FRound( aDestRect.getMaxY() ) ) );
+ {
+ // just to be on the safe side: let the
+ // ScopedAccessors get destructed before
+ // copy-constructing the resulting bitmap. This will
+ // rule out the possibility that cached accessor data
+ // is not yet written back.
+ ScopedBitmapReadAccess pReadAccess( aSrcBitmap.AcquireReadAccess(),
+ aSrcBitmap );
+ ScopedBitmapReadAccess pAlphaReadAccess( rBitmap.IsTransparent() ? aSrcAlpha.AcquireReadAccess() : NULL,
+ aSrcAlpha );
+
+ ScopedBitmapWriteAccess pWriteAccess( aDstBitmap.AcquireWriteAccess(),
+ aDstBitmap );
+ ScopedBitmapWriteAccess pAlphaWriteAccess( aDstAlpha.AcquireWriteAccess(),
+ aDstAlpha );
+
+
+ if( pReadAccess.get() != NULL &&
+ (pAlphaReadAccess.get() != NULL || !rBitmap.IsTransparent()) &&
+ pWriteAccess.get() != NULL &&
+ pAlphaWriteAccess.get() != NULL &&
+ aTransform.isInvertible() )
+ {
+ // we're doing inverse mapping here, i.e. mapping
+ // points from the destination bitmap back to the
+ // source
+ aTransform.invert();
+
+ const Size aDestBmpSize( aDstBitmap.GetSizePixel() );
+
+ // for the time being, always read as ARGB
+ for( int y=0; y<aDestBmpSize.Height(); ++y )
+ {
+ // differentiate mask and alpha channel (on-off
+ // vs. multi-level transparency)
+ if( rBitmap.IsTransparent() )
+ {
+ // Handling alpha and mask just the same...
+ for( int x=0; x<aDestBmpSize.Width(); ++x )
+ {
+ ::basegfx::B2DPoint aPoint(x,y);
+ aPoint *= aTransform;
+
+ const int nSrcX( FRound( aPoint.getX() + .5 ) );
+ const int nSrcY( FRound( aPoint.getY() + .5 ) );
+ if( nSrcX < 0 || nSrcX >= aBmpSize.Width() ||
+ nSrcY < 0 || nSrcX >= aBmpSize.Height() )
+ {
+ pAlphaWriteAccess->SetPixel( y, x, BitmapColor(255) );
+ }
+ else
+ {
+ pAlphaWriteAccess->SetPixel( y, x, pAlphaReadAccess->GetPixel( nSrcY,
+ nSrcX ) );
+ pWriteAccess->SetPixel( y, x, pReadAccess->GetPixel( nSrcY,
+ nSrcX ) );
+ }
+ }
+ }
+ else
+ {
+ for( int x=0; x<aDestBmpSize.Width(); ++x )
+ {
+ ::basegfx::B2DPoint aPoint(x,y);
+ aPoint *= aTransform;
+
+ const int nSrcX( FRound( aPoint.getX() + .5 ) );
+ const int nSrcY( FRound( aPoint.getY() + .5 ) );
+ if( nSrcX < 0 || nSrcX >= aBmpSize.Width() ||
+ nSrcY < 0 || nSrcX >= aBmpSize.Height() )
+ {
+ pAlphaWriteAccess->SetPixel( y, x, BitmapColor(255) );
+ }
+ else
+ {
+ pAlphaWriteAccess->SetPixel( y, x, BitmapColor(0) );
+ pWriteAccess->SetPixel( y, x, pReadAccess->GetPixel( nSrcY,
+ nSrcX ) );
+ }
+ }
+ }
+ }
+
+ bCopyBack = true;
+ }
+ else
+ {
+ // TODO: Error handling!
+ }
+ }
+
+ if( bCopyBack )
+ return BitmapEx( aDstBitmap, AlphaMask( aDstAlpha ) );
+ else
+ return BitmapEx();
+ }
+ }
+}
diff --git a/canvas/source/vcl/impltools.hxx b/canvas/source/vcl/impltools.hxx
new file mode 100644
index 000000000000..92157cb6556f
--- /dev/null
+++ b/canvas/source/vcl/impltools.hxx
@@ -0,0 +1,195 @@
+/*************************************************************************
+ *
+ * $RCSfile: impltools.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: thb $ $Date: 2004-03-18 10:38:42 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _VCLCANVAS_TOOLS_HXX
+#define _VCLCANVAS_TOOLS_HXX
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _VOS_MUTEX_HXX_
+#include <vos/mutex.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+
+#ifndef _SV_OUTDEV_HXX
+#include <vcl/outdev.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
+#include <com/sun/star/uno/Reference.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+
+namespace basegfx
+{
+ namespace matrix
+ {
+ class B2DHomMatrix;
+ }
+ namespace vector
+ {
+ class B2DVector;
+ }
+ namespace point
+ {
+ class B2DPoint;
+ }
+}
+
+namespace com { namespace sun { namespace star { namespace awt
+{
+ struct Point;
+ struct Size;
+ struct Rectangle;
+} } } }
+
+namespace com { namespace sun { namespace star { namespace drawing
+{
+ struct HomogenMatrix3;
+} } } }
+
+namespace drafts { namespace com { namespace sun { namespace star { namespace rendering
+{
+ struct RealPoint2D;
+ struct RealSize2D;
+ struct RealRectangle2D;
+ struct RenderState;
+ struct ViewState;
+ class XCanvas;
+ class XBitmap;
+ class XPolyPolygon2D;
+} } } } }
+
+
+namespace vclcanvas
+{
+ namespace tools
+ {
+ ::PolyPolygon
+ polyPolygonFromXPolyPolygon2D( const ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::rendering::XPolyPolygon2D >& );
+
+ ::BitmapEx
+ bitmapExFromXBitmap( const ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::rendering::XBitmap >& );
+
+ ::Point setupFontTransform( ::Font& aVCLFont,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState,
+ ::OutputDevice& rOutDev );
+
+
+ // Little helper to encapsulate locking into policy class
+ class LocalGuard
+ {
+ public:
+ LocalGuard() :
+ aGuard( Application::GetSolarMutex() )
+ {
+ }
+
+ private:
+ ::vos::OGuard aGuard;
+ };
+
+ class OutDevStateKeeper
+ {
+ public:
+ explicit OutDevStateKeeper( OutputDevice& rOutDev ) :
+ mrOutDev( rOutDev ),
+ mbMappingWasEnable( rOutDev.IsMapModeEnabled() )
+ {
+ mrOutDev.Push();
+ mrOutDev.EnableMapMode(FALSE);
+ }
+
+ ~OutDevStateKeeper()
+ {
+ mrOutDev.EnableMapMode( mbMappingWasEnable );
+ mrOutDev.Pop();
+ }
+
+ private:
+ OutputDevice& mrOutDev;
+ const bool mbMappingWasEnable;
+ };
+
+ ::Point mapRealPoint2D( const ::drafts::com::sun::star::geometry::RealPoint2D& rPoint,
+ const ::drafts::com::sun::star::rendering::ViewState& rViewState,
+ const ::drafts::com::sun::star::rendering::RenderState& rRenderState );
+
+ ::PolyPolygon mapPolyPolygon( const ::PolyPolygon& rPoly,
+ const ::drafts::com::sun::star::rendering::ViewState& rViewState,
+ const ::drafts::com::sun::star::rendering::RenderState& rRenderState );
+
+ ::BitmapEx transformBitmap( const BitmapEx& rBitmap,
+ const ::drafts::com::sun::star::rendering::ViewState& rViewState,
+ const ::drafts::com::sun::star::rendering::RenderState& rRenderState );
+
+ }
+}
+
+#endif /* _VCLCANVAS_TOOLS_HXX */
diff --git a/canvas/source/vcl/makefile.mk b/canvas/source/vcl/makefile.mk
new file mode 100644
index 000000000000..d748dfcb81dc
--- /dev/null
+++ b/canvas/source/vcl/makefile.mk
@@ -0,0 +1,106 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.2 $
+#
+# last change: $Author: thb $ $Date: 2004-03-18 10:38:43 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# 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.
+#
+# 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.
+#
+# 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
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (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.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=canvas
+TARGET=vclcanvas
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------------
+
+.INCLUDE : settings.mk
+DLLPRE =
+
+# --- Common ----------------------------------------------------------
+
+.IF "$(verbose)"!="" || "$(VERBOSE)"!=""
+CDEFS+= -DVERBOSE
+.ENDIF
+
+SLOFILES = $(SLO)$/spritecanvas.obj \
+ $(SLO)$/linepolypolygon.obj \
+ $(SLO)$/canvasfont.obj \
+ $(SLO)$/graphicdevice.obj \
+ $(SLO)$/canvasbitmap.obj \
+ $(SLO)$/canvasbase.obj \
+ $(SLO)$/bitmapcanvas.obj \
+ $(SLO)$/canvascustomsprite.obj \
+ $(SLO)$/redrawmanager.obj \
+ $(SLO)$/impltools.obj
+
+SHL1TARGET=$(TARGET).uno
+
+SHL1STDLIBS= $(TOOLSLIB) $(CPPULIB) $(SALLIB) $(VCLLIB) $(COMPHELPERLIB) $(CPPUHELPERLIB) $(BASEGFXLIB) $(CANVASTOOLSLIB)
+
+#SHL1VERSIONMAP=$(TARGET).map
+
+SHL1IMPLIB=i$(TARGET)
+SHL1LIBS=$(SLB)$/$(TARGET).lib
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORTFILE=exports.dxp
+
+# ==========================================================================
+
+.INCLUDE : target.mk
diff --git a/canvas/source/vcl/outdevprovider.hxx b/canvas/source/vcl/outdevprovider.hxx
new file mode 100644
index 000000000000..266a66f91e59
--- /dev/null
+++ b/canvas/source/vcl/outdevprovider.hxx
@@ -0,0 +1,124 @@
+/*************************************************************************
+ *
+ * $RCSfile: outdevprovider.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: thb $ $Date: 2004-03-18 10:38:43 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _VCLCANVAS_OUTDEVPROVIDER_HXX
+#define _VCLCANVAS_OUTDEVPROVIDER_HXX
+
+#ifndef _COMPHELPER_IMPLEMENTATIONREFERENCE_HXX
+#include <comphelper/implementationreference.hxx>
+#endif
+
+#ifndef _DRAFTS_COM_SUN_STAR_RENDERING_XCANVAS_HPP_
+#include <drafts/com/sun/star/rendering/XCanvas.hpp>
+#endif
+
+class OutputDevice;
+
+namespace vclcanvas
+{
+ /* Definition of OutDevProvider interface */
+
+ /** Helper interface to connect CanvasBase with its various
+ clients.
+ */
+
+ // The problem here is the fact that first of all, XCanvas and its
+ // specialised interfaces form an inheritance hierarchy. Thus,
+ // every client of a base class implementing the commons of
+ // canvases, will have to implement all interface methods, and
+ // forward them to the base class. Thus, there's no real gain in
+ // using implementation inheritance here. If we instead use a
+ // helper class to be held as a member by its client, we have the
+ // problem that several base methods serve as object factories,
+ // generating objects which require links to the canvas
+ // implementation object _and_ a UNO reference. The latter is for
+ // lifetime issues, and should better be directly from the client
+ // object.
+
+ // Therefore, every client of CanvasBase must implement this
+ // interface and pass a pointer to it to the CanvasBase
+ // instance. The XInterface base class is necessary to have basic
+ // UNO reference semantics.
+
+ class OutDevProvider : public ::com::sun::star::uno::XInterface
+ {
+ public:
+ /** Use this type to store a C++ pointer alongside a UNO
+ reference to this interface.
+
+ This is advantageous e.g. for CanvasBase, where several
+ helper methods (color conversion etc.) need access to the
+ XCanvas UNO interface. Performing a QueryInterface
+ everytime is a real performance killer there.
+ */
+ typedef ::comphelper::ImplementationReference<
+ OutDevProvider,
+ ::drafts::com::sun::star::rendering::XCanvas,
+ ::com::sun::star::uno::XInterface > ImplRef;
+
+ virtual ~OutDevProvider() {}
+
+ virtual OutputDevice& getOutDev() = 0;
+ virtual const OutputDevice& getOutDev() const = 0;
+ };
+}
+
+#endif /* _VCLCANVAS_OUTDEVPROVIDER_HXX */
diff --git a/canvas/source/vcl/sprite.hxx b/canvas/source/vcl/sprite.hxx
new file mode 100644
index 000000000000..97114e31ab58
--- /dev/null
+++ b/canvas/source/vcl/sprite.hxx
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * $RCSfile: sprite.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: thb $ $Date: 2004-03-18 10:38:44 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _VCLCANVAS_SPRITE_HXX
+#define _VCLCANVAS_SPRITE_HXX
+
+#ifndef _RTL_REF_HXX_
+#include <rtl/ref.hxx>
+#endif
+
+#ifndef _DRAFTS_COM_SUN_STAR_RENDERING_XCANVAS_HPP_
+#include <drafts/com/sun/star/rendering/XCanvas.hpp>
+#endif
+
+#ifndef _BGFX_POINT_B2DSIZE_HXX
+#include <basegfx/vector/b2dsize.hxx>
+#endif
+
+class OutputDevice;
+
+namespace vclcanvas
+{
+ /* Definition of Sprite class */
+
+ /** Helper interface to connect SpriteCanvas with various
+ sprite implementations.
+ */
+
+ class Sprite : public ::com::sun::star::uno::XInterface
+ {
+ public:
+ typedef ::rtl::Reference< Sprite > ImplRef;
+
+ virtual ~Sprite() {}
+
+ virtual void redraw( OutputDevice& rTargetSurface ) const = 0;
+ virtual void redraw( OutputDevice& rTargetSurface, const Point& rOutputPosition ) const = 0;
+
+ virtual ::basegfx::B2DSize getSize() const = 0;
+ };
+}
+
+#endif /* _VCLCANVAS_SPRITE_HXX */
diff --git a/canvas/source/vcl/spritecanvas.cxx b/canvas/source/vcl/spritecanvas.cxx
new file mode 100644
index 000000000000..c2dfb89c69f8
--- /dev/null
+++ b/canvas/source/vcl/spritecanvas.cxx
@@ -0,0 +1,532 @@
+/*************************************************************************
+ *
+ * $RCSfile: spritecanvas.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: thb $ $Date: 2004-03-18 10:38:44 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _VOS_MUTEX_HXX_
+#include <vos/mutex.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+
+#ifndef _SV_OUTDEV_HXX
+#include <vcl/outdev.hxx>
+#endif
+#ifndef _SV_WINDOW_HXX
+#include <vcl/window.hxx>
+#endif
+#ifndef _SV_BITMAPEX_HXX
+#include <vcl/bitmapex.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICENAME_HPP_
+#include <com/sun/star/lang/XServiceName.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENTCONTEXT_HPP_
+#include <com/sun/star/uno/XComponentContext.hpp>
+#endif
+
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE4_HXX_
+#include <cppuhelper/implbase4.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_
+#include <cppuhelper/implementationentry.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_
+#include <cppuhelper/implementationentry.hxx>
+#endif
+
+#ifndef _DRAFTS_COM_SUN_STAR_RENDERING_XSPRITECANVAS_HPP_
+#include <drafts/com/sun/star/rendering/XSpriteCanvas.hpp>
+#endif
+
+#ifndef BOOST_SCOPED_ARRAY_HPP_INCLUDED
+#include <external/boost/scoped_array.hpp>
+#endif
+
+#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#endif
+#ifndef _BGFX_POINT_B2DPOINT_HXX
+#include <basegfx/point/b2dpoint.hxx>
+#endif
+#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX
+#include <basegfx/tools/canvastools.hxx>
+#endif
+
+#include <algorithm>
+
+#include <canvas/verbosetrace.hxx>
+
+#include <canvas/canvastools.hxx>
+
+#include "impltools.hxx"
+#include "canvasfont.hxx"
+#include "spritecanvas.hxx"
+#include "graphicdevice.hxx"
+#include "outdevprovider.hxx"
+#include "canvascustomsprite.hxx"
+#include "bitmapcanvas.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::drafts::com::sun::star;
+
+#define IMPLEMENTATION_NAME "VCLCanvas::SpriteCanvas"
+#define SERVICE_NAME "drafts.com.sun.star.rendering.Canvas"
+
+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 ) :
+ SpriteCanvas_Base( m_aMutex )
+ {
+ }
+
+ SpriteCanvas::~SpriteCanvas()
+ {
+ }
+
+ OutDevProvider::ImplRef SpriteCanvas::getImplRef()
+ {
+ return OutDevProvider::ImplRef::createFromQuery( this );
+ }
+
+ void SAL_CALL SpriteCanvas::drawPoint( const geometry::RealPoint2D& aPoint,
+ const rendering::ViewState& viewState,
+ const rendering::RenderState& renderState ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ checkOurState();
+
+ mpRedrawManager->backgroundDirty();
+ maCanvasHelper.drawPoint( aPoint, viewState, renderState, getImplRef() );
+ }
+
+ void SAL_CALL SpriteCanvas::drawLine( const geometry::RealPoint2D& aStartPoint, const geometry::RealPoint2D& aEndPoint, const rendering::ViewState& viewState, const rendering::RenderState& renderState ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ checkOurState();
+
+ mpRedrawManager->backgroundDirty();
+ maCanvasHelper.drawLine(aStartPoint, aEndPoint, viewState, renderState, getImplRef());
+ }
+
+ void SAL_CALL SpriteCanvas::drawBezier( const geometry::RealBezierSegment2D& aBezierSegment,
+ const geometry::RealPoint2D& aEndPoint,
+ const rendering::ViewState& viewState,
+ const rendering::RenderState& renderState ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ checkOurState();
+
+ mpRedrawManager->backgroundDirty();
+ maCanvasHelper.drawBezier(aBezierSegment, aEndPoint, viewState, renderState, getImplRef());
+ }
+
+ uno::Reference< rendering::XCachedPrimitive > SAL_CALL SpriteCanvas::drawPolyPolygon( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon, const rendering::ViewState& viewState, const rendering::RenderState& renderState ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ checkOurState();
+
+ // TODO: Remember to handle backgroundDirty also for XCachedPrimitive redraw!
+ mpRedrawManager->backgroundDirty();
+ return maCanvasHelper.drawPolyPolygon(xPolyPolygon, viewState, renderState, getImplRef());
+ }
+
+ uno::Reference< rendering::XCachedPrimitive > SAL_CALL SpriteCanvas::strokePolyPolygon( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon, const rendering::ViewState& viewState, const rendering::RenderState& renderState, const rendering::StrokeAttributes& strokeAttributes ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ checkOurState();
+
+ mpRedrawManager->backgroundDirty();
+ return maCanvasHelper.strokePolyPolygon(xPolyPolygon, viewState, renderState, strokeAttributes, getImplRef());
+ }
+
+ uno::Reference< rendering::XCachedPrimitive > SAL_CALL SpriteCanvas::strokeTexturedPolyPolygon( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon, const rendering::ViewState& viewState, const rendering::RenderState& renderState, const uno::Sequence< rendering::Texture >& textures, const rendering::StrokeAttributes& strokeAttributes ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ checkOurState();
+
+ mpRedrawManager->backgroundDirty();
+ return maCanvasHelper.strokeTexturedPolyPolygon(xPolyPolygon, viewState, renderState, textures, strokeAttributes, getImplRef());
+ }
+
+ uno::Reference< rendering::XCachedPrimitive > SAL_CALL SpriteCanvas::strokeTextureMappedPolyPolygon( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon, const rendering::ViewState& viewState, const rendering::RenderState& renderState, const uno::Sequence< rendering::Texture >& textures, const uno::Reference< geometry::XMapping2D >& xMapping, const rendering::StrokeAttributes& strokeAttributes ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ checkOurState();
+
+ mpRedrawManager->backgroundDirty();
+ return maCanvasHelper.strokeTextureMappedPolyPolygon(xPolyPolygon, viewState, renderState, textures, xMapping, strokeAttributes, getImplRef());
+ }
+
+ uno::Reference< rendering::XPolyPolygon2D > SAL_CALL SpriteCanvas::queryStrokeShapes( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon, const rendering::ViewState& viewState, const rendering::RenderState& renderState, const rendering::StrokeAttributes& strokeAttributes ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ return maCanvasHelper.queryStrokeShapes(xPolyPolygon, viewState, renderState, strokeAttributes, getImplRef());
+ }
+
+ uno::Reference< rendering::XCachedPrimitive > SAL_CALL SpriteCanvas::fillPolyPolygon( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon, const rendering::ViewState& viewState, const rendering::RenderState& renderState ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ checkOurState();
+
+ mpRedrawManager->backgroundDirty();
+ return maCanvasHelper.fillPolyPolygon(xPolyPolygon, viewState, renderState, getImplRef() );
+ }
+
+ uno::Reference< rendering::XCachedPrimitive > SAL_CALL SpriteCanvas::fillTexturedPolyPolygon( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon, const rendering::ViewState& viewState, const rendering::RenderState& renderState, const uno::Sequence< rendering::Texture >& textures ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ checkOurState();
+
+ mpRedrawManager->backgroundDirty();
+ return maCanvasHelper.fillTexturedPolyPolygon(xPolyPolygon, viewState, renderState, textures, getImplRef());
+ }
+
+ uno::Reference< rendering::XCachedPrimitive > SAL_CALL SpriteCanvas::fillTextureMappedPolyPolygon( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon, const rendering::ViewState& viewState, const rendering::RenderState& renderState, const uno::Sequence< rendering::Texture >& textures, const uno::Reference< geometry::XMapping2D >& xMapping ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ checkOurState();
+
+ mpRedrawManager->backgroundDirty();
+ return maCanvasHelper.fillTextureMappedPolyPolygon(xPolyPolygon, viewState, renderState, textures, xMapping, getImplRef());
+ }
+
+ uno::Reference< rendering::XCanvasFont > SAL_CALL SpriteCanvas::queryFont( const rendering::FontRequest& fontRequest ) throw (uno::RuntimeException)
+ {
+ return maCanvasHelper.queryFont( fontRequest, getImplRef() );
+ }
+
+ uno::Reference< rendering::XCachedPrimitive > SAL_CALL SpriteCanvas::drawText( const rendering::StringContext& text,
+ const uno::Reference< rendering::XCanvasFont >& xFont,
+ const rendering::ViewState& viewState,
+ const rendering::RenderState& renderState,
+ sal_Int8 textDirection ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ checkOurState();
+
+ mpRedrawManager->backgroundDirty();
+ return maCanvasHelper.drawText(text, xFont, viewState, renderState, textDirection, getImplRef());
+ }
+
+ uno::Reference< rendering::XCachedPrimitive > SAL_CALL SpriteCanvas::drawOffsettedText( const rendering::StringContext& text, const uno::Reference< rendering::XCanvasFont >& xFont, const uno::Sequence< double >& offsets, const rendering::ViewState& viewState, const rendering::RenderState& renderState, sal_Int8 textDirection ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ checkOurState();
+
+ mpRedrawManager->backgroundDirty();
+ return maCanvasHelper.drawOffsettedText(text, xFont, offsets, viewState, renderState, textDirection, getImplRef());
+ }
+
+ uno::Reference< rendering::XCachedPrimitive > SAL_CALL SpriteCanvas::drawBitmap( const uno::Reference< rendering::XBitmap >& xBitmap, const rendering::ViewState& viewState, const rendering::RenderState& renderState ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ checkOurState();
+
+ mpRedrawManager->backgroundDirty();
+ return maCanvasHelper.drawBitmap(xBitmap, viewState, renderState, getImplRef());
+ }
+
+ uno::Reference< rendering::XGraphicDevice > SAL_CALL SpriteCanvas::getDevice() throw (uno::RuntimeException)
+ {
+ return maCanvasHelper.getDevice( getImplRef() );
+ }
+
+ void SAL_CALL SpriteCanvas::copyRect( const uno::Reference< rendering::XBitmapCanvas >& sourceCanvas,
+ const geometry::RealRectangle2D& sourceRect,
+ const rendering::ViewState& sourceViewState,
+ const rendering::RenderState& sourceRenderState,
+ const geometry::RealRectangle2D& destRect,
+ const rendering::ViewState& destViewState,
+ const rendering::RenderState& destRenderState ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ checkOurState();
+
+ tools::LocalGuard aGuard;
+
+ mpRedrawManager->backgroundDirty();
+ }
+
+ uno::Reference< rendering::XAnimatedSprite > SAL_CALL SpriteCanvas::createSpriteFromAnimation( const uno::Reference< rendering::XAnimation >& animation ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ tools::LocalGuard aGuard;
+
+ return uno::Reference< rendering::XAnimatedSprite >(NULL);
+ }
+
+ uno::Reference< rendering::XAnimatedSprite > SAL_CALL SpriteCanvas::createSpriteFromBitmaps( const uno::Sequence< uno::Reference< rendering::XBitmap > >& animationBitmaps,
+ sal_Int16 interpolationMode ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ tools::LocalGuard aGuard;
+
+ return uno::Reference< rendering::XAnimatedSprite >(NULL);
+ }
+
+ uno::Reference< rendering::XCustomSprite > SAL_CALL SpriteCanvas::createCustomSprite( const geometry::RealSize2D& spriteSize ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ tools::LocalGuard aGuard;
+
+ return uno::Reference< rendering::XCustomSprite >(
+ new CanvasCustomSprite( spriteSize,
+ ImplRef(this)) );
+ }
+
+ uno::Reference< rendering::XSprite > SAL_CALL SpriteCanvas::createClonedSprite( const uno::Reference< rendering::XSprite >& original ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ tools::LocalGuard aGuard;
+
+ return uno::Reference< rendering::XSprite >(NULL);
+ }
+
+ sal_Bool SAL_CALL SpriteCanvas::updateScreen() throw (uno::RuntimeException)
+ {
+ checkOurState();
+
+ tools::LocalGuard aGuard;
+
+ mpRedrawManager->updateScreen();
+
+ // commit to screen
+ maCanvasHelper.flush();
+
+ return sal_True;
+ }
+
+ void SAL_CALL SpriteCanvas::initialize( const uno::Sequence< uno::Any >& aArguments ) throw( uno::Exception,
+ uno::RuntimeException)
+ {
+ VERBOSE_TRACE( "SpriteCanvas::initialize called" );
+
+ OSL_ENSURE( aArguments.getLength() >= 1,
+ "SpriteCanvas::initialize: wrong number of arguments" );
+
+ // 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 )
+ {
+ mpOutputWindow = *(Window**)(aArguments[0].getValue());
+ OSL_ENSURE( mpOutputWindow != NULL,
+ "SpriteCanvas::initialize: invalid Window pointer" );
+
+ // setup back buffer
+ maVDev->SetOutputSizePixel( mpOutputWindow->GetOutputSizePixel() );
+
+ // always render into back buffer
+ maCanvasHelper.setOutDev( *maVDev );
+
+ mpRedrawManager = ::std::auto_ptr< RedrawManager >( new RedrawManager( *mpOutputWindow,
+ *maVDev ) );
+ }
+ }
+
+ ::rtl::OUString SAL_CALL SpriteCanvas::getImplementationName() throw( uno::RuntimeException )
+ {
+ return getImplementationName_SpriteCanvas();
+ }
+
+ sal_Bool SAL_CALL SpriteCanvas::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException )
+ {
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
+ }
+
+ uno::Sequence< ::rtl::OUString > SAL_CALL SpriteCanvas::getSupportedServiceNames() throw( uno::RuntimeException )
+ {
+ return getSupportedServiceNames_SpriteCanvas();
+ }
+
+ ::rtl::OUString SAL_CALL SpriteCanvas::getServiceName( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) );
+ }
+
+ uno::Reference< uno::XInterface > SAL_CALL SpriteCanvas::createInstance( const uno::Reference< uno::XComponentContext >& xContext ) throw ( uno::Exception )
+ {
+ return uno::Reference< uno::XInterface >( static_cast<cppu::OWeakObject*>(new SpriteCanvas( xContext )) );
+ }
+
+ // SpriteSurface
+ void SpriteCanvas::showSprite( const Sprite::ImplRef& sprite )
+ {
+ checkOurState();
+
+ tools::LocalGuard aGuard;
+ mpRedrawManager->showSprite( sprite );
+ }
+
+ void SpriteCanvas::hideSprite( const Sprite::ImplRef& sprite )
+ {
+ checkOurState();
+
+ // strictly speaking, the solar mutex here is overkill, and a
+ // object mutex would suffice. But on the other hand, nearly
+ // every other method needs the solar mutex anyway, so it's no
+ // big loss (and much simpler) here.
+ tools::LocalGuard aGuard;
+ mpRedrawManager->hideSprite( sprite );
+ }
+
+ void SpriteCanvas::moveSprite( const Sprite::ImplRef& sprite,
+ const Point& rOldPos,
+ const Point& rNewPos )
+ {
+ checkOurState();
+
+ tools::LocalGuard aGuard;
+ mpRedrawManager->moveSprite( sprite, rOldPos, rNewPos );
+ }
+
+ void SpriteCanvas::updateSprite( const Sprite::ImplRef& sprite,
+ const Point& rPos,
+ const Rectangle& rUpdateArea )
+ {
+ checkOurState();
+
+ tools::LocalGuard aGuard;
+ mpRedrawManager->updateSprite( sprite, rPos, rUpdateArea );
+ }
+
+ // OutDevProvider
+ ::OutputDevice& SpriteCanvas::getOutDev()
+ {
+ return maCanvasHelper.getOutDev();
+ }
+
+ const ::OutputDevice& SpriteCanvas::getOutDev() const
+ {
+ return maCanvasHelper.getOutDev();
+ }
+
+ void SpriteCanvas::checkOurState()
+ {
+ if( mpOutputWindow == NULL ||
+ mpRedrawManager.get() == NULL )
+ throw uno::RuntimeException();
+ }
+
+}
+
+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,
+ uno_Environment** ppEnv )
+ {
+ *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 );
+ }
+}
diff --git a/canvas/source/vcl/spritecanvas.hxx b/canvas/source/vcl/spritecanvas.hxx
new file mode 100644
index 000000000000..3ef72a84bea9
--- /dev/null
+++ b/canvas/source/vcl/spritecanvas.hxx
@@ -0,0 +1,298 @@
+/*************************************************************************
+ *
+ * $RCSfile: spritecanvas.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: thb $ $Date: 2004-03-18 10:38:44 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _VCLCANVAS_SPRITECANVAS_HXX_
+#define _VCLCANVAS_SPRITECANVAS_HXX_
+
+#include <memory>
+
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
+#include <com/sun/star/uno/Reference.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
+#include <com/sun/star/uno/Any.hxx>
+#endif
+
+#ifndef _CPPUHELPER_COMPBASE4_HXX_
+#include <cppuhelper/compbase4.hxx>
+#endif
+#ifndef _COMPHELPER_BROADCASTHELPER_HXX_
+#include <comphelper/broadcasthelper.hxx>
+#endif
+#ifndef _COMPHELPER_UNO3_HXX
+#include <comphelper/uno3.hxx>
+#endif
+
+#ifndef _RTL_REF_HXX_
+#include <rtl/ref.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICENAME_HPP_
+#include <com/sun/star/lang/XServiceName.hpp>
+#endif
+
+#ifndef _SV_VIRDEV_HXX
+#include <vcl/virdev.hxx>
+#endif
+
+#ifndef _DRAFTS_COM_SUN_STAR_RENDERING_XSPRITECANVAS_HPP_
+#include <drafts/com/sun/star/rendering/XSpriteCanvas.hpp>
+#endif
+
+#include <canvas/vclwrapper.hxx>
+
+#include "redrawmanager.hxx"
+#include "spritesurface.hxx"
+#include "outdevprovider.hxx"
+#include "canvasbase.hxx"
+#include "impltools.hxx"
+
+class OutputDevice;
+class Point;
+
+namespace com { namespace sun { namespace star { namespace uno
+{
+ class XComponentContext;
+ class RuntimeException;
+} } } }
+
+class Window;
+
+namespace vclcanvas
+{
+ typedef ::cppu::WeakComponentImplHelper4< ::drafts::com::sun::star::rendering::XSpriteCanvas,
+ ::com::sun::star::lang::XInitialization,
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::lang::XServiceName > SpriteCanvas_Base;
+
+ class SpriteCanvas : public ::comphelper::OBaseMutex,
+ public SpriteSurface,
+ public OutDevProvider,
+ public SpriteCanvas_Base
+
+ {
+ public:
+ typedef ::rtl::Reference< SpriteCanvas > ImplRef;
+
+ SpriteCanvas( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
+
+ // XInterface
+
+ // Need to implement that, because OutDevProvide comes with an
+ // unimplemented version of XInterface.
+
+ // Forwarding the XInterface implementation to the
+ // cppu::ImplHelper templated base, which does the refcounting and
+ // queryInterface for us: Classname Base doing refcount and handling queryInterface
+ // | |
+ // V V
+ DECLARE_UNO3_AGG_DEFAULTS( SpriteCanvas, SpriteCanvas_Base );
+
+ // XCanvas
+ virtual void SAL_CALL drawPoint( const ::drafts::com::sun::star::geometry::RealPoint2D& aPoint,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL drawLine( const ::drafts::com::sun::star::geometry::RealPoint2D& aStartPoint,
+ const ::drafts::com::sun::star::geometry::RealPoint2D& aEndPoint,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL drawBezier( const ::drafts::com::sun::star::geometry::RealBezierSegment2D& aBezierSegment,
+ const ::drafts::com::sun::star::geometry::RealPoint2D& aEndPoint,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCachedPrimitive > SAL_CALL
+ drawPolyPolygon( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCachedPrimitive > SAL_CALL
+ strokePolyPolygon( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState,
+ const ::drafts::com::sun::star::rendering::StrokeAttributes& strokeAttributes ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCachedPrimitive > SAL_CALL
+ strokeTexturedPolyPolygon( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState,
+ const ::com::sun::star::uno::Sequence< ::drafts::com::sun::star::rendering::Texture >& textures,
+ const ::drafts::com::sun::star::rendering::StrokeAttributes& strokeAttributes ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCachedPrimitive > SAL_CALL
+ strokeTextureMappedPolyPolygon( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState,
+ const ::com::sun::star::uno::Sequence< ::drafts::com::sun::star::rendering::Texture >& textures,
+ const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::geometry::XMapping2D >& xMapping,
+ const ::drafts::com::sun::star::rendering::StrokeAttributes& strokeAttributes ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XPolyPolygon2D > SAL_CALL
+ queryStrokeShapes( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState,
+ const ::drafts::com::sun::star::rendering::StrokeAttributes& strokeAttributes ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCachedPrimitive > SAL_CALL
+ fillPolyPolygon( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCachedPrimitive > SAL_CALL
+ fillTexturedPolyPolygon( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState,
+ const ::com::sun::star::uno::Sequence< ::drafts::com::sun::star::rendering::Texture >& textures ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCachedPrimitive > SAL_CALL
+ fillTextureMappedPolyPolygon( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState,
+ const ::com::sun::star::uno::Sequence< ::drafts::com::sun::star::rendering::Texture >& textures,
+ const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::geometry::XMapping2D >& xMapping ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCanvasFont > SAL_CALL
+ queryFont( const ::drafts::com::sun::star::rendering::FontRequest& fontRequest ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCachedPrimitive > SAL_CALL
+ drawText( const ::drafts::com::sun::star::rendering::StringContext& text,
+ const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCanvasFont >& xFont,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState,
+ sal_Int8 textDirection ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCachedPrimitive > SAL_CALL
+ drawOffsettedText( const ::drafts::com::sun::star::rendering::StringContext& text,
+ const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCanvasFont >& xFont,
+ const ::com::sun::star::uno::Sequence< double >& offsets,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState,
+ sal_Int8 textDirection ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCachedPrimitive > SAL_CALL
+ drawBitmap( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XBitmap >& xBitmap,
+ const ::drafts::com::sun::star::rendering::ViewState& viewState,
+ const ::drafts::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XGraphicDevice > SAL_CALL
+ getDevice() throw (::com::sun::star::uno::RuntimeException);
+
+ // XBitmapCanvas (only providing, not implementing the
+ // interface. Also note subtle method parameter differences)
+ virtual void SAL_CALL copyRect( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XBitmapCanvas >& sourceCanvas,
+ const ::drafts::com::sun::star::geometry::RealRectangle2D& sourceRect,
+ const ::drafts::com::sun::star::rendering::ViewState& sourceViewState,
+ const ::drafts::com::sun::star::rendering::RenderState& sourceRenderState,
+ const ::drafts::com::sun::star::geometry::RealRectangle2D& destRect,
+ const ::drafts::com::sun::star::rendering::ViewState& destViewState,
+ const ::drafts::com::sun::star::rendering::RenderState& destRenderState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ // XSpriteCanvas
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XAnimatedSprite > SAL_CALL createSpriteFromAnimation( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XAnimation >& animation ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XAnimatedSprite > SAL_CALL createSpriteFromBitmaps( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XBitmap > >& animationBitmaps,
+ sal_Int16 interpolationMode ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XCustomSprite > SAL_CALL createCustomSprite( const ::drafts::com::sun::star::geometry::RealSize2D& spriteSize ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XSprite > SAL_CALL createClonedSprite( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::rendering::XSprite >& original ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL updateScreen() throw (::com::sun::star::uno::RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw( ::com::sun::star::uno::Exception,
+ ::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
+
+ // XServiceName
+ virtual ::rtl::OUString SAL_CALL getServiceName( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // factory
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ) throw ( ::com::sun::star::uno::Exception );
+
+ // SpriteSurface
+ virtual void showSprite( const Sprite::ImplRef& sprite );
+ virtual void hideSprite( const Sprite::ImplRef& sprite );
+ virtual void moveSprite( const Sprite::ImplRef& sprite,
+ const Point& rOldPos,
+ const Point& rNewPos );
+ virtual void updateSprite( const Sprite::ImplRef& sprite,
+ const Point& rPos,
+ const Rectangle& rUpdateArea );
+
+ // OutDevProvider
+ virtual OutputDevice& getOutDev();
+ virtual const OutputDevice& getOutDev() const;
+
+ protected:
+ ~SpriteCanvas(); // we're a ref-counted UNO class. _We_ destroy ourselves.
+
+ private:
+ // default: disabled copy/assignment
+ SpriteCanvas(const SpriteCanvas&);
+ SpriteCanvas& operator=( const SpriteCanvas& );
+
+ void checkOurState(); // throws
+ OutDevProvider::ImplRef getImplRef();
+
+ // TODO: Lifetime issue. Cannot control pointer validity over
+ // object lifetime, since we're a UNO component
+ Window* mpOutputWindow; // for the screen output
+ ::canvas::vcltools::VCLObject<VirtualDevice> maVDev; // for the back-buffer
+ ::std::auto_ptr< RedrawManager > mpRedrawManager; // handles smooth screen updates for us
+ CanvasBase maCanvasHelper; // for the basic canvas implementation
+ };
+}
+
+#endif