Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_VCL_INC_HEADLESS_SVPINST_HXX
21 : #define INCLUDED_VCL_INC_HEADLESS_SVPINST_HXX
22 :
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 :
31 : #include <list>
32 :
33 : #include <time.h>
34 :
35 : #define VIRTUAL_DESKTOP_WIDTH 1024
36 : #define VIRTUAL_DESKTOP_HEIGHT 768
37 :
38 : #ifdef IOS
39 : #define SvpSalInstance AquaSalInstance
40 : #endif
41 :
42 : class SvpSalInstance;
43 : class SvpSalTimer : public SalTimer
44 : {
45 : SvpSalInstance* m_pInstance;
46 : public:
47 0 : SvpSalTimer( SvpSalInstance* pInstance ) : m_pInstance( pInstance ) {}
48 : virtual ~SvpSalTimer();
49 :
50 : // overload all pure virtual methods
51 : virtual void Start( sal_uLong nMS ) SAL_OVERRIDE;
52 : virtual void Stop() SAL_OVERRIDE;
53 : };
54 :
55 : class SvpSalFrame;
56 : class GenPspGraphics;
57 :
58 : class SvpSalInstance : public SalGenericInstance
59 : {
60 : timeval m_aTimeout;
61 : sal_uLong m_nTimeoutMS;
62 : int m_pTimeoutFDS[2];
63 :
64 : // internal event queue
65 : struct SalUserEvent
66 : {
67 : const SalFrame* m_pFrame;
68 : void* m_pData;
69 : sal_uInt16 m_nEvent;
70 :
71 0 : SalUserEvent( const SalFrame* pFrame, void* pData, sal_uInt16 nEvent = SALEVENT_USEREVENT )
72 : : m_pFrame( pFrame ),
73 : m_pData( pData ),
74 0 : m_nEvent( nEvent )
75 0 : {}
76 : };
77 :
78 : oslMutex m_aEventGuard;
79 : std::list< SalUserEvent > m_aUserEvents;
80 :
81 : std::list< SalFrame* > m_aFrames;
82 :
83 : bool isFrameAlive( const SalFrame* pFrame ) const;
84 :
85 : void DoReleaseYield( int nTimeoutMS );
86 :
87 : public:
88 : static SvpSalInstance* s_pDefaultInstance;
89 :
90 : SvpSalInstance( SalYieldMutex *pMutex );
91 : virtual ~SvpSalInstance();
92 :
93 : void PostEvent( const SalFrame* pFrame, void* pData, sal_uInt16 nEvent );
94 :
95 : bool PostedEventsInQueue();
96 :
97 : void StartTimer( sal_uLong nMS );
98 : void StopTimer();
99 : void Wakeup();
100 :
101 0 : void registerFrame( SalFrame* pFrame ) { m_aFrames.push_back( pFrame ); }
102 : void deregisterFrame( SalFrame* pFrame );
103 : const std::list< SalFrame* >&
104 0 : getFrames() const { return m_aFrames; }
105 :
106 : bool CheckTimeout( bool bExecuteTimers = true );
107 :
108 : // Frame
109 : virtual SalFrame* CreateChildFrame( SystemParentData* pParent, sal_uLong nStyle ) SAL_OVERRIDE;
110 : virtual SalFrame* CreateFrame( SalFrame* pParent, sal_uLong nStyle ) SAL_OVERRIDE;
111 : virtual void DestroyFrame( SalFrame* pFrame ) SAL_OVERRIDE;
112 :
113 : // Object (System Child Window)
114 : virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, bool bShow = true ) SAL_OVERRIDE;
115 : virtual void DestroyObject( SalObject* pObject ) SAL_OVERRIDE;
116 :
117 : // VirtualDevice
118 : // nDX and nDY in Pixel
119 : // nBitCount: 0 == Default(=as window) / 1 == Mono
120 : // pData allows for using a system dependent graphics or device context
121 : virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics,
122 : long nDX, long nDY,
123 : sal_uInt16 nBitCount, const SystemGraphicsData *pData = NULL ) SAL_OVERRIDE;
124 :
125 : // Printer
126 : // pSetupData->mpDriverData can be 0
127 : // pSetupData must be updatet with the current
128 : // JobSetup
129 : virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
130 : ImplJobSetup* pSetupData ) SAL_OVERRIDE;
131 : virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ) SAL_OVERRIDE;
132 : virtual SalPrinter* CreatePrinter( SalInfoPrinter* pInfoPrinter ) SAL_OVERRIDE;
133 : virtual void DestroyPrinter( SalPrinter* pPrinter ) SAL_OVERRIDE;
134 :
135 : virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList ) SAL_OVERRIDE;
136 : virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) SAL_OVERRIDE;
137 : virtual void DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo ) SAL_OVERRIDE;
138 : virtual OUString GetDefaultPrinter() SAL_OVERRIDE;
139 : virtual void PostPrintersChanged() SAL_OVERRIDE;
140 :
141 : // SalTimer
142 : virtual SalTimer* CreateSalTimer() SAL_OVERRIDE;
143 : // SalI18NImeStatus
144 : virtual SalI18NImeStatus* CreateI18NImeStatus() SAL_OVERRIDE;
145 : // SalSystem
146 : virtual SalSystem* CreateSalSystem() SAL_OVERRIDE;
147 : // SalBitmap
148 : virtual SalBitmap* CreateSalBitmap() SAL_OVERRIDE;
149 :
150 : // wait next event and dispatch
151 : // must returned by UserEvent (SalFrame::PostEvent)
152 : // and timer
153 : virtual void Yield( bool bWait, bool bHandleAllCurrentEvents ) SAL_OVERRIDE;
154 : virtual bool AnyInput( sal_uInt16 nType ) SAL_OVERRIDE;
155 :
156 : // may return NULL to disable session management
157 : virtual SalSession* CreateSalSession() SAL_OVERRIDE;
158 :
159 : virtual void* GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes ) SAL_OVERRIDE;
160 :
161 : virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) SAL_OVERRIDE;
162 :
163 : virtual GenPspGraphics *CreatePrintGraphics() SAL_OVERRIDE;
164 : };
165 :
166 : #endif // INCLUDED_VCL_INC_HEADLESS_SVPINST_HXX
167 :
168 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|