Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
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.
15 : : *
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).
21 : : *
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.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <toolkit/awt/vclxwindow.hxx>
31 : : #include <com/sun/star/beans/NamedValue.hpp>
32 : : #ifndef _SV_WORKWIN
33 : : #include <vcl/wrkwin.hxx>
34 : : #endif
35 : : #include <vcl/window.hxx>
36 : :
37 : : #ifdef WNT
38 : : #include <prewin.h>
39 : : #include <postwin.h>
40 : : #elif defined ( QUARTZ )
41 : : #include "premac.h"
42 : : #include <Cocoa/Cocoa.h>
43 : : #include "postmac.h"
44 : : #elif defined ( IOS )
45 : : #include "premac.h"
46 : : #include <UIKit/UIKit.h>
47 : : #include "postmac.h"
48 : : #endif
49 : : #include <vcl/sysdata.hxx>
50 : :
51 : : /// helper method to set a window handle into a SystemParentData struct
52 : 0 : void VCLXWindow::SetSystemParent_Impl( const com::sun::star::uno::Any& rHandle )
53 : : {
54 : : // does only work for WorkWindows
55 : 0 : Window *pWindow = GetWindow();
56 [ # # ][ # # ]: 0 : if ( pWindow->GetType() != WINDOW_WORKWINDOW )
57 : : {
58 : : ::com::sun::star::uno::Exception *pException =
59 [ # # ][ # # ]: 0 : new ::com::sun::star::uno::RuntimeException;
60 : 0 : pException->Message = ::rtl::OUString("not a work window");
61 : 0 : throw pException;
62 : : }
63 : :
64 : : // use sal_Int64 here to accomodate all int types
65 : : // uno::Any shift operator whill upcast if necessary
66 : 0 : sal_Int64 nHandle = 0;
67 : 0 : sal_Bool bXEmbed = sal_False;
68 : 0 : bool bThrow = false;
69 [ # # ]: 0 : if( ! (rHandle >>= nHandle) )
70 : : {
71 [ # # ]: 0 : com::sun::star::uno::Sequence< com::sun::star::beans::NamedValue > aProps;
72 [ # # ][ # # ]: 0 : if( rHandle >>= aProps )
73 : : {
74 : 0 : const int nProps = aProps.getLength();
75 : 0 : const com::sun::star::beans::NamedValue* pProps = aProps.getConstArray();
76 [ # # ]: 0 : for( int i = 0; i < nProps; i++ )
77 : : {
78 [ # # ]: 0 : if ( pProps[i].Name == "WINDOW" )
79 : 0 : pProps[i].Value >>= nHandle;
80 [ # # ]: 0 : else if ( pProps[i].Name == "XEMBED" )
81 : 0 : pProps[i].Value >>= bXEmbed;
82 : : }
83 : : }
84 : : else
85 [ # # ]: 0 : bThrow = true;
86 : : }
87 [ # # ]: 0 : if( bThrow )
88 : : {
89 : : ::com::sun::star::uno::Exception *pException =
90 [ # # ][ # # ]: 0 : new ::com::sun::star::uno::RuntimeException;
91 : 0 : pException->Message = ::rtl::OUString("incorrect window handle type");
92 : 0 : throw pException;
93 : : }
94 : : // create system parent data
95 : : SystemParentData aSysParentData;
96 : 0 : aSysParentData.nSize = sizeof ( SystemParentData );
97 : : #if defined( WNT )
98 : : aSysParentData.hWnd = (HWND) nHandle;
99 : : #elif defined( QUARTZ )
100 : : aSysParentData.pView = reinterpret_cast<NSView*>(nHandle);
101 : : #elif defined( IOS )
102 : : aSysParentData.pView = reinterpret_cast<UIView*>(nHandle);
103 : : #elif defined( UNX )
104 : 0 : aSysParentData.aWindow = (long)nHandle;
105 : 0 : aSysParentData.bXEmbedSupport = bXEmbed;
106 : : #endif
107 : :
108 : : // set system parent
109 [ # # ]: 0 : ((WorkWindow*)pWindow)->SetPluginParent( &aSysParentData );
110 : 0 : }
111 : :
112 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|