Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
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.
15 : : *
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).
21 : : *
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.
26 : : *
27 : : ************************************************************************/
28 : :
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>
37 : :
38 : : #include <cppcanvas/vclfactory.hxx>
39 : :
40 : : #include <implbitmapcanvas.hxx>
41 : : #include <implspritecanvas.hxx>
42 : : #include <implpolypolygon.hxx>
43 : : #include <implbitmap.hxx>
44 : : #include <implrenderer.hxx>
45 : : #include <implsprite.hxx>
46 : :
47 : : using namespace ::com::sun::star;
48 : :
49 : : namespace cppcanvas
50 : : {
51 : : /* Singleton handling */
52 : : struct InitInstance
53 : : {
54 : 0 : VCLFactory* operator()()
55 : : {
56 [ # # ]: 0 : return new VCLFactory();
57 : : }
58 : : };
59 : :
60 : 0 : VCLFactory& VCLFactory::getInstance()
61 : : {
62 : : return *rtl_Instance< VCLFactory, InitInstance, ::osl::MutexGuard,
63 : : ::osl::GetGlobalMutex >::create(
64 [ # # ]: 0 : InitInstance(), ::osl::GetGlobalMutex());
65 : : }
66 : :
67 : 0 : VCLFactory::VCLFactory()
68 : : {
69 : 0 : }
70 : :
71 : 0 : BitmapCanvasSharedPtr VCLFactory::createCanvas( const uno::Reference< rendering::XBitmapCanvas >& xCanvas )
72 : : {
73 : : return BitmapCanvasSharedPtr(
74 [ # # ]: 0 : new internal::ImplBitmapCanvas( xCanvas ) );
75 : : }
76 : :
77 : 0 : SpriteCanvasSharedPtr VCLFactory::createSpriteCanvas( const ::Window& rVCLWindow ) const
78 : : {
79 : : return SpriteCanvasSharedPtr(
80 : : new internal::ImplSpriteCanvas(
81 : : uno::Reference< rendering::XSpriteCanvas >(
82 : : rVCLWindow.GetSpriteCanvas(),
83 [ # # ][ # # ]: 0 : uno::UNO_QUERY) ) );
[ # # ][ # # ]
84 : : }
85 : :
86 : 0 : SpriteCanvasSharedPtr VCLFactory::createSpriteCanvas( const uno::Reference< rendering::XSpriteCanvas >& xCanvas ) const
87 : : {
88 : : return SpriteCanvasSharedPtr(
89 [ # # ]: 0 : new internal::ImplSpriteCanvas( xCanvas ) );
90 : : }
91 : :
92 : 0 : BitmapSharedPtr VCLFactory::createBitmap( const CanvasSharedPtr& rCanvas,
93 : : const ::BitmapEx& rBmpEx ) const
94 : : {
95 : : OSL_ENSURE( rCanvas.get() != NULL &&
96 : : rCanvas->getUNOCanvas().is(),
97 : : "VCLFactory::createBitmap(): Invalid canvas" );
98 : :
99 [ # # ]: 0 : if( rCanvas.get() == NULL )
100 [ # # ]: 0 : return BitmapSharedPtr();
101 : :
102 [ # # ]: 0 : uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
103 [ # # ]: 0 : if( !xCanvas.is() )
104 [ # # ]: 0 : return BitmapSharedPtr();
105 : :
106 : : return BitmapSharedPtr( new internal::ImplBitmap( rCanvas,
107 : : ::vcl::unotools::xBitmapFromBitmapEx(
108 [ # # ]: 0 : xCanvas->getDevice(),
109 [ # # ][ # # ]: 0 : rBmpEx) ) );
[ # # ][ # # ]
[ # # ]
110 : : }
111 : :
112 : 0 : RendererSharedPtr VCLFactory::createRenderer( const CanvasSharedPtr& rCanvas,
113 : : const ::GDIMetaFile& rMtf,
114 : : const Renderer::Parameters& rParms ) const
115 : : {
116 : : return RendererSharedPtr( new internal::ImplRenderer( rCanvas,
117 : : rMtf,
118 [ # # ]: 0 : rParms ) );
119 : : }
120 : : }
121 : :
122 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|