31#include <com/sun/star/awt/XSystemDependentWindowPeer.hpp>
32#include <com/sun/star/awt/XWindow.hpp>
33#include <com/sun/star/lang/NoSupportException.hpp>
34#include <com/sun/star/lang/XSingleServiceFactory.hpp>
35#include <com/sun/star/registry/XRegistryKey.hpp>
36#include <com/sun/star/uno/XComponentContext.hpp>
38#include <osl/mutex.hxx>
57 class GraphicsProviderImpl :
public GraphicsProvider
68 const uno::Reference< uno::XComponentContext >& rxContext ) :
74 void Canvas::initialize()
77 if( maArguments.getLength() == 0 )
82 SAL_INFO(
"canvas.directx",
"Canvas::initialize called" );
88 maArguments[4].getValueTypeClass() == uno::TypeClass_SEQUENCE,
89 "Canvas::initialize: wrong number of arguments, or wrong types" );
91 uno::Sequence<sal_Int8>
aSeq;
92 maArguments[4] >>=
aSeq;
95 if( !pSysData || !pSysData->hDC )
96 throw lang::NoSupportException(
"Passed SystemGraphicsData or HDC invalid!");
99 maArguments[0] >>= nPtr;
104 maDeviceHelper.init( pSysData->hDC, pOutDev, *
this );
105 maCanvasHelper.setDevice( *
this );
106 maCanvasHelper.setTarget(
107 std::make_shared<GraphicsProviderImpl>(
110 maArguments.realloc(0);
113 void Canvas::disposeThis()
115 ::osl::MutexGuard aGuard(
m_aMutex );
120 CanvasBaseT::disposeThis();
123 OUString SAL_CALL Canvas::getServiceName( )
125 return "com.sun.star.rendering.Canvas.GDI+";
129 css::uno::Sequence<OUString> Canvas::getSupportedServiceNames( )
131 return {
"com.sun.star.rendering.Canvas.GDI+" };
133 OUString Canvas::getImplementationName( )
135 return "com.sun.star.comp.rendering.Canvas.GDI+";
137 sal_Bool Canvas::supportsService(
const OUString& sServiceName )
142 BitmapCanvas::BitmapCanvas(
const uno::Sequence< uno::Any >& aArguments,
143 const uno::Reference< uno::XComponentContext >& rxContext ) :
156 SAL_INFO(
"canvas.directx",
"BitmapCanvas::initialize called" );
162 maArguments[4].getValueTypeClass() == uno::TypeClass_SEQUENCE,
163 "Canvas::initialize: wrong number of arguments, or wrong types" );
165 uno::Sequence<sal_Int8>
aSeq;
169 if( !pSysData || !pSysData->hDC )
170 throw lang::NoSupportException(
"Passed SystemGraphicsData or HDC invalid!");
178 maDeviceHelper.init( pSysData->hDC, pOutDev, *
this );
179 maCanvasHelper.setDevice( *
this );
185 hBmp=
static_cast<HBITMAP
>(GetCurrentObject(pSysData->hDC, OBJ_BITMAP));
186 if( !hBmp || GetObjectType(pSysData->hDC) != OBJ_MEMDC )
188 throw lang::NoSupportException(
"Passed HDC is no mem DC/has no bitmap selected!");
191 mpTarget = std::make_shared<DXBitmap>(
193 Gdiplus::Bitmap::FromHBITMAP(
197 maCanvasHelper.setTarget(
mpTarget );
204 ::osl::MutexGuard aGuard(
m_aMutex );
210 BitmapCanvasBaseT::disposeThis();
215 return "com.sun.star.rendering.BitmapCanvas.GDI+";
221 return {
"com.sun.star.rendering.BitmapCanvas.GDI+" };
225 return "com.sun.star.comp.rendering.BitmapCanvas.GDI+";
237 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
239 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& args)
242 xCanvas->initialize();
243 return cppu::acquire(xCanvas.get());
246 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
248 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& args)
251 xCanvas->initialize();
252 return cppu::acquire(xCanvas.get());
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
constexpr OUStringLiteral sServiceName
Product of this component's factory.
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual OUString SAL_CALL getServiceName() override
virtual void disposeThis() override
Dispose all internal references.
css::uno::Sequence< css::uno::Any > maArguments
virtual OUString SAL_CALL getImplementationName() override
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
IBitmapSharedPtr mpTarget
virtual sal_Bool SAL_CALL supportsService(const OUString &) override
virtual IBitmapSharedPtr getBitmap() const override
Product of this component's factory.
Canvas(const css::uno::Sequence< css::uno::Any > &aArguments, const css::uno::Reference< css::uno::XComponentContext > &rxContext)
#define ENSURE_ARG_OR_THROW(c, m)
GraphicsSharedPtr mpGraphics
Sequence< PropertyValue > aArguments
Sequence< sal_Int8 > aSeq
#define SAL_INFO(area, stream)
VCL_DLLPUBLIC bool isVCLSkiaEnabled()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
std::shared_ptr< Gdiplus::Graphics > GraphicsSharedPtr
std::shared_ptr< IBitmap > IBitmapSharedPtr
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * canvas_gdiplus_BitmapCanvas_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &args)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * canvas_gdiplus_Canvas_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &args)
std::shared_ptr< Gdiplus::Bitmap > BitmapSharedPtr