diff options
author | Kurt Zenker <kz@openoffice.org> | 2008-06-24 10:07:38 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2008-06-24 10:07:38 +0000 |
commit | 280fe3ce6fc9b3e2144663083d75aa7d18952ede (patch) | |
tree | 9190a5db185c4b2c60a5184945f84698967a6562 /canvas | |
parent | 1fa8e69f7aaa355b6ac0250c68de086aa190dab2 (diff) |
INTEGRATION: CWS canvas05 (1.5.26); FILE MERGED
2008/06/03 11:11:24 thb 1.5.26.7: Cleaned up image debugging stuff; fixed a few d3d debug warnings; fixed one deadlock rendering a bitmap from the same surface to itself; fixed premature ReleaseDC call in GraphicsProvider::getGraphics()
2008/05/30 16:03:39 thb 1.5.26.6: Added test of VirtualDevice::GetCanvas(); corrected one tiny bit in cairocanvas::clear
2008/04/21 07:32:56 thb 1.5.26.5: RESYNC: (1.5-1.6); FILE MERGED
2008/04/20 23:36:08 thb 1.5.26.4: Made canvasdemo work again on dev300; made sure GDIPlusUser is always destroyed _last_ (as it kills all other GDIPlus objects); made cairocanvas sensitive to outdev size
2008/04/04 13:39:04 thb 1.5.26.3: Fixed invalid polygon access; checking for the correct argument sequence now in Canvas::initialize; a few tweaks to canvasdemo
2008/04/03 21:26:11 thb 1.5.26.2: Made canvasdemo work again
2007/10/01 13:02:04 thb 1.5.26.1: #i78888# #i78925# #i79258# #i79437# Merge from CWS picom
Diffstat (limited to 'canvas')
-rw-r--r-- | canvas/workben/canvasdemo.cxx | 87 |
1 files changed, 63 insertions, 24 deletions
diff --git a/canvas/workben/canvasdemo.cxx b/canvas/workben/canvasdemo.cxx index 9d36b2e4061b..dad94cf843c0 100644 --- a/canvas/workben/canvasdemo.cxx +++ b/canvas/workben/canvasdemo.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: canvasdemo.cxx,v $ - * $Revision: 1.6 $ + * $Revision: 1.7 $ * * This file is part of OpenOffice.org. * @@ -33,14 +33,6 @@ #include "precompiled_canvas.hxx" // This code strongly inspired by Miguel / Federico's Gnome Canvas demo code. -#include <stdio.h> -#include <unistd.h> - -#ifndef _USE_MATH_DEFINES -#define _USE_MATH_DEFINES // needed by Visual C++ for math constants -#endif -#include <math.h> - #include <comphelper/processfactory.hxx> #include <comphelper/regpathhelper.hxx> #include <cppuhelper/servicefactory.hxx> @@ -57,6 +49,7 @@ #include <basegfx/tools/canvastools.hxx> #include <vcl/window.hxx> +#include <vcl/virdev.hxx> #include <vcl/svapp.hxx> #include <vcl/msgbox.hxx> #include <vcl/unowrap.hxx> @@ -75,6 +68,10 @@ #include <com/sun/star/rendering/CompositeOperation.hpp> #include <com/sun/star/rendering/XBitmap.hpp> +#include <stdio.h> +#include <unistd.h> + + // never import whole leaf namespaces, since this will result in // absolutely weird effects during (Koenig) name lookup using namespace ::com::sun::star; @@ -128,12 +125,17 @@ class DemoRenderer DemoRenderer( uno::Reference< rendering::XGraphicDevice > xDevice, uno::Reference< rendering::XCanvas > xCanvas, Size aSize ) : - mxDevice( xDevice ), mxCanvas( xCanvas ), maSize( aSize ) + maSize(aSize), + maBox(), + maViewState(), + maRenderState(), + maColorBlack( vcl::unotools::colorToStdColorSpaceSequence( Color(COL_BLACK)) ), + maColorWhite( vcl::unotools::colorToStdColorSpaceSequence( Color(COL_WHITE)) ), + maColorRed( vcl::unotools::colorToStdColorSpaceSequence( Color(COL_RED)) ), + mxCanvas(xCanvas), + mxDefaultFont(), + mxDevice( xDevice ) { - // Color init - maColorBlack = ::vcl::unotools::colorToDoubleSequence( xDevice, Color( COL_BLACK ) ); - maColorWhite = ::vcl::unotools::colorToDoubleSequence( xDevice, Color( COL_WHITE ) ); - maColorRed = ::vcl::unotools::colorToDoubleSequence( xDevice, Color( COL_RED ) ); // Geometry init geometry::AffineMatrix2D aUnit( 1,0, 0, 0,1, 0 ); @@ -378,7 +380,9 @@ class DemoRenderer drawTitle( ::rtl::OString( "Images" ) ); uno::Reference< rendering::XBitmap > xBitmap(mxCanvas, uno::UNO_QUERY); - xBitmap->queryBitmapCanvas(); + + if( !xBitmap.is() ) + return; translate( maBox.Width()*0.1, maBox.Height()*0.2 ); maRenderState.AffineTransform.m00 *= 4.0/15; @@ -492,17 +496,18 @@ class DemoRenderer by= gimmerand(); double c1x= gimmerand(); double c1y= gimmerand(); - double c2x= c1x; //gimmerand(); - double c2y= c1y; //gimmerand(); + double c2x= gimmerand(); + double c2y= gimmerand(); maRenderState.DeviceColor = maColorRed; mxCanvas->drawLine(geometry::RealPoint2D(ax, ay), geometry::RealPoint2D(c1x, c1y), maViewState, maRenderState); + mxCanvas->drawLine(geometry::RealPoint2D(c1x, c1y), geometry::RealPoint2D(c2x, c2y), maViewState, maRenderState); mxCanvas->drawLine(geometry::RealPoint2D(bx, by), geometry::RealPoint2D(c2x, c2y), maViewState, maRenderState); //draw from a to b geometry::RealBezierSegment2D aBezierSegment( ax, //Px ay, //Py c1x, - c2x, + c1x, c2x, c2y ); @@ -574,12 +579,31 @@ void TestWindow::Paint( const Rectangle& /*rRect*/ ) { try { - uno::Reference< rendering::XCanvas > xCanvas( GetCanvas(), - uno::UNO_QUERY_THROW ); + const Size aVDevSize(300,300); + VirtualDevice aVDev(*this); + aVDev.SetOutputSizePixel(aVDevSize); + uno::Reference< rendering::XCanvas > xVDevCanvas( aVDev.GetCanvas(), + uno::UNO_QUERY_THROW ); + uno::Reference< rendering::XGraphicDevice > xVDevDevice( xVDevCanvas->getDevice(), + uno::UNO_QUERY_THROW ); + DemoRenderer aVDevRenderer( xVDevDevice, xVDevCanvas, aVDevSize); + xVDevCanvas->clear(); + aVDevRenderer.drawGrid(); + aVDevRenderer.drawRectangles(); + aVDevRenderer.drawEllipses(); + aVDevRenderer.drawText(); + aVDevRenderer.drawLines(); + aVDevRenderer.drawCurves(); + aVDevRenderer.drawArcs(); + aVDevRenderer.drawPolygons(); + + uno::Reference< rendering::XCanvas > xCanvas( GetSpriteCanvas(), + uno::UNO_QUERY_THROW ); uno::Reference< rendering::XGraphicDevice > xDevice( xCanvas->getDevice(), uno::UNO_QUERY_THROW ); DemoRenderer aRenderer( xDevice, xCanvas, GetSizePixel() ); + xCanvas->clear(); aRenderer.drawGrid(); aRenderer.drawRectangles(); aRenderer.drawEllipses(); @@ -591,9 +615,22 @@ void TestWindow::Paint( const Rectangle& /*rRect*/ ) aRenderer.drawWidgets(); aRenderer.drawImages(); + // check whether virdev actually contained something + uno::Reference< rendering::XBitmap > xBitmap(xVDevCanvas, uno::UNO_QUERY); + if( !xBitmap.is() ) + return; + + aRenderer.maRenderState.AffineTransform.m02 += 100; + aRenderer.maRenderState.AffineTransform.m12 += 100; + xCanvas->drawBitmap(xBitmap, aRenderer.maViewState, aRenderer.maRenderState); + uno::Reference< rendering::XSpriteCanvas > xSpriteCanvas( xCanvas, - uno::UNO_QUERY_THROW ); - xSpriteCanvas->updateScreen( sal_True ); + uno::UNO_QUERY ); + if( xSpriteCanvas.is() ) + xSpriteCanvas->updateScreen( sal_True ); // without + // updateScreen(), + // nothing is + // visible } catch (const uno::Exception &e) { @@ -658,13 +695,15 @@ void DemoApp::Main() uno::Sequence< uno::Any > aArgs( 2 ); aArgs[ 0 ] <<= rtl::OUString::createFromAscii( UCB_CONFIGURATION_KEY1_LOCAL ); aArgs[ 1 ] <<= rtl::OUString::createFromAscii( UCB_CONFIGURATION_KEY2_OFFICE ); - ::ucb::ContentBroker::initialize( xFactory, aArgs ); + ::ucbhelper::ContentBroker::initialize( xFactory, aArgs ); + InitVCL( xFactory ); TestWindow pWindow; pWindow.Execute(); + DeInitVCL(); // clean up UCB - ::ucb::ContentBroker::deinitialize(); + ::ucbhelper::ContentBroker::deinitialize(); } DemoApp aDemoApp; |