1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <toolkit/awt/vclxwindow.hxx>
31 #include <com/sun/star/beans/NamedValue.hpp>
33 #include <vcl/wrkwin.hxx>
35 #include <vcl/window.hxx>
40 #elif defined ( QUARTZ )
42 #include <Cocoa/Cocoa.h>
46 #include <UIKit/UIKit.h>
49 #include <vcl/sysdata.hxx>
51 /// helper method to set a window handle into a SystemParentData struct
52 void VCLXWindow::SetSystemParent_Impl( const com::sun::star::uno::Any
& rHandle
)
54 // does only work for WorkWindows
55 Window
*pWindow
= GetWindow();
56 if ( pWindow
->GetType() != WINDOW_WORKWINDOW
)
58 ::com::sun::star::uno::Exception
*pException
=
59 new ::com::sun::star::uno::RuntimeException
;
60 pException
->Message
= ::rtl::OUString("not a work window");
64 // use sal_Int64 here to accomodate all int types
65 // uno::Any shift operator whill upcast if necessary
66 sal_Int64 nHandle
= 0;
67 sal_Bool bXEmbed
= sal_False
;
69 if( ! (rHandle
>>= nHandle
) )
71 com::sun::star::uno::Sequence
< com::sun::star::beans::NamedValue
> aProps
;
72 if( rHandle
>>= aProps
)
74 const int nProps
= aProps
.getLength();
75 const com::sun::star::beans::NamedValue
* pProps
= aProps
.getConstArray();
76 for( int i
= 0; i
< nProps
; i
++ )
78 if ( pProps
[i
].Name
== "WINDOW" )
79 pProps
[i
].Value
>>= nHandle
;
80 else if ( pProps
[i
].Name
== "XEMBED" )
81 pProps
[i
].Value
>>= bXEmbed
;
89 ::com::sun::star::uno::Exception
*pException
=
90 new ::com::sun::star::uno::RuntimeException
;
91 pException
->Message
= ::rtl::OUString("incorrect window handle type");
94 // create system parent data
95 SystemParentData aSysParentData
;
96 aSysParentData
.nSize
= sizeof ( SystemParentData
);
98 aSysParentData
.hWnd
= (HWND
) nHandle
;
99 #elif defined( QUARTZ )
100 aSysParentData
.pView
= reinterpret_cast<NSView
*>(nHandle
);
102 aSysParentData
.pView
= reinterpret_cast<UIView
*>(nHandle
);
104 aSysParentData
.aWindow
= (long)nHandle
;
105 aSysParentData
.bXEmbedSupport
= bXEmbed
;
109 ((WorkWindow
*)pWindow
)->SetPluginParent( &aSysParentData
);
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */