update dev300-m58
[ooovba.git] / svx / source / form / fmservs.cxx
blobd41886c844b5e9d0ab5f8418e4832e08b26e6142
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fmservs.cxx,v $
10 * $Revision: 1.17 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <com/sun/star/container/XSet.hpp>
34 #include <cppuhelper/factory.hxx>
35 #include <comphelper/processfactory.hxx>
36 #include "fmservs.hxx"
38 // ------------------------------------------------------------------------
39 #define DECL_SERVICE(ImplName) \
40 ::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 );
42 #define REGISTER_SERVICE(ImplName, ServiceName) \
43 sString = (ServiceName); \
44 xSingleFactory = ::cppu::createSingleFactory(xServiceFactory, \
45 ::rtl::OUString(), ImplName##_NewInstance_Impl, \
46 ::com::sun::star::uno::Sequence< ::rtl::OUString>(&sString, 1)); \
47 if (xSingleFactory.is()) \
48 xSet->insert(::com::sun::star::uno::makeAny(xSingleFactory));
51 DECL_SERVICE( FmXGridControl )
52 DECL_SERVICE( FmXFormController )
55 // ------------------------------------------------------------------------
56 namespace svxform
59 #define DECL_SELFAWARE_SERVICE( ClassName ) \
60 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ClassName##_Create( \
61 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ); \
62 ::rtl::OUString SAL_CALL ClassName##_GetImplementationName(); \
63 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL ClassName##_GetSupportedServiceNames(); \
66 #define REGISTER_SELFAWARE_SERVICE( ClassName ) \
67 xSingleFactory = ::cppu::createSingleFactory( xServiceFactory, \
68 ClassName##_GetImplementationName(), \
69 ClassName##_Create, \
70 ClassName##_GetSupportedServiceNames() \
71 ); \
72 if ( xSingleFactory.is() ) \
73 xSet->insert( ::com::sun::star::uno::makeAny( xSingleFactory ) );
76 // ------------------------------------------------------------------------
77 DECL_SELFAWARE_SERVICE( OAddConditionDialog )
79 // ------------------------------------------------------------------------
80 void ImplSmartRegisterUnoServices()
82 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory(::comphelper::getProcessServiceFactory(), ::com::sun::star::uno::UNO_QUERY);
83 ::com::sun::star::uno::Reference< ::com::sun::star::container::XSet > xSet(xServiceFactory, ::com::sun::star::uno::UNO_QUERY);
84 if (!xSet.is())
85 return;
87 ::com::sun::star::uno::Sequence< ::rtl::OUString> aServices;
88 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > xSingleFactory;
90 ::rtl::OUString sString;
92 // ------------------------------------------------------------------------
93 // FormController
94 REGISTER_SERVICE(FmXFormController, FM_FORM_CONTROLLER);
96 // ------------------------------------------------------------------------
97 // FormController
98 REGISTER_SELFAWARE_SERVICE( OAddConditionDialog );
100 // ------------------------------------------------------------------------
101 // DBGridControl
102 REGISTER_SERVICE(FmXGridControl, FM_CONTROL_GRID); // compatibility
103 REGISTER_SERVICE(FmXGridControl, FM_CONTROL_GRIDCONTROL);
104 REGISTER_SERVICE(FmXGridControl, FM_SUN_CONTROL_GRIDCONTROL);
110 } // namespace svxform