tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / framework / inc / jobs / helponstartup.hxx
blobaaaf35492ffe748154ea580cf09069942798dd7e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <sal/config.h>
24 #include <mutex>
25 #include <string_view>
27 #include <cppuhelper/implbase.hxx>
29 #include <com/sun/star/task/XJob.hpp>
30 #include <com/sun/star/lang/XEventListener.hpp>
31 #include <com/sun/star/container/XNameAccess.hpp>
32 #include <com/sun/star/frame/XDesktop2.hpp>
33 #include <com/sun/star/frame/XModuleManager2.hpp>
34 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <com/sun/star/uno/XComponentContext.hpp>
37 namespace framework{
39 /** @short implements a job component, which handle the special
40 feature to show a suitable help page for every (visible!)
41 loaded document.
43 class HelpOnStartup final : public ::cppu::WeakImplHelper< css::lang::XServiceInfo,css::lang::XEventListener,css::task::XJob >
46 // member
47 private:
48 std::mutex m_mutex;
50 /** @short reference to a uno service manager. */
51 css::uno::Reference< css::uno::XComponentContext > m_xContext;
53 /** @short such module manager is used to classify new opened documents. */
54 css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager;
56 /** @short is needed to locate a might open help frame. */
57 css::uno::Reference< css::frame::XDesktop2 > m_xDesktop;
59 /** @short provides read access to the underlying configuration. */
60 css::uno::Reference< css::container::XNameAccess > m_xConfig;
62 /** @short knows the current locale of this office session,
63 which is needed to build complete help URLs.
65 OUString m_sLocale;
67 /** @short knows the current operating system of this office session,
68 which is needed to build complete help URLs.
70 OUString m_sSystem;
72 // native interface
73 public:
75 /** @short create new instance of this class.
77 @param xContext
78 reference to the uno service manager, which created this instance.
79 Can be used later to create own needed uno resources on demand.
81 HelpOnStartup(css::uno::Reference< css::uno::XComponentContext > xContext);
83 /** @short does nothing real ...
85 @descr But it should exists as virtual function,
86 so this class can't make trouble
87 related to inline/symbols etcpp.!
89 virtual ~HelpOnStartup() override;
91 // uno interface
92 public:
94 /* interface XServiceInfo */
95 virtual OUString SAL_CALL getImplementationName() override;
96 virtual sal_Bool SAL_CALL supportsService( const OUString& sServiceName ) override;
97 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
99 // css.task.XJob
100 virtual css::uno::Any SAL_CALL execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments) override;
102 // css.lang.XEventListener
103 virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override;
105 // helper
106 private:
108 /** @short analyze the given job arguments, try to locate a model reference
109 and try to classify this model.
111 @descr As a result of this operation a module identifier will be returned.
112 It can be used against the module configuration then to retrieve further information.
114 @param lArguments
115 the list of job arguments which is given on our interface method execute().
117 @return [string]
118 a module identifier ... or an empty value if no model could be located ...
119 or if it could not be classified successfully.
121 OUString its_getModuleIdFromEnv(const css::uno::Sequence< css::beans::NamedValue >& lArguments);
123 /** @short tries to locate the open help module and return
124 the url of the currently shown help content.
126 @descr It returns an empty string, if the help isn't still
127 open at calling time.
129 @return The URL of the current shown help content;
130 or an empty value if the help isn't still open.
132 OUString its_getCurrentHelpURL();
134 /** @short checks if the given help url match to a default help url
135 of any office module.
137 @param sHelpURL
138 the help url for checking.
140 @return [bool]
141 sal_True if the given URL is any default one ...
142 sal_False otherwise.
144 bool its_isHelpUrlADefaultOne(std::u16string_view sHelpURL);
146 /** @short checks, if the help module should be shown automatically for the
147 currently opened office module.
149 @descr This value is read from the module configuration.
150 In case the help should be shown, this method returns
151 a help URL, which can be used to show the right help content.
153 @param sModule
154 identifies the used office module.
156 @return [string]
157 A valid help URL in case the help content should be shown;
158 an empty value if such automatism was disabled for the specified office module.
160 OUString its_checkIfHelpEnabledAndGetURL(const OUString& sModule);
162 /** @short create a help URL for the given parameters.
164 @param sBaseURL
165 must be the base URL for a requested help content
166 e.g. "vnd.sun.star.help://swriter/"
167 or "vnd.sun.star.help://swriter/67351"
169 @param sLocale
170 the current office locale
171 e.g. "en-US"
173 @param sSystem
174 the current operating system
175 e.g. "WIN"
177 @return The URL which was generated.
178 e.g.
179 e.g. "vnd.sun.star.help://swriter/?Language=en-US&System=WIN"
180 or "vnd.sun.star.help://swriter/67351?Language=en-US&System=WIN"
182 static OUString ist_createHelpURL(std::u16string_view sBaseURL,
183 std::u16string_view sLocale ,
184 std::u16string_view sSystem );
187 } // namespace framework
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */