1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/FillRule.hpp>
30 #include <com/sun/star/rendering/PathCapType.hpp>
31 #include <com/sun/star/rendering/PathJoinType.hpp>
32 #include <com/sun/star/rendering/RenderState.hpp>
33 #include <com/sun/star/rendering/ViewState.hpp>
34 #include <com/sun/star/rendering/XBitmap.hpp>
35 #include <com/sun/star/rendering/XCanvas.hpp>
36 #include <com/sun/star/rendering/XGraphicDevice.hpp>
37 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
38 #include <com/sun/star/ucb/UniversalContentBroker.hpp>
39 #include <comphelper/processfactory.hxx>
40 #include <cppuhelper/bootstrap.hxx>
41 #include <vcl/canvastools.hxx>
42 #include <vcl/svapp.hxx>
43 #include <vcl/vclmain.hxx>
44 #include <vcl/virdev.hxx>
45 #include <vcl/window.hxx>
46 #include <vcl/wrkwin.hxx>
48 using namespace ::com::sun::star
;
50 static void PrintHelp()
52 fprintf( stdout
, "canvasdemo - Exercise the new canvas impl\n" );
55 class TestWindow
: public WorkWindow
58 TestWindow() : WorkWindow(nullptr, WB_APP
| WB_STDWORK
)
60 SetText("Canvas test");
61 SetSizePixel( Size( 600, 450 ) );
65 virtual ~TestWindow() override
{}
66 virtual void MouseButtonUp( const MouseEvent
& /*rMEvt*/ ) override
68 //TODO: do something cool
71 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
79 rendering::ViewState maViewState
;
80 rendering::RenderState maRenderState
;
81 uno::Sequence
< double > maColorBlack
;
82 uno::Sequence
< double > maColorWhite
;
83 uno::Sequence
< double > maColorRed
;
84 uno::Reference
< rendering::XCanvas
> mxCanvas
;
85 uno::Reference
< rendering::XCanvasFont
> mxDefaultFont
;
86 uno::Reference
< rendering::XGraphicDevice
> mxDevice
;
88 DemoRenderer( uno::Reference
< rendering::XGraphicDevice
> xDevice
,
89 uno::Reference
< rendering::XCanvas
> xCanvas
,
95 maColorBlack( vcl::unotools::colorToStdColorSpaceSequence( COL_BLACK
) ),
96 maColorWhite( vcl::unotools::colorToStdColorSpaceSequence( COL_WHITE
) ),
97 maColorRed( vcl::unotools::colorToStdColorSpaceSequence( COL_RED
) ),
103 geometry::AffineMatrix2D
aUnit( 1,0, 0,
105 maViewState
.AffineTransform
= aUnit
;
106 maRenderState
.AffineTransform
= aUnit
;
107 maRenderState
.DeviceColor
= maColorBlack
;
109 //I can't figure out what the compositeoperation stuff does
110 //it doesn't seem to do anything in either VCL or cairocanvas
111 //I was hoping that CLEAR would clear the canvas before we paint,
112 //but nothing changes
113 maRenderState
.CompositeOperation
= rendering::CompositeOperation::OVER
;
115 maBox
.setWidth(aSize
.Width() / 3);
116 maBox
.setHeight(aSize
.Height() / 3);
118 lang::Locale aLocale
;
119 rendering::FontInfo aFontInfo
;
120 aFontInfo
.FamilyName
= "Swiss";
121 aFontInfo
.StyleName
= "SansSerif";
122 geometry::Matrix2D
aFontMatrix( 1, 0,
124 rendering::FontRequest
aFontRequest( aFontInfo
, 12.0, 0.0, aLocale
);
125 uno::Sequence
< beans::PropertyValue
> aExtraFontProperties
;
126 mxDefaultFont
= xCanvas
->createFont( aFontRequest
, aExtraFontProperties
, aFontMatrix
);
127 if( !mxDefaultFont
.is() )
128 fprintf( stderr
, "Failed to create font\n" );
133 double d
, dIncr
= maSize
.Width() / 3;
134 for ( d
= 0; d
<= maSize
.Width(); d
+= dIncr
)
135 mxCanvas
->drawLine( geometry::RealPoint2D( d
, 0 ),
136 geometry::RealPoint2D( d
, maSize
.Height() ),
137 maViewState
, maRenderState
);
138 dIncr
= maSize
.Height() / 3;
139 for ( d
= 0; d
<= maSize
.Height(); d
+= dIncr
)
140 mxCanvas
->drawLine( geometry::RealPoint2D( 0, d
),
141 geometry::RealPoint2D( maSize
.Width(), d
),
142 maViewState
, maRenderState
);
145 void drawStringAt( OString aString
, double x
, double y
)
147 rendering::StringContext aText
;
148 aText
.Text
= OStringToOUString( aString
, RTL_TEXTENCODING_UTF8
);
149 aText
.StartPosition
= 0;
150 aText
.Length
= aString
.getLength();
151 rendering::RenderState
aRenderState( maRenderState
);
152 aRenderState
.AffineTransform
.m02
+= x
;
153 aRenderState
.AffineTransform
.m12
+= y
;
155 mxCanvas
->drawText( aText
, mxDefaultFont
, maViewState
, aRenderState
, 0);
158 void drawRect( tools::Rectangle rRect
, const uno::Sequence
< double > &aColor
, int /*nWidth*/ )
160 uno::Sequence
< geometry::RealPoint2D
> aPoints(4);
161 uno::Reference
< rendering::XLinePolyPolygon2D
> xPoly
;
163 aPoints
[0] = geometry::RealPoint2D( rRect
.Left(), rRect
.Top() );
164 aPoints
[1] = geometry::RealPoint2D( rRect
.Left(), rRect
.Bottom() );
165 aPoints
[2] = geometry::RealPoint2D( rRect
.Right(), rRect
.Bottom() );
166 aPoints
[3] = geometry::RealPoint2D( rRect
.Right(), rRect
.Top() );
168 uno::Sequence
< uno::Sequence
< geometry::RealPoint2D
> > aPolys(1);
170 xPoly
= mxDevice
->createCompatibleLinePolyPolygon( aPolys
);
171 xPoly
->setClosed( 0, true );
172 uno::Reference
< rendering::XPolyPolygon2D
> xPP( xPoly
, uno::UNO_QUERY
);
174 rendering::RenderState
aRenderState( maRenderState
);
175 aRenderState
.DeviceColor
= aColor
;
176 mxCanvas
->drawPolyPolygon( xPP
, maViewState
, aRenderState
);
179 void translate( double x
, double y
)
181 maRenderState
.AffineTransform
.m02
+= x
;
182 maRenderState
.AffineTransform
.m12
+= y
;
185 void drawPolishDiamond( double center_x
, double center_y
)
187 const int VERTICES
= 10;
188 const double RADIUS
= 60.0;
191 rendering::RenderState maOldRenderState
= maRenderState
; // push
192 translate( center_x
, center_y
);
194 for (i
= 0; i
< VERTICES
; i
++)
196 double a
= 2.0 * M_PI
* i
/ VERTICES
;
197 geometry::RealPoint2D
aSrc( RADIUS
* cos (a
), RADIUS
* sin (a
) );
199 for (j
= i
+ 1; j
< VERTICES
; j
++)
201 a
= 2.0 * M_PI
* j
/ VERTICES
;
203 // FIXME: set cap_style to 'ROUND'
204 mxCanvas
->drawLine( aSrc
,
205 geometry::RealPoint2D( RADIUS
* cos (a
),
207 maViewState
, maRenderState
);
211 maRenderState
= maOldRenderState
; // pop
214 void drawHilbert( double anchor_x
, double anchor_y
)
216 const double SCALE
=7.0;
217 const char hilbert
[] = "urdrrulurulldluuruluurdrurddldrrruluurdrurddldrddlulldrdldrrurd";
218 int nLength
= SAL_N_ELEMENTS( hilbert
);
220 uno::Sequence
< geometry::RealPoint2D
> aPoints( nLength
);
221 uno::Reference
< rendering::XLinePolyPolygon2D
> xPoly
;
223 aPoints
[0] = geometry::RealPoint2D( anchor_x
, anchor_y
);
224 for (int i
= 0; i
< nLength
; i
++ )
229 aPoints
[i
+1] = geometry::RealPoint2D( aPoints
[i
].X
,
230 aPoints
[i
].Y
- SCALE
);
233 aPoints
[i
+1] = geometry::RealPoint2D( aPoints
[i
].X
,
234 aPoints
[i
].Y
+ SCALE
);
237 aPoints
[i
+1] = geometry::RealPoint2D( aPoints
[i
].X
- SCALE
,
241 aPoints
[i
+1] = geometry::RealPoint2D( aPoints
[i
].X
+ SCALE
,
247 uno::Sequence
< uno::Sequence
< geometry::RealPoint2D
> > aPolys(1);
250 xPoly
= mxDevice
->createCompatibleLinePolyPolygon( aPolys
);
251 xPoly
->setClosed( 0, false );
252 uno::Reference
< rendering::XPolyPolygon2D
> xPP( xPoly
, uno::UNO_QUERY
);
254 rendering::RenderState
aRenderState( maRenderState
);
255 aRenderState
.DeviceColor
= maColorRed
;
256 // aRenderState.DeviceColor[3] = 0.5;
257 rendering::StrokeAttributes aStrokeAttrs
;
258 aStrokeAttrs
.StrokeWidth
= 4.0;
259 aStrokeAttrs
.MiterLimit
= 2.0; // ?
260 aStrokeAttrs
.StartCapType
= rendering::PathCapType::BUTT
;
261 aStrokeAttrs
.EndCapType
= rendering::PathCapType::BUTT
;
262 aStrokeAttrs
.JoinType
= rendering::PathJoinType::MITER
;
263 //fprintf( stderr, "FIXME: stroking a tools::PolyPolygon doesn't show up\n" );
265 mxCanvas
->strokePolyPolygon( xPP
, maViewState
, aRenderState
, aStrokeAttrs
);
266 // FIXME: do this instead:
267 //mxCanvas->drawPolyPolygon( xPP, maViewState, aRenderState );
270 void drawTitle( OString aTitle
)
272 // FIXME: text anchoring to be done
273 double nStringWidth
= aTitle
.getLength() * 8.0;
274 drawStringAt ( aTitle
, (maBox
.Width() - nStringWidth
) / 2, 15 );
277 void drawRectangles()
279 rendering::RenderState maOldRenderState
= maRenderState
; // push
281 drawTitle( OString( "Rectangles" ) );
283 drawRect( tools::Rectangle( 20, 30, 70, 60 ), maColorRed
, 8 );
284 // color mediumseagreen, stipple fill, outline black
285 drawRect( tools::Rectangle( 90, 40, 180, 100 ), maColorBlack
, 4 );
286 // color steelblue, filled, no outline
287 drawRect( tools::Rectangle( 10, 80, 80, 140 ), maColorBlack
, 1 );
289 maRenderState
= maOldRenderState
; // pop
294 rendering::RenderState maOldRenderState
= maRenderState
; // push
295 translate( maBox
.Width(), 0.0 );
297 drawTitle( OString( "Ellipses" ) );
299 const basegfx::B2DPoint
aCenter( maBox
.Width()*.5,
301 const basegfx::B2DPoint
aRadii( maBox
.Width()*.3,
303 const basegfx::B2DPolygon
& rEllipse(
304 basegfx::utils::createPolygonFromEllipse( aCenter
,
308 uno::Reference
< rendering::XPolyPolygon2D
> xPoly(
309 basegfx::unotools::xPolyPolygonFromB2DPolygon(mxDevice
,
312 rendering::StrokeAttributes aStrokeAttrs
;
313 aStrokeAttrs
.StrokeWidth
= 4.0;
314 aStrokeAttrs
.MiterLimit
= 2.0; // ?
315 aStrokeAttrs
.StartCapType
= rendering::PathCapType::BUTT
;
316 aStrokeAttrs
.EndCapType
= rendering::PathCapType::BUTT
;
317 aStrokeAttrs
.JoinType
= rendering::PathJoinType::MITER
;
318 mxCanvas
->strokePolyPolygon( xPoly
, maViewState
, maRenderState
, aStrokeAttrs
);
320 maRenderState
= maOldRenderState
; // pop
325 rendering::RenderState maOldRenderState
= maRenderState
; // push
326 translate( maBox
.Width() * 2.0, 0.0 );
328 drawTitle( OString( "Text" ) );
331 maBox
.Height() * .5 );
332 drawTitle( OString( "This is lame" ) );
334 maRenderState
= maOldRenderState
; // pop
339 rendering::RenderState maOldRenderState
= maRenderState
; // push
340 translate( 0.0, maBox
.Height() );
342 drawTitle( OString( "Images" ) );
344 uno::Reference
< rendering::XBitmap
> xBitmap(mxCanvas
, uno::UNO_QUERY
);
349 translate( maBox
.Width()*0.1, maBox
.Height()*0.2 );
350 maRenderState
.AffineTransform
.m00
*= 4.0/15;
351 maRenderState
.AffineTransform
.m11
*= 3.0/15;
353 mxCanvas
->drawBitmap(xBitmap
, maViewState
, maRenderState
);
355 // uno::Reference< rendering::XBitmap > xBitmap2( xBitmap->getScaledBitmap(geometry::RealSize2D(48, 48), false) );
356 // mxCanvas->drawBitmap(xBitmap2, maViewState, maRenderState); //yes, but where?
358 //called CanvasHelper::getScaledBitmap, we return NULL, TODO
359 //Exception 'BitmapEx vclcanvas::tools::bitmapExFromXBitmap(const css::uno::Reference<css::rendering::XBitmap>&),
360 //bitmapExFromXBitmap(): could not extract BitmapEx' thrown
363 //Exception 'BitmapEx vclcanvas::tools::bitmapExFromXBitmap(const css::uno::Reference<css::rendering::XBitmap>&),
364 //bitmapExFromXBitmap(): could not extract bitmap' thrown
365 // Thorsten says that this is a bug, and Thorsten never lies.
367 maRenderState
= maOldRenderState
; // pop
372 rendering::RenderState maOldRenderState
= maRenderState
; // push
373 translate( maBox
.Width(), maBox
.Height() );
375 drawTitle( OString( "Lines" ) );
377 drawPolishDiamond( 70.0, 80.0 );
378 drawHilbert( 140.0, 140.0 );
380 maRenderState
= maOldRenderState
; // pop
385 rendering::RenderState maOldRenderState
= maRenderState
; // push
386 translate( maBox
.Width() * 2.0, maBox
.Height() );
388 drawTitle( OString( "Curves" ) );
390 translate( maBox
.Width() * .5, maBox
.Height() * .5 );
392 const double r
= 30.0;
393 const int num_curves
= 3;
396 uno::Sequence
< geometry::RealBezierSegment2D
> aBeziers (num_curves
);
397 uno::Reference
< rendering::XBezierPolyPolygon2D
> xPoly
;
399 for (int i
= 0; i
< num_curves
; i
++)
400 aBeziers
[i
]= geometry::RealBezierSegment2D( r
* cos(i
*2*M_PI
/num_curves
), //Px
401 r
* sin(i
*2*M_PI
/num_curves
), //py
402 r
* 2 * cos((i
*2*M_PI
+ 2*M_PI
)/num_curves
), //C1x
403 r
* 2 * sin((i
*2*M_PI
+ 2*M_PI
)/num_curves
), //C1y
404 r
* 2 * cos((i
*2*M_PI
+ 2*M_PI
)/num_curves
), //C2x
405 r
* 2 * sin((i
*2*M_PI
+ 2*M_PI
)/num_curves
)); //C2y
406 uno::Sequence
< uno::Sequence
< geometry::RealBezierSegment2D
> > aPolys(1);
407 aPolys
[0] = aBeziers
;
408 xPoly
= mxDevice
->createCompatibleBezierPolyPolygon(aPolys
);
409 xPoly
->setClosed( 0, true );
410 //uno::Reference< rendering::XBezierPolyPolygon2D> xPP( xPoly, uno::UNO_QUERY );
411 //compiles, but totally screws up. I think it is interpreting the bezier as a line
412 uno::Reference
< rendering::XPolyPolygon2D
> xPP( xPoly
, uno::UNO_QUERY
);
414 rendering::StrokeAttributes aStrokeAttrs
;
415 aStrokeAttrs
.StrokeWidth
= 4.0;
416 aStrokeAttrs
.MiterLimit
= 2.0; // ?
417 aStrokeAttrs
.StartCapType
= rendering::PathCapType::BUTT
;
418 aStrokeAttrs
.EndCapType
= rendering::PathCapType::BUTT
;
419 aStrokeAttrs
.JoinType
= rendering::PathJoinType::MITER
;
420 mxCanvas
->strokePolyPolygon( xPP
, maViewState
, maRenderState
, aStrokeAttrs
);
421 //you can't draw a BezierPolyPolygon2D with this, even though it is derived from it
422 //mxCanvas->drawPolyPolygon( xPP, maViewState, maRenderState );
424 maRenderState
= maOldRenderState
; // pop
429 return static_cast<double>(rand()) / RAND_MAX
* 100 + 50;
434 rendering::RenderState maOldRenderState
= maRenderState
; // push
435 translate( 0.0, maBox
.Height() * 2.0 );
437 drawTitle( OString( "Arcs" ) );
441 //This stuff doesn't belong here, but probably in curves
442 //This stuff doesn't work in VCL b/c vcl doesn't do beziers
443 //Hah! Every time the window redraws, we do this
449 for (int i
= 0; i
< 1; i
++)
459 double c1x
= gimmerand();
460 double c1y
= gimmerand();
461 double c2x
= gimmerand();
462 double c2y
= gimmerand();
463 maRenderState
.DeviceColor
= maColorRed
;
464 mxCanvas
->drawLine(geometry::RealPoint2D(ax
, ay
), geometry::RealPoint2D(c1x
, c1y
), maViewState
, maRenderState
);
465 mxCanvas
->drawLine(geometry::RealPoint2D(c1x
, c1y
), geometry::RealPoint2D(c2x
, c2y
), maViewState
, maRenderState
);
466 mxCanvas
->drawLine(geometry::RealPoint2D(bx
, by
), geometry::RealPoint2D(c2x
, c2y
), maViewState
, maRenderState
);
468 geometry::RealBezierSegment2D
aBezierSegment(
476 geometry::RealPoint2D
aEndPoint(bx
, by
);
477 maRenderState
.DeviceColor
= maColorBlack
;
478 mxCanvas
->drawBezier(
481 maViewState
, maRenderState
);
483 maRenderState
= maOldRenderState
; // pop
487 void drawRegularPolygon(double centerx
, double centery
, int sides
, double r
)
490 uno::Sequence
< geometry::RealPoint2D
> aPoints (sides
);
491 uno::Reference
< rendering::XLinePolyPolygon2D
> xPoly
;
493 for (int i
= 0; i
< sides
; i
++)
495 aPoints
[i
]= geometry::RealPoint2D( centerx
+ r
* cos(i
*2 * M_PI
/sides
),
496 centery
+ r
* sin(i
*2 * M_PI
/sides
));
498 uno::Sequence
< uno::Sequence
< geometry::RealPoint2D
> > aPolys(1);
500 xPoly
= mxDevice
->createCompatibleLinePolyPolygon( aPolys
);
501 xPoly
->setClosed( 0, true );
502 rendering::RenderState
aRenderState( maRenderState
);
503 aRenderState
.DeviceColor
= maColorRed
;
504 uno::Reference
< rendering::XPolyPolygon2D
> xPP( xPoly
, uno::UNO_QUERY
);
505 mxCanvas
->drawPolyPolygon( xPP
, maViewState
, aRenderState
);
506 mxCanvas
->fillPolyPolygon( xPP
,
513 rendering::RenderState maOldRenderState
= maRenderState
; // push
514 translate( maBox
.Width() * 1.0, maBox
.Height() * 2.0 );
516 drawTitle( OString( "Polgyons" ) );
519 for (int i
= 1; i
<= 4; i
++)
521 drawRegularPolygon(35*i
, 35, sides
, 15);
525 maRenderState
= maOldRenderState
; // pop
528 void drawWidgets() // FIXME: prolly makes no sense
530 rendering::RenderState maOldRenderState
= maRenderState
; // push
531 translate( maBox
.Width() * 2.0, maBox
.Height() * 2.0 );
533 drawTitle( OString( "Widgets" ) );
535 maRenderState
= maOldRenderState
; // pop
540 void TestWindow::Paint(vcl::RenderContext
&, const tools::Rectangle
&)
544 uno::Reference
< rendering::XCanvas
> xVDevCanvas( GetCanvas(),
545 uno::UNO_SET_THROW
);
546 uno::Reference
< rendering::XGraphicDevice
> xVDevDevice( xVDevCanvas
->getDevice(),
547 uno::UNO_SET_THROW
);
548 DemoRenderer
aVDevRenderer( xVDevDevice
, xVDevCanvas
, GetSizePixel());
549 xVDevCanvas
->clear();
550 aVDevRenderer
.drawGrid();
551 aVDevRenderer
.drawRectangles();
552 aVDevRenderer
.drawEllipses();
553 aVDevRenderer
.drawText();
554 aVDevRenderer
.drawLines();
555 aVDevRenderer
.drawCurves();
556 aVDevRenderer
.drawArcs();
557 aVDevRenderer
.drawPolygons();
559 uno::Reference
< rendering::XCanvas
> xCanvas( GetSpriteCanvas(),
560 uno::UNO_QUERY_THROW
);
561 uno::Reference
< rendering::XGraphicDevice
> xDevice( xCanvas
->getDevice(),
562 uno::UNO_SET_THROW
);
564 DemoRenderer
aRenderer( xDevice
, xCanvas
, GetSizePixel() );
566 aRenderer
.drawGrid();
567 aRenderer
.drawRectangles();
568 aRenderer
.drawEllipses();
569 aRenderer
.drawText();
570 aRenderer
.drawLines();
571 aRenderer
.drawCurves();
572 aRenderer
.drawArcs();
573 aRenderer
.drawPolygons();
574 aRenderer
.drawWidgets();
575 aRenderer
.drawImages();
577 // check whether virdev actually contained something
578 uno::Reference
< rendering::XBitmap
> xBitmap(xVDevCanvas
, uno::UNO_QUERY
);
582 aRenderer
.maRenderState
.AffineTransform
.m02
+= 100;
583 aRenderer
.maRenderState
.AffineTransform
.m12
+= 100;
584 xCanvas
->drawBitmap(xBitmap
, aRenderer
.maViewState
, aRenderer
.maRenderState
);
586 uno::Reference
< rendering::XSpriteCanvas
> xSpriteCanvas( xCanvas
,
588 if( xSpriteCanvas
.is() )
589 xSpriteCanvas
->updateScreen( true ); // without
594 catch (const uno::Exception
&e
)
596 fprintf( stderr
, "Exception '%s' thrown\n" ,
597 OUStringToOString( e
.Message
, RTL_TEXTENCODING_UTF8
).getStr() );
601 class DemoApp
: public Application
604 virtual int Main() override
;
605 virtual void Exception(ExceptionCategory nCategory
) override
;
608 void Init() override
;
609 void DeInit() override
;
616 for( unsigned int i
= 0; i
< GetCommandLineParamCount(); i
++ )
618 OUString aParam
= GetCommandLineParam( i
);
620 if( aParam
== "--help" || aParam
== "-h" )
630 // Create UCB (for backwards compatibility, in case some code still uses
631 // plain createInstance w/o args directly to obtain an instance):
632 ::ucb::UniversalContentBroker::create(
633 comphelper::getProcessComponentContext() );
635 ScopedVclPtr
<TestWindow
> aWindow
= VclPtr
<TestWindow
>::Create();
638 Application::Execute();
642 void DemoApp::Exception( ExceptionCategory nCategory
)
646 case ExceptionCategory::ResourceNotLoaded
:
647 Abort( "Error: could not load language resources.\nPlease check your installation.\n" );
658 uno::Reference
<uno::XComponentContext
> xComponentContext
659 = ::cppu::defaultBootstrap_InitialComponentContext();
660 uno::Reference
<lang::XMultiServiceFactory
> xMSF
;
661 xMSF
.set(xComponentContext
->getServiceManager(), uno::UNO_QUERY
);
663 Application::Abort("Bootstrap failure - no service manager");
665 ::comphelper::setProcessServiceFactory(xMSF
);
667 catch (const uno::Exception
&e
)
669 Application::Abort("Bootstrap exception " + e
.Message
);
673 void DemoApp::DeInit()
675 uno::Reference
< lang::XComponent
>(
676 comphelper::getProcessComponentContext(),
677 uno::UNO_QUERY_THROW
)-> dispose();
678 ::comphelper::setProcessServiceFactory(nullptr);
681 void vclmain::createApplication()
687 // - bouncing clip-rectangle mode - bounce a clip-rect around the window...
688 // - complete all of pre-existing canvas bits
689 // - affine transform tweakage...
691 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */