Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / toolkit / source / awt / vclxwindow1.cxx
bloba3dba99b38e61e7be6898a08b0e42e2a11e6e8bb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <toolkit/awt/vclxwindow.hxx>
31 #include <com/sun/star/beans/NamedValue.hpp>
32 #ifndef _SV_WORKWIN
33 #include <vcl/wrkwin.hxx>
34 #endif
35 #include <vcl/window.hxx>
37 #ifdef WNT
38 #include <prewin.h>
39 #include <postwin.h>
40 #elif defined ( QUARTZ )
41 #include "premac.h"
42 #include <Cocoa/Cocoa.h>
43 #include "postmac.h"
44 #elif defined ( IOS )
45 #include "premac.h"
46 #include <UIKit/UIKit.h>
47 #include "postmac.h"
48 #endif
49 #include <vcl/sysdata.hxx>
51 /// helper method to set a window handle into a SystemParentData struct
52 void VCLXWindow::SetSystemParent_Impl( const com::sun::star::uno::Any& rHandle )
54 // does only work for WorkWindows
55 Window *pWindow = GetWindow();
56 if ( pWindow->GetType() != WINDOW_WORKWINDOW )
58 ::com::sun::star::uno::Exception *pException =
59 new ::com::sun::star::uno::RuntimeException;
60 pException->Message = ::rtl::OUString("not a work window");
61 throw pException;
64 // use sal_Int64 here to accomodate all int types
65 // uno::Any shift operator whill upcast if necessary
66 sal_Int64 nHandle = 0;
67 sal_Bool bXEmbed = sal_False;
68 bool bThrow = false;
69 if( ! (rHandle >>= nHandle) )
71 com::sun::star::uno::Sequence< com::sun::star::beans::NamedValue > aProps;
72 if( rHandle >>= aProps )
74 const int nProps = aProps.getLength();
75 const com::sun::star::beans::NamedValue* pProps = aProps.getConstArray();
76 for( int i = 0; i < nProps; i++ )
78 if ( pProps[i].Name == "WINDOW" )
79 pProps[i].Value >>= nHandle;
80 else if ( pProps[i].Name == "XEMBED" )
81 pProps[i].Value >>= bXEmbed;
84 else
85 bThrow = true;
87 if( bThrow )
89 ::com::sun::star::uno::Exception *pException =
90 new ::com::sun::star::uno::RuntimeException;
91 pException->Message = ::rtl::OUString("incorrect window handle type");
92 throw pException;
94 // create system parent data
95 SystemParentData aSysParentData;
96 aSysParentData.nSize = sizeof ( SystemParentData );
97 #if defined( WNT )
98 aSysParentData.hWnd = (HWND) nHandle;
99 #elif defined( QUARTZ )
100 aSysParentData.pView = reinterpret_cast<NSView*>(nHandle);
101 #elif defined( IOS )
102 aSysParentData.pView = reinterpret_cast<UIView*>(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 );
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */