/src/libreoffice/sfx2/source/appl/appbas.cxx
Line | Count | Source |
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 | | #include <config_features.h> |
21 | | |
22 | | #include <sal/config.h> |
23 | | |
24 | | #include <cassert> |
25 | | |
26 | | #include <com/sun/star/script/XStorageBasedLibraryContainer.hpp> |
27 | | #include <officecfg/Office/Common.hxx> |
28 | | #include <svl/intitem.hxx> |
29 | | #include <svl/eitem.hxx> |
30 | | #include <svl/whiter.hxx> |
31 | | #include <svl/voiditem.hxx> |
32 | | #include <basic/sbstar.hxx> |
33 | | |
34 | | #include <sfx2/frame.hxx> |
35 | | #include <sfx2/dinfdlg.hxx> |
36 | | #include <sfx2/app.hxx> |
37 | | #include <sfx2/msg.hxx> |
38 | | #include <sfx2/request.hxx> |
39 | | #include <sfx2/sfxsids.hrc> |
40 | | #include <appdata.hxx> |
41 | | #include <basic/basmgr.hxx> |
42 | | #include <unotools/configmgr.hxx> |
43 | | #include <sorgitm.hxx> |
44 | | #include <appbaslib.hxx> |
45 | | #include <basic/basicmanagerrepository.hxx> |
46 | | |
47 | | #define SFX_TYPEMAP |
48 | | #include <sfxslots.hxx> |
49 | | |
50 | | using namespace ::com::sun::star; |
51 | | using namespace ::com::sun::star::script; |
52 | | |
53 | | using ::basic::BasicManagerRepository; |
54 | | |
55 | | |
56 | | void SfxApplication::SaveBasicAndDialogContainer() const |
57 | 0 | { |
58 | 0 | if ( pImpl->pBasicManager->isValid() ) |
59 | 0 | pImpl->pBasicManager->storeAllLibraries(); |
60 | 0 | } |
61 | | |
62 | | BasicManager* SfxApplication::GetBasicManager() |
63 | 0 | { |
64 | 0 | #if !HAVE_FEATURE_SCRIPTING |
65 | 0 | return nullptr; |
66 | | #else |
67 | | if (comphelper::IsFuzzing()) |
68 | | return nullptr; |
69 | | return BasicManagerRepository::getApplicationBasicManager(); |
70 | | #endif |
71 | 0 | } |
72 | | |
73 | | XStorageBasedLibraryContainer* SfxApplication::GetDialogContainer() |
74 | 0 | { |
75 | 0 | #if !HAVE_FEATURE_SCRIPTING |
76 | 0 | return nullptr; |
77 | | #else |
78 | | if (comphelper::IsFuzzing()) |
79 | | return nullptr; |
80 | | if ( !pImpl->pBasicManager->isValid() ) |
81 | | GetBasicManager(); |
82 | | return pImpl->pBasicManager->getLibraryContainer( SfxBasicManagerHolder::DIALOGS ); |
83 | | #endif |
84 | 0 | } |
85 | | |
86 | | |
87 | | XStorageBasedLibraryContainer* SfxApplication::GetBasicContainer() |
88 | 25.1k | { |
89 | 25.1k | #if !HAVE_FEATURE_SCRIPTING |
90 | 25.1k | return nullptr; |
91 | | #else |
92 | | if (comphelper::IsFuzzing()) |
93 | | return nullptr; |
94 | | if ( !pImpl->pBasicManager->isValid() ) |
95 | | GetBasicManager(); |
96 | | return pImpl->pBasicManager->getLibraryContainer( SfxBasicManagerHolder::SCRIPTS ); |
97 | | #endif |
98 | 25.1k | } |
99 | | |
100 | | StarBASIC* SfxApplication::GetBasic() |
101 | 0 | { |
102 | 0 | #if !HAVE_FEATURE_SCRIPTING |
103 | 0 | return nullptr; |
104 | | #else |
105 | | if (comphelper::IsFuzzing()) |
106 | | return nullptr; |
107 | | return GetBasicManager()->GetLib(0); |
108 | | #endif |
109 | 0 | } |
110 | | |
111 | | void SfxApplication::PropExec_Impl( SfxRequest const &rReq ) |
112 | 0 | { |
113 | 0 | sal_uInt16 nSID = rReq.GetSlot(); |
114 | 0 | switch ( nSID ) |
115 | 0 | { |
116 | 0 | case SID_ATTR_UNDO_COUNT: |
117 | 0 | { |
118 | 0 | if (const SfxUInt16Item* pCountItem = rReq.GetArg<SfxUInt16Item>(nSID)) |
119 | 0 | { |
120 | 0 | std::shared_ptr< comphelper::ConfigurationChanges > batch( |
121 | 0 | comphelper::ConfigurationChanges::create()); |
122 | 0 | officecfg::Office::Common::Undo::Steps::set( |
123 | 0 | pCountItem->GetValue(), batch); |
124 | 0 | batch->commit(); |
125 | 0 | } |
126 | 0 | break; |
127 | 0 | } |
128 | | |
129 | 0 | default: |
130 | 0 | assert(false); |
131 | 0 | } |
132 | 0 | } |
133 | | |
134 | | void SfxApplication::PropState_Impl( SfxItemSet &rSet ) |
135 | 0 | { |
136 | 0 | SfxWhichIter aIter(rSet); |
137 | 0 | for ( sal_uInt16 nSID = aIter.FirstWhich(); nSID; nSID = aIter.NextWhich() ) |
138 | 0 | { |
139 | 0 | switch ( nSID ) |
140 | 0 | { |
141 | 0 | case SID_ATTR_UNDO_COUNT: |
142 | 0 | rSet.Put( |
143 | 0 | SfxUInt16Item( |
144 | 0 | SID_ATTR_UNDO_COUNT, |
145 | 0 | officecfg::Office::Common::Undo::Steps::get())); |
146 | 0 | break; |
147 | | |
148 | 0 | default: |
149 | | assert(false); |
150 | 0 | } |
151 | 0 | } |
152 | 0 | } |
153 | | |
154 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |