xref: /aoo42x/main/toolkit/source/awt/vclxwindow1.cxx (revision b0724fc6)
1*b0724fc6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b0724fc6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b0724fc6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b0724fc6SAndrew Rist  * distributed with this work for additional information
6*b0724fc6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b0724fc6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b0724fc6SAndrew Rist  * "License"); you may not use this file except in compliance
9*b0724fc6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b0724fc6SAndrew Rist  *
11*b0724fc6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b0724fc6SAndrew Rist  *
13*b0724fc6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b0724fc6SAndrew Rist  * software distributed under the License is distributed on an
15*b0724fc6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b0724fc6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b0724fc6SAndrew Rist  * specific language governing permissions and limitations
18*b0724fc6SAndrew Rist  * under the License.
19*b0724fc6SAndrew Rist  *
20*b0724fc6SAndrew Rist  *************************************************************/
21*b0724fc6SAndrew Rist 
22*b0724fc6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_toolkit.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <tools/svwin.h>
28cdf0e10cSrcweir #include <toolkit/awt/vclxwindow.hxx>
29cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp>
30cdf0e10cSrcweir #ifndef _SV_WORKWIN
31cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #include <vcl/window.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #ifdef WNT
36cdf0e10cSrcweir #include <tools/prewin.h>
37cdf0e10cSrcweir #include <windows.h>
38cdf0e10cSrcweir #include <tools/postwin.h>
39cdf0e10cSrcweir #elif defined ( QUARTZ )
40cdf0e10cSrcweir #include "premac.h"
41cdf0e10cSrcweir #include <Cocoa/Cocoa.h>
42cdf0e10cSrcweir #include "postmac.h"
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir #include <vcl/sysdata.hxx>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir /// helper method to set a window handle into a SystemParentData struct
47cdf0e10cSrcweir void VCLXWindow::SetSystemParent_Impl( const com::sun::star::uno::Any& rHandle )
48cdf0e10cSrcweir {
49cdf0e10cSrcweir 	// does only work for WorkWindows
50cdf0e10cSrcweir 	Window *pWindow = GetWindow();
51cdf0e10cSrcweir 	if ( pWindow->GetType() != WINDOW_WORKWINDOW )
52cdf0e10cSrcweir 	{
53cdf0e10cSrcweir 		::com::sun::star::uno::Exception *pException =
54cdf0e10cSrcweir 			new ::com::sun::star::uno::RuntimeException;
55cdf0e10cSrcweir 		pException->Message = ::rtl::OUString::createFromAscii( "not a work window" );
56cdf0e10cSrcweir 		throw pException;
57cdf0e10cSrcweir 	}
58cdf0e10cSrcweir 
59cdf0e10cSrcweir     // use sal_Int64 here to accomodate all int types
60cdf0e10cSrcweir     // uno::Any shift operator whill upcast if necessary
61cdf0e10cSrcweir     sal_Int64 nHandle = 0;
62cdf0e10cSrcweir     sal_Bool  bXEmbed = sal_False;
63cdf0e10cSrcweir     bool bThrow = false;
64cdf0e10cSrcweir     if( ! (rHandle >>= nHandle) )
65cdf0e10cSrcweir     {
66cdf0e10cSrcweir         com::sun::star::uno::Sequence< com::sun::star::beans::NamedValue > aProps;
67cdf0e10cSrcweir         if( rHandle >>= aProps )
68cdf0e10cSrcweir         {
69cdf0e10cSrcweir             const int nProps = aProps.getLength();
70cdf0e10cSrcweir             const com::sun::star::beans::NamedValue* pProps = aProps.getConstArray();
71cdf0e10cSrcweir             for( int i = 0; i < nProps; i++ )
72cdf0e10cSrcweir             {
73cdf0e10cSrcweir                 if( pProps[i].Name.equalsAscii( "WINDOW" ) )
74cdf0e10cSrcweir                     pProps[i].Value >>= nHandle;
75cdf0e10cSrcweir                 else if( pProps[i].Name.equalsAscii( "XEMBED" ) )
76cdf0e10cSrcweir                     pProps[i].Value >>= bXEmbed;
77cdf0e10cSrcweir             }
78cdf0e10cSrcweir         }
79cdf0e10cSrcweir         else
80cdf0e10cSrcweir             bThrow = true;
81cdf0e10cSrcweir     }
82cdf0e10cSrcweir     if( bThrow )
83cdf0e10cSrcweir     {
84cdf0e10cSrcweir         ::com::sun::star::uno::Exception *pException =
85cdf0e10cSrcweir             new ::com::sun::star::uno::RuntimeException;
86cdf0e10cSrcweir         pException->Message = ::rtl::OUString::createFromAscii( "incorrect window handle type" );
87cdf0e10cSrcweir         throw pException;
88cdf0e10cSrcweir     }
89cdf0e10cSrcweir     // create system parent data
90cdf0e10cSrcweir 	SystemParentData aSysParentData;
91cdf0e10cSrcweir 	aSysParentData.nSize = sizeof ( SystemParentData );
92cdf0e10cSrcweir #if defined( WNT ) || defined ( OS2 )
93cdf0e10cSrcweir 	aSysParentData.hWnd = (HWND) nHandle;
94cdf0e10cSrcweir #elif defined( QUARTZ )
95cdf0e10cSrcweir 	aSysParentData.pView = reinterpret_cast<NSView*>(nHandle);
96cdf0e10cSrcweir #elif defined( UNX )
97cdf0e10cSrcweir 	aSysParentData.aWindow = (long)nHandle;
98cdf0e10cSrcweir     aSysParentData.bXEmbedSupport = bXEmbed;
99cdf0e10cSrcweir #endif
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 	// set system parent
102cdf0e10cSrcweir 	((WorkWindow*)pWindow)->SetPluginParent( &aSysParentData );
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
105