merge the formfield patch from ooo-build
[ooovba.git] / toolkit / source / awt / vclxsystemdependentwindow.cxx
blobf3db357bd6a6e2d906bf4d26c24a699b09df5cf7
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: vclxsystemdependentwindow.cxx,v $
10 * $Revision: 1.8 $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_toolkit.hxx"
35 #include <com/sun/star/lang/SystemDependent.hpp>
37 #if defined UNX && ! defined QUARTZ && ! defined _COM_SUN_STAR_AWT_SYSTEMDEPENDENTXWINDOW_HPP_
38 #include <com/sun/star/awt/SystemDependentXWindow.hpp>
39 #endif
41 #include <toolkit/awt/vclxsystemdependentwindow.hxx>
42 #include <toolkit/helper/macros.hxx>
43 #include <cppuhelper/typeprovider.hxx>
45 #ifdef WNT
46 #include <tools/prewin.h>
47 #include <windows.h>
48 #include <tools/postwin.h>
49 #elif defined ( QUARTZ )
50 #include "premac.h"
51 #include <Cocoa/Cocoa.h>
52 #include "postmac.h"
53 #endif
55 #include <vcl/syschild.hxx>
56 #include <vcl/sysdata.hxx>
58 // ----------------------------------------------------
59 // class VCLXSystemDependentWindow
60 // ----------------------------------------------------
61 VCLXSystemDependentWindow::VCLXSystemDependentWindow()
65 VCLXSystemDependentWindow::~VCLXSystemDependentWindow()
69 // ::com::sun::star::uno::XInterface
70 ::com::sun::star::uno::Any VCLXSystemDependentWindow::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
72 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
73 SAL_STATIC_CAST( ::com::sun::star::awt::XSystemDependentWindowPeer*, this ) );
74 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
77 // ::com::sun::star::lang::XTypeProvider
78 IMPL_XTYPEPROVIDER_START( VCLXSystemDependentWindow )
79 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSystemDependentWindowPeer>* ) NULL ),
80 VCLXWindow::getTypes()
81 IMPL_XTYPEPROVIDER_END
83 ::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)
85 ::vos::OGuard aGuard( GetMutex() );
87 // TODO, check the process id
88 ::com::sun::star::uno::Any aRet;
89 Window* pWindow = GetWindow();
90 if ( pWindow )
92 const SystemEnvData* pSysData = ((SystemChildWindow *)pWindow)->GetSystemData();
93 if( pSysData )
95 #if (defined WNT)
96 if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_WIN32 )
98 aRet <<= (sal_Int32)pSysData->hWnd;
100 #elif (defined OS2)
101 if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_OS2 )
103 aRet <<= (sal_Int32)pSysData->hWnd;
105 #elif (defined QUARTZ)
106 if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_MAC )
108 aRet <<= (sal_IntPtr)pSysData->pView;
110 #elif (defined UNX)
111 if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_XWINDOW )
113 ::com::sun::star::awt::SystemDependentXWindow aSD;
114 aSD.DisplayPointer = sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_IntPtr >(pSysData->pDisplay));
115 aSD.WindowHandle = pSysData->aWindow;
116 aRet <<= aSD;
118 #endif
121 return aRet;