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 : #ifndef _SV_WORKWIN
24 : #include <vcl/wrkwin.hxx>
25 : #endif
26 : #include <vcl/window.hxx>
27 :
28 : #ifdef WNT
29 : #include <prewin.h>
30 : #include <postwin.h>
31 : #elif defined ( QUARTZ )
32 : #include "premac.h"
33 : #include <Cocoa/Cocoa.h>
34 : #include "postmac.h"
35 : #elif defined ( IOS )
36 : #include "premac.h"
37 : #include <UIKit/UIKit.h>
38 : #include "postmac.h"
39 : #endif
40 : #include <vcl/sysdata.hxx>
41 :
42 : /// helper method to set a window handle into a SystemParentData struct
43 0 : void VCLXWindow::SetSystemParent_Impl( const com::sun::star::uno::Any& rHandle )
44 : {
45 : // does only work for WorkWindows
46 0 : Window *pWindow = GetWindow();
47 0 : if ( pWindow->GetType() != WINDOW_WORKWINDOW )
48 : {
49 : ::com::sun::star::uno::Exception *pException =
50 0 : new ::com::sun::star::uno::RuntimeException;
51 0 : pException->Message = ::rtl::OUString("not a work window");
52 0 : throw pException;
53 : }
54 :
55 : // use sal_Int64 here to accomodate all int types
56 : // uno::Any shift operator whill upcast if necessary
57 0 : sal_Int64 nHandle = 0;
58 0 : sal_Bool bXEmbed = sal_False;
59 0 : bool bThrow = false;
60 0 : if( ! (rHandle >>= nHandle) )
61 : {
62 0 : com::sun::star::uno::Sequence< com::sun::star::beans::NamedValue > aProps;
63 0 : if( rHandle >>= aProps )
64 : {
65 0 : const int nProps = aProps.getLength();
66 0 : const com::sun::star::beans::NamedValue* pProps = aProps.getConstArray();
67 0 : for( int i = 0; i < nProps; i++ )
68 : {
69 0 : if ( pProps[i].Name == "WINDOW" )
70 0 : pProps[i].Value >>= nHandle;
71 0 : else if ( pProps[i].Name == "XEMBED" )
72 0 : pProps[i].Value >>= bXEmbed;
73 : }
74 : }
75 : else
76 0 : bThrow = true;
77 : }
78 0 : if( bThrow )
79 : {
80 : ::com::sun::star::uno::Exception *pException =
81 0 : new ::com::sun::star::uno::RuntimeException;
82 0 : pException->Message = ::rtl::OUString("incorrect window handle type");
83 0 : throw pException;
84 : }
85 : // create system parent data
86 : SystemParentData aSysParentData;
87 0 : aSysParentData.nSize = sizeof ( SystemParentData );
88 : #if defined( WNT )
89 : aSysParentData.hWnd = (HWND) nHandle;
90 : #elif defined( QUARTZ )
91 : aSysParentData.pView = reinterpret_cast<NSView*>(nHandle);
92 : #elif defined( IOS )
93 : aSysParentData.pView = reinterpret_cast<UIView*>(nHandle);
94 : #elif defined( UNX )
95 0 : aSysParentData.aWindow = (long)nHandle;
96 0 : aSysParentData.bXEmbedSupport = bXEmbed;
97 : #endif
98 :
99 : // set system parent
100 0 : ((WorkWindow*)pWindow)->SetPluginParent( &aSysParentData );
101 0 : }
102 :
103 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|