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 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_toolkit.hxx"
30 
31 
32 #include <com/sun/star/lang/SystemDependent.hpp>
33 
34 #if defined UNX && ! defined QUARTZ && ! defined _COM_SUN_STAR_AWT_SYSTEMDEPENDENTXWINDOW_HPP_
35 #include <com/sun/star/awt/SystemDependentXWindow.hpp>
36 #endif
37 
38 #include <toolkit/awt/vclxsystemdependentwindow.hxx>
39 #include <toolkit/helper/macros.hxx>
40 #include <cppuhelper/typeprovider.hxx>
41 
42 #ifdef WNT
43 #include <tools/prewin.h>
44 #include <windows.h>
45 #include <tools/postwin.h>
46 #elif defined ( QUARTZ )
47 #include "premac.h"
48 #include <Cocoa/Cocoa.h>
49 #include "postmac.h"
50 #endif
51 
52 #include <vcl/syschild.hxx>
53 #include <vcl/sysdata.hxx>
54 
55 //	----------------------------------------------------
56 //	class VCLXSystemDependentWindow
57 //	----------------------------------------------------
58 VCLXSystemDependentWindow::VCLXSystemDependentWindow()
59 {
60 }
61 
62 VCLXSystemDependentWindow::~VCLXSystemDependentWindow()
63 {
64 }
65 
66 // ::com::sun::star::uno::XInterface
67 ::com::sun::star::uno::Any VCLXSystemDependentWindow::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
68 {
69 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
70 										SAL_STATIC_CAST( ::com::sun::star::awt::XSystemDependentWindowPeer*, this ) );
71 	return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
72 }
73 
74 // ::com::sun::star::lang::XTypeProvider
75 IMPL_XTYPEPROVIDER_START( VCLXSystemDependentWindow )
76 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSystemDependentWindowPeer>* ) NULL ),
77 	VCLXWindow::getTypes()
78 IMPL_XTYPEPROVIDER_END
79 
80 ::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)
81 {
82 	::vos::OGuard aGuard( GetMutex() );
83 
84 	// TODO, check the process id
85 	::com::sun::star::uno::Any aRet;
86 	Window* pWindow = GetWindow();
87 	if ( pWindow )
88 	{
89 		const SystemEnvData* pSysData = ((SystemChildWindow *)pWindow)->GetSystemData();
90 		if( pSysData )
91 		{
92 #if (defined WNT)
93 			if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_WIN32 )
94 			{
95 				 aRet <<= (sal_Int32)pSysData->hWnd;
96 			}
97 #elif (defined OS2)
98 			if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_OS2 )
99 			{
100 				 aRet <<= (sal_Int32)pSysData->hWnd;
101 			}
102 #elif (defined QUARTZ)
103 			if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_MAC )
104 			{
105 				 aRet <<= (sal_IntPtr)pSysData->pView;
106 			}
107 #elif (defined UNX)
108 			if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_XWINDOW )
109 			{
110 				::com::sun::star::awt::SystemDependentXWindow aSD;
111 				aSD.DisplayPointer = sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_IntPtr >(pSysData->pDisplay));
112 				aSD.WindowHandle = pSysData->aWindow;
113 				aRet <<= aSD;
114 			}
115 #endif
116 		}
117 	}
118 	return aRet;
119 }
120 
121 
122 
123 
124 
125