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