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 <sal/config.h>
12 #include <test/bootstrapfixture.hxx>
14 #include <vcl/wrkwin.hxx>
15 #include <vcl/canvastools.hxx>
17 #include <com/sun/star/rendering/XBitmap.hpp>
18 #include <com/sun/star/rendering/XCanvas.hpp>
19 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
21 using namespace ::com::sun::star
;
23 class CanvasTest
: public test::BootstrapFixture
26 CanvasTest() : BootstrapFixture(true, false) {}
30 CPPUNIT_TEST_SUITE(CanvasTest
);
31 CPPUNIT_TEST(testComposite
);
32 CPPUNIT_TEST_SUITE_END();
35 void CanvasTest::testComposite()
38 ScopedVclPtrInstance
<WorkWindow
> pWin( nullptr, WB_STDWORK
);
40 uno::Reference
<rendering::XCanvas
> xCanvas
= pWin
->GetCanvas ();
42 return; // can't get a canvas working at all - truly headless ?
46 uno::Reference
<rendering::XBitmap
> xBitmap
= xCanvas
->getDevice ()->createCompatibleAlphaBitmap(
47 vcl::unotools::integerSize2DFromSize( aSize
) );
48 CPPUNIT_ASSERT( xBitmap
.is() );
50 uno::Reference
< rendering::XBitmapCanvas
> xBitmapCanvas( xBitmap
, uno::UNO_QUERY
);
51 CPPUNIT_ASSERT( xBitmapCanvas
.is() );
55 // clear the canvas and basic sanity check ...
56 xBitmapCanvas
->clear();
57 CPPUNIT_ASSERT( aBitmapEx
.Create( xBitmapCanvas
, aSize
) );
58 CPPUNIT_ASSERT( aBitmapEx
.IsAlpha() );
59 CPPUNIT_ASSERT( aBitmapEx
.GetAlpha() );
64 rendering::RenderState aDefaultState
;
65 uno::Sequence
< double > aRedTransparent( 4 );
66 aRedTransparent
[0] = 1.0; // R
67 aRedTransparent
[1] = 0.0; // G
68 aRedTransparent
[2] = 0.0; // B
69 aRedTransparent
[3] = 0.5; // A
70 aDefaultState
.DeviceColor
= aRedTransparent
;
72 // words fail me to describe the sheer beauty of allocating a UNO
73 // object to represent a polygon, and manually handling the ViewState
74 // and there being no public helper for this - to render ... a rectangle.
75 XCachedPrimitive
fillPolyPolygon( [in
] XPolyPolygon2D xPolyPolygon
, [in
] ViewState aViewState
, [in
] RenderState aRenderState
)
82 CPPUNIT_TEST_SUITE_REGISTRATION(CanvasTest
);
84 CPPUNIT_PLUGIN_IMPLEMENT();
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */