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