merge the formfield patch from ooo-build
[ooovba.git] / vcl / aqua / inc / salinst.h
blob827456cb69e3f8c8964382085aeca58cb166bf59
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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 ************************************************************************/
31 #ifndef _SV_SALINST_H
32 #define _SV_SALINST_H
34 #include "vcl/sv.h"
35 #include "vos/mutex.hxx"
36 #include "vos/thread.hxx"
37 #include "vcl/salinst.hxx"
39 #include "aquavcltypes.h"
41 #include <list>
43 class AquaSalFrame;
44 class ApplicationEvent;
45 class Image;
47 // -----------------
48 // - SalYieldMutex -
49 // -----------------
51 class SalYieldMutex : public vos::OMutex
53 ULONG mnCount;
54 vos::OThread::TThreadIdentifier mnThreadId;
56 public:
57 SalYieldMutex();
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
73 //{
74 //public:
75 //};
77 // ------------------
78 // - AquaSalInstance -
79 // ------------------
81 class AquaSalInstance : public SalInstance
83 struct SalUserEvent
85 AquaSalFrame* mpFrame;
86 void* mpData;
87 USHORT mnType;
89 SalUserEvent( AquaSalFrame* pFrame, void* pData, USHORT nType ) :
90 mpFrame( pFrame ), mpData( pData ), mnType( nType )
94 public:
95 SalYieldMutex* mpSalYieldMutex; // Sal-Yield-Mutex
96 rtl::OUString maDefaultPrinter;
97 vos::OThread::TThreadIdentifier maMainThread;
98 bool mbWaitingYield;
99 int mnActivePrintJobs;
100 std::list< SalUserEvent > maUserEvents;
101 oslMutex maUserEventListMutex;
103 typedef std::list<const ApplicationEvent*> AppEventList;
104 static AppEventList aAppEventList;
106 public:
107 AquaSalInstance();
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,
118 long nDX, long nDY,
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 AddToRecentDocumentList(const rtl::OUString& rFileUrl, const rtl::OUString& rMimeType);
147 virtual void SetEventCallback( void* pInstance, bool(*pCallback)(void*,void*,int) );
148 virtual void SetErrorEventCallback( void* pInstance, bool(*pCallback)(void*,void*,int) );
150 // dtrans implementation
151 virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
152 CreateClipboard( const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& i_rArguments );
153 virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > CreateDragSource();
154 virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > CreateDropTarget();
156 static void handleAppDefinedEvent( NSEvent* pEvent );
158 // check whether a particular string is passed on the command line
159 // this is needed to avoid duplicate open events through a) command line and b) NSApp's openFile
160 static bool isOnCommandLine( const rtl::OUString& );
162 void wakeupYield();
164 public:
165 friend class AquaSalFrame;
167 void PostUserEvent( AquaSalFrame* pFrame, USHORT nType, void* pData );
168 void delayedSettingsChanged( bool bInvalidate );
170 bool isNSAppThread() const;
172 void startedPrintJob() { mnActivePrintJobs++; }
173 void endedPrintJob() { mnActivePrintJobs--; }
175 // event subtypes for NSApplicationDefined events
176 static const short AppExecuteSVMain = 0x7fff;
177 static const short AppEndLoopEvent = 1;
178 static const short AppStartTimerEvent = 10;
179 static const short AppleRemoteEvent = 15;
180 static const short YieldWakeupEvent = 20;
182 static NSMenu* GetDynamicDockMenu();
185 // helper class: inverted solar guard
186 class YieldMutexReleaser
188 ULONG mnCount;
189 public:
190 YieldMutexReleaser();
191 ~YieldMutexReleaser();
194 // helper class
195 rtl::OUString GetOUString( CFStringRef );
196 rtl::OUString GetOUString( NSString* );
197 CFStringRef CreateCFString( const rtl::OUString& );
198 NSString* CreateNSString( const rtl::OUString& );
200 CGImageRef CreateCGImage( const Image& );
201 NSImage* CreateNSImage( const Image& );
203 #endif // _SV_SALINST_H