16d739b60SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
36d739b60SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
46d739b60SAndrew Rist * or more contributor license agreements. See the NOTICE file
56d739b60SAndrew Rist * distributed with this work for additional information
66d739b60SAndrew Rist * regarding copyright ownership. The ASF licenses this file
76d739b60SAndrew Rist * to you under the Apache License, Version 2.0 (the
86d739b60SAndrew Rist * "License"); you may not use this file except in compliance
96d739b60SAndrew Rist * with the License. You may obtain a copy of the License at
106d739b60SAndrew Rist *
116d739b60SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
126d739b60SAndrew Rist *
136d739b60SAndrew Rist * Unless required by applicable law or agreed to in writing,
146d739b60SAndrew Rist * software distributed under the License is distributed on an
156d739b60SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
166d739b60SAndrew Rist * KIND, either express or implied. See the License for the
176d739b60SAndrew Rist * specific language governing permissions and limitations
186d739b60SAndrew Rist * under the License.
196d739b60SAndrew Rist *
206d739b60SAndrew Rist *************************************************************/
216d739b60SAndrew Rist
226d739b60SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_framework.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir //_______________________________________________
28cdf0e10cSrcweir // include own header
29cdf0e10cSrcweir #include <jobs/helponstartup.hxx>
30cdf0e10cSrcweir #include <threadhelp/resetableguard.hxx>
31cdf0e10cSrcweir #include <loadenv/targethelper.hxx>
32cdf0e10cSrcweir #include <services.h>
33cdf0e10cSrcweir
34cdf0e10cSrcweir //_______________________________________________
35cdf0e10cSrcweir // include others
36cdf0e10cSrcweir #include <comphelper/configurationhelper.hxx>
37cdf0e10cSrcweir #include <comphelper/sequenceashashmap.hxx>
38cdf0e10cSrcweir #include <unotools/configmgr.hxx>
39cdf0e10cSrcweir #include <vcl/svapp.hxx>
40cdf0e10cSrcweir #include <vcl/help.hxx>
41cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
42cdf0e10cSrcweir
43cdf0e10cSrcweir //_______________________________________________
44cdf0e10cSrcweir // include interfaces
45cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp>
46cdf0e10cSrcweir #include <com/sun/star/frame/XFramesSupplier.hpp>
47cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp>
48cdf0e10cSrcweir
49cdf0e10cSrcweir //_______________________________________________
50cdf0e10cSrcweir // namespace
51cdf0e10cSrcweir
52cdf0e10cSrcweir namespace framework{
53cdf0e10cSrcweir
54cdf0e10cSrcweir //_______________________________________________
55cdf0e10cSrcweir // definitions
56cdf0e10cSrcweir
57cdf0e10cSrcweir // path to module config
58cdf0e10cSrcweir static ::rtl::OUString CFG_PACKAGE_MODULES = ::rtl::OUString::createFromAscii("/org.openoffice.Setup/Office/Factories");
59cdf0e10cSrcweir static ::rtl::OUString CFG_PACKAGE_SETUP = ::rtl::OUString::createFromAscii("/org.openoffice.Setup" );
60cdf0e10cSrcweir static ::rtl::OUString CFG_PACKAGE_COMMON = ::rtl::OUString::createFromAscii("/org.openoffice.Office.Common" );
61cdf0e10cSrcweir static ::rtl::OUString CFG_PATH_L10N = ::rtl::OUString::createFromAscii("L10N" );
62cdf0e10cSrcweir static ::rtl::OUString CFG_PATH_HELP = ::rtl::OUString::createFromAscii("Help" );
63cdf0e10cSrcweir static ::rtl::OUString CFG_KEY_LOCALE = ::rtl::OUString::createFromAscii("ooLocale" );
64cdf0e10cSrcweir static ::rtl::OUString CFG_KEY_HELPSYSTEM = ::rtl::OUString::createFromAscii("System" );
65cdf0e10cSrcweir
66cdf0e10cSrcweir // props of job environment
67cdf0e10cSrcweir static ::rtl::OUString PROP_ENVIRONMENT = ::rtl::OUString::createFromAscii("Environment" );
68cdf0e10cSrcweir static ::rtl::OUString PROP_JOBCONFIG = ::rtl::OUString::createFromAscii("JobConfig" );
69cdf0e10cSrcweir static ::rtl::OUString PROP_ENVTYPE = ::rtl::OUString::createFromAscii("EnvType" );
70cdf0e10cSrcweir static ::rtl::OUString PROP_MODEL = ::rtl::OUString::createFromAscii("Model" );
71cdf0e10cSrcweir
72cdf0e10cSrcweir // props of module config
73cdf0e10cSrcweir static ::rtl::OUString PROP_HELP_BASEURL = ::rtl::OUString::createFromAscii("ooSetupFactoryHelpBaseURL" );
74cdf0e10cSrcweir static ::rtl::OUString PROP_AUTOMATIC_HELP = ::rtl::OUString::createFromAscii("ooSetupFactoryHelpOnOpen" );
75cdf0e10cSrcweir
76cdf0e10cSrcweir // special value of job environment
77cdf0e10cSrcweir static ::rtl::OUString ENVTYPE_DOCUMENTEVENT = ::rtl::OUString::createFromAscii("DOCUMENTEVENT" );
78cdf0e10cSrcweir
79cdf0e10cSrcweir //-----------------------------------------------
80cdf0e10cSrcweir
DEFINE_XSERVICEINFO_MULTISERVICE(HelpOnStartup,::cppu::OWeakObject,SERVICENAME_JOB,IMPLEMENTATIONNAME_HELPONSTARTUP)81cdf0e10cSrcweir DEFINE_XSERVICEINFO_MULTISERVICE(HelpOnStartup ,
82cdf0e10cSrcweir ::cppu::OWeakObject ,
83cdf0e10cSrcweir SERVICENAME_JOB ,
84cdf0e10cSrcweir IMPLEMENTATIONNAME_HELPONSTARTUP)
85cdf0e10cSrcweir
86cdf0e10cSrcweir DEFINE_INIT_SERVICE(HelpOnStartup,
87cdf0e10cSrcweir {
88cdf0e10cSrcweir /* Attention
89cdf0e10cSrcweir I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance()
90cdf0e10cSrcweir to create a new instance of this class by our own supported service factory.
91cdf0e10cSrcweir see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations!
92cdf0e10cSrcweir */
93cdf0e10cSrcweir // create some needed uno services and cache it
94cdf0e10cSrcweir m_xModuleManager = css::uno::Reference< css::frame::XModuleManager >(
95cdf0e10cSrcweir m_xSMGR->createInstance(SERVICENAME_MODULEMANAGER),
96cdf0e10cSrcweir css::uno::UNO_QUERY_THROW);
97cdf0e10cSrcweir
98cdf0e10cSrcweir m_xDesktop = css::uno::Reference< css::frame::XFrame >(
99cdf0e10cSrcweir m_xSMGR->createInstance(SERVICENAME_DESKTOP),
100cdf0e10cSrcweir css::uno::UNO_QUERY_THROW);
101cdf0e10cSrcweir
102cdf0e10cSrcweir m_xConfig = css::uno::Reference< css::container::XNameAccess >(
103cdf0e10cSrcweir ::comphelper::ConfigurationHelper::openConfig(
104cdf0e10cSrcweir m_xSMGR,
105cdf0e10cSrcweir CFG_PACKAGE_MODULES,
106cdf0e10cSrcweir ::comphelper::ConfigurationHelper::E_READONLY),
107cdf0e10cSrcweir css::uno::UNO_QUERY_THROW);
108cdf0e10cSrcweir
109cdf0e10cSrcweir // ask for office locale
110cdf0e10cSrcweir ::comphelper::ConfigurationHelper::readDirectKey(
111cdf0e10cSrcweir m_xSMGR,
112cdf0e10cSrcweir CFG_PACKAGE_SETUP,
113cdf0e10cSrcweir CFG_PATH_L10N,
114cdf0e10cSrcweir CFG_KEY_LOCALE,
115cdf0e10cSrcweir ::comphelper::ConfigurationHelper::E_READONLY) >>= m_sLocale;
116cdf0e10cSrcweir
117cdf0e10cSrcweir // detect system
118cdf0e10cSrcweir ::comphelper::ConfigurationHelper::readDirectKey(
119cdf0e10cSrcweir m_xSMGR,
120cdf0e10cSrcweir CFG_PACKAGE_COMMON,
121cdf0e10cSrcweir CFG_PATH_HELP,
122cdf0e10cSrcweir CFG_KEY_HELPSYSTEM,
123cdf0e10cSrcweir ::comphelper::ConfigurationHelper::E_READONLY) >>= m_sSystem;
124cdf0e10cSrcweir
125cdf0e10cSrcweir // Start listening for disposing events of these services,
126cdf0e10cSrcweir // so we can react e.g. for an office shutdown
127cdf0e10cSrcweir css::uno::Reference< css::lang::XComponent > xComponent;
128cdf0e10cSrcweir xComponent = css::uno::Reference< css::lang::XComponent >(m_xModuleManager, css::uno::UNO_QUERY);
129cdf0e10cSrcweir if (xComponent.is())
130cdf0e10cSrcweir xComponent->addEventListener(static_cast< css::lang::XEventListener* >(this));
131cdf0e10cSrcweir xComponent = css::uno::Reference< css::lang::XComponent >(m_xDesktop, css::uno::UNO_QUERY);
132cdf0e10cSrcweir if (xComponent.is())
133cdf0e10cSrcweir xComponent->addEventListener(static_cast< css::lang::XEventListener* >(this));
134cdf0e10cSrcweir xComponent = css::uno::Reference< css::lang::XComponent >(m_xConfig, css::uno::UNO_QUERY);
135cdf0e10cSrcweir if (xComponent.is())
136cdf0e10cSrcweir xComponent->addEventListener(static_cast< css::lang::XEventListener* >(this));
137cdf0e10cSrcweir }
138cdf0e10cSrcweir )
139cdf0e10cSrcweir
140cdf0e10cSrcweir //-----------------------------------------------
141cdf0e10cSrcweir HelpOnStartup::HelpOnStartup(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
142cdf0e10cSrcweir : ThreadHelpBase( )
143cdf0e10cSrcweir , m_xSMGR (xSMGR)
144cdf0e10cSrcweir {
145cdf0e10cSrcweir }
146cdf0e10cSrcweir
147cdf0e10cSrcweir //-----------------------------------------------
~HelpOnStartup()148cdf0e10cSrcweir HelpOnStartup::~HelpOnStartup()
149cdf0e10cSrcweir {
150cdf0e10cSrcweir }
151cdf0e10cSrcweir
152cdf0e10cSrcweir //-----------------------------------------------
153cdf0e10cSrcweir // css.task.XJob
execute(const css::uno::Sequence<css::beans::NamedValue> & lArguments)154cdf0e10cSrcweir css::uno::Any SAL_CALL HelpOnStartup::execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments)
155cdf0e10cSrcweir throw(css::lang::IllegalArgumentException,
156cdf0e10cSrcweir css::uno::Exception ,
157cdf0e10cSrcweir css::uno::RuntimeException )
158cdf0e10cSrcweir {
159cdf0e10cSrcweir // Analyze the given arguments; try to locate a model there and
160cdf0e10cSrcweir // classify it's used application module.
161cdf0e10cSrcweir ::rtl::OUString sModule = its_getModuleIdFromEnv(lArguments);
162cdf0e10cSrcweir
163cdf0e10cSrcweir // Attention: We are bound to events for openeing any document inside the office.
164cdf0e10cSrcweir // That includes e.g. the help module itself. But we have to do nothing then!
165cdf0e10cSrcweir if (!sModule.getLength())
166cdf0e10cSrcweir return css::uno::Any();
167cdf0e10cSrcweir
168cdf0e10cSrcweir // check current state of the help module
169*07a3d7f1SPedro Giffuni // a) help isn't open => show default page for the detected module
170cdf0e10cSrcweir // b) help shows any other default page(!) => show default page for the detected module
171cdf0e10cSrcweir // c) help shows any other content => do nothing (user travelled to any other content and leaved the set of default pages)
172cdf0e10cSrcweir ::rtl::OUString sCurrentHelpURL = its_getCurrentHelpURL();
173cdf0e10cSrcweir sal_Bool bCurrentHelpURLIsAnyDefaultURL = its_isHelpUrlADefaultOne(sCurrentHelpURL);
174cdf0e10cSrcweir sal_Bool bShowIt = sal_False;
175cdf0e10cSrcweir
176cdf0e10cSrcweir // a)
177cdf0e10cSrcweir if (!sCurrentHelpURL.getLength())
178cdf0e10cSrcweir bShowIt = sal_True;
179cdf0e10cSrcweir else
180cdf0e10cSrcweir // b)
181cdf0e10cSrcweir if (bCurrentHelpURLIsAnyDefaultURL)
182cdf0e10cSrcweir bShowIt = sal_True;
183cdf0e10cSrcweir
184cdf0e10cSrcweir if (bShowIt)
185cdf0e10cSrcweir {
186cdf0e10cSrcweir // retrieve the help URL for the detected application module
187cdf0e10cSrcweir ::rtl::OUString sModuleDependendHelpURL = its_checkIfHelpEnabledAndGetURL(sModule);
188cdf0e10cSrcweir if (sModuleDependendHelpURL.getLength())
189cdf0e10cSrcweir {
190cdf0e10cSrcweir // Show this help page.
191cdf0e10cSrcweir // Note: The help window brings itself to front ...
192cdf0e10cSrcweir Help* pHelp = Application::GetHelp();
193cdf0e10cSrcweir if (pHelp)
194cdf0e10cSrcweir pHelp->Start(sModuleDependendHelpURL, 0);
195cdf0e10cSrcweir }
196cdf0e10cSrcweir }
197cdf0e10cSrcweir
198cdf0e10cSrcweir return css::uno::Any();
199cdf0e10cSrcweir }
200cdf0e10cSrcweir
201cdf0e10cSrcweir //-----------------------------------------------
disposing(const css::lang::EventObject & aEvent)202cdf0e10cSrcweir void SAL_CALL HelpOnStartup::disposing(const css::lang::EventObject& aEvent)
203cdf0e10cSrcweir throw(css::uno::RuntimeException)
204cdf0e10cSrcweir {
205cdf0e10cSrcweir // SAFE ->
206cdf0e10cSrcweir ResetableGuard aLock(m_aLock);
207cdf0e10cSrcweir
208cdf0e10cSrcweir if (aEvent.Source == m_xModuleManager)
209cdf0e10cSrcweir m_xModuleManager.clear();
210cdf0e10cSrcweir else
211cdf0e10cSrcweir if (aEvent.Source == m_xDesktop)
212cdf0e10cSrcweir m_xDesktop.clear();
213cdf0e10cSrcweir else
214cdf0e10cSrcweir if (aEvent.Source == m_xConfig)
215cdf0e10cSrcweir m_xConfig.clear();
216cdf0e10cSrcweir
217cdf0e10cSrcweir aLock.unlock();
218cdf0e10cSrcweir // <- SAFE
219cdf0e10cSrcweir }
220cdf0e10cSrcweir
221cdf0e10cSrcweir //-----------------------------------------------
its_getModuleIdFromEnv(const css::uno::Sequence<css::beans::NamedValue> & lArguments)222cdf0e10cSrcweir ::rtl::OUString HelpOnStartup::its_getModuleIdFromEnv(const css::uno::Sequence< css::beans::NamedValue >& lArguments)
223cdf0e10cSrcweir {
224cdf0e10cSrcweir ::comphelper::SequenceAsHashMap lArgs (lArguments);
225cdf0e10cSrcweir ::comphelper::SequenceAsHashMap lEnvironment = lArgs.getUnpackedValueOrDefault(PROP_ENVIRONMENT, css::uno::Sequence< css::beans::NamedValue >());
226cdf0e10cSrcweir ::comphelper::SequenceAsHashMap lJobConfig = lArgs.getUnpackedValueOrDefault(PROP_JOBCONFIG , css::uno::Sequence< css::beans::NamedValue >());
227cdf0e10cSrcweir
228cdf0e10cSrcweir // check for right environment.
229cdf0e10cSrcweir // If its not a DocumentEvent, which triggered this job,
230*07a3d7f1SPedro Giffuni // we can't work correctly! => return immediately and do nothing
231cdf0e10cSrcweir ::rtl::OUString sEnvType = lEnvironment.getUnpackedValueOrDefault(PROP_ENVTYPE, ::rtl::OUString());
232cdf0e10cSrcweir if (!sEnvType.equals(ENVTYPE_DOCUMENTEVENT))
233cdf0e10cSrcweir return ::rtl::OUString();
234cdf0e10cSrcweir
235cdf0e10cSrcweir css::uno::Reference< css::frame::XModel > xDoc = lEnvironment.getUnpackedValueOrDefault(PROP_MODEL, css::uno::Reference< css::frame::XModel >());
236cdf0e10cSrcweir if (!xDoc.is())
237cdf0e10cSrcweir return ::rtl::OUString();
238cdf0e10cSrcweir
239cdf0e10cSrcweir // be sure that we work on top level documents only, which are registered
240cdf0e10cSrcweir // on the desktop instance. Ignore e.g. life previews, which are top frames too ...
241cdf0e10cSrcweir // but not registered at this global desktop instance.
242cdf0e10cSrcweir css::uno::Reference< css::frame::XDesktop > xDesktopCheck;
243cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > xFrame ;
244cdf0e10cSrcweir css::uno::Reference< css::frame::XController > xController = xDoc->getCurrentController();
245cdf0e10cSrcweir if (xController.is())
246cdf0e10cSrcweir xFrame = xController->getFrame();
247cdf0e10cSrcweir if (xFrame.is() && xFrame->isTop())
248cdf0e10cSrcweir xDesktopCheck = css::uno::Reference< css::frame::XDesktop >(xFrame->getCreator(), css::uno::UNO_QUERY);
249cdf0e10cSrcweir if (!xDesktopCheck.is())
250cdf0e10cSrcweir return ::rtl::OUString();
251cdf0e10cSrcweir
252cdf0e10cSrcweir // OK - now we are sure this document is a top level document.
253cdf0e10cSrcweir // Classify it.
254cdf0e10cSrcweir // SAFE ->
255cdf0e10cSrcweir ResetableGuard aLock(m_aLock);
256cdf0e10cSrcweir css::uno::Reference< css::frame::XModuleManager > xModuleManager = m_xModuleManager;
257cdf0e10cSrcweir aLock.unlock();
258cdf0e10cSrcweir // <- SAFE
259cdf0e10cSrcweir
260cdf0e10cSrcweir if (!xModuleManager.is())
261cdf0e10cSrcweir return ::rtl::OUString();
262cdf0e10cSrcweir
263cdf0e10cSrcweir ::rtl::OUString sModuleId;
264cdf0e10cSrcweir try
265cdf0e10cSrcweir {
266cdf0e10cSrcweir sModuleId = xModuleManager->identify(xDoc);
267cdf0e10cSrcweir }
268cdf0e10cSrcweir catch(const css::uno::RuntimeException& exRun)
269cdf0e10cSrcweir { throw exRun; }
270cdf0e10cSrcweir catch(const css::uno::Exception&)
271cdf0e10cSrcweir { sModuleId = ::rtl::OUString(); }
272cdf0e10cSrcweir
273cdf0e10cSrcweir return sModuleId;
274cdf0e10cSrcweir }
275cdf0e10cSrcweir
276cdf0e10cSrcweir //-----------------------------------------------
its_getCurrentHelpURL()277cdf0e10cSrcweir ::rtl::OUString HelpOnStartup::its_getCurrentHelpURL()
278cdf0e10cSrcweir {
279cdf0e10cSrcweir // SAFE ->
280cdf0e10cSrcweir ResetableGuard aLock(m_aLock);
281cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > xDesktop = m_xDesktop;
282cdf0e10cSrcweir aLock.unlock();
283cdf0e10cSrcweir // <- SAFE
284cdf0e10cSrcweir
285cdf0e10cSrcweir if (!xDesktop.is())
286cdf0e10cSrcweir return ::rtl::OUString();
287cdf0e10cSrcweir
288cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > xHelp = xDesktop->findFrame(SPECIALTARGET_HELPTASK, css::frame::FrameSearchFlag::CHILDREN);
289cdf0e10cSrcweir if (!xHelp.is())
290cdf0e10cSrcweir return ::rtl::OUString();
291cdf0e10cSrcweir
292cdf0e10cSrcweir ::rtl::OUString sCurrentHelpURL;
293cdf0e10cSrcweir try
294cdf0e10cSrcweir {
295cdf0e10cSrcweir css::uno::Reference< css::frame::XFramesSupplier > xHelpRoot (xHelp , css::uno::UNO_QUERY_THROW);
296cdf0e10cSrcweir css::uno::Reference< css::container::XIndexAccess > xHelpChilds(xHelpRoot->getFrames(), css::uno::UNO_QUERY_THROW);
297cdf0e10cSrcweir
298cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > xHelpChild ;
299cdf0e10cSrcweir css::uno::Reference< css::frame::XController > xHelpView ;
300cdf0e10cSrcweir css::uno::Reference< css::frame::XModel > xHelpContent;
301cdf0e10cSrcweir
302cdf0e10cSrcweir xHelpChilds->getByIndex(0) >>= xHelpChild;
303cdf0e10cSrcweir if (xHelpChild.is())
304cdf0e10cSrcweir xHelpView = xHelpChild->getController();
305cdf0e10cSrcweir if (xHelpView.is())
306cdf0e10cSrcweir xHelpContent = xHelpView->getModel();
307cdf0e10cSrcweir if (xHelpContent.is())
308cdf0e10cSrcweir sCurrentHelpURL = xHelpContent->getURL();
309cdf0e10cSrcweir }
310cdf0e10cSrcweir catch(css::uno::RuntimeException& exRun)
311cdf0e10cSrcweir { throw exRun; }
312cdf0e10cSrcweir catch(css::uno::Exception&)
313cdf0e10cSrcweir { sCurrentHelpURL = ::rtl::OUString(); }
314cdf0e10cSrcweir
315cdf0e10cSrcweir return sCurrentHelpURL;
316cdf0e10cSrcweir }
317cdf0e10cSrcweir
318cdf0e10cSrcweir //-----------------------------------------------
its_isHelpUrlADefaultOne(const::rtl::OUString & sHelpURL)319cdf0e10cSrcweir ::sal_Bool HelpOnStartup::its_isHelpUrlADefaultOne(const ::rtl::OUString& sHelpURL)
320cdf0e10cSrcweir {
321cdf0e10cSrcweir if (!sHelpURL.getLength())
322cdf0e10cSrcweir return sal_False;
323cdf0e10cSrcweir
324cdf0e10cSrcweir // SAFE ->
325cdf0e10cSrcweir ResetableGuard aLock(m_aLock);
326cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR (m_xSMGR, css::uno::UNO_QUERY_THROW);
327cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > xConfig = m_xConfig;
328cdf0e10cSrcweir ::rtl::OUString sLocale = m_sLocale;
329cdf0e10cSrcweir ::rtl::OUString sSystem = m_sSystem;
330cdf0e10cSrcweir aLock.unlock();
331cdf0e10cSrcweir // <- SAFE
332cdf0e10cSrcweir
333cdf0e10cSrcweir if (!xConfig.is())
334cdf0e10cSrcweir return sal_False;
335cdf0e10cSrcweir
336cdf0e10cSrcweir // check given help url against all default ones
337cdf0e10cSrcweir const css::uno::Sequence< ::rtl::OUString > lModules = xConfig->getElementNames();
338cdf0e10cSrcweir const ::rtl::OUString* pModules = lModules.getConstArray();
339cdf0e10cSrcweir ::sal_Int32 c = lModules.getLength();
340cdf0e10cSrcweir ::sal_Int32 i = 0;
341cdf0e10cSrcweir
342cdf0e10cSrcweir for (i=0; i<c; ++i)
343cdf0e10cSrcweir {
344cdf0e10cSrcweir try
345cdf0e10cSrcweir {
346cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > xModuleConfig;
347cdf0e10cSrcweir xConfig->getByName(pModules[i]) >>= xModuleConfig;
348cdf0e10cSrcweir if (!xModuleConfig.is())
349cdf0e10cSrcweir continue;
350cdf0e10cSrcweir
351cdf0e10cSrcweir ::rtl::OUString sHelpBaseURL;
352cdf0e10cSrcweir xModuleConfig->getByName(PROP_HELP_BASEURL) >>= sHelpBaseURL;
353cdf0e10cSrcweir ::rtl::OUString sHelpURLForModule = HelpOnStartup::ist_createHelpURL(sHelpBaseURL, sLocale, sSystem);
354cdf0e10cSrcweir if (sHelpURL.equals(sHelpURLForModule))
355cdf0e10cSrcweir return sal_True;
356cdf0e10cSrcweir }
357cdf0e10cSrcweir catch(const css::uno::RuntimeException& exRun)
358cdf0e10cSrcweir { throw exRun; }
359cdf0e10cSrcweir catch(const css::uno::Exception&)
360cdf0e10cSrcweir {}
361cdf0e10cSrcweir }
362cdf0e10cSrcweir
363cdf0e10cSrcweir return sal_False;
364cdf0e10cSrcweir }
365cdf0e10cSrcweir
366cdf0e10cSrcweir //-----------------------------------------------
its_checkIfHelpEnabledAndGetURL(const::rtl::OUString & sModule)367cdf0e10cSrcweir ::rtl::OUString HelpOnStartup::its_checkIfHelpEnabledAndGetURL(const ::rtl::OUString& sModule)
368cdf0e10cSrcweir {
369cdf0e10cSrcweir // SAFE ->
370cdf0e10cSrcweir ResetableGuard aLock(m_aLock);
371cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > xConfig = m_xConfig;
372cdf0e10cSrcweir ::rtl::OUString sLocale = m_sLocale;
373cdf0e10cSrcweir ::rtl::OUString sSystem = m_sSystem;
374cdf0e10cSrcweir aLock.unlock();
375cdf0e10cSrcweir // <- SAFE
376cdf0e10cSrcweir
377cdf0e10cSrcweir ::rtl::OUString sHelpURL;
378cdf0e10cSrcweir
379cdf0e10cSrcweir try
380cdf0e10cSrcweir {
381cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > xModuleConfig;
382cdf0e10cSrcweir if (xConfig.is())
383cdf0e10cSrcweir xConfig->getByName(sModule) >>= xModuleConfig;
384cdf0e10cSrcweir
385cdf0e10cSrcweir sal_Bool bHelpEnabled = sal_False;
386cdf0e10cSrcweir if (xModuleConfig.is())
387cdf0e10cSrcweir xModuleConfig->getByName(PROP_AUTOMATIC_HELP) >>= bHelpEnabled;
388cdf0e10cSrcweir
389cdf0e10cSrcweir if (bHelpEnabled)
390cdf0e10cSrcweir {
391cdf0e10cSrcweir ::rtl::OUString sHelpBaseURL;
392cdf0e10cSrcweir xModuleConfig->getByName(PROP_HELP_BASEURL) >>= sHelpBaseURL;
393cdf0e10cSrcweir sHelpURL = HelpOnStartup::ist_createHelpURL(sHelpBaseURL, sLocale, sSystem);
394cdf0e10cSrcweir }
395cdf0e10cSrcweir }
396cdf0e10cSrcweir catch(const css::uno::RuntimeException& exRun)
397cdf0e10cSrcweir { throw exRun; }
398cdf0e10cSrcweir catch(const css::uno::Exception&)
399cdf0e10cSrcweir { sHelpURL = ::rtl::OUString(); }
400cdf0e10cSrcweir
401cdf0e10cSrcweir return sHelpURL;
402cdf0e10cSrcweir }
403cdf0e10cSrcweir
404cdf0e10cSrcweir //-----------------------------------------------
ist_createHelpURL(const::rtl::OUString & sBaseURL,const::rtl::OUString & sLocale,const::rtl::OUString & sSystem)405cdf0e10cSrcweir ::rtl::OUString HelpOnStartup::ist_createHelpURL(const ::rtl::OUString& sBaseURL,
406cdf0e10cSrcweir const ::rtl::OUString& sLocale ,
407cdf0e10cSrcweir const ::rtl::OUString& sSystem )
408cdf0e10cSrcweir {
409cdf0e10cSrcweir ::rtl::OUStringBuffer sHelpURL(256);
410cdf0e10cSrcweir sHelpURL.append (sBaseURL );
411cdf0e10cSrcweir sHelpURL.appendAscii("?Language=");
412cdf0e10cSrcweir sHelpURL.append (sLocale );
413cdf0e10cSrcweir sHelpURL.appendAscii("&System=" );
414cdf0e10cSrcweir sHelpURL.append (sSystem );
415cdf0e10cSrcweir
416cdf0e10cSrcweir return sHelpURL.makeStringAndClear();
417cdf0e10cSrcweir }
418cdf0e10cSrcweir
419cdf0e10cSrcweir } // namespace framework
420