1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <rtl/instance.hxx>
30 #include <osl/getglobalmutex.hxx>
31 #include <osl/diagnose.h>
32 #include <com/sun/star/rendering/InterpolationMode.hpp>
33 #include <vcl/window.hxx>
34 #include <vcl/graph.hxx>
35 #include <vcl/canvastools.hxx>
36 #include <basegfx/polygon/b2dpolypolygon.hxx>
38 #include <cppcanvas/vclfactory.hxx>
40 #include <implbitmapcanvas.hxx>
41 #include <implspritecanvas.hxx>
42 #include <implpolypolygon.hxx>
43 #include <implbitmap.hxx>
44 #include <implrenderer.hxx>
45 #include <implsprite.hxx>
47 using namespace ::com::sun::star
;
51 /* Singleton handling */
54 VCLFactory
* operator()()
56 return new VCLFactory();
60 VCLFactory
& VCLFactory::getInstance()
62 return *rtl_Instance
< VCLFactory
, InitInstance
, ::osl::MutexGuard
,
63 ::osl::GetGlobalMutex
>::create(
64 InitInstance(), ::osl::GetGlobalMutex());
67 VCLFactory::VCLFactory()
71 BitmapCanvasSharedPtr
VCLFactory::createCanvas( const uno::Reference
< rendering::XBitmapCanvas
>& xCanvas
)
73 return BitmapCanvasSharedPtr(
74 new internal::ImplBitmapCanvas( xCanvas
) );
77 SpriteCanvasSharedPtr
VCLFactory::createSpriteCanvas( const ::Window
& rVCLWindow
) const
79 return SpriteCanvasSharedPtr(
80 new internal::ImplSpriteCanvas(
81 uno::Reference
< rendering::XSpriteCanvas
>(
82 rVCLWindow
.GetSpriteCanvas(),
86 SpriteCanvasSharedPtr
VCLFactory::createSpriteCanvas( const uno::Reference
< rendering::XSpriteCanvas
>& xCanvas
) const
88 return SpriteCanvasSharedPtr(
89 new internal::ImplSpriteCanvas( xCanvas
) );
92 BitmapSharedPtr
VCLFactory::createBitmap( const CanvasSharedPtr
& rCanvas
,
93 const ::BitmapEx
& rBmpEx
) const
95 OSL_ENSURE( rCanvas
.get() != NULL
&&
96 rCanvas
->getUNOCanvas().is(),
97 "VCLFactory::createBitmap(): Invalid canvas" );
99 if( rCanvas
.get() == NULL
)
100 return BitmapSharedPtr();
102 uno::Reference
< rendering::XCanvas
> xCanvas( rCanvas
->getUNOCanvas() );
104 return BitmapSharedPtr();
106 return BitmapSharedPtr( new internal::ImplBitmap( rCanvas
,
107 ::vcl::unotools::xBitmapFromBitmapEx(
108 xCanvas
->getDevice(),
112 RendererSharedPtr
VCLFactory::createRenderer( const CanvasSharedPtr
& rCanvas
,
113 const ::GDIMetaFile
& rMtf
,
114 const Renderer::Parameters
& rParms
) const
116 return RendererSharedPtr( new internal::ImplRenderer( rCanvas
,
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */