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 : :
30 : : #include <rtl/instance.hxx>
31 : : #include <osl/getglobalmutex.hxx>
32 : : #include <osl/diagnose.h>
33 : :
34 : : #include <com/sun/star/rendering/InterpolationMode.hpp>
35 : :
36 : : #include <basegfx/polygon/b2dpolygon.hxx>
37 : : #include <basegfx/polygon/b2dpolypolygon.hxx>
38 : : #include <basegfx/tools/canvastools.hxx>
39 : :
40 : : #include <cppcanvas/basegfxfactory.hxx>
41 : :
42 : : #include <com/sun/star/rendering/RenderState.hpp>
43 : : #include <com/sun/star/rendering/StringContext.hpp>
44 : : #include <com/sun/star/rendering/XCanvas.hpp>
45 : : #include <com/sun/star/rendering/XCanvasFont.hpp>
46 : :
47 : : #include <cppcanvas/text.hxx>
48 : : #include <canvasgraphichelper.hxx>
49 : :
50 : : #include "implpolypolygon.hxx"
51 : : #include "implbitmap.hxx"
52 : :
53 : : using namespace ::com::sun::star;
54 : :
55 : : namespace cppcanvas
56 : : {
57 : : /* Singleton handling */
58 : : struct InitInstance2
59 : : {
60 : 0 : BaseGfxFactory* operator()()
61 : : {
62 [ # # ]: 0 : return new BaseGfxFactory();
63 : : }
64 : : };
65 : :
66 : 0 : BaseGfxFactory& BaseGfxFactory::getInstance()
67 : : {
68 : : return *rtl_Instance< BaseGfxFactory, InitInstance2, ::osl::MutexGuard,
69 : : ::osl::GetGlobalMutex >::create(
70 [ # # ]: 0 : InitInstance2(), ::osl::GetGlobalMutex());
71 : : }
72 : :
73 : 0 : BaseGfxFactory::BaseGfxFactory()
74 : : {
75 : 0 : }
76 : :
77 : 0 : PolyPolygonSharedPtr BaseGfxFactory::createPolyPolygon( const CanvasSharedPtr& rCanvas,
78 : : const ::basegfx::B2DPolygon& rPoly ) const
79 : : {
80 : : OSL_ENSURE( rCanvas.get() != NULL &&
81 : : rCanvas->getUNOCanvas().is(),
82 : : "BaseGfxFactory::createPolyPolygon(): Invalid canvas" );
83 : :
84 [ # # ]: 0 : if( rCanvas.get() == NULL )
85 [ # # ]: 0 : return PolyPolygonSharedPtr();
86 : :
87 [ # # ]: 0 : uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
88 [ # # ]: 0 : if( !xCanvas.is() )
89 [ # # ]: 0 : return PolyPolygonSharedPtr();
90 : :
91 : : return PolyPolygonSharedPtr(
92 : : new internal::ImplPolyPolygon( rCanvas,
93 : : ::basegfx::unotools::xPolyPolygonFromB2DPolygon(
94 [ # # ]: 0 : xCanvas->getDevice(),
95 [ # # ][ # # ]: 0 : rPoly) ) );
[ # # ][ # # ]
[ # # ]
96 : : }
97 : :
98 : 0 : BitmapSharedPtr BaseGfxFactory::createBitmap( const CanvasSharedPtr& rCanvas,
99 : : const ::basegfx::B2ISize& rSize ) const
100 : : {
101 : : OSL_ENSURE( rCanvas.get() != NULL &&
102 : : rCanvas->getUNOCanvas().is(),
103 : : "BaseGfxFactory::createBitmap(): Invalid canvas" );
104 : :
105 [ # # ]: 0 : if( rCanvas.get() == NULL )
106 [ # # ]: 0 : return BitmapSharedPtr();
107 : :
108 [ # # ]: 0 : uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
109 [ # # ]: 0 : if( !xCanvas.is() )
110 [ # # ]: 0 : return BitmapSharedPtr();
111 : :
112 : : return BitmapSharedPtr(
113 : : new internal::ImplBitmap( rCanvas,
114 [ # # ][ # # ]: 0 : xCanvas->getDevice()->createCompatibleBitmap(
[ # # ]
115 [ # # ][ # # ]: 0 : ::basegfx::unotools::integerSize2DFromB2ISize(rSize) ) ) );
[ # # ][ # # ]
[ # # ]
116 : : }
117 : :
118 : 0 : BitmapSharedPtr BaseGfxFactory::createAlphaBitmap( const CanvasSharedPtr& rCanvas,
119 : : const ::basegfx::B2ISize& rSize ) const
120 : : {
121 : : OSL_ENSURE( rCanvas.get() != NULL &&
122 : : rCanvas->getUNOCanvas().is(),
123 : : "BaseGfxFactory::createBitmap(): Invalid canvas" );
124 : :
125 [ # # ]: 0 : if( rCanvas.get() == NULL )
126 [ # # ]: 0 : return BitmapSharedPtr();
127 : :
128 [ # # ]: 0 : uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
129 [ # # ]: 0 : if( !xCanvas.is() )
130 [ # # ]: 0 : return BitmapSharedPtr();
131 : :
132 : : return BitmapSharedPtr(
133 : : new internal::ImplBitmap( rCanvas,
134 [ # # ][ # # ]: 0 : xCanvas->getDevice()->createCompatibleAlphaBitmap(
[ # # ]
135 [ # # ][ # # ]: 0 : ::basegfx::unotools::integerSize2DFromB2ISize(rSize) ) ) );
[ # # ][ # # ]
[ # # ]
136 : : }
137 : :
138 : : }
139 : :
140 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|