update dev300-m58
[ooovba.git] / toolkit / source / awt / vclxwindow1.cxx
blob9ddd90eed379e246d10e7ba15251ae524d57f340
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: vclxwindow1.cxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_toolkit.hxx"
34 #include <tools/svwin.h>
35 #include <toolkit/awt/vclxwindow.hxx>
36 #include <com/sun/star/beans/NamedValue.hpp>
37 #ifndef _SV_WORKWIN
38 #include <vcl/wrkwin.hxx>
39 #endif
40 #include <vcl/window.hxx>
42 #ifdef WNT
43 #include <tools/prewin.h>
44 #include <windows.h>
45 #include <tools/postwin.h>
46 #elif defined ( QUARTZ )
47 #include "premac.h"
48 #include <Cocoa/Cocoa.h>
49 #include "postmac.h"
50 #endif
51 #include <vcl/sysdata.hxx>
53 /// helper method to set a window handle into a SystemParentData struct
54 void VCLXWindow::SetSystemParent_Impl( const com::sun::star::uno::Any& rHandle )
56 // does only work for WorkWindows
57 Window *pWindow = GetWindow();
58 if ( pWindow->GetType() != WINDOW_WORKWINDOW )
60 ::com::sun::star::uno::Exception *pException =
61 new ::com::sun::star::uno::RuntimeException;
62 pException->Message = ::rtl::OUString::createFromAscii( "not a work window" );
63 throw pException;
66 // use sal_Int64 here to accomodate all int types
67 // uno::Any shift operator whill upcast if necessary
68 sal_Int64 nHandle = 0;
69 sal_Bool bXEmbed = sal_False;
70 bool bThrow = false;
71 if( ! (rHandle >>= nHandle) )
73 com::sun::star::uno::Sequence< com::sun::star::beans::NamedValue > aProps;
74 if( rHandle >>= aProps )
76 const int nProps = aProps.getLength();
77 const com::sun::star::beans::NamedValue* pProps = aProps.getConstArray();
78 for( int i = 0; i < nProps; i++ )
80 if( pProps[i].Name.equalsAscii( "WINDOW" ) )
81 pProps[i].Value >>= nHandle;
82 else if( pProps[i].Name.equalsAscii( "XEMBED" ) )
83 pProps[i].Value >>= bXEmbed;
86 else
87 bThrow = true;
89 if( bThrow )
91 ::com::sun::star::uno::Exception *pException =
92 new ::com::sun::star::uno::RuntimeException;
93 pException->Message = ::rtl::OUString::createFromAscii( "incorrect window handle type" );
94 throw pException;
96 // create system parent data
97 SystemParentData aSysParentData;
98 aSysParentData.nSize = sizeof ( SystemParentData );
99 #if defined( WIN ) || defined( WNT ) || defined ( OS2 )
100 aSysParentData.hWnd = (HWND) nHandle;
101 #elif defined( QUARTZ )
102 aSysParentData.pView = reinterpret_cast<NSView*>(nHandle);
103 #elif defined( UNX )
104 aSysParentData.aWindow = (long)nHandle;
105 aSysParentData.bXEmbedSupport = bXEmbed;
106 #endif
108 // set system parent
109 ((WorkWindow*)pWindow)->SetPluginParent( &aSysParentData );