merge the formfield patch from ooo-build
[ooovba.git] / basctl / source / basicide / unomodel.cxx
blobce69e3da0d0e31d17b59d980155d00c3c7f50913
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: unomodel.cxx,v $
10 * $Revision: 1.9 $
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_basctl.hxx"
34 #include "unomodel.hxx"
35 #include <vos/mutex.hxx>
36 #include <vcl/svapp.hxx>
38 #include <sfx2/docfac.hxx>
39 #include <sfx2/objsh.hxx>
41 #include <iderdll.hxx>
42 #include <basdoc.hxx>
44 using namespace ::vos;
45 using ::rtl::OUString;
46 using namespace ::cppu;
47 using namespace ::std;
48 using namespace ::com::sun::star;
49 using namespace ::com::sun::star::uno;
50 using namespace ::com::sun::star::lang;
52 SIDEModel::SIDEModel( SfxObjectShell *pObjSh )
53 : SfxBaseModel(pObjSh)
57 SIDEModel::~SIDEModel()
61 uno::Any SAL_CALL SIDEModel::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
63 uno::Any aRet = ::cppu::queryInterface ( rType,
64 // OWeakObject interfaces
65 static_cast< XInterface* >( static_cast< OWeakObject* >( this ) ),
66 static_cast< XWeak* > ( this ),
67 static_cast< XServiceInfo* > ( this ) );
68 if (!aRet.hasValue())
69 aRet = SfxBaseModel::queryInterface ( rType );
70 return aRet;
73 void SAL_CALL SIDEModel::acquire() throw()
75 ::vos::OGuard aGuard(Application::GetSolarMutex());
76 OWeakObject::acquire();
79 void SAL_CALL SIDEModel::release() throw()
81 ::vos::OGuard aGuard(Application::GetSolarMutex());
82 OWeakObject::release();
85 uno::Sequence< uno::Type > SAL_CALL SIDEModel::getTypes( ) throw(uno::RuntimeException)
87 uno::Sequence< uno::Type > aTypes = SfxBaseModel::getTypes();
88 sal_Int32 nLen = aTypes.getLength();
89 aTypes.realloc(nLen + 1);
90 uno::Type* pTypes = aTypes.getArray();
91 pTypes[nLen++] = ::getCppuType((Reference<XServiceInfo>*)0);
93 return aTypes;
96 OUString SIDEModel::getImplementationName(void) throw( uno::RuntimeException )
98 return getImplementationName_Static();
101 ::rtl::OUString SIDEModel::getImplementationName_Static()
103 return rtl::OUString::createFromAscii("com.sun.star.comp.basic.BasicIDE");
106 sal_Bool SIDEModel::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
108 return rServiceName == ::rtl::OUString::createFromAscii("com.sun.star.script.BasicIDE");
110 uno::Sequence< OUString > SIDEModel::getSupportedServiceNames(void) throw( uno::RuntimeException )
112 return getSupportedServiceNames_Static();
115 uno::Sequence< OUString > SIDEModel::getSupportedServiceNames_Static(void)
117 uno::Sequence< OUString > aRet(1);
118 OUString* pArray = aRet.getArray();
119 pArray[0] = ::rtl::OUString::createFromAscii("com.sun.star.script.BasicIDE");
120 return aRet;
123 uno::Reference< uno::XInterface > SAL_CALL SIDEModel_createInstance(
124 const uno::Reference< lang::XMultiServiceFactory > & ) throw( uno::Exception )
126 ::vos::OGuard aGuard( Application::GetSolarMutex() );
127 BasicIDEDLL::Init();
128 SfxObjectShell* pShell = new BasicDocShell();
129 return uno::Reference< uno::XInterface >( pShell->GetModel() );