1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
9 #include <headless/svpinst.hxx>
10 #include <headless/svpdummies.hxx>
11 #include <unx/gendata.hxx>
13 class HeadlessSalInstance
: public SvpSalInstance
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
{
28 HeadlessSalSystem() : SvpSalSystem() {}
29 virtual int ShowNativeDialog( const OUString
& rTitle
,
30 const OUString
& rMessage
,
31 const std::vector
< OUString
>& rButtons
) override
34 SAL_INFO("vcl.headless",
35 "LibreOffice - dialog '"
42 SalSystem
*HeadlessSalInstance::CreateSalSystem()
44 return new HeadlessSalSystem();
47 class HeadlessSalData
: public GenericUnixSalData
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
<< "'.");
70 const OUString
& SalGetDesktopEnvironment()
72 static OUString
aEnv( "headless" );
77 m_pInstance( nullptr ),
78 m_pPIManager( nullptr )
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();
95 void DestroySalInstance( SalInstance
*pInst
)
97 pInst
->ReleaseYieldMutexAll();
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */