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 .
21 #include <toolkit/awt/vclxwindow.hxx>
22 #include <com/sun/star/beans/NamedValue.hpp>
24 #include <vcl/wrkwin.hxx>
26 #include <vcl/window.hxx>
31 #elif defined ( QUARTZ )
33 #include <Cocoa/Cocoa.h>
37 #include <UIKit/UIKit.h>
40 #include <vcl/sysdata.hxx>
42 /// helper method to set a window handle into a SystemParentData struct
43 void VCLXWindow::SetSystemParent_Impl( const com::sun::star::uno::Any
& rHandle
)
45 // does only work for WorkWindows
46 Window
*pWindow
= GetWindow();
47 if ( pWindow
->GetType() != WINDOW_WORKWINDOW
)
49 ::com::sun::star::uno::Exception
*pException
=
50 new ::com::sun::star::uno::RuntimeException
;
51 pException
->Message
= ::rtl::OUString("not a work window");
55 // use sal_Int64 here to accomodate all int types
56 // uno::Any shift operator whill upcast if necessary
57 sal_Int64 nHandle
= 0;
58 sal_Bool bXEmbed
= sal_False
;
60 if( ! (rHandle
>>= nHandle
) )
62 com::sun::star::uno::Sequence
< com::sun::star::beans::NamedValue
> aProps
;
63 if( rHandle
>>= aProps
)
65 const int nProps
= aProps
.getLength();
66 const com::sun::star::beans::NamedValue
* pProps
= aProps
.getConstArray();
67 for( int i
= 0; i
< nProps
; i
++ )
69 if ( pProps
[i
].Name
== "WINDOW" )
70 pProps
[i
].Value
>>= nHandle
;
71 else if ( pProps
[i
].Name
== "XEMBED" )
72 pProps
[i
].Value
>>= bXEmbed
;
80 ::com::sun::star::uno::Exception
*pException
=
81 new ::com::sun::star::uno::RuntimeException
;
82 pException
->Message
= ::rtl::OUString("incorrect window handle type");
85 // create system parent data
86 SystemParentData aSysParentData
;
87 aSysParentData
.nSize
= sizeof ( SystemParentData
);
89 aSysParentData
.hWnd
= (HWND
) nHandle
;
90 #elif defined( QUARTZ )
91 aSysParentData
.pView
= reinterpret_cast<NSView
*>(nHandle
);
93 aSysParentData
.pView
= reinterpret_cast<UIView
*>(nHandle
);
95 aSysParentData
.aWindow
= (long)nHandle
;
96 aSysParentData
.bXEmbedSupport
= bXEmbed
;
100 ((WorkWindow
*)pWindow
)->SetPluginParent( &aSysParentData
);
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */