bump product version to 4.2.0.1
[LibreOffice.git] / sfx2 / source / appl / appbas.cxx
blob1a5153943153923d05f87ec37f2dbe72e033693e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
62 #include "app.hrc"
63 #include <sfx2/evntconf.hxx>
64 #include <sfx2/request.hxx>
65 #include <sfx2/dinfdlg.hxx>
66 #include "appdata.hxx"
67 #include "appbas.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>
78 #define SFX_TYPEMAP
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();
93 return 0;
96 //--------------------------------------------------------------------
98 SbxVariable* MakeVariable( StarBASIC *pBas, SbxObject *pObject,
99 const char *pName, sal_uInt32 nSID, SbxDataType eType, SbxClassType eClassType )
101 #ifdef DISABLE_SCRIPTING
102 (void) pBas;
103 (void) pObject;
104 (void) pName;
105 (void) nSID;
106 (void) eType;
107 (void) eClassType;
108 return 0;
109 #else
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() );
114 return pVar;
115 #endif
118 //--------------------------------------------------------------------
120 BasicManager* SfxApplication::GetBasicManager()
122 #ifdef DISABLE_SCRIPTING
123 return 0;
124 #else
125 return BasicManagerRepository::getApplicationBasicManager( true );
126 #endif
129 //--------------------------------------------------------------------
131 Reference< XLibraryContainer > SfxApplication::GetDialogContainer()
133 #ifdef DISABLE_SCRIPTING
134 Reference< XLibraryContainer > dummy;
135 return dummy;
136 #else
137 if ( !pAppData_Impl->pBasicManager->isValid() )
138 GetBasicManager();
139 return pAppData_Impl->pBasicManager->getLibraryContainer( SfxBasicManagerHolder::DIALOGS );
140 #endif
143 //--------------------------------------------------------------------
145 Reference< XLibraryContainer > SfxApplication::GetBasicContainer()
147 #ifdef DISABLE_SCRIPTING
148 Reference< XLibraryContainer > dummy;
149 return dummy;
150 #else
151 if ( !pAppData_Impl->pBasicManager->isValid() )
152 GetBasicManager();
153 return pAppData_Impl->pBasicManager->getLibraryContainer( SfxBasicManagerHolder::SCRIPTS );
154 #endif
157 //--------------------------------------------------------------------
159 StarBASIC* SfxApplication::GetBasic()
161 #ifdef DISABLE_SCRIPTING
162 return 0;
163 #else
164 return GetBasicManager()->GetLib(0);
165 #endif
168 //-------------------------------------------------------------------------
169 void SfxApplication::PropExec_Impl( SfxRequest &rReq )
171 #ifdef DISABLE_SCRIPTING
172 (void) rReq;
173 #else
174 rReq.GetArgs();
175 sal_uInt16 nSID = rReq.GetSlot();
176 switch ( nSID )
178 case SID_CREATE_BASICOBJECT:
180 SFX_REQUEST_ARG(rReq, pItem, SfxStringItem, nSID, sal_False);
181 if ( pItem )
183 SbxObject* pObject = SbxBase::CreateObject( pItem->GetValue() );
184 pObject->AddRef();
185 rReq.Done();
187 break;
190 case SID_DELETE_BASICOBJECT:
192 break;
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);
202 batch->commit();
203 break;
206 case SID_WIN_VISIBLE:
208 break;
211 case SID_OFFICE_CUSTOMERNUMBER:
213 SFX_REQUEST_ARG(rReq, pStringItem, SfxStringItem, nSID, sal_False);
215 if ( pStringItem )
216 SvtUserOptions().SetCustomerNumber( pStringItem->GetValue() );
217 break;
220 #endif
223 //-------------------------------------------------------------------------
224 void SfxApplication::PropState_Impl( SfxItemSet &rSet )
226 #ifdef DISABLE_SCRIPTING
227 (void) rSet;
228 #else
229 SfxWhichIter aIter(rSet);
230 for ( sal_uInt16 nSID = aIter.FirstWhich(); nSID; nSID = aIter.NextWhich() )
232 switch ( nSID )
234 case SID_PROGNAME:
235 rSet.Put( SfxStringItem( SID_PROGNAME, GetName() ) );
236 break;
238 case SID_ACTIVEDOCUMENT:
239 rSet.Put( SfxObjectItem( SID_ACTIVEDOCUMENT, SfxObjectShell::Current() ) );
240 break;
242 case SID_APPLICATION:
243 rSet.Put( SfxObjectItem( SID_APPLICATION, this ) );
244 break;
246 case SID_PROGFILENAME:
247 rSet.Put( SfxStringItem( SID_PROGFILENAME, Application::GetAppFileName() ) );
248 break;
250 case SID_ATTR_UNDO_COUNT:
251 rSet.Put(
252 SfxUInt16Item(
253 SID_ATTR_UNDO_COUNT,
254 officecfg::Office::Common::Undo::Steps::get()));
255 break;
257 case SID_UPDATE_VERSION:
258 rSet.Put( SfxUInt32Item( SID_UPDATE_VERSION, SUPD ) );
259 break;
261 case SID_OFFICE_CUSTOMERNUMBER:
263 rSet.Put( SfxStringItem( nSID, SvtUserOptions().GetCustomerNumber() ) );
264 break;
268 #endif
271 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */