Version 4.0.2.1, tag libreoffice-4.0.2.1
[LibreOffice.git] / toolkit / source / awt / vclxwindow1.cxx
blobf38a95cb6dda973896355fb401ecf18bea6bedb3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <toolkit/awt/vclxwindow.hxx>
22 #include <com/sun/star/beans/NamedValue.hpp>
23 #ifndef _SV_WORKWIN
24 #include <vcl/wrkwin.hxx>
25 #endif
26 #include <vcl/window.hxx>
28 #ifdef WNT
29 #include <prewin.h>
30 #include <postwin.h>
31 #elif defined ( QUARTZ )
32 #include "premac.h"
33 #include <Cocoa/Cocoa.h>
34 #include "postmac.h"
35 #elif defined ( IOS )
36 #include "premac.h"
37 #include <UIKit/UIKit.h>
38 #include "postmac.h"
39 #endif
40 #include <vcl/sysdata.hxx>
42 /// helper method to set a window handle into a SystemParentData struct
43 void VCLXWindow::SetSystemParent_Impl( const com::sun::star::uno::Any& rHandle )
45 // does only work for WorkWindows
46 Window *pWindow = GetWindow();
47 if ( pWindow->GetType() != WINDOW_WORKWINDOW )
49 ::com::sun::star::uno::Exception *pException =
50 new ::com::sun::star::uno::RuntimeException;
51 pException->Message = ::rtl::OUString("not a work window");
52 throw pException;
55 // use sal_Int64 here to accomodate all int types
56 // uno::Any shift operator whill upcast if necessary
57 sal_Int64 nHandle = 0;
58 sal_Bool bXEmbed = sal_False;
59 bool bThrow = false;
60 if( ! (rHandle >>= nHandle) )
62 com::sun::star::uno::Sequence< com::sun::star::beans::NamedValue > aProps;
63 if( rHandle >>= aProps )
65 const int nProps = aProps.getLength();
66 const com::sun::star::beans::NamedValue* pProps = aProps.getConstArray();
67 for( int i = 0; i < nProps; i++ )
69 if ( pProps[i].Name == "WINDOW" )
70 pProps[i].Value >>= nHandle;
71 else if ( pProps[i].Name == "XEMBED" )
72 pProps[i].Value >>= bXEmbed;
75 else
76 bThrow = true;
78 if( bThrow )
80 ::com::sun::star::uno::Exception *pException =
81 new ::com::sun::star::uno::RuntimeException;
82 pException->Message = ::rtl::OUString("incorrect window handle type");
83 throw pException;
85 // create system parent data
86 SystemParentData aSysParentData;
87 aSysParentData.nSize = sizeof ( SystemParentData );
88 #if defined( WNT )
89 aSysParentData.hWnd = (HWND) nHandle;
90 #elif defined( QUARTZ )
91 aSysParentData.pView = reinterpret_cast<NSView*>(nHandle);
92 #elif defined( IOS )
93 aSysParentData.pView = reinterpret_cast<UIView*>(nHandle);
94 #elif defined( UNX )
95 aSysParentData.aWindow = (long)nHandle;
96 aSysParentData.bXEmbedSupport = bXEmbed;
97 #endif
99 // set system parent
100 ((WorkWindow*)pWindow)->SetPluginParent( &aSysParentData );
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */