nss: upgrade to release 3.73
[LibreOffice.git] / canvas / workben / canvasdemo.cxx
blobe19e1f45f2afda55a3e22b59f7cff01f0db7f258
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 // This code strongly inspired by Miguel / Federico's Gnome Canvas demo code.
22 #include <sal/config.h>
24 #include <basegfx/polygon/b2dpolygon.hxx>
25 #include <basegfx/polygon/b2dpolygontools.hxx>
26 #include <basegfx/utils/canvastools.hxx>
27 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
28 #include <com/sun/star/rendering/CompositeOperation.hpp>
29 #include <com/sun/star/rendering/PathCapType.hpp>
30 #include <com/sun/star/rendering/PathJoinType.hpp>
31 #include <com/sun/star/rendering/RenderState.hpp>
32 #include <com/sun/star/rendering/ViewState.hpp>
33 #include <com/sun/star/rendering/XBitmap.hpp>
34 #include <com/sun/star/rendering/XCanvas.hpp>
35 #include <com/sun/star/rendering/XGraphicDevice.hpp>
36 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
37 #include <com/sun/star/uno/XComponentContext.hpp>
38 #include <comphelper/processfactory.hxx>
39 #include <comphelper/random.hxx>
40 #include <cppuhelper/bootstrap.hxx>
41 #include <vcl/canvastools.hxx>
42 #include <vcl/svapp.hxx>
43 #include <vcl/vclmain.hxx>
44 #include <vcl/wrkwin.hxx>
46 using namespace ::com::sun::star;
48 static void PrintHelp()
50 fprintf( stdout, "canvasdemo - Exercise the new canvas impl\n" );
53 namespace {
55 class TestWindow : public WorkWindow
57 public:
58 TestWindow() : WorkWindow(nullptr, WB_APP | WB_STDWORK)
60 SetText("Canvas test");
61 SetSizePixel( Size( 600, 450 ) );
62 EnablePaint( true );
63 Show();
65 virtual ~TestWindow() override {}
66 virtual void MouseButtonUp( const MouseEvent& /*rMEvt*/ ) override
68 //TODO: do something cool
69 Application::Quit();
71 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
74 class DemoRenderer
76 public:
77 Size maSize;
78 Size maBox;
79 rendering::ViewState maViewState;
80 rendering::RenderState maRenderState;
81 uno::Sequence< double > maColorBlack;
82 uno::Sequence< double > maColorRed;
83 uno::Reference< rendering::XCanvas > mxCanvas;
84 uno::Reference< rendering::XCanvasFont > mxDefaultFont;
85 uno::Reference< rendering::XGraphicDevice > mxDevice;
87 DemoRenderer( uno::Reference< rendering::XGraphicDevice > xDevice,
88 uno::Reference< rendering::XCanvas > xCanvas,
89 Size aSize ) :
90 maSize(aSize),
91 maBox(),
92 maViewState(),
93 maRenderState(),
94 maColorBlack( vcl::unotools::colorToStdColorSpaceSequence( COL_BLACK) ),
95 maColorRed( vcl::unotools::colorToStdColorSpaceSequence( COL_RED) ),
96 mxCanvas(xCanvas),
97 mxDefaultFont(),
98 mxDevice( xDevice )
100 // Geometry init
101 geometry::AffineMatrix2D aUnit( 1,0, 0,
102 0,1, 0 );
103 maViewState.AffineTransform = aUnit;
104 maRenderState.AffineTransform = aUnit;
105 maRenderState.DeviceColor = maColorBlack;
107 //I can't figure out what the compositeoperation stuff does
108 //it doesn't seem to do anything in either VCL or cairocanvas
109 //I was hoping that CLEAR would clear the canvas before we paint,
110 //but nothing changes
111 maRenderState.CompositeOperation = rendering::CompositeOperation::OVER;
113 maBox.setWidth(aSize.Width() / 3);
114 maBox.setHeight(aSize.Height() / 3);
116 lang::Locale aLocale;
117 rendering::FontInfo aFontInfo;
118 aFontInfo.FamilyName = "Swiss";
119 aFontInfo.StyleName = "SansSerif";
120 geometry::Matrix2D aFontMatrix( 1, 0,
121 0, 1 );
122 rendering::FontRequest aFontRequest( aFontInfo, 12.0, 0.0, aLocale );
123 uno::Sequence< beans::PropertyValue > aExtraFontProperties;
124 mxDefaultFont = xCanvas->createFont( aFontRequest, aExtraFontProperties, aFontMatrix );
125 if( !mxDefaultFont.is() )
126 fprintf( stderr, "Failed to create font\n" );
129 void drawGrid()
131 tools::Long d, dIncr = maSize.Width() / 3;
132 for ( d = 0; d <= maSize.Width(); d += dIncr )
133 mxCanvas->drawLine( geometry::RealPoint2D( d, 0 ),
134 geometry::RealPoint2D( d, maSize.Height() ),
135 maViewState, maRenderState );
136 dIncr = maSize.Height() / 3;
137 for ( d = 0; d <= maSize.Height(); d += dIncr )
138 mxCanvas->drawLine( geometry::RealPoint2D( 0, d ),
139 geometry::RealPoint2D( maSize.Width(), d ),
140 maViewState, maRenderState );
143 void drawStringAt( OString aString, double x, double y )
145 rendering::StringContext aText;
146 aText.Text = OStringToOUString( aString, RTL_TEXTENCODING_UTF8 );
147 aText.StartPosition = 0;
148 aText.Length = aString.getLength();
149 rendering::RenderState aRenderState( maRenderState );
150 aRenderState.AffineTransform.m02 += x;
151 aRenderState.AffineTransform.m12 += y;
153 mxCanvas->drawText( aText, mxDefaultFont, maViewState, aRenderState, 0);
156 void drawRect( tools::Rectangle rRect, const uno::Sequence< double > &aColor, int /*nWidth*/ )
158 uno::Sequence< geometry::RealPoint2D > aPoints(4);
159 uno::Reference< rendering::XLinePolyPolygon2D > xPoly;
161 aPoints[0] = geometry::RealPoint2D( rRect.Left(), rRect.Top() );
162 aPoints[1] = geometry::RealPoint2D( rRect.Left(), rRect.Bottom() );
163 aPoints[2] = geometry::RealPoint2D( rRect.Right(), rRect.Bottom() );
164 aPoints[3] = geometry::RealPoint2D( rRect.Right(), rRect.Top() );
166 uno::Sequence< uno::Sequence< geometry::RealPoint2D > > aPolys(1);
167 aPolys[0] = aPoints;
168 xPoly = mxDevice->createCompatibleLinePolyPolygon( aPolys );
169 xPoly->setClosed( 0, true );
171 rendering::RenderState aRenderState( maRenderState );
172 aRenderState.DeviceColor = aColor;
173 mxCanvas->drawPolyPolygon( xPoly, maViewState, aRenderState );
176 void translate( double x, double y)
178 maRenderState.AffineTransform.m02 += x;
179 maRenderState.AffineTransform.m12 += y;
182 void drawPolishDiamond( double center_x, double center_y)
184 const int VERTICES = 10;
185 const double RADIUS = 60.0;
186 int i, j;
188 rendering::RenderState maOldRenderState = maRenderState; // push
189 translate( center_x, center_y );
191 for (i = 0; i < VERTICES; i++)
193 double a = 2.0 * M_PI * i / VERTICES;
194 geometry::RealPoint2D aSrc( RADIUS * cos (a), RADIUS * sin (a) );
196 for (j = i + 1; j < VERTICES; j++)
198 a = 2.0 * M_PI * j / VERTICES;
200 // FIXME: set cap_style to 'ROUND'
201 mxCanvas->drawLine( aSrc,
202 geometry::RealPoint2D( RADIUS * cos (a),
203 RADIUS * sin (a) ),
204 maViewState, maRenderState );
208 maRenderState = maOldRenderState; // pop
211 void drawHilbert( double anchor_x, double anchor_y )
213 const double SCALE=7.0;
214 const char hilbert[] = "urdrrulurulldluuruluurdrurddldrrruluurdrurddldrddlulldrdldrrurd";
215 int nLength = SAL_N_ELEMENTS( hilbert );
217 uno::Sequence< geometry::RealPoint2D > aPoints( nLength );
218 uno::Reference< rendering::XLinePolyPolygon2D > xPoly;
220 aPoints[0] = geometry::RealPoint2D( anchor_x, anchor_y );
221 for (int i = 0; i < nLength; i++ )
223 switch( hilbert[i] )
225 case 'u':
226 aPoints[i+1] = geometry::RealPoint2D( aPoints[i].X,
227 aPoints[i].Y - SCALE );
228 break;
229 case 'd':
230 aPoints[i+1] = geometry::RealPoint2D( aPoints[i].X,
231 aPoints[i].Y + SCALE );
232 break;
233 case 'l':
234 aPoints[i+1] = geometry::RealPoint2D( aPoints[i].X - SCALE,
235 aPoints[i].Y );
236 break;
237 case 'r':
238 aPoints[i+1] = geometry::RealPoint2D( aPoints[i].X + SCALE,
239 aPoints[i].Y );
240 break;
244 uno::Sequence< uno::Sequence< geometry::RealPoint2D > > aPolys(1);
245 aPolys[0] = aPoints;
247 xPoly = mxDevice->createCompatibleLinePolyPolygon( aPolys );
248 xPoly->setClosed( 0, false );
250 rendering::RenderState aRenderState( maRenderState );
251 aRenderState.DeviceColor = maColorRed;
252 // aRenderState.DeviceColor[3] = 0.5;
253 rendering::StrokeAttributes aStrokeAttrs;
254 aStrokeAttrs.StrokeWidth = 4.0;
255 aStrokeAttrs.MiterLimit = 2.0; // ?
256 aStrokeAttrs.StartCapType = rendering::PathCapType::BUTT;
257 aStrokeAttrs.EndCapType = rendering::PathCapType::BUTT;
258 aStrokeAttrs.JoinType = rendering::PathJoinType::MITER;
259 //fprintf( stderr, "FIXME: stroking a tools::PolyPolygon doesn't show up\n" );
260 //yes it does
261 mxCanvas->strokePolyPolygon( xPoly, maViewState, aRenderState, aStrokeAttrs );
262 // FIXME: do this instead:
263 //mxCanvas->drawPolyPolygon( xPoly, maViewState, aRenderState );
266 void drawTitle( OString aTitle )
268 // FIXME: text anchoring to be done
269 double nStringWidth = aTitle.getLength() * 8.0;
270 drawStringAt ( aTitle, (maBox.Width() - nStringWidth) / 2, 15 );
273 void drawRectangles()
275 rendering::RenderState maOldRenderState = maRenderState; // push
277 drawTitle( OString( "Rectangles" ) );
279 drawRect( tools::Rectangle( 20, 30, 70, 60 ), maColorRed, 8 );
280 // color mediumseagreen, stipple fill, outline black
281 drawRect( tools::Rectangle( 90, 40, 180, 100 ), maColorBlack, 4 );
282 // color steelblue, filled, no outline
283 drawRect( tools::Rectangle( 10, 80, 80, 140 ), maColorBlack, 1 );
285 maRenderState = maOldRenderState; // pop
288 void drawEllipses()
290 rendering::RenderState maOldRenderState = maRenderState; // push
291 translate( maBox.Width(), 0.0 );
293 drawTitle( OString( "Ellipses" ) );
295 const basegfx::B2DPoint aCenter( maBox.Width()*.5,
296 maBox.Height()*.5 );
297 const basegfx::B2DPoint aRadii( maBox.Width()*.3,
298 maBox.Height()*.3 );
299 const basegfx::B2DPolygon& rEllipse(
300 basegfx::utils::createPolygonFromEllipse( aCenter,
301 aRadii.getX(),
302 aRadii.getY() ));
304 uno::Reference< rendering::XPolyPolygon2D > xPoly(
305 basegfx::unotools::xPolyPolygonFromB2DPolygon(mxDevice,
306 rEllipse) );
308 rendering::StrokeAttributes aStrokeAttrs;
309 aStrokeAttrs.StrokeWidth = 4.0;
310 aStrokeAttrs.MiterLimit = 2.0; // ?
311 aStrokeAttrs.StartCapType = rendering::PathCapType::BUTT;
312 aStrokeAttrs.EndCapType = rendering::PathCapType::BUTT;
313 aStrokeAttrs.JoinType = rendering::PathJoinType::MITER;
314 mxCanvas->strokePolyPolygon( xPoly, maViewState, maRenderState, aStrokeAttrs );
316 maRenderState = maOldRenderState; // pop
319 void drawText()
321 rendering::RenderState maOldRenderState = maRenderState; // push
322 translate( maBox.Width() * 2.0, 0.0 );
324 drawTitle( OString( "Text" ) );
326 translate( 0.0,
327 maBox.Height() * .5 );
328 drawTitle( OString( "This is lame" ) );
330 maRenderState = maOldRenderState; // pop
333 void drawImages()
335 rendering::RenderState maOldRenderState = maRenderState; // push
336 translate( 0.0, maBox.Height() );
338 drawTitle( OString( "Images" ) );
340 uno::Reference< rendering::XBitmap > xBitmap(mxCanvas, uno::UNO_QUERY);
342 if( !xBitmap.is() )
343 return;
345 translate( maBox.Width()*0.1, maBox.Height()*0.2 );
346 maRenderState.AffineTransform.m00 *= 4.0/15;
347 maRenderState.AffineTransform.m11 *= 3.0/15;
349 mxCanvas->drawBitmap(xBitmap, maViewState, maRenderState);
351 // uno::Reference< rendering::XBitmap > xBitmap2( xBitmap->getScaledBitmap(geometry::RealSize2D(48, 48), false) );
352 // mxCanvas->drawBitmap(xBitmap2, maViewState, maRenderState); //yes, but where?
353 //cairo-canvas says:
354 //called CanvasHelper::getScaledBitmap, we return NULL, TODO
355 //Exception 'BitmapEx vclcanvas::tools::bitmapExFromXBitmap(const css::uno::Reference<css::rendering::XBitmap>&),
356 //bitmapExFromXBitmap(): could not extract BitmapEx' thrown
358 //vcl-canvas says:
359 //Exception 'BitmapEx vclcanvas::tools::bitmapExFromXBitmap(const css::uno::Reference<css::rendering::XBitmap>&),
360 //bitmapExFromXBitmap(): could not extract bitmap' thrown
361 // Thorsten says that this is a bug, and Thorsten never lies.
363 maRenderState = maOldRenderState; // pop
366 void drawLines()
368 rendering::RenderState maOldRenderState = maRenderState; // push
369 translate( maBox.Width(), maBox.Height() );
371 drawTitle( OString( "Lines" ) );
373 drawPolishDiamond( 70.0, 80.0 );
374 drawHilbert( 140.0, 140.0 );
376 maRenderState = maOldRenderState; // pop
379 void drawCurves()
381 rendering::RenderState maOldRenderState = maRenderState; // push
382 translate( maBox.Width() * 2.0, maBox.Height() );
384 drawTitle( OString( "Curves" ) );
386 translate( maBox.Width() * .5, maBox.Height() * .5 );
388 const double r= 30.0;
389 const int num_curves = 3;
391 //hacky hack hack
392 uno::Sequence< geometry::RealBezierSegment2D > aBeziers (num_curves);
393 uno::Reference< rendering::XBezierPolyPolygon2D > xPoly;
395 for (int i= 0; i < num_curves; i++)
396 aBeziers[i]= geometry::RealBezierSegment2D( r * cos(i*2*M_PI/num_curves), //Px
397 r * sin(i*2*M_PI/num_curves), //py
398 r * 2 * cos((i*2*M_PI + 2*M_PI)/num_curves), //C1x
399 r * 2 * sin((i*2*M_PI + 2*M_PI)/num_curves), //C1y
400 r * 2 * cos((i*2*M_PI + 2*M_PI)/num_curves), //C2x
401 r * 2 * sin((i*2*M_PI + 2*M_PI)/num_curves)); //C2y
402 uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > > aPolys(1);
403 aPolys[0] = aBeziers;
404 xPoly = mxDevice->createCompatibleBezierPolyPolygon(aPolys);
405 xPoly->setClosed( 0, true );
406 //uno::Reference< rendering::XBezierPolyPolygon2D> xPP( xPoly, uno::UNO_QUERY );
407 //compiles, but totally screws up. I think it is interpreting the bezier as a line
409 rendering::StrokeAttributes aStrokeAttrs;
410 aStrokeAttrs.StrokeWidth = 4.0;
411 aStrokeAttrs.MiterLimit = 2.0; // ?
412 aStrokeAttrs.StartCapType = rendering::PathCapType::BUTT;
413 aStrokeAttrs.EndCapType = rendering::PathCapType::BUTT;
414 aStrokeAttrs.JoinType = rendering::PathJoinType::MITER;
415 mxCanvas->strokePolyPolygon( xPoly, maViewState, maRenderState, aStrokeAttrs );
416 //you can't draw a BezierPolyPolygon2D with this, even though it is derived from it
417 //mxCanvas->drawPolyPolygon( xPoly, maViewState, maRenderState );
419 maRenderState = maOldRenderState; // pop
422 double gimmerand()
424 return comphelper::rng::uniform_real_distribution(0, 100);
427 void drawArcs()
429 rendering::RenderState maOldRenderState = maRenderState; // push
430 translate( 0.0, maBox.Height() * 2.0 );
432 drawTitle( OString( "Arcs" ) );
435 //begin hacks
436 //This stuff doesn't belong here, but probably in curves
437 //This stuff doesn't work in VCL b/c vcl doesn't do beziers
438 //Hah! Every time the window redraws, we do this
439 double bx;
440 double by;
441 bx= gimmerand();
442 by= gimmerand();
444 for (int i= 0; i < 1; i++)
446 double ax;
447 double ay;
448 //point a= point b;
449 ax= bx;
450 ay= by;
451 //point b= rand;
452 bx= gimmerand();
453 by= gimmerand();
454 double c1x= gimmerand();
455 double c1y= gimmerand();
456 double c2x= gimmerand();
457 double c2y= gimmerand();
458 maRenderState.DeviceColor = maColorRed;
459 mxCanvas->drawLine(geometry::RealPoint2D(ax, ay), geometry::RealPoint2D(c1x, c1y), maViewState, maRenderState);
460 mxCanvas->drawLine(geometry::RealPoint2D(c1x, c1y), geometry::RealPoint2D(c2x, c2y), maViewState, maRenderState);
461 mxCanvas->drawLine(geometry::RealPoint2D(bx, by), geometry::RealPoint2D(c2x, c2y), maViewState, maRenderState);
462 //draw from a to b
463 geometry::RealBezierSegment2D aBezierSegment(
464 ax, //Px
465 ay, //Py
466 c1x,
467 c1x,
468 c2x,
471 geometry::RealPoint2D aEndPoint(bx, by);
472 maRenderState.DeviceColor = maColorBlack;
473 mxCanvas->drawBezier(
474 aBezierSegment,
475 aEndPoint,
476 maViewState, maRenderState );
478 maRenderState = maOldRenderState; // pop
482 void drawRegularPolygon(double centerx, double centery, int sides, double r)
484 //hacky hack hack
485 uno::Sequence< geometry::RealPoint2D > aPoints (sides);
486 uno::Reference< rendering::XLinePolyPolygon2D > xPoly;
488 for (int i= 0; i < sides; i++)
490 aPoints[i]= geometry::RealPoint2D( centerx + r * cos(i*2 * M_PI/sides),
491 centery + r * sin(i*2 * M_PI/sides));
493 uno::Sequence< uno::Sequence< geometry::RealPoint2D > > aPolys(1);
494 aPolys[0] = aPoints;
495 xPoly = mxDevice->createCompatibleLinePolyPolygon( aPolys );
496 xPoly->setClosed( 0, true );
497 rendering::RenderState aRenderState( maRenderState );
498 aRenderState.DeviceColor = maColorRed;
499 mxCanvas->drawPolyPolygon( xPoly, maViewState, aRenderState);
500 mxCanvas->fillPolyPolygon( xPoly,
501 maViewState,
502 aRenderState );
505 void drawPolygons()
507 rendering::RenderState maOldRenderState = maRenderState; // push
508 translate( maBox.Width() * 1.0, maBox.Height() * 2.0 );
510 drawTitle( OString( "Polygons" ) );
512 int sides= 3;
513 for (int i= 1; i <= 4; i++)
515 drawRegularPolygon(35*i, 35, sides, 15);
516 sides++;
519 maRenderState = maOldRenderState; // pop
522 void drawWidgets() // FIXME: prolly makes no sense
524 rendering::RenderState maOldRenderState = maRenderState; // push
525 translate( maBox.Width() * 2.0, maBox.Height() * 2.0 );
527 drawTitle( OString( "Widgets" ) );
529 maRenderState = maOldRenderState; // pop
535 void TestWindow::Paint(vcl::RenderContext&, const tools::Rectangle&)
539 uno::Reference< rendering::XCanvas > xVDevCanvas( GetCanvas(),
540 uno::UNO_SET_THROW );
541 uno::Reference< rendering::XGraphicDevice > xVDevDevice( xVDevCanvas->getDevice(),
542 uno::UNO_SET_THROW );
543 DemoRenderer aVDevRenderer( xVDevDevice, xVDevCanvas, GetSizePixel());
544 xVDevCanvas->clear();
545 aVDevRenderer.drawGrid();
546 aVDevRenderer.drawRectangles();
547 aVDevRenderer.drawEllipses();
548 aVDevRenderer.drawText();
549 aVDevRenderer.drawLines();
550 aVDevRenderer.drawCurves();
551 aVDevRenderer.drawArcs();
552 aVDevRenderer.drawPolygons();
554 uno::Reference< rendering::XCanvas > xCanvas( GetSpriteCanvas(),
555 uno::UNO_QUERY_THROW );
556 uno::Reference< rendering::XGraphicDevice > xDevice( xCanvas->getDevice(),
557 uno::UNO_SET_THROW );
559 DemoRenderer aRenderer( xDevice, xCanvas, GetSizePixel() );
560 xCanvas->clear();
561 aRenderer.drawGrid();
562 aRenderer.drawRectangles();
563 aRenderer.drawEllipses();
564 aRenderer.drawText();
565 aRenderer.drawLines();
566 aRenderer.drawCurves();
567 aRenderer.drawArcs();
568 aRenderer.drawPolygons();
569 aRenderer.drawWidgets();
570 aRenderer.drawImages();
572 // check whether virdev actually contained something
573 uno::Reference< rendering::XBitmap > xBitmap(xVDevCanvas, uno::UNO_QUERY);
574 if( !xBitmap.is() )
575 return;
577 aRenderer.maRenderState.AffineTransform.m02 += 100;
578 aRenderer.maRenderState.AffineTransform.m12 += 100;
579 xCanvas->drawBitmap(xBitmap, aRenderer.maViewState, aRenderer.maRenderState);
581 uno::Reference< rendering::XSpriteCanvas > xSpriteCanvas( xCanvas,
582 uno::UNO_QUERY );
583 if( xSpriteCanvas.is() )
584 xSpriteCanvas->updateScreen( true ); // without
585 // updateScreen(),
586 // nothing is
587 // visible
589 catch (const uno::Exception &e)
591 fprintf( stderr, "Exception '%s' thrown\n" ,
592 OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
596 namespace {
598 class DemoApp : public Application
600 public:
601 virtual int Main() override;
602 virtual void Exception(ExceptionCategory nCategory) override;
604 protected:
605 void Init() override;
606 void DeInit() override;
611 int DemoApp::Main()
613 bool bHelp = false;
615 for( unsigned int i = 0; i < GetCommandLineParamCount(); i++ )
617 OUString aParam = GetCommandLineParam( i );
619 if( aParam == "--help" || aParam == "-h" )
620 bHelp = true;
623 if( bHelp )
625 PrintHelp();
626 return 1;
629 ScopedVclPtr<TestWindow> aWindow = VclPtr<TestWindow>::Create();
630 aWindow->Show();
632 Application::Execute();
633 return 0;
636 void DemoApp::Exception( ExceptionCategory )
640 void DemoApp::Init()
644 uno::Reference<uno::XComponentContext> xComponentContext
645 = ::cppu::defaultBootstrap_InitialComponentContext();
646 uno::Reference<lang::XMultiServiceFactory> xMSF;
647 xMSF.set(xComponentContext->getServiceManager(), uno::UNO_QUERY);
648 if(!xMSF.is())
649 Application::Abort("Bootstrap failure - no service manager");
651 ::comphelper::setProcessServiceFactory(xMSF);
653 catch (const uno::Exception &e)
655 Application::Abort("Bootstrap exception " + e.Message);
659 void DemoApp::DeInit()
661 uno::Reference< lang::XComponent >(
662 comphelper::getProcessComponentContext(),
663 uno::UNO_QUERY_THROW)-> dispose();
664 ::comphelper::setProcessServiceFactory(nullptr);
667 void vclmain::createApplication()
669 static DemoApp aApp;
672 // TODO
673 // - bouncing clip-rectangle mode - bounce a clip-rect around the window...
674 // - complete all of pre-existing canvas bits
675 // - affine transform tweakage...
677 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */