LibreOffice Module cppcanvas (master) 1
basegfxfactory.cxx
Go to the documentation of this file.
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 <osl/diagnose.h>
22
25
27
28#include <com/sun/star/rendering/XCanvas.hpp>
29
30#include "implpolypolygon.hxx"
31#include "implbitmap.hxx"
32
33using namespace ::com::sun::star;
34
35namespace cppcanvas
36{
38 const ::basegfx::B2DPolygon& rPoly )
39 {
40 OSL_ENSURE( rCanvas && rCanvas->getUNOCanvas().is(),
41 "BaseGfxFactory::createPolyPolygon(): Invalid canvas" );
42
43 if( !rCanvas )
44 return PolyPolygonSharedPtr();
45
46 uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
47 if( !xCanvas.is() )
48 return PolyPolygonSharedPtr();
49
50 return std::make_shared<internal::ImplPolyPolygon>( rCanvas,
51 ::basegfx::unotools::xPolyPolygonFromB2DPolygon(
52 xCanvas->getDevice(),
53 rPoly) );
54 }
55
57 const ::basegfx::B2ISize& rSize )
58 {
59 OSL_ENSURE( rCanvas && rCanvas->getUNOCanvas().is(),
60 "BaseGfxFactory::createBitmap(): Invalid canvas" );
61
62 if( !rCanvas )
63 return BitmapSharedPtr();
64
65 uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
66 if( !xCanvas.is() )
67 return BitmapSharedPtr();
68
69 return std::make_shared<internal::ImplBitmap>( rCanvas,
70 xCanvas->getDevice()->createCompatibleBitmap(
71 ::basegfx::unotools::integerSize2DFromB2ISize(rSize) ) );
72 }
73
75 const ::basegfx::B2ISize& rSize )
76 {
77 OSL_ENSURE( rCanvas && rCanvas->getUNOCanvas().is(),
78 "BaseGfxFactory::createBitmap(): Invalid canvas" );
79
80 if( !rCanvas )
81 return BitmapSharedPtr();
82
83 uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
84 if( !xCanvas.is() )
85 return BitmapSharedPtr();
86
87 return std::make_shared<internal::ImplBitmap>( rCanvas,
88 xCanvas->getDevice()->createCompatibleAlphaBitmap(
89 ::basegfx::unotools::integerSize2DFromB2ISize(rSize) ) );
90 }
91
92}
93
94/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static PolyPolygonSharedPtr createPolyPolygon(const CanvasSharedPtr &, const ::basegfx::B2DPolygon &rPoly)
Create a polygon from a basegfx::B2DPolygon.
static BitmapSharedPtr createBitmap(const CanvasSharedPtr &, const ::basegfx::B2ISize &rSize)
Create an uninitialized bitmap with the given size.
static BitmapSharedPtr createAlphaBitmap(const CanvasSharedPtr &, const ::basegfx::B2ISize &rSize)
Create an uninitialized alpha bitmap with the given size.
std::shared_ptr< PolyPolygon > PolyPolygonSharedPtr
Definition: canvas.hxx:44
std::shared_ptr< ::cppcanvas::Bitmap > BitmapSharedPtr
Definition: bitmap.hxx:65
std::shared_ptr< Canvas > CanvasSharedPtr