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