1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <sal/config.h>
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>
39 /** @short implements a job component, which handle the special
40 feature to show a suitable help page for every (visible!)
43 class HelpOnStartup final
: public ::cppu::WeakImplHelper
< css::lang::XServiceInfo
,css::lang::XEventListener
,css::task::XJob
>
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.
67 /** @short knows the current operating system of this office session,
68 which is needed to build complete help URLs.
75 /** @short create new instance of this class.
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
;
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
;
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
;
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.
115 the list of job arguments which is given on our interface method execute().
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.
138 the help url for checking.
141 sal_True if the given URL is any default one ...
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.
154 identifies the used office module.
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.
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"
170 the current office locale
174 the current operating system
177 @return The URL which was generated.
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: */