Line data Source code
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 : #include <com/sun/star/container/XSet.hpp>
21 : #include <cppuhelper/factory.hxx>
22 : #include <comphelper/processfactory.hxx>
23 : #include "fmservs.hxx"
24 :
25 : // ------------------------------------------------------------------------
26 : #define DECL_SERVICE(ImplName) \
27 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ImplName##_NewInstance_Impl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &) throw( ::com::sun::star::uno::Exception );
28 :
29 : #define REGISTER_SERVICE(ImplName, ServiceName) \
30 : sString = (ServiceName); \
31 : xSingleFactory = ::cppu::createSingleFactory(xServiceFactory, \
32 : ::rtl::OUString(), ImplName##_NewInstance_Impl, \
33 : ::com::sun::star::uno::Sequence< ::rtl::OUString>(&sString, 1)); \
34 : if (xSingleFactory.is()) \
35 : xSet->insert(::com::sun::star::uno::makeAny(xSingleFactory));
36 :
37 :
38 : DECL_SERVICE( FmXGridControl )
39 : DECL_SERVICE( FormController )
40 : DECL_SERVICE( LegacyFormController )
41 :
42 :
43 : // ------------------------------------------------------------------------
44 : namespace svxform
45 : {
46 :
47 : #define DECL_SELFAWARE_SERVICE( ClassName ) \
48 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ClassName##_Create( \
49 : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ); \
50 : ::rtl::OUString SAL_CALL ClassName##_GetImplementationName(); \
51 : ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL ClassName##_GetSupportedServiceNames(); \
52 :
53 :
54 : #define REGISTER_SELFAWARE_SERVICE( ClassName ) \
55 : xSingleFactory = ::cppu::createSingleFactory( xServiceFactory, \
56 : ClassName##_GetImplementationName(), \
57 : ClassName##_Create, \
58 : ClassName##_GetSupportedServiceNames() \
59 : ); \
60 : if ( xSingleFactory.is() ) \
61 : xSet->insert( ::com::sun::star::uno::makeAny( xSingleFactory ) );
62 :
63 :
64 : // ------------------------------------------------------------------------
65 : DECL_SELFAWARE_SERVICE( OAddConditionDialog )
66 :
67 : // ------------------------------------------------------------------------
68 18 : void ImplSmartRegisterUnoServices()
69 : {
70 18 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory(::comphelper::getProcessServiceFactory(), ::com::sun::star::uno::UNO_QUERY);
71 18 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XSet > xSet(xServiceFactory, ::com::sun::star::uno::UNO_QUERY);
72 18 : if (!xSet.is())
73 18 : return;
74 :
75 18 : ::com::sun::star::uno::Sequence< ::rtl::OUString> aServices;
76 18 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > xSingleFactory;
77 :
78 18 : ::rtl::OUString sString;
79 :
80 : // ------------------------------------------------------------------------
81 : // FormController
82 18 : REGISTER_SERVICE( FormController, FM_FORM_CONTROLLER );
83 18 : REGISTER_SERVICE( LegacyFormController, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.FormController" ) ) );
84 :
85 : // ------------------------------------------------------------------------
86 : // FormController
87 18 : REGISTER_SELFAWARE_SERVICE( OAddConditionDialog );
88 :
89 : // ------------------------------------------------------------------------
90 : // DBGridControl
91 18 : REGISTER_SERVICE(FmXGridControl, FM_CONTROL_GRID); // compatibility
92 18 : REGISTER_SERVICE(FmXGridControl, FM_CONTROL_GRIDCONTROL);
93 18 : REGISTER_SERVICE(FmXGridControl, FM_SUN_CONTROL_GRIDCONTROL);
94 : };
95 :
96 : } // namespace svxform
97 :
98 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|