LibreOffice Module framework (master) 1
helponstartup.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <sal/config.h>
23
24#include <mutex>
25#include <string_view>
26
28
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>
36
37namespace framework{
38
43class HelpOnStartup final : public ::cppu::WeakImplHelper< css::lang::XServiceInfo,css::lang::XEventListener,css::task::XJob >
44{
45
46 // member
47 private:
48 std::mutex m_mutex;
49
51 css::uno::Reference< css::uno::XComponentContext > m_xContext;
52
54 css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager;
55
57 css::uno::Reference< css::frame::XDesktop2 > m_xDesktop;
58
60 css::uno::Reference< css::container::XNameAccess > m_xConfig;
61
65 OUString m_sLocale;
66
70 OUString m_sSystem;
71
72 // native interface
73 public:
74
81 HelpOnStartup(css::uno::Reference< css::uno::XComponentContext > xContext);
82
89 virtual ~HelpOnStartup() override;
90
91 // uno interface
92 public:
93
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;
98
99 // css.task.XJob
100 virtual css::uno::Any SAL_CALL execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments) override;
101
102 // css.lang.XEventListener
103 virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override;
104
105 // helper
106 private:
107
121 OUString its_getModuleIdFromEnv(const css::uno::Sequence< css::beans::NamedValue >& lArguments);
122
132 OUString its_getCurrentHelpURL();
133
144 bool its_isHelpUrlADefaultOne(std::u16string_view sHelpURL);
145
160 OUString its_checkIfHelpEnabledAndGetURL(const OUString& sModule);
161
182 static OUString ist_createHelpURL(std::u16string_view sBaseURL,
183 std::u16string_view sLocale ,
184 std::u16string_view sSystem );
185};
186
187} // namespace framework
188
189/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
implements a job component, which handle the special feature to show a suitable help page for every (...
HelpOnStartup(css::uno::Reference< css::uno::XComponentContext > xContext)
create new instance of this class.
css::uno::Reference< css::frame::XDesktop2 > m_xDesktop
is needed to locate a might open help frame.
static OUString ist_createHelpURL(std::u16string_view sBaseURL, std::u16string_view sLocale, std::u16string_view sSystem)
create a help URL for the given parameters.
OUString its_checkIfHelpEnabledAndGetURL(const OUString &sModule)
checks, if the help module should be shown automatically for the currently opened office module.
virtual void SAL_CALL disposing(const css::lang::EventObject &aEvent) override
virtual OUString SAL_CALL getImplementationName() override
OUString its_getCurrentHelpURL()
tries to locate the open help module and return the url of the currently shown help content.
OUString m_sSystem
knows the current operating system of this office session, which is needed to build complete help URL...
bool its_isHelpUrlADefaultOne(std::u16string_view sHelpURL)
checks if the given help url match to a default help url of any office module.
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager
such module manager is used to classify new opened documents.
OUString m_sLocale
knows the current locale of this office session, which is needed to build complete help URLs.
virtual css::uno::Any SAL_CALL execute(const css::uno::Sequence< css::beans::NamedValue > &lArguments) override
virtual ~HelpOnStartup() override
does nothing real ...
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
css::uno::Reference< css::uno::XComponentContext > m_xContext
reference to a uno service manager.
css::uno::Reference< css::container::XNameAccess > m_xConfig
provides read access to the underlying configuration.
OUString its_getModuleIdFromEnv(const css::uno::Sequence< css::beans::NamedValue > &lArguments)
analyze the given job arguments, try to locate a model reference and try to classify this model.
unsigned char sal_Bool