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 <generic/gendata.hxx>
13 class HeadlessSalInstance
: public SvpSalInstance
16 HeadlessSalInstance( SalYieldMutex
*pMutex
);
17 virtual ~HeadlessSalInstance();
19 virtual SalSystem
* CreateSalSystem();
22 HeadlessSalInstance::HeadlessSalInstance( SalYieldMutex
*pMutex
) :
23 SvpSalInstance( pMutex
)
27 HeadlessSalInstance::~HeadlessSalInstance()
31 class HeadlessSalSystem
: public SvpSalSystem
{
33 HeadlessSalSystem() : SvpSalSystem() {}
34 virtual ~HeadlessSalSystem() {}
35 virtual int ShowNativeDialog( const OUString
& rTitle
,
36 const OUString
& rMessage
,
37 const std::list
< OUString
>& rButtons
,
40 (void)rButtons
; (void)nDefButton
;
41 ::fprintf(stdout
, "LibreOffice - dialog '%s': '%s'",
42 OUStringToOString(rTitle
, RTL_TEXTENCODING_ASCII_US
).getStr(),
43 OUStringToOString(rMessage
, RTL_TEXTENCODING_ASCII_US
).getStr());
48 SalSystem
*HeadlessSalInstance::CreateSalSystem()
50 return new HeadlessSalSystem();
53 class HeadlessSalData
: public SalGenericData
56 HeadlessSalData( SalInstance
*pInstance
) : SalGenericData( SAL_DATA_HEADLESS
, pInstance
) {}
57 virtual void ErrorTrapPush() {}
58 virtual bool ErrorTrapPop( bool ) { return false; }
61 // All the interesting stuff is slaved from the AndroidSalInstance
63 void DeInitSalData() {}
66 void SalAbort( const OUString
& rErrorText
, bool bDumpCore
)
68 OUString
aError( rErrorText
);
69 if( aError
.isEmpty() )
70 aError
= "Unknown application error";
71 ::fprintf( stderr
, "%s\n", OUStringToOString(rErrorText
, osl_getThreadTextEncoding()).getStr() );
73 ::fprintf( stderr
, "SalAbort: '%s'",
74 OUStringToOString(aError
, RTL_TEXTENCODING_ASCII_US
).getStr());
81 const OUString
& SalGetDesktopEnvironment()
83 static OUString
aEnv( "headless" );
98 // This is our main entry point:
99 SalInstance
*CreateSalInstance()
101 HeadlessSalInstance
* pInstance
= new HeadlessSalInstance( new SalYieldMutex() );
102 new HeadlessSalData( pInstance
);
103 pInstance
->AcquireYieldMutex(1);
107 void DestroySalInstance( SalInstance
*pInst
)
109 pInst
->ReleaseYieldMutex();
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */