bump product version to 6.4.0.3
[LibreOffice.git] / vcl / headless / headlessinst.cxx
blobc1bf1a7b7294eef18fa68fcea2cfb2d31c208ad3
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 ::fprintf(stdout, "LibreOffice - dialog '%s': '%s'",
35 OUStringToOString(rTitle, RTL_TEXTENCODING_ASCII_US).getStr(),
36 OUStringToOString(rMessage, RTL_TEXTENCODING_ASCII_US).getStr());
37 return 0;
41 SalSystem *HeadlessSalInstance::CreateSalSystem()
43 return new HeadlessSalSystem();
46 class HeadlessSalData : public GenericUnixSalData
48 public:
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());
63 if( bDumpCore )
64 abort();
65 else
66 _exit(1);
69 const OUString& SalGetDesktopEnvironment()
71 static OUString aEnv( "headless" );
72 return aEnv;
75 SalData::SalData() :
76 m_pInstance( nullptr ),
77 m_pPIManager( nullptr )
81 SalData::~SalData()
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();
91 return pInstance;
94 void DestroySalInstance( SalInstance *pInst )
96 pInst->ReleaseYieldMutexAll();
97 delete pInst;
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */