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