Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / svx / source / form / fmdmod.cxx
bloba9a1b5e5053fcd03a86e508f97d7329924f31128
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/macros.h>
21 #include <svx/fmdmod.hxx>
22 #include "fmservs.hxx"
23 #include <fmobj.hxx>
24 #include <svx/unoshape.hxx>
25 #include <comphelper/processfactory.hxx>
26 #include <svx/fmglob.hxx>
28 using namespace ::svxform;
31 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvxFmMSFactory::createInstance(const OUString& rServiceSpecifier) throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception )
33 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xRet;
34 if ( rServiceSpecifier.startsWith( "com.sun.star.form.component." ) )
36 css::uno::Reference<css::uno::XComponentContext> xContext = comphelper::getProcessComponentContext();
37 xRet = xContext->getServiceManager()->createInstanceWithContext(rServiceSpecifier, xContext);
39 else if ( rServiceSpecifier == "com.sun.star.drawing.ControlShape" )
41 SdrObject* pObj = new FmFormObj();
42 xRet = static_cast<cppu::OWeakObject*>(static_cast<SvxShape_UnoImplHelper*>(new SvxShapeControl(pObj)));
44 if (!xRet.is())
45 xRet = SvxUnoDrawMSFactory::createInstance(rServiceSpecifier);
46 return xRet;
51 // Encapsulation violation: We *know* that
52 // SvxUnoDrawMSFactory::createInstanceWithArguments() always throws.
54 SAL_WNOUNREACHABLE_CODE_PUSH
56 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvxFmMSFactory::createInstanceWithArguments(const 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, std::exception )
58 return SvxUnoDrawMSFactory::createInstanceWithArguments(ServiceSpecifier, Arguments );
61 SAL_WNOUNREACHABLE_CODE_POP
64 ::com::sun::star::uno::Sequence< OUString > SAL_CALL SvxFmMSFactory::getAvailableServiceNames(void) throw( ::com::sun::star::uno::RuntimeException, std::exception )
66 static const OUString aSvxComponentServiceNameList[] =
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
89 static const sal_uInt16 nSvxComponentServiceNameListCount = sizeof(aSvxComponentServiceNameList) / sizeof ( aSvxComponentServiceNameList[0] );
91 ::com::sun::star::uno::Sequence< OUString > aSeq( nSvxComponentServiceNameListCount );
92 OUString* pStrings = aSeq.getArray();
93 for( sal_uInt16 nIdx = 0; nIdx < nSvxComponentServiceNameListCount; nIdx++ )
94 pStrings[nIdx] = aSvxComponentServiceNameList[nIdx];
96 ::com::sun::star::uno::Sequence< OUString > aParentSeq( SvxUnoDrawMSFactory::getAvailableServiceNames() );
97 return concatServiceNames( aParentSeq, aSeq );
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */