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 #include <tools/svwin.h> 28 #include <toolkit/awt/vclxwindow.hxx> 29 #include <com/sun/star/beans/NamedValue.hpp> 30 #ifndef _SV_WORKWIN 31 #include <vcl/wrkwin.hxx> 32 #endif 33 #include <vcl/window.hxx> 34 35 #ifdef WNT 36 #include <tools/prewin.h> 37 #include <windows.h> 38 #include <tools/postwin.h> 39 #elif defined ( QUARTZ ) 40 #include "premac.h" 41 #include <Cocoa/Cocoa.h> 42 #include "postmac.h" 43 #endif 44 #include <vcl/sysdata.hxx> 45 46 /// helper method to set a window handle into a SystemParentData struct 47 void VCLXWindow::SetSystemParent_Impl( const com::sun::star::uno::Any& rHandle ) 48 { 49 // does only work for WorkWindows 50 Window *pWindow = GetWindow(); 51 if ( pWindow->GetType() != WINDOW_WORKWINDOW ) 52 { 53 ::com::sun::star::uno::Exception *pException = 54 new ::com::sun::star::uno::RuntimeException; 55 pException->Message = ::rtl::OUString::createFromAscii( "not a work window" ); 56 throw pException; 57 } 58 59 // use sal_Int64 here to accomodate all int types 60 // uno::Any shift operator whill upcast if necessary 61 sal_Int64 nHandle = 0; 62 sal_Bool bXEmbed = sal_False; 63 bool bThrow = false; 64 if( ! (rHandle >>= nHandle) ) 65 { 66 com::sun::star::uno::Sequence< com::sun::star::beans::NamedValue > aProps; 67 if( rHandle >>= aProps ) 68 { 69 const int nProps = aProps.getLength(); 70 const com::sun::star::beans::NamedValue* pProps = aProps.getConstArray(); 71 for( int i = 0; i < nProps; i++ ) 72 { 73 if( pProps[i].Name.equalsAscii( "WINDOW" ) ) 74 pProps[i].Value >>= nHandle; 75 else if( pProps[i].Name.equalsAscii( "XEMBED" ) ) 76 pProps[i].Value >>= bXEmbed; 77 } 78 } 79 else 80 bThrow = true; 81 } 82 if( bThrow ) 83 { 84 ::com::sun::star::uno::Exception *pException = 85 new ::com::sun::star::uno::RuntimeException; 86 pException->Message = ::rtl::OUString::createFromAscii( "incorrect window handle type" ); 87 throw pException; 88 } 89 // create system parent data 90 SystemParentData aSysParentData; 91 aSysParentData.nSize = sizeof ( SystemParentData ); 92 #if defined( WNT ) || defined ( OS2 ) 93 aSysParentData.hWnd = (HWND) nHandle; 94 #elif defined( QUARTZ ) 95 aSysParentData.pView = reinterpret_cast<NSView*>(nHandle); 96 #elif defined( UNX ) 97 aSysParentData.aWindow = (long)nHandle; 98 aSysParentData.bXEmbedSupport = bXEmbed; 99 #endif 100 101 // set system parent 102 ((WorkWindow*)pWindow)->SetPluginParent( &aSysParentData ); 103 } 104 105