Branch libreoffice-5-0-4
[LibreOffice.git] / sfx2 / source / appl / appbas.cxx
blobbecd677efcaf0b2b3a4e071a28718955c9880e82
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 <config_features.h>
21 #include <config_options.h>
23 #include <sal/config.h>
25 #include <cassert>
27 #include <com/sun/star/frame/XDesktop.hpp>
28 #include <com/sun/star/script/XLibraryContainer.hpp>
29 #include <com/sun/star/uno/Reference.h>
30 #include <basic/basrdll.hxx>
31 #include <officecfg/Office/Common.hxx>
32 #include <svl/macitem.hxx>
33 #include <basic/sbxfac.hxx>
34 #include <basic/sbx.hxx>
35 #include <vcl/gradient.hxx>
36 #include <svl/rectitem.hxx>
37 #include <svl/intitem.hxx>
38 #include <svl/eitem.hxx>
39 #include <basic/sbmod.hxx>
40 #include <svl/whiter.hxx>
41 #include <basic/sbmeth.hxx>
42 #include <basic/sbstar.hxx>
43 #include <vcl/wrkwin.hxx>
44 #include <vcl/msgbox.hxx>
45 #include <basic/sbuno.hxx>
46 #include <svtools/sfxecode.hxx>
47 #include <svtools/ehdl.hxx>
49 #include <sfx2/module.hxx>
50 #include "arrdecl.hxx"
51 #include <sfx2/app.hxx>
52 #include "sfxtypes.hxx"
53 #include <sfx2/sfxresid.hxx>
54 #include <sfx2/msg.hxx>
55 #include <sfx2/msgpool.hxx>
56 #include <sfx2/progress.hxx>
57 #include <sfx2/objsh.hxx>
58 #include <sfx2/objitem.hxx>
59 #include <sfx2/viewfrm.hxx>
60 #include <sfx2/viewsh.hxx>
61 #include <sfx2/dispatch.hxx>
62 #include <sfx2/tplpitem.hxx>
63 #include <sfx2/minfitem.hxx>
64 #include "app.hrc"
65 #include <sfx2/evntconf.hxx>
66 #include <sfx2/request.hxx>
67 #include <sfx2/dinfdlg.hxx>
68 #include "appdata.hxx"
69 #include <sfx2/sfxhelp.hxx>
70 #include <basic/basmgr.hxx>
71 #include <svtools/svtools.hrc>
72 #include "sorgitm.hxx"
73 #include "appbaslib.hxx"
74 #include <basic/basicmanagerrepository.hxx>
76 #include <svl/srchitem.hxx>
77 #include <osl/socket.hxx>
79 #define SFX_TYPEMAP
80 #include "sfxslots.hxx"
82 using namespace ::com::sun::star;
83 using namespace ::com::sun::star::uno;
84 using namespace ::com::sun::star::frame;
85 using namespace ::com::sun::star::script;
87 using ::basic::BasicManagerRepository;
90 sal_uInt16 SfxApplication::SaveBasicAndDialogContainer() const
92 if ( pAppData_Impl->pBasicManager->isValid() )
93 pAppData_Impl->pBasicManager->storeAllLibraries();
94 return 0;
97 BasicManager* SfxApplication::GetBasicManager()
99 #if !HAVE_FEATURE_SCRIPTING
100 return 0;
101 #else
102 return BasicManagerRepository::getApplicationBasicManager( true );
103 #endif
108 XLibraryContainer * SfxApplication::GetDialogContainer()
110 #if !HAVE_FEATURE_SCRIPTING
111 return NULL;
112 #else
113 if ( !pAppData_Impl->pBasicManager->isValid() )
114 GetBasicManager();
115 return pAppData_Impl->pBasicManager->getLibraryContainer( SfxBasicManagerHolder::DIALOGS );
116 #endif
121 XLibraryContainer * SfxApplication::GetBasicContainer()
123 #if !HAVE_FEATURE_SCRIPTING
124 return NULL;
125 #else
126 if ( !pAppData_Impl->pBasicManager->isValid() )
127 GetBasicManager();
128 return pAppData_Impl->pBasicManager->getLibraryContainer( SfxBasicManagerHolder::SCRIPTS );
129 #endif
132 StarBASIC* SfxApplication::GetBasic()
134 #if !HAVE_FEATURE_SCRIPTING
135 return 0;
136 #else
137 return GetBasicManager()->GetLib(0);
138 #endif
141 void SfxApplication::PropExec_Impl( SfxRequest &rReq )
143 sal_uInt16 nSID = rReq.GetSlot();
144 switch ( nSID )
146 case SID_ATTR_UNDO_COUNT:
148 SFX_REQUEST_ARG(rReq, pCountItem, SfxUInt16Item, nSID, false);
149 std::shared_ptr< comphelper::ConfigurationChanges > batch(
150 comphelper::ConfigurationChanges::create());
151 officecfg::Office::Common::Undo::Steps::set(
152 pCountItem->GetValue(), batch);
153 batch->commit();
154 break;
157 default:
158 assert(false);
162 void SfxApplication::PropState_Impl( SfxItemSet &rSet )
164 SfxWhichIter aIter(rSet);
165 for ( sal_uInt16 nSID = aIter.FirstWhich(); nSID; nSID = aIter.NextWhich() )
167 switch ( nSID )
169 case SID_ATTR_UNDO_COUNT:
170 rSet.Put(
171 SfxUInt16Item(
172 SID_ATTR_UNDO_COUNT,
173 officecfg::Office::Common::Undo::Steps::get()));
174 break;
176 default:
177 assert(false);
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */