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