1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
29 #elif defined ( MACOSX )
31 #include <Cocoa/Cocoa.h>
34 #include <vcl/sysdata.hxx>
36 /// helper method to set a window handle into a SystemParentData struct
37 void VCLXWindow::SetSystemParent_Impl( const css::uno::Any
& rHandle
)
39 // does only work for WorkWindows
40 VclPtr
<vcl::Window
> pWindow
= GetWindow();
41 if ( pWindow
->GetType() != WindowType::WORKWINDOW
)
43 css::uno::RuntimeException aException
;
44 aException
.Message
= "not a work window";
48 // use sal_Int64 here to accommodate all int types
49 // uno::Any shift operator whill upcast if necessary
50 sal_Int64 nHandle
= 0;
53 if( ! (rHandle
>>= nHandle
) )
55 css::uno::Sequence
< css::beans::NamedValue
> aProps
;
56 if( rHandle
>>= aProps
)
58 const int nProps
= aProps
.getLength();
59 const css::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
;
73 css::uno::RuntimeException aException
;
74 aException
.Message
= "incorrect window handle type";
77 // create system parent data
78 SystemParentData aSysParentData
;
79 aSysParentData
.nSize
= sizeof ( SystemParentData
);
81 aSysParentData
.hWnd
= reinterpret_cast<HWND
>(nHandle
);
82 #elif defined( MACOSX )
83 aSysParentData
.pView
= reinterpret_cast<NSView
*>(nHandle
);
84 #elif defined( ANDROID )
89 aSysParentData
.aWindow
= static_cast<long>(nHandle
);
90 aSysParentData
.bXEmbedSupport
= bXEmbed
;
94 static_cast<WorkWindow
*>(pWindow
.get())->SetPluginParent( &aSysParentData
);
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */