Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / vcl / headless / headlessinst.cxx
blobf204b5f3fd84db6257c7749a610c49ba717bbbf0
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 <generic/gendata.hxx>
13 class HeadlessSalInstance : public SvpSalInstance
15 public:
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 {
32 public:
33 HeadlessSalSystem() : SvpSalSystem() {}
34 virtual ~HeadlessSalSystem() {}
35 virtual int ShowNativeDialog( const OUString& rTitle,
36 const OUString& rMessage,
37 const std::list< OUString >& rButtons,
38 int nDefButton )
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());
44 return 0;
48 SalSystem *HeadlessSalInstance::CreateSalSystem()
50 return new HeadlessSalSystem();
53 class HeadlessSalData : public SalGenericData
55 public:
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
62 void InitSalData() {}
63 void DeInitSalData() {}
64 void InitSalMain() {}
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());
75 if( bDumpCore )
76 abort();
77 else
78 _exit(1);
81 const OUString& SalGetDesktopEnvironment()
83 static OUString aEnv( "headless" );
84 return aEnv;
87 SalData::SalData() :
88 m_pInstance( 0 ),
89 m_pPlugin( 0 ),
90 m_pPIManager(0 )
94 SalData::~SalData()
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);
104 return pInstance;
107 void DestroySalInstance( SalInstance *pInst )
109 pInst->ReleaseYieldMutex();
110 delete pInst;
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */