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