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 .
21 // This code strongly inspired by Miguel / Federico's Gnome Canvas demo code.
23 #include <comphelper/processfactory.hxx>
24 #include <cppuhelper/servicefactory.hxx>
25 #include <cppuhelper/bootstrap.hxx>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <com/sun/star/lang/XInitialization.hpp>
28 #include <com/sun/star/registry/XSimpleRegistry.hpp>
29 #include <com/sun/star/ucb/UniversalContentBroker.hpp>
31 #include <basegfx/polygon/b2dpolygon.hxx>
32 #include <basegfx/polygon/b2dpolygontools.hxx>
33 #include <basegfx/tools/canvastools.hxx>
35 #include <vcl/window.hxx>
36 #include <vcl/virdev.hxx>
37 #include <vcl/svapp.hxx>
38 #include <vcl/msgbox.hxx>
39 #include <vcl/unowrap.hxx>
40 #include <vcl/canvastools.hxx>
42 #include <rtl/bootstrap.hxx>
43 #include <sal/macros.h>
45 #include <com/sun/star/rendering/XCanvas.hpp>
46 #include <com/sun/star/rendering/FillRule.hpp>
47 #include <com/sun/star/rendering/ViewState.hpp>
48 #include <com/sun/star/rendering/RenderState.hpp>
49 #include <com/sun/star/rendering/PathCapType.hpp>
50 #include <com/sun/star/rendering/PathJoinType.hpp>
51 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
52 #include <com/sun/star/rendering/XGraphicDevice.hpp>
53 #include <com/sun/star/rendering/CompositeOperation.hpp>
54 #include <com/sun/star/rendering/XBitmap.hpp>
59 // never import whole leaf namespaces, since this will result in
60 // absolutely weird effects during (Koenig) name lookup
61 using namespace ::com::sun::star
;
64 class DemoApp
: public Application
68 virtual USHORT
Exception( USHORT nError
);
71 static void PrintHelp()
73 fprintf( stdout
, "canvasdemo - Exercise the new canvas impl\n" );
76 class TestWindow
: public Dialog
79 TestWindow() : Dialog( (Window
*) NULL
)
81 SetText( OUString( "Canvas test" ) );
82 SetSizePixel( Size( 600, 450 ) );
86 virtual ~TestWindow() {}
87 virtual void MouseButtonUp( const MouseEvent
& /*rMEvt*/ )
89 //TODO: do something cool
92 virtual void Paint( const Rectangle
& rRect
);
100 rendering::ViewState maViewState
;
101 rendering::RenderState maRenderState
;
102 uno::Sequence
< double > maColorBlack
;
103 uno::Sequence
< double > maColorWhite
;
104 uno::Sequence
< double > maColorRed
;
105 uno::Reference
< rendering::XCanvas
> mxCanvas
;
106 uno::Reference
< rendering::XCanvasFont
> mxDefaultFont
;
107 uno::Reference
< rendering::XGraphicDevice
> mxDevice
;
109 DemoRenderer( uno::Reference
< rendering::XGraphicDevice
> xDevice
,
110 uno::Reference
< rendering::XCanvas
> xCanvas
,
116 maColorBlack( vcl::unotools::colorToStdColorSpaceSequence( Color(COL_BLACK
)) ),
117 maColorWhite( vcl::unotools::colorToStdColorSpaceSequence( Color(COL_WHITE
)) ),
118 maColorRed( vcl::unotools::colorToStdColorSpaceSequence( Color(COL_RED
)) ),
124 geometry::AffineMatrix2D
aUnit( 1,0, 0,
126 maViewState
.AffineTransform
= aUnit
;
127 maRenderState
.AffineTransform
= aUnit
;
128 maRenderState
.DeviceColor
= maColorBlack
;
130 //I can't figure out what the compsiteoperation stuff does
131 //it doesn't seem to do anything in either VCL or cairocanvas
132 //I was hoping that CLEAR would clear the canvas before we paint,
133 //but nothing changes
134 maRenderState
.CompositeOperation
= rendering::CompositeOperation::OVER
;
136 maBox
.Width() = aSize
.Width() / 3;
137 maBox
.Height() = aSize
.Height() / 3;
139 lang::Locale aLocale
;
140 rendering::FontInfo aFontInfo
;
141 aFontInfo
.FamilyName
= OUString( "Swiss" );
142 aFontInfo
.StyleName
= OUString( "SansSerif" );
143 geometry::Matrix2D
aFontMatrix( 1, 0,
145 rendering::FontRequest
aFontRequest( aFontInfo
, 12.0, 0.0, aLocale
);
146 uno::Sequence
< beans::PropertyValue
> aExtraFontProperties
;
147 mxDefaultFont
= xCanvas
->createFont( aFontRequest
, aExtraFontProperties
, aFontMatrix
);
148 if( !mxDefaultFont
.is() )
149 fprintf( stderr
, "Failed to create font\n" );
154 double d
, dIncr
= maSize
.Width() / 3;
155 for ( d
= 0; d
<= maSize
.Width(); d
+= dIncr
)
156 mxCanvas
->drawLine( geometry::RealPoint2D( d
, 0 ),
157 geometry::RealPoint2D( d
, maSize
.Height() ),
158 maViewState
, maRenderState
);
159 dIncr
= maSize
.Height() / 3;
160 for ( d
= 0; d
<= maSize
.Height(); d
+= dIncr
)
161 mxCanvas
->drawLine( geometry::RealPoint2D( 0, d
),
162 geometry::RealPoint2D( maSize
.Width(), d
),
163 maViewState
, maRenderState
);
166 void drawStringAt( OString aString
, double x
, double y
)
168 rendering::StringContext aText
;
169 aText
.Text
= OStringToOUString( aString
, RTL_TEXTENCODING_UTF8
);
170 aText
.StartPosition
= 0;
171 aText
.Length
= aString
.getLength();
172 rendering::RenderState
aRenderState( maRenderState
);
173 aRenderState
.AffineTransform
.m02
+= x
;
174 aRenderState
.AffineTransform
.m12
+= y
;
176 mxCanvas
->drawText( aText
, mxDefaultFont
, maViewState
, aRenderState
, 0);
179 void drawRect( Rectangle rRect
, uno::Sequence
< double > &aColor
, int /*nWidth*/ )
181 uno::Sequence
< geometry::RealPoint2D
> aPoints(4);
182 uno::Reference
< rendering::XLinePolyPolygon2D
> xPoly
;
184 aPoints
[0] = geometry::RealPoint2D( rRect
.Left(), rRect
.Top() );
185 aPoints
[1] = geometry::RealPoint2D( rRect
.Left(), rRect
.Bottom() );
186 aPoints
[2] = geometry::RealPoint2D( rRect
.Right(), rRect
.Bottom() );
187 aPoints
[3] = geometry::RealPoint2D( rRect
.Right(), rRect
.Top() );
189 uno::Sequence
< uno::Sequence
< geometry::RealPoint2D
> > aPolys(1);
191 xPoly
= mxDevice
->createCompatibleLinePolyPolygon( aPolys
);
192 xPoly
->setClosed( 0, true );
193 uno::Reference
< rendering::XPolyPolygon2D
> xPP( xPoly
, uno::UNO_QUERY
);
195 rendering::RenderState
aRenderState( maRenderState
);
196 aRenderState
.DeviceColor
= aColor
;
197 mxCanvas
->drawPolyPolygon( xPP
, maViewState
, aRenderState
);
200 void translate( double x
, double y
)
202 maRenderState
.AffineTransform
.m02
+= x
;
203 maRenderState
.AffineTransform
.m12
+= y
;
206 void drawPolishDiamond( double center_x
, double center_y
)
208 const int VERTICES
= 10;
209 const double RADIUS
= 60.0;
213 rendering::RenderState maOldRenderState
= maRenderState
; // push
214 translate( center_x
, center_y
);
216 for (i
= 0; i
< VERTICES
; i
++)
218 a
= 2.0 * M_PI
* i
/ VERTICES
;
219 geometry::RealPoint2D
aSrc( RADIUS
* cos (a
), RADIUS
* sin (a
) );
221 for (j
= i
+ 1; j
< VERTICES
; j
++)
223 a
= 2.0 * M_PI
* j
/ VERTICES
;
225 // FIXME: set cap_style to 'ROUND'
226 mxCanvas
->drawLine( aSrc
,
227 geometry::RealPoint2D( RADIUS
* cos (a
),
229 maViewState
, maRenderState
);
233 maRenderState
= maOldRenderState
; // pop
236 void drawHilbert( double anchor_x
, double anchor_y
)
238 const double SCALE
=7.0;
239 const char hilbert
[] = "urdrrulurulldluuruluurdrurddldrrruluurdrurddldrddlulldrdldrrurd";
240 int nLength
= SAL_N_ELEMENTS( hilbert
);
242 uno::Sequence
< geometry::RealPoint2D
> aPoints( nLength
);
243 uno::Reference
< rendering::XLinePolyPolygon2D
> xPoly
;
245 aPoints
[0] = geometry::RealPoint2D( anchor_x
, anchor_y
);
246 for (int i
= 0; i
< nLength
; i
++ )
251 aPoints
[i
+1] = geometry::RealPoint2D( aPoints
[i
].X
,
252 aPoints
[i
].Y
- SCALE
);
255 aPoints
[i
+1] = geometry::RealPoint2D( aPoints
[i
].X
,
256 aPoints
[i
].Y
+ SCALE
);
259 aPoints
[i
+1] = geometry::RealPoint2D( aPoints
[i
].X
- SCALE
,
263 aPoints
[i
+1] = geometry::RealPoint2D( aPoints
[i
].X
+ SCALE
,
269 uno::Sequence
< uno::Sequence
< geometry::RealPoint2D
> > aPolys(1);
272 xPoly
= mxDevice
->createCompatibleLinePolyPolygon( aPolys
);
273 xPoly
->setClosed( 0, false );
274 uno::Reference
< rendering::XPolyPolygon2D
> xPP( xPoly
, uno::UNO_QUERY
);
276 rendering::RenderState
aRenderState( maRenderState
);
277 aRenderState
.DeviceColor
= maColorRed
;
278 // aRenderState.DeviceColor[3] = 0.5;
279 rendering::StrokeAttributes aStrokeAttrs
;
280 aStrokeAttrs
.StrokeWidth
= 4.0;
281 aStrokeAttrs
.MiterLimit
= 2.0; // ?
282 aStrokeAttrs
.StartCapType
= rendering::PathCapType::BUTT
;
283 aStrokeAttrs
.EndCapType
= rendering::PathCapType::BUTT
;
284 aStrokeAttrs
.JoinType
= rendering::PathJoinType::MITER
;
285 //fprintf( stderr, "FIXME: stroking a PolyPolygon doesn't show up\n" );
287 mxCanvas
->strokePolyPolygon( xPP
, maViewState
, aRenderState
, aStrokeAttrs
);
288 // FIXME: do this instead:
289 //mxCanvas->drawPolyPolygon( xPP, maViewState, aRenderState );
292 void drawTitle( OString aTitle
)
294 // FIXME: text anchoring to be done
295 double nStringWidth
= aTitle
.getLength() * 8.0;
296 drawStringAt ( aTitle
, (maBox
.Width() - nStringWidth
) / 2, 15 );
299 void drawRectangles()
301 rendering::RenderState maOldRenderState
= maRenderState
; // push
303 drawTitle( OString( "Rectangles" ) );
305 drawRect( Rectangle( 20, 30, 70, 60 ), maColorRed
, 8 );
306 // color mediumseagreen, stipple fill, outline black
307 drawRect( Rectangle( 90, 40, 180, 100 ), maColorBlack
, 4 );
308 // color steelblue, filled, no outline
309 drawRect( Rectangle( 10, 80, 80, 140 ), maColorBlack
, 1 );
311 maRenderState
= maOldRenderState
; // pop
316 rendering::RenderState maOldRenderState
= maRenderState
; // push
317 translate( maBox
.Width(), 0.0 );
319 drawTitle( OString( "Ellipses" ) );
321 const basegfx::B2DPoint
aCenter( maBox
.Width()*.5,
323 const basegfx::B2DPoint
aRadii( maBox
.Width()*.3,
325 const basegfx::B2DPolygon
& rEllipse(
326 basegfx::tools::createPolygonFromEllipse( aCenter
,
330 uno::Reference
< rendering::XPolyPolygon2D
> xPoly(
331 basegfx::unotools::xPolyPolygonFromB2DPolygon(mxDevice
,
334 rendering::StrokeAttributes aStrokeAttrs
;
335 aStrokeAttrs
.StrokeWidth
= 4.0;
336 aStrokeAttrs
.MiterLimit
= 2.0; // ?
337 aStrokeAttrs
.StartCapType
= rendering::PathCapType::BUTT
;
338 aStrokeAttrs
.EndCapType
= rendering::PathCapType::BUTT
;
339 aStrokeAttrs
.JoinType
= rendering::PathJoinType::MITER
;
340 mxCanvas
->strokePolyPolygon( xPoly
, maViewState
, maRenderState
, aStrokeAttrs
);
342 maRenderState
= maOldRenderState
; // pop
347 rendering::RenderState maOldRenderState
= maRenderState
; // push
348 translate( maBox
.Width() * 2.0, 0.0 );
350 drawTitle( OString( "Text" ) );
353 maBox
.Height() * .5 );
354 drawTitle( OString( "This is lame" ) );
356 maRenderState
= maOldRenderState
; // pop
361 rendering::RenderState maOldRenderState
= maRenderState
; // push
362 translate( 0.0, maBox
.Height() );
364 drawTitle( OString( "Images" ) );
366 uno::Reference
< rendering::XBitmap
> xBitmap(mxCanvas
, uno::UNO_QUERY
);
371 translate( maBox
.Width()*0.1, maBox
.Height()*0.2 );
372 maRenderState
.AffineTransform
.m00
*= 4.0/15;
373 maRenderState
.AffineTransform
.m11
*= 3.0/15;
375 mxCanvas
->drawBitmap(xBitmap
, maViewState
, maRenderState
);
377 // uno::Reference< rendering::XBitmap > xBitmap2( xBitmap->getScaledBitmap(geometry::RealSize2D(48, 48), false) );
378 // mxCanvas->drawBitmap(xBitmap2, maViewState, maRenderState); //yes, but where?
380 //called CanvasHelper::getScaledBitmap, we return NULL, TODO
381 //Exception 'BitmapEx vclcanvas::tools::bitmapExFromXBitmap(const com::sun::star::uno::Reference<com::sun::star::rendering::XBitmap>&),
382 //bitmapExFromXBitmap(): could not extract BitmapEx' thrown
385 //Exception 'BitmapEx vclcanvas::tools::bitmapExFromXBitmap(const com::sun::star::uno::Reference<com::sun::star::rendering::XBitmap>&),
386 //bitmapExFromXBitmap(): could not extract bitmap' thrown
387 // Thorsten says that this is a bug, and Thorsten never lies.
389 maRenderState
= maOldRenderState
; // pop
394 rendering::RenderState maOldRenderState
= maRenderState
; // push
395 translate( maBox
.Width(), maBox
.Height() );
397 drawTitle( OString( "Lines" ) );
399 drawPolishDiamond( 70.0, 80.0 );
400 drawHilbert( 140.0, 140.0 );
402 maRenderState
= maOldRenderState
; // pop
407 rendering::RenderState maOldRenderState
= maRenderState
; // push
408 translate( maBox
.Width() * 2.0, maBox
.Height() );
410 drawTitle( OString( "Curves" ) );
412 translate( maBox
.Width() * .5, maBox
.Height() * .5 );
414 const double r
= 30.0;
415 const int num_curves
= 3;
418 uno::Sequence
< geometry::RealBezierSegment2D
> aBeziers (num_curves
);
419 uno::Reference
< rendering::XBezierPolyPolygon2D
> xPoly
;
421 for (int i
= 0; i
< num_curves
; i
++)
422 aBeziers
[i
]= geometry::RealBezierSegment2D( r
* cos(i
*2*M_PI
/num_curves
), //Px
423 r
* sin(i
*2*M_PI
/num_curves
), //py
424 r
* 2 * cos((i
*2*M_PI
+ 2*M_PI
)/num_curves
), //C1x
425 r
* 2 * sin((i
*2*M_PI
+ 2*M_PI
)/num_curves
), //C1y
426 r
* 2 * cos((i
*2*M_PI
+ 2*M_PI
)/num_curves
), //C2x
427 r
* 2 * sin((i
*2*M_PI
+ 2*M_PI
)/num_curves
)); //C2y
428 uno::Sequence
< uno::Sequence
< geometry::RealBezierSegment2D
> > aPolys(1);
429 aPolys
[0] = aBeziers
;
430 xPoly
= mxDevice
->createCompatibleBezierPolyPolygon(aPolys
);
431 xPoly
->setClosed( 0, true );
432 //uno::Reference< rendering::XBezierPolyPolygon2D> xPP( xPoly, uno::UNO_QUERY );
433 //compiles, but totally screws up. I think it is interpretting the bezier as a line
434 uno::Reference
< rendering::XPolyPolygon2D
> xPP( xPoly
, uno::UNO_QUERY
);
436 rendering::StrokeAttributes aStrokeAttrs
;
437 aStrokeAttrs
.StrokeWidth
= 4.0;
438 aStrokeAttrs
.MiterLimit
= 2.0; // ?
439 aStrokeAttrs
.StartCapType
= rendering::PathCapType::BUTT
;
440 aStrokeAttrs
.EndCapType
= rendering::PathCapType::BUTT
;
441 aStrokeAttrs
.JoinType
= rendering::PathJoinType::MITER
;
442 mxCanvas
->strokePolyPolygon( xPP
, maViewState
, maRenderState
, aStrokeAttrs
);
443 //you can't draw a BezierPolyPolygon2D with this, even though it is derived from it
444 //mxCanvas->drawPolyPolygon( xPP, maViewState, maRenderState );
446 maRenderState
= maOldRenderState
; // pop
451 return (double)(rand()) / RAND_MAX
* 100 + 50;
456 rendering::RenderState maOldRenderState
= maRenderState
; // push
457 translate( 0.0, maBox
.Height() * 2.0 );
459 drawTitle( OString( "Arcs" ) );
463 //This stuff doesn't belong here, but probably in curves
464 //This stuff doesn't work in VCL b/c vcl doesn't do beziers
465 //Hah! Everytime the window redraws, we do this
473 for (int i
= 0; i
< 1; i
++)
481 double c1x
= gimmerand();
482 double c1y
= gimmerand();
483 double c2x
= gimmerand();
484 double c2y
= gimmerand();
485 maRenderState
.DeviceColor
= maColorRed
;
486 mxCanvas
->drawLine(geometry::RealPoint2D(ax
, ay
), geometry::RealPoint2D(c1x
, c1y
), maViewState
, maRenderState
);
487 mxCanvas
->drawLine(geometry::RealPoint2D(c1x
, c1y
), geometry::RealPoint2D(c2x
, c2y
), maViewState
, maRenderState
);
488 mxCanvas
->drawLine(geometry::RealPoint2D(bx
, by
), geometry::RealPoint2D(c2x
, c2y
), maViewState
, maRenderState
);
490 geometry::RealBezierSegment2D
aBezierSegment(
498 geometry::RealPoint2D
aEndPoint(bx
, by
);
499 maRenderState
.DeviceColor
= maColorBlack
;
500 mxCanvas
->drawBezier(
503 maViewState
, maRenderState
);
505 maRenderState
= maOldRenderState
; // pop
509 void drawRegularPolygon(double centerx
, double centery
, int sides
, double r
)
512 uno::Sequence
< geometry::RealPoint2D
> aPoints (sides
);
513 uno::Reference
< rendering::XLinePolyPolygon2D
> xPoly
;
515 for (int i
= 0; i
< sides
; i
++)
517 aPoints
[i
]= geometry::RealPoint2D( centerx
+ r
* cos(i
*2 * M_PI
/sides
),
518 centery
+ r
* sin(i
*2 * M_PI
/sides
));
520 uno::Sequence
< uno::Sequence
< geometry::RealPoint2D
> > aPolys(1);
522 xPoly
= mxDevice
->createCompatibleLinePolyPolygon( aPolys
);
523 xPoly
->setClosed( 0, true );
524 rendering::RenderState
aRenderState( maRenderState
);
525 aRenderState
.DeviceColor
= maColorRed
;
526 uno::Reference
< rendering::XPolyPolygon2D
> xPP( xPoly
, uno::UNO_QUERY
);
527 mxCanvas
->drawPolyPolygon( xPP
, maViewState
, aRenderState
);
528 mxCanvas
->fillPolyPolygon( xPP
,
535 rendering::RenderState maOldRenderState
= maRenderState
; // push
536 translate( maBox
.Width() * 1.0, maBox
.Height() * 2.0 );
538 drawTitle( OString( "Polgyons" ) );
541 for (int i
= 1; i
<= 4; i
++)
543 drawRegularPolygon(35*i
, 35, sides
, 15);
547 maRenderState
= maOldRenderState
; // pop
550 void drawWidgets() // FIXME: prolly makes no sense
552 rendering::RenderState maOldRenderState
= maRenderState
; // push
553 translate( maBox
.Width() * 2.0, maBox
.Height() * 2.0 );
555 drawTitle( OString( "Widgets" ) );
557 maRenderState
= maOldRenderState
; // pop
562 void TestWindow::Paint( const Rectangle
& /*rRect*/ )
566 const Size
aVDevSize(300,300);
567 VirtualDevice
aVDev(*this);
568 aVDev
.SetOutputSizePixel(aVDevSize
);
569 uno::Reference
< rendering::XCanvas
> xVDevCanvas( aVDev
.GetCanvas(),
570 uno::UNO_QUERY_THROW
);
571 uno::Reference
< rendering::XGraphicDevice
> xVDevDevice( xVDevCanvas
->getDevice(),
572 uno::UNO_QUERY_THROW
);
573 DemoRenderer
aVDevRenderer( xVDevDevice
, xVDevCanvas
, aVDevSize
);
574 xVDevCanvas
->clear();
575 aVDevRenderer
.drawGrid();
576 aVDevRenderer
.drawRectangles();
577 aVDevRenderer
.drawEllipses();
578 aVDevRenderer
.drawText();
579 aVDevRenderer
.drawLines();
580 aVDevRenderer
.drawCurves();
581 aVDevRenderer
.drawArcs();
582 aVDevRenderer
.drawPolygons();
584 uno::Reference
< rendering::XCanvas
> xCanvas( GetSpriteCanvas(),
585 uno::UNO_QUERY_THROW
);
586 uno::Reference
< rendering::XGraphicDevice
> xDevice( xCanvas
->getDevice(),
587 uno::UNO_QUERY_THROW
);
589 DemoRenderer
aRenderer( xDevice
, xCanvas
, GetSizePixel() );
591 aRenderer
.drawGrid();
592 aRenderer
.drawRectangles();
593 aRenderer
.drawEllipses();
594 aRenderer
.drawText();
595 aRenderer
.drawLines();
596 aRenderer
.drawCurves();
597 aRenderer
.drawArcs();
598 aRenderer
.drawPolygons();
599 aRenderer
.drawWidgets();
600 aRenderer
.drawImages();
602 // check whether virdev actually contained something
603 uno::Reference
< rendering::XBitmap
> xBitmap(xVDevCanvas
, uno::UNO_QUERY
);
607 aRenderer
.maRenderState
.AffineTransform
.m02
+= 100;
608 aRenderer
.maRenderState
.AffineTransform
.m12
+= 100;
609 xCanvas
->drawBitmap(xBitmap
, aRenderer
.maViewState
, aRenderer
.maRenderState
);
611 uno::Reference
< rendering::XSpriteCanvas
> xSpriteCanvas( xCanvas
,
613 if( xSpriteCanvas
.is() )
614 xSpriteCanvas
->updateScreen( sal_True
); // without
619 catch (const uno::Exception
&e
)
621 fprintf( stderr
, "Exception '%s' thrown\n" ,
622 OUStringToOString( e
.Message
, RTL_TEXTENCODING_UTF8
).getStr() );
626 USHORT
DemoApp::Exception( USHORT nError
)
628 switch( nError
& EXC_MAJORTYPE
)
630 case EXC_RSCNOTLOADED
:
631 Abort( "Error: could not load language resources.\nPlease check your installation.\n" );
641 for( USHORT i
= 0; i
< GetCommandLineParamCount(); i
++ )
643 OUString aParam
= GetCommandLineParam( i
);
645 if( aParam
== "--help" || aParam
== "-h" )
655 //-------------------------------------------------
656 // create the global service-manager
657 //-------------------------------------------------
658 uno::Reference
< lang::XMultiServiceFactory
> xFactory
;
661 uno::Reference
< uno::XComponentContext
> xCtx
= ::cppu::defaultBootstrap_InitialComponentContext();
662 xFactory
= uno::Reference
< lang::XMultiServiceFactory
>( xCtx
->getServiceManager(),
665 ::comphelper::setProcessServiceFactory( xFactory
);
667 catch( const uno::Exception
& )
673 fprintf( stderr
, "Could not bootstrap UNO, installation must be in disorder. Exiting.\n" );
677 // Create UCB (for backwards compatibility, in case some code still uses
678 // plain createInstance w/o args directly to obtain an instance):
679 ::ucb::UniversalContentBroker::create(
680 comphelper::getProcessComponentContext() );
691 // - bouncing clip-rectangle mode - bounce a clip-rect around the window ...
692 // - complete all of pre-existing canvas bits
693 // - affine transform tweakage ...
695 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */