/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// include own header #include <jobs/helponstartup.hxx> #include <services.h> #include <targets.h>
// ask for office locale
m_sLocale = officecfg::Setup::L10N::ooLocale::get();
// detect system
m_sSystem = officecfg::Office::Common::Help::System::get();
// Start listening for disposing events of these services, // so we can react e.g. for an office shutdown
css::uno::Reference< css::lang::XComponent > xComponent;
xComponent.set(m_xModuleManager, css::uno::UNO_QUERY); if (xComponent.is())
xComponent->addEventListener(static_cast< css::lang::XEventListener* >(this)); if (m_xDesktop.is())
m_xDesktop->addEventListener(static_cast< css::lang::XEventListener* >(this));
xComponent.set(m_xConfig, css::uno::UNO_QUERY); if (xComponent.is())
xComponent->addEventListener(static_cast< css::lang::XEventListener* >(this));
}
HelpOnStartup::~HelpOnStartup()
{
}
// css.task.XJob
css::uno::Any SAL_CALL HelpOnStartup::execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments)
{ // Analyze the given arguments; try to locate a model there and // classify it's used application module.
OUString sModule = its_getModuleIdFromEnv(lArguments);
// Attention: we are bound to events for opening any document inside the office. // That includes e.g. the help module itself. But we have to do nothing then! if (sModule.isEmpty()) return css::uno::Any();
// check current state of the help module // a) help isn't open => show default page for the detected module // b) help shows any other default page(!) => show default page for the detected module // c) help shows any other content => do nothing (user travelled to any other content and leaved the set of default pages)
OUString sCurrentHelpURL = its_getCurrentHelpURL(); bool bCurrentHelpURLIsAnyDefaultURL = its_isHelpUrlADefaultOne(sCurrentHelpURL); bool bShowIt = false;
// a) if (sCurrentHelpURL.isEmpty())
bShowIt = true; // b) elseif (bCurrentHelpURLIsAnyDefaultURL)
bShowIt = true;
if (bShowIt)
{ // retrieve the help URL for the detected application module
OUString sModuleDependentHelpURL = its_checkIfHelpEnabledAndGetURL(sModule); if (!sModuleDependentHelpURL.isEmpty())
{ // Show this help page. // Note: The help window brings itself to front ...
Help* pHelp = Application::GetHelp(); if (pHelp)
pHelp->Start(sModuleDependentHelpURL);
}
}
// check for right environment. // If it's not a DocumentEvent, which triggered this job, // we can't work correctly! => return immediately and do nothing
OUString sEnvType = lEnvironment.getUnpackedValueOrDefault(u"EnvType"_ustr, OUString()); if (sEnvType != "DOCUMENTEVENT") return OUString();
// be sure that we work on top level documents only, which are registered // on the desktop instance. Ignore e.g. life previews, which are top frames too ... // but not registered at this global desktop instance.
css::uno::Reference< css::frame::XDesktop > xDesktopCheck;
css::uno::Reference< css::frame::XFrame > xFrame;
css::uno::Reference< css::frame::XController > xController = xDoc->getCurrentController(); if (xController.is())
xFrame = xController->getFrame(); if (xFrame.is() && xFrame->isTop())
xDesktopCheck.set(xFrame->getCreator(), css::uno::UNO_QUERY); if (!xDesktopCheck.is()) return OUString();
// OK - now we are sure this document is a top level document. // Classify it. // SAFE ->
std::unique_lock aLock(m_mutex);
css::uno::Reference< css::frame::XModuleManager2 > xModuleManager = m_xModuleManager;
aLock.unlock(); // <- SAFE
// check given help url against all default ones const css::uno::Sequence< OUString > lModules = xConfig->getElementNames(); const OUString* pModules = lModules.getConstArray();
::sal_Int32 c = lModules.getLength();
::sal_Int32 i = 0;
for (i=0; i<c; ++i)
{ try
{
css::uno::Reference< css::container::XNameAccess > xModuleConfig;
xConfig->getByName(pModules[i]) >>= xModuleConfig; if (!xModuleConfig.is()) continue;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.