1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef _SVP_SALINST_HXX 29*cdf0e10cSrcweir #define _SVP_SALINST_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <vos/mutex.hxx> 32*cdf0e10cSrcweir #include <vos/thread.hxx> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include <salinst.hxx> 35*cdf0e10cSrcweir #include <salwtype.hxx> 36*cdf0e10cSrcweir #include <saltimer.hxx> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <list> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include <time.h> // timeval 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir #define VIRTUAL_DESKTOP_WIDTH 1024 43*cdf0e10cSrcweir #define VIRTUAL_DESKTOP_HEIGHT 768 44*cdf0e10cSrcweir #define VIRTUAL_DESKTOP_DEPTH 24 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir // ------------------------------------------------------------------------- 47*cdf0e10cSrcweir // SalYieldMutex 48*cdf0e10cSrcweir // ------------------------------------------------------------------------- 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir class SvpSalYieldMutex : public vos::OMutex 51*cdf0e10cSrcweir { 52*cdf0e10cSrcweir protected: 53*cdf0e10cSrcweir sal_uLong mnCount; 54*cdf0e10cSrcweir vos::OThread::TThreadIdentifier mnThreadId; 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir public: 57*cdf0e10cSrcweir SvpSalYieldMutex(); 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir virtual void acquire(); 60*cdf0e10cSrcweir virtual void release(); 61*cdf0e10cSrcweir virtual sal_Bool tryToAcquire(); 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir sal_uLong GetAcquireCount() const { return mnCount; } 64*cdf0e10cSrcweir vos::OThread::TThreadIdentifier GetThreadId() const { return mnThreadId; } 65*cdf0e10cSrcweir }; 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir // --------------- 68*cdf0e10cSrcweir // - SalTimer - 69*cdf0e10cSrcweir // --------------- 70*cdf0e10cSrcweir class SvpSalInstance; 71*cdf0e10cSrcweir class SvpSalTimer : public SalTimer 72*cdf0e10cSrcweir { 73*cdf0e10cSrcweir SvpSalInstance* m_pInstance; 74*cdf0e10cSrcweir public: 75*cdf0e10cSrcweir SvpSalTimer( SvpSalInstance* pInstance ) : m_pInstance( pInstance ) {} 76*cdf0e10cSrcweir virtual ~SvpSalTimer(); 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir // overload all pure virtual methods 79*cdf0e10cSrcweir virtual void Start( sal_uLong nMS ); 80*cdf0e10cSrcweir virtual void Stop(); 81*cdf0e10cSrcweir }; 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir // --------------- 84*cdf0e10cSrcweir // - SalInstance - 85*cdf0e10cSrcweir // --------------- 86*cdf0e10cSrcweir class SvpSalFrame; 87*cdf0e10cSrcweir class SvpSalInstance : public SalInstance 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir timeval m_aTimeout; 90*cdf0e10cSrcweir sal_uLong m_nTimeoutMS; 91*cdf0e10cSrcweir int m_pTimeoutFDS[2]; 92*cdf0e10cSrcweir SvpSalYieldMutex m_aYieldMutex; 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir // internal event queue 95*cdf0e10cSrcweir struct SalUserEvent 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir const SalFrame* m_pFrame; 98*cdf0e10cSrcweir void* m_pData; 99*cdf0e10cSrcweir sal_uInt16 m_nEvent; 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir SalUserEvent( const SalFrame* pFrame, void* pData, sal_uInt16 nEvent = SALEVENT_USEREVENT ) 102*cdf0e10cSrcweir : m_pFrame( pFrame ), 103*cdf0e10cSrcweir m_pData( pData ), 104*cdf0e10cSrcweir m_nEvent( nEvent ) 105*cdf0e10cSrcweir {} 106*cdf0e10cSrcweir }; 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir oslMutex m_aEventGuard; 109*cdf0e10cSrcweir std::list< SalUserEvent > m_aUserEvents; 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir std::list< SalFrame* > m_aFrames; 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir bool isFrameAlive( const SalFrame* pFrame ) const; 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir public: 116*cdf0e10cSrcweir static SvpSalInstance* s_pDefaultInstance; 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir SvpSalInstance(); 119*cdf0e10cSrcweir virtual ~SvpSalInstance(); 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir void PostEvent( const SalFrame* pFrame, void* pData, sal_uInt16 nEvent ); 122*cdf0e10cSrcweir void CancelEvent( const SalFrame* pFrame, void* pData, sal_uInt16 nEvent ); 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir void StartTimer( sal_uLong nMS ); 125*cdf0e10cSrcweir void StopTimer(); 126*cdf0e10cSrcweir void Wakeup(); 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir void registerFrame( SalFrame* pFrame ) { m_aFrames.push_back( pFrame ); } 129*cdf0e10cSrcweir void deregisterFrame( SalFrame* pFrame ); 130*cdf0e10cSrcweir const std::list< SalFrame* >& getFrames() const { return m_aFrames; } 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir bool CheckTimeout( bool bExecuteTimers = true ); 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir // Frame 135*cdf0e10cSrcweir virtual SalFrame* CreateChildFrame( SystemParentData* pParent, sal_uLong nStyle ); 136*cdf0e10cSrcweir virtual SalFrame* CreateFrame( SalFrame* pParent, sal_uLong nStyle ); 137*cdf0e10cSrcweir virtual void DestroyFrame( SalFrame* pFrame ); 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir // Object (System Child Window) 140*cdf0e10cSrcweir virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, sal_Bool bShow = sal_True ); 141*cdf0e10cSrcweir virtual void DestroyObject( SalObject* pObject ); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir // VirtualDevice 144*cdf0e10cSrcweir // nDX and nDY in Pixel 145*cdf0e10cSrcweir // nBitCount: 0 == Default(=as window) / 1 == Mono 146*cdf0e10cSrcweir // pData allows for using a system dependent graphics or device context 147*cdf0e10cSrcweir virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics, 148*cdf0e10cSrcweir long nDX, long nDY, 149*cdf0e10cSrcweir sal_uInt16 nBitCount, const SystemGraphicsData *pData = NULL ); 150*cdf0e10cSrcweir virtual void DestroyVirtualDevice( SalVirtualDevice* pDevice ); 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir // Printer 153*cdf0e10cSrcweir // pSetupData->mpDriverData can be 0 154*cdf0e10cSrcweir // pSetupData must be updatet with the current 155*cdf0e10cSrcweir // JobSetup 156*cdf0e10cSrcweir virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo, 157*cdf0e10cSrcweir ImplJobSetup* pSetupData ); 158*cdf0e10cSrcweir virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ); 159*cdf0e10cSrcweir virtual SalPrinter* CreatePrinter( SalInfoPrinter* pInfoPrinter ); 160*cdf0e10cSrcweir virtual void DestroyPrinter( SalPrinter* pPrinter ); 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList ); 163*cdf0e10cSrcweir virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo ); 164*cdf0e10cSrcweir virtual void DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo ); 165*cdf0e10cSrcweir virtual String GetDefaultPrinter(); 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir // SalTimer 168*cdf0e10cSrcweir virtual SalTimer* CreateSalTimer(); 169*cdf0e10cSrcweir // SalI18NImeStatus 170*cdf0e10cSrcweir virtual SalI18NImeStatus* CreateI18NImeStatus(); 171*cdf0e10cSrcweir // SalSystem 172*cdf0e10cSrcweir virtual SalSystem* CreateSalSystem(); 173*cdf0e10cSrcweir // SalBitmap 174*cdf0e10cSrcweir virtual SalBitmap* CreateSalBitmap(); 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir // YieldMutex 177*cdf0e10cSrcweir virtual vos::IMutex* GetYieldMutex(); 178*cdf0e10cSrcweir virtual sal_uLong ReleaseYieldMutex(); 179*cdf0e10cSrcweir virtual void AcquireYieldMutex( sal_uLong nCount ); 180*cdf0e10cSrcweir virtual bool CheckYieldMutex(); 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir // wait next event and dispatch 183*cdf0e10cSrcweir // must returned by UserEvent (SalFrame::PostEvent) 184*cdf0e10cSrcweir // and timer 185*cdf0e10cSrcweir virtual void Yield( bool bWait, bool bHandleAllCurrentEvents ); 186*cdf0e10cSrcweir virtual bool AnyInput( sal_uInt16 nType ); 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir // may return NULL to disable session management 189*cdf0e10cSrcweir virtual SalSession* CreateSalSession(); 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir virtual void* GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes ); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir virtual void AddToRecentDocumentList(const rtl::OUString& rFileUrl, const rtl::OUString& rMimeType); 194*cdf0e10cSrcweir }; 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir #endif // _SV_SALINST_HXX 197