android: Update app-specific/MIME type icons
[LibreOffice.git] / cppcanvas / source / wrapper / basegfxfactory.cxx
blob5b06bcfd9715fd0ef3d4e3d9fdaba6224ba69930
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <osl/diagnose.h>
23 #include <basegfx/polygon/b2dpolygon.hxx>
24 #include <basegfx/utils/canvastools.hxx>
26 #include <cppcanvas/basegfxfactory.hxx>
28 #include <com/sun/star/rendering/XCanvas.hpp>
30 #include "implpolypolygon.hxx"
31 #include "implbitmap.hxx"
33 using namespace ::com::sun::star;
35 namespace cppcanvas
37 PolyPolygonSharedPtr BaseGfxFactory::createPolyPolygon( const CanvasSharedPtr& rCanvas,
38 const ::basegfx::B2DPolygon& rPoly )
40 OSL_ENSURE( rCanvas && rCanvas->getUNOCanvas().is(),
41 "BaseGfxFactory::createPolyPolygon(): Invalid canvas" );
43 if( !rCanvas )
44 return PolyPolygonSharedPtr();
46 uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
47 if( !xCanvas.is() )
48 return PolyPolygonSharedPtr();
50 return std::make_shared<internal::ImplPolyPolygon>( rCanvas,
51 ::basegfx::unotools::xPolyPolygonFromB2DPolygon(
52 xCanvas->getDevice(),
53 rPoly) );
56 BitmapSharedPtr BaseGfxFactory::createBitmap( const CanvasSharedPtr& rCanvas,
57 const ::basegfx::B2ISize& rSize )
59 OSL_ENSURE( rCanvas && rCanvas->getUNOCanvas().is(),
60 "BaseGfxFactory::createBitmap(): Invalid canvas" );
62 if( !rCanvas )
63 return BitmapSharedPtr();
65 uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
66 if( !xCanvas.is() )
67 return BitmapSharedPtr();
69 return std::make_shared<internal::ImplBitmap>( rCanvas,
70 xCanvas->getDevice()->createCompatibleBitmap(
71 ::basegfx::unotools::integerSize2DFromB2ISize(rSize) ) );
74 BitmapSharedPtr BaseGfxFactory::createAlphaBitmap( const CanvasSharedPtr& rCanvas,
75 const ::basegfx::B2ISize& rSize )
77 OSL_ENSURE( rCanvas && rCanvas->getUNOCanvas().is(),
78 "BaseGfxFactory::createBitmap(): Invalid canvas" );
80 if( !rCanvas )
81 return BitmapSharedPtr();
83 uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
84 if( !xCanvas.is() )
85 return BitmapSharedPtr();
87 return std::make_shared<internal::ImplBitmap>( rCanvas,
88 xCanvas->getDevice()->createCompatibleAlphaBitmap(
89 ::basegfx::unotools::integerSize2DFromB2ISize(rSize) ) );
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */