xref: /trunk/main/framework/inc/jobs/helponstartup.hxx (revision 45c5a00162811bd03b87fcb4fe9996782f2b59ec)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef __FRAMEWORK_JOBS_HELPONSTARTUP_HXX_
25 #define __FRAMEWORK_JOBS_HELPONSTARTUP_HXX_
26 
27 //_______________________________________________
28 // my own includes
29 
30 #include <threadhelp/threadhelpbase.hxx>
31 #include <macros/xinterface.hxx>
32 #include <macros/xtypeprovider.hxx>
33 #include <macros/xserviceinfo.hxx>
34 
35 //_______________________________________________
36 // other includes
37 #include <cppuhelper/implbase3.hxx>
38 
39 //_______________________________________________
40 // uno includes
41 #include <com/sun/star/frame/XFrame.hpp>
42 #include <com/sun/star/task/XJob.hpp>
43 #include <com/sun/star/lang/XEventListener.hpp>
44 #include <com/sun/star/container/XNameAccess.hpp>
45 #include <com/sun/star/frame/XModuleManager.hpp>
46 
47 //_______________________________________________
48 // namespace
49 
50 namespace framework{
51 
52 //_______________________________________________
53 // declarations
54 
55 //_______________________________________________
56 /** @short  implements a job component, which handle the special
57             feature to show a suitable help page for every (visible!)
58             loaded document.
59 
60     @author as96863
61  */
62 class HelpOnStartup : private ThreadHelpBase
63                       ,public ::cppu::WeakImplHelper3< ::com::sun::star::lang::XServiceInfo,::com::sun::star::lang::XEventListener,::com::sun::star::task::XJob >
64 {
65     //-------------------------------------------
66     // member
67     private:
68 
69         //.......................................
70         /** @short  reference to an uno service manager. */
71         css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
72 
73         //.......................................
74         /** @short  such module manager is used to classify new opened documents. */
75         css::uno::Reference< css::frame::XModuleManager > m_xModuleManager;
76 
77         //.......................................
78         /** @short  is needed to locate a might open help frame. */
79         css::uno::Reference< css::frame::XFrame > m_xDesktop;
80 
81         //.......................................
82         /** @short  provides read access to the underlying configuration. */
83         css::uno::Reference< css::container::XNameAccess > m_xConfig;
84 
85         //.......................................
86         /** @short  knows the current locale of this office session,
87                     which is needed to build complete help URLs.
88          */
89         ::rtl::OUString m_sLocale;
90 
91         //.......................................
92         /** @short  knows the current operating system of this office session,
93                     which is needed to build complete help URLs.
94          */
95         ::rtl::OUString m_sSystem;
96 
97     //-------------------------------------------
98     // native interface
99     public:
100 
101         //---------------------------------------
102         /** @short  create new instance of this class.
103 
104             @param  xSMGR
105                     reference to the uno service manager, which created this instance.
106                     Can be used later to create own needed uno resources on demand.
107          */
108         HelpOnStartup(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
109 
110         //---------------------------------------
111         /** @short  does nothing real ...
112 
113             @descr  But it should exists as virtual function,
114                     so this class can't make trouble
115                     related to inline/symbols etcpp.!
116          */
117         virtual ~HelpOnStartup();
118 
119     //-------------------------------------------
120     // uno interface
121     public:
122 
123         //---------------------------------------
124         // css.lang.XServiceInfo
125         DECLARE_XSERVICEINFO
126 
127         // css.task.XJob
128         virtual css::uno::Any SAL_CALL execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments);
129 
130         // css.lang.XEventListener
131         virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent);
132 
133     //-------------------------------------------
134     // helper
135     private:
136 
137         //---------------------------------------
138         /** @short  analyze the given job arguments, try to locate a model reference
139                     and try to classify this model.
140 
141             @descr  As a result of this operation a module identifier will be returned.
142                     It can be used against the module configuration then to retrieve further informations.
143 
144             @param  lArguments
145                     the list of job arguments which is given on our interface method execute().
146 
147             @return [string]
148                     a module identifier ... or an empty value if no model could be located ...
149                     or if it could not be classified successfully.
150          */
151         ::rtl::OUString its_getModuleIdFromEnv(const css::uno::Sequence< css::beans::NamedValue >& lArguments);
152 
153         //---------------------------------------
154         /** @short  tries to locate the open help module and return
155                     the url of the currently shown help content.
156 
157             @descr  It returns an empty string, if the help isn't still
158                     open at calling time.
159 
160             @return The URL of the current shown help content;
161                     or an empty value if the help isn't still open.
162          */
163         ::rtl::OUString its_getCurrentHelpURL();
164 
165         //---------------------------------------
166         /** @short  checks if the given help url match to a default help url
167                     of any office module.
168 
169             @param  sHelpURL
170                     the help url for checking.
171 
172             @return [bool]
173                     sal_True if the given URL is any default one ...
174                     sal_False otherwise.
175          */
176         ::sal_Bool its_isHelpUrlADefaultOne(const ::rtl::OUString& sHelpURL);
177 
178         //---------------------------------------
179         /** @short  checks, if the help module should be shown automatically for the
180                     currently opened office module.
181 
182             @descr  This value is readed from the module configuration.
183                     In case the help should be shown, this method returns
184                     a help URL, which can be used to show the right help content.
185 
186             @param  sModule
187                     identifies the used office module.
188 
189             @return [string]
190                     A valid help URL in case the help content should be shown;
191                     an empty value if such automatism was disabled for the specified office module.
192          */
193         ::rtl::OUString its_checkIfHelpEnabledAndGetURL(const ::rtl::OUString& sModule);
194 
195         //---------------------------------------
196         /** @short  create a help URL for the given parameters.
197 
198             @param  sBaseURL
199                     must be the base URL for a requested help content
200                     e.g. "vnd.sun.star.help://swriter/"
201                     or   "vnd.sun.star.help://swriter/67351"
202 
203             @param  sLocale
204                     the current office locale
205                     e.g. "en-US"
206 
207             @param  sSystem
208                     the current operating system
209                     e.g. "WIN"
210 
211             @return The URL which was generated.
212                     e.g.
213                     e.g. "vnd.sun.star.help://swriter/?Language=en-US&System=WIN"
214                     or   "vnd.sun.star.help://swriter/67351?Language=en-US&System=WIN"
215          */
216         static ::rtl::OUString ist_createHelpURL(const ::rtl::OUString& sBaseURL,
217                                                  const ::rtl::OUString& sLocale ,
218                                                  const ::rtl::OUString& sSystem );
219 };
220 
221 } // namespace framework
222 
223 #endif // __FRAMEWORK_JOBS_HELPONSTARTUP_HXX_
224