Line data Source code
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 :
20 :
21 : #include <toolkit/awt/vclxwindow.hxx>
22 : #include <com/sun/star/beans/NamedValue.hpp>
23 : #include <vcl/wrkwin.hxx>
24 : #include <vcl/window.hxx>
25 :
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>
35 :
36 : /// helper method to set a window handle into a SystemParentData struct
37 0 : void VCLXWindow::SetSystemParent_Impl( const com::sun::star::uno::Any& rHandle )
38 : {
39 : // does only work for WorkWindows
40 0 : Window *pWindow = GetWindow();
41 0 : if ( pWindow->GetType() != WINDOW_WORKWINDOW )
42 : {
43 0 : com::sun::star::uno::RuntimeException aException;
44 0 : aException.Message = "not a work window";
45 0 : throw aException;
46 : }
47 :
48 : // use sal_Int64 here to accommodate all int types
49 : // uno::Any shift operator whill upcast if necessary
50 0 : sal_Int64 nHandle = 0;
51 0 : bool bXEmbed = false;
52 0 : bool bThrow = false;
53 0 : if( ! (rHandle >>= nHandle) )
54 : {
55 0 : com::sun::star::uno::Sequence< com::sun::star::beans::NamedValue > aProps;
56 0 : if( rHandle >>= aProps )
57 : {
58 0 : const int nProps = aProps.getLength();
59 0 : const com::sun::star::beans::NamedValue* pProps = aProps.getConstArray();
60 0 : for( int i = 0; i < nProps; i++ )
61 : {
62 0 : if ( pProps[i].Name == "WINDOW" )
63 0 : pProps[i].Value >>= nHandle;
64 0 : else if ( pProps[i].Name == "XEMBED" )
65 0 : pProps[i].Value >>= bXEmbed;
66 : }
67 : }
68 : else
69 0 : bThrow = true;
70 : }
71 0 : if( bThrow )
72 : {
73 0 : com::sun::star::uno::Exception aException;
74 0 : aException.Message = "incorrect window handle type";
75 0 : throw aException;
76 : }
77 : // create system parent data
78 : SystemParentData aSysParentData;
79 0 : 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 0 : aSysParentData.aWindow = (long)nHandle;
90 0 : aSysParentData.bXEmbedSupport = bXEmbed;
91 : #endif
92 :
93 : // set system parent
94 0 : ((WorkWindow*)pWindow)->SetPluginParent( &aSysParentData );
95 0 : }
96 :
97 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|