1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: salinst.h,v $
10 * $Revision: 1.20.30.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
35 #include "vos/mutex.hxx"
36 #include "vos/thread.hxx"
37 #include "vcl/salinst.hxx"
39 #include "aquavcltypes.h"
44 class ApplicationEvent
;
51 class SalYieldMutex
: public vos::OMutex
54 vos::OThread::TThreadIdentifier mnThreadId
;
58 virtual void acquire();
59 virtual void release();
60 virtual sal_Bool
tryToAcquire();
61 ULONG
GetAcquireCount() const { return mnCount
; }
62 vos::OThread::TThreadIdentifier
GetThreadId() const { return mnThreadId
; }
65 #define YIELD_GUARD vos::OGuard aGuard( GetSalData()->mpFirstInstance->GetYieldMutex() )
68 // -------------------
69 // - SalInstanceData -
70 // -------------------
72 //struct SalInstanceData
78 // - AquaSalInstance -
81 class AquaSalInstance
: public SalInstance
85 AquaSalFrame
* mpFrame
;
89 SalUserEvent( AquaSalFrame
* pFrame
, void* pData
, USHORT nType
) :
90 mpFrame( pFrame
), mpData( pData
), mnType( nType
)
95 SalYieldMutex
* mpSalYieldMutex
; // Sal-Yield-Mutex
96 rtl::OUString maDefaultPrinter
;
97 vos::OThread::TThreadIdentifier maMainThread
;
99 int mnActivePrintJobs
;
100 std::list
< SalUserEvent
> maUserEvents
;
101 oslMutex maUserEventListMutex
;
103 typedef std::list
<const ApplicationEvent
*> AppEventList
;
104 static AppEventList aAppEventList
;
108 virtual ~AquaSalInstance();
110 virtual SalSystem
* CreateSystem();
111 virtual void DestroySystem(SalSystem
*);
112 virtual SalFrame
* CreateChildFrame( SystemParentData
* pParent
, ULONG nStyle
);
113 virtual SalFrame
* CreateFrame( SalFrame
* pParent
, ULONG nStyle
);
114 virtual void DestroyFrame( SalFrame
* pFrame
);
115 virtual SalObject
* CreateObject( SalFrame
* pParent
, SystemWindowData
* pWindowData
, BOOL bShow
= TRUE
);
116 virtual void DestroyObject( SalObject
* pObject
);
117 virtual SalVirtualDevice
* CreateVirtualDevice( SalGraphics
* pGraphics
,
119 USHORT nBitCount
, const SystemGraphicsData
*pData
);
120 virtual void DestroyVirtualDevice( SalVirtualDevice
* pDevice
);
122 virtual SalInfoPrinter
* CreateInfoPrinter( SalPrinterQueueInfo
* pQueueInfo
,
123 ImplJobSetup
* pSetupData
);
124 virtual void DestroyInfoPrinter( SalInfoPrinter
* pPrinter
);
125 virtual SalPrinter
* CreatePrinter( SalInfoPrinter
* pInfoPrinter
);
126 virtual void DestroyPrinter( SalPrinter
* pPrinter
);
127 virtual void GetPrinterQueueInfo( ImplPrnQueueList
* pList
);
128 virtual void GetPrinterQueueState( SalPrinterQueueInfo
* pInfo
);
129 virtual void DeletePrinterQueueInfo( SalPrinterQueueInfo
* pInfo
);
130 virtual String
GetDefaultPrinter();
131 virtual SalTimer
* CreateSalTimer();
132 virtual SalI18NImeStatus
* CreateI18NImeStatus();
133 virtual SalSystem
* CreateSalSystem();
134 virtual SalBitmap
* CreateSalBitmap();
135 virtual vos::IMutex
* GetYieldMutex();
136 virtual ULONG
ReleaseYieldMutex();
137 virtual void AcquireYieldMutex( ULONG nCount
);
138 virtual void Yield( bool bWait
, bool bHandleAllCurrentEvents
);
139 virtual bool AnyInput( USHORT nType
);
140 virtual SalMenu
* CreateMenu( BOOL bMenuBar
);
141 virtual void DestroyMenu( SalMenu
* );
142 virtual SalMenuItem
* CreateMenuItem( const SalItemParams
* pItemData
);
143 virtual void DestroyMenuItem( SalMenuItem
* );
144 virtual SalSession
* CreateSalSession();
145 virtual void* GetConnectionIdentifier( ConnectionIdentifierType
& rReturnedType
, int& rReturnedBytes
);
146 virtual void SetEventCallback( void* pInstance
, bool(*pCallback
)(void*,void*,int) );
147 virtual void SetErrorEventCallback( void* pInstance
, bool(*pCallback
)(void*,void*,int) );
149 static void handleAppDefinedEvent( NSEvent
* pEvent
);
151 // check whether a particular string is passed on the command line
152 // this is needed to avoid duplicate open events through a) command line and b) NSApp's openFile
153 static bool isOnCommandLine( const rtl::OUString
& );
158 friend class AquaSalFrame
;
160 void PostUserEvent( AquaSalFrame
* pFrame
, USHORT nType
, void* pData
);
161 void delayedSettingsChanged( bool bInvalidate
);
163 bool isNSAppThread() const;
165 void startedPrintJob() { mnActivePrintJobs
++; }
166 void endedPrintJob() { mnActivePrintJobs
--; }
168 // event subtypes for NSApplicationDefined events
169 static const short AppExecuteSVMain
= 0x7fff;
170 static const short AppEndLoopEvent
= 1;
171 static const short AppStartTimerEvent
= 10;
172 static const short AppleRemoteEvent
= 15;
173 static const short YieldWakeupEvent
= 20;
175 static NSMenu
* GetDynamicDockMenu();
178 // helper class: inverted solar guard
179 class YieldMutexReleaser
183 YieldMutexReleaser();
184 ~YieldMutexReleaser();
188 rtl::OUString
GetOUString( CFStringRef
);
189 rtl::OUString
GetOUString( NSString
* );
190 CFStringRef
CreateCFString( const rtl::OUString
& );
191 NSString
* CreateNSString( const rtl::OUString
& );
193 CGImageRef
CreateCGImage( const Image
& );
194 NSImage
* CreateNSImage( const Image
& );
196 #endif // _SV_SALINST_H