nss: upgrade to release 3.73
[LibreOffice.git] / vcl / headless / headlessinst.cxx
blobe1694c429d2bd4abd4011cf3d33e8787c56966d0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9 #include <headless/svpinst.hxx>
10 #include <headless/svpdummies.hxx>
11 #include <unx/gendata.hxx>
13 class HeadlessSalInstance : public SvpSalInstance
15 public:
16 explicit HeadlessSalInstance(std::unique_ptr<SalYieldMutex> pMutex);
18 virtual SalSystem* CreateSalSystem() override;
21 HeadlessSalInstance::HeadlessSalInstance(std::unique_ptr<SalYieldMutex> pMutex)
22 : SvpSalInstance(std::move(pMutex))
26 class HeadlessSalSystem : public SvpSalSystem {
27 public:
28 HeadlessSalSystem() : SvpSalSystem() {}
29 virtual int ShowNativeDialog( const OUString& rTitle,
30 const OUString& rMessage,
31 const std::vector< OUString >& rButtons ) override
33 (void)rButtons;
34 SAL_INFO("vcl.headless",
35 "LibreOffice - dialog '"
36 << rTitle << "': '"
37 << rMessage << "'");
38 return 0;
42 SalSystem *HeadlessSalInstance::CreateSalSystem()
44 return new HeadlessSalSystem();
47 class HeadlessSalData : public GenericUnixSalData
49 public:
50 explicit HeadlessSalData( SalInstance *pInstance ) : GenericUnixSalData( SAL_DATA_HEADLESS, pInstance ) {}
51 virtual void ErrorTrapPush() override {}
52 virtual bool ErrorTrapPop( bool ) override { return false; }
55 void SalAbort( const OUString& rErrorText, bool bDumpCore )
57 OUString aError( rErrorText );
58 if( aError.isEmpty() )
59 aError = "Unknown application error";
61 SAL_WARN("vcl.headless", rErrorText);
62 SAL_INFO("vcl.headless", "SalAbort: '" << aError << "'.");
64 if( bDumpCore )
65 abort();
66 else
67 _exit(1);
70 const OUString& SalGetDesktopEnvironment()
72 static OUString aEnv( "headless" );
73 return aEnv;
76 SalData::SalData() :
77 m_pInstance( nullptr ),
78 m_pPIManager( nullptr )
82 SalData::~SalData()
86 // This is our main entry point:
87 SalInstance *CreateSalInstance()
89 HeadlessSalInstance* pInstance = new HeadlessSalInstance(std::make_unique<SvpSalYieldMutex>());
90 new HeadlessSalData( pInstance );
91 pInstance->AcquireYieldMutex();
92 return pInstance;
95 void DestroySalInstance( SalInstance *pInst )
97 pInst->ReleaseYieldMutexAll();
98 delete pInst;
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */