LibreOffice Module toolkit (master) 1
vclxwindow1.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
21#include <com/sun/star/beans/NamedValue.hpp>
22#include <vcl/wrkwin.hxx>
23#include <vcl/window.hxx>
24
25#ifdef _WIN32
26#include <prewin.h>
27#include <postwin.h>
28#elif defined(MACOSX)
29#include <premac.h>
30#include <Cocoa/Cocoa.h>
31#include <postmac.h>
32#endif
33#include <vcl/sysdata.hxx>
34
36void VCLXWindow::SetSystemParent_Impl(const css::uno::Any& rHandle)
37{
38 // does only work for WorkWindows
40 if (pWindow->GetType() != WindowType::WORKWINDOW)
41 {
42 css::uno::RuntimeException aException;
43 aException.Message = "not a work window";
44 throw aException;
45 }
46
47 // use sal_Int64 here to accommodate all int types
48 // uno::Any shift operator will upcast if necessary
49 sal_Int64 nHandle = 0;
50 bool bXEmbed = false;
51 bool bThrow = false;
52 if (!(rHandle >>= nHandle))
53 {
54 css::uno::Sequence<css::beans::NamedValue> aProps;
55 if (rHandle >>= aProps)
56 {
57 for (const css::beans::NamedValue& rProp : std::as_const(aProps))
58 {
59 if (rProp.Name == "WINDOW")
60 rProp.Value >>= nHandle;
61 else if (rProp.Name == "XEMBED")
62 rProp.Value >>= bXEmbed;
63 }
64 }
65 else
66 bThrow = true;
67 }
68 if (bThrow)
69 {
70 css::uno::RuntimeException aException;
71 aException.Message = "incorrect window handle type";
72 throw aException;
73 }
74 // create system parent data
75 SystemParentData aSysParentData;
76 aSysParentData.nSize = sizeof(SystemParentData);
77#if defined(_WIN32)
78 aSysParentData.hWnd = reinterpret_cast<HWND>(nHandle);
79#elif defined(MACOSX)
80 aSysParentData.pView = reinterpret_cast<NSView*>(nHandle);
81#elif defined(ANDROID)
82 // Nothing
83#elif defined(IOS)
84 // Nothing
85#elif defined(UNX)
86 aSysParentData.aWindow = nHandle;
87 aSysParentData.bXEmbedSupport = bXEmbed;
88#endif
89
90 // set system parent
91 static_cast<WorkWindow*>(pWindow.get())->SetPluginParent(&aSysParentData);
92}
93
94/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
vcl::Window * GetWindow() const
Definition: vclxwindow.hxx:131
void SetSystemParent_Impl(const css::uno::Any &rHandle)
helper method to set a window handle into a SystemParentData struct
Definition: vclxwindow1.cxx:36
reference_type * get() const
sal_Int32 nHandle
sal_uInt32 nSize
sal_uIntPtr aWindow