xref: /aoo41x/main/vcl/inc/salinst.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SV_SALINST_HXX
29 #define _SV_SALINST_HXX
30 
31 #include "com/sun/star/uno/Reference.hxx"
32 
33 #include "vcl/sv.h"
34 #include "vcl/displayconnectiondispatch.hxx"
35 #include "vcl/dllapi.h"
36 
37 #include "tools/string.hxx"
38 
39 #include "rtl/ref.hxx"
40 #include "rtl/string.hxx"
41 
42 #include <list>
43 
44 struct SystemParentData;
45 struct SalPrinterQueueInfo;
46 struct SalStatus;
47 struct ImplJobSetup;
48 class SalGraphics;
49 class SalFrame;
50 class SalObject;
51 class SalMenu;
52 class SalMenuItem;
53 class SalVirtualDevice;
54 class SalInfoPrinter;
55 class SalPrinter;
56 class SalTimer;
57 class ImplPrnQueueList;
58 class SalI18NImeStatus;
59 class SalSystem;
60 class SalBitmap;
61 struct SalItemParams;
62 class SalSession;
63 struct SystemGraphicsData;
64 struct SystemWindowData;
65 class Menu;
66 
67 namespace vos { class IMutex; }
68 
69 // ---------------
70 // - SalInstance -
71 // ---------------
72 
73 class VCL_PLUGIN_PUBLIC SalInstance
74 {
75 private:
76     rtl::Reference< vcl::DisplayConnectionDispatch > m_pEventInst;
77 
78 public:
79     SalInstance() {}
80     virtual ~SalInstance();
81 
82     // Frame
83     // DisplayName for Unix ???
84     virtual SalFrame*      	CreateChildFrame( SystemParentData* pParent, sal_uLong nStyle ) = 0;
85     virtual SalFrame*      	CreateFrame( SalFrame* pParent, sal_uLong nStyle ) = 0;
86     virtual void				DestroyFrame( SalFrame* pFrame ) = 0;
87 
88     // Object (System Child Window)
89     virtual SalObject*			CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, sal_Bool bShow = sal_True ) = 0;
90     virtual void				DestroyObject( SalObject* pObject ) = 0;
91 
92     // VirtualDevice
93     // nDX and nDY in Pixel
94     // nBitCount: 0 == Default(=as window) / 1 == Mono
95     // pData allows for using a system dependent graphics or device context
96     virtual SalVirtualDevice*	CreateVirtualDevice( SalGraphics* pGraphics,
97                                                      long nDX, long nDY,
98                                                      sal_uInt16 nBitCount, const SystemGraphicsData *pData = NULL ) = 0;
99     virtual void				DestroyVirtualDevice( SalVirtualDevice* pDevice ) = 0;
100 
101     // Printer
102     // pSetupData->mpDriverData can be 0
103     // pSetupData must be updatet with the current
104     // JobSetup
105     virtual SalInfoPrinter*	CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
106                                                ImplJobSetup* pSetupData ) = 0;
107     virtual void				DestroyInfoPrinter( SalInfoPrinter* pPrinter ) = 0;
108     virtual SalPrinter*		CreatePrinter( SalInfoPrinter* pInfoPrinter ) = 0;
109     virtual void				DestroyPrinter( SalPrinter* pPrinter ) = 0;
110 
111     virtual void				GetPrinterQueueInfo( ImplPrnQueueList* pList ) = 0;
112     virtual void				GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) = 0;
113     virtual void				DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo ) = 0;
114     virtual String             GetDefaultPrinter() = 0;
115 
116     // SalTimer
117     virtual SalTimer*			CreateSalTimer() = 0;
118     // SalI18NImeStatus
119     virtual SalI18NImeStatus*	CreateI18NImeStatus() = 0;
120     // SalSystem
121     virtual SalSystem*			CreateSalSystem() = 0;
122     // SalBitmap
123     virtual SalBitmap*			CreateSalBitmap() = 0;
124 
125     // YieldMutex
126     virtual vos::IMutex*		GetYieldMutex() = 0;
127     virtual sal_uLong				ReleaseYieldMutex() = 0;
128     virtual void				AcquireYieldMutex( sal_uLong nCount ) = 0;
129     // return true, if yield mutex is owned by this thread, else false
130     virtual bool                CheckYieldMutex() = 0;
131 
132 	// wait next event and dispatch
133     // must returned by UserEvent (SalFrame::PostEvent)
134     // and timer
135     virtual void				Yield( bool bWait, bool bHandleAllCurrentEvents ) = 0;
136     virtual bool				AnyInput( sal_uInt16 nType ) = 0;
137 
138                             // Menues
139     virtual SalMenu*        CreateMenu( sal_Bool bMenuBar, Menu* pMenu );
140     virtual void            DestroyMenu( SalMenu* pMenu);
141     virtual SalMenuItem*    CreateMenuItem( const SalItemParams* pItemData );
142     virtual void            DestroyMenuItem( SalMenuItem* pItem );
143 
144     // may return NULL to disable session management
145     virtual SalSession*		CreateSalSession() = 0;
146 
147     // methods for XDisplayConnection
148 
149     void				SetEventCallback( rtl::Reference< vcl::DisplayConnectionDispatch > const & pInstance )
150     { m_pEventInst = pInstance; }
151     bool				CallEventCallback( void* pEvent, int nBytes )
152     { return m_pEventInst.is() && m_pEventInst->dispatchEvent( pEvent, nBytes ); }
153     bool				CallErrorCallback( void* pEvent, int nBytes )
154     { return m_pEventInst.is() && m_pEventInst->dispatchErrorEvent( pEvent, nBytes ); }
155 
156     enum ConnectionIdentifierType { AsciiCString, Blob };
157     virtual void*				GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes ) = 0;
158 
159     // this is a vehicle for PrintFontManager to bridge the gap between vcl and libvclplug_*
160     // this is only necessary because PrintFontManager is an exported vcl API and therefore
161     // needs to be in libvcl while libvclplug_* do not contain exported C++ API
162     virtual void        FillFontPathList( std::list< rtl::OString >& o_rFontPaths );
163 
164     // dtrans implementation
165     virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
166         CreateClipboard( const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& i_rArguments );
167     virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > CreateDragSource();
168     virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > CreateDropTarget();
169     virtual void        AddToRecentDocumentList(const rtl::OUString& rFileUrl, const rtl::OUString& rMimeType) = 0;
170 };
171 
172 // called from SVMain
173 SalInstance* CreateSalInstance();
174 void DestroySalInstance( SalInstance* pInst );
175 
176 // -------------------------
177 // - SalInstance-Functions -
178 // -------------------------
179 
180 void SalAbort( const XubString& rErrorText );
181 
182 VCL_PLUGIN_PUBLIC const ::rtl::OUString& SalGetDesktopEnvironment();
183 
184 // -----------
185 // - SalData -
186 // -----------
187 
188 void InitSalData();                         // called from Application-Ctor
189 void DeInitSalData();                       // called from Application-Dtor
190 
191 void InitSalMain();
192 void DeInitSalMain();
193 
194 // ----------
195 // - SVMain -
196 // ----------
197 
198 // Callbacks (indepen in \sv\source\app\svmain.cxx)
199 VCL_DLLPUBLIC sal_Bool SVMain();
200 
201 #endif // _SV_SALINST_HXX
202