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