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 .
20 #include <toolkit/awt/vclxwindow.hxx>
21 #include <com/sun/star/beans/NamedValue.hpp>
22 #include <vcl/wrkwin.hxx>
23 #include <vcl/window.hxx>
30 #include <Cocoa/Cocoa.h>
33 #include <vcl/sysdata.hxx>
35 /// helper method to set a window handle into a SystemParentData struct
36 void VCLXWindow::SetSystemParent_Impl(const css::uno::Any
& rHandle
)
38 // does only work for WorkWindows
39 VclPtr
<vcl::Window
> pWindow
= GetWindow();
40 if (pWindow
->GetType() != WindowType::WORKWINDOW
)
42 css::uno::RuntimeException aException
;
43 aException
.Message
= "not a work window";
47 // use sal_Int64 here to accommodate all int types
48 // uno::Any shift operator will upcast if necessary
49 sal_Int64 nHandle
= 0;
52 if (!(rHandle
>>= nHandle
))
54 css::uno::Sequence
<css::beans::NamedValue
> aProps
;
55 if (rHandle
>>= aProps
)
57 for (const css::beans::NamedValue
& rProp
: std::as_const(aProps
))
59 if (rProp
.Name
== "WINDOW")
60 rProp
.Value
>>= nHandle
;
61 else if (rProp
.Name
== "XEMBED")
62 rProp
.Value
>>= bXEmbed
;
70 css::uno::RuntimeException aException
;
71 aException
.Message
= "incorrect window handle type";
74 // create system parent data
75 SystemParentData aSysParentData
;
76 aSysParentData
.nSize
= sizeof(SystemParentData
);
78 aSysParentData
.hWnd
= reinterpret_cast<HWND
>(nHandle
);
80 aSysParentData
.pView
= reinterpret_cast<NSView
*>(nHandle
);
81 #elif defined(ANDROID)
86 aSysParentData
.aWindow
= nHandle
;
87 aSysParentData
.bXEmbedSupport
= bXEmbed
;
91 static_cast<WorkWindow
*>(pWindow
.get())->SetPluginParent(&aSysParentData
);
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */