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_folders.h> | |||
21 | #include <sfx2/sfxhelp.hxx> | |||
22 | ||||
23 | #include <string_view> | |||
24 | #include <algorithm> | |||
25 | #include <cassert> | |||
26 | #ifdef MACOSX | |||
27 | #include <premac.h> | |||
28 | #include <Foundation/NSString.h> | |||
29 | #include <CoreFoundation/CFURL.h> | |||
30 | #include <CoreServices/CoreServices.h> | |||
31 | #include <postmac.h> | |||
32 | #endif | |||
33 | ||||
34 | #include <sal/log.hxx> | |||
35 | #include <com/sun/star/uno/Reference.h> | |||
36 | #include <com/sun/star/frame/Desktop.hpp> | |||
37 | #include <com/sun/star/frame/UnknownModuleException.hpp> | |||
38 | #include <com/sun/star/frame/XFrame2.hpp> | |||
39 | #include <comphelper/processfactory.hxx> | |||
40 | #include <com/sun/star/awt/XWindow.hpp> | |||
41 | #include <com/sun/star/awt/XTopWindow.hpp> | |||
42 | #include <com/sun/star/beans/XPropertySet.hpp> | |||
43 | #include <com/sun/star/frame/FrameSearchFlag.hpp> | |||
44 | #include <toolkit/helper/vclunohelper.hxx> | |||
45 | #include <com/sun/star/frame/ModuleManager.hpp> | |||
46 | #include <unotools/configmgr.hxx> | |||
47 | #include <svtools/helpopt.hxx> | |||
48 | #include <unotools/moduleoptions.hxx> | |||
49 | #include <tools/urlobj.hxx> | |||
50 | #include <ucbhelper/content.hxx> | |||
51 | #include <unotools/pathoptions.hxx> | |||
52 | #include <rtl/byteseq.hxx> | |||
53 | #include <rtl/ustring.hxx> | |||
54 | #include <officecfg/Office/Common.hxx> | |||
55 | #include <osl/process.h> | |||
56 | #include <osl/file.hxx> | |||
57 | #include <unotools/tempfile.hxx> | |||
58 | #include <unotools/securityoptions.hxx> | |||
59 | #include <rtl/uri.hxx> | |||
60 | #include <vcl/commandinfoprovider.hxx> | |||
61 | #include <vcl/keycod.hxx> | |||
62 | #include <vcl/settings.hxx> | |||
63 | #include <vcl/waitobj.hxx> | |||
64 | #include <vcl/weld.hxx> | |||
65 | #include <openuriexternally.hxx> | |||
66 | ||||
67 | #include <comphelper/lok.hxx> | |||
68 | #include <LibreOfficeKit/LibreOfficeKitEnums.h> | |||
69 | #include <sfx2/viewsh.hxx> | |||
70 | ||||
71 | #include "newhelp.hxx" | |||
72 | #include <sfx2/flatpak.hxx> | |||
73 | #include <sfx2/sfxresid.hxx> | |||
74 | #include <helper.hxx> | |||
75 | #include <sfx2/strings.hrc> | |||
76 | #include <vcl/svapp.hxx> | |||
77 | #include <rtl/string.hxx> | |||
78 | #include <svtools/langtab.hxx> | |||
79 | #include <tools/diagnose_ex.h> | |||
80 | ||||
81 | using namespace ::com::sun::star::beans; | |||
82 | using namespace ::com::sun::star::frame; | |||
83 | using namespace ::com::sun::star::uno; | |||
84 | using namespace ::com::sun::star::util; | |||
85 | using namespace ::com::sun::star::lang; | |||
86 | ||||
87 | namespace { | |||
88 | ||||
89 | class NoHelpErrorBox | |||
90 | { | |||
91 | private: | |||
92 | std::unique_ptr<weld::MessageDialog> m_xErrBox; | |||
93 | public: | |||
94 | DECL_STATIC_LINK(NoHelpErrorBox, HelpRequestHdl, weld::Widget&, bool)static bool LinkStubHelpRequestHdl(void *, weld::Widget&) ; static bool HelpRequestHdl(NoHelpErrorBox *, weld::Widget& ); | |||
95 | public: | |||
96 | explicit NoHelpErrorBox(weld::Widget* pParent) | |||
97 | : m_xErrBox(Application::CreateMessageDialog(pParent, VclMessageType::Error, VclButtonsType::Ok, | |||
98 | SfxResId(RID_STR_HLPFILENOTEXISTreinterpret_cast<char const *>("RID_STR_HLPFILENOTEXIST" "\004" u8"The help file for this topic is not installed.")))) | |||
99 | { | |||
100 | // Error message: "No help available" | |||
101 | m_xErrBox->connect_help(LINK(nullptr, NoHelpErrorBox, HelpRequestHdl)::tools::detail::makeLink( ::tools::detail::castTo<NoHelpErrorBox *>(nullptr), &NoHelpErrorBox::LinkStubHelpRequestHdl)); | |||
102 | } | |||
103 | void run() | |||
104 | { | |||
105 | m_xErrBox->run(); | |||
106 | } | |||
107 | }; | |||
108 | ||||
109 | } | |||
110 | ||||
111 | IMPL_STATIC_LINK_NOARG(NoHelpErrorBox, HelpRequestHdl, weld::Widget&, bool)bool NoHelpErrorBox::LinkStubHelpRequestHdl(void * instance, weld ::Widget& data) { return HelpRequestHdl(static_cast<NoHelpErrorBox *>(instance), data); } bool NoHelpErrorBox::HelpRequestHdl ( __attribute__ ((unused)) NoHelpErrorBox *, __attribute__ (( unused)) weld::Widget&) | |||
112 | { | |||
113 | // do nothing, because no help available | |||
114 | return false; | |||
115 | } | |||
116 | ||||
117 | static OUString const & HelpLocaleString(); | |||
118 | ||||
119 | namespace { | |||
120 | ||||
121 | /// Root path of the help. | |||
122 | OUString const & getHelpRootURL() | |||
123 | { | |||
124 | static OUString const s_instURL = [&]() | |||
125 | { | |||
126 | OUString tmp = officecfg::Office::Common::Path::Current::Help::get(comphelper::getProcessComponentContext()); | |||
127 | if (tmp.isEmpty()) | |||
128 | { | |||
129 | // try to determine path from default | |||
130 | tmp = "$(instpath)/" LIBO_SHARE_HELP_FOLDER"help"; | |||
131 | } | |||
132 | ||||
133 | // replace anything like $(instpath); | |||
134 | SvtPathOptions aOptions; | |||
135 | tmp = aOptions.SubstituteVariable(tmp); | |||
136 | ||||
137 | OUString url; | |||
138 | if (osl::FileBase::getFileURLFromSystemPath(tmp, url) == osl::FileBase::E_None) | |||
139 | tmp = url; | |||
140 | return tmp; | |||
141 | }(); | |||
142 | return s_instURL; | |||
143 | } | |||
144 | ||||
145 | bool impl_checkHelpLocalePath(OUString const & rpPath) | |||
146 | { | |||
147 | osl::DirectoryItem directoryItem; | |||
148 | bool bOK = false; | |||
149 | ||||
150 | osl::FileStatus fileStatus(osl_FileStatus_Mask_Type0x00000001 | osl_FileStatus_Mask_FileURL0x00000200 | osl_FileStatus_Mask_FileName0x00000100); | |||
151 | if (osl::DirectoryItem::get(rpPath, directoryItem) == osl::FileBase::E_None && | |||
152 | directoryItem.getFileStatus(fileStatus) == osl::FileBase::E_None && | |||
153 | fileStatus.isDirectory()) | |||
154 | { | |||
155 | bOK = true; | |||
156 | } | |||
157 | return bOK; | |||
158 | } | |||
159 | ||||
160 | /// Check for built-in help | |||
161 | /// Check if help/<lang>/err.html file exist | |||
162 | bool impl_hasHelpInstalled() | |||
163 | { | |||
164 | if (comphelper::LibreOfficeKit::isActive()) | |||
165 | return false; | |||
166 | ||||
167 | // detect installed locale | |||
168 | static OUString const aLocaleStr = HelpLocaleString(); | |||
169 | ||||
170 | OUString helpRootURL = getHelpRootURL() + "/" + aLocaleStr + "/err.html"; | |||
171 | bool bOK = false; | |||
172 | osl::DirectoryItem directoryItem; | |||
173 | if(osl::DirectoryItem::get(helpRootURL, directoryItem) == osl::FileBase::E_None){ | |||
174 | bOK=true; | |||
175 | } | |||
176 | ||||
177 | SAL_INFO( "sfx.appl", "Checking old help installed " << bOK)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() << "Checking old help installed " << bOK) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "177" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "Checking old help installed " << bOK), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Checking old help installed " << bOK; ::sal:: detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "177" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "Checking old help installed " << bOK) == 1 ) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "177" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "Checking old help installed " << bOK), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Checking old help installed " << bOK; ::sal:: detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "177" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
178 | return bOK; | |||
179 | } | |||
180 | ||||
181 | /// Check for html built-in help | |||
182 | /// Check if help/lang/text folder exist. Only html has it. | |||
183 | bool impl_hasHTMLHelpInstalled() | |||
184 | { | |||
185 | if (comphelper::LibreOfficeKit::isActive()) | |||
186 | return false; | |||
187 | ||||
188 | // detect installed locale | |||
189 | static OUString const aLocaleStr = HelpLocaleString(); | |||
190 | ||||
191 | OUString helpRootURL = getHelpRootURL() + "/" + aLocaleStr + "/text"; | |||
192 | bool bOK = impl_checkHelpLocalePath( helpRootURL ); | |||
193 | SAL_INFO( "sfx.appl", "Checking new help (html) installed " << bOK)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() << "Checking new help (html) installed " << bOK) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "193" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "Checking new help (html) installed " << bOK), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Checking new help (html) installed " << bOK; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "193" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "Checking new help (html) installed " << bOK ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "193" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "Checking new help (html) installed " << bOK), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Checking new help (html) installed " << bOK; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "193" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
194 | return bOK; | |||
195 | } | |||
196 | ||||
197 | } // namespace | |||
198 | ||||
199 | /// Return the locale we prefer for displaying help | |||
200 | static OUString const & HelpLocaleString() | |||
201 | { | |||
202 | if (comphelper::LibreOfficeKit::isActive()) | |||
203 | return comphelper::LibreOfficeKit::getLanguageTag().getBcp47(); | |||
204 | ||||
205 | static OUString aLocaleStr; | |||
206 | if (!aLocaleStr.isEmpty()) | |||
207 | return aLocaleStr; | |||
208 | ||||
209 | const OUString aEnglish("en-US"); | |||
210 | // detect installed locale | |||
211 | aLocaleStr = utl::ConfigManager::getUILocale(); | |||
212 | ||||
213 | if ( aLocaleStr.isEmpty() ) | |||
214 | { | |||
215 | aLocaleStr = aEnglish; | |||
216 | return aLocaleStr; | |||
217 | } | |||
218 | ||||
219 | // get fall-back language (country) | |||
220 | OUString sLang = aLocaleStr; | |||
221 | sal_Int32 nSepPos = sLang.indexOf( '-' ); | |||
222 | if (nSepPos != -1) | |||
223 | { | |||
224 | sLang = sLang.copy( 0, nSepPos ); | |||
225 | } | |||
226 | OUString sHelpPath(""); | |||
227 | sHelpPath = getHelpRootURL() + "/" + utl::ConfigManager::getProductVersion() + "/" + aLocaleStr; | |||
228 | if (impl_checkHelpLocalePath(sHelpPath)) | |||
229 | { | |||
230 | return aLocaleStr; | |||
231 | } | |||
232 | sHelpPath = getHelpRootURL() + "/" + utl::ConfigManager::getProductVersion() + "/" + sLang; | |||
233 | if (impl_checkHelpLocalePath(sHelpPath)) | |||
234 | { | |||
235 | aLocaleStr = sLang; | |||
236 | return aLocaleStr; | |||
237 | } | |||
238 | sHelpPath = getHelpRootURL() + "/" + aLocaleStr; | |||
239 | if (impl_checkHelpLocalePath(sHelpPath)) | |||
240 | { | |||
241 | return aLocaleStr; | |||
242 | } | |||
243 | sHelpPath = getHelpRootURL() + "/" + sLang; | |||
244 | if (impl_checkHelpLocalePath(sHelpPath)) | |||
245 | { | |||
246 | aLocaleStr = sLang; | |||
247 | return aLocaleStr; | |||
248 | } | |||
249 | sHelpPath = getHelpRootURL() + "/" + utl::ConfigManager::getProductVersion() + "/" + aEnglish; | |||
250 | if (impl_checkHelpLocalePath(sHelpPath)) | |||
251 | { | |||
252 | aLocaleStr = aEnglish; | |||
253 | return aLocaleStr; | |||
254 | } | |||
255 | sHelpPath = getHelpRootURL() + "/" + aEnglish; | |||
256 | if (impl_checkHelpLocalePath(sHelpPath)) | |||
257 | { | |||
258 | aLocaleStr = aEnglish; | |||
259 | return aLocaleStr; | |||
260 | } | |||
261 | return aLocaleStr; | |||
262 | } | |||
263 | ||||
264 | ||||
265 | ||||
266 | void AppendConfigToken( OUStringBuffer& rURL, bool bQuestionMark ) | |||
267 | { | |||
268 | OUString aLocaleStr = HelpLocaleString(); | |||
269 | ||||
270 | // query part exists? | |||
271 | if ( bQuestionMark ) | |||
272 | // no, so start with '?' | |||
273 | rURL.append('?'); | |||
274 | else | |||
275 | // yes, so only append with '&' | |||
276 | rURL.append('&'); | |||
277 | ||||
278 | // set parameters | |||
279 | rURL.append("Language="); | |||
280 | rURL.append(aLocaleStr); | |||
281 | rURL.append("&System="); | |||
282 | rURL.append(SvtHelpOptions().GetSystem()); | |||
283 | rURL.append("&Version="); | |||
284 | rURL.append(utl::ConfigManager::getProductVersion()); | |||
285 | } | |||
286 | ||||
287 | static bool GetHelpAnchor_Impl( const OUString& _rURL, OUString& _rAnchor ) | |||
288 | { | |||
289 | bool bRet = false; | |||
290 | ||||
291 | try | |||
292 | { | |||
293 | ::ucbhelper::Content aCnt( INetURLObject( _rURL ).GetMainURL( INetURLObject::DecodeMechanism::NONE ), | |||
294 | Reference< css::ucb::XCommandEnvironment >(), | |||
295 | comphelper::getProcessComponentContext() ); | |||
296 | OUString sAnchor; | |||
297 | if ( aCnt.getPropertyValue("AnchorName") >>= sAnchor ) | |||
298 | { | |||
299 | ||||
300 | if ( !sAnchor.isEmpty() ) | |||
301 | { | |||
302 | _rAnchor = sAnchor; | |||
303 | bRet = true; | |||
304 | } | |||
305 | } | |||
306 | else | |||
307 | { | |||
308 | SAL_WARN( "sfx.appl", "Property 'AnchorName' is missing" )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() << "Property 'AnchorName' is missing" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "308" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "Property 'AnchorName' is missing"), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Property 'AnchorName' is missing"; ::sal::detail:: log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "308" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "Property 'AnchorName' is missing") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "308" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "Property 'AnchorName' is missing"), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Property 'AnchorName' is missing"; ::sal::detail:: log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "308" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
309 | } | |||
310 | } | |||
311 | catch (const css::uno::Exception&) | |||
312 | { | |||
313 | } | |||
314 | ||||
315 | return bRet; | |||
316 | } | |||
317 | ||||
318 | namespace { | |||
319 | ||||
320 | class SfxHelp_Impl | |||
321 | { | |||
322 | public: | |||
323 | static OUString GetHelpText( const OUString& aCommandURL, const OUString& rModule ); | |||
324 | }; | |||
325 | ||||
326 | } | |||
327 | ||||
328 | OUString SfxHelp_Impl::GetHelpText( const OUString& aCommandURL, const OUString& rModule ) | |||
329 | { | |||
330 | // create help url | |||
331 | OUStringBuffer aHelpURL( SfxHelp::CreateHelpURL( aCommandURL, rModule ) ); | |||
332 | // added 'active' parameter | |||
333 | sal_Int32 nIndex = aHelpURL.lastIndexOf( '#' ); | |||
334 | if ( nIndex < 0 ) | |||
335 | nIndex = aHelpURL.getLength(); | |||
336 | aHelpURL.insert( nIndex, "&Active=true" ); | |||
337 | // load help string | |||
338 | return SfxContentHelper::GetActiveHelpString( aHelpURL.makeStringAndClear() ); | |||
339 | } | |||
340 | ||||
341 | SfxHelp::SfxHelp() : | |||
342 | bIsDebug( false ) | |||
343 | { | |||
344 | // read the environment variable "HELP_DEBUG" | |||
345 | // if it's set, you will see debug output on active help | |||
346 | OUString sHelpDebug; | |||
347 | OUString sEnvVarName( "HELP_DEBUG" ); | |||
348 | osl_getEnvironment( sEnvVarName.pData, &sHelpDebug.pData ); | |||
349 | bIsDebug = !sHelpDebug.isEmpty(); | |||
350 | } | |||
351 | ||||
352 | SfxHelp::~SfxHelp() | |||
353 | { | |||
354 | } | |||
355 | ||||
356 | static OUString getDefaultModule_Impl() | |||
357 | { | |||
358 | OUString sDefaultModule; | |||
359 | SvtModuleOptions aModOpt; | |||
360 | if ( aModOpt.IsModuleInstalled( SvtModuleOptions::EModule::WRITER ) ) | |||
361 | sDefaultModule = "swriter"; | |||
362 | else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::EModule::CALC ) ) | |||
363 | sDefaultModule = "scalc"; | |||
364 | else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::EModule::IMPRESS ) ) | |||
365 | sDefaultModule = "simpress"; | |||
366 | else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::EModule::DRAW ) ) | |||
367 | sDefaultModule = "sdraw"; | |||
368 | else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::EModule::MATH ) ) | |||
369 | sDefaultModule = "smath"; | |||
370 | else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::EModule::CHART ) ) | |||
371 | sDefaultModule = "schart"; | |||
372 | else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::EModule::BASIC ) ) | |||
373 | sDefaultModule = "sbasic"; | |||
374 | else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::EModule::DATABASE ) ) | |||
375 | sDefaultModule = "sdatabase"; | |||
376 | else | |||
377 | { | |||
378 | SAL_WARN( "sfx.appl", "getDefaultModule_Impl(): no module installed" )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() << "getDefaultModule_Impl(): no module installed" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "378" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "getDefaultModule_Impl(): no module installed" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "getDefaultModule_Impl(): no module installed"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "378" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "getDefaultModule_Impl(): no module installed") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "378" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "getDefaultModule_Impl(): no module installed" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "getDefaultModule_Impl(): no module installed"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "378" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
379 | } | |||
380 | return sDefaultModule; | |||
381 | } | |||
382 | ||||
383 | static OUString getCurrentModuleIdentifier_Impl() | |||
384 | { | |||
385 | OUString sIdentifier; | |||
386 | Reference < XComponentContext > xContext = ::comphelper::getProcessComponentContext(); | |||
387 | Reference < XModuleManager2 > xModuleManager = ModuleManager::create(xContext); | |||
388 | Reference < XDesktop2 > xDesktop = Desktop::create(xContext); | |||
389 | Reference < XFrame > xCurrentFrame = xDesktop->getCurrentFrame(); | |||
390 | ||||
391 | if ( xCurrentFrame.is() ) | |||
392 | { | |||
393 | try | |||
394 | { | |||
395 | sIdentifier = xModuleManager->identify( xCurrentFrame ); | |||
396 | } | |||
397 | catch (const css::frame::UnknownModuleException&) | |||
398 | { | |||
399 | SAL_INFO( "sfx.appl", "SfxHelp::getCurrentModuleIdentifier_Impl(): unknown module (help in help?)" )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() << "SfxHelp::getCurrentModuleIdentifier_Impl(): unknown module (help in help?)" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "399" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "SfxHelp::getCurrentModuleIdentifier_Impl(): unknown module (help in help?)" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "SfxHelp::getCurrentModuleIdentifier_Impl(): unknown module (help in help?)" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "399" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "SfxHelp::getCurrentModuleIdentifier_Impl(): unknown module (help in help?)" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "399" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "SfxHelp::getCurrentModuleIdentifier_Impl(): unknown module (help in help?)" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "SfxHelp::getCurrentModuleIdentifier_Impl(): unknown module (help in help?)" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "399" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
400 | } | |||
401 | catch (const Exception&) | |||
402 | { | |||
403 | TOOLS_WARN_EXCEPTION( "sfx.appl", "SfxHelp::getCurrentModuleIdentifier_Impl(): exception of XModuleManager::identify()" )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() << "SfxHelp::getCurrentModuleIdentifier_Impl(): exception of XModuleManager::identify()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "403" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "SfxHelp::getCurrentModuleIdentifier_Impl(): exception of XModuleManager::identify()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "SfxHelp::getCurrentModuleIdentifier_Impl(): exception of XModuleManager::identify()" << " " << exceptionToString(tools_warn_exception ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "403" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "SfxHelp::getCurrentModuleIdentifier_Impl(): exception of XModuleManager::identify()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "403" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "SfxHelp::getCurrentModuleIdentifier_Impl(): exception of XModuleManager::identify()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "SfxHelp::getCurrentModuleIdentifier_Impl(): exception of XModuleManager::identify()" << " " << exceptionToString(tools_warn_exception ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "403" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
404 | } | |||
405 | } | |||
406 | ||||
407 | return sIdentifier; | |||
408 | } | |||
409 | ||||
410 | namespace | |||
411 | { | |||
412 | OUString MapModuleIdentifier(const OUString &rFactoryShortName) | |||
413 | { | |||
414 | OUString aFactoryShortName(rFactoryShortName); | |||
415 | ||||
416 | // Map some module identifiers to their "real" help module string. | |||
417 | if ( aFactoryShortName == "chart2" ) | |||
418 | aFactoryShortName = "schart" ; | |||
419 | else if ( aFactoryShortName == "BasicIDE" ) | |||
420 | aFactoryShortName = "sbasic"; | |||
421 | else if ( aFactoryShortName == "sweb" | |||
422 | || aFactoryShortName == "sglobal" | |||
423 | || aFactoryShortName == "swxform" ) | |||
424 | aFactoryShortName = "swriter" ; | |||
425 | else if ( aFactoryShortName == "dbquery" | |||
426 | || aFactoryShortName == "dbbrowser" | |||
427 | || aFactoryShortName == "dbrelation" | |||
428 | || aFactoryShortName == "dbtable" | |||
429 | || aFactoryShortName == "dbapp" | |||
430 | || aFactoryShortName == "dbreport" | |||
431 | || aFactoryShortName == "dbtdata" | |||
432 | || aFactoryShortName == "swreport" | |||
433 | || aFactoryShortName == "swform" ) | |||
434 | aFactoryShortName = "sdatabase"; | |||
435 | else if ( aFactoryShortName == "sbibliography" | |||
436 | || aFactoryShortName == "sabpilot" | |||
437 | || aFactoryShortName == "scanner" | |||
438 | || aFactoryShortName == "spropctrlr" | |||
439 | || aFactoryShortName == "StartModule" ) | |||
440 | aFactoryShortName.clear(); | |||
441 | ||||
442 | return aFactoryShortName; | |||
443 | } | |||
444 | } | |||
445 | ||||
446 | OUString SfxHelp::GetHelpModuleName_Impl(const OUString& rHelpID) | |||
447 | { | |||
448 | OUString aFactoryShortName; | |||
449 | ||||
450 | //rhbz#1438876 detect preferred module for this help id, e.g. csv dialog | |||
451 | //for calc import before any toplevel is created and so context is | |||
452 | //otherwise unknown. Cosmetic, same help is shown in any case because its | |||
453 | //in the shared section, but title bar would state "Writer" when context is | |||
454 | //expected to be "Calc" | |||
455 | OUString sRemainder; | |||
456 | if (rHelpID.startsWith("modules/", &sRemainder)) | |||
457 | { | |||
458 | sal_Int32 nEndModule = sRemainder.indexOf('/'); | |||
459 | aFactoryShortName = nEndModule != -1 ? sRemainder.copy(0, nEndModule) : sRemainder; | |||
460 | } | |||
461 | ||||
462 | if (aFactoryShortName.isEmpty()) | |||
463 | { | |||
464 | OUString aModuleIdentifier = getCurrentModuleIdentifier_Impl(); | |||
465 | if (!aModuleIdentifier.isEmpty()) | |||
466 | { | |||
467 | try | |||
468 | { | |||
469 | Reference < XModuleManager2 > xModuleManager( | |||
470 | ModuleManager::create(::comphelper::getProcessComponentContext()) ); | |||
471 | Sequence< PropertyValue > lProps; | |||
472 | xModuleManager->getByName( aModuleIdentifier ) >>= lProps; | |||
473 | auto pProp = std::find_if(lProps.begin(), lProps.end(), | |||
474 | [](const PropertyValue& rProp) { return rProp.Name == "ooSetupFactoryShortName"; }); | |||
475 | if (pProp != lProps.end()) | |||
476 | pProp->Value >>= aFactoryShortName; | |||
477 | } | |||
478 | catch (const Exception&) | |||
479 | { | |||
480 | TOOLS_WARN_EXCEPTION( "sfx.appl", "SfxHelp::GetHelpModuleName_Impl()" )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() << "SfxHelp::GetHelpModuleName_Impl()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "480" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "SfxHelp::GetHelpModuleName_Impl()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "SfxHelp::GetHelpModuleName_Impl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "480" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "SfxHelp::GetHelpModuleName_Impl()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "480" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "SfxHelp::GetHelpModuleName_Impl()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "SfxHelp::GetHelpModuleName_Impl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "480" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
481 | } | |||
482 | } | |||
483 | } | |||
484 | ||||
485 | if (!aFactoryShortName.isEmpty()) | |||
486 | aFactoryShortName = MapModuleIdentifier(aFactoryShortName); | |||
487 | if (aFactoryShortName.isEmpty()) | |||
488 | aFactoryShortName = getDefaultModule_Impl(); | |||
489 | ||||
490 | return aFactoryShortName; | |||
491 | } | |||
492 | ||||
493 | OUString SfxHelp::CreateHelpURL_Impl( const OUString& aCommandURL, const OUString& rModuleName ) | |||
494 | { | |||
495 | // build up the help URL | |||
496 | OUStringBuffer aHelpURL("vnd.sun.star.help://"); | |||
497 | bool bHasAnchor = false; | |||
498 | OUString aAnchor; | |||
499 | ||||
500 | OUString aModuleName( rModuleName ); | |||
501 | if (aModuleName.isEmpty()) | |||
502 | aModuleName = getDefaultModule_Impl(); | |||
503 | ||||
504 | aHelpURL.append(aModuleName); | |||
505 | ||||
506 | if ( aCommandURL.isEmpty() ) | |||
507 | aHelpURL.append("/start"); | |||
508 | else | |||
509 | { | |||
510 | aHelpURL.append('/'); | |||
511 | aHelpURL.append(rtl::Uri::encode(aCommandURL, | |||
512 | rtl_UriCharClassRelSegment, | |||
513 | rtl_UriEncodeKeepEscapes, | |||
514 | RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)))); | |||
515 | ||||
516 | OUStringBuffer aTempURL = aHelpURL; | |||
517 | AppendConfigToken( aTempURL, true ); | |||
518 | bHasAnchor = GetHelpAnchor_Impl(aTempURL.makeStringAndClear(), aAnchor); | |||
519 | } | |||
520 | ||||
521 | AppendConfigToken( aHelpURL, true ); | |||
522 | ||||
523 | if ( bHasAnchor ) | |||
524 | { | |||
525 | aHelpURL.append('#'); | |||
526 | aHelpURL.append(aAnchor); | |||
527 | } | |||
528 | ||||
529 | return aHelpURL.makeStringAndClear(); | |||
530 | } | |||
531 | ||||
532 | static SfxHelpWindow_Impl* impl_createHelp(Reference< XFrame2 >& rHelpTask , | |||
533 | Reference< XFrame >& rHelpContent) | |||
534 | { | |||
535 | Reference < XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() ); | |||
536 | ||||
537 | // otherwise - create new help task | |||
538 | Reference< XFrame2 > xHelpTask( | |||
539 | xDesktop->findFrame( "OFFICE_HELP_TASK", FrameSearchFlag::TASKS | FrameSearchFlag::CREATE), | |||
540 | UNO_QUERY); | |||
541 | if (!xHelpTask.is()) | |||
542 | return nullptr; | |||
543 | ||||
544 | // create all internal windows and sub frames ... | |||
545 | Reference< css::awt::XWindow > xParentWindow = xHelpTask->getContainerWindow(); | |||
546 | VclPtr<vcl::Window> pParentWindow = VCLUnoHelper::GetWindow( xParentWindow ); | |||
547 | VclPtrInstance<SfxHelpWindow_Impl> pHelpWindow( xHelpTask, pParentWindow ); | |||
548 | Reference< css::awt::XWindow > xHelpWindow = VCLUnoHelper::GetInterface( pHelpWindow ); | |||
549 | ||||
550 | Reference< XFrame > xHelpContent; | |||
551 | if (xHelpTask->setComponent( xHelpWindow, Reference< XController >() )) | |||
552 | { | |||
553 | // Customize UI ... | |||
554 | xHelpTask->setName("OFFICE_HELP_TASK"); | |||
555 | ||||
556 | Reference< XPropertySet > xProps(xHelpTask, UNO_QUERY); | |||
557 | if (xProps.is()) | |||
558 | xProps->setPropertyValue( | |||
559 | "Title", | |||
560 | makeAny(SfxResId(STR_HELP_WINDOW_TITLEreinterpret_cast<char const *>("STR_HELP_WINDOW_TITLE" "\004" u8"%PRODUCTNAME Help")))); | |||
561 | ||||
562 | pHelpWindow->setContainerWindow( xParentWindow ); | |||
563 | xParentWindow->setVisible(true); | |||
564 | xHelpWindow->setVisible(true); | |||
565 | ||||
566 | // This sub frame is created internally (if we called new SfxHelpWindow_Impl() ...) | |||
567 | // It should exist :-) | |||
568 | xHelpContent = xHelpTask->findFrame("OFFICE_HELP", FrameSearchFlag::CHILDREN); | |||
569 | } | |||
570 | ||||
571 | if (!xHelpContent.is()) | |||
572 | { | |||
573 | pHelpWindow.disposeAndClear(); | |||
574 | return nullptr; | |||
575 | } | |||
576 | ||||
577 | xHelpContent->setName("OFFICE_HELP"); | |||
578 | ||||
579 | rHelpTask = xHelpTask; | |||
580 | rHelpContent = xHelpContent; | |||
581 | return pHelpWindow; | |||
582 | } | |||
583 | ||||
584 | OUString SfxHelp::GetHelpText( const OUString& aCommandURL, const vcl::Window* pWindow ) | |||
585 | { | |||
586 | OUString sModuleName = GetHelpModuleName_Impl(aCommandURL); | |||
587 | auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(aCommandURL, getCurrentModuleIdentifier_Impl()); | |||
588 | OUString sRealCommand = vcl::CommandInfoProvider::GetRealCommandForCommand(aProperties); | |||
589 | OUString sHelpText = SfxHelp_Impl::GetHelpText( sRealCommand.isEmpty() ? aCommandURL : sRealCommand, sModuleName ); | |||
590 | ||||
591 | OString aNewHelpId; | |||
592 | ||||
593 | if (pWindow && sHelpText.isEmpty()) | |||
594 | { | |||
595 | // no help text found -> try with parent help id. | |||
596 | vcl::Window* pParent = pWindow->GetParent(); | |||
597 | while ( pParent ) | |||
598 | { | |||
599 | aNewHelpId = pParent->GetHelpId(); | |||
600 | sHelpText = SfxHelp_Impl::GetHelpText( OStringToOUString(aNewHelpId, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76))), sModuleName ); | |||
601 | if (!sHelpText.isEmpty()) | |||
602 | pParent = nullptr; | |||
603 | else | |||
604 | pParent = pParent->GetParent(); | |||
605 | } | |||
606 | ||||
607 | if (bIsDebug && sHelpText.isEmpty()) | |||
608 | aNewHelpId.clear(); | |||
609 | } | |||
610 | ||||
611 | // add some debug information? | |||
612 | if ( bIsDebug ) | |||
613 | { | |||
614 | sHelpText += "\n-------------\n" + | |||
615 | sModuleName + ": " + aCommandURL; | |||
616 | if ( !aNewHelpId.isEmpty() ) | |||
617 | { | |||
618 | sHelpText += " - " + | |||
619 | OStringToOUString(aNewHelpId, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76))); | |||
620 | } | |||
621 | } | |||
622 | ||||
623 | return sHelpText; | |||
624 | } | |||
625 | ||||
626 | OUString SfxHelp::GetHelpText(const OUString& aCommandURL, const weld::Widget* pWidget) | |||
627 | { | |||
628 | OUString sModuleName = GetHelpModuleName_Impl(aCommandURL); | |||
629 | auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(aCommandURL, getCurrentModuleIdentifier_Impl()); | |||
630 | OUString sRealCommand = vcl::CommandInfoProvider::GetRealCommandForCommand(aProperties); | |||
631 | OUString sHelpText = SfxHelp_Impl::GetHelpText( sRealCommand.isEmpty() ? aCommandURL : sRealCommand, sModuleName ); | |||
632 | ||||
633 | OString aNewHelpId; | |||
634 | ||||
635 | if (pWidget && sHelpText.isEmpty()) | |||
636 | { | |||
637 | // no help text found -> try with parent help id. | |||
638 | std::unique_ptr<weld::Widget> xParent(pWidget->weld_parent()); | |||
639 | while (xParent) | |||
640 | { | |||
641 | aNewHelpId = xParent->get_help_id(); | |||
642 | sHelpText = SfxHelp_Impl::GetHelpText( OStringToOUString(aNewHelpId, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76))), sModuleName ); | |||
643 | if (!sHelpText.isEmpty()) | |||
644 | xParent.reset(); | |||
645 | else | |||
646 | xParent = xParent->weld_parent(); | |||
647 | } | |||
648 | ||||
649 | if (bIsDebug && sHelpText.isEmpty()) | |||
650 | aNewHelpId.clear(); | |||
651 | } | |||
652 | ||||
653 | // add some debug information? | |||
654 | if ( bIsDebug ) | |||
655 | { | |||
656 | sHelpText += "\n-------------\n" + | |||
657 | sModuleName + ": " + aCommandURL; | |||
658 | if ( !aNewHelpId.isEmpty() ) | |||
659 | { | |||
660 | sHelpText += " - " + | |||
661 | OStringToOUString(aNewHelpId, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76))); | |||
662 | } | |||
663 | } | |||
664 | ||||
665 | return sHelpText; | |||
666 | } | |||
667 | ||||
668 | OUString SfxHelp::GetURLHelpText(const OUString& aURL) | |||
669 | { | |||
670 | SvtSecurityOptions aSecOpt; | |||
671 | bool bCtrlClickHlink = aSecOpt.IsOptionSet(SvtSecurityOptions::EOption::CtrlClickHyperlink); | |||
672 | ||||
673 | // "ctrl-click to follow link:" for not MacOS | |||
674 | // "⌘-click to follow link:" for MacOs | |||
675 | vcl::KeyCode aCode(KEY_SPACE); | |||
676 | vcl::KeyCode aModifiedCode(KEY_SPACE, KEY_MOD1); | |||
677 | OUString aModStr(aModifiedCode.GetName()); | |||
678 | aModStr = aModStr.replaceFirst(aCode.GetName(), ""); | |||
679 | aModStr = aModStr.replaceAll("+", ""); | |||
680 | OUString aHelpStr | |||
681 | = bCtrlClickHlink ? SfxResId(STR_CTRLCLICKHYPERLINKreinterpret_cast<char const *>("STR_CTRLCLICKHYPERLINK" "\004" u8"%{key}-click to open hyperlink: %{link}")) : SfxResId(STR_CLICKHYPERLINKreinterpret_cast<char const *>("STR_CLICKHYPERLINK" "\004" u8"Click to open hyperlink: %{link}")); | |||
682 | aHelpStr = aHelpStr.replaceFirst("%{key}", aModStr); | |||
683 | aHelpStr = aHelpStr.replaceFirst("%{link}", aURL); | |||
684 | return aHelpStr; | |||
685 | } | |||
686 | ||||
687 | void SfxHelp::SearchKeyword( const OUString& rKeyword ) | |||
688 | { | |||
689 | Start_Impl(OUString(), static_cast<vcl::Window*>(nullptr), rKeyword); | |||
| ||||
690 | } | |||
691 | ||||
692 | bool SfxHelp::Start( const OUString& rURL, const vcl::Window* pWindow ) | |||
693 | { | |||
694 | return Start_Impl( rURL, pWindow, OUString() ); | |||
695 | } | |||
696 | ||||
697 | bool SfxHelp::Start(const OUString& rURL, weld::Widget* pWidget) | |||
698 | { | |||
699 | return Start_Impl(rURL, pWidget, OUString()); | |||
700 | } | |||
701 | ||||
702 | /// Redirect the vnd.sun.star.help:// urls to http://help.libreoffice.org | |||
703 | static bool impl_showOnlineHelp( const OUString& rURL ) | |||
704 | { | |||
705 | static constexpr OUStringLiteral aInternal(u"vnd.sun.star.help://"); | |||
706 | if ( rURL.getLength() <= aInternal.getLength() || !rURL.startsWith(aInternal) ) | |||
707 | return false; | |||
708 | ||||
709 | OUString aHelpLink = officecfg::Office::Common::Help::HelpRootURL::get(); | |||
710 | OUString aTarget = "Target=" + rURL.copy(aInternal.getLength()); | |||
711 | aTarget = aTarget.replaceAll("%2F", "/").replaceAll("?", "&"); | |||
712 | aHelpLink += aTarget; | |||
713 | ||||
714 | if (comphelper::LibreOfficeKit::isActive()) | |||
715 | { | |||
716 | if(SfxViewShell* pViewShell = SfxViewShell::Current()) | |||
717 | { | |||
718 | pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_HYPERLINK_CLICKED, | |||
719 | aHelpLink.toUtf8().getStr()); | |||
720 | return true; | |||
721 | } | |||
722 | return false; | |||
723 | } | |||
724 | ||||
725 | try | |||
726 | { | |||
727 | #ifdef MACOSX | |||
728 | LSOpenCFURLRef(CFURLCreateWithString(kCFAllocatorDefault, | |||
729 | CFStringCreateWithCString(kCFAllocatorDefault, | |||
730 | aHelpLink.toUtf8().getStr(), | |||
731 | kCFStringEncodingUTF8), | |||
732 | nullptr), | |||
733 | nullptr); | |||
734 | #else | |||
735 | sfx2::openUriExternally(aHelpLink, false); | |||
736 | #endif | |||
737 | return true; | |||
738 | } | |||
739 | catch (const Exception&) | |||
740 | { | |||
741 | } | |||
742 | return false; | |||
743 | } | |||
744 | ||||
745 | namespace { | |||
746 | ||||
747 | bool rewriteFlatpakHelpRootUrl(OUString * helpRootUrl) { | |||
748 | assert(helpRootUrl != nullptr)(static_cast <bool> (helpRootUrl != nullptr) ? void (0) : __assert_fail ("helpRootUrl != nullptr", "/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" , 748, __extension__ __PRETTY_FUNCTION__)); | |||
749 | //TODO: this function for now assumes that the passed-in *helpRootUrl references | |||
750 | // /app/libreoffice/help (which belongs to the org.libreoffice.LibreOffice.Help | |||
751 | // extension); it replaces it with the corresponding file URL as seen outside the flatpak | |||
752 | // sandbox: | |||
753 | struct Failure: public std::exception {}; | |||
754 | try { | |||
755 | static auto const url = [] { | |||
756 | // From /.flatpak-info [Instance] section, read | |||
757 | // app-path=<path> | |||
758 | // app-extensions=...;org.libreoffice.LibreOffice.Help=<sha>;... | |||
759 | // lines: | |||
760 | osl::File ini("file:///.flatpak-info"); | |||
761 | auto err = ini.open(osl_File_OpenFlag_Read0x00000001L); | |||
762 | if (err != osl::FileBase::E_None) { | |||
763 | SAL_WARN("sfx.appl", "LIBO_FLATPAK mode failure opening /.flatpak-info: " << err)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() << "LIBO_FLATPAK mode failure opening /.flatpak-info: " << err) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "763" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure opening /.flatpak-info: " << err), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "LIBO_FLATPAK mode failure opening /.flatpak-info: " << err; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "763" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode failure opening /.flatpak-info: " << err) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "763" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure opening /.flatpak-info: " << err), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "LIBO_FLATPAK mode failure opening /.flatpak-info: " << err; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "763" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
764 | throw Failure(); | |||
765 | } | |||
766 | OUString path; | |||
767 | OUString extensions; | |||
768 | bool havePath = false; | |||
769 | bool haveExtensions = false; | |||
770 | for (bool instance = false; !(havePath && haveExtensions);) { | |||
771 | rtl::ByteSequence bytes; | |||
772 | err = ini.readLine(bytes); | |||
773 | if (err != osl::FileBase::E_None) { | |||
774 | SAL_WARN(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() << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "777" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path"; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "777" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "777" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path"; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "777" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
775 | "sfx.appl",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() << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "777" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path"; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "777" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "777" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path"; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "777" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
776 | "LIBO_FLATPAK mode reading /.flatpak-info fails with " << errdo { 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() << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "777" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path"; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "777" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "777" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path"; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "777" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
777 | << " before [Instance] app-path")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() << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "777" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path"; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "777" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "777" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode reading /.flatpak-info fails with " << err << " before [Instance] app-path"; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "777" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
778 | throw Failure(); | |||
779 | } | |||
780 | std::string_view const line( | |||
781 | reinterpret_cast<char const *>(bytes.getConstArray()), bytes.getLength()); | |||
782 | if (instance) { | |||
783 | static constexpr auto keyPath = std::string_view("app-path="); | |||
784 | static constexpr auto keyExtensions = std::string_view("app-extensions="); | |||
785 | if (!havePath && line.length() >= keyPath.size() | |||
786 | && line.substr(0, keyPath.size()) == keyPath.data()) | |||
787 | { | |||
788 | auto const value = line.substr(keyPath.size()); | |||
789 | if (!rtl_convertStringToUString( | |||
790 | &path.pData, value.data(), value.length(), | |||
791 | osl_getThreadTextEncoding(), | |||
792 | (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR((sal_uInt32)0x0001) | |||
793 | | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR((sal_uInt32)0x0010) | |||
794 | | RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR((sal_uInt32)0x0100)))) | |||
795 | { | |||
796 | SAL_WARN(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() << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "799" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding"), 0); } else { ::std:: ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding"; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "799" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "799" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding"), 0); } else { ::std:: ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding"; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "799" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
797 | "sfx.appl",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() << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "799" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding"), 0); } else { ::std:: ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding"; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "799" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "799" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding"), 0); } else { ::std:: ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding"; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "799" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
798 | "LIBO_FLATPAK mode failure converting app-path \"" << valuedo { 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() << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "799" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding"), 0); } else { ::std:: ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding"; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "799" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "799" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding"), 0); } else { ::std:: ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding"; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "799" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
799 | << "\" encoding")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() << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "799" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding"), 0); } else { ::std:: ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding"; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "799" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "799" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding"), 0); } else { ::std:: ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-path \"" << value << "\" encoding"; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "799" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
800 | throw Failure(); | |||
801 | } | |||
802 | havePath = true; | |||
803 | } else if (!haveExtensions && line.length() >= keyExtensions.size() | |||
804 | && line.substr(0, keyExtensions.size()) == keyExtensions.data()) | |||
805 | { | |||
806 | auto const value = line.substr(keyExtensions.size()); | |||
807 | if (!rtl_convertStringToUString( | |||
808 | &extensions.pData, value.data(), value.length(), | |||
809 | osl_getThreadTextEncoding(), | |||
810 | (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR((sal_uInt32)0x0001) | |||
811 | | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR((sal_uInt32)0x0010) | |||
812 | | RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR((sal_uInt32)0x0100)))) | |||
813 | { | |||
814 | SAL_WARN(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() << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "817" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding"), 0); } else { ::std:: ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding"; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "817" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "817" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding"), 0); } else { ::std:: ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding"; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "817" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
815 | "sfx.appl",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() << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "817" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding"), 0); } else { ::std:: ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding"; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "817" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "817" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding"), 0); } else { ::std:: ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding"; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "817" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
816 | "LIBO_FLATPAK mode failure converting app-extensions \"" << valuedo { 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() << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "817" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding"), 0); } else { ::std:: ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding"; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "817" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "817" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding"), 0); } else { ::std:: ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding"; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "817" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
817 | << "\" encoding")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() << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "817" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding"), 0); } else { ::std:: ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding"; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "817" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "817" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding"), 0); } else { ::std:: ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-extensions \"" << value << "\" encoding"; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "817" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
818 | throw Failure(); | |||
819 | } | |||
820 | haveExtensions = true; | |||
821 | } else if (line.length() > 0 && line[0] == '[') { | |||
822 | SAL_WARN(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() << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "825" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "825" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "825" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "825" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
823 | "sfx.appl",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() << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "825" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "825" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "825" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "825" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
824 | "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and"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() << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "825" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "825" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "825" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "825" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
825 | " app-extensions")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() << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "825" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "825" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "825" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions"), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info lacks [Instance] app-path and" " app-extensions"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "825" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
826 | throw Failure(); | |||
827 | } | |||
828 | } else if (line == "[Instance]") { | |||
829 | instance = true; | |||
830 | } | |||
831 | } | |||
832 | ini.close(); | |||
833 | // Extract <sha> from ...;org.libreoffice.LibreOffice.Help=<sha>;...: | |||
834 | OUString sha; | |||
835 | for (sal_Int32 i = 0;;) { | |||
836 | OUString elem = extensions.getToken(0, ';', i); | |||
837 | if (elem.startsWith("org.libreoffice.LibreOffice.Help=", &sha)) { | |||
838 | break; | |||
839 | } | |||
840 | if (i == -1) { | |||
841 | SAL_WARN(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() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "844" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "844" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "844" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "844" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
842 | "sfx.appl",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() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "844" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "844" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "844" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "844" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
843 | "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \""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() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "844" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "844" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "844" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "844" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
844 | << extensions << "\" org.libreoffice.LibreOffice.Help")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() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "844" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "844" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "844" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-extensions \"" << extensions << "\" org.libreoffice.LibreOffice.Help" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "844" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
845 | throw Failure(); | |||
846 | } | |||
847 | } | |||
848 | // Assuming that <path> is of the form | |||
849 | // /.../app/org.libreoffice.LibreOffice/<arch>/<branch>/<sha'>/files | |||
850 | // rewrite it as | |||
851 | // /.../runtime/org.libreoffice.LibreOffice.Help/<arch>/<branch>/<sha>/files | |||
852 | // because the extension's files are stored at a different place than the app's files, | |||
853 | // so use this hack until flatpak itself provides a better solution: | |||
854 | static constexpr auto segments = OUStringLiteral(u"/app/org.libreoffice.LibreOffice/"); | |||
855 | auto const i1 = path.lastIndexOf(segments); | |||
856 | // use lastIndexOf instead of indexOf, in case the user-controlled prefix /.../ | |||
857 | // happens to contain such segments | |||
858 | if (i1 == -1) { | |||
859 | SAL_WARN(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() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "862" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "862" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "862" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "862" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
860 | "sfx.appl",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() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "862" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "862" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "862" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "862" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
861 | "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << pathdo { 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() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "862" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "862" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "862" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "862" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
862 | << "\" doesn't contain /app/org.libreoffice.LibreOffice/")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() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "862" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "862" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "862" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain /app/org.libreoffice.LibreOffice/" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "862" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
863 | throw Failure(); | |||
864 | } | |||
865 | auto const i2 = i1 + segments.getLength(); | |||
866 | auto i3 = path.indexOf('/', i2); | |||
867 | if (i3 == -1) { | |||
868 | SAL_WARN(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() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "871" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl") , ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "871" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "871" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl") , ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "871" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
869 | "sfx.appl",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() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "871" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl") , ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "871" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "871" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl") , ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "871" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
870 | "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << pathdo { 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() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "871" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl") , ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "871" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "871" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl") , ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "871" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
871 | << "\" doesn't contain branch segment")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() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "871" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl") , ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "871" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "871" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain branch segment"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl") , ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "871" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
872 | throw Failure(); | |||
873 | } | |||
874 | i3 = path.indexOf('/', i3 + 1); | |||
875 | if (i3 == -1) { | |||
876 | SAL_WARN(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() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment") == 1 ) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "879" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment"), 0) ; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "879" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment") == 1 ) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "879" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment"), 0) ; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "879" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
877 | "sfx.appl",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() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment") == 1 ) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "879" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment"), 0) ; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "879" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment") == 1 ) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "879" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment"), 0) ; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "879" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
878 | "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << pathdo { 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() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment") == 1 ) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "879" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment"), 0) ; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "879" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment") == 1 ) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "879" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment"), 0) ; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "879" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
879 | << "\" doesn't contain sha segment")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() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment") == 1 ) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "879" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment"), 0) ; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "879" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment") == 1 ) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "879" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment"), 0) ; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain sha segment"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "879" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
880 | throw Failure(); | |||
881 | } | |||
882 | ++i3; | |||
883 | auto const i4 = path.indexOf('/', i3); | |||
884 | if (i4 == -1) { | |||
885 | SAL_WARN(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() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "888" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment"), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl") , ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "888" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "888" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment"), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl") , ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "888" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
886 | "sfx.appl",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() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "888" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment"), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl") , ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "888" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "888" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment"), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl") , ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "888" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
887 | "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << pathdo { 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() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "888" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment"), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl") , ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "888" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "888" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment"), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl") , ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "888" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
888 | << "\" doesn't contain files segment")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() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "888" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment"), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl") , ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "888" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "888" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment"), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode /.flatpak-info [Instance] app-path \"" << path << "\" doesn't contain files segment"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl") , ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "888" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
889 | throw Failure(); | |||
890 | } | |||
891 | path = path.copy(0, i1) + "/runtime/org.libreoffice.LibreOffice.Help/" | |||
892 | + path.copy(i2, i3 - i2) + sha + path.copy(i4); | |||
893 | // Turn <path> into a file URL: | |||
894 | OUString url_; | |||
895 | err = osl::FileBase::getFileURLFromSystemPath(path, url_); | |||
896 | if (err != osl::FileBase::E_None) { | |||
897 | SAL_WARN(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() << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "900" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err; ::sal::detail::log( (:: SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "900" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "900" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err; ::sal::detail::log( (:: SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "900" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
898 | "sfx.appl",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() << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "900" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err; ::sal::detail::log( (:: SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "900" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "900" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err; ::sal::detail::log( (:: SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "900" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
899 | "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: "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() << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "900" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err; ::sal::detail::log( (:: SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "900" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "900" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err; ::sal::detail::log( (:: SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "900" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
900 | << err)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() << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "900" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err; ::sal::detail::log( (:: SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "900" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ( "/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "900" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "LIBO_FLATPAK mode failure converting app-path \"" << path << "\" to URL: " << err; ::sal::detail::log( (:: SAL_DETAIL_LOG_LEVEL_WARN), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "900" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
901 | throw Failure(); | |||
902 | } | |||
903 | return url_; | |||
904 | }(); | |||
905 | *helpRootUrl = url; | |||
906 | return true; | |||
907 | } catch (Failure &) { | |||
908 | return false; | |||
909 | } | |||
910 | } | |||
911 | ||||
912 | } | |||
913 | ||||
914 | // add <noscript> meta for browsers without javascript | |||
915 | ||||
916 | #define SHTML1"<!DOCTYPE HTML><html lang=\"en-US\"><head><meta charset=\"UTF-8\">" "<!DOCTYPE HTML><html lang=\"en-US\"><head><meta charset=\"UTF-8\">" | |||
917 | #define SHTML2"<noscript><meta http-equiv=\"refresh\" content=\"0; url='" "<noscript><meta http-equiv=\"refresh\" content=\"0; url='" | |||
918 | #define SHTML3"/noscript.html'\"></noscript><meta http-equiv=\"refresh\" content=\"1; url='" "/noscript.html'\"></noscript><meta http-equiv=\"refresh\" content=\"1; url='" | |||
919 | #define SHTML4"'\"><script type=\"text/javascript\"> window.location.href = \"" "'\"><script type=\"text/javascript\"> window.location.href = \"" | |||
920 | #define SHTML5"\";</script><title>Help Page Redirection</title></head><body></body></html>" "\";</script><title>Help Page Redirection</title></head><body></body></html>" | |||
921 | ||||
922 | // use a tempfile since e.g. xdg-open doesn't support URL-parameters with file:// URLs | |||
923 | static bool impl_showOfflineHelp( const OUString& rURL ) | |||
924 | { | |||
925 | OUString aBaseInstallPath = getHelpRootURL(); | |||
926 | // For the flatpak case, find the pathname outside the flatpak sandbox that corresponds to | |||
927 | // aBaseInstallPath, because that is what needs to be stored in aTempFile below: | |||
928 | if (flatpak::isFlatpak() && !rewriteFlatpakHelpRootUrl(&aBaseInstallPath)) { | |||
929 | return false; | |||
930 | } | |||
931 | ||||
932 | OUString aHelpLink( aBaseInstallPath + "/index.html?" ); | |||
933 | OUString aTarget = "Target=" + rURL.copy(RTL_CONSTASCII_LENGTH("vnd.sun.star.help://")((sal_Int32)((sizeof(sal_n_array_size("vnd.sun.star.help://") ))-1))); | |||
934 | aTarget = aTarget.replaceAll("%2F","/").replaceAll("?","&"); | |||
935 | aHelpLink += aTarget; | |||
936 | ||||
937 | // Get a html tempfile (for the flatpak case, create it in XDG_CACHE_HOME instead of /tmp for | |||
938 | // technical reasons, so that it can be accessed by the browser running outside the sandbox): | |||
939 | OUString const aExtension(".html"); | |||
940 | OUString * parent = nullptr; | |||
941 | if (flatpak::isFlatpak() && !flatpak::createTemporaryHtmlDirectory(&parent)) { | |||
942 | return false; | |||
943 | } | |||
944 | ::utl::TempFile aTempFile("NewHelp", true, &aExtension, parent, false ); | |||
945 | ||||
946 | SvStream* pStream = aTempFile.GetStream(StreamMode::WRITE); | |||
947 | pStream->SetStreamCharSet(RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76))); | |||
948 | ||||
949 | OUString aTempStr = SHTML1"<!DOCTYPE HTML><html lang=\"en-US\"><head><meta charset=\"UTF-8\">" SHTML2"<noscript><meta http-equiv=\"refresh\" content=\"0; url='" + | |||
950 | aBaseInstallPath + "/" + HelpLocaleString() + SHTML3"/noscript.html'\"></noscript><meta http-equiv=\"refresh\" content=\"1; url='" + | |||
951 | aHelpLink + SHTML4"'\"><script type=\"text/javascript\"> window.location.href = \"" + | |||
952 | aHelpLink + SHTML5"\";</script><title>Help Page Redirection</title></head><body></body></html>"; | |||
953 | ||||
954 | pStream->WriteUnicodeOrByteText(aTempStr); | |||
955 | ||||
956 | aTempFile.CloseStream(); | |||
957 | try | |||
958 | { | |||
959 | #ifdef MACOSX | |||
960 | LSOpenCFURLRef(CFURLCreateWithString(kCFAllocatorDefault, | |||
961 | CFStringCreateWithCString(kCFAllocatorDefault, | |||
962 | aTempFile.GetURL().toUtf8().getStr(), | |||
963 | kCFStringEncodingUTF8), | |||
964 | nullptr), | |||
965 | nullptr); | |||
966 | #else | |||
967 | sfx2::openUriExternally(aTempFile.GetURL(), false); | |||
968 | #endif | |||
969 | return true; | |||
970 | } | |||
971 | catch (const Exception&) | |||
972 | { | |||
973 | } | |||
974 | aTempFile.EnableKillingFile(); | |||
975 | return false; | |||
976 | } | |||
977 | ||||
978 | namespace | |||
979 | { | |||
980 | // tdf#119579 skip floating windows as potential parent for missing help dialog | |||
981 | const vcl::Window* GetBestParent(const vcl::Window* pWindow) | |||
982 | { | |||
983 | while (pWindow) | |||
984 | { | |||
985 | if (pWindow->IsSystemWindow() && pWindow->GetType() != WindowType::FLOATINGWINDOW) | |||
986 | break; | |||
987 | pWindow = pWindow->GetParent(); | |||
988 | } | |||
989 | return pWindow; | |||
990 | } | |||
991 | } | |||
992 | ||||
993 | namespace { | |||
994 | ||||
995 | class HelpManualMessage : public weld::MessageDialogController | |||
996 | { | |||
997 | private: | |||
998 | std::unique_ptr<weld::CheckButton> m_xHideOfflineHelpCB; | |||
999 | ||||
1000 | public: | |||
1001 | HelpManualMessage(weld::Widget* pParent) | |||
1002 | : MessageDialogController(pParent, "sfx/ui/helpmanual.ui", "onlinehelpmanual", "hidedialog") | |||
1003 | , m_xHideOfflineHelpCB(m_xBuilder->weld_check_button("hidedialog")) | |||
1004 | { | |||
1005 | LanguageTag aLangTag = Application::GetSettings().GetUILanguageTag(); | |||
1006 | OUString sLocaleString = SvtLanguageTable::GetLanguageString(aLangTag.getLanguageType()); | |||
1007 | OUString sPrimText = get_primary_text(); | |||
1008 | set_primary_text(sPrimText.replaceAll("$UILOCALE", sLocaleString)); | |||
1009 | } | |||
1010 | ||||
1011 | bool GetOfflineHelpPopUp() const { return !m_xHideOfflineHelpCB->get_active(); } | |||
1012 | }; | |||
1013 | ||||
1014 | } | |||
1015 | ||||
1016 | bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow, const OUString& rKeyword) | |||
1017 | { | |||
1018 | OUStringBuffer aHelpRootURL("vnd.sun.star.help://"); | |||
1019 | AppendConfigToken(aHelpRootURL, true); | |||
1020 | SfxContentHelper::GetResultSet(aHelpRootURL.makeStringAndClear()); | |||
1021 | ||||
1022 | /* rURL may be | |||
1023 | * - a "real" URL | |||
1024 | * - a HelpID (formerly a long, now a string) | |||
1025 | * If rURL is a URL, CreateHelpURL should be called for this URL | |||
1026 | * If rURL is an arbitrary string, the same should happen, but the URL should be tried out | |||
1027 | * if it delivers real help content. In case only the Help Error Document is returned, the | |||
1028 | * parent of the window for that help was called, is asked for its HelpID. | |||
1029 | * For compatibility reasons this upward search is not implemented for "real" URLs. | |||
1030 | * Help keyword search now is implemented as own method; in former versions it | |||
1031 | * was done via Help::Start, but this implementation conflicted with the upward search. | |||
1032 | */ | |||
1033 | OUString aHelpURL; | |||
1034 | INetURLObject aParser( rURL ); | |||
1035 | INetProtocol nProtocol = aParser.GetProtocol(); | |||
1036 | ||||
1037 | switch ( nProtocol ) | |||
1038 | { | |||
1039 | case INetProtocol::VndSunStarHelp: | |||
1040 | // already a vnd.sun.star.help URL -> nothing to do | |||
1041 | aHelpURL = rURL; | |||
1042 | break; | |||
1043 | default: | |||
1044 | { | |||
1045 | OUString aHelpModuleName(GetHelpModuleName_Impl(rURL)); | |||
1046 | OUString aRealCommand; | |||
1047 | ||||
1048 | if ( nProtocol == INetProtocol::Uno ) | |||
1049 | { | |||
1050 | // Command can be just an alias to another command. | |||
1051 | auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(rURL, getCurrentModuleIdentifier_Impl()); | |||
1052 | aRealCommand = vcl::CommandInfoProvider::GetRealCommandForCommand(aProperties); | |||
1053 | } | |||
1054 | ||||
1055 | // no URL, just a HelpID (maybe empty in case of keyword search) | |||
1056 | aHelpURL = CreateHelpURL_Impl( aRealCommand.isEmpty() ? rURL : aRealCommand, aHelpModuleName ); | |||
1057 | ||||
1058 | if ( impl_hasHelpInstalled() && pWindow && SfxContentHelper::IsHelpErrorDocument( aHelpURL ) ) | |||
1059 | { | |||
1060 | // no help found -> try with parent help id. | |||
1061 | vcl::Window* pParent = pWindow->GetParent(); | |||
1062 | while ( pParent ) | |||
1063 | { | |||
1064 | OString aHelpId = pParent->GetHelpId(); | |||
1065 | aHelpURL = CreateHelpURL( OStringToOUString(aHelpId, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76))), aHelpModuleName ); | |||
1066 | ||||
1067 | if ( !SfxContentHelper::IsHelpErrorDocument( aHelpURL ) ) | |||
1068 | { | |||
1069 | break; | |||
1070 | } | |||
1071 | else | |||
1072 | { | |||
1073 | pParent = pParent->GetParent(); | |||
1074 | if (!pParent) | |||
1075 | { | |||
1076 | // create help url of start page ( helpid == 0 -> start page) | |||
1077 | aHelpURL = CreateHelpURL( OUString(), aHelpModuleName ); | |||
1078 | } | |||
1079 | } | |||
1080 | } | |||
1081 | } | |||
1082 | break; | |||
1083 | } | |||
1084 | } | |||
1085 | ||||
1086 | if ( comphelper::LibreOfficeKit::isActive() ) | |||
1087 | { | |||
1088 | impl_showOnlineHelp( aHelpURL ); | |||
1089 | return true; | |||
1090 | } | |||
1091 | #ifdef MACOSX | |||
1092 | if (@available(macOS 10.14, *)) { | |||
1093 | // Workaround: Safari sandboxing prevents it from accessing files in the LibreOffice.app folder | |||
1094 | // force online-help instead if Safari is default browser. | |||
1095 | CFURLRef pBrowser = LSCopyDefaultApplicationURLForURL( | |||
1096 | CFURLCreateWithString( | |||
1097 | kCFAllocatorDefault, | |||
1098 | static_cast<CFStringRef>(@"https://www.libreoffice.org"), | |||
1099 | nullptr), | |||
1100 | kLSRolesAll, nullptr); | |||
1101 | if([static_cast<NSString*>(CFURLGetString(pBrowser)) isEqualToString:@"file:///Applications/Safari.app/"]) { | |||
1102 | impl_showOnlineHelp( aHelpURL ); | |||
1103 | return true; | |||
1104 | } | |||
1105 | } | |||
1106 | #endif | |||
1107 | ||||
1108 | // If the HTML or no help is installed, but aHelpURL nevertheless references valid help content, | |||
1109 | // that implies that this help content belongs to an extension (and thus would not be available | |||
1110 | // in neither the offline nor online HTML help); in that case, fall through to the "old-help to | |||
1111 | // display" code below: | |||
1112 | if (SfxContentHelper::IsHelpErrorDocument(aHelpURL)) | |||
1113 | { | |||
1114 | if ( impl_hasHTMLHelpInstalled() && impl_showOfflineHelp(aHelpURL) ) | |||
1115 | { | |||
1116 | return true; | |||
1117 | } | |||
1118 | ||||
1119 | if ( !impl_hasHelpInstalled() ) | |||
1120 | { | |||
1121 | SvtHelpOptions aHelpOptions; | |||
1122 | bool bShowOfflineHelpPopUp = aHelpOptions.IsOfflineHelpPopUp(); | |||
1123 | ||||
1124 | pWindow = GetBestParent(pWindow); | |||
1125 | ||||
1126 | TopLevelWindowLocker aBusy; | |||
1127 | ||||
1128 | if(bShowOfflineHelpPopUp) | |||
1129 | { | |||
1130 | weld::Window* pWeldWindow = pWindow ? pWindow->GetFrameWeld() : nullptr; | |||
1131 | aBusy.incBusy(pWeldWindow); | |||
1132 | HelpManualMessage aQueryBox(pWeldWindow); | |||
1133 | short OnlineHelpBox = aQueryBox.run(); | |||
1134 | bShowOfflineHelpPopUp = OnlineHelpBox != RET_OK; | |||
1135 | aHelpOptions.SetOfflineHelpPopUp(aQueryBox.GetOfflineHelpPopUp()); | |||
1136 | aBusy.decBusy(); | |||
1137 | } | |||
1138 | if(!bShowOfflineHelpPopUp) | |||
1139 | { | |||
1140 | if ( impl_showOnlineHelp( aHelpURL ) ) | |||
1141 | return true; | |||
1142 | else | |||
1143 | { | |||
1144 | weld::Window* pWeldWindow = pWindow ? pWindow->GetFrameWeld() : nullptr; | |||
1145 | aBusy.incBusy(pWeldWindow); | |||
1146 | NoHelpErrorBox aErrBox(pWeldWindow); | |||
1147 | aErrBox.run(); | |||
1148 | aBusy.decBusy(); | |||
1149 | return false; | |||
1150 | } | |||
1151 | } | |||
1152 | else | |||
1153 | { | |||
1154 | return false; | |||
1155 | } | |||
1156 | } | |||
1157 | } | |||
1158 | ||||
1159 | // old-help to display | |||
1160 | Reference < XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() ); | |||
1161 | ||||
1162 | // check if help window is still open | |||
1163 | // If not, create a new one and return access directly to the internal sub frame showing the help content | |||
1164 | // search must be done here; search one desktop level could return an arbitrary frame | |||
1165 | Reference< XFrame2 > xHelp( | |||
1166 | xDesktop->findFrame( "OFFICE_HELP_TASK", FrameSearchFlag::CHILDREN), | |||
1167 | UNO_QUERY); | |||
1168 | Reference< XFrame > xHelpContent = xDesktop->findFrame( | |||
1169 | "OFFICE_HELP", | |||
1170 | FrameSearchFlag::CHILDREN); | |||
1171 | ||||
1172 | SfxHelpWindow_Impl* pHelpWindow = nullptr; | |||
1173 | if (!xHelp.is()) | |||
1174 | pHelpWindow = impl_createHelp(xHelp, xHelpContent); | |||
1175 | else | |||
1176 | pHelpWindow = static_cast<SfxHelpWindow_Impl*>(VCLUnoHelper::GetWindow(xHelp->getComponentWindow()).get()); | |||
1177 | if (!xHelp.is() || !xHelpContent.is() || !pHelpWindow) | |||
1178 | return false; | |||
1179 | ||||
1180 | SAL_INFO("sfx.appl", "HelpId = " << aHelpURL)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() << "HelpId = " << aHelpURL ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "1180" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "HelpId = " << aHelpURL), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "HelpId = " << aHelpURL; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "1180" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "HelpId = " << aHelpURL) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "1180" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "HelpId = " << aHelpURL), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "HelpId = " << aHelpURL; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "1180" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1181 | ||||
1182 | pHelpWindow->SetHelpURL( aHelpURL ); | |||
1183 | pHelpWindow->loadHelpContent(aHelpURL); | |||
1184 | if (!rKeyword.isEmpty()) | |||
1185 | pHelpWindow->OpenKeyword( rKeyword ); | |||
1186 | ||||
1187 | Reference < css::awt::XTopWindow > xTopWindow( xHelp->getContainerWindow(), UNO_QUERY ); | |||
1188 | if ( xTopWindow.is() ) | |||
1189 | xTopWindow->toFront(); | |||
1190 | ||||
1191 | return true; | |||
1192 | } | |||
1193 | ||||
1194 | bool SfxHelp::Start_Impl(const OUString& rURL, weld::Widget* pWidget, const OUString& rKeyword) | |||
1195 | { | |||
1196 | OUStringBuffer aHelpRootURL("vnd.sun.star.help://"); | |||
1197 | AppendConfigToken(aHelpRootURL, true); | |||
1198 | SfxContentHelper::GetResultSet(aHelpRootURL.makeStringAndClear()); | |||
1199 | ||||
1200 | /* rURL may be | |||
1201 | * - a "real" URL | |||
1202 | * - a HelpID (formerly a long, now a string) | |||
1203 | * If rURL is a URL, CreateHelpURL should be called for this URL | |||
1204 | * If rURL is an arbitrary string, the same should happen, but the URL should be tried out | |||
1205 | * if it delivers real help content. In case only the Help Error Document is returned, the | |||
1206 | * parent of the window for that help was called, is asked for its HelpID. | |||
1207 | * For compatibility reasons this upward search is not implemented for "real" URLs. | |||
1208 | * Help keyword search now is implemented as own method; in former versions it | |||
1209 | * was done via Help::Start, but this implementation conflicted with the upward search. | |||
1210 | */ | |||
1211 | OUString aHelpURL; | |||
1212 | INetURLObject aParser( rURL ); | |||
1213 | INetProtocol nProtocol = aParser.GetProtocol(); | |||
1214 | ||||
1215 | switch ( nProtocol ) | |||
1216 | { | |||
1217 | case INetProtocol::VndSunStarHelp: | |||
1218 | // already a vnd.sun.star.help URL -> nothing to do | |||
1219 | aHelpURL = rURL; | |||
1220 | break; | |||
1221 | default: | |||
1222 | { | |||
1223 | OUString aHelpModuleName(GetHelpModuleName_Impl(rURL)); | |||
1224 | OUString aRealCommand; | |||
1225 | ||||
1226 | if ( nProtocol == INetProtocol::Uno ) | |||
1227 | { | |||
1228 | // Command can be just an alias to another command. | |||
1229 | auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(rURL, getCurrentModuleIdentifier_Impl()); | |||
1230 | aRealCommand = vcl::CommandInfoProvider::GetRealCommandForCommand(aProperties); | |||
1231 | } | |||
1232 | ||||
1233 | // no URL, just a HelpID (maybe empty in case of keyword search) | |||
1234 | aHelpURL = CreateHelpURL_Impl( aRealCommand.isEmpty() ? rURL : aRealCommand, aHelpModuleName ); | |||
1235 | ||||
1236 | if ( impl_hasHelpInstalled() && pWidget && SfxContentHelper::IsHelpErrorDocument( aHelpURL ) ) | |||
1237 | { | |||
1238 | bool bUseFinalFallback = true; | |||
1239 | // no help found -> try ids of parents. | |||
1240 | pWidget->help_hierarchy_foreach([&aHelpModuleName, &aHelpURL, &bUseFinalFallback](const OString& rHelpId){ | |||
1241 | if (rHelpId.isEmpty()) | |||
1242 | return false; | |||
1243 | aHelpURL = CreateHelpURL( OStringToOUString(rHelpId, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76))), aHelpModuleName); | |||
1244 | bool bFinished = !SfxContentHelper::IsHelpErrorDocument(aHelpURL); | |||
1245 | if (bFinished) | |||
1246 | bUseFinalFallback = false; | |||
1247 | return bFinished; | |||
1248 | }); | |||
1249 | ||||
1250 | if (bUseFinalFallback) | |||
1251 | { | |||
1252 | // create help url of start page ( helpid == 0 -> start page) | |||
1253 | aHelpURL = CreateHelpURL( OUString(), aHelpModuleName ); | |||
1254 | } | |||
1255 | } | |||
1256 | break; | |||
1257 | } | |||
1258 | } | |||
1259 | ||||
1260 | if ( comphelper::LibreOfficeKit::isActive() ) | |||
1261 | { | |||
1262 | impl_showOnlineHelp( aHelpURL ); | |||
1263 | return true; | |||
1264 | } | |||
1265 | ||||
1266 | // If the HTML or no help is installed, but aHelpURL nevertheless references valid help content, | |||
1267 | // that implies that help content belongs to an extension (and thus would not be available | |||
1268 | // in neither the offline nor online HTML help); in that case, fall through to the "old-help to | |||
1269 | // display" code below: | |||
1270 | if (SfxContentHelper::IsHelpErrorDocument(aHelpURL)) | |||
1271 | { | |||
1272 | if ( impl_hasHTMLHelpInstalled() && impl_showOfflineHelp(aHelpURL) ) | |||
1273 | { | |||
1274 | return true; | |||
1275 | } | |||
1276 | ||||
1277 | if ( !impl_hasHelpInstalled() ) | |||
1278 | { | |||
1279 | SvtHelpOptions aHelpOptions; | |||
1280 | bool bShowOfflineHelpPopUp = aHelpOptions.IsOfflineHelpPopUp(); | |||
1281 | ||||
1282 | TopLevelWindowLocker aBusy; | |||
1283 | ||||
1284 | if(bShowOfflineHelpPopUp) | |||
1285 | { | |||
1286 | aBusy.incBusy(pWidget); | |||
1287 | HelpManualMessage aQueryBox(pWidget); | |||
1288 | short OnlineHelpBox = aQueryBox.run(); | |||
1289 | bShowOfflineHelpPopUp = OnlineHelpBox != RET_OK; | |||
1290 | aHelpOptions.SetOfflineHelpPopUp(aQueryBox.GetOfflineHelpPopUp()); | |||
1291 | aBusy.decBusy(); | |||
1292 | } | |||
1293 | if(!bShowOfflineHelpPopUp) | |||
1294 | { | |||
1295 | if ( impl_showOnlineHelp( aHelpURL ) ) | |||
1296 | return true; | |||
1297 | else | |||
1298 | { | |||
1299 | aBusy.incBusy(pWidget); | |||
1300 | NoHelpErrorBox aErrBox(pWidget); | |||
1301 | aErrBox.run(); | |||
1302 | aBusy.decBusy(); | |||
1303 | return false; | |||
1304 | } | |||
1305 | } | |||
1306 | else | |||
1307 | { | |||
1308 | return false; | |||
1309 | } | |||
1310 | ||||
1311 | } | |||
1312 | } | |||
1313 | ||||
1314 | // old-help to display | |||
1315 | Reference < XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() ); | |||
1316 | ||||
1317 | // check if help window is still open | |||
1318 | // If not, create a new one and return access directly to the internal sub frame showing the help content | |||
1319 | // search must be done here; search one desktop level could return an arbitrary frame | |||
1320 | Reference< XFrame2 > xHelp( | |||
1321 | xDesktop->findFrame( "OFFICE_HELP_TASK", FrameSearchFlag::CHILDREN), | |||
1322 | UNO_QUERY); | |||
1323 | Reference< XFrame > xHelpContent = xDesktop->findFrame( | |||
1324 | "OFFICE_HELP", | |||
1325 | FrameSearchFlag::CHILDREN); | |||
1326 | ||||
1327 | SfxHelpWindow_Impl* pHelpWindow = nullptr; | |||
1328 | if (!xHelp.is()) | |||
1329 | pHelpWindow = impl_createHelp(xHelp, xHelpContent); | |||
1330 | else | |||
1331 | pHelpWindow = static_cast<SfxHelpWindow_Impl*>(VCLUnoHelper::GetWindow(xHelp->getComponentWindow()).get()); | |||
1332 | if (!xHelp.is() || !xHelpContent.is() || !pHelpWindow) | |||
1333 | return false; | |||
1334 | ||||
1335 | SAL_INFO("sfx.appl", "HelpId = " << aHelpURL)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() << "HelpId = " << aHelpURL ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl" ), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "1335" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "HelpId = " << aHelpURL), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "HelpId = " << aHelpURL; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "1335" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "HelpId = " << aHelpURL) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "1335" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "HelpId = " << aHelpURL), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "HelpId = " << aHelpURL; ::sal::detail::log( ( ::SAL_DETAIL_LOG_LEVEL_INFO), ("sfx.appl"), ("/home/maarten/src/libreoffice/core/sfx2/source/appl/sfxhelp.cxx" ":" "1335" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1336 | ||||
1337 | pHelpWindow->SetHelpURL( aHelpURL ); | |||
1338 | pHelpWindow->loadHelpContent(aHelpURL); | |||
1339 | if (!rKeyword.isEmpty()) | |||
1340 | pHelpWindow->OpenKeyword( rKeyword ); | |||
1341 | ||||
1342 | Reference < css::awt::XTopWindow > xTopWindow( xHelp->getContainerWindow(), UNO_QUERY ); | |||
1343 | if ( xTopWindow.is() ) | |||
1344 | xTopWindow->toFront(); | |||
1345 | ||||
1346 | return true; | |||
1347 | } | |||
1348 | ||||
1349 | OUString SfxHelp::CreateHelpURL(const OUString& aCommandURL, const OUString& rModuleName) | |||
1350 | { | |||
1351 | SfxHelp* pHelp = static_cast< SfxHelp* >(Application::GetHelp()); | |||
1352 | return pHelp ? SfxHelp::CreateHelpURL_Impl( aCommandURL, rModuleName ) : OUString(); | |||
1353 | } | |||
1354 | ||||
1355 | OUString SfxHelp::GetDefaultHelpModule() | |||
1356 | { | |||
1357 | return getDefaultModule_Impl(); | |||
1358 | } | |||
1359 | ||||
1360 | OUString SfxHelp::GetCurrentModuleIdentifier() | |||
1361 | { | |||
1362 | return getCurrentModuleIdentifier_Impl(); | |||
1363 | } | |||
1364 | ||||
1365 | bool SfxHelp::IsHelpInstalled() | |||
1366 | { | |||
1367 | return impl_hasHelpInstalled(); | |||
1368 | } | |||
1369 | ||||
1370 | /* 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 |