1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <com/sun/star/container/XSet.hpp>
30 #include <cppuhelper/factory.hxx>
31 #include <comphelper/processfactory.hxx>
32 #include "fmservs.hxx"
34 // ------------------------------------------------------------------------
35 #define DECL_SERVICE(ImplName) \
36 ::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 );
38 #define REGISTER_SERVICE(ImplName, ServiceName) \
39 sString = (ServiceName); \
40 xSingleFactory = ::cppu::createSingleFactory(xServiceFactory, \
41 ::rtl::OUString(), ImplName##_NewInstance_Impl, \
42 ::com::sun::star::uno::Sequence< ::rtl::OUString>(&sString, 1)); \
43 if (xSingleFactory.is()) \
44 xSet->insert(::com::sun::star::uno::makeAny(xSingleFactory));
47 DECL_SERVICE( FmXGridControl
)
48 DECL_SERVICE( FormController
)
49 DECL_SERVICE( LegacyFormController
)
52 // ------------------------------------------------------------------------
56 #define DECL_SELFAWARE_SERVICE( ClassName ) \
57 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ClassName##_Create( \
58 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ); \
59 ::rtl::OUString SAL_CALL ClassName##_GetImplementationName(); \
60 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL ClassName##_GetSupportedServiceNames(); \
63 #define REGISTER_SELFAWARE_SERVICE( ClassName ) \
64 xSingleFactory = ::cppu::createSingleFactory( xServiceFactory, \
65 ClassName##_GetImplementationName(), \
67 ClassName##_GetSupportedServiceNames() \
69 if ( xSingleFactory.is() ) \
70 xSet->insert( ::com::sun::star::uno::makeAny( xSingleFactory ) );
73 // ------------------------------------------------------------------------
74 DECL_SELFAWARE_SERVICE( OAddConditionDialog
)
76 // ------------------------------------------------------------------------
77 void ImplSmartRegisterUnoServices()
79 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> xServiceFactory(::comphelper::getProcessServiceFactory(), ::com::sun::star::uno::UNO_QUERY
);
80 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XSet
> xSet(xServiceFactory
, ::com::sun::star::uno::UNO_QUERY
);
84 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> aServices
;
85 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XSingleServiceFactory
> xSingleFactory
;
87 ::rtl::OUString sString
;
89 // ------------------------------------------------------------------------
91 REGISTER_SERVICE( FormController
, FM_FORM_CONTROLLER
);
92 REGISTER_SERVICE( LegacyFormController
, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.FormController" ) ) );
94 // ------------------------------------------------------------------------
96 REGISTER_SELFAWARE_SERVICE( OAddConditionDialog
);
98 // ------------------------------------------------------------------------
100 REGISTER_SERVICE(FmXGridControl
, FM_CONTROL_GRID
); // compatibility
101 REGISTER_SERVICE(FmXGridControl
, FM_CONTROL_GRIDCONTROL
);
102 REGISTER_SERVICE(FmXGridControl
, FM_SUN_CONTROL_GRIDCONTROL
);
105 } // namespace svxform
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */