xref: /aoo42x/main/svx/source/form/fmservs.cxx (revision f6e50924)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 #include <com/sun/star/container/XSet.hpp>
27 #include <cppuhelper/factory.hxx>
28 #include <comphelper/processfactory.hxx>
29 #include "fmservs.hxx"
30 
31 // ------------------------------------------------------------------------
32 #define DECL_SERVICE(ImplName)						\
33 ::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 );
34 
35 #define REGISTER_SERVICE(ImplName, ServiceName)							\
36 	sString = (ServiceName);										\
37 	xSingleFactory = ::cppu::createSingleFactory(xServiceFactory,				\
38 						::rtl::OUString(), ImplName##_NewInstance_Impl, 			\
39 						::com::sun::star::uno::Sequence< ::rtl::OUString>(&sString, 1));	\
40 	if (xSingleFactory.is())											\
41 		xSet->insert(::com::sun::star::uno::makeAny(xSingleFactory));
42 
43 
44 	DECL_SERVICE( FmXGridControl )
45 	DECL_SERVICE( FormController )
46     DECL_SERVICE( LegacyFormController )
47 
48 
49 // ------------------------------------------------------------------------
50 namespace svxform
51 {
52 
53 #define DECL_SELFAWARE_SERVICE( ClassName )						\
54     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ClassName##_Create(      \
55                 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& );  \
56     ::rtl::OUString SAL_CALL ClassName##_GetImplementationName();                                           \
57     ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL ClassName##_GetSupportedServiceNames();     \
58 
59 
60 #define REGISTER_SELFAWARE_SERVICE( ClassName )                     \
61     xSingleFactory = ::cppu::createSingleFactory( xServiceFactory,  \
62                         ClassName##_GetImplementationName(),        \
63                         ClassName##_Create,                         \
64                         ClassName##_GetSupportedServiceNames()      \
65                      );                                             \
66     if ( xSingleFactory.is() )                                      \
67         xSet->insert( ::com::sun::star::uno::makeAny( xSingleFactory ) );
68 
69 
70     // ------------------------------------------------------------------------
DECL_SELFAWARE_SERVICE(OAddConditionDialog)71     DECL_SELFAWARE_SERVICE( OAddConditionDialog )
72 
73 	// ------------------------------------------------------------------------
74 	void ImplSmartRegisterUnoServices()
75 	{
76 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >  xServiceFactory(::comphelper::getProcessServiceFactory(), ::com::sun::star::uno::UNO_QUERY);
77 		::com::sun::star::uno::Reference< ::com::sun::star::container::XSet >  xSet(xServiceFactory, ::com::sun::star::uno::UNO_QUERY);
78 		if (!xSet.is())
79 			return;
80 
81 		::com::sun::star::uno::Sequence< ::rtl::OUString> aServices;
82 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory >  xSingleFactory;
83 
84 		::rtl::OUString sString;
85 
86 		// ------------------------------------------------------------------------
87         // FormController
88 		REGISTER_SERVICE( FormController, FM_FORM_CONTROLLER );
89 		REGISTER_SERVICE( LegacyFormController, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.FormController" ) ) );
90 
91 		// ------------------------------------------------------------------------
92         // FormController
93 		REGISTER_SELFAWARE_SERVICE( OAddConditionDialog );
94 
95 		// ------------------------------------------------------------------------
96 		// DBGridControl
97 		REGISTER_SERVICE(FmXGridControl, FM_CONTROL_GRID);	// compatibility
98 		REGISTER_SERVICE(FmXGridControl, FM_CONTROL_GRIDCONTROL);
99 		REGISTER_SERVICE(FmXGridControl, FM_SUN_CONTROL_GRIDCONTROL);
100 	};
101 
102 }	// namespace svxform
103