Get the style color and number just once
[LibreOffice.git] / vcl / source / components / factory.cxx
blob2a2014125bee1f2e76f8be9f93f76c1ed58bfb74
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 .
20 #include <cppuhelper/factory.hxx>
21 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
22 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
23 #include <vcl/dllapi.h>
25 #include <factory.hxx>
27 using namespace com::sun::star::uno;
28 using namespace com::sun::star::lang;
30 extern "C" {
32 VCL_DLLPUBLIC void* vcl_component_getFactory(
33 const char* pImplementationName,
34 void* pXUnoSMgr,
35 void* /*pXUnoKey*/)
37 if (!pXUnoSMgr)
38 return nullptr;
40 Reference< css::lang::XMultiServiceFactory > xMgr(
41 static_cast<css::lang::XMultiServiceFactory*>(pXUnoSMgr));
43 Reference< css::lang::XSingleServiceFactory > xFactory;
45 if( vcl::DragSource_getImplementationName().equalsAscii( pImplementationName ) )
47 xFactory = ::cppu::createSingleFactory(
48 xMgr, vcl::DragSource_getImplementationName(), vcl::DragSource_createInstance,
49 vcl::DragSource_getSupportedServiceNames() );
51 else if( vcl::DropTarget_getImplementationName().equalsAscii( pImplementationName ) )
53 xFactory = ::cppu::createSingleFactory(
54 xMgr, vcl::DropTarget_getImplementationName(), vcl::DropTarget_createInstance,
55 vcl::DropTarget_getSupportedServiceNames() );
58 if( xFactory.is() )
60 xFactory->acquire();
61 return xFactory.get();
64 return nullptr;
67 } /* extern "C" */
69 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */