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_basctl.hxx"
30 
31 #include "unomodel.hxx"
32 #include <vos/mutex.hxx>
33 #include <vcl/svapp.hxx>
34 
35 #include <sfx2/docfac.hxx>
36 #include <sfx2/objsh.hxx>
37 
38 #include <iderdll.hxx>
39 #include <basdoc.hxx>
40 
41 using namespace ::vos;
42 using ::rtl::OUString;
43 using namespace ::cppu;
44 using namespace ::std;
45 using namespace ::com::sun::star;
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::lang;
48 
49 SIDEModel::SIDEModel( SfxObjectShell *pObjSh )
50 : SfxBaseModel(pObjSh)
51 {
52 }
53 
54 SIDEModel::~SIDEModel()
55 {
56 }
57 
58 uno::Any SAL_CALL SIDEModel::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
59 {
60     uno::Any aRet =  ::cppu::queryInterface ( rType,
61 									// OWeakObject interfaces
62 									static_cast< XInterface* >( static_cast< OWeakObject* >( this ) ),
63                                     static_cast< XWeak* > ( this ),
64                                     static_cast< XServiceInfo*  > ( this ) );
65 	if (!aRet.hasValue())
66 		aRet = SfxBaseModel::queryInterface ( rType );
67 	return aRet;
68 }
69 
70 void SAL_CALL SIDEModel::acquire() throw()
71 {
72 	::vos::OGuard aGuard(Application::GetSolarMutex());
73 	OWeakObject::acquire();
74 }
75 
76 void SAL_CALL SIDEModel::release() throw()
77 {
78 	::vos::OGuard aGuard(Application::GetSolarMutex());
79 	OWeakObject::release();
80 }
81 
82 uno::Sequence< uno::Type > SAL_CALL SIDEModel::getTypes(  ) throw(uno::RuntimeException)
83 {
84     uno::Sequence< uno::Type > aTypes = SfxBaseModel::getTypes();
85     sal_Int32 nLen = aTypes.getLength();
86     aTypes.realloc(nLen + 1);
87     uno::Type* pTypes = aTypes.getArray();
88     pTypes[nLen++] = ::getCppuType((Reference<XServiceInfo>*)0);
89 
90     return aTypes;
91 }
92 
93 OUString SIDEModel::getImplementationName(void) throw( uno::RuntimeException )
94 {
95 	return getImplementationName_Static();
96 }
97 
98 ::rtl::OUString SIDEModel::getImplementationName_Static()
99 {
100 	return rtl::OUString::createFromAscii("com.sun.star.comp.basic.BasicIDE");
101 }
102 
103 sal_Bool SIDEModel::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
104 {
105 	return rServiceName == ::rtl::OUString::createFromAscii("com.sun.star.script.BasicIDE");
106 }
107 uno::Sequence< OUString > SIDEModel::getSupportedServiceNames(void) throw( uno::RuntimeException )
108 {
109 	return getSupportedServiceNames_Static();
110 }
111 
112 uno::Sequence< OUString > SIDEModel::getSupportedServiceNames_Static(void)
113 {
114 	uno::Sequence< OUString > aRet(1);
115 	OUString* pArray = aRet.getArray();
116 	pArray[0] = ::rtl::OUString::createFromAscii("com.sun.star.script.BasicIDE");
117 	return aRet;
118 }
119 
120 uno::Reference< uno::XInterface > SAL_CALL SIDEModel_createInstance(
121 				const uno::Reference< lang::XMultiServiceFactory > & ) throw( uno::Exception )
122 {
123     ::vos::OGuard aGuard( Application::GetSolarMutex() );
124 	BasicIDEDLL::Init();
125 	SfxObjectShell* pShell = new BasicDocShell();
126 	return uno::Reference< uno::XInterface >( pShell->GetModel() );
127 }
128 
129