Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / inc / headless / svpinst.hxx
blob44795d56ab49262a855d2bbdb2edc4f5664a01e6
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_INC_HEADLESS_SVPINST_HXX
21 #define INCLUDED_VCL_INC_HEADLESS_SVPINST_HXX
23 #include <osl/mutex.hxx>
24 #include <osl/thread.hxx>
25 #include <salinst.hxx>
26 #include <salwtype.hxx>
27 #include <saltimer.hxx>
28 #include <generic/geninst.h>
29 #include <generic/genprn.h>
30 #include <basebmp/scanlineformats.hxx>
32 #include <list>
33 #include <map>
35 #include <time.h>
37 #define VIRTUAL_DESKTOP_WIDTH 1024
38 #define VIRTUAL_DESKTOP_HEIGHT 768
40 #ifdef IOS
41 #define SvpSalInstance AquaSalInstance
42 #endif
44 class SvpSalInstance;
45 class SvpSalTimer : public SalTimer
47 SvpSalInstance* m_pInstance;
48 public:
49 SvpSalTimer( SvpSalInstance* pInstance ) : m_pInstance( pInstance ) {}
50 virtual ~SvpSalTimer();
52 // override all pure virtual methods
53 virtual void Start( sal_uLong nMS ) SAL_OVERRIDE;
54 virtual void Stop() SAL_OVERRIDE;
57 class SvpSalFrame;
58 class GenPspGraphics;
60 SalInstance* svp_create_SalInstance();
62 class VCL_DLLPUBLIC SvpSalInstance : public SalGenericInstance
64 timeval m_aTimeout;
65 sal_uLong m_nTimeoutMS;
66 int m_pTimeoutFDS[2];
68 // internal event queue
69 struct SalUserEvent
71 const SalFrame* m_pFrame;
72 void* m_pData;
73 sal_uInt16 m_nEvent;
75 SalUserEvent( const SalFrame* pFrame, void* pData, sal_uInt16 nEvent = SALEVENT_USEREVENT )
76 : m_pFrame( pFrame ),
77 m_pData( pData ),
78 m_nEvent( nEvent )
82 oslMutex m_aEventGuard;
83 std::list< SalUserEvent > m_aUserEvents;
85 std::list< SalFrame* > m_aFrames;
87 bool isFrameAlive( const SalFrame* pFrame ) const;
89 void DoReleaseYield( int nTimeoutMS );
91 typedef std::map< sal_uInt16, ::basebmp::Format > BitCountFormatMap;
92 BitCountFormatMap m_aBitCountFormatMap;
94 public:
95 static SvpSalInstance* s_pDefaultInstance;
97 SvpSalInstance( SalYieldMutex *pMutex );
98 virtual ~SvpSalInstance();
100 void PostEvent( const SalFrame* pFrame, void* pData, sal_uInt16 nEvent );
102 bool PostedEventsInQueue();
104 void StartTimer( sal_uLong nMS );
105 void StopTimer();
106 void Wakeup();
108 void registerFrame( SalFrame* pFrame ) { m_aFrames.push_back( pFrame ); }
109 void deregisterFrame( SalFrame* pFrame );
110 const std::list< SalFrame* >&
111 getFrames() const { return m_aFrames; }
113 bool CheckTimeout( bool bExecuteTimers = true );
115 // Frame
116 virtual SalFrame* CreateChildFrame( SystemParentData* pParent, sal_uLong nStyle ) SAL_OVERRIDE;
117 virtual SalFrame* CreateFrame( SalFrame* pParent, sal_uLong nStyle ) SAL_OVERRIDE;
118 virtual void DestroyFrame( SalFrame* pFrame ) SAL_OVERRIDE;
120 // Object (System Child Window)
121 virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, bool bShow = true ) SAL_OVERRIDE;
122 virtual void DestroyObject( SalObject* pObject ) SAL_OVERRIDE;
124 // VirtualDevice
125 // nDX and nDY in Pixel
126 // nBitCount: 0 == Default(=as window) / 1 == Mono
127 // pData allows for using a system dependent graphics or device context
128 virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics,
129 long &nDX, long &nDY,
130 sal_uInt16 nBitCount, const SystemGraphicsData *pData = NULL ) SAL_OVERRIDE;
132 // Printer
133 // pSetupData->mpDriverData can be 0
134 // pSetupData must be updatet with the current
135 // JobSetup
136 virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
137 ImplJobSetup* pSetupData ) SAL_OVERRIDE;
138 virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ) SAL_OVERRIDE;
139 virtual SalPrinter* CreatePrinter( SalInfoPrinter* pInfoPrinter ) SAL_OVERRIDE;
140 virtual void DestroyPrinter( SalPrinter* pPrinter ) SAL_OVERRIDE;
142 virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList ) SAL_OVERRIDE;
143 virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) SAL_OVERRIDE;
144 virtual void DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo ) SAL_OVERRIDE;
145 virtual OUString GetDefaultPrinter() SAL_OVERRIDE;
146 virtual void PostPrintersChanged() SAL_OVERRIDE;
148 // SalTimer
149 virtual SalTimer* CreateSalTimer() SAL_OVERRIDE;
150 // SalI18NImeStatus
151 virtual SalI18NImeStatus* CreateI18NImeStatus() SAL_OVERRIDE;
152 // SalSystem
153 virtual SalSystem* CreateSalSystem() SAL_OVERRIDE;
154 // SalBitmap
155 virtual SalBitmap* CreateSalBitmap() SAL_OVERRIDE;
157 // wait next event and dispatch
158 // must returned by UserEvent (SalFrame::PostEvent)
159 // and timer
160 virtual void Yield( bool bWait, bool bHandleAllCurrentEvents ) SAL_OVERRIDE;
161 virtual bool AnyInput( VclInputFlags nType ) SAL_OVERRIDE;
163 // may return NULL to disable session management
164 virtual SalSession* CreateSalSession() SAL_OVERRIDE;
166 virtual void* GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes ) SAL_OVERRIDE;
168 virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) SAL_OVERRIDE;
170 virtual GenPspGraphics *CreatePrintGraphics() SAL_OVERRIDE;
172 // We want to be able to select colourspace, i.e. ARGB vs RGBA vs BGRA etc.
173 // -- as the rest of vcl always uses bit depths, it is perhaps simplest
174 // to let us simply change the mapping of bitcount to format (which was
175 // previously unchangeable).
176 void setBitCountFormatMapping( sal_uInt16 nBitCount, ::basebmp::Format aFormat );
178 ::basebmp::Format getFormatForBitCount( sal_uInt16 );
181 #endif // INCLUDED_VCL_INC_HEADLESS_SVPINST_HXX
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */