/* -*- 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/. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace { class Protector: public CppUnit::Protector, private boost::noncopyable { public: Protector() { // Force locale (and resource files loaded) to en-US: ResMgr::SetDefaultLocale(LanguageTag("en-US")); SvtSysLocaleOptions localOptions; localOptions.SetLocaleConfigString("en-US"); localOptions.SetUILocaleConfigString("en-US"); MsLangId::setConfiguredSystemUILanguage(LANGUAGE_ENGLISH_US); LanguageTag::setConfiguredSystemLanguage(LANGUAGE_ENGLISH_US); InitVCL(); if (test::isHeadless()) { Application::EnableHeadlessMode(true); } Application::setDeInitHook(LINK(this, Protector, deinitHook)); } private: virtual ~Protector() { DeInitVCL(); } virtual bool protect( CppUnit::Functor const & functor, CppUnit::ProtectorContext const &) override { return functor(); } DECL_STATIC_LINK_TYPED(Protector, deinitHook, LinkParamNone*, void); }; // HACK so that defaultBootstrap_InitialComponentContext (in // unobootstrapprotector) is called before InitVCL (above), but component // context is disposed (redundantly again in unobootstrapprotector) from within // DeInitVCL (cf. Desktop::DeInit, desktop/source/app/app.cxx): IMPL_STATIC_LINK_NOARG_TYPED(Protector, deinitHook, LinkParamNone*, void) { css::uno::Reference context; try { context = comphelper::getProcessComponentContext(); } catch (css::uno::RuntimeException &) {} if (context.is()) { css::uno::Reference config; try { config = css::configuration::theDefaultProvider::get(context); } catch (css::uno::DeploymentException &) {} if (config.is()) { utl::ConfigManager::storeConfigItems(); css::uno::Reference( config, css::uno::UNO_QUERY_THROW)->flush(); } css::uno::Reference( context, css::uno::UNO_QUERY_THROW)->dispose(); comphelper::setProcessServiceFactory(0); } } } extern "C" SAL_DLLPUBLIC_EXPORT CppUnit::Protector * SAL_CALL vclbootstrapprotector() { return new Protector; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */