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( SalYieldMutex
*pMutex
);
18 virtual SalSystem
* CreateSalSystem() override
;
21 HeadlessSalInstance::HeadlessSalInstance( SalYieldMutex
*pMutex
) :
22 SvpSalInstance( 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 ::fprintf(stdout
, "LibreOffice - dialog '%s': '%s'",
35 OUStringToOString(rTitle
, RTL_TEXTENCODING_ASCII_US
).getStr(),
36 OUStringToOString(rMessage
, RTL_TEXTENCODING_ASCII_US
).getStr());
41 SalSystem
*HeadlessSalInstance::CreateSalSystem()
43 return new HeadlessSalSystem();
46 class HeadlessSalData
: public GenericUnixSalData
49 explicit HeadlessSalData( SalInstance
*pInstance
) : GenericUnixSalData( SAL_DATA_HEADLESS
, pInstance
) {}
50 virtual void ErrorTrapPush() override
{}
51 virtual bool ErrorTrapPop( bool ) override
{ return false; }
54 // All the interesting stuff is slaved from the AndroidSalInstance
56 void DeInitSalData() {}
59 void SalAbort( const OUString
& rErrorText
, bool bDumpCore
)
61 OUString
aError( rErrorText
);
62 if( aError
.isEmpty() )
63 aError
= "Unknown application error";
64 ::fprintf( stderr
, "%s\n", OUStringToOString(rErrorText
, osl_getThreadTextEncoding()).getStr() );
66 ::fprintf( stderr
, "SalAbort: '%s'",
67 OUStringToOString(aError
, RTL_TEXTENCODING_ASCII_US
).getStr());
74 const OUString
& SalGetDesktopEnvironment()
76 static OUString
aEnv( "headless" );
81 m_pInstance( nullptr ),
82 m_pPIManager( nullptr )
90 // This is our main entry point:
91 SalInstance
*CreateSalInstance()
93 HeadlessSalInstance
* pInstance
= new HeadlessSalInstance( new SvpSalYieldMutex() );
94 new HeadlessSalData( pInstance
);
95 pInstance
->AcquireYieldMutex();
99 void DestroySalInstance( SalInstance
*pInst
)
101 pInst
->ReleaseYieldMutexAll();
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */