lwp build fixes
[LibreOffice.git] / toolkit / source / awt / vclxwindow1.cxx
blob46b2e72be8833947b7897152e69c135f097d5a09
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 #include <vcl/wrkwin.hxx>
24 #include <vcl/window.hxx>
26 #ifdef WNT
27 #include <prewin.h>
28 #include <postwin.h>
29 #elif defined ( MACOSX )
30 #include "premac.h"
31 #include <Cocoa/Cocoa.h>
32 #include "postmac.h"
33 #endif
34 #include <vcl/sysdata.hxx>
36 /// helper method to set a window handle into a SystemParentData struct
37 void VCLXWindow::SetSystemParent_Impl( const com::sun::star::uno::Any& rHandle )
39 // does only work for WorkWindows
40 vcl::Window *pWindow = GetWindow();
41 if ( pWindow->GetType() != WINDOW_WORKWINDOW )
43 com::sun::star::uno::RuntimeException aException;
44 aException.Message = "not a work window";
45 throw aException;
48 // use sal_Int64 here to accommodate all int types
49 // uno::Any shift operator whill upcast if necessary
50 sal_Int64 nHandle = 0;
51 bool bXEmbed = false;
52 bool bThrow = false;
53 if( ! (rHandle >>= nHandle) )
55 com::sun::star::uno::Sequence< com::sun::star::beans::NamedValue > aProps;
56 if( rHandle >>= aProps )
58 const int nProps = aProps.getLength();
59 const com::sun::star::beans::NamedValue* pProps = aProps.getConstArray();
60 for( int i = 0; i < nProps; i++ )
62 if ( pProps[i].Name == "WINDOW" )
63 pProps[i].Value >>= nHandle;
64 else if ( pProps[i].Name == "XEMBED" )
65 pProps[i].Value >>= bXEmbed;
68 else
69 bThrow = true;
71 if( bThrow )
73 com::sun::star::uno::RuntimeException aException;
74 aException.Message = "incorrect window handle type";
75 throw aException;
77 // create system parent data
78 SystemParentData aSysParentData;
79 aSysParentData.nSize = sizeof ( SystemParentData );
80 #if defined( WNT )
81 aSysParentData.hWnd = (HWND) nHandle;
82 #elif defined( MACOSX )
83 aSysParentData.pView = reinterpret_cast<NSView*>(nHandle);
84 #elif defined( ANDROID )
85 // Nothing
86 #elif defined( IOS )
87 // Nothing
88 #elif defined( UNX )
89 aSysParentData.aWindow = (long)nHandle;
90 aSysParentData.bXEmbedSupport = bXEmbed;
91 #endif
93 // set system parent
94 static_cast<WorkWindow*>(pWindow)->SetPluginParent( &aSysParentData );
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */