1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <com/sun/star/frame/XDesktop.hpp>
30 #include <com/sun/star/script/XLibraryContainer.hpp>
31 #include <com/sun/star/uno/Reference.h>
32 #include <basic/basrdll.hxx>
33 #include <officecfg/Office/Common.hxx>
34 #include <svl/macitem.hxx>
35 #include <basic/sbxfac.hxx>
36 #include <basic/sbx.hxx>
37 #include <vcl/gradient.hxx>
38 #include <svl/rectitem.hxx>
39 #include <svl/intitem.hxx>
40 #include <svl/eitem.hxx>
41 #include <basic/sbmod.hxx>
42 #include <svl/whiter.hxx>
43 #include <basic/sbmeth.hxx>
44 #include <basic/sbstar.hxx>
45 #include <vcl/wrkwin.hxx>
46 #include <vcl/msgbox.hxx>
47 #include <basic/sbuno.hxx>
48 #include <svtools/sfxecode.hxx>
49 #include <svtools/ehdl.hxx>
51 #include <unotools/pathoptions.hxx>
52 #include <unotools/useroptions.hxx>
53 #include <unotools/bootstrap.hxx>
55 #include <sfx2/appuno.hxx>
56 #include <sfx2/module.hxx>
57 #include "arrdecl.hxx"
58 #include <sfx2/app.hxx>
59 #include "sfxtypes.hxx"
60 #include "sfx2/sfxresid.hxx"
61 #include <sfx2/msg.hxx>
62 #include <sfx2/msgpool.hxx>
63 #include <sfx2/progress.hxx>
64 #include <sfx2/objsh.hxx>
65 #include <sfx2/objitem.hxx>
66 #include <sfx2/viewfrm.hxx>
67 #include <sfx2/viewsh.hxx>
68 #include <sfx2/dispatch.hxx>
69 #include "sfx2/tplpitem.hxx"
70 #include "sfx2/minfitem.hxx"
72 #include <sfx2/evntconf.hxx>
73 #include <sfx2/request.hxx>
74 #include <sfx2/dinfdlg.hxx>
75 #include "appdata.hxx"
77 #include "sfx2/sfxhelp.hxx"
78 #include "sfx2/basmgr.hxx"
79 #include "sorgitm.hxx"
80 #include "appbaslib.hxx"
81 #include <basic/basicmanagerrepository.hxx>
83 #define ITEMID_SEARCH SID_SEARCH_ITEM
85 #include <svl/srchitem.hxx>
86 #include <osl/socket.hxx>
88 #if defined(LIBO_MERGELIBS) || defined(IOS)
89 /* Avoid clash with the ones from svx/source/form/typemap.cxx */
90 #define aSfxBoolItem_Impl sfx2_source_appl_appbas_aSfxBoolItem_Impl
92 #define aSfxInt16Item_Impl sfx2_source_appl_appbas_aSfxInt16Item_Impl
94 #define aSfxStringItem_Impl sfx2_source_appl_appbas_aSfxStringItem_Impl
95 #define aSfxUInt16Item_Impl sfx2_source_appl_appbas_aSfxUInt16Item_Impl
96 #define aSfxUInt32Item_Impl sfx2_source_appl_appbas_aSfxUInt32Item_Impl
97 #define aSfxVoidItem_Impl sfx2_source_appl_appbas_aSfxVoidtem_Impl
102 #include "sfxslots.hxx"
104 #if defined(LIBO_MERGELIBS) || defined(IOS)
105 #undef aSfxBoolItem_Impl
107 #undef aSfxInt16Item_Impl
109 #undef aSfxStringItem_Impl
110 #undef aSfxUInt16Item_Impl
111 #undef aSfxUInt32Item_Impl
112 #undef aSfxVoidItem_Impl
115 using namespace ::com::sun::star
;
116 using namespace ::com::sun::star::uno
;
117 using namespace ::com::sun::star::frame
;
118 using namespace ::com::sun::star::script
;
120 using ::basic::BasicManagerRepository
;
122 //=========================================================================
123 sal_uInt16
SfxApplication::SaveBasicManager() const
128 //--------------------------------------------------------------------
129 sal_uInt16
SfxApplication::SaveBasicAndDialogContainer() const
131 if ( pAppData_Impl
->pBasicManager
->isValid() )
132 pAppData_Impl
->pBasicManager
->storeAllLibraries();
136 //--------------------------------------------------------------------
138 SbxVariable
* MakeVariable( StarBASIC
*pBas
, SbxObject
*pObject
,
139 const char *pName
, sal_uInt32 nSID
, SbxDataType eType
, SbxClassType eClassType
)
141 #ifdef DISABLE_SCRIPTING
150 SbxVariable
*pVar
= pBas
->Make( String::CreateFromAscii(pName
), eClassType
, eType
); //SbxCLASS_PROPERTY
151 pVar
->SetUserData( nSID
);
152 pVar
->SetFlag( SBX_DONTSTORE
);
153 pObject
->StartListening( pVar
->GetBroadcaster() );
158 //--------------------------------------------------------------------
160 BasicManager
* SfxApplication::GetBasicManager()
162 #ifdef DISABLE_SCRIPTING
165 return BasicManagerRepository::getApplicationBasicManager( true );
169 //--------------------------------------------------------------------
171 Reference
< XLibraryContainer
> SfxApplication::GetDialogContainer()
173 #ifdef DISABLE_SCRIPTING
174 Reference
< XLibraryContainer
> dummy
;
177 if ( !pAppData_Impl
->pBasicManager
->isValid() )
179 return pAppData_Impl
->pBasicManager
->getLibraryContainer( SfxBasicManagerHolder::DIALOGS
);
183 //--------------------------------------------------------------------
185 Reference
< XLibraryContainer
> SfxApplication::GetBasicContainer()
187 #ifdef DISABLE_SCRIPTING
188 Reference
< XLibraryContainer
> dummy
;
191 if ( !pAppData_Impl
->pBasicManager
->isValid() )
193 return pAppData_Impl
->pBasicManager
->getLibraryContainer( SfxBasicManagerHolder::SCRIPTS
);
197 //--------------------------------------------------------------------
199 StarBASIC
* SfxApplication::GetBasic()
201 #ifdef DISABLE_SCRIPTING
204 return GetBasicManager()->GetLib(0);
208 //-------------------------------------------------------------------------
209 void SfxApplication::PropExec_Impl( SfxRequest
&rReq
)
211 #ifdef DISABLE_SCRIPTING
215 sal_uInt16 nSID
= rReq
.GetSlot();
218 case SID_CREATE_BASICOBJECT
:
220 SFX_REQUEST_ARG(rReq
, pItem
, SfxStringItem
, nSID
, sal_False
);
223 SbxObject
* pObject
= SbxBase::CreateObject( pItem
->GetValue() );
230 case SID_DELETE_BASICOBJECT
:
235 case SID_ATTR_UNDO_COUNT
:
237 SFX_REQUEST_ARG(rReq
, pCountItem
, SfxUInt16Item
, nSID
, sal_False
);
238 boost::shared_ptr
< comphelper::ConfigurationChanges
> batch(
239 comphelper::ConfigurationChanges::create());
240 officecfg::Office::Common::Undo::Steps::set(
241 pCountItem
->GetValue(), batch
);
246 case SID_WIN_VISIBLE
:
251 case SID_STATUSBARTEXT
:
253 SFX_REQUEST_ARG(rReq
, pStringItem
, SfxStringItem
, nSID
, sal_False
);
254 String aText
= pStringItem
->GetValue();
256 GetpApp()->ShowStatusText( aText
);
258 GetpApp()->HideStatusText();
262 case SID_OFFICE_PRIVATE_USE
:
263 case SID_OFFICE_COMMERCIAL_USE
:
265 DBG_ASSERT( sal_False
, "SfxApplication::PropExec_Impl()\nSID_OFFICE_PRIVATE_USE & SID_OFFICE_COMMERCIAL_USE are obsolete!\n" );
269 case SID_OFFICE_CUSTOMERNUMBER
:
271 SFX_REQUEST_ARG(rReq
, pStringItem
, SfxStringItem
, nSID
, sal_False
);
274 SvtUserOptions().SetCustomerNumber( pStringItem
->GetValue() );
281 //-------------------------------------------------------------------------
282 void SfxApplication::PropState_Impl( SfxItemSet
&rSet
)
284 #ifdef DISABLE_SCRIPTING
287 SfxWhichIter
aIter(rSet
);
288 for ( sal_uInt16 nSID
= aIter
.FirstWhich(); nSID
; nSID
= aIter
.NextWhich() )
293 rSet
.Put( SfxStringItem( SID_PROGNAME
, GetName() ) );
296 case SID_ACTIVEDOCUMENT
:
297 rSet
.Put( SfxObjectItem( SID_ACTIVEDOCUMENT
, SfxObjectShell::Current() ) );
300 case SID_APPLICATION
:
301 rSet
.Put( SfxObjectItem( SID_APPLICATION
, this ) );
304 case SID_PROGFILENAME
:
305 rSet
.Put( SfxStringItem( SID_PROGFILENAME
, Application::GetAppFileName() ) );
308 case SID_ATTR_UNDO_COUNT
:
312 officecfg::Office::Common::Undo::Steps::get()));
315 case SID_UPDATE_VERSION
:
316 rSet
.Put( SfxUInt32Item( SID_UPDATE_VERSION
, SUPD
) );
319 case SID_OFFICE_CUSTOMERNUMBER
:
321 rSet
.Put( SfxStringItem( nSID
, SvtUserOptions().GetCustomerNumber() ) );
329 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */