File: | home/maarten/src/libreoffice/core/include/rtl/ref.hxx |
Warning: | line 192, column 9 Use of memory after it is freed |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
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 | #include <com/sun/star/document/XEmbeddedScripts.hpp> | |||
22 | #include <com/sun/star/drawing/ModuleDispatcher.hpp> | |||
23 | #include <com/sun/star/frame/Desktop.hpp> | |||
24 | #include <com/sun/star/frame/DispatchResultEvent.hpp> | |||
25 | #include <com/sun/star/frame/DispatchResultState.hpp> | |||
26 | #include <com/sun/star/frame/DispatchHelper.hpp> | |||
27 | #include <com/sun/star/frame/UnknownModuleException.hpp> | |||
28 | #include <com/sun/star/frame/XLayoutManager.hpp> | |||
29 | #include <com/sun/star/frame/XSynchronousFrameLoader.hpp> | |||
30 | #include <com/sun/star/sdbc/DriverManager.hpp> | |||
31 | #include <com/sun/star/system/SystemShellExecute.hpp> | |||
32 | #include <com/sun/star/system/SystemShellExecuteFlags.hpp> | |||
33 | #include <com/sun/star/text/ModuleDispatcher.hpp> | |||
34 | #include <com/sun/star/task/OfficeRestartManager.hpp> | |||
35 | #include <com/sun/star/task/XInteractionHandler.hpp> | |||
36 | #include <com/sun/star/ui/dialogs/AddressBookSourcePilot.hpp> | |||
37 | #include <com/sun/star/ui/UIElementType.hpp> | |||
38 | #include <com/sun/star/ui/XUIElement.hpp> | |||
39 | #include <com/sun/star/uno/Reference.hxx> | |||
40 | #include <com/sun/star/util/XCloseable.hpp> | |||
41 | #include <com/sun/star/util/CloseVetoException.hpp> | |||
42 | #include <org/freedesktop/PackageKit/SyncDbusSessionHelper.hpp> | |||
43 | ||||
44 | #include <comphelper/lok.hxx> | |||
45 | #include <comphelper/namedvaluecollection.hxx> | |||
46 | #include <comphelper/processfactory.hxx> | |||
47 | #include <comphelper/propertysequence.hxx> | |||
48 | #include <comphelper/sequence.hxx> | |||
49 | ||||
50 | #include <svtools/addresstemplate.hxx> | |||
51 | #include <svtools/miscopt.hxx> | |||
52 | #include <svtools/restartdialog.hxx> | |||
53 | #include <svl/visitem.hxx> | |||
54 | ||||
55 | #include <unotools/configmgr.hxx> | |||
56 | #include <tools/svlibrary.h> | |||
57 | #include <tools/diagnose_ex.h> | |||
58 | #include <vcl/svapp.hxx> | |||
59 | #include <vcl/weld.hxx> | |||
60 | #include <svl/intitem.hxx> | |||
61 | #include <svl/eitem.hxx> | |||
62 | #include <svl/stritem.hxx> | |||
63 | #include <basic/sbstar.hxx> | |||
64 | #include <basic/basrdll.hxx> | |||
65 | #include <basic/sberrors.hxx> | |||
66 | #include <vcl/help.hxx> | |||
67 | #include <rtl/ustrbuf.hxx> | |||
68 | #include <sal/log.hxx> | |||
69 | #include <osl/file.hxx> | |||
70 | #include <vcl/EnumContext.hxx> | |||
71 | ||||
72 | #include <unotools/moduleoptions.hxx> | |||
73 | #include <svtools/helpopt.hxx> | |||
74 | #include <toolkit/helper/vclunohelper.hxx> | |||
75 | #include <rtl/bootstrap.hxx> | |||
76 | ||||
77 | #include <com/sun/star/frame/ModuleManager.hpp> | |||
78 | #include <com/sun/star/beans/XPropertySet.hpp> | |||
79 | ||||
80 | #include <sfx2/app.hxx> | |||
81 | #include <sfx2/request.hxx> | |||
82 | #include <sfx2/dispatch.hxx> | |||
83 | #include <sfx2/bindings.hxx> | |||
84 | #include <sfx2/msg.hxx> | |||
85 | #include <sfx2/objface.hxx> | |||
86 | #include <sfx2/objsh.hxx> | |||
87 | #include <sfx2/viewsh.hxx> | |||
88 | #include <sfx2/docfac.hxx> | |||
89 | #include <sfx2/strings.hrc> | |||
90 | #include <sfx2/sfxresid.hxx> | |||
91 | #include <appdata.hxx> | |||
92 | #include <sfx2/viewfrm.hxx> | |||
93 | #include <sfx2/sfxdlg.hxx> | |||
94 | #include <sfx2/sfxsids.hrc> | |||
95 | #include <sorgitm.hxx> | |||
96 | #include <sfx2/sfxhelp.hxx> | |||
97 | #include <sfx2/zoomitem.hxx> | |||
98 | #include <sfx2/templatedlg.hxx> | |||
99 | #include <sfx2/notebookbar/SfxNotebookBar.hxx> | |||
100 | #include <sfx2/sidebar/SidebarController.hxx> | |||
101 | #include <sfx2/safemode.hxx> | |||
102 | #include <sfx2/sfxuno.hxx> | |||
103 | ||||
104 | #include <comphelper/types.hxx> | |||
105 | #include <officecfg/Office/Common.hxx> | |||
106 | #include <unotools/confignode.hxx> | |||
107 | #include <officecfg/Setup.hxx> | |||
108 | #include <memory> | |||
109 | ||||
110 | #include <openuriexternally.hxx> | |||
111 | ||||
112 | #include "getbasctlfunction.hxx" | |||
113 | ||||
114 | using namespace ::com::sun::star; | |||
115 | using namespace ::com::sun::star::beans; | |||
116 | using namespace ::com::sun::star::uno; | |||
117 | using namespace ::com::sun::star::frame; | |||
118 | using namespace ::com::sun::star::container; | |||
119 | using namespace ::com::sun::star::util; | |||
120 | using namespace ::com::sun::star::script; | |||
121 | using namespace ::com::sun::star::system; | |||
122 | using namespace ::com::sun::star::lang; | |||
123 | using namespace ::com::sun::star::document; | |||
124 | using namespace ::com::sun::star::ui; | |||
125 | ||||
126 | namespace | |||
127 | { | |||
128 | OUString lcl_getAppName( vcl::EnumContext::Application eApp ) | |||
129 | { | |||
130 | switch ( eApp ) | |||
131 | { | |||
132 | case vcl::EnumContext::Application::Writer: | |||
133 | return "Writer"; | |||
134 | break; | |||
135 | case vcl::EnumContext::Application::Calc: | |||
136 | return "Calc"; | |||
137 | break; | |||
138 | case vcl::EnumContext::Application::Impress: | |||
139 | return "Impress"; | |||
140 | break; | |||
141 | case vcl::EnumContext::Application::Draw: | |||
142 | return "Draw"; | |||
143 | break; | |||
144 | case vcl::EnumContext::Application::Formula: | |||
145 | return "Formula"; | |||
146 | break; | |||
147 | case vcl::EnumContext::Application::Base: | |||
148 | return "Base"; | |||
149 | break; | |||
150 | default: | |||
151 | return OUString(); | |||
152 | break; | |||
153 | } | |||
154 | } | |||
155 | ||||
156 | // lp#527938, debian#602953, fdo#33266, i#105408 | |||
157 | bool lcl_isBaseAvailable() | |||
158 | { | |||
159 | try | |||
160 | { | |||
161 | // if we get css::sdbc::DriverManager, libsdbc2 is there | |||
162 | // and the bibliography is assumed to work | |||
163 | return css::sdbc::DriverManager::create(comphelper::getProcessComponentContext()).is(); | |||
164 | } | |||
165 | catch (const Exception &) | |||
166 | { | |||
167 | TOOLS_INFO_EXCEPTION("sfx.appl", "assuming Base to be missing")do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "sfx.appl")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "assuming Base to be missing" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ( "sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "167" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "assuming Base to be missing" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "assuming Base to be missing" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "167" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "assuming Base to be missing" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "167" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "assuming Base to be missing" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "assuming Base to be missing" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "167" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
168 | return false; | |||
169 | } | |||
170 | } | |||
171 | void lcl_tryLoadBibliography() | |||
172 | { | |||
173 | // lp#527938, debian#602953, fdo#33266, i#105408 | |||
174 | // make sure we actually can instantiate services from base first | |||
175 | if(!lcl_isBaseAvailable()) | |||
176 | { | |||
177 | if (officecfg::Office::Common::PackageKit::EnableBaseInstallation::get()) | |||
178 | { | |||
179 | try | |||
180 | { | |||
181 | using namespace org::freedesktop::PackageKit; | |||
182 | using namespace svtools; | |||
183 | Reference< XSyncDbusSessionHelper > xSyncDbusSessionHelper(SyncDbusSessionHelper::create(comphelper::getProcessComponentContext())); | |||
184 | Sequence< OUString > vPackages { "libreoffice-base" }; | |||
185 | xSyncDbusSessionHelper->InstallPackageNames(vPackages, OUString()); | |||
186 | // I'll be back (hopefully)! | |||
187 | SolarMutexGuard aGuard; | |||
188 | executeRestartDialog(comphelper::getProcessComponentContext(), nullptr, RESTART_REASON_BIBLIOGRAPHY_INSTALL); | |||
189 | } | |||
190 | catch (const Exception &) | |||
191 | { | |||
192 | TOOLS_INFO_EXCEPTION("sfx.appl", "trying to install LibreOffice Base")do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "sfx.appl")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "trying to install LibreOffice Base" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ( "sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "192" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "trying to install LibreOffice Base" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "trying to install LibreOffice Base" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "192" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "trying to install LibreOffice Base" << " " << exceptionToString(tools_warn_exception)) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "192" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "trying to install LibreOffice Base" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "trying to install LibreOffice Base" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "192" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
193 | } | |||
194 | } | |||
195 | return; | |||
196 | } | |||
197 | ||||
198 | try // fdo#48775 | |||
199 | { | |||
200 | SfxStringItem aURL(SID_FILE_NAME(5000 + 507), ".component:Bibliography/View1"); | |||
201 | SfxStringItem aRef(SID_REFERER(5000 + 654), "private:user"); | |||
202 | SfxStringItem aTarget(SID_TARGETNAME(5000 + 560), "_blank"); | |||
203 | SfxViewFrame::Current()->GetDispatcher()->ExecuteList(SID_OPENDOC(5000 + 501), | |||
204 | SfxCallMode::ASYNCHRON, { &aURL, &aRef, &aTarget }); | |||
205 | } | |||
206 | catch (const Exception &) | |||
207 | { | |||
208 | TOOLS_INFO_EXCEPTION( "sfx.appl", "trying to load bibliography database")do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "sfx.appl")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "trying to load bibliography database" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ( "sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "208" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "trying to load bibliography database" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "trying to load bibliography database" << " " << exceptionToString(tools_warn_exception); ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "208" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "trying to load bibliography database" << " " << exceptionToString(tools_warn_exception)) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "208" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "trying to load bibliography database" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "trying to load bibliography database" << " " << exceptionToString(tools_warn_exception); ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "208" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
209 | } | |||
210 | } | |||
211 | } | |||
212 | /// Find the correct location of the document (CREDITS.fodt, etc.), and return | |||
213 | /// it in rURL if found. | |||
214 | static bool checkURL( const char *pName, const char *pExt, OUString &rURL ) | |||
215 | { | |||
216 | using namespace osl; | |||
217 | DirectoryItem aDirItem; | |||
218 | ||||
219 | #ifdef MACOSX | |||
220 | rURL = "$BRAND_BASE_DIR/Resources/" + OUString::createFromAscii( pName ) + | |||
221 | OUString::createFromAscii( pExt ); | |||
222 | #else | |||
223 | rURL = "$BRAND_BASE_DIR/" + OUString::createFromAscii( pName ) + | |||
224 | OUString::createFromAscii( pExt ); | |||
225 | #endif | |||
226 | rtl::Bootstrap::expandMacros( rURL ); | |||
227 | ||||
228 | if (!rURL.isEmpty()) | |||
229 | return DirectoryItem::get( rURL, aDirItem ) == DirectoryItem::E_None; | |||
230 | else | |||
231 | return false; | |||
232 | } | |||
233 | ||||
234 | /// Displays CREDITS or LICENSE in any of the available version | |||
235 | static void showDocument( const char* pBaseName ) | |||
236 | { | |||
237 | try { | |||
238 | Reference < XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() ); | |||
239 | auto args(::comphelper::InitPropertySequence({ | |||
240 | {"ViewOnly", makeAny(true)}, | |||
241 | {"ReadOnly", makeAny(true)} | |||
242 | })); | |||
243 | ||||
244 | OUString aURL; | |||
245 | if ( checkURL ( pBaseName, ".fodt", aURL ) || | |||
246 | checkURL ( pBaseName, ".html", aURL ) || | |||
247 | checkURL ( pBaseName, "", aURL ) ) { | |||
248 | xDesktop->loadComponentFromURL( aURL, "_blank", 0, args ); | |||
249 | } | |||
250 | } catch (const css::uno::Exception &) { | |||
251 | } | |||
252 | } | |||
253 | ||||
254 | namespace | |||
255 | { | |||
256 | Reference<XFrame> GetRequestFrame(const SfxRequest& rReq) | |||
257 | { | |||
258 | const SfxItemSet* pArgs = rReq.GetInternalArgs_Impl(); | |||
259 | const SfxPoolItem* pItem = nullptr; | |||
260 | Reference <XFrame> xFrame; | |||
261 | if (pArgs && pArgs->GetItemState(SID_FILLFRAME(5000 + 1516), false, &pItem) == SfxItemState::SET) | |||
262 | { | |||
263 | OSL_ENSURE( dynamic_cast< const SfxUnoFrameItem *>( pItem ) != nullptr, "SfxApplication::OfaExec_Impl: XFrames are to be transported via SfxUnoFrameItem by now!" )do { if (true && (!(dynamic_cast< const SfxUnoFrameItem *>( pItem ) != nullptr))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "263" ": "), "%s", "SfxApplication::OfaExec_Impl: XFrames are to be transported via SfxUnoFrameItem by now!" ); } } while (false); | |||
264 | xFrame = static_cast< const SfxUnoFrameItem*>( pItem )->GetFrame(); | |||
265 | } | |||
266 | return xFrame; | |||
267 | } | |||
268 | ||||
269 | vcl::Window* getFrameWindow(const Reference<XFrame>& rFrame) | |||
270 | { | |||
271 | if (rFrame.is()) | |||
272 | { | |||
273 | try | |||
274 | { | |||
275 | Reference< awt::XWindow > xContainerWindow(rFrame->getContainerWindow(), UNO_SET_THROW); | |||
276 | VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xContainerWindow); | |||
277 | return pWindow; | |||
278 | } | |||
279 | catch (const Exception&) | |||
280 | { | |||
281 | DBG_UNHANDLED_EXCEPTION("sfx.appl")DbgUnhandledException( DbgGetCaughtException(), __func__, "/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "281" ": ", "sfx.appl" );; | |||
282 | } | |||
283 | } | |||
284 | ||||
285 | SAL_WARN( "sfx.appl", "no parent for dialogs" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "sfx.appl")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "no parent for dialogs" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "285" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "no parent for dialogs"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "no parent for dialogs"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "285" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "no parent for dialogs") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "285" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "no parent for dialogs"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "no parent for dialogs"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "285" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
286 | return nullptr; | |||
287 | } | |||
288 | ||||
289 | class LicenseDialog : public weld::GenericDialogController | |||
290 | { | |||
291 | public: | |||
292 | LicenseDialog(weld::Window* pParent) | |||
293 | : GenericDialogController(pParent, "sfx/ui/licensedialog.ui", "LicenseDialog") | |||
294 | { | |||
295 | } | |||
296 | ||||
297 | virtual short run() override | |||
298 | { | |||
299 | short nRet = GenericDialogController::run(); | |||
300 | if (nRet == RET_OK) | |||
301 | showDocument("LICENSE"); | |||
302 | return nRet; | |||
303 | } | |||
304 | }; | |||
305 | ||||
306 | class SafeModeQueryDialog : public weld::MessageDialogController | |||
307 | { | |||
308 | public: | |||
309 | SafeModeQueryDialog(weld::Window* pParent) | |||
310 | : MessageDialogController(pParent, "sfx/ui/safemodequerydialog.ui", "SafeModeQueryDialog") | |||
311 | { | |||
312 | } | |||
313 | ||||
314 | virtual short run() override | |||
315 | { | |||
316 | short nRet = MessageDialogController::run(); | |||
317 | if (nRet == RET_OK) | |||
318 | { | |||
319 | sfx2::SafeMode::putFlag(); | |||
320 | uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); | |||
321 | css::task::OfficeRestartManager::get(xContext)->requestRestart( | |||
322 | css::uno::Reference< css::task::XInteractionHandler >()); | |||
323 | } | |||
324 | return nRet; | |||
325 | } | |||
326 | }; | |||
327 | } | |||
328 | ||||
329 | vcl::Window* SfxRequest::GetFrameWindow() const | |||
330 | { | |||
331 | return getFrameWindow(GetRequestFrame(*this)); | |||
332 | } | |||
333 | ||||
334 | weld::Window* SfxRequest::GetFrameWeld() const | |||
335 | { | |||
336 | const SfxItemSet* pIntArgs = GetInternalArgs_Impl(); | |||
337 | const SfxPoolItem* pItem = nullptr; | |||
338 | if (pIntArgs && pIntArgs->GetItemState(SID_DIALOG_PARENT(5000 + 1735), false, &pItem) == SfxItemState::SET) | |||
339 | { | |||
340 | assert(dynamic_cast<const SfxUnoAnyItem*>(pItem))(static_cast <bool> (dynamic_cast<const SfxUnoAnyItem *>(pItem)) ? void (0) : __assert_fail ("dynamic_cast<const SfxUnoAnyItem*>(pItem)" , "/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" , 340, __extension__ __PRETTY_FUNCTION__)); | |||
341 | auto aAny = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue(); | |||
342 | Reference<awt::XWindow> xWindow; | |||
343 | aAny >>= xWindow; | |||
344 | return Application::GetFrameWeld(xWindow); | |||
345 | } | |||
346 | ||||
347 | vcl::Window* pWin = GetFrameWindow(); | |||
348 | return pWin ? pWin->GetFrameWeld() : nullptr; | |||
349 | } | |||
350 | ||||
351 | void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) | |||
352 | { | |||
353 | bool bDone = false; | |||
354 | switch ( rReq.GetSlot() ) | |||
| ||||
355 | { | |||
356 | case SID_SETOPTIONS(5000 + 670): | |||
357 | { | |||
358 | if( rReq.GetArgs() ) | |||
359 | SetOptions_Impl( *rReq.GetArgs() ); | |||
360 | break; | |||
361 | } | |||
362 | ||||
363 | case SID_QUITAPP(5000 + 300): | |||
364 | case SID_LOGOUT(5000 + 1652): | |||
365 | { | |||
366 | // protect against reentrant calls | |||
367 | if ( pImpl->bInQuit ) | |||
368 | return; | |||
369 | ||||
370 | if ( rReq.GetSlot() == SID_LOGOUT(5000 + 1652) ) | |||
371 | { | |||
372 | for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst(); | |||
373 | pObjSh; pObjSh = SfxObjectShell::GetNext( *pObjSh ) ) | |||
374 | { | |||
375 | if ( !pObjSh->IsModified() ) | |||
376 | continue; | |||
377 | ||||
378 | SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pObjSh ); | |||
379 | if ( !pFrame || !pFrame->GetWindow().IsReallyVisible() ) | |||
380 | continue; | |||
381 | ||||
382 | if (pObjSh->PrepareClose()) | |||
383 | pObjSh->SetModified( false ); | |||
384 | else | |||
385 | return; | |||
386 | } | |||
387 | ||||
388 | SfxStringItem aNameItem( SID_FILE_NAME(5000 + 507), "vnd.sun.star.cmd:logout" ); | |||
389 | SfxStringItem aReferer( SID_REFERER(5000 + 654), "private/user" ); | |||
390 | pImpl->pAppDispat->ExecuteList(SID_OPENDOC(5000 + 501), | |||
391 | SfxCallMode::SLOT, { &aNameItem, &aReferer }); | |||
392 | return; | |||
393 | } | |||
394 | ||||
395 | // try from nested requests again after 100ms | |||
396 | if( Application::GetDispatchLevel() > 1 ) | |||
397 | { | |||
398 | /* Don't save the request for closing the application and try it later | |||
399 | again. This is an UI bound functionality ... and the user will try it again | |||
400 | if the dialog is closed. But we should not close the application automatically | |||
401 | if this dialog is closed by the user ... | |||
402 | So we ignore this request now and wait for a new user decision. | |||
403 | */ | |||
404 | SAL_INFO("sfx.appl", "QueryExit => sal_False, DispatchLevel == " << Application::GetDispatchLevel() )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "sfx.appl")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "QueryExit => sal_False, DispatchLevel == " << Application::GetDispatchLevel()) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "404" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "QueryExit => sal_False, DispatchLevel == " << Application::GetDispatchLevel()), 0); } else { ::std ::ostringstream sal_detail_stream; sal_detail_stream << "QueryExit => sal_False, DispatchLevel == " << Application ::GetDispatchLevel(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "404" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "QueryExit => sal_False, DispatchLevel == " << Application::GetDispatchLevel()) == 1) { ::sal_detail_log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "404" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "QueryExit => sal_False, DispatchLevel == " << Application::GetDispatchLevel()), 0); } else { ::std ::ostringstream sal_detail_stream; sal_detail_stream << "QueryExit => sal_False, DispatchLevel == " << Application ::GetDispatchLevel(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "404" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
405 | return; | |||
406 | } | |||
407 | ||||
408 | // block reentrant calls | |||
409 | pImpl->bInQuit = true; | |||
410 | Reference < XDesktop2 > xDesktop = Desktop::create ( ::comphelper::getProcessComponentContext() ); | |||
411 | ||||
412 | rReq.ForgetAllArgs(); | |||
413 | ||||
414 | // if terminate() failed, pImpl->bInQuit will now be sal_False, allowing further calls of SID_QUITAPP | |||
415 | bool bTerminated = xDesktop->terminate(); | |||
416 | if (!bTerminated) | |||
417 | // if terminate() was successful, SfxApplication is now dead! | |||
418 | pImpl->bInQuit = false; | |||
419 | ||||
420 | // Set return value, terminate if possible | |||
421 | rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bTerminated ) ); | |||
422 | return; | |||
423 | } | |||
424 | ||||
425 | case SID_CONFIG(5000 + 904): | |||
426 | case SID_TOOLBOXOPTIONS(5000 + 907): | |||
427 | case SID_CONFIGSTATUSBAR(5000 + 921): | |||
428 | case SID_CONFIGMENU(5000 + 924): | |||
429 | case SID_CONFIGACCEL(5000 + 925): | |||
430 | case SID_CONFIGEVENT(5000 + 926): | |||
431 | { | |||
432 | SfxAbstractDialogFactory* pFact = | |||
433 | SfxAbstractDialogFactory::Create(); | |||
434 | ||||
435 | const SfxStringItem* pStringItem = rReq.GetArg<SfxStringItem>(SID_CONFIG(5000 + 904)); | |||
436 | ||||
437 | SfxItemSet aSet( | |||
438 | GetPool(), svl::Items<SID_CONFIG(5000 + 904), SID_CONFIG(5000 + 904)>{} ); | |||
439 | ||||
440 | if ( pStringItem ) | |||
441 | { | |||
442 | aSet.Put( SfxStringItem( | |||
443 | SID_CONFIG(5000 + 904), pStringItem->GetValue() ) ); | |||
444 | } | |||
445 | ||||
446 | Reference <XFrame> xFrame(GetRequestFrame(rReq)); | |||
447 | ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateCustomizeTabDialog(rReq.GetFrameWeld(), | |||
448 | &aSet, xFrame )); | |||
449 | ||||
450 | const short nRet = pDlg->Execute(); | |||
451 | ||||
452 | if ( nRet ) | |||
453 | bDone = true; | |||
454 | break; | |||
455 | } | |||
456 | ||||
457 | case SID_CLOSEDOCS(5000 + 595): | |||
458 | { | |||
459 | ||||
460 | Reference < XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() ); | |||
461 | Reference< XIndexAccess > xTasks = xDesktop->getFrames(); | |||
462 | if ( !xTasks.is() ) | |||
463 | break; | |||
464 | ||||
465 | sal_Int32 n=0; | |||
466 | do | |||
467 | { | |||
468 | if ( xTasks->getCount() <= n ) | |||
469 | break; | |||
470 | ||||
471 | Any aAny = xTasks->getByIndex(n); | |||
472 | Reference < XCloseable > xTask; | |||
473 | aAny >>= xTask; | |||
474 | try | |||
475 | { | |||
476 | xTask->close(true); | |||
477 | n++; | |||
478 | } | |||
479 | catch( CloseVetoException& ) | |||
480 | { | |||
481 | } | |||
482 | } | |||
483 | while( true ); | |||
484 | ||||
485 | bool bOk = ( n == 0); | |||
486 | rReq.SetReturnValue( SfxBoolItem( 0, bOk ) ); | |||
487 | bDone = true; | |||
488 | break; | |||
489 | } | |||
490 | ||||
491 | case SID_SAVEDOCS(5000 + 309): | |||
492 | { | |||
493 | bool bOK = true; | |||
494 | for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst(); | |||
495 | pObjSh; | |||
496 | pObjSh = SfxObjectShell::GetNext( *pObjSh ) ) | |||
497 | { | |||
498 | SfxRequest aReq( SID_SAVEDOC(5000 + 505), SfxCallMode::SLOT, pObjSh->GetPool() ); | |||
499 | if ( pObjSh->IsModified() ) | |||
500 | { | |||
501 | pObjSh->ExecuteSlot( aReq ); | |||
502 | const SfxBoolItem *pItem = dynamic_cast<const SfxBoolItem*>( aReq.GetReturnValue() ); | |||
503 | if ( !pItem || !pItem->GetValue() ) | |||
504 | bOK = false; | |||
505 | } | |||
506 | } | |||
507 | ||||
508 | rReq.SetReturnValue( SfxBoolItem( 0, bOK ) ); | |||
509 | rReq.Done(); | |||
510 | break; | |||
511 | } | |||
512 | ||||
513 | case SID_SEND_FEEDBACK(5000 + 421): | |||
514 | { | |||
515 | OUString module = SfxHelp::GetCurrentModuleIdentifier(); | |||
516 | OUString sURL(officecfg::Office::Common::Menus::SendFeedbackURL::get() + //officecfg/registry/data/org/openoffice/Office/Common.xcu => https://hub.libreoffice.org/send-feedback/ | |||
517 | "?LOversion=" + utl::ConfigManager::getAboutBoxProductVersion() + | |||
518 | "&LOlocale=" + utl::ConfigManager::getUILocale() + | |||
519 | "&LOmodule=" + module.copy(module.lastIndexOf('.') + 1 ) ); | |||
520 | sfx2::openUriExternally(sURL, false); | |||
521 | break; | |||
522 | } | |||
523 | ||||
524 | case SID_Q_AND_A(5000 + 422): | |||
525 | { | |||
526 | // Askbot has URL's normalized to languages, not locales | |||
527 | // Get language from locale: ll or lll or ll-CC or lll-CC | |||
528 | ||||
529 | OUString sURL(officecfg::Office::Common::Menus::QA_URL::get() + //https://hub.libreoffice.org/forum/ | |||
530 | "?LOlocale=" + utl::ConfigManager::getUILocale()); | |||
531 | sfx2::openUriExternally(sURL, false); | |||
532 | break; | |||
533 | } | |||
534 | case SID_DOCUMENTATION(5000 + 423): | |||
535 | { | |||
536 | // Open documentation page based on locales | |||
537 | OUString sURL(officecfg::Office::Common::Menus::DocumentationURL::get() + //https://hub.libreoffice.org/documentation/ | |||
538 | "?LOlocale=" + utl::ConfigManager::getUILocale()); | |||
539 | sfx2::openUriExternally(sURL, false); | |||
540 | break; | |||
541 | } | |||
542 | case SID_GETINVOLVED(5000 + 425): | |||
543 | { | |||
544 | // Open get involved/join us page based on locales | |||
545 | OUString sURL(officecfg::Office::Common::Menus::GetInvolvedURL::get() + //https://hub.libreoffice.org/joinus/ | |||
546 | "?LOlocale=" + utl::ConfigManager::getUILocale()); | |||
547 | sfx2::openUriExternally(sURL, false); | |||
548 | break; | |||
549 | } | |||
550 | case SID_DONATION(5000 + 424): | |||
551 | { | |||
552 | // Open donation page based on language + script (BCP47) with language as fall back. | |||
553 | OUString aLang = LanguageTag(utl::ConfigManager::getUILocale()).getLanguage(); | |||
554 | OUString aBcp47 = LanguageTag(utl::ConfigManager::getUILocale()).getBcp47(); | |||
555 | OUString sURL(officecfg::Office::Common::Menus::DonationURL::get() + //https://hub.libreoffice.org/donation/ | |||
556 | "?BCP47=" + aBcp47 + "&LOlang=" + aLang ); | |||
557 | sfx2::openUriExternally(sURL, false); | |||
558 | break; | |||
559 | } | |||
560 | case SID_WHATSNEW(5000 + 426): | |||
561 | { | |||
562 | // Open release notes depending on version and locale | |||
563 | OUString sURL(officecfg::Office::Common::Menus::ReleaseNotesURL::get() + //https://hub.libreoffice.org/ReleaseNotes/ | |||
564 | "?LOvers=" + utl::ConfigManager::getProductVersion() + | |||
565 | "&LOlocale=" + LanguageTag(utl::ConfigManager::getUILocale()).getBcp47() ); | |||
566 | sfx2::openUriExternally(sURL, false); | |||
567 | break; | |||
568 | } | |||
569 | case SID_SHOW_LICENSE(5000 + 1683): | |||
570 | { | |||
571 | LicenseDialog aDialog(rReq.GetFrameWeld()); | |||
572 | aDialog.run(); | |||
573 | break; | |||
574 | } | |||
575 | ||||
576 | case SID_SHOW_CREDITS(5000 + 1711): | |||
577 | { | |||
578 | showDocument( "CREDITS" ); | |||
579 | break; | |||
580 | } | |||
581 | ||||
582 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |||
583 | case SID_HELPINDEX(5000 + 401): | |||
584 | { | |||
585 | Help* pHelp = Application::GetHelp(); | |||
586 | if ( pHelp ) | |||
587 | { | |||
588 | pHelp->Start(".uno:HelpIndex", Application::GetDefDialogParent()); // show start page | |||
589 | bDone = true; | |||
590 | } | |||
591 | break; | |||
592 | } | |||
593 | ||||
594 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |||
595 | case SID_HELPTIPS(5000 + 404): | |||
596 | { | |||
597 | // Evaluate Parameter | |||
598 | const SfxBoolItem* pOnItem = rReq.GetArg<SfxBoolItem>(SID_HELPTIPS(5000 + 404)); | |||
599 | bool bOn = pOnItem | |||
600 | ? pOnItem->GetValue() | |||
601 | : !Help::IsQuickHelpEnabled(); | |||
602 | ||||
603 | if ( bOn ) | |||
604 | Help::EnableQuickHelp(); | |||
605 | else | |||
606 | Help::DisableQuickHelp(); | |||
607 | SvtHelpOptions().SetHelpTips( bOn ); | |||
608 | Invalidate(SID_HELPTIPS(5000 + 404)); | |||
609 | bDone = true; | |||
610 | ||||
611 | // Record if possible | |||
612 | if ( !rReq.IsAPI() ) | |||
613 | rReq.AppendItem( SfxBoolItem( SID_HELPTIPS(5000 + 404), bOn) ); | |||
614 | break; | |||
615 | } | |||
616 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |||
617 | case SID_EXTENDEDHELP(5000 + 402): | |||
618 | { | |||
619 | Help::StartExtHelp(); | |||
620 | break; | |||
621 | } | |||
622 | case SID_HELPBALLOONS(5000 + 403): | |||
623 | { | |||
624 | // Evaluate Parameter | |||
625 | const SfxBoolItem* pOnItem = rReq.GetArg<SfxBoolItem>(SID_HELPBALLOONS(5000 + 403)); | |||
626 | bool bOn = pOnItem | |||
627 | ? pOnItem->GetValue() | |||
628 | : !Help::IsBalloonHelpEnabled(); | |||
629 | ||||
630 | if ( bOn ) | |||
631 | Help::EnableBalloonHelp(); | |||
632 | else | |||
633 | Help::DisableBalloonHelp(); | |||
634 | SvtHelpOptions().SetExtendedHelp( bOn ); | |||
635 | Invalidate(SID_HELPBALLOONS(5000 + 403)); | |||
636 | bDone = true; | |||
637 | ||||
638 | // Record if possible | |||
639 | if ( !rReq.IsAPI() ) | |||
640 | rReq.AppendItem( SfxBoolItem( SID_HELPBALLOONS(5000 + 403), bOn) ); | |||
641 | break; | |||
642 | } | |||
643 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |||
644 | case SID_TIPOFTHEDAY(5000 + 407): | |||
645 | { | |||
646 | SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); | |||
647 | ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateTipOfTheDayDialog(rReq.GetFrameWeld())); | |||
648 | pDlg->Execute(); | |||
649 | bDone = true; | |||
650 | break; | |||
651 | } | |||
652 | ||||
653 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |||
654 | case SID_ABOUT(5000 + 301): | |||
655 | { | |||
656 | SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); | |||
657 | ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateAboutDialog(rReq.GetFrameWeld())); | |||
658 | pDlg->Execute(); | |||
659 | bDone = true; | |||
660 | break; | |||
661 | } | |||
662 | ||||
663 | case SID_TEMPLATE_MANAGER(5000 + 1727): | |||
664 | { | |||
665 | SfxTemplateManagerDlg aDialog(rReq.GetFrameWeld()); | |||
666 | aDialog.run(); | |||
667 | bDone = true; | |||
668 | break; | |||
669 | } | |||
670 | ||||
671 | case SID_TEMPLATE_ADDRESSBOKSOURCE(5000 + 1655): | |||
672 | { | |||
673 | svt::AddressBookSourceDialog aDialog(rReq.GetFrameWeld(), ::comphelper::getProcessComponentContext()); | |||
674 | aDialog.run(); | |||
675 | bDone = true; | |||
676 | break; | |||
677 | } | |||
678 | ||||
679 | #if HAVE_FEATURE_SCRIPTING1 | |||
680 | case SID_BASICSTOP(5000 + 958): | |||
681 | StarBASIC::Stop(); | |||
682 | break; | |||
683 | ||||
684 | case SID_BASICBREAK(5000 +1521) : | |||
685 | BasicDLL::BasicBreak(); | |||
686 | break; | |||
687 | #endif | |||
688 | ||||
689 | case SID_ZOOM_50_PERCENT(10000 + 1421): | |||
690 | case SID_ZOOM_75_PERCENT(10000 + 1422): | |||
691 | case SID_ZOOM_100_PERCENT((10000 + 99)): | |||
692 | case SID_ZOOM_150_PERCENT(10000 + 1423): | |||
693 | case SID_ZOOM_200_PERCENT(10000 + 1424): | |||
694 | case SID_ZOOM_OPTIMAL((27000 +99)): | |||
695 | case SID_ZOOM_ENTIRE_PAGE((10000 + 100)): | |||
696 | case SID_ZOOM_PAGE_WIDTH(10000 + 1420): | |||
697 | { | |||
698 | SfxObjectShell* pCurrentShell = SfxObjectShell::Current(); | |||
699 | if (!pCurrentShell) | |||
700 | return; | |||
701 | ||||
702 | // make sure aZoom is initialized with a proper value if SetType | |||
703 | // doesn't work | |||
704 | SvxZoomItem aZoom( SvxZoomType::PERCENT, 100 ); | |||
705 | ||||
706 | switch (rReq.GetSlot()) | |||
707 | { | |||
708 | case SID_ZOOM_50_PERCENT(10000 + 1421): | |||
709 | aZoom.SetValue(50); | |||
710 | break; | |||
711 | case SID_ZOOM_75_PERCENT(10000 + 1422): | |||
712 | aZoom.SetValue(75); | |||
713 | break; | |||
714 | case SID_ZOOM_100_PERCENT((10000 + 99)): | |||
715 | aZoom.SetValue(100); | |||
716 | break; | |||
717 | case SID_ZOOM_150_PERCENT(10000 + 1423): | |||
718 | aZoom.SetValue(150); | |||
719 | break; | |||
720 | case SID_ZOOM_200_PERCENT(10000 + 1424): | |||
721 | aZoom.SetValue(200); | |||
722 | break; | |||
723 | case SID_ZOOM_OPTIMAL((27000 +99)): | |||
724 | aZoom.SetType( SvxZoomType::OPTIMAL ); | |||
725 | break; | |||
726 | case SID_ZOOM_ENTIRE_PAGE((10000 + 100)): | |||
727 | aZoom.SetType( SvxZoomType::WHOLEPAGE ); | |||
728 | break; | |||
729 | case SID_ZOOM_PAGE_WIDTH(10000 + 1420): | |||
730 | aZoom.SetType( SvxZoomType::PAGEWIDTH ); | |||
731 | break; | |||
732 | } | |||
733 | ||||
734 | pCurrentShell->GetDispatcher()->ExecuteList(SID_ATTR_ZOOMTypedWhichId<SvxZoomItem>(10000 + 0), SfxCallMode::ASYNCHRON, { &aZoom }); | |||
735 | ||||
736 | break; | |||
737 | } | |||
738 | case SID_TOOLBAR_MODE(5000 + 1728): | |||
739 | { | |||
740 | const SfxStringItem* pModeName = rReq.GetArg<SfxStringItem>( SID_TOOLBAR_MODE(5000 + 1728) ); | |||
741 | ||||
742 | if ( !pModeName ) | |||
743 | { | |||
744 | bDone = true; | |||
745 | break; | |||
746 | } | |||
747 | ||||
748 | OUString aNewName(pModeName->GetValue()); | |||
749 | uno::Reference< uno::XComponentContext > xContext = | |||
750 | ::comphelper::getProcessComponentContext(); | |||
751 | ||||
752 | // Get information about current frame and module | |||
753 | Reference<XFrame> xCurrentFrame; | |||
754 | vcl::EnumContext::Application eCurrentApp = vcl::EnumContext::Application::NONE; | |||
755 | OUString aCurrentMode; | |||
756 | ||||
757 | SfxViewFrame* pViewFrame = SfxViewFrame::Current(); | |||
758 | if( pViewFrame ) | |||
759 | { | |||
760 | xCurrentFrame = pViewFrame->GetFrame().GetFrameInterface(); | |||
761 | ||||
762 | const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create( xContext ); | |||
763 | eCurrentApp = vcl::EnumContext::GetApplicationEnum( xModuleManager->identify( xCurrentFrame ) ); | |||
764 | ||||
765 | OUStringBuffer aPath("org.openoffice.Office.UI.ToolbarMode/Applications/"); | |||
766 | aPath.append( lcl_getAppName( eCurrentApp ) ); | |||
767 | ||||
768 | const utl::OConfigurationTreeRoot aAppNode( | |||
769 | xContext, | |||
770 | aPath.makeStringAndClear(), | |||
771 | true); | |||
772 | if ( !aAppNode.isValid() ) | |||
773 | { | |||
774 | bDone = true; | |||
775 | break; | |||
776 | } | |||
777 | ||||
778 | aCurrentMode = comphelper::getString( aAppNode.getNodeValue( "Active" ) ); | |||
779 | ||||
780 | if ( aCurrentMode == aNewName ) | |||
781 | { | |||
782 | bDone = true; | |||
783 | break; | |||
784 | } | |||
785 | ||||
786 | // Save new toolbar mode for a current module | |||
787 | aAppNode.setNodeValue( "Active", makeAny( aNewName ) ); | |||
788 | aAppNode.commit(); | |||
789 | } | |||
790 | ||||
791 | // Apply settings for all frames | |||
792 | pViewFrame = SfxViewFrame::GetFirst(); | |||
793 | while( pViewFrame ) | |||
794 | { | |||
795 | Reference<XFrame> xFrame = pViewFrame->GetFrame().GetFrameInterface(); | |||
796 | ||||
797 | // We want to change mode only for a current app module, ignore other apps | |||
798 | const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create( xContext ); | |||
799 | vcl::EnumContext::Application eApp = vcl::EnumContext::GetApplicationEnum( xModuleManager->identify( xFrame ) ); | |||
800 | if ( eApp != eCurrentApp ) | |||
801 | { | |||
802 | pViewFrame = SfxViewFrame::GetNext( *pViewFrame ); | |||
803 | continue; | |||
804 | } | |||
805 | ||||
806 | Reference<css::beans::XPropertySet> xPropSet( xFrame, UNO_QUERY ); | |||
807 | Reference<css::frame::XLayoutManager> xLayoutManager; | |||
808 | if ( xPropSet.is() ) | |||
809 | { | |||
810 | try | |||
811 | { | |||
812 | Any aValue = xPropSet->getPropertyValue( "LayoutManager" ); | |||
813 | aValue >>= xLayoutManager; | |||
814 | } | |||
815 | catch ( const css::uno::RuntimeException& ) | |||
816 | { | |||
817 | throw; | |||
818 | } | |||
819 | catch ( css::uno::Exception& ) | |||
820 | { | |||
821 | } | |||
822 | } | |||
823 | ||||
824 | if ( xLayoutManager.is() ) | |||
825 | { | |||
826 | css::uno::Sequence<OUString> aMandatoryToolbars; | |||
827 | css::uno::Sequence<OUString> aUserToolbars; | |||
828 | std::vector<OUString> aBackupList; | |||
829 | OUString aSidebarMode; | |||
830 | ||||
831 | OUStringBuffer aPath( "org.openoffice.Office.UI.ToolbarMode/Applications/" ); | |||
832 | aPath.append( lcl_getAppName( eApp ) ); | |||
833 | aPath.append( "/Modes" ); | |||
834 | ||||
835 | // Read mode settings | |||
836 | const utl::OConfigurationTreeRoot aModesNode( | |||
837 | xContext, | |||
838 | aPath.makeStringAndClear(), | |||
839 | true); | |||
840 | if ( !aModesNode.isValid() ) | |||
841 | { | |||
842 | bDone = true; | |||
843 | break; | |||
844 | } | |||
845 | ||||
846 | const Sequence<OUString> aModeNodeNames( aModesNode.getNodeNames() ); | |||
847 | ||||
848 | for ( const auto& rModeNodeName : aModeNodeNames ) | |||
849 | { | |||
850 | const utl::OConfigurationNode aModeNode( aModesNode.openNode( rModeNodeName ) ); | |||
851 | if ( !aModeNode.isValid() ) | |||
852 | continue; | |||
853 | ||||
854 | OUString aCommandArg = comphelper::getString( aModeNode.getNodeValue( "CommandArg" ) ); | |||
855 | ||||
856 | if ( aCommandArg == aNewName ) | |||
857 | { | |||
858 | aMandatoryToolbars = aModeNode.getNodeValue( "Toolbars" ).get< uno::Sequence<OUString> >(); | |||
859 | aUserToolbars = aModeNode.getNodeValue( "UserToolbars" ).get< uno::Sequence<OUString> >(); | |||
860 | aSidebarMode = comphelper::getString( aModeNode.getNodeValue( "Sidebar" ) ); | |||
861 | break; | |||
862 | } | |||
863 | } | |||
864 | ||||
865 | // Backup visible toolbar list and hide all toolbars | |||
866 | const Sequence<Reference<XUIElement>> aUIElements = xLayoutManager->getElements(); | |||
867 | for ( const Reference< XUIElement >& xUIElement : aUIElements ) | |||
868 | { | |||
869 | Reference< XPropertySet > xPropertySet( xUIElement, UNO_QUERY ); | |||
870 | if ( xPropertySet.is() && xUIElement.is() ) | |||
871 | { | |||
872 | try | |||
873 | { | |||
874 | OUString aResName; | |||
875 | sal_Int16 nType( -1 ); | |||
876 | xPropertySet->getPropertyValue( "Type" ) >>= nType; | |||
877 | xPropertySet->getPropertyValue( "ResourceURL" ) >>= aResName; | |||
878 | ||||
879 | if (( nType == css::ui::UIElementType::TOOLBAR ) && | |||
880 | !aResName.isEmpty() ) | |||
881 | { | |||
882 | if ( xLayoutManager->isElementVisible( aResName ) ) | |||
883 | { | |||
884 | aBackupList.push_back( aResName ); | |||
885 | } | |||
886 | xLayoutManager->hideElement( aResName ); | |||
887 | } | |||
888 | } | |||
889 | catch ( const Exception& ) | |||
890 | { | |||
891 | } | |||
892 | } | |||
893 | } | |||
894 | ||||
895 | // Show/Hide the Notebookbar | |||
896 | const SfxStringItem pItem(SID_NOTEBOOKBAR(10000 + 338), aNewName); | |||
897 | pViewFrame->GetDispatcher()->ExecuteList(SID_NOTEBOOKBAR(10000 + 338), SfxCallMode::SYNCHRON, {&pItem}); | |||
898 | ||||
899 | // Show toolbars | |||
900 | for ( const OUString& rName : std::as_const(aMandatoryToolbars) ) | |||
901 | { | |||
902 | xLayoutManager->createElement( rName ); | |||
903 | xLayoutManager->showElement( rName ); | |||
904 | } | |||
905 | ||||
906 | for ( const OUString& rName : std::as_const(aUserToolbars) ) | |||
907 | { | |||
908 | xLayoutManager->createElement( rName ); | |||
909 | xLayoutManager->showElement( rName ); | |||
910 | } | |||
911 | ||||
912 | // Sidebar | |||
913 | pViewFrame->ShowChildWindow( SID_SIDEBAR(10000 + 336) ); | |||
914 | ||||
915 | sfx2::sidebar::SidebarController* pSidebar = | |||
916 | sfx2::sidebar::SidebarController::GetSidebarControllerForFrame( xFrame ); | |||
917 | if ( pSidebar ) | |||
918 | { | |||
919 | if ( aSidebarMode == "Arrow" ) | |||
920 | { | |||
921 | pSidebar->FadeOut(); | |||
922 | } | |||
923 | else if ( aSidebarMode == "Tabs" ) | |||
924 | { | |||
925 | pSidebar->FadeIn(); | |||
926 | pSidebar->RequestOpenDeck(); | |||
927 | pSidebar->RequestCloseDeck(); | |||
928 | } | |||
929 | else if ( aSidebarMode == "Opened" ) | |||
930 | { | |||
931 | pSidebar->FadeIn(); | |||
932 | pSidebar->RequestOpenDeck(); | |||
933 | } | |||
934 | } | |||
935 | ||||
936 | // Save settings | |||
937 | if ( pViewFrame == SfxViewFrame::Current() ) | |||
938 | { | |||
939 | css::uno::Sequence<OUString> aBackup( comphelper::containerToSequence(aBackupList) ); | |||
940 | ||||
941 | for ( const auto& rModeNodeName : aModeNodeNames ) | |||
942 | { | |||
943 | const utl::OConfigurationNode aModeNode( aModesNode.openNode( rModeNodeName ) ); | |||
944 | if ( !aModeNode.isValid() ) | |||
945 | continue; | |||
946 | ||||
947 | OUString aCommandArg = comphelper::getString( aModeNode.getNodeValue( "CommandArg" ) ); | |||
948 | ||||
949 | if ( aCommandArg == aCurrentMode ) | |||
950 | { | |||
951 | aModeNode.setNodeValue( "UserToolbars", makeAny( aBackup ) ); | |||
952 | break; | |||
953 | } | |||
954 | } | |||
955 | aModesNode.commit(); | |||
956 | } | |||
957 | } | |||
958 | ||||
959 | pViewFrame = SfxViewFrame::GetNext(*pViewFrame); | |||
960 | } | |||
961 | ||||
962 | bDone = true; | |||
963 | break; | |||
964 | } | |||
965 | case SID_AVAILABLE_TOOLBARS(5000 + 1698): | |||
966 | { | |||
967 | const SfxStringItem* pToolbarName = rReq.GetArg<SfxStringItem>(SID_AVAILABLE_TOOLBARS(5000 + 1698)); | |||
968 | ||||
969 | if ( pToolbarName ) | |||
970 | { | |||
971 | Reference < XDesktop2 > xDesktop = Desktop::create ( ::comphelper::getProcessComponentContext() ); | |||
972 | Reference< XFrame > xFrame = xDesktop->getActiveFrame(); | |||
973 | ||||
974 | Reference< css::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY ); | |||
975 | Reference< css::frame::XLayoutManager > xLayoutManager; | |||
976 | if ( xPropSet.is() ) | |||
977 | { | |||
978 | try | |||
979 | { | |||
980 | Any aValue = xPropSet->getPropertyValue("LayoutManager"); | |||
981 | aValue >>= xLayoutManager; | |||
982 | } | |||
983 | catch ( const css::uno::RuntimeException& ) | |||
984 | { | |||
985 | throw; | |||
986 | } | |||
987 | catch ( css::uno::Exception& ) | |||
988 | { | |||
989 | } | |||
990 | } | |||
991 | ||||
992 | if ( xLayoutManager.is() ) | |||
993 | { | |||
994 | OUStringBuffer aBuf( "private:resource/toolbar/" ); | |||
995 | aBuf.append( pToolbarName->GetValue() ); | |||
996 | ||||
997 | // Evaluate Parameter | |||
998 | OUString aToolbarName( aBuf.makeStringAndClear() ); | |||
999 | bool bShow( !xLayoutManager->isElementVisible( aToolbarName )); | |||
1000 | ||||
1001 | if ( bShow ) | |||
1002 | { | |||
1003 | xLayoutManager->createElement( aToolbarName ); | |||
1004 | xLayoutManager->showElement( aToolbarName ); | |||
1005 | } | |||
1006 | else | |||
1007 | xLayoutManager->hideElement( aToolbarName ); | |||
1008 | } | |||
1009 | } | |||
1010 | ||||
1011 | bDone = true; | |||
1012 | break; | |||
1013 | } | |||
1014 | case SID_MENUBAR(10000 + 339): | |||
1015 | { | |||
1016 | sfx2::SfxNotebookBar::ToggleMenubar(); | |||
1017 | bDone = true; | |||
1018 | break; | |||
1019 | } | |||
1020 | case SID_SAFE_MODE(5000 + 303): | |||
1021 | { | |||
1022 | SafeModeQueryDialog aDialog(rReq.GetFrameWeld()); | |||
1023 | aDialog.run(); | |||
1024 | break; | |||
1025 | } | |||
1026 | ||||
1027 | default: | |||
1028 | break; | |||
1029 | } | |||
1030 | ||||
1031 | if ( bDone ) | |||
1032 | rReq.Done(); | |||
1033 | } | |||
1034 | ||||
1035 | void SfxApplication::MiscState_Impl(SfxItemSet &rSet) | |||
1036 | { | |||
1037 | const sal_uInt16 *pRanges = rSet.GetRanges(); | |||
1038 | DBG_ASSERT(pRanges && *pRanges, "Set without range")do { if (true && (!(pRanges && *pRanges))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1038" ": "), "%s", "Set without range"); } } while (false ); | |||
1039 | while ( *pRanges ) | |||
1040 | { | |||
1041 | for(sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich) | |||
1042 | { | |||
1043 | switch(nWhich) | |||
1044 | { | |||
1045 | case SID_TEMPLATE_ADDRESSBOKSOURCE(5000 + 1655): | |||
1046 | if ( !SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::EModule::DATABASE) ) | |||
1047 | rSet.Put(SfxVisibilityItem(nWhich, false)); | |||
1048 | break; | |||
1049 | case SID_QUITAPP(5000 + 300): | |||
1050 | { | |||
1051 | if ( pImpl->nDocModalMode ) | |||
1052 | rSet.DisableItem(nWhich); | |||
1053 | else | |||
1054 | rSet.Put(SfxStringItem(nWhich, SfxResId(STR_QUITAPPreinterpret_cast<char const *>("STR_QUITAPP" "\004" u8"E~xit %PRODUCTNAME" )))); | |||
1055 | break; | |||
1056 | } | |||
1057 | ||||
1058 | case SID_CONFIG(5000 + 904): | |||
1059 | case SID_TOOLBOXOPTIONS(5000 + 907): | |||
1060 | case SID_CONFIGSTATUSBAR(5000 + 921): | |||
1061 | case SID_CONFIGMENU(5000 + 924): | |||
1062 | case SID_CONFIGACCEL(5000 + 925): | |||
1063 | case SID_CONFIGEVENT(5000 + 926): | |||
1064 | { | |||
1065 | if( SvtMiscOptions().DisableUICustomization() ) | |||
1066 | rSet.DisableItem(nWhich); | |||
1067 | break; | |||
1068 | } | |||
1069 | ||||
1070 | #if HAVE_FEATURE_SCRIPTING1 | |||
1071 | case SID_BASICSTOP(5000 + 958): | |||
1072 | if ( !StarBASIC::IsRunning() ) | |||
1073 | rSet.DisableItem(nWhich); | |||
1074 | break; | |||
1075 | #endif | |||
1076 | ||||
1077 | case SID_HELPTIPS(5000 + 404): | |||
1078 | { | |||
1079 | rSet.Put( SfxBoolItem( SID_HELPTIPS(5000 + 404), Help::IsQuickHelpEnabled() ) ); | |||
1080 | } | |||
1081 | break; | |||
1082 | case SID_HELPBALLOONS(5000 + 403): | |||
1083 | { | |||
1084 | rSet.Put( SfxBoolItem( SID_HELPBALLOONS(5000 + 403), Help::IsBalloonHelpEnabled() ) ); | |||
1085 | } | |||
1086 | break; | |||
1087 | ||||
1088 | case SID_EXTENDEDHELP(5000 + 402): | |||
1089 | { | |||
1090 | } | |||
1091 | break; | |||
1092 | ||||
1093 | case SID_CLOSEDOCS(5000 + 595): | |||
1094 | { | |||
1095 | Reference < XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() ); | |||
1096 | Reference< XIndexAccess > xTasks = xDesktop->getFrames(); | |||
1097 | if ( !xTasks.is() || !xTasks->getCount() ) | |||
1098 | rSet.DisableItem(nWhich); | |||
1099 | break; | |||
1100 | } | |||
1101 | ||||
1102 | case SID_SAVEDOCS(5000 + 309): | |||
1103 | { | |||
1104 | bool bModified = false; | |||
1105 | for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst(); | |||
1106 | pObjSh; | |||
1107 | pObjSh = SfxObjectShell::GetNext( *pObjSh ) ) | |||
1108 | { | |||
1109 | if ( pObjSh->IsModified() ) | |||
1110 | { | |||
1111 | bModified = true; | |||
1112 | break; | |||
1113 | } | |||
1114 | } | |||
1115 | ||||
1116 | if ( !bModified ) | |||
1117 | rSet.DisableItem( nWhich ); | |||
1118 | break; | |||
1119 | } | |||
1120 | ||||
1121 | case SID_TEMPLATE_MANAGER(5000 + 1727): | |||
1122 | { | |||
1123 | SvtMiscOptions aMiscOptions; | |||
1124 | if ( !aMiscOptions.IsExperimentalMode() ) | |||
1125 | { | |||
1126 | rSet.DisableItem( nWhich ); | |||
1127 | rSet.Put( SfxVisibilityItem( nWhich, false ) ); | |||
1128 | } | |||
1129 | } | |||
1130 | break; | |||
1131 | ||||
1132 | case SID_ZOOM_50_PERCENT(10000 + 1421): | |||
1133 | case SID_ZOOM_75_PERCENT(10000 + 1422): | |||
1134 | case SID_ZOOM_100_PERCENT((10000 + 99)): | |||
1135 | case SID_ZOOM_150_PERCENT(10000 + 1423): | |||
1136 | case SID_ZOOM_200_PERCENT(10000 + 1424): | |||
1137 | case SID_ZOOM_OPTIMAL((27000 +99)): | |||
1138 | case SID_ZOOM_ENTIRE_PAGE((10000 + 100)): | |||
1139 | case SID_ZOOM_PAGE_WIDTH(10000 + 1420): | |||
1140 | { | |||
1141 | SfxObjectShell* pCurrentShell = SfxObjectShell::Current(); | |||
1142 | ||||
1143 | const SfxPoolItem *pItem; | |||
1144 | SfxItemState aState = pCurrentShell ? | |||
1145 | pCurrentShell->GetDispatcher()->QueryState(SID_ATTR_ZOOMTypedWhichId<SvxZoomItem>(10000 + 0), pItem) : SfxItemState::DISABLED; | |||
1146 | if ( aState == SfxItemState::DISABLED ) | |||
1147 | rSet.DisableItem( nWhich ); | |||
1148 | } | |||
1149 | break; | |||
1150 | ||||
1151 | case SID_MENUBAR(10000 + 339): | |||
1152 | { | |||
1153 | Reference < XDesktop2 > xDesktop = Desktop::create ( ::comphelper::getProcessComponentContext() ); | |||
1154 | Reference< XFrame > xFrame = xDesktop->getActiveFrame(); | |||
1155 | ||||
1156 | Reference< css::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY ); | |||
1157 | Reference< css::frame::XLayoutManager > xLayoutManager; | |||
1158 | if ( xPropSet.is() ) | |||
1159 | { | |||
1160 | try | |||
1161 | { | |||
1162 | Any aValue = xPropSet->getPropertyValue("LayoutManager"); | |||
1163 | aValue >>= xLayoutManager; | |||
1164 | } | |||
1165 | catch ( const css::uno::RuntimeException& ) | |||
1166 | { | |||
1167 | throw; | |||
1168 | } | |||
1169 | catch ( css::uno::Exception& ) | |||
1170 | { | |||
1171 | } | |||
1172 | } | |||
1173 | ||||
1174 | if ( xLayoutManager.is() ) | |||
1175 | { | |||
1176 | const bool bState | |||
1177 | = xLayoutManager->getElement("private:resource/menubar/menubar").is() | |||
1178 | && xLayoutManager->isElementVisible( | |||
1179 | "private:resource/menubar/menubar"); | |||
1180 | ||||
1181 | SfxBoolItem aItem( SID_MENUBAR(10000 + 339), bState ); | |||
1182 | rSet.Put( aItem ); | |||
1183 | } | |||
1184 | break; | |||
1185 | } | |||
1186 | case SID_SAFE_MODE(5000 + 303): | |||
1187 | { | |||
1188 | // no restart in safe mode when already in safe mode | |||
1189 | if ( Application::IsSafeModeEnabled() ) | |||
1190 | rSet.DisableItem( SID_SAFE_MODE(5000 + 303) ); | |||
1191 | break; | |||
1192 | } | |||
1193 | ||||
1194 | default: | |||
1195 | break; | |||
1196 | } | |||
1197 | } | |||
1198 | ||||
1199 | ++pRanges; | |||
1200 | } | |||
1201 | } | |||
1202 | ||||
1203 | #if HAVE_FEATURE_SCRIPTING1 | |||
1204 | ||||
1205 | #ifndef DISABLE_DYNLOADING | |||
1206 | ||||
1207 | typedef rtl_uString* (*basicide_choose_macro)(void*, void*, void*, sal_Bool); | |||
1208 | ||||
1209 | #else | |||
1210 | ||||
1211 | extern "C" rtl_uString* basicide_choose_macro(void*, void*, void*, sal_Bool); | |||
1212 | ||||
1213 | #endif | |||
1214 | ||||
1215 | static OUString ChooseMacro(weld::Window* pParent, const Reference<XModel>& rxLimitToDocument, const Reference<XFrame>& xDocFrame, bool bChooseOnly) | |||
1216 | { | |||
1217 | #ifndef DISABLE_DYNLOADING | |||
1218 | basicide_choose_macro pSymbol = reinterpret_cast<basicide_choose_macro>(sfx2::getBasctlFunction("basicide_choose_macro")); | |||
1219 | #else | |||
1220 | #define pSymbol basicide_choose_macro | |||
1221 | #endif | |||
1222 | ||||
1223 | // call basicide_choose_macro in basctl | |||
1224 | rtl_uString* pScriptURL = pSymbol(pParent, rxLimitToDocument.get(), xDocFrame.get(), bChooseOnly); | |||
1225 | OUString aScriptURL( pScriptURL ); | |||
1226 | rtl_uString_release( pScriptURL ); | |||
1227 | return aScriptURL; | |||
1228 | ||||
1229 | #ifdef DISABLE_DYNLOADING | |||
1230 | #undef pSymbol | |||
1231 | #endif | |||
1232 | } | |||
1233 | ||||
1234 | #endif | |||
1235 | ||||
1236 | namespace | |||
1237 | { | |||
1238 | #if HAVE_FEATURE_SCRIPTING1 | |||
1239 | weld::Window* lcl_getDialogParent(const Reference<XFrame>& rxFrame) | |||
1240 | { | |||
1241 | Reference<awt::XWindow> xContainerWindow; | |||
1242 | if (rxFrame.is()) | |||
1243 | xContainerWindow = rxFrame->getContainerWindow(); | |||
1244 | return Application::GetFrameWeld(xContainerWindow); | |||
1245 | } | |||
1246 | ||||
1247 | SfxViewFrame* lcl_getBasicIDEViewFrame( SfxObjectShell const * i_pBasicIDE ) | |||
1248 | { | |||
1249 | SfxViewFrame* pView = SfxViewFrame::GetFirst( i_pBasicIDE ); | |||
1250 | while ( pView ) | |||
1251 | { | |||
1252 | if ( pView->GetObjectShell()->GetFactory().GetDocumentServiceName() == "com.sun.star.script.BasicIDE" ) | |||
1253 | break; | |||
1254 | pView = SfxViewFrame::GetNext( *pView, i_pBasicIDE ); | |||
1255 | } | |||
1256 | return pView; | |||
1257 | } | |||
1258 | Reference< XFrame > lcl_findStartModuleFrame( const Reference<XComponentContext> & rxContext ) | |||
1259 | { | |||
1260 | try | |||
1261 | { | |||
1262 | Reference < XDesktop2 > xDesktop = Desktop::create( rxContext ); | |||
1263 | Reference < XIndexAccess > xContainer( xDesktop->getFrames(), UNO_QUERY_THROW ); | |||
1264 | ||||
1265 | Reference< XModuleManager2 > xCheck = ModuleManager::create(rxContext); | |||
1266 | ||||
1267 | sal_Int32 nCount = xContainer->getCount(); | |||
1268 | for ( sal_Int32 i=0; i<nCount; ++i ) | |||
1269 | { | |||
1270 | try | |||
1271 | { | |||
1272 | Reference < XFrame > xFrame( xContainer->getByIndex(i), UNO_QUERY_THROW ); | |||
1273 | OUString sModule = xCheck->identify( xFrame ); | |||
1274 | if ( sModule == "com.sun.star.frame.StartModule" ) | |||
1275 | return xFrame; | |||
1276 | } | |||
1277 | catch( const UnknownModuleException& ) | |||
1278 | { | |||
1279 | // silence | |||
1280 | } | |||
1281 | catch(const Exception&) | |||
1282 | { | |||
1283 | // re-throw, caught below | |||
1284 | throw; | |||
1285 | } | |||
1286 | } | |||
1287 | } | |||
1288 | catch( const Exception& ) | |||
1289 | { | |||
1290 | DBG_UNHANDLED_EXCEPTION("sfx.appl")DbgUnhandledException( DbgGetCaughtException(), __func__, "/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1290" ": ", "sfx.appl" );; | |||
1291 | } | |||
1292 | return nullptr; | |||
1293 | } | |||
1294 | #endif // HAVE_FEATURE_SCRIPTING | |||
1295 | } | |||
1296 | ||||
1297 | void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) | |||
1298 | { | |||
1299 | switch ( rReq.GetSlot() ) | |||
1300 | { | |||
1301 | case SID_OPTIONS_TREEDIALOG( (30000 + 768) + 862): | |||
1302 | { | |||
1303 | OUString sPageURL; | |||
1304 | const SfxStringItem* pURLItem = rReq.GetArg<SfxStringItem>(SID_OPTIONS_PAGEURL(5000 + 1713)); | |||
1305 | if ( pURLItem ) | |||
1306 | sPageURL = pURLItem->GetValue(); | |||
1307 | Reference <XFrame> xFrame(GetRequestFrame(rReq)); | |||
1308 | SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); | |||
1309 | VclPtr<VclAbstractDialog> pDlg = | |||
1310 | pFact->CreateFrameDialog(rReq.GetFrameWeld(), xFrame, rReq.GetSlot(), sPageURL ); | |||
1311 | short nRet = pDlg->Execute(); | |||
1312 | pDlg.disposeAndClear(); | |||
1313 | SfxViewFrame* pView = SfxViewFrame::GetFirst(); | |||
1314 | while ( pView ) | |||
1315 | { | |||
1316 | if (nRet == RET_OK) | |||
1317 | { | |||
1318 | SfxObjectShell* pObjSh = pView->GetObjectShell(); | |||
1319 | if (pObjSh) | |||
1320 | pObjSh->SetConfigOptionsChecked(false); | |||
1321 | } | |||
1322 | pView->GetBindings().InvalidateAll(false); | |||
1323 | pView = SfxViewFrame::GetNext( *pView ); | |||
1324 | } | |||
1325 | break; | |||
1326 | } | |||
1327 | ||||
1328 | case SID_MORE_DICTIONARIES(5000 + 1714): | |||
1329 | { | |||
1330 | try | |||
1331 | { | |||
1332 | uno::Reference< uno::XComponentContext > xContext = | |||
1333 | ::comphelper::getProcessComponentContext(); | |||
1334 | uno::Reference< css::system::XSystemShellExecute > xSystemShell( | |||
1335 | css::system::SystemShellExecute::create(xContext) ); | |||
1336 | ||||
1337 | // read repository URL from configuration | |||
1338 | OUString sTemplRepoURL(officecfg::Office::Common::Dictionaries::RepositoryURL::get()); | |||
1339 | ||||
1340 | if ( xSystemShell.is() && !sTemplRepoURL.isEmpty() ) | |||
1341 | { | |||
1342 | // read locale from configuration | |||
1343 | OUString sLocale(officecfg::Setup::L10N::ooLocale::get()); | |||
1344 | if (sLocale.isEmpty()) | |||
1345 | sLocale = "en-US"; | |||
1346 | ||||
1347 | OUString aURLBuf = sTemplRepoURL + "?lang=" + sLocale; | |||
1348 | xSystemShell->execute( | |||
1349 | aURLBuf, | |||
1350 | OUString(), | |||
1351 | css::system::SystemShellExecuteFlags::URIS_ONLY ); | |||
1352 | } | |||
1353 | } | |||
1354 | catch( const css::uno::Exception& ) | |||
1355 | { | |||
1356 | TOOLS_WARN_EXCEPTION( "sfx.appl", "SfxApplication::OfaExec_Impl(SID_MORE_DICTIONARIES)" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "sfx.appl")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "SfxApplication::OfaExec_Impl(SID_MORE_DICTIONARIES)" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1356" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "SfxApplication::OfaExec_Impl(SID_MORE_DICTIONARIES)" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "SfxApplication::OfaExec_Impl(SID_MORE_DICTIONARIES)" << " " << exceptionToString(tools_warn_exception ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1356" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "SfxApplication::OfaExec_Impl(SID_MORE_DICTIONARIES)" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1356" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "SfxApplication::OfaExec_Impl(SID_MORE_DICTIONARIES)" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "SfxApplication::OfaExec_Impl(SID_MORE_DICTIONARIES)" << " " << exceptionToString(tools_warn_exception ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1356" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
1357 | } | |||
1358 | break; | |||
1359 | } | |||
1360 | #if HAVE_FEATURE_SCRIPTING1 | |||
1361 | case SID_BASICIDE_APPEAR( (30000 + 768) + 15 ): | |||
1362 | { | |||
1363 | SfxViewFrame* pView = lcl_getBasicIDEViewFrame( nullptr ); | |||
1364 | if ( !pView ) | |||
1365 | { | |||
1366 | SfxObjectShell* pBasicIDE = SfxObjectShell::CreateObject( "com.sun.star.script.BasicIDE" ); | |||
1367 | pBasicIDE->DoInitNew(); | |||
1368 | pBasicIDE->SetModified( false ); | |||
1369 | try | |||
1370 | { | |||
1371 | // load the Basic IDE via direct access to the SFX frame loader. A generic loadComponentFromURL | |||
1372 | // (which could be done via SfxViewFrame::LoadDocumentIntoFrame) is not feasible here, since the Basic IDE | |||
1373 | // does not really play nice with the framework's concept. For instance, it is a "singleton document", | |||
1374 | // which conflicts, at the latest, with the framework's concept of loading into _blank frames. | |||
1375 | // So, since we know that our frame loader can handle it, we skip the generic framework loader | |||
1376 | // mechanism, and the type detection (which doesn't know about the Basic IDE). | |||
1377 | Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); | |||
1378 | Reference< XSynchronousFrameLoader > xLoader( | |||
1379 | xContext->getServiceManager()->createInstanceWithContext("com.sun.star.comp.office.FrameLoader", xContext), | |||
1380 | UNO_QUERY_THROW ); | |||
1381 | ::comphelper::NamedValueCollection aLoadArgs; | |||
1382 | aLoadArgs.put( "Model", pBasicIDE->GetModel() ); | |||
1383 | aLoadArgs.put( "URL", OUString( "private:factory/sbasic" ) ); | |||
1384 | ||||
1385 | Reference< XFrame > xTargetFrame( lcl_findStartModuleFrame( xContext ) ); | |||
1386 | if ( !xTargetFrame.is() ) | |||
1387 | xTargetFrame = SfxFrame::CreateBlankFrame(); | |||
1388 | ENSURE_OR_THROW( xTargetFrame.is(), "could not obtain a frameto load the Basic IDE into!" )if( !(xTargetFrame.is()) ){ do { if (true && (!(xTargetFrame .is()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ( "legacy.osl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1388" ": "), "%s", "could not obtain a frameto load the Basic IDE into!" ); } } while (false); throw css::uno::RuntimeException( __func__ + OUStringLiteral(u",\n" "could not obtain a frameto load the Basic IDE into!" ), css::uno::Reference< css::uno::XInterface >() ); }; | |||
1389 | ||||
1390 | xLoader->load( aLoadArgs.getPropertyValues(), xTargetFrame ); | |||
1391 | } | |||
1392 | catch( const Exception& ) | |||
1393 | { | |||
1394 | DBG_UNHANDLED_EXCEPTION("sfx.appl")DbgUnhandledException( DbgGetCaughtException(), __func__, "/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1394" ": ", "sfx.appl" );; | |||
1395 | } | |||
1396 | ||||
1397 | pView = lcl_getBasicIDEViewFrame( pBasicIDE ); | |||
1398 | if ( pView ) | |||
1399 | pView->SetName( "BASIC:1" ); | |||
1400 | } | |||
1401 | ||||
1402 | if ( pView ) | |||
1403 | pView->GetFrame().Appear(); | |||
1404 | ||||
1405 | const SfxItemSet* pArgs = rReq.GetArgs(); | |||
1406 | if ( pArgs && pView ) | |||
1407 | { | |||
1408 | SfxViewShell* pViewShell = pView->GetViewShell(); | |||
1409 | SfxObjectShell* pObjShell = pView->GetObjectShell(); | |||
1410 | if ( pViewShell && pObjShell ) | |||
1411 | { | |||
1412 | SfxRequest aReq( SID_BASICIDE_SHOWWINDOW( (30000 + 768) + 44 ), SfxCallMode::SYNCHRON, pObjShell->GetPool() ); | |||
1413 | aReq.SetArgs( *pArgs ); | |||
1414 | pViewShell->ExecuteSlot( aReq ); | |||
1415 | } | |||
1416 | } | |||
1417 | ||||
1418 | rReq.Done(); | |||
1419 | } | |||
1420 | break; | |||
1421 | ||||
1422 | case SID_BASICCHOOSER(5000 + 959): | |||
1423 | { | |||
1424 | const SfxItemSet* pArgs = rReq.GetArgs(); | |||
1425 | const SfxPoolItem* pItem; | |||
1426 | bool bChooseOnly = false; | |||
1427 | Reference< XModel > xLimitToModel; | |||
1428 | if(pArgs && SfxItemState::SET == pArgs->GetItemState(SID_RECORDMACRO(5000 + 1669), false, &pItem) ) | |||
1429 | { | |||
1430 | bool bRecord = static_cast<const SfxBoolItem*>(pItem)->GetValue(); | |||
1431 | if ( bRecord ) | |||
1432 | { | |||
1433 | // !Hack | |||
1434 | bChooseOnly = false; | |||
1435 | SfxObjectShell* pCurrentShell = SfxObjectShell::Current(); | |||
1436 | OSL_ENSURE( pCurrentShell, "macro recording outside an SFX document?" )do { if (true && (!(pCurrentShell))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1436" ": "), "%s", "macro recording outside an SFX document?" ); } } while (false); | |||
1437 | if ( pCurrentShell ) | |||
1438 | xLimitToModel = pCurrentShell->GetModel(); | |||
1439 | } | |||
1440 | } | |||
1441 | ||||
1442 | Reference <XFrame> xFrame(GetRequestFrame(rReq)); | |||
1443 | rReq.SetReturnValue(SfxStringItem(rReq.GetSlot(), ChooseMacro(rReq.GetFrameWeld(), xLimitToModel, xFrame, bChooseOnly))); | |||
1444 | rReq.Done(); | |||
1445 | } | |||
1446 | break; | |||
1447 | ||||
1448 | case SID_MACROORGANIZER(5000 + 1691): | |||
1449 | { | |||
1450 | SAL_INFO("sfx.appl", "handling SID_MACROORGANIZER")do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "sfx.appl")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "handling SID_MACROORGANIZER" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1450" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "handling SID_MACROORGANIZER"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "handling SID_MACROORGANIZER"; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1450" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "handling SID_MACROORGANIZER") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1450" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "handling SID_MACROORGANIZER"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "handling SID_MACROORGANIZER"; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1450" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1451 | const SfxItemSet* pArgs = rReq.GetArgs(); | |||
1452 | const SfxPoolItem* pItem; | |||
1453 | sal_Int16 nTabId = 0; | |||
1454 | if(pArgs && SfxItemState::SET == pArgs->GetItemState(SID_MACROORGANIZER(5000 + 1691), false, &pItem) ) | |||
1455 | { | |||
1456 | nTabId = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); | |||
1457 | } | |||
1458 | ||||
1459 | SfxApplication::MacroOrganizer(rReq.GetFrameWeld(), nTabId); | |||
1460 | rReq.Done(); | |||
1461 | } | |||
1462 | break; | |||
1463 | ||||
1464 | case SID_RUNMACRO(5000 + 1692): | |||
1465 | { | |||
1466 | SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); | |||
1467 | SAL_INFO("sfx.appl", "SfxApplication::OfaExec_Impl: case ScriptOrg")do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "sfx.appl")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "SfxApplication::OfaExec_Impl: case ScriptOrg" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1467" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "SfxApplication::OfaExec_Impl: case ScriptOrg" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "SfxApplication::OfaExec_Impl: case ScriptOrg"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1467" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "SfxApplication::OfaExec_Impl: case ScriptOrg") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1467" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "SfxApplication::OfaExec_Impl: case ScriptOrg" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "SfxApplication::OfaExec_Impl: case ScriptOrg"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1467" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1468 | ||||
1469 | Reference <XFrame> xFrame(GetRequestFrame(rReq)); | |||
1470 | if ( !xFrame.is() ) | |||
1471 | { | |||
1472 | const SfxViewFrame* pViewFrame = SfxViewFrame::Current(); | |||
1473 | if ( pViewFrame ) | |||
1474 | xFrame = pViewFrame->GetFrame().GetFrameInterface(); | |||
1475 | } | |||
1476 | ||||
1477 | do // artificial loop for flow control | |||
1478 | { | |||
1479 | ScopedVclPtr<AbstractScriptSelectorDialog> pDlg(pFact->CreateScriptSelectorDialog(lcl_getDialogParent(xFrame), xFrame)); | |||
1480 | OSL_ENSURE( pDlg, "SfxApplication::OfaExec_Impl( SID_RUNMACRO ): no dialog!" )do { if (true && (!(pDlg))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1480" ": "), "%s", "SfxApplication::OfaExec_Impl( SID_RUNMACRO ): no dialog!" ); } } while (false); | |||
1481 | if ( !pDlg ) | |||
1482 | break; | |||
1483 | pDlg->SetRunLabel(); | |||
1484 | ||||
1485 | short nDialogResult = pDlg->Execute(); | |||
1486 | if ( !nDialogResult ) | |||
1487 | break; | |||
1488 | ||||
1489 | Sequence< Any > args; | |||
1490 | Sequence< sal_Int16 > outIndex; | |||
1491 | Sequence< Any > outArgs; | |||
1492 | Any ret; | |||
1493 | ||||
1494 | Reference< XInterface > xScriptContext; | |||
1495 | ||||
1496 | Reference< XController > xController; | |||
1497 | if ( xFrame.is() ) | |||
1498 | xController = xFrame->getController(); | |||
1499 | if ( xController.is() ) | |||
1500 | xScriptContext = xController->getModel(); | |||
1501 | if ( !xScriptContext.is() ) | |||
1502 | xScriptContext = xController; | |||
1503 | ||||
1504 | SfxObjectShell::CallXScript( xScriptContext, pDlg->GetScriptURL(), args, ret, outIndex, outArgs ); | |||
1505 | } | |||
1506 | while ( false ); | |||
1507 | rReq.Done(); | |||
1508 | } | |||
1509 | break; | |||
1510 | ||||
1511 | case SID_SCRIPTORGANIZER(5000 + 1690): | |||
1512 | { | |||
1513 | SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); | |||
1514 | SAL_INFO("sfx.appl", "SfxApplication::OfaExec_Impl: case ScriptOrg")do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "sfx.appl")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "SfxApplication::OfaExec_Impl: case ScriptOrg" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1514" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "SfxApplication::OfaExec_Impl: case ScriptOrg" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "SfxApplication::OfaExec_Impl: case ScriptOrg"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1514" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "SfxApplication::OfaExec_Impl: case ScriptOrg") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1514" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "SfxApplication::OfaExec_Impl: case ScriptOrg" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "SfxApplication::OfaExec_Impl: case ScriptOrg"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1514" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1515 | const SfxItemSet* pArgs = rReq.GetArgs(); | |||
1516 | const SfxPoolItem* pItem; | |||
1517 | OUString aLanguage; | |||
1518 | if(pArgs && SfxItemState::SET == pArgs->GetItemState(SID_SCRIPTORGANIZER(5000 + 1690), false, &pItem) ) | |||
1519 | { | |||
1520 | aLanguage = static_cast<const SfxScriptOrganizerItem*>(pItem)->getLanguage(); | |||
1521 | } | |||
1522 | ||||
1523 | OUString aLang( aLanguage ); | |||
1524 | SAL_INFO("sfx.appl", "SfxApplication::OfaExec_Impl: about to create dialog for: " << aLang)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "sfx.appl")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "SfxApplication::OfaExec_Impl: about to create dialog for: " << aLang) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1524" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "SfxApplication::OfaExec_Impl: about to create dialog for: " << aLang), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "SfxApplication::OfaExec_Impl: about to create dialog for: " << aLang; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1524" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "SfxApplication::OfaExec_Impl: about to create dialog for: " << aLang) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1524" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "SfxApplication::OfaExec_Impl: about to create dialog for: " << aLang), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "SfxApplication::OfaExec_Impl: about to create dialog for: " << aLang; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1524" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1525 | ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSvxScriptOrgDialog(rReq.GetFrameWeld(), aLanguage)); | |||
1526 | if( pDlg ) | |||
1527 | { | |||
1528 | pDlg->Execute(); | |||
1529 | } | |||
1530 | else | |||
1531 | { | |||
1532 | SAL_WARN("sfx.appl", "no dialog!!!")do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "sfx.appl")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "no dialog!!!") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1532" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "no dialog!!!"), 0); } else { ::std:: ostringstream sal_detail_stream; sal_detail_stream << "no dialog!!!" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1532" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "no dialog!!!") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1532" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "no dialog!!!"), 0); } else { ::std:: ostringstream sal_detail_stream; sal_detail_stream << "no dialog!!!" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1532" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1533 | } | |||
1534 | rReq.Done(); | |||
1535 | } | |||
1536 | break; | |||
1537 | #endif // HAVE_FEATURE_SCRIPTING | |||
1538 | ||||
1539 | case SID_OFFICE_CHECK_PLZ(5000 + 1610): | |||
1540 | { | |||
1541 | bool bRet = false; | |||
1542 | const SfxStringItem* pStringItem = rReq.GetArg<SfxStringItem>(rReq.GetSlot()); | |||
1543 | ||||
1544 | if ( pStringItem ) | |||
1545 | { | |||
1546 | bRet = true /*!!!SfxIniManager::CheckPLZ( aPLZ )*/; | |||
1547 | } | |||
1548 | #if HAVE_FEATURE_SCRIPTING1 | |||
1549 | else | |||
1550 | SbxBase::SetError( ERRCODE_BASIC_WRONG_ARGSErrCode( ErrCodeArea::Sbx, ErrCodeClass::Sbx, 28) ); | |||
1551 | #endif | |||
1552 | rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bRet ) ); | |||
1553 | } | |||
1554 | break; | |||
1555 | ||||
1556 | case SID_AUTO_CORRECT_DLG(10000 + 424): | |||
1557 | { | |||
1558 | SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); | |||
1559 | SfxItemSet aSet(GetPool(), svl::Items<SID_AUTO_CORRECT_DLG(10000 + 424), SID_AUTO_CORRECT_DLG(10000 + 424)>{}); | |||
1560 | const SfxPoolItem* pItem=nullptr; | |||
1561 | const SfxItemSet* pSet = rReq.GetArgs(); | |||
1562 | SfxItemPool* pSetPool = pSet ? pSet->GetPool() : nullptr; | |||
1563 | if ( pSet && pSet->GetItemState( pSetPool->GetWhich( SID_AUTO_CORRECT_DLG(10000 + 424) ), false, &pItem ) == SfxItemState::SET ) | |||
1564 | aSet.Put( *pItem ); | |||
1565 | ||||
1566 | const SfxViewFrame* pViewFrame = SfxViewFrame::Current(); | |||
1567 | ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateAutoCorrTabDialog(pViewFrame ? pViewFrame->GetWindow().GetFrameWeld() : nullptr, &aSet)); | |||
1568 | pDlg->Execute(); | |||
1569 | ||||
1570 | break; | |||
1571 | } | |||
1572 | ||||
1573 | case SID_NEWSD(5000 + 1686) : | |||
1574 | { | |||
1575 | SvtModuleOptions aModuleOpt; | |||
1576 | if ( !aModuleOpt.IsImpress() ) | |||
1577 | { | |||
1578 | std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr, | |||
1579 | VclMessageType::Warning, VclButtonsType::Ok, | |||
1580 | SfxResId(STR_MODULENOTINSTALLEDreinterpret_cast<char const *>("STR_MODULENOTINSTALLED" "\004" u8"The action could not be executed. The %PRODUCTNAME program module needed for this action is currently not installed." )))); | |||
1581 | xBox->run(); | |||
1582 | return; | |||
1583 | } | |||
1584 | ||||
1585 | Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); | |||
1586 | Reference< frame::XDispatchProvider > xProv = drawing::ModuleDispatcher::create( xContext ); | |||
1587 | ||||
1588 | OUString aCmd = OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() ); | |||
1589 | Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) ); | |||
1590 | Sequence < beans::PropertyValue > aSeq; | |||
1591 | if ( rReq.GetArgs() ) | |||
1592 | TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq ); | |||
1593 | Any aResult = xHelper->executeDispatch( xProv, aCmd, OUString(), 0, aSeq ); | |||
1594 | frame::DispatchResultEvent aEvent; | |||
1595 | bool bSuccess = (aResult >>= aEvent) && | |||
1596 | (aEvent.State == frame::DispatchResultState::SUCCESS); | |||
1597 | rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) ); | |||
1598 | } | |||
1599 | break; | |||
1600 | ||||
1601 | case FN_LABEL(20000 + 1051 ) : | |||
1602 | case FN_BUSINESS_CARD(20000 + 1052) : | |||
1603 | case FN_XFORMS_INIT(20000 + 1053) : | |||
1604 | { | |||
1605 | Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); | |||
1606 | Reference< frame::XDispatchProvider > xProv = text::ModuleDispatcher::create( xContext ); | |||
1607 | ||||
1608 | OUString aCmd = OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() ); | |||
1609 | Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) ); | |||
1610 | Sequence < beans::PropertyValue > aSeq; | |||
1611 | if ( rReq.GetArgs() ) | |||
1612 | TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq ); | |||
1613 | Any aResult = xHelper->executeDispatch( xProv, aCmd, OUString(), 0, aSeq ); | |||
1614 | frame::DispatchResultEvent aEvent; | |||
1615 | bool bSuccess = (aResult >>= aEvent) && | |||
1616 | (aEvent.State == frame::DispatchResultState::SUCCESS); | |||
1617 | rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) ); | |||
1618 | } | |||
1619 | break; | |||
1620 | ||||
1621 | case SID_ADDRESS_DATA_SOURCE(10000 + 934): | |||
1622 | { | |||
1623 | try | |||
1624 | { | |||
1625 | Reference< uno::XComponentContext > xORB = ::comphelper::getProcessComponentContext(); | |||
1626 | Reference< ui::dialogs::XExecutableDialog > xDialog = ui::dialogs::AddressBookSourcePilot::createWithParent(xORB, nullptr); | |||
1627 | xDialog->execute(); | |||
1628 | } | |||
1629 | catch(const css::uno::Exception&) | |||
1630 | { | |||
1631 | DBG_UNHANDLED_EXCEPTION("sfx.appl")DbgUnhandledException( DbgGetCaughtException(), __func__, "/home/maarten/src/libreoffice/core/sfx2/source/appl/appserv.cxx" ":" "1631" ": ", "sfx.appl" );; | |||
1632 | } | |||
1633 | } | |||
1634 | break; | |||
1635 | ||||
1636 | case SID_COMP_BIBLIOGRAPHY(10000 + 880): | |||
1637 | lcl_tryLoadBibliography(); | |||
1638 | break; | |||
1639 | } | |||
1640 | } | |||
1641 | ||||
1642 | void SfxApplication::OfaState_Impl(SfxItemSet &rSet) | |||
1643 | { | |||
1644 | SvtModuleOptions aModuleOpt; | |||
1645 | ||||
1646 | if( !aModuleOpt.IsWriter()) | |||
1647 | { | |||
1648 | rSet.DisableItem( FN_LABEL(20000 + 1051 ) ); | |||
1649 | rSet.DisableItem( FN_BUSINESS_CARD(20000 + 1052) ); | |||
1650 | rSet.DisableItem( FN_XFORMS_INIT(20000 + 1053) ); | |||
1651 | } | |||
1652 | if ( comphelper::LibreOfficeKit::isActive() ) | |||
1653 | rSet.DisableItem( SID_AUTO_CORRECT_DLG(10000 + 424) ); | |||
1654 | ||||
1655 | bool bMacrosDisabled | |||
1656 | = officecfg::Office::Common::Security::Scripting::DisableMacrosExecution::get(); | |||
1657 | if (bMacrosDisabled) | |||
1658 | { | |||
1659 | rSet.DisableItem(SID_RUNMACRO(5000 + 1692)); | |||
1660 | rSet.DisableItem(SID_MACROORGANIZER(5000 + 1691)); | |||
1661 | rSet.DisableItem(SID_SCRIPTORGANIZER(5000 + 1690)); | |||
1662 | rSet.DisableItem(SID_BASICIDE_APPEAR( (30000 + 768) + 15 )); | |||
1663 | } | |||
1664 | } | |||
1665 | ||||
1666 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
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 | #ifndef INCLUDED_VCL_PTR_HXX |
21 | #define INCLUDED_VCL_PTR_HXX |
22 | |
23 | #include <sal/config.h> |
24 | |
25 | #include <rtl/ref.hxx> |
26 | |
27 | #include <utility> |
28 | #include <type_traits> |
29 | |
30 | #ifdef DBG_UTIL |
31 | #ifndef _WIN32 |
32 | #include <vcl/vclmain.hxx> |
33 | #endif |
34 | #endif |
35 | |
36 | class VclReferenceBase; |
37 | |
38 | namespace vcl::detail { |
39 | |
40 | template<typename> |
41 | constexpr bool isIncompleteOrDerivedFromVclReferenceBase(...) { return true; } |
42 | |
43 | template<typename T> constexpr bool isIncompleteOrDerivedFromVclReferenceBase( |
44 | int (*)[sizeof(T)]) |
45 | { return std::is_base_of<VclReferenceBase, T>::value; } |
46 | |
47 | } // namespace vcl::detail |
48 | |
49 | /** |
50 | * A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for references to vcl::Window subclasses. |
51 | * |
52 | * For more details on the design please see vcl/README.lifecycle |
53 | * |
54 | * @param reference_type must be a subclass of vcl::Window |
55 | */ |
56 | template <class reference_type> |
57 | class VclPtr |
58 | { |
59 | static_assert( |
60 | vcl::detail::isIncompleteOrDerivedFromVclReferenceBase<reference_type>( |
61 | nullptr), |
62 | "template argument type must be derived from VclReferenceBase"); |
63 | |
64 | ::rtl::Reference<reference_type> m_rInnerRef; |
65 | |
66 | public: |
67 | /** Constructor... |
68 | */ |
69 | VclPtr() |
70 | : m_rInnerRef() |
71 | {} |
72 | |
73 | /** Constructor... |
74 | */ |
75 | VclPtr (reference_type * pBody) |
76 | : m_rInnerRef(pBody) |
77 | {} |
78 | |
79 | /** Constructor... that doesn't take a ref. |
80 | */ |
81 | VclPtr (reference_type * pBody, __sal_NoAcquire) |
82 | : m_rInnerRef(pBody, SAL_NO_ACQUIRE) |
83 | {} |
84 | |
85 | /** Up-casting conversion constructor: Copies interface reference. |
86 | |
87 | Does not work for up-casts to ambiguous bases. For the special case of |
88 | up-casting to Reference< XInterface >, see the corresponding conversion |
89 | operator. |
90 | |
91 | @param rRef another reference |
92 | */ |
93 | template< class derived_type > |
94 | VclPtr( |
95 | const VclPtr< derived_type > & rRef, |
96 | typename std::enable_if< |
97 | std::is_base_of<reference_type, derived_type>::value, int>::type |
98 | = 0 ) |
99 | : m_rInnerRef( static_cast<reference_type*>(rRef) ) |
100 | { |
101 | } |
102 | |
103 | #if defined(DBG_UTIL) && !defined(_WIN32) |
104 | virtual ~VclPtr() |
105 | { |
106 | assert(m_rInnerRef.get() == nullptr || vclmain::isAlive())(static_cast <bool> (m_rInnerRef.get() == nullptr || vclmain ::isAlive()) ? void (0) : __assert_fail ("m_rInnerRef.get() == nullptr || vclmain::isAlive()" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 106, __extension__ __PRETTY_FUNCTION__)); |
107 | // We can be one of the intermediate counts, but if we are the last |
108 | // VclPtr keeping this object alive, then something forgot to call dispose(). |
109 | assert((!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1)(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef ->isDisposed() || m_rInnerRef->getRefCount() > 1) && "someone forgot to call dispose()") ? void (0) : __assert_fail ("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\"" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 110, __extension__ __PRETTY_FUNCTION__)) |
110 | && "someone forgot to call dispose()")(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef ->isDisposed() || m_rInnerRef->getRefCount() > 1) && "someone forgot to call dispose()") ? void (0) : __assert_fail ("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\"" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 110, __extension__ __PRETTY_FUNCTION__)); |
111 | } |
112 | VclPtr(VclPtr const &) = default; |
113 | VclPtr(VclPtr &&) = default; |
114 | VclPtr & operator =(VclPtr const &) = default; |
115 | VclPtr & operator =(VclPtr &&) = default; |
116 | #endif |
117 | |
118 | /** |
119 | * A construction helper for VclPtr. Since VclPtr types are created |
120 | * with a reference-count of one - to help fit into the existing |
121 | * code-flow; this helps us to construct them easily. |
122 | * |
123 | * For more details on the design please see vcl/README.lifecycle |
124 | * |
125 | * @tparam reference_type must be a subclass of vcl::Window |
126 | */ |
127 | template<typename... Arg> [[nodiscard]] static VclPtr< reference_type > Create(Arg &&... arg) |
128 | { |
129 | return VclPtr< reference_type >( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ); |
130 | } |
131 | |
132 | /** Probably most common used: handle->someBodyOp(). |
133 | */ |
134 | reference_type * operator->() const |
135 | { |
136 | return m_rInnerRef.get(); |
137 | } |
138 | |
139 | /** Get the body. Can be used instead of operator->(). |
140 | I.e. handle->someBodyOp() and handle.get()->someBodyOp() |
141 | are the same. |
142 | */ |
143 | reference_type * get() const |
144 | { |
145 | return m_rInnerRef.get(); |
146 | } |
147 | |
148 | void set(reference_type *pBody) |
149 | { |
150 | m_rInnerRef.set(pBody); |
151 | } |
152 | |
153 | void reset(reference_type *pBody) |
154 | { |
155 | m_rInnerRef.set(pBody); |
156 | } |
157 | |
158 | /** Up-casting copy assignment operator. |
159 | |
160 | Does not work for up-casts to ambiguous bases. |
161 | |
162 | @param rRef another reference |
163 | */ |
164 | template<typename derived_type> |
165 | typename std::enable_if< |
166 | std::is_base_of<reference_type, derived_type>::value, |
167 | VclPtr &>::type |
168 | operator =(VclPtr<derived_type> const & rRef) |
169 | { |
170 | m_rInnerRef.set(rRef.get()); |
171 | return *this; |
172 | } |
173 | |
174 | VclPtr & operator =(reference_type * pBody) |
175 | { |
176 | m_rInnerRef.set(pBody); |
177 | return *this; |
178 | } |
179 | |
180 | operator reference_type * () const |
181 | { |
182 | return m_rInnerRef.get(); |
183 | } |
184 | |
185 | explicit operator bool () const |
186 | { |
187 | return m_rInnerRef.get() != nullptr; |
188 | } |
189 | |
190 | void clear() |
191 | { |
192 | m_rInnerRef.clear(); |
193 | } |
194 | |
195 | void reset() |
196 | { |
197 | m_rInnerRef.clear(); |
198 | } |
199 | |
200 | void disposeAndClear() |
201 | { |
202 | // hold it alive for the lifetime of this method |
203 | ::rtl::Reference<reference_type> aTmp(m_rInnerRef); |
204 | m_rInnerRef.clear(); // we should use some 'swap' method ideally ;-) |
205 | if (aTmp.get()) { |
206 | aTmp->disposeOnce(); |
207 | } |
208 | } |
209 | |
210 | /** Needed to place VclPtr's into STL collection. |
211 | */ |
212 | bool operator< (const VclPtr<reference_type> & handle) const |
213 | { |
214 | return (m_rInnerRef < handle.m_rInnerRef); |
215 | } |
216 | }; // class VclPtr |
217 | |
218 | template<typename T1, typename T2> |
219 | inline bool operator ==(VclPtr<T1> const & p1, VclPtr<T2> const & p2) { |
220 | return p1.get() == p2.get(); |
221 | } |
222 | |
223 | template<typename T> inline bool operator ==(VclPtr<T> const & p1, T const * p2) |
224 | { |
225 | return p1.get() == p2; |
226 | } |
227 | |
228 | template<typename T> inline bool operator ==(VclPtr<T> const & p1, T * p2) { |
229 | return p1.get() == p2; |
230 | } |
231 | |
232 | template<typename T> inline bool operator ==(T const * p1, VclPtr<T> const & p2) |
233 | { |
234 | return p1 == p2.get(); |
235 | } |
236 | |
237 | template<typename T> inline bool operator ==(T * p1, VclPtr<T> const & p2) { |
238 | return p1 == p2.get(); |
239 | } |
240 | |
241 | template<typename T1, typename T2> |
242 | inline bool operator !=(VclPtr<T1> const & p1, VclPtr<T2> const & p2) { |
243 | return !(p1 == p2); |
244 | } |
245 | |
246 | template<typename T> inline bool operator !=(VclPtr<T> const & p1, T const * p2) |
247 | { |
248 | return !(p1 == p2); |
249 | } |
250 | |
251 | template<typename T> inline bool operator !=(VclPtr<T> const & p1, T * p2) { |
252 | return !(p1 == p2); |
253 | } |
254 | |
255 | template<typename T> inline bool operator !=(T const * p1, VclPtr<T> const & p2) |
256 | { |
257 | return !(p1 == p2); |
258 | } |
259 | |
260 | template<typename T> inline bool operator !=(T * p1, VclPtr<T> const & p2) { |
261 | return !(p1 == p2); |
262 | } |
263 | |
264 | /** |
265 | * A construction helper for a temporary VclPtr. Since VclPtr types |
266 | * are created with a reference-count of one - to help fit into |
267 | * the existing code-flow; this helps us to construct them easily. |
268 | * see also VclPtr::Create and ScopedVclPtr |
269 | * |
270 | * For more details on the design please see vcl/README.lifecycle |
271 | * |
272 | * @param reference_type must be a subclass of vcl::Window |
273 | */ |
274 | template <class reference_type> |
275 | class SAL_WARN_UNUSED__attribute__((warn_unused)) VclPtrInstance final : public VclPtr<reference_type> |
276 | { |
277 | public: |
278 | template<typename... Arg> VclPtrInstance(Arg &&... arg) |
279 | : VclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) |
280 | { |
281 | } |
282 | |
283 | /** |
284 | * Override and disallow this, to prevent people accidentally calling it and actually |
285 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
286 | */ |
287 | template<typename... Arg> static VclPtrInstance< reference_type > Create(Arg &&... ) = delete; |
288 | }; |
289 | |
290 | template <class reference_type> |
291 | class ScopedVclPtr : public VclPtr<reference_type> |
292 | { |
293 | public: |
294 | /** Constructor... |
295 | */ |
296 | ScopedVclPtr() |
297 | : VclPtr<reference_type>() |
298 | {} |
299 | |
300 | /** Constructor |
301 | */ |
302 | ScopedVclPtr (reference_type * pBody) |
303 | : VclPtr<reference_type>(pBody) |
304 | {} |
305 | |
306 | /** Copy constructor... |
307 | */ |
308 | ScopedVclPtr (const VclPtr<reference_type> & handle) |
309 | : VclPtr<reference_type>(handle) |
310 | {} |
311 | |
312 | /** |
313 | Assignment that releases the last reference. |
314 | */ |
315 | void disposeAndReset(reference_type *pBody) |
316 | { |
317 | if (pBody != this->get()) { |
318 | VclPtr<reference_type>::disposeAndClear(); |
319 | VclPtr<reference_type>::set(pBody); |
320 | } |
321 | } |
322 | |
323 | /** |
324 | Assignment that releases the last reference. |
325 | */ |
326 | ScopedVclPtr<reference_type>& operator = (reference_type * pBody) |
327 | { |
328 | disposeAndReset(pBody); |
329 | return *this; |
330 | } |
331 | |
332 | /** Up-casting conversion constructor: Copies interface reference. |
333 | |
334 | Does not work for up-casts to ambiguous bases. For the special case of |
335 | up-casting to Reference< XInterface >, see the corresponding conversion |
336 | operator. |
337 | |
338 | @param rRef another reference |
339 | */ |
340 | template< class derived_type > |
341 | ScopedVclPtr( |
342 | const VclPtr< derived_type > & rRef, |
343 | typename std::enable_if< |
344 | std::is_base_of<reference_type, derived_type>::value, int>::type |
345 | = 0 ) |
346 | : VclPtr<reference_type>( rRef ) |
347 | { |
348 | } |
349 | |
350 | /** Up-casting assignment operator. |
351 | |
352 | Does not work for up-casts to ambiguous bases. |
353 | |
354 | @param rRef another VclPtr |
355 | */ |
356 | template<typename derived_type> |
357 | typename std::enable_if< |
358 | std::is_base_of<reference_type, derived_type>::value, |
359 | ScopedVclPtr &>::type |
360 | operator =(VclPtr<derived_type> const & rRef) |
361 | { |
362 | disposeAndReset(rRef.get()); |
363 | return *this; |
364 | } |
365 | |
366 | /** |
367 | * Override and disallow this, to prevent people accidentally calling it and actually |
368 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
369 | */ |
370 | template<typename... Arg> static ScopedVclPtr< reference_type > Create(Arg &&... ) = delete; |
371 | |
372 | ~ScopedVclPtr() |
373 | { |
374 | VclPtr<reference_type>::disposeAndClear(); |
375 | assert(VclPtr<reference_type>::get() == nullptr)(static_cast <bool> (VclPtr<reference_type>::get( ) == nullptr) ? void (0) : __assert_fail ("VclPtr<reference_type>::get() == nullptr" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 375, __extension__ __PRETTY_FUNCTION__)); // make sure there are no lingering references |
376 | } |
377 | |
378 | private: |
379 | // Most likely we don't want this default copy-constructor. |
380 | ScopedVclPtr (const ScopedVclPtr<reference_type> &) = delete; |
381 | // And certainly we don't want a default assignment operator. |
382 | ScopedVclPtr<reference_type>& operator = (const ScopedVclPtr<reference_type> &) = delete; |
383 | // And disallow reset as that doesn't call disposeAndClear on the original reference |
384 | void reset() = delete; |
385 | void reset(reference_type *pBody) = delete; |
386 | |
387 | protected: |
388 | ScopedVclPtr (reference_type * pBody, __sal_NoAcquire) |
389 | : VclPtr<reference_type>(pBody, SAL_NO_ACQUIRE) |
390 | {} |
391 | }; |
392 | |
393 | /** |
394 | * A construction helper for ScopedVclPtr. Since VclPtr types are created |
395 | * with a reference-count of one - to help fit into the existing |
396 | * code-flow; this helps us to construct them easily. |
397 | * |
398 | * For more details on the design please see vcl/README.lifecycle |
399 | * |
400 | * @param reference_type must be a subclass of vcl::Window |
401 | */ |
402 | #if defined _MSC_VER |
403 | #pragma warning(push) |
404 | #pragma warning(disable: 4521) // " multiple copy constructors specified" |
405 | #endif |
406 | template <class reference_type> |
407 | class SAL_WARN_UNUSED__attribute__((warn_unused)) ScopedVclPtrInstance final : public ScopedVclPtr<reference_type> |
408 | { |
409 | public: |
410 | template<typename... Arg> ScopedVclPtrInstance(Arg &&... arg) |
411 | : ScopedVclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) |
412 | { |
413 | } |
414 | |
415 | /** |
416 | * Override and disallow this, to prevent people accidentally calling it and actually |
417 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
418 | */ |
419 | template<typename... Arg> static ScopedVclPtrInstance< reference_type > Create(Arg &&...) = delete; |
420 | |
421 | private: |
422 | // Prevent the above perfect forwarding ctor from hijacking (accidental) |
423 | // attempts at ScopedVclPtrInstance copy construction (where the hijacking |
424 | // would typically lead to somewhat obscure error messages); both non-const |
425 | // and const variants are needed here, as the ScopedVclPtr base class has a |
426 | // const--variant copy ctor, so the implicitly declared copy ctor for |
427 | // ScopedVclPtrInstance would also be the const variant, so non-const copy |
428 | // construction attempts would be hijacked by the perfect forwarding ctor; |
429 | // but if we only declared a non-const variant here, the const variant would |
430 | // no longer be implicitly declared (as there would already be an explicitly |
431 | // declared copy ctor), so const copy construction attempts would then be |
432 | // hijacked by the perfect forwarding ctor: |
433 | ScopedVclPtrInstance(ScopedVclPtrInstance &) = delete; |
434 | ScopedVclPtrInstance(ScopedVclPtrInstance const &) = delete; |
435 | }; |
436 | #if defined _MSC_VER |
437 | #pragma warning(pop) |
438 | #endif |
439 | |
440 | #endif // INCLUDED_VCL_PTR_HXX |
441 | |
442 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
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 | #ifndef INCLUDED_RTL_REF_HXX | ||||||||
21 | #define INCLUDED_RTL_REF_HXX | ||||||||
22 | |||||||||
23 | #include "sal/config.h" | ||||||||
24 | |||||||||
25 | #include <cassert> | ||||||||
26 | #include <cstddef> | ||||||||
27 | #include <functional> | ||||||||
28 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||
29 | #include <type_traits> | ||||||||
30 | #endif | ||||||||
31 | |||||||||
32 | #include "sal/types.h" | ||||||||
33 | |||||||||
34 | namespace rtl | ||||||||
35 | { | ||||||||
36 | |||||||||
37 | /** Template reference class for reference type. | ||||||||
38 | */ | ||||||||
39 | template <class reference_type> | ||||||||
40 | class Reference | ||||||||
41 | { | ||||||||
42 | /** The <b>reference_type</b> body pointer. | ||||||||
43 | */ | ||||||||
44 | reference_type * m_pBody; | ||||||||
45 | |||||||||
46 | |||||||||
47 | public: | ||||||||
48 | /** Constructor... | ||||||||
49 | */ | ||||||||
50 | Reference() | ||||||||
51 | : m_pBody (NULL__null) | ||||||||
52 | {} | ||||||||
53 | |||||||||
54 | |||||||||
55 | /** Constructor... | ||||||||
56 | */ | ||||||||
57 | Reference (reference_type * pBody, __sal_NoAcquire) | ||||||||
58 | : m_pBody (pBody) | ||||||||
59 | { | ||||||||
60 | } | ||||||||
61 | |||||||||
62 | /** Constructor... | ||||||||
63 | */ | ||||||||
64 | Reference (reference_type * pBody) | ||||||||
65 | : m_pBody (pBody) | ||||||||
66 | { | ||||||||
67 | if (m_pBody) | ||||||||
68 | m_pBody->acquire(); | ||||||||
69 | } | ||||||||
70 | |||||||||
71 | /** Copy constructor... | ||||||||
72 | */ | ||||||||
73 | Reference (const Reference<reference_type> & handle) | ||||||||
74 | : m_pBody (handle.m_pBody) | ||||||||
75 | { | ||||||||
76 | if (m_pBody) | ||||||||
77 | m_pBody->acquire(); | ||||||||
78 | } | ||||||||
79 | |||||||||
80 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||
81 | /** Move constructor... | ||||||||
82 | */ | ||||||||
83 | Reference (Reference<reference_type> && handle) noexcept | ||||||||
84 | : m_pBody (handle.m_pBody) | ||||||||
85 | { | ||||||||
86 | handle.m_pBody = nullptr; | ||||||||
87 | } | ||||||||
88 | #endif | ||||||||
89 | |||||||||
90 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||
91 | /** Up-casting conversion constructor: Copies interface reference. | ||||||||
92 | |||||||||
93 | Does not work for up-casts to ambiguous bases. | ||||||||
94 | |||||||||
95 | @param rRef another reference | ||||||||
96 | */ | ||||||||
97 | template< class derived_type > | ||||||||
98 | inline Reference( | ||||||||
99 | const Reference< derived_type > & rRef, | ||||||||
100 | std::enable_if_t<std::is_base_of_v<reference_type, derived_type>, int> = 0 ) | ||||||||
101 | : m_pBody (rRef.get()) | ||||||||
102 | { | ||||||||
103 | if (m_pBody) | ||||||||
104 | m_pBody->acquire(); | ||||||||
105 | } | ||||||||
106 | #endif | ||||||||
107 | |||||||||
108 | /** Destructor... | ||||||||
109 | */ | ||||||||
110 | ~Reference() COVERITY_NOEXCEPT_FALSE | ||||||||
111 | { | ||||||||
112 | if (m_pBody
| ||||||||
113 | m_pBody->release(); | ||||||||
114 | } | ||||||||
115 | |||||||||
116 | /** Set... | ||||||||
117 | Similar to assignment. | ||||||||
118 | */ | ||||||||
119 | Reference<reference_type> & | ||||||||
120 | SAL_CALL set (reference_type * pBody) | ||||||||
121 | { | ||||||||
122 | if (pBody) | ||||||||
123 | pBody->acquire(); | ||||||||
124 | reference_type * const pOld = m_pBody; | ||||||||
125 | m_pBody = pBody; | ||||||||
126 | if (pOld) | ||||||||
127 | pOld->release(); | ||||||||
128 | return *this; | ||||||||
129 | } | ||||||||
130 | |||||||||
131 | /** Assignment. | ||||||||
132 | Unbinds this instance from its body (if bound) and | ||||||||
133 | bind it to the body represented by the handle. | ||||||||
134 | */ | ||||||||
135 | Reference<reference_type> & | ||||||||
136 | SAL_CALL operator= (const Reference<reference_type> & handle) | ||||||||
137 | { | ||||||||
138 | return set( handle.m_pBody ); | ||||||||
139 | } | ||||||||
140 | |||||||||
141 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||
142 | /** Assignment. | ||||||||
143 | * Unbinds this instance from its body (if bound), | ||||||||
144 | * bind it to the body represented by the handle, and | ||||||||
145 | * set the body represented by the handle to nullptr. | ||||||||
146 | */ | ||||||||
147 | Reference<reference_type> & | ||||||||
148 | operator= (Reference<reference_type> && handle) | ||||||||
149 | { | ||||||||
150 | // self-movement guts ourself | ||||||||
151 | if (m_pBody) | ||||||||
152 | m_pBody->release(); | ||||||||
153 | m_pBody = handle.m_pBody; | ||||||||
154 | handle.m_pBody = nullptr; | ||||||||
155 | return *this; | ||||||||
156 | } | ||||||||
157 | #endif | ||||||||
158 | |||||||||
159 | /** Assignment... | ||||||||
160 | */ | ||||||||
161 | Reference<reference_type> & | ||||||||
162 | SAL_CALL operator= (reference_type * pBody) | ||||||||
163 | { | ||||||||
164 | return set( pBody ); | ||||||||
165 | } | ||||||||
166 | |||||||||
167 | /** Unbind the body from this handle. | ||||||||
168 | Note that for a handle representing a large body, | ||||||||
169 | "handle.clear().set(new body());" _might_ | ||||||||
170 | perform a little bit better than "handle.set(new body());", | ||||||||
171 | since in the second case two large objects exist in memory | ||||||||
172 | (the old body and the new body). | ||||||||
173 | */ | ||||||||
174 | Reference<reference_type> & SAL_CALL clear() | ||||||||
175 | { | ||||||||
176 | if (m_pBody) | ||||||||
177 | { | ||||||||
178 | reference_type * const pOld = m_pBody; | ||||||||
179 | m_pBody = NULL__null; | ||||||||
180 | pOld->release(); | ||||||||
181 | } | ||||||||
182 | return *this; | ||||||||
183 | } | ||||||||
184 | |||||||||
185 | |||||||||
186 | /** Get the body. Can be used instead of operator->(). | ||||||||
187 | I.e. handle->someBodyOp() and handle.get()->someBodyOp() | ||||||||
188 | are the same. | ||||||||
189 | */ | ||||||||
190 | reference_type * SAL_CALL get() const | ||||||||
191 | { | ||||||||
192 | return m_pBody; | ||||||||
| |||||||||
193 | } | ||||||||
194 | |||||||||
195 | |||||||||
196 | /** Probably most common used: handle->someBodyOp(). | ||||||||
197 | */ | ||||||||
198 | reference_type * SAL_CALL operator->() const | ||||||||
199 | { | ||||||||
200 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 200, __extension__ __PRETTY_FUNCTION__)); | ||||||||
201 | return m_pBody; | ||||||||
202 | } | ||||||||
203 | |||||||||
204 | |||||||||
205 | /** Allows (*handle).someBodyOp(). | ||||||||
206 | */ | ||||||||
207 | reference_type & SAL_CALL operator*() const | ||||||||
208 | { | ||||||||
209 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 209, __extension__ __PRETTY_FUNCTION__)); | ||||||||
210 | return *m_pBody; | ||||||||
211 | } | ||||||||
212 | |||||||||
213 | |||||||||
214 | /** Returns True if the handle does point to a valid body. | ||||||||
215 | */ | ||||||||
216 | bool SAL_CALL is() const | ||||||||
217 | { | ||||||||
218 | return (m_pBody != NULL__null); | ||||||||
219 | } | ||||||||
220 | |||||||||
221 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||
222 | /** Returns True if the handle does point to a valid body. | ||||||||
223 | */ | ||||||||
224 | explicit operator bool() const | ||||||||
225 | { | ||||||||
226 | return is(); | ||||||||
227 | } | ||||||||
228 | #endif | ||||||||
229 | |||||||||
230 | /** Returns True if this points to pBody. | ||||||||
231 | */ | ||||||||
232 | bool SAL_CALL operator== (const reference_type * pBody) const | ||||||||
233 | { | ||||||||
234 | return (m_pBody == pBody); | ||||||||
235 | } | ||||||||
236 | |||||||||
237 | |||||||||
238 | /** Returns True if handle points to the same body. | ||||||||
239 | */ | ||||||||
240 | bool | ||||||||
241 | SAL_CALL operator== (const Reference<reference_type> & handle) const | ||||||||
242 | { | ||||||||
243 | return (m_pBody == handle.m_pBody); | ||||||||
244 | } | ||||||||
245 | |||||||||
246 | |||||||||
247 | /** Needed to place References into STL collection. | ||||||||
248 | */ | ||||||||
249 | bool | ||||||||
250 | SAL_CALL operator!= (const Reference<reference_type> & handle) const | ||||||||
251 | { | ||||||||
252 | return (m_pBody != handle.m_pBody); | ||||||||
253 | } | ||||||||
254 | |||||||||
255 | |||||||||
256 | /** Needed to place References into STL collection. | ||||||||
257 | */ | ||||||||
258 | bool | ||||||||
259 | SAL_CALL operator< (const Reference<reference_type> & handle) const | ||||||||
260 | { | ||||||||
261 | return (m_pBody < handle.m_pBody); | ||||||||
262 | } | ||||||||
263 | |||||||||
264 | |||||||||
265 | /** Needed to place References into STL collection. | ||||||||
266 | */ | ||||||||
267 | bool | ||||||||
268 | SAL_CALL operator> (const Reference<reference_type> & handle) const | ||||||||
269 | { | ||||||||
270 | return (m_pBody > handle.m_pBody); | ||||||||
271 | } | ||||||||
272 | }; | ||||||||
273 | |||||||||
274 | } // namespace rtl | ||||||||
275 | |||||||||
276 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||
277 | namespace std | ||||||||
278 | { | ||||||||
279 | |||||||||
280 | /// @cond INTERNAL | ||||||||
281 | /** | ||||||||
282 | Make rtl::Reference hashable by default for use in STL containers. | ||||||||
283 | |||||||||
284 | @since LibreOffice 6.3 | ||||||||
285 | */ | ||||||||
286 | template<typename T> | ||||||||
287 | struct hash<::rtl::Reference<T>> | ||||||||
288 | { | ||||||||
289 | std::size_t operator()(::rtl::Reference<T> const & s) const | ||||||||
290 | { return std::size_t(s.get()); } | ||||||||
291 | }; | ||||||||
292 | /// @endcond | ||||||||
293 | |||||||||
294 | } | ||||||||
295 | |||||||||
296 | #endif | ||||||||
297 | |||||||||
298 | #endif /* ! INCLUDED_RTL_REF_HXX */ | ||||||||
299 | |||||||||
300 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
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 | #ifndef INCLUDED_VCL_Reference_HXX |
20 | #define INCLUDED_VCL_Reference_HXX |
21 | |
22 | #include <vcl/dllapi.h> |
23 | #include <osl/interlck.h> |
24 | |
25 | class VCL_DLLPUBLIC__attribute__ ((visibility("default"))) VclReferenceBase |
26 | { |
27 | mutable oslInterlockedCount mnRefCnt; |
28 | |
29 | template<typename T> friend class VclPtr; |
30 | |
31 | public: |
32 | void acquire() const |
33 | { |
34 | osl_atomic_increment(&mnRefCnt)__sync_add_and_fetch((&mnRefCnt), 1); |
35 | } |
36 | |
37 | void release() const |
38 | { |
39 | if (osl_atomic_decrement(&mnRefCnt)__sync_sub_and_fetch((&mnRefCnt), 1) == 0) |
40 | delete this; |
41 | } |
42 | #ifdef DBG_UTIL |
43 | #ifndef _WIN32 |
44 | sal_Int32 getRefCount() const { return mnRefCnt; } |
45 | #endif |
46 | #endif |
47 | |
48 | |
49 | private: |
50 | VclReferenceBase(const VclReferenceBase&) = delete; |
51 | VclReferenceBase& operator=(const VclReferenceBase&) = delete; |
52 | |
53 | bool mbDisposed : 1; |
54 | |
55 | protected: |
56 | VclReferenceBase(); |
57 | protected: |
58 | virtual ~VclReferenceBase(); |
59 | |
60 | protected: |
61 | virtual void dispose(); |
62 | |
63 | public: |
64 | void disposeOnce(); |
65 | bool isDisposed() const { return mbDisposed; } |
66 | |
67 | }; |
68 | #endif |