1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <com/sun/star/frame/XDesktop.hpp>
21 #include <com/sun/star/script/XLibraryContainer.hpp>
22 #include <com/sun/star/uno/Reference.h>
23 #include <basic/basrdll.hxx>
24 #include <officecfg/Office/Common.hxx>
25 #include <svl/macitem.hxx>
26 #include <basic/sbxfac.hxx>
27 #include <basic/sbx.hxx>
28 #include <vcl/gradient.hxx>
29 #include <svl/rectitem.hxx>
30 #include <svl/intitem.hxx>
31 #include <svl/eitem.hxx>
32 #include <basic/sbmod.hxx>
33 #include <svl/whiter.hxx>
34 #include <basic/sbmeth.hxx>
35 #include <basic/sbstar.hxx>
36 #include <vcl/wrkwin.hxx>
37 #include <vcl/msgbox.hxx>
38 #include <basic/sbuno.hxx>
39 #include <svtools/sfxecode.hxx>
40 #include <svtools/ehdl.hxx>
42 #include <unotools/pathoptions.hxx>
43 #include <unotools/useroptions.hxx>
44 #include <unotools/bootstrap.hxx>
46 #include <sfx2/appuno.hxx>
47 #include <sfx2/module.hxx>
48 #include "arrdecl.hxx"
49 #include <sfx2/app.hxx>
50 #include "sfxtypes.hxx"
51 #include <sfx2/sfxresid.hxx>
52 #include <sfx2/msg.hxx>
53 #include <sfx2/msgpool.hxx>
54 #include <sfx2/progress.hxx>
55 #include <sfx2/objsh.hxx>
56 #include <sfx2/objitem.hxx>
57 #include <sfx2/viewfrm.hxx>
58 #include <sfx2/viewsh.hxx>
59 #include <sfx2/dispatch.hxx>
60 #include <sfx2/tplpitem.hxx>
61 #include <sfx2/minfitem.hxx>
63 #include <sfx2/evntconf.hxx>
64 #include <sfx2/request.hxx>
65 #include <sfx2/dinfdlg.hxx>
66 #include "appdata.hxx"
68 #include <sfx2/sfxhelp.hxx>
69 #include <basic/basmgr.hxx>
70 #include <svtools/svtools.hrc>
71 #include "sorgitm.hxx"
72 #include "appbaslib.hxx"
73 #include <basic/basicmanagerrepository.hxx>
75 #include <svl/srchitem.hxx>
76 #include <osl/socket.hxx>
79 #include "sfxslots.hxx"
81 using namespace ::com::sun::star
;
82 using namespace ::com::sun::star::uno
;
83 using namespace ::com::sun::star::frame
;
84 using namespace ::com::sun::star::script
;
86 using ::basic::BasicManagerRepository
;
88 //=========================================================================
89 sal_uInt16
SfxApplication::SaveBasicAndDialogContainer() const
91 if ( pAppData_Impl
->pBasicManager
->isValid() )
92 pAppData_Impl
->pBasicManager
->storeAllLibraries();
96 //--------------------------------------------------------------------
98 SbxVariable
* MakeVariable( StarBASIC
*pBas
, SbxObject
*pObject
,
99 const char *pName
, sal_uInt32 nSID
, SbxDataType eType
, SbxClassType eClassType
)
101 #ifdef DISABLE_SCRIPTING
110 SbxVariable
*pVar
= pBas
->Make( OUString::createFromAscii(pName
), eClassType
, eType
); //SbxCLASS_PROPERTY
111 pVar
->SetUserData( nSID
);
112 pVar
->SetFlag( SBX_DONTSTORE
);
113 pObject
->StartListening( pVar
->GetBroadcaster() );
118 //--------------------------------------------------------------------
120 BasicManager
* SfxApplication::GetBasicManager()
122 #ifdef DISABLE_SCRIPTING
125 return BasicManagerRepository::getApplicationBasicManager( true );
129 //--------------------------------------------------------------------
131 Reference
< XLibraryContainer
> SfxApplication::GetDialogContainer()
133 #ifdef DISABLE_SCRIPTING
134 Reference
< XLibraryContainer
> dummy
;
137 if ( !pAppData_Impl
->pBasicManager
->isValid() )
139 return pAppData_Impl
->pBasicManager
->getLibraryContainer( SfxBasicManagerHolder::DIALOGS
);
143 //--------------------------------------------------------------------
145 Reference
< XLibraryContainer
> SfxApplication::GetBasicContainer()
147 #ifdef DISABLE_SCRIPTING
148 Reference
< XLibraryContainer
> dummy
;
151 if ( !pAppData_Impl
->pBasicManager
->isValid() )
153 return pAppData_Impl
->pBasicManager
->getLibraryContainer( SfxBasicManagerHolder::SCRIPTS
);
157 //--------------------------------------------------------------------
159 StarBASIC
* SfxApplication::GetBasic()
161 #ifdef DISABLE_SCRIPTING
164 return GetBasicManager()->GetLib(0);
168 //-------------------------------------------------------------------------
169 void SfxApplication::PropExec_Impl( SfxRequest
&rReq
)
171 #ifdef DISABLE_SCRIPTING
175 sal_uInt16 nSID
= rReq
.GetSlot();
178 case SID_CREATE_BASICOBJECT
:
180 SFX_REQUEST_ARG(rReq
, pItem
, SfxStringItem
, nSID
, sal_False
);
183 SbxObject
* pObject
= SbxBase::CreateObject( pItem
->GetValue() );
190 case SID_DELETE_BASICOBJECT
:
195 case SID_ATTR_UNDO_COUNT
:
197 SFX_REQUEST_ARG(rReq
, pCountItem
, SfxUInt16Item
, nSID
, sal_False
);
198 boost::shared_ptr
< comphelper::ConfigurationChanges
> batch(
199 comphelper::ConfigurationChanges::create());
200 officecfg::Office::Common::Undo::Steps::set(
201 pCountItem
->GetValue(), batch
);
206 case SID_WIN_VISIBLE
:
211 case SID_OFFICE_CUSTOMERNUMBER
:
213 SFX_REQUEST_ARG(rReq
, pStringItem
, SfxStringItem
, nSID
, sal_False
);
216 SvtUserOptions().SetCustomerNumber( pStringItem
->GetValue() );
223 //-------------------------------------------------------------------------
224 void SfxApplication::PropState_Impl( SfxItemSet
&rSet
)
226 #ifdef DISABLE_SCRIPTING
229 SfxWhichIter
aIter(rSet
);
230 for ( sal_uInt16 nSID
= aIter
.FirstWhich(); nSID
; nSID
= aIter
.NextWhich() )
235 rSet
.Put( SfxStringItem( SID_PROGNAME
, GetName() ) );
238 case SID_ACTIVEDOCUMENT
:
239 rSet
.Put( SfxObjectItem( SID_ACTIVEDOCUMENT
, SfxObjectShell::Current() ) );
242 case SID_APPLICATION
:
243 rSet
.Put( SfxObjectItem( SID_APPLICATION
, this ) );
246 case SID_PROGFILENAME
:
247 rSet
.Put( SfxStringItem( SID_PROGFILENAME
, Application::GetAppFileName() ) );
250 case SID_ATTR_UNDO_COUNT
:
254 officecfg::Office::Common::Undo::Steps::get()));
257 case SID_UPDATE_VERSION
:
258 rSet
.Put( SfxUInt32Item( SID_UPDATE_VERSION
, SUPD
) );
261 case SID_OFFICE_CUSTOMERNUMBER
:
263 rSet
.Put( SfxStringItem( nSID
, SvtUserOptions().GetCustomerNumber() ) );
271 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */