Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <rtl/instance.hxx>
21 : #include <osl/getglobalmutex.hxx>
22 : #include <osl/diagnose.h>
23 : #include <com/sun/star/rendering/InterpolationMode.hpp>
24 : #include <vcl/window.hxx>
25 : #include <vcl/graph.hxx>
26 : #include <vcl/canvastools.hxx>
27 : #include <basegfx/polygon/b2dpolypolygon.hxx>
28 :
29 : #include <cppcanvas/vclfactory.hxx>
30 :
31 : #include <implbitmapcanvas.hxx>
32 : #include <implspritecanvas.hxx>
33 : #include <implpolypolygon.hxx>
34 : #include <implbitmap.hxx>
35 : #include <implrenderer.hxx>
36 : #include <implsprite.hxx>
37 :
38 : using namespace ::com::sun::star;
39 :
40 : namespace cppcanvas
41 : {
42 : /* Singleton handling */
43 : struct InitInstance
44 : {
45 0 : VCLFactory* operator()()
46 : {
47 0 : return new VCLFactory();
48 : }
49 : };
50 :
51 0 : VCLFactory& VCLFactory::getInstance()
52 : {
53 : return *rtl_Instance< VCLFactory, InitInstance, ::osl::MutexGuard,
54 : ::osl::GetGlobalMutex >::create(
55 0 : InitInstance(), ::osl::GetGlobalMutex());
56 : }
57 :
58 0 : VCLFactory::VCLFactory()
59 : {
60 0 : }
61 :
62 0 : BitmapCanvasSharedPtr VCLFactory::createCanvas( const uno::Reference< rendering::XBitmapCanvas >& xCanvas )
63 : {
64 : return BitmapCanvasSharedPtr(
65 0 : new internal::ImplBitmapCanvas( xCanvas ) );
66 : }
67 :
68 0 : SpriteCanvasSharedPtr VCLFactory::createSpriteCanvas( const ::Window& rVCLWindow ) const
69 : {
70 : return SpriteCanvasSharedPtr(
71 : new internal::ImplSpriteCanvas(
72 : uno::Reference< rendering::XSpriteCanvas >(
73 : rVCLWindow.GetSpriteCanvas(),
74 0 : uno::UNO_QUERY) ) );
75 : }
76 :
77 0 : SpriteCanvasSharedPtr VCLFactory::createSpriteCanvas( const uno::Reference< rendering::XSpriteCanvas >& xCanvas ) const
78 : {
79 : return SpriteCanvasSharedPtr(
80 0 : new internal::ImplSpriteCanvas( xCanvas ) );
81 : }
82 :
83 0 : BitmapSharedPtr VCLFactory::createBitmap( const CanvasSharedPtr& rCanvas,
84 : const ::BitmapEx& rBmpEx ) const
85 : {
86 : OSL_ENSURE( rCanvas.get() != NULL &&
87 : rCanvas->getUNOCanvas().is(),
88 : "VCLFactory::createBitmap(): Invalid canvas" );
89 :
90 0 : if( rCanvas.get() == NULL )
91 0 : return BitmapSharedPtr();
92 :
93 0 : uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
94 0 : if( !xCanvas.is() )
95 0 : return BitmapSharedPtr();
96 :
97 : return BitmapSharedPtr( new internal::ImplBitmap( rCanvas,
98 : ::vcl::unotools::xBitmapFromBitmapEx(
99 0 : xCanvas->getDevice(),
100 0 : rBmpEx) ) );
101 : }
102 :
103 0 : RendererSharedPtr VCLFactory::createRenderer( const CanvasSharedPtr& rCanvas,
104 : const ::GDIMetaFile& rMtf,
105 : const Renderer::Parameters& rParms ) const
106 : {
107 : return RendererSharedPtr( new internal::ImplRenderer( rCanvas,
108 : rMtf,
109 0 : rParms ) );
110 : }
111 : }
112 :
113 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|