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 ::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 void SalAbort( const OUString
& rErrorText
, bool bDumpCore
)
56 OUString
aError( rErrorText
);
57 if( aError
.isEmpty() )
58 aError
= "Unknown application error";
59 ::fprintf( stderr
, "%s\n", OUStringToOString(rErrorText
, osl_getThreadTextEncoding()).getStr() );
61 ::fprintf( stderr
, "SalAbort: '%s'",
62 OUStringToOString(aError
, RTL_TEXTENCODING_ASCII_US
).getStr());
69 const OUString
& SalGetDesktopEnvironment()
71 static OUString
aEnv( "headless" );
76 m_pInstance( nullptr ),
77 m_pPIManager( nullptr )
85 // This is our main entry point:
86 SalInstance
*CreateSalInstance()
88 HeadlessSalInstance
* pInstance
= new HeadlessSalInstance(std::make_unique
<SvpSalYieldMutex
>());
89 new HeadlessSalData( pInstance
);
90 pInstance
->AcquireYieldMutex();
94 void DestroySalInstance( SalInstance
*pInst
)
96 pInst
->ReleaseYieldMutexAll();
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */