tdf#116301: write correct content type for diagramDrawing
[LibreOffice.git] / vcl / headless / headlessinst.cxx
blobb49859c03c20d4a556e2655ff4e30a879923124a
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( SalYieldMutex *pMutex );
18 virtual SalSystem* CreateSalSystem() override;
21 HeadlessSalInstance::HeadlessSalInstance( SalYieldMutex *pMutex ) :
22 SvpSalInstance( 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 // All the interesting stuff is slaved from the AndroidSalInstance
55 void InitSalData() {}
56 void DeInitSalData() {}
57 void InitSalMain() {}
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());
68 if( bDumpCore )
69 abort();
70 else
71 _exit(1);
74 const OUString& SalGetDesktopEnvironment()
76 static OUString aEnv( "headless" );
77 return aEnv;
80 SalData::SalData() :
81 m_pInstance( nullptr ),
82 m_pPIManager( nullptr )
86 SalData::~SalData()
90 // This is our main entry point:
91 SalInstance *CreateSalInstance()
93 HeadlessSalInstance* pInstance = new HeadlessSalInstance( new SvpSalYieldMutex() );
94 new HeadlessSalData( pInstance );
95 pInstance->AcquireYieldMutex();
96 return pInstance;
99 void DestroySalInstance( SalInstance *pInst )
101 pInst->ReleaseYieldMutexAll();
102 delete pInst;
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */