Bump for 3.6-28
[LibreOffice.git] / cppcanvas / source / wrapper / basegfxfactory.cxx
blob97d42f9054961dc5db77544242e8ec86a1663481
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 ************************************************************************/
30 #include <rtl/instance.hxx>
31 #include <osl/getglobalmutex.hxx>
32 #include <osl/diagnose.h>
34 #include <com/sun/star/rendering/InterpolationMode.hpp>
36 #include <basegfx/polygon/b2dpolygon.hxx>
37 #include <basegfx/polygon/b2dpolypolygon.hxx>
38 #include <basegfx/tools/canvastools.hxx>
40 #include <cppcanvas/basegfxfactory.hxx>
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>
47 #include <cppcanvas/text.hxx>
48 #include <canvasgraphichelper.hxx>
50 #include "implpolypolygon.hxx"
51 #include "implbitmap.hxx"
53 using namespace ::com::sun::star;
55 namespace cppcanvas
57 /* Singleton handling */
58 struct InitInstance2
60 BaseGfxFactory* operator()()
62 return new BaseGfxFactory();
66 BaseGfxFactory& BaseGfxFactory::getInstance()
68 return *rtl_Instance< BaseGfxFactory, InitInstance2, ::osl::MutexGuard,
69 ::osl::GetGlobalMutex >::create(
70 InitInstance2(), ::osl::GetGlobalMutex());
73 BaseGfxFactory::BaseGfxFactory()
77 PolyPolygonSharedPtr BaseGfxFactory::createPolyPolygon( const CanvasSharedPtr& rCanvas,
78 const ::basegfx::B2DPolygon& rPoly ) const
80 OSL_ENSURE( rCanvas.get() != NULL &&
81 rCanvas->getUNOCanvas().is(),
82 "BaseGfxFactory::createPolyPolygon(): Invalid canvas" );
84 if( rCanvas.get() == NULL )
85 return PolyPolygonSharedPtr();
87 uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
88 if( !xCanvas.is() )
89 return PolyPolygonSharedPtr();
91 return PolyPolygonSharedPtr(
92 new internal::ImplPolyPolygon( rCanvas,
93 ::basegfx::unotools::xPolyPolygonFromB2DPolygon(
94 xCanvas->getDevice(),
95 rPoly) ) );
98 BitmapSharedPtr BaseGfxFactory::createBitmap( const CanvasSharedPtr& rCanvas,
99 const ::basegfx::B2ISize& rSize ) const
101 OSL_ENSURE( rCanvas.get() != NULL &&
102 rCanvas->getUNOCanvas().is(),
103 "BaseGfxFactory::createBitmap(): Invalid canvas" );
105 if( rCanvas.get() == NULL )
106 return BitmapSharedPtr();
108 uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
109 if( !xCanvas.is() )
110 return BitmapSharedPtr();
112 return BitmapSharedPtr(
113 new internal::ImplBitmap( rCanvas,
114 xCanvas->getDevice()->createCompatibleBitmap(
115 ::basegfx::unotools::integerSize2DFromB2ISize(rSize) ) ) );
118 BitmapSharedPtr BaseGfxFactory::createAlphaBitmap( const CanvasSharedPtr& rCanvas,
119 const ::basegfx::B2ISize& rSize ) const
121 OSL_ENSURE( rCanvas.get() != NULL &&
122 rCanvas->getUNOCanvas().is(),
123 "BaseGfxFactory::createBitmap(): Invalid canvas" );
125 if( rCanvas.get() == NULL )
126 return BitmapSharedPtr();
128 uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
129 if( !xCanvas.is() )
130 return BitmapSharedPtr();
132 return BitmapSharedPtr(
133 new internal::ImplBitmap( rCanvas,
134 xCanvas->getDevice()->createCompatibleAlphaBitmap(
135 ::basegfx::unotools::integerSize2DFromB2ISize(rSize) ) ) );
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */