xref: /aoo42x/main/svx/source/form/fmdmod.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 <svx/fmdmod.hxx>
27 #include "fmservs.hxx"
28 #include <fmobj.hxx>
29 #include <svx/unoshape.hxx>
30 #include <comphelper/processfactory.hxx>
31 #include <svx/fmglob.hxx>
32 
33 using namespace ::svxform;
34 
35 //-----------------------------------------------------------------------------
createInstance(const::rtl::OUString & ServiceSpecifier)36 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >  SAL_CALL SvxFmMSFactory::createInstance(const ::rtl::OUString& ServiceSpecifier) throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException )
37 {
38 	::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >  xRet;
39 	if ( ServiceSpecifier.indexOf( ::rtl::OUString::createFromAscii("com.sun.star.form.component.") ) == 0 )
40 	{
41 		xRet = ::comphelper::getProcessServiceFactory()->createInstance(ServiceSpecifier);
42 	}
43 	else if ( ServiceSpecifier == ::rtl::OUString( ::rtl::OUString::createFromAscii("com.sun.star.drawing.ControlShape") ) )
44 	{
45 		SdrObject* pObj = new FmFormObj(OBJ_FM_CONTROL);
46 		xRet = *new SvxShapeControl(pObj);
47 	}
48 	if (!xRet.is())
49 		xRet = SvxUnoDrawMSFactory::createInstance(ServiceSpecifier);
50 	return xRet;
51 }
52 
53 //-----------------------------------------------------------------------------
createInstanceWithArguments(const::rtl::OUString & ServiceSpecifier,const::com::sun::star::uno::Sequence<::com::sun::star::uno::Any> & Arguments)54 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL  SvxFmMSFactory::createInstanceWithArguments(const ::rtl::OUString& ServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments) throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException )
55 {
56 	return SvxUnoDrawMSFactory::createInstanceWithArguments(ServiceSpecifier, Arguments );
57 }
58 
59 //-----------------------------------------------------------------------------
getAvailableServiceNames(void)60 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL SvxFmMSFactory::getAvailableServiceNames(void) throw( ::com::sun::star::uno::RuntimeException )
61 {
62 	static const ::rtl::OUString aSvxComponentServiceNameList[] =
63 	{
64 		FM_SUN_COMPONENT_TEXTFIELD,
65 		FM_SUN_COMPONENT_FORM,
66 		FM_SUN_COMPONENT_LISTBOX,
67 		FM_SUN_COMPONENT_COMBOBOX,
68 		FM_SUN_COMPONENT_RADIOBUTTON,
69 		FM_SUN_COMPONENT_GROUPBOX,
70 		FM_SUN_COMPONENT_FIXEDTEXT,
71 		FM_SUN_COMPONENT_COMMANDBUTTON,
72 		FM_SUN_COMPONENT_CHECKBOX,
73 		FM_SUN_COMPONENT_GRIDCONTROL,
74 		FM_SUN_COMPONENT_IMAGEBUTTON,
75 		FM_SUN_COMPONENT_FILECONTROL,
76 		FM_SUN_COMPONENT_TIMEFIELD,
77 		FM_SUN_COMPONENT_DATEFIELD,
78 		FM_SUN_COMPONENT_NUMERICFIELD,
79 		FM_SUN_COMPONENT_CURRENCYFIELD,
80 		FM_SUN_COMPONENT_PATTERNFIELD,
81 		FM_SUN_COMPONENT_HIDDENCONTROL,
82 		FM_SUN_COMPONENT_IMAGECONTROL
83 	};
84 
85 	static const sal_uInt16 nSvxComponentServiceNameListCount = sizeof(aSvxComponentServiceNameList) / sizeof ( aSvxComponentServiceNameList[0] );
86 
87 	::com::sun::star::uno::Sequence< ::rtl::OUString > aSeq( nSvxComponentServiceNameListCount );
88 	::rtl::OUString* pStrings = aSeq.getArray();
89 	for( sal_uInt16 nIdx = 0; nIdx < nSvxComponentServiceNameListCount; nIdx++ )
90 		pStrings[nIdx] = aSvxComponentServiceNameList[nIdx];
91 
92 	::com::sun::star::uno::Sequence< ::rtl::OUString > aParentSeq( SvxUnoDrawMSFactory::getAvailableServiceNames() );
93 	return concatServiceNames( aParentSeq, aSeq );
94 }
95 
96 /*
97 // XServiceManager
98 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >  SvxFmDrawModel::createInstance(const ::rtl::OUString& ServiceName)
99 			const throw( ::com::sun::star::lang::ServiceNotRegisteredException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException )
100 {
101 	::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >  xRet;
102 	sal_uInt16 nTokenCount = ServiceName.getTokenCount('.');
103 	if (nTokenCount == 5 &&
104 		ServiceName.getToken( 0, '.' ) == ::rtl::OUString::createFromAscii("stardiv") &&
105 		ServiceName.getToken( 1, '.' ) == ::rtl::OUString::createFromAscii("one") &&
106 		ServiceName.getToken( 2, '.' ) == ::rtl::OUString::createFromAscii("form") &&
107 		ServiceName.getToken( 3, '.' ) == ::rtl::OUString::createFromAscii("component"))
108 	{
109 		xRet = ::comphelper::getProcessServiceFactory()->createInstance(ServiceName);
110 	}
111 	else
112 	if (nTokenCount == 4 &&
113 		ServiceName.getToken( 0, '.' ) == ::rtl::OUString::createFromAscii("stardiv") &&
114 		ServiceName.getToken( 1, '.' ) == ::rtl::OUString::createFromAscii("one") &&
115 		ServiceName.getToken( 2, '.' ) == ::rtl::OUString::createFromAscii("drawing") &&
116 		ServiceName.getToken( 3, '.' ) == ::rtl::OUString::createFromAscii("ControlShape"))
117 	{
118 		SdrObject* pObj = new FmFormObj();
119 		xRet = *new SvxShapeControl(pObj);
120 	}
121 	if (!xRet.is())
122 		xRet = SvxUnoDrawModel::createInstance(ServiceName);
123 	return xRet;
124 }
125 */
126 
127 
128