1b0724fc6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3b0724fc6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4b0724fc6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5b0724fc6SAndrew Rist  * distributed with this work for additional information
6b0724fc6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7b0724fc6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8b0724fc6SAndrew Rist  * "License"); you may not use this file except in compliance
9b0724fc6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10b0724fc6SAndrew Rist  *
11b0724fc6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12b0724fc6SAndrew Rist  *
13b0724fc6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14b0724fc6SAndrew Rist  * software distributed under the License is distributed on an
15b0724fc6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b0724fc6SAndrew Rist  * KIND, either express or implied.  See the License for the
17b0724fc6SAndrew Rist  * specific language governing permissions and limitations
18b0724fc6SAndrew Rist  * under the License.
19b0724fc6SAndrew Rist  *
20b0724fc6SAndrew Rist  *************************************************************/
21b0724fc6SAndrew Rist 
22b0724fc6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_toolkit.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <com/sun/star/lang/SystemDependent.hpp>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #if defined UNX && ! defined QUARTZ && ! defined _COM_SUN_STAR_AWT_SYSTEMDEPENDENTXWINDOW_HPP_
31cdf0e10cSrcweir #include <com/sun/star/awt/SystemDependentXWindow.hpp>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <toolkit/awt/vclxsystemdependentwindow.hxx>
35cdf0e10cSrcweir #include <toolkit/helper/macros.hxx>
36cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #ifdef WNT
39cdf0e10cSrcweir #include <tools/prewin.h>
40cdf0e10cSrcweir #include <windows.h>
41cdf0e10cSrcweir #include <tools/postwin.h>
4227ead02aSPedro Giffuni #elif defined ( OS2 )
4327ead02aSPedro Giffuni #include <svpm.h>
44cdf0e10cSrcweir #elif defined ( QUARTZ )
45cdf0e10cSrcweir #include "premac.h"
46cdf0e10cSrcweir #include <Cocoa/Cocoa.h>
47cdf0e10cSrcweir #include "postmac.h"
48cdf0e10cSrcweir #endif
49cdf0e10cSrcweir 
50cdf0e10cSrcweir #include <vcl/syschild.hxx>
51cdf0e10cSrcweir #include <vcl/sysdata.hxx>
52cdf0e10cSrcweir 
53cdf0e10cSrcweir //	----------------------------------------------------
54cdf0e10cSrcweir //	class VCLXSystemDependentWindow
55cdf0e10cSrcweir //	----------------------------------------------------
VCLXSystemDependentWindow()56cdf0e10cSrcweir VCLXSystemDependentWindow::VCLXSystemDependentWindow()
57cdf0e10cSrcweir {
58cdf0e10cSrcweir }
59cdf0e10cSrcweir 
~VCLXSystemDependentWindow()60cdf0e10cSrcweir VCLXSystemDependentWindow::~VCLXSystemDependentWindow()
61cdf0e10cSrcweir {
62cdf0e10cSrcweir }
63cdf0e10cSrcweir 
64cdf0e10cSrcweir // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)65cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXSystemDependentWindow::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
66cdf0e10cSrcweir {
67cdf0e10cSrcweir 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
68cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::awt::XSystemDependentWindowPeer*, this ) );
69cdf0e10cSrcweir 	return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
70cdf0e10cSrcweir }
71cdf0e10cSrcweir 
72cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider
73cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXSystemDependentWindow )
74cdf0e10cSrcweir 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSystemDependentWindowPeer>* ) NULL ),
75cdf0e10cSrcweir 	VCLXWindow::getTypes()
76cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END
77cdf0e10cSrcweir 
78cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXSystemDependentWindow::getWindowHandle( const ::com::sun::star::uno::Sequence< sal_Int8 >& /*ProcessId*/, sal_Int16 SystemType ) throw(::com::sun::star::uno::RuntimeException)
79cdf0e10cSrcweir {
80cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 	// TODO, check the process id
83cdf0e10cSrcweir 	::com::sun::star::uno::Any aRet;
84cdf0e10cSrcweir 	Window* pWindow = GetWindow();
85cdf0e10cSrcweir 	if ( pWindow )
86cdf0e10cSrcweir 	{
87cdf0e10cSrcweir 		const SystemEnvData* pSysData = ((SystemChildWindow *)pWindow)->GetSystemData();
88cdf0e10cSrcweir 		if( pSysData )
89cdf0e10cSrcweir 		{
90cdf0e10cSrcweir #if (defined WNT)
91cdf0e10cSrcweir 			if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_WIN32 )
92cdf0e10cSrcweir 			{
93cdf0e10cSrcweir 				 aRet <<= (sal_Int32)pSysData->hWnd;
94cdf0e10cSrcweir 			}
95cdf0e10cSrcweir #elif (defined OS2)
96cdf0e10cSrcweir 			if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_OS2 )
97cdf0e10cSrcweir 			{
98cdf0e10cSrcweir 				 aRet <<= (sal_Int32)pSysData->hWnd;
99cdf0e10cSrcweir 			}
100cdf0e10cSrcweir #elif (defined QUARTZ)
101cdf0e10cSrcweir 			if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_MAC )
102cdf0e10cSrcweir 			{
103*bde8a4bdSHerbert Dürr 				 aRet <<= (sal_IntPtr)pSysData->mpNSView;
104cdf0e10cSrcweir 			}
105cdf0e10cSrcweir #elif (defined UNX)
106cdf0e10cSrcweir 			if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_XWINDOW )
107cdf0e10cSrcweir 			{
108cdf0e10cSrcweir 				::com::sun::star::awt::SystemDependentXWindow aSD;
109cdf0e10cSrcweir 				aSD.DisplayPointer = sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_IntPtr >(pSysData->pDisplay));
110cdf0e10cSrcweir 				aSD.WindowHandle = pSysData->aWindow;
111cdf0e10cSrcweir 				aRet <<= aSD;
112cdf0e10cSrcweir 			}
113cdf0e10cSrcweir #endif
114cdf0e10cSrcweir 		}
115cdf0e10cSrcweir 	}
116cdf0e10cSrcweir 	return aRet;
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 
123