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 .
20 #ifndef INCLUDED_FRAMEWORK_INC_JOBS_HELPONSTARTUP_HXX
21 #define INCLUDED_FRAMEWORK_INC_JOBS_HELPONSTARTUP_HXX
23 #include <macros/xinterface.hxx>
24 #include <macros/xtypeprovider.hxx>
25 #include <macros/xserviceinfo.hxx>
27 #include <cppuhelper/implbase3.hxx>
29 #include <com/sun/star/frame/XFrame.hpp>
30 #include <com/sun/star/task/XJob.hpp>
31 #include <com/sun/star/lang/XEventListener.hpp>
32 #include <com/sun/star/container/XNameAccess.hpp>
33 #include <com/sun/star/frame/XDesktop2.hpp>
34 #include <com/sun/star/frame/XModuleManager2.hpp>
38 /** @short implements a job component, which handle the special
39 feature to show a suitable help page for every (visible!)
44 class HelpOnStartup
: public ::cppu::WeakImplHelper3
< ::com::sun::star::lang::XServiceInfo
,::com::sun::star::lang::XEventListener
,::com::sun::star::task::XJob
>
51 /** @short reference to an uno service manager. */
52 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
54 /** @short such module manager is used to classify new opened documents. */
55 css::uno::Reference
< css::frame::XModuleManager2
> m_xModuleManager
;
57 /** @short is needed to locate a might open help frame. */
58 css::uno::Reference
< css::frame::XDesktop2
> m_xDesktop
;
60 /** @short provides read access to the underlying configuration. */
61 css::uno::Reference
< css::container::XNameAccess
> m_xConfig
;
63 /** @short knows the current locale of this office session,
64 which is needed to build complete help URLs.
68 /** @short knows the current operating system of this office session,
69 which is needed to build complete help URLs.
76 /** @short create new instance of this class.
79 reference to the uno service manager, which created this instance.
80 Can be used later to create own needed uno resources on demand.
82 HelpOnStartup(const css::uno::Reference
< css::uno::XComponentContext
>& xContext
);
84 /** @short does nothing real ...
86 @descr But it should exists as virtual function,
87 so this class can't make trouble
88 related to inline/symbols etcpp.!
90 virtual ~HelpOnStartup();
95 // css.lang.XServiceInfo
99 virtual css::uno::Any SAL_CALL
execute(const css::uno::Sequence
< css::beans::NamedValue
>& lArguments
)
100 throw(css::lang::IllegalArgumentException
,
101 css::uno::Exception
,
102 css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
104 // css.lang.XEventListener
105 virtual void SAL_CALL
disposing(const css::lang::EventObject
& aEvent
)
106 throw(css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
111 /** @short analyze the given job arguments, try to locate a model reference
112 and try to classify this model.
114 @descr As a result of this operation a module identifier will be returned.
115 It can be used against the module configuration then to retrieve further information.
118 the list of job arguments which is given on our interface method execute().
121 a module identifier ... or an empty value if no model could be located ...
122 or if it could not be classified successfully.
124 OUString
its_getModuleIdFromEnv(const css::uno::Sequence
< css::beans::NamedValue
>& lArguments
);
126 /** @short tries to locate the open help module and return
127 the url of the currently shown help content.
129 @descr It returns an empty string, if the help isn't still
130 open at calling time.
132 @return The URL of the current shown help content;
133 or an empty value if the help isn't still open.
135 OUString
its_getCurrentHelpURL();
137 /** @short checks if the given help url match to a default help url
138 of any office module.
141 the help url for checking.
144 sal_True if the given URL is any default one ...
147 bool its_isHelpUrlADefaultOne(const OUString
& sHelpURL
);
149 /** @short checks, if the help module should be shown automatically for the
150 currently opened office module.
152 @descr This value is readed from the module configuration.
153 In case the help should be shown, this method returns
154 a help URL, which can be used to show the right help content.
157 identifies the used office module.
160 A valid help URL in case the help content should be shown;
161 an empty value if such automatism was disabled for the specified office module.
163 OUString
its_checkIfHelpEnabledAndGetURL(const OUString
& sModule
);
165 /** @short create a help URL for the given parameters.
168 must be the base URL for a requested help content
169 e.g. "vnd.sun.star.help://swriter/"
170 or "vnd.sun.star.help://swriter/67351"
173 the current office locale
177 the current operating system
180 @return The URL which was generated.
182 e.g. "vnd.sun.star.help://swriter/?Language=en-US&System=WIN"
183 or "vnd.sun.star.help://swriter/67351?Language=en-US&System=WIN"
185 static OUString
ist_createHelpURL(const OUString
& sBaseURL
,
186 const OUString
& sLocale
,
187 const OUString
& sSystem
);
190 } // namespace framework
192 #endif // INCLUDED_FRAMEWORK_INC_JOBS_HELPONSTARTUP_HXX
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */