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