1*31598a22SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*31598a22SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*31598a22SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*31598a22SAndrew Rist * distributed with this work for additional information 6*31598a22SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*31598a22SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*31598a22SAndrew Rist * "License"); you may not use this file except in compliance 9*31598a22SAndrew Rist * with the License. You may obtain a copy of the License at 10*31598a22SAndrew Rist * 11*31598a22SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*31598a22SAndrew Rist * 13*31598a22SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*31598a22SAndrew Rist * software distributed under the License is distributed on an 15*31598a22SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*31598a22SAndrew Rist * KIND, either express or implied. See the License for the 17*31598a22SAndrew Rist * specific language governing permissions and limitations 18*31598a22SAndrew Rist * under the License. 19*31598a22SAndrew Rist * 20*31598a22SAndrew Rist *************************************************************/ 21*31598a22SAndrew Rist 22*31598a22SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_basctl.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "unomodel.hxx" 28cdf0e10cSrcweir #include <vos/mutex.hxx> 29cdf0e10cSrcweir #include <vcl/svapp.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <sfx2/docfac.hxx> 32cdf0e10cSrcweir #include <sfx2/objsh.hxx> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include <iderdll.hxx> 35cdf0e10cSrcweir #include <basdoc.hxx> 36cdf0e10cSrcweir 37cdf0e10cSrcweir using namespace ::vos; 38cdf0e10cSrcweir using ::rtl::OUString; 39cdf0e10cSrcweir using namespace ::cppu; 40cdf0e10cSrcweir using namespace ::std; 41cdf0e10cSrcweir using namespace ::com::sun::star; 42cdf0e10cSrcweir using namespace ::com::sun::star::uno; 43cdf0e10cSrcweir using namespace ::com::sun::star::lang; 44cdf0e10cSrcweir SIDEModel(SfxObjectShell * pObjSh)45cdf0e10cSrcweirSIDEModel::SIDEModel( SfxObjectShell *pObjSh ) 46cdf0e10cSrcweir : SfxBaseModel(pObjSh) 47cdf0e10cSrcweir { 48cdf0e10cSrcweir } 49cdf0e10cSrcweir ~SIDEModel()50cdf0e10cSrcweirSIDEModel::~SIDEModel() 51cdf0e10cSrcweir { 52cdf0e10cSrcweir } 53cdf0e10cSrcweir queryInterface(const uno::Type & rType)54cdf0e10cSrcweiruno::Any SAL_CALL SIDEModel::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException) 55cdf0e10cSrcweir { 56cdf0e10cSrcweir uno::Any aRet = ::cppu::queryInterface ( rType, 57cdf0e10cSrcweir // OWeakObject interfaces 58cdf0e10cSrcweir static_cast< XInterface* >( static_cast< OWeakObject* >( this ) ), 59cdf0e10cSrcweir static_cast< XWeak* > ( this ), 60cdf0e10cSrcweir static_cast< XServiceInfo* > ( this ) ); 61cdf0e10cSrcweir if (!aRet.hasValue()) 62cdf0e10cSrcweir aRet = SfxBaseModel::queryInterface ( rType ); 63cdf0e10cSrcweir return aRet; 64cdf0e10cSrcweir } 65cdf0e10cSrcweir acquire()66cdf0e10cSrcweirvoid SAL_CALL SIDEModel::acquire() throw() 67cdf0e10cSrcweir { 68cdf0e10cSrcweir ::vos::OGuard aGuard(Application::GetSolarMutex()); 69cdf0e10cSrcweir OWeakObject::acquire(); 70cdf0e10cSrcweir } 71cdf0e10cSrcweir release()72cdf0e10cSrcweirvoid SAL_CALL SIDEModel::release() throw() 73cdf0e10cSrcweir { 74cdf0e10cSrcweir ::vos::OGuard aGuard(Application::GetSolarMutex()); 75cdf0e10cSrcweir OWeakObject::release(); 76cdf0e10cSrcweir } 77cdf0e10cSrcweir getTypes()78cdf0e10cSrcweiruno::Sequence< uno::Type > SAL_CALL SIDEModel::getTypes( ) throw(uno::RuntimeException) 79cdf0e10cSrcweir { 80cdf0e10cSrcweir uno::Sequence< uno::Type > aTypes = SfxBaseModel::getTypes(); 81cdf0e10cSrcweir sal_Int32 nLen = aTypes.getLength(); 82cdf0e10cSrcweir aTypes.realloc(nLen + 1); 83cdf0e10cSrcweir uno::Type* pTypes = aTypes.getArray(); 84cdf0e10cSrcweir pTypes[nLen++] = ::getCppuType((Reference<XServiceInfo>*)0); 85cdf0e10cSrcweir 86cdf0e10cSrcweir return aTypes; 87cdf0e10cSrcweir } 88cdf0e10cSrcweir getImplementationName(void)89cdf0e10cSrcweirOUString SIDEModel::getImplementationName(void) throw( uno::RuntimeException ) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir return getImplementationName_Static(); 92cdf0e10cSrcweir } 93cdf0e10cSrcweir getImplementationName_Static()94cdf0e10cSrcweir::rtl::OUString SIDEModel::getImplementationName_Static() 95cdf0e10cSrcweir { 96cdf0e10cSrcweir return rtl::OUString::createFromAscii("com.sun.star.comp.basic.BasicIDE"); 97cdf0e10cSrcweir } 98cdf0e10cSrcweir supportsService(const OUString & rServiceName)99cdf0e10cSrcweirsal_Bool SIDEModel::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) 100cdf0e10cSrcweir { 101cdf0e10cSrcweir return rServiceName == ::rtl::OUString::createFromAscii("com.sun.star.script.BasicIDE"); 102cdf0e10cSrcweir } getSupportedServiceNames(void)103cdf0e10cSrcweiruno::Sequence< OUString > SIDEModel::getSupportedServiceNames(void) throw( uno::RuntimeException ) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir return getSupportedServiceNames_Static(); 106cdf0e10cSrcweir } 107cdf0e10cSrcweir getSupportedServiceNames_Static(void)108cdf0e10cSrcweiruno::Sequence< OUString > SIDEModel::getSupportedServiceNames_Static(void) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir uno::Sequence< OUString > aRet(1); 111cdf0e10cSrcweir OUString* pArray = aRet.getArray(); 112cdf0e10cSrcweir pArray[0] = ::rtl::OUString::createFromAscii("com.sun.star.script.BasicIDE"); 113cdf0e10cSrcweir return aRet; 114cdf0e10cSrcweir } 115cdf0e10cSrcweir SIDEModel_createInstance(const uno::Reference<lang::XMultiServiceFactory> &)116cdf0e10cSrcweiruno::Reference< uno::XInterface > SAL_CALL SIDEModel_createInstance( 117cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory > & ) throw( uno::Exception ) 118cdf0e10cSrcweir { 119cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 120cdf0e10cSrcweir BasicIDEDLL::Init(); 121cdf0e10cSrcweir SfxObjectShell* pShell = new BasicDocShell(); 122cdf0e10cSrcweir return uno::Reference< uno::XInterface >( pShell->GetModel() ); 123cdf0e10cSrcweir } 124cdf0e10cSrcweir 125