1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
21 #include "basdoc.hxx"
22 #include <iderdll.hxx>
23 #include <com/sun/star/io/IOException.hpp>
24 #include <comphelper/sequence.hxx>
25 #include <cppuhelper/queryinterface.hxx>
26 #include <cppuhelper/supportsservice.hxx>
27 #include <sfx2/objsh.hxx>
28 #include <vcl/svapp.hxx>
29
30 #include "unomodel.hxx"
31
32 namespace basctl
33 {
34
35 using namespace ::cppu;
36 using namespace ::std;
37 using namespace ::com::sun::star;
38 using namespace ::com::sun::star::uno;
39 using namespace ::com::sun::star::lang;
40
SIDEModel(SfxObjectShell * pObjSh)41 SIDEModel::SIDEModel( SfxObjectShell *pObjSh )
42 : SfxBaseModel(pObjSh)
43 {
44 }
45
~SIDEModel()46 SIDEModel::~SIDEModel()
47 {
48 }
49
queryInterface(const uno::Type & rType)50 uno::Any SAL_CALL SIDEModel::queryInterface( const uno::Type& rType )
51 {
52 uno::Any aRet = ::cppu::queryInterface ( rType,
53 // OWeakObject interfaces
54 static_cast< XInterface* >( static_cast< OWeakObject* >( this ) ),
55 static_cast< XWeak* > ( this ),
56 static_cast< XServiceInfo* > ( this ) );
57 if (!aRet.hasValue())
58 aRet = SfxBaseModel::queryInterface ( rType );
59 return aRet;
60 }
61
acquire()62 void SAL_CALL SIDEModel::acquire() throw()
63 {
64 SolarMutexGuard aGuard;
65 OWeakObject::acquire();
66 }
67
release()68 void SAL_CALL SIDEModel::release() throw()
69 {
70 SolarMutexGuard aGuard;
71 OWeakObject::release();
72 }
73
getTypes()74 uno::Sequence< uno::Type > SAL_CALL SIDEModel::getTypes( )
75 {
76 return comphelper::concatSequences(
77 SfxBaseModel::getTypes(),
78 uno::Sequence { cppu::UnoType<XServiceInfo>::get() });
79 }
80
getImplementationName()81 OUString SIDEModel::getImplementationName()
82 {
83 return getImplementationName_Static();
84 }
85
getImplementationName_Static()86 OUString SIDEModel::getImplementationName_Static()
87 {
88 return "com.sun.star.comp.basic.BasicIDE";
89 }
90
supportsService(const OUString & rServiceName)91 sal_Bool SIDEModel::supportsService(const OUString& rServiceName)
92 {
93 return cppu::supportsService(this, rServiceName);
94 }
getSupportedServiceNames()95 uno::Sequence< OUString > SIDEModel::getSupportedServiceNames()
96 {
97 return getSupportedServiceNames_Static();
98 }
99
getSupportedServiceNames_Static()100 uno::Sequence< OUString > SIDEModel::getSupportedServiceNames_Static()
101 {
102 return { "com.sun.star.script.BasicIDE" };
103 }
104
SIDEModel_createInstance(const uno::Reference<lang::XMultiServiceFactory> &)105 uno::Reference< uno::XInterface > SIDEModel_createInstance(
106 const uno::Reference< lang::XMultiServiceFactory > & )
107 {
108 SolarMutexGuard aGuard;
109 EnsureIde();
110 SfxObjectShell* pShell = new DocShell();
111 return uno::Reference< uno::XInterface >( pShell->GetModel() );
112 }
113
114 // XStorable
store()115 void SAL_CALL SIDEModel::store()
116 {
117 notImplemented();
118 }
119
storeAsURL(const OUString &,const uno::Sequence<beans::PropertyValue> &)120 void SAL_CALL SIDEModel::storeAsURL( const OUString&, const uno::Sequence< beans::PropertyValue >& )
121 {
122 notImplemented();
123 }
124
storeToURL(const OUString &,const uno::Sequence<beans::PropertyValue> &)125 void SAL_CALL SIDEModel::storeToURL( const OUString&,
126 const uno::Sequence< beans::PropertyValue >& )
127 {
128 notImplemented();
129 }
130
notImplemented()131 void SIDEModel::notImplemented()
132 {
133 throw io::IOException("Can't store IDE model" );
134 }
135
136 } // namespace basctl
137
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
139