Update ooo320-m1
[ooovba.git] / svx / source / form / fmdmod.cxx
blob45a27a6122193a808f58c385859799c6cb64a6c1
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: fmdmod.cxx,v $
10 * $Revision: 1.12 $
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 <svx/fmdmod.hxx>
34 #include "fmservs.hxx"
35 #include <fmobj.hxx>
36 #include <svx/unoshape.hxx>
37 #include <comphelper/processfactory.hxx>
38 #include <svx/fmglob.hxx>
40 using namespace ::svxform;
42 //-----------------------------------------------------------------------------
43 ::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 )
45 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xRet;
46 if ( ServiceSpecifier.indexOf( ::rtl::OUString::createFromAscii("com.sun.star.form.component.") ) == 0 )
48 xRet = ::comphelper::getProcessServiceFactory()->createInstance(ServiceSpecifier);
50 else if ( ServiceSpecifier == ::rtl::OUString( ::rtl::OUString::createFromAscii("com.sun.star.drawing.ControlShape") ) )
52 SdrObject* pObj = new FmFormObj(OBJ_FM_CONTROL);
53 xRet = *new SvxShapeControl(pObj);
55 if (!xRet.is())
56 xRet = SvxUnoDrawMSFactory::createInstance(ServiceSpecifier);
57 return xRet;
60 //-----------------------------------------------------------------------------
61 ::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 )
63 return SvxUnoDrawMSFactory::createInstanceWithArguments(ServiceSpecifier, Arguments );
66 //-----------------------------------------------------------------------------
67 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL SvxFmMSFactory::getAvailableServiceNames(void) throw( ::com::sun::star::uno::RuntimeException )
69 static const ::rtl::OUString aSvxComponentServiceNameList[] =
71 FM_SUN_COMPONENT_TEXTFIELD,
72 FM_SUN_COMPONENT_FORM,
73 FM_SUN_COMPONENT_LISTBOX,
74 FM_SUN_COMPONENT_COMBOBOX,
75 FM_SUN_COMPONENT_RADIOBUTTON,
76 FM_SUN_COMPONENT_GROUPBOX,
77 FM_SUN_COMPONENT_FIXEDTEXT,
78 FM_SUN_COMPONENT_COMMANDBUTTON,
79 FM_SUN_COMPONENT_CHECKBOX,
80 FM_SUN_COMPONENT_GRIDCONTROL,
81 FM_SUN_COMPONENT_IMAGEBUTTON,
82 FM_SUN_COMPONENT_FILECONTROL,
83 FM_SUN_COMPONENT_TIMEFIELD,
84 FM_SUN_COMPONENT_DATEFIELD,
85 FM_SUN_COMPONENT_NUMERICFIELD,
86 FM_SUN_COMPONENT_CURRENCYFIELD,
87 FM_SUN_COMPONENT_PATTERNFIELD,
88 FM_SUN_COMPONENT_HIDDENCONTROL,
89 FM_SUN_COMPONENT_IMAGECONTROL
92 static const sal_uInt16 nSvxComponentServiceNameListCount = sizeof(aSvxComponentServiceNameList) / sizeof ( aSvxComponentServiceNameList[0] );
94 ::com::sun::star::uno::Sequence< ::rtl::OUString > aSeq( nSvxComponentServiceNameListCount );
95 ::rtl::OUString* pStrings = aSeq.getArray();
96 for( sal_uInt16 nIdx = 0; nIdx < nSvxComponentServiceNameListCount; nIdx++ )
97 pStrings[nIdx] = aSvxComponentServiceNameList[nIdx];
99 ::com::sun::star::uno::Sequence< ::rtl::OUString > aParentSeq( SvxUnoDrawMSFactory::getAvailableServiceNames() );
100 return concatServiceNames( aParentSeq, aSeq );
104 // XServiceManager
105 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SvxFmDrawModel::createInstance(const ::rtl::OUString& ServiceName)
106 const throw( ::com::sun::star::lang::ServiceNotRegisteredException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException )
108 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xRet;
109 sal_uInt16 nTokenCount = ServiceName.getTokenCount('.');
110 if (nTokenCount == 5 &&
111 ServiceName.getToken( 0, '.' ) == ::rtl::OUString::createFromAscii("stardiv") &&
112 ServiceName.getToken( 1, '.' ) == ::rtl::OUString::createFromAscii("one") &&
113 ServiceName.getToken( 2, '.' ) == ::rtl::OUString::createFromAscii("form") &&
114 ServiceName.getToken( 3, '.' ) == ::rtl::OUString::createFromAscii("component"))
116 xRet = ::comphelper::getProcessServiceFactory()->createInstance(ServiceName);
118 else
119 if (nTokenCount == 4 &&
120 ServiceName.getToken( 0, '.' ) == ::rtl::OUString::createFromAscii("stardiv") &&
121 ServiceName.getToken( 1, '.' ) == ::rtl::OUString::createFromAscii("one") &&
122 ServiceName.getToken( 2, '.' ) == ::rtl::OUString::createFromAscii("drawing") &&
123 ServiceName.getToken( 3, '.' ) == ::rtl::OUString::createFromAscii("ControlShape"))
125 SdrObject* pObj = new FmFormObj();
126 xRet = *new SvxShapeControl(pObj);
128 if (!xRet.is())
129 xRet = SvxUnoDrawModel::createInstance(ServiceName);
130 return xRet;