Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / toolkit / source / awt / vclxwindow1.cxx
blob7b7b7192f9dbf8b72aae68d59c96eda6bc22cbf9
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 .
20 #include <toolkit/awt/vclxwindow.hxx>
21 #include <com/sun/star/beans/NamedValue.hpp>
22 #include <vcl/wrkwin.hxx>
23 #include <vcl/window.hxx>
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>
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";
44 throw aException;
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))
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;
65 else
66 bThrow = true;
68 if (bThrow)
70 css::uno::RuntimeException aException;
71 aException.Message = "incorrect window handle type";
72 throw aException;
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
90 // set system parent
91 static_cast<WorkWindow*>(pWindow.get())->SetPluginParent(&aSysParentData);
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */