xref: /aoo41x/main/svx/source/form/fmdmod.cxx (revision f6e50924)
1*f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f6e50924SAndrew Rist  * distributed with this work for additional information
6*f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9*f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f6e50924SAndrew Rist  *
11*f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f6e50924SAndrew Rist  *
13*f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15*f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f6e50924SAndrew Rist  * specific language governing permissions and limitations
18*f6e50924SAndrew Rist  * under the License.
19*f6e50924SAndrew Rist  *
20*f6e50924SAndrew Rist  *************************************************************/
21*f6e50924SAndrew Rist 
22*f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir #include <svx/fmdmod.hxx>
27cdf0e10cSrcweir #include "fmservs.hxx"
28cdf0e10cSrcweir #include <fmobj.hxx>
29cdf0e10cSrcweir #include <svx/unoshape.hxx>
30cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
31cdf0e10cSrcweir #include <svx/fmglob.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir using namespace ::svxform;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir //-----------------------------------------------------------------------------
createInstance(const::rtl::OUString & ServiceSpecifier)36cdf0e10cSrcweir ::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 )
37cdf0e10cSrcweir {
38cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >  xRet;
39cdf0e10cSrcweir 	if ( ServiceSpecifier.indexOf( ::rtl::OUString::createFromAscii("com.sun.star.form.component.") ) == 0 )
40cdf0e10cSrcweir 	{
41cdf0e10cSrcweir 		xRet = ::comphelper::getProcessServiceFactory()->createInstance(ServiceSpecifier);
42cdf0e10cSrcweir 	}
43cdf0e10cSrcweir 	else if ( ServiceSpecifier == ::rtl::OUString( ::rtl::OUString::createFromAscii("com.sun.star.drawing.ControlShape") ) )
44cdf0e10cSrcweir 	{
45cdf0e10cSrcweir 		SdrObject* pObj = new FmFormObj(OBJ_FM_CONTROL);
46cdf0e10cSrcweir 		xRet = *new SvxShapeControl(pObj);
47cdf0e10cSrcweir 	}
48cdf0e10cSrcweir 	if (!xRet.is())
49cdf0e10cSrcweir 		xRet = SvxUnoDrawMSFactory::createInstance(ServiceSpecifier);
50cdf0e10cSrcweir 	return xRet;
51cdf0e10cSrcweir }
52cdf0e10cSrcweir 
53cdf0e10cSrcweir //-----------------------------------------------------------------------------
createInstanceWithArguments(const::rtl::OUString & ServiceSpecifier,const::com::sun::star::uno::Sequence<::com::sun::star::uno::Any> & Arguments)54cdf0e10cSrcweir ::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 )
55cdf0e10cSrcweir {
56cdf0e10cSrcweir 	return SvxUnoDrawMSFactory::createInstanceWithArguments(ServiceSpecifier, Arguments );
57cdf0e10cSrcweir }
58cdf0e10cSrcweir 
59cdf0e10cSrcweir //-----------------------------------------------------------------------------
getAvailableServiceNames(void)60cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL SvxFmMSFactory::getAvailableServiceNames(void) throw( ::com::sun::star::uno::RuntimeException )
61cdf0e10cSrcweir {
62cdf0e10cSrcweir 	static const ::rtl::OUString aSvxComponentServiceNameList[] =
63cdf0e10cSrcweir 	{
64cdf0e10cSrcweir 		FM_SUN_COMPONENT_TEXTFIELD,
65cdf0e10cSrcweir 		FM_SUN_COMPONENT_FORM,
66cdf0e10cSrcweir 		FM_SUN_COMPONENT_LISTBOX,
67cdf0e10cSrcweir 		FM_SUN_COMPONENT_COMBOBOX,
68cdf0e10cSrcweir 		FM_SUN_COMPONENT_RADIOBUTTON,
69cdf0e10cSrcweir 		FM_SUN_COMPONENT_GROUPBOX,
70cdf0e10cSrcweir 		FM_SUN_COMPONENT_FIXEDTEXT,
71cdf0e10cSrcweir 		FM_SUN_COMPONENT_COMMANDBUTTON,
72cdf0e10cSrcweir 		FM_SUN_COMPONENT_CHECKBOX,
73cdf0e10cSrcweir 		FM_SUN_COMPONENT_GRIDCONTROL,
74cdf0e10cSrcweir 		FM_SUN_COMPONENT_IMAGEBUTTON,
75cdf0e10cSrcweir 		FM_SUN_COMPONENT_FILECONTROL,
76cdf0e10cSrcweir 		FM_SUN_COMPONENT_TIMEFIELD,
77cdf0e10cSrcweir 		FM_SUN_COMPONENT_DATEFIELD,
78cdf0e10cSrcweir 		FM_SUN_COMPONENT_NUMERICFIELD,
79cdf0e10cSrcweir 		FM_SUN_COMPONENT_CURRENCYFIELD,
80cdf0e10cSrcweir 		FM_SUN_COMPONENT_PATTERNFIELD,
81cdf0e10cSrcweir 		FM_SUN_COMPONENT_HIDDENCONTROL,
82cdf0e10cSrcweir 		FM_SUN_COMPONENT_IMAGECONTROL
83cdf0e10cSrcweir 	};
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	static const sal_uInt16 nSvxComponentServiceNameListCount = sizeof(aSvxComponentServiceNameList) / sizeof ( aSvxComponentServiceNameList[0] );
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::rtl::OUString > aSeq( nSvxComponentServiceNameListCount );
88cdf0e10cSrcweir 	::rtl::OUString* pStrings = aSeq.getArray();
89cdf0e10cSrcweir 	for( sal_uInt16 nIdx = 0; nIdx < nSvxComponentServiceNameListCount; nIdx++ )
90cdf0e10cSrcweir 		pStrings[nIdx] = aSvxComponentServiceNameList[nIdx];
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::rtl::OUString > aParentSeq( SvxUnoDrawMSFactory::getAvailableServiceNames() );
93cdf0e10cSrcweir 	return concatServiceNames( aParentSeq, aSeq );
94cdf0e10cSrcweir }
95cdf0e10cSrcweir 
96cdf0e10cSrcweir /*
97cdf0e10cSrcweir // XServiceManager
98cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >  SvxFmDrawModel::createInstance(const ::rtl::OUString& ServiceName)
99cdf0e10cSrcweir 			const throw( ::com::sun::star::lang::ServiceNotRegisteredException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException )
100cdf0e10cSrcweir {
101cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >  xRet;
102cdf0e10cSrcweir 	sal_uInt16 nTokenCount = ServiceName.getTokenCount('.');
103cdf0e10cSrcweir 	if (nTokenCount == 5 &&
104cdf0e10cSrcweir 		ServiceName.getToken( 0, '.' ) == ::rtl::OUString::createFromAscii("stardiv") &&
105cdf0e10cSrcweir 		ServiceName.getToken( 1, '.' ) == ::rtl::OUString::createFromAscii("one") &&
106cdf0e10cSrcweir 		ServiceName.getToken( 2, '.' ) == ::rtl::OUString::createFromAscii("form") &&
107cdf0e10cSrcweir 		ServiceName.getToken( 3, '.' ) == ::rtl::OUString::createFromAscii("component"))
108cdf0e10cSrcweir 	{
109cdf0e10cSrcweir 		xRet = ::comphelper::getProcessServiceFactory()->createInstance(ServiceName);
110cdf0e10cSrcweir 	}
111cdf0e10cSrcweir 	else
112cdf0e10cSrcweir 	if (nTokenCount == 4 &&
113cdf0e10cSrcweir 		ServiceName.getToken( 0, '.' ) == ::rtl::OUString::createFromAscii("stardiv") &&
114cdf0e10cSrcweir 		ServiceName.getToken( 1, '.' ) == ::rtl::OUString::createFromAscii("one") &&
115cdf0e10cSrcweir 		ServiceName.getToken( 2, '.' ) == ::rtl::OUString::createFromAscii("drawing") &&
116cdf0e10cSrcweir 		ServiceName.getToken( 3, '.' ) == ::rtl::OUString::createFromAscii("ControlShape"))
117cdf0e10cSrcweir 	{
118cdf0e10cSrcweir 		SdrObject* pObj = new FmFormObj();
119cdf0e10cSrcweir 		xRet = *new SvxShapeControl(pObj);
120cdf0e10cSrcweir 	}
121cdf0e10cSrcweir 	if (!xRet.is())
122cdf0e10cSrcweir 		xRet = SvxUnoDrawModel::createInstance(ServiceName);
123cdf0e10cSrcweir 	return xRet;
124cdf0e10cSrcweir }
125cdf0e10cSrcweir */
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 
128