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 :
21 : #include <rtl/instance.hxx>
22 : #include <osl/getglobalmutex.hxx>
23 : #include <osl/diagnose.h>
24 :
25 : #include <com/sun/star/rendering/InterpolationMode.hpp>
26 :
27 : #include <basegfx/polygon/b2dpolygon.hxx>
28 : #include <basegfx/polygon/b2dpolypolygon.hxx>
29 : #include <basegfx/tools/canvastools.hxx>
30 :
31 : #include <cppcanvas/basegfxfactory.hxx>
32 :
33 : #include <com/sun/star/rendering/RenderState.hpp>
34 : #include <com/sun/star/rendering/StringContext.hpp>
35 : #include <com/sun/star/rendering/XCanvas.hpp>
36 : #include <com/sun/star/rendering/XCanvasFont.hpp>
37 :
38 : #include <canvasgraphichelper.hxx>
39 :
40 : #include "implpolypolygon.hxx"
41 : #include "implbitmap.hxx"
42 :
43 : using namespace ::com::sun::star;
44 :
45 : namespace cppcanvas
46 : {
47 0 : PolyPolygonSharedPtr BaseGfxFactory::createPolyPolygon( const CanvasSharedPtr& rCanvas,
48 : const ::basegfx::B2DPolygon& rPoly )
49 : {
50 : OSL_ENSURE( rCanvas.get() != NULL &&
51 : rCanvas->getUNOCanvas().is(),
52 : "BaseGfxFactory::createPolyPolygon(): Invalid canvas" );
53 :
54 0 : if( rCanvas.get() == NULL )
55 0 : return PolyPolygonSharedPtr();
56 :
57 0 : uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
58 0 : if( !xCanvas.is() )
59 0 : return PolyPolygonSharedPtr();
60 :
61 : return PolyPolygonSharedPtr(
62 : new internal::ImplPolyPolygon( rCanvas,
63 : ::basegfx::unotools::xPolyPolygonFromB2DPolygon(
64 0 : xCanvas->getDevice(),
65 0 : rPoly) ) );
66 : }
67 :
68 0 : BitmapSharedPtr BaseGfxFactory::createBitmap( const CanvasSharedPtr& rCanvas,
69 : const ::basegfx::B2ISize& rSize )
70 : {
71 : OSL_ENSURE( rCanvas.get() != NULL &&
72 : rCanvas->getUNOCanvas().is(),
73 : "BaseGfxFactory::createBitmap(): Invalid canvas" );
74 :
75 0 : if( rCanvas.get() == NULL )
76 0 : return BitmapSharedPtr();
77 :
78 0 : uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
79 0 : if( !xCanvas.is() )
80 0 : return BitmapSharedPtr();
81 :
82 : return BitmapSharedPtr(
83 : new internal::ImplBitmap( rCanvas,
84 0 : xCanvas->getDevice()->createCompatibleBitmap(
85 0 : ::basegfx::unotools::integerSize2DFromB2ISize(rSize) ) ) );
86 : }
87 :
88 0 : BitmapSharedPtr BaseGfxFactory::createAlphaBitmap( const CanvasSharedPtr& rCanvas,
89 : const ::basegfx::B2ISize& rSize )
90 : {
91 : OSL_ENSURE( rCanvas.get() != NULL &&
92 : rCanvas->getUNOCanvas().is(),
93 : "BaseGfxFactory::createBitmap(): Invalid canvas" );
94 :
95 0 : if( rCanvas.get() == NULL )
96 0 : return BitmapSharedPtr();
97 :
98 0 : uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
99 0 : if( !xCanvas.is() )
100 0 : return BitmapSharedPtr();
101 :
102 : return BitmapSharedPtr(
103 : new internal::ImplBitmap( rCanvas,
104 0 : xCanvas->getDevice()->createCompatibleAlphaBitmap(
105 0 : ::basegfx::unotools::integerSize2DFromB2ISize(rSize) ) ) );
106 : }
107 :
108 : }
109 :
110 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|