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