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/.
10 #include <test/bootstrapfixture.hxx>
12 #include <osl/file.hxx>
13 #include <osl/process.h>
14 #include <vcl/svapp.hxx>
15 #include <vcl/wrkwin.hxx>
16 #include <vcl/canvastools.hxx>
18 #include <comphelper/processfactory.hxx>
19 #include <com/sun/star/lang/XInitialization.hpp>
20 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
22 #include <com/sun/star/rendering/XBitmap.hpp>
23 #include <com/sun/star/rendering/XCanvas.hpp>
24 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
26 using namespace ::com::sun::star
;
28 class CanvasTest
: public test::BootstrapFixture
31 CanvasTest() : BootstrapFixture(true, false) {}
35 CPPUNIT_TEST_SUITE(CanvasTest
);
36 CPPUNIT_TEST(testComposite
);
37 CPPUNIT_TEST_SUITE_END();
40 void CanvasTest::testComposite()
43 Window
* pWin
= new WorkWindow( (Window
*)NULL
);
44 CPPUNIT_ASSERT( pWin
!= NULL
);
46 uno::Reference
<rendering::XCanvas
> xCanvas
= pWin
->GetCanvas ();
48 return; // can't get a canvas working at all - truly headless ?
52 uno::Reference
<rendering::XBitmap
> xBitmap
;
53 xBitmap
= xCanvas
->getDevice ()->createCompatibleAlphaBitmap(
54 vcl::unotools::integerSize2DFromSize( aSize
) );
55 CPPUNIT_ASSERT( xBitmap
.is() );
57 uno::Reference
< rendering::XBitmapCanvas
> xBitmapCanvas( xBitmap
, uno::UNO_QUERY
);
58 CPPUNIT_ASSERT( xBitmapCanvas
.is() );
62 // clear the canvas and basic sanity check ...
63 xBitmapCanvas
->clear();
64 CPPUNIT_ASSERT( aBitmapEx
.Create( xBitmapCanvas
, aSize
) );
65 CPPUNIT_ASSERT( aBitmapEx
.IsAlpha() );
66 CPPUNIT_ASSERT( aBitmapEx
.GetAlpha() );
71 rendering::RenderState aDefaultState
;
72 uno::Sequence
< double > aRedTransparent( 4 );
73 aRedTransparent
[0] = 1.0; // R
74 aRedTransparent
[1] = 0.0; // G
75 aRedTransparent
[2] = 0.0; // B
76 aRedTransparent
[3] = 0.5; // A
77 aDefaultState
.DeviceColor
= aRedTransparent
;
79 // words fail me to describe the sheer beauty of allocating an UNO
80 // object to represent a polygon, and manually handling the ViewState
81 // and there being no public helper for this - to render ... a rectangle.
82 XCachedPrimitive
fillPolyPolygon( [in
] XPolyPolygon2D xPolyPolygon
, [in
] ViewState aViewState
, [in
] RenderState aRenderState
)
89 CPPUNIT_TEST_SUITE_REGISTRATION(CanvasTest
);
91 CPPUNIT_PLUGIN_IMPLEMENT();
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */