xref: /trunk/main/toolkit/source/awt/vclxwindow1.cxx (revision b3897e6aa10c44e4a3a28a6e1f45e38816be3d7f)
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
10cdf0e10cSrcweir  *
11b0724fc6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
20b0724fc6SAndrew Rist  *************************************************************/
21b0724fc6SAndrew Rist 
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_toolkit.hxx"
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #include <tools/svwin.h>
26cdf0e10cSrcweir #include <toolkit/awt/vclxwindow.hxx>
27cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp>
28cdf0e10cSrcweir #ifndef _SV_WORKWIN
29cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir #include <vcl/window.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #ifdef WNT
34cdf0e10cSrcweir #include <tools/prewin.h>
35cdf0e10cSrcweir #include <windows.h>
36cdf0e10cSrcweir #include <tools/postwin.h>
3727ead02aSPedro Giffuni #elif defined ( OS2 )
3827ead02aSPedro Giffuni #include <svpm.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 
46*b3897e6aSmseidel // helper method to set a window handle into a SystemParentData struct
SetSystemParent_Impl(const com::sun::star::uno::Any & rHandle)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 
5986e1cf34SPedro Giffuni     // use sal_Int64 here to accommodate all int types
60cdfa2a0eSJohn Bampton     // uno::Any shift operator will 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 }
104*b3897e6aSmseidel 
105*b3897e6aSmseidel /* vim: set noet sw=4 ts=4: */
106